@libp2p/mdns 11.0.23 → 11.0.24
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/package.json +8 -8
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 Ks=Object.create;var dr=Object.defineProperty;var qs=Object.getOwnPropertyDescriptor;var zs=Object.getOwnPropertyNames;var Vs=Object.getPrototypeOf,Hs=Object.prototype.hasOwnProperty;var ne=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var ve=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ie=(r,e)=>{for(var t in e)dr(r,t,{get:e[t],enumerable:!0})},Di=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of zs(e))!Hs.call(r,i)&&i!==t&&dr(r,i,{get:()=>e[i],enumerable:!(n=qs(e,i))||n.enumerable});return r};var Ut=(r,e,t)=>(t=r!=null?Ks(Vs(r)):{},Di(e||!r||!r.__esModule?dr(t,"default",{value:r,enumerable:!0}):t,r)),js=r=>Di(dr({},"__esModule",{value:!0}),r);var Ki=ve(Zr=>{"use strict";Zr.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};Zr.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return r.toUpperCase().startsWith("UNKNOWN_")?parseInt(r.slice(8)):0}});var qi=ve(Qr=>{"use strict";Qr.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};Qr.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var zi=ve(Jr=>{"use strict";Jr.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};Jr.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var Vi=ve(en=>{"use strict";en.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};en.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Hi=ve(tn=>{"use strict";tn.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return r<0?null:`OPTION_${r}`};tn.toCode=function(r){if(typeof r=="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=r.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var Gi=ve(($i,rn)=>{var ji=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=l,r.encode=m,r.familyOf=d,r.name=void 0,r.sizeOf=c,r.v6=r.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,t=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:t,isFormat:u=>e.test(u),encode(u,p,h){h=~~h,p=p||new Uint8Array(h+t);let y=u.length,g=0;for(let f=0;f<y;){let x=u.charCodeAt(f++);x===46?(p[h++]=g,g=0):g=g*10+(x-48)}return p[h]=g,p},decode(u,p){return p=~~p,`${u[p++]}.${u[p++]}.${u[p++]}.${u[p]}`}};r.v4=o;let s={name:"v6",size:i,isFormat:u=>u.length>0&&n.test(u),encode(u,p,h){h=~~h;let y=h+i,g=-1,f=0,x=0,b=!0,L=!1;p=p||new Uint8Array(h+i);for(let T=0;T<u.length;T++){let B=u.charCodeAt(T);B===58?(b?g!==-1?(h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2):h<y&&(g=h):(L===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2),f=0,x=0),b=!0,L=!1):B===46?(h<y&&(p[h]=x),h++,x=0,f=0,b=!1,L=!0):(b=!1,B>=97?B-=87:B>=65?B-=55:(B-=48,x=x*10+B),f=(f<<4)+B)}if(b===!1)L===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2);else if(g===0)h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2;else if(g!==-1){h+=2;for(let T=Math.min(h-1,y-1);T>=g+2;T--)p[T]=p[T-2];p[g]=0,p[g+1]=0,g=h}if(g!==h&&g!==-1)for(h>y-2&&(h=y-2);y>g;)p[--y]=h<y&&h>g?p[--h]:0;else for(;h<y;)p[h++]=0;return p},decode(u,p){p=~~p;let h="";for(let y=0;y<i;y+=2)y!==0&&(h+=":"),h+=(u[p+y]<<8|u[p+y+1]).toString(16);return h.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=s;let a="ip";r.name=a;function c(u){if(o.isFormat(u))return o.size;if(s.isFormat(u))return s.size;throw Error(`Invalid ip address: ${u}`)}function d(u){return c(u)===o.size?1:2}function m(u,p,h){h=~~h;let y=c(u);return typeof p=="function"&&(p=p(h+y)),y===o.size?o.encode(u,p,h):s.encode(u,p,h)}function l(u,p,h){if(p=~~p,h=h||u.length-p,h===o.size)return o.decode(u,p,h);if(h===s.size)return s.decode(u,p,h);throw Error(`Invalid buffer size needs to be ${o.size} for v4 or ${s.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return ji}):typeof rn=="object"&&typeof $i=="object"&&(rn.exports=ji)});var Wi=ve(v=>{"use strict";var S=ne("buffer").Buffer,ze=Ki(),$s=qi(),Gs=zi(),gr=Vi(),nn=Hi(),lt=Gi(),Ys=0,Yi=32768,on=32768,Xs=~on,Xi=32768,Ws=~Xi,w=v.name={};w.encode=function(r,e,t,{mail:n=!1}={}){e||(e=S.alloc(w.encodingLength(r))),t||(t=0);let i=t,o=r.replace(/^\.|\.$/gm,"");if(o.length){let s=[];if(n){let a="";o.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=o.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],t+1);e[t]=c,t+=c+1}}return e[t++]=0,w.encode.bytes=t-i,e};w.encode.bytes=0;w.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],i=e,o=0,s=0,a=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let c=r[e++];if(s+=a?0:1,c===0)break;if(c&192)if((c&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let d=r.readUInt16BE(e-1)-49152;if(d>=i)throw new Error("Cannot decode name (bad pointer)");e=d,i=d,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+c>r.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=c+1,o>254)throw new Error("Cannot decode name (name too long)");let d=r.toString("utf-8",e,e+c);t&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=c,s+=a?0:c}}return w.decode.bytes=s,n.length===0?".":n.join(".")};w.decode.bytes=0;w.encodingLength=function(r){return r==="."||r===".."?1:S.byteLength(r.replace(/^\.|\.$/gm,""))+2};var O={};O.encode=function(r,e,t){e||(e=S.alloc(O.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,O.encode.bytes=n+1,e};O.encode.bytes=0;O.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return O.decode.bytes=t+1,n};O.decode.bytes=0;O.encodingLength=function(r){return S.byteLength(r)+1};var Ee={};Ee.encode=function(r,e,t){e||(e=Ee.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?Yi:Ys;return e.writeUInt16BE(r.id||0,t),e.writeUInt16BE(n|i,t+2),e.writeUInt16BE(r.questions.length,t+4),e.writeUInt16BE(r.answers.length,t+6),e.writeUInt16BE(r.authorities.length,t+8),e.writeUInt16BE(r.additionals.length,t+10),e};Ee.encode.bytes=12;Ee.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let t=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:t&Yi?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:Gs.toString(t>>11&15),flag_aa:(t>>10&1)===1,flag_tc:(t>>9&1)===1,flag_rd:(t>>8&1)===1,flag_ra:(t>>7&1)===1,flag_z:(t>>6&1)===1,flag_ad:(t>>5&1)===1,flag_cd:(t>>4&1)===1,rcode:$s.toString(t&15),questions:new Array(r.readUInt16BE(e+4)),answers:new Array(r.readUInt16BE(e+6)),authorities:new Array(r.readUInt16BE(e+8)),additionals:new Array(r.readUInt16BE(e+10))}};Ee.decode.bytes=12;Ee.encodingLength=function(){return 12};var Pe=v.unknown={};Pe.encode=function(r,e,t){return e||(e=S.alloc(Pe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),Pe.encode.bytes=r.length+2,e};Pe.encode.bytes=0;Pe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return Pe.decode.bytes=t+2,n};Pe.decode.bytes=0;Pe.encodingLength=function(r){return r.length+2};var Re=v.ns={};Re.encode=function(r,e,t){return e||(e=S.alloc(Re.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),Re.encode.bytes=w.encode.bytes+2,e};Re.encode.bytes=0;Re.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=w.decode(r,e+2);return Re.decode.bytes=t+2,n};Re.decode.bytes=0;Re.encodingLength=function(r){return w.encodingLength(r)+2};var De=v.soa={};De.encode=function(r,e,t){e||(e=S.alloc(De.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mname,e,t),t+=w.encode.bytes,w.encode(r.rname,e,t,{mail:!0}),t+=w.encode.bytes,e.writeUInt32BE(r.serial||0,t),t+=4,e.writeUInt32BE(r.refresh||0,t),t+=4,e.writeUInt32BE(r.retry||0,t),t+=4,e.writeUInt32BE(r.expire||0,t),t+=4,e.writeUInt32BE(r.minimum||0,t),t+=4,e.writeUInt16BE(t-n-2,n),De.encode.bytes=t-n,e};De.encode.bytes=0;De.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=w.decode(r,e),e+=w.decode.bytes,n.rname=w.decode(r,e,{mail:!0}),e+=w.decode.bytes,n.serial=r.readUInt32BE(e),e+=4,n.refresh=r.readUInt32BE(e),e+=4,n.retry=r.readUInt32BE(e),e+=4,n.expire=r.readUInt32BE(e),e+=4,n.minimum=r.readUInt32BE(e),e+=4,De.decode.bytes=e-t,n};De.decode.bytes=0;De.encodingLength=function(r){return 22+w.encodingLength(r.mname)+w.encodingLength(r.rname)};var ke=v.txt={};ke.encode=function(r,e,t){Array.isArray(r)||(r=[r]);for(let i=0;i<r.length;i++)if(typeof r[i]=="string"&&(r[i]=S.from(r[i])),!S.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=S.alloc(ke.encodingLength(r))),t||(t=0);let n=t;return t+=2,r.forEach(function(i){e[t++]=i.length,i.copy(e,t,0,i.length),t+=i.length}),e.writeUInt16BE(t-n-2,n),ke.encode.bytes=t-n,e};ke.encode.bytes=0;ke.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let o=r[e++];if(--n,n<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,n-=o}return ke.decode.bytes=e-t,i};ke.decode.bytes=0;ke.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(t){typeof t=="string"?e+=S.byteLength(t)+1:e+=t.length+1}),e};var _e=v.null={};_e.encode=function(r,e,t){e||(e=S.alloc(_e.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=S.from(r)),r||(r=S.alloc(0));let n=t;t+=2;let i=r.length;return r.copy(e,t,0,i),t+=i,e.writeUInt16BE(t-n-2,n),_e.encode.bytes=t-n,e};_e.encode.bytes=0;_e.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+n);return e+=n,_e.decode.bytes=e-t,i};_e.decode.bytes=0;_e.encodingLength=function(r){return r?(S.isBuffer(r)?r.length:S.byteLength(r))+2:2};var Me=v.hinfo={};Me.encode=function(r,e,t){e||(e=S.alloc(Me.encodingLength(r))),t||(t=0);let n=t;return t+=2,O.encode(r.cpu,e,t),t+=O.encode.bytes,O.encode(r.os,e,t),t+=O.encode.bytes,e.writeUInt16BE(t-n-2,n),Me.encode.bytes=t-n,e};Me.encode.bytes=0;Me.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.cpu=O.decode(r,e),e+=O.decode.bytes,n.os=O.decode(r,e),e+=O.decode.bytes,Me.decode.bytes=e-t,n};Me.decode.bytes=0;Me.encodingLength=function(r){return O.encodingLength(r.cpu)+O.encodingLength(r.os)+2};var we=v.ptr={},Zs=v.cname=we,Qs=v.dname=we;we.encode=function(r,e,t){return e||(e=S.alloc(we.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),we.encode.bytes=w.encode.bytes+2,e};we.encode.bytes=0;we.decode=function(r,e){e||(e=0);let t=w.decode(r,e+2);return we.decode.bytes=w.decode.bytes+2,t};we.decode.bytes=0;we.encodingLength=function(r){return w.encodingLength(r)+2};var Fe=v.srv={};Fe.encode=function(r,e,t){e||(e=S.alloc(Fe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.priority||0,t+2),e.writeUInt16BE(r.weight||0,t+4),e.writeUInt16BE(r.port||0,t+6),w.encode(r.target,e,t+8);let n=w.encode.bytes+6;return e.writeUInt16BE(n,t),Fe.encode.bytes=n+2,e};Fe.encode.bytes=0;Fe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n={};return n.priority=r.readUInt16BE(e+2),n.weight=r.readUInt16BE(e+4),n.port=r.readUInt16BE(e+6),n.target=w.decode(r,e+8),Fe.decode.bytes=t+2,n};Fe.decode.bytes=0;Fe.encodingLength=function(r){return 8+w.encodingLength(r.target)};var ae=v.caa={};ae.ISSUER_CRITICAL=128;ae.encode=function(r,e,t){let n=ae.encodingLength(r);return e||(e=S.alloc(ae.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=ae.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,O.encode(r.tag,e,t),t+=O.encode.bytes,e.write(r.value,t),t+=S.byteLength(r.value),ae.encode.bytes=n,e};ae.encode.bytes=0;ae.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e);e+=2;let n=e,i={};return i.flags=r.readUInt8(e),e+=1,i.tag=O.decode(r,e),e+=O.decode.bytes,i.value=r.toString("utf-8",e,n+t),i.issuerCritical=!!(i.flags&ae.ISSUER_CRITICAL),ae.decode.bytes=t+2,i};ae.decode.bytes=0;ae.encodingLength=function(r){return O.encodingLength(r.tag)+O.encodingLength(r.value)+2};var et=v.mx={};et.encode=function(r,e,t){e||(e=S.alloc(et.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,w.encode(r.exchange,e,t),t+=w.encode.bytes,e.writeUInt16BE(t-n-2,n),et.encode.bytes=t-n,e};et.encode.bytes=0;et.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=w.decode(r,e),e+=w.decode.bytes,et.decode.bytes=e-t,n};et.encodingLength=function(r){return 4+w.encodingLength(r.exchange)};var Ke=v.a={};Ke.encode=function(r,e,t){return e||(e=S.alloc(Ke.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,lt.v4.encode(r,e,t),Ke.encode.bytes=6,e};Ke.encode.bytes=0;Ke.decode=function(r,e){e||(e=0),e+=2;let t=lt.v4.decode(r,e);return Ke.decode.bytes=6,t};Ke.decode.bytes=0;Ke.encodingLength=function(){return 6};var qe=v.aaaa={};qe.encode=function(r,e,t){return e||(e=S.alloc(qe.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,lt.v6.encode(r,e,t),qe.encode.bytes=18,e};qe.encode.bytes=0;qe.decode=function(r,e){e||(e=0),e+=2;let t=lt.v6.decode(r,e);return qe.decode.bytes=18,t};qe.decode.bytes=0;qe.encodingLength=function(){return 18};var oe=v.option={};oe.encode=function(r,e,t){e||(e=S.alloc(oe.encodingLength(r))),t||(t=0);let n=t,i=nn.toCode(r.code);if(e.writeUInt16BE(i,t),t+=2,r.data)e.writeUInt16BE(r.data.length,t),t+=2,r.data.copy(e,t),t+=r.data.length;else switch(i){case 8:let o=r.sourcePrefixLength||0,s=r.family||lt.familyOf(r.ip),a=lt.encode(r.ip,S.alloc),c=Math.ceil(o/8);e.writeUInt16BE(c+4,t),t+=2,e.writeUInt16BE(s,t),t+=2,e.writeUInt8(o,t++),e.writeUInt8(r.scopePrefixLength||0,t++),a.copy(e,t,0,c),t+=c;break;case 11:r.timeout?(e.writeUInt16BE(2,t),t+=2,e.writeUInt16BE(r.timeout,t),t+=2):(e.writeUInt16BE(0,t),t+=2);break;case 12:let d=r.length||0;e.writeUInt16BE(d,t),t+=2,e.fill(0,t,t+d),t+=d;break;case 14:let m=r.tags.length*2;e.writeUInt16BE(m,t),t+=2;for(let l of r.tags)e.writeUInt16BE(l,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return oe.encode.bytes=t-n,e};oe.encode.bytes=0;oe.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=nn.toString(t.code),e+=2;let n=r.readUInt16BE(e);switch(e+=2,t.data=r.slice(e,e+n),t.code){case 8:t.family=r.readUInt16BE(e),e+=2,t.sourcePrefixLength=r.readUInt8(e++),t.scopePrefixLength=r.readUInt8(e++);let i=S.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=lt.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let o=0;o<n;o+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return oe.decode.bytes=n+4,t};oe.decode.bytes=0;oe.encodingLength=function(r){if(r.data)return r.data.length+4;switch(nn.toCode(r.code)){case 8:let t=r.sourcePrefixLength||0;return Math.ceil(t/8)+8;case 11:return typeof r.timeout=="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw new Error(`Unknown roption code: ${r.code}`)};var ue=v.opt={};ue.encode=function(r,e,t){e||(e=S.alloc(ue.encodingLength(r))),t||(t=0);let n=t,i=Tt(r,oe);return e.writeUInt16BE(i,t),t=Gt(r,oe,e,t+2),ue.encode.bytes=t-n,e};ue.encode.bytes=0;ue.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)n[o++]=oe.decode(r,e),e+=oe.decode.bytes,i-=oe.decode.bytes;return ue.decode.bytes=e-t,n};ue.decode.bytes=0;ue.encodingLength=function(r){return 2+Tt(r||[],oe)};var J=v.dnskey={};J.PROTOCOL_DNSSEC=3;J.ZONE_KEY=128;J.SECURE_ENTRYPOINT=32768;J.encode=function(r,e,t){e||(e=S.alloc(J.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!S.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(J.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,J.encode.bytes=t-n,e.writeUInt16BE(J.encode.bytes-2,n),e};J.encode.bytes=0;J.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==J.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=r.readUInt8(e),e+=1,n.key=r.slice(e,t+i+2),e+=n.key.length,J.decode.bytes=e-t,n};J.decode.bytes=0;J.encodingLength=function(r){return 6+S.byteLength(r.key)};var Se=v.rrsig={};Se.encode=function(r,e,t){e||(e=S.alloc(Se.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!S.isBuffer(i))throw new Error("Signature must be a Buffer");return t+=2,e.writeUInt16BE(ze.toType(r.typeCovered),t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.labels,t),t+=1,e.writeUInt32BE(r.originalTTL,t),t+=4,e.writeUInt32BE(r.expiration,t),t+=4,e.writeUInt32BE(r.inception,t),t+=4,e.writeUInt16BE(r.keyTag,t),t+=2,w.encode(r.signersName,e,t),t+=w.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Se.encode.bytes=t-n,e.writeUInt16BE(Se.encode.bytes-2,n),e};Se.encode.bytes=0;Se.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=ze.toString(r.readUInt16BE(e)),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.labels=r.readUInt8(e),e+=1,n.originalTTL=r.readUInt32BE(e),e+=4,n.expiration=r.readUInt32BE(e),e+=4,n.inception=r.readUInt32BE(e),e+=4,n.keyTag=r.readUInt16BE(e),e+=2,n.signersName=w.decode(r,e),e+=w.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Se.decode.bytes=e-t,n};Se.decode.bytes=0;Se.encodingLength=function(r){return 20+w.encodingLength(r.signersName)+S.byteLength(r.signature)};var Ae=v.rp={};Ae.encode=function(r,e,t){e||(e=S.alloc(Ae.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mbox||".",e,t,{mail:!0}),t+=w.encode.bytes,w.encode(r.txt||".",e,t),t+=w.encode.bytes,Ae.encode.bytes=t-n,e.writeUInt16BE(Ae.encode.bytes-2,n),e};Ae.encode.bytes=0;Ae.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=w.decode(r,e,{mail:!0})||".",e+=w.decode.bytes,n.txt=w.decode(r,e)||".",e+=w.decode.bytes,Ae.decode.bytes=e-t,n};Ae.decode.bytes=0;Ae.encodingLength=function(r){return 2+w.encodingLength(r.mbox||".")+w.encodingLength(r.txt||".")};var j={};j.encode=function(r,e,t){e||(e=S.alloc(j.encodingLength(r))),t||(t=0);let n=t;for(var i=[],o=0;o<r.length;o++){var s=ze.toType(r[o]);i[s>>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(o=0;o<i.length;o++)if(i[o]!==void 0){var a=S.from(i[o]);e.writeUInt8(o,t),t+=1,e.writeUInt8(a.length,t),t+=1,a.copy(e,t),t+=a.length}return j.encode.bytes=t-n,e};j.encode.bytes=0;j.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){var o=r.readUInt8(e);e+=1;var s=r.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=r.readUInt8(e+a),d=0;d<8;d++)if(c&1<<7-d){var m=ze.toString(o<<8|a<<3|d);i.push(m)}e+=s}return j.decode.bytes=e-n,i};j.decode.bytes=0;j.encodingLength=function(r){for(var e=[],t=0;t<r.length;t++){var n=ze.toType(r[t]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(t=0;t<e.length;t++)e[t]!==void 0&&(i+=2+Math.ceil((e[t]+1)/8));return i};var Be=v.nsec={};Be.encode=function(r,e,t){e||(e=S.alloc(Be.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.nextDomain,e,t),t+=w.encode.bytes,j.encode(r.rrtypes,e,t),t+=j.encode.bytes,Be.encode.bytes=t-n,e.writeUInt16BE(Be.encode.bytes-2,n),e};Be.encode.bytes=0;Be.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=w.decode(r,e),e+=w.decode.bytes,n.rrtypes=j.decode(r,e,i-(e-t)),e+=j.decode.bytes,Be.decode.bytes=e-t,n};Be.decode.bytes=0;Be.encodingLength=function(r){return 2+w.encodingLength(r.nextDomain)+j.encodingLength(r.rrtypes)};var Ue=v.nsec3={};Ue.encode=function(r,e,t){e||(e=S.alloc(Ue.encodingLength(r))),t||(t=0);let n=t,i=r.salt;if(!S.isBuffer(i))throw new Error("salt must be a Buffer");let o=r.nextDomain;if(!S.isBuffer(o))throw new Error("nextDomain must be a Buffer");return t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.flags,t),t+=1,e.writeUInt16BE(r.iterations,t),t+=2,e.writeUInt8(i.length,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,e.writeUInt8(o.length,t),t+=1,o.copy(e,t,0,o.length),t+=o.length,j.encode(r.rrtypes,e,t),t+=j.encode.bytes,Ue.encode.bytes=t-n,e.writeUInt16BE(Ue.encode.bytes-2,n),e};Ue.encode.bytes=0;Ue.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+o),e+=o;let s=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+s),e+=s,n.rrtypes=j.decode(r,e,i-(e-t)),e+=j.decode.bytes,Ue.decode.bytes=e-t,n};Ue.decode.bytes=0;Ue.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+j.encodingLength(r.rrtypes)};var Le=v.ds={};Le.encode=function(r,e,t){e||(e=S.alloc(Le.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!S.isBuffer(i))throw new Error("Digest must be a Buffer");return t+=2,e.writeUInt16BE(r.keyTag,t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.digestType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,Le.encode.bytes=t-n,e.writeUInt16BE(Le.encode.bytes-2,n),e};Le.encode.bytes=0;Le.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.keyTag=r.readUInt16BE(e),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.digestType=r.readUInt8(e),e+=1,n.digest=r.slice(e,t+i+2),e+=n.digest.length,Le.decode.bytes=e-t,n};Le.decode.bytes=0;Le.encodingLength=function(r){return 6+S.byteLength(r.digest)};var de=v.sshfp={};de.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};de.encode=function(e,t,n){t||(t=S.alloc(de.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=1;let o=S.from(e.fingerprint.toUpperCase(),"hex");if(o.length!==de.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(t,n),n+=o.byteLength,de.encode.bytes=n-i,t.writeUInt16BE(de.encode.bytes-2,i),t};de.encode.bytes=0;de.decode=function(e,t){t||(t=0);let n=t,i={};t+=2,i.algorithm=e[t],t+=1,i.hash=e[t],t+=1;let o=de.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,de.decode.bytes=t-n,i};de.decode.bytes=0;de.encodingLength=function(r){return 4+S.from(r.fingerprint,"hex").byteLength};var Te=v.naptr={};Te.encode=function(r,e,t){e||(e=S.alloc(Te.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.order||0,t),t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,O.encode(r.flags,e,t),t+=O.encode.bytes,O.encode(r.services,e,t),t+=O.encode.bytes,O.encode(r.regexp,e,t),t+=O.encode.bytes,w.encode(r.replacement,e,t),t+=w.encode.bytes,Te.encode.bytes=t-n,e.writeUInt16BE(Te.encode.bytes-2,n),e};Te.encode.bytes=0;Te.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=O.decode(r,e),e+=O.decode.bytes,n.services=O.decode(r,e),e+=O.decode.bytes,n.regexp=O.decode(r,e),e+=O.decode.bytes,n.replacement=w.decode(r,e),e+=w.decode.bytes,Te.decode.bytes=e-t,n};Te.decode.bytes=0;Te.encodingLength=function(r){return O.encodingLength(r.flags)+O.encodingLength(r.services)+O.encodingLength(r.regexp)+w.encodingLength(r.replacement)+6};var Ne=v.tlsa={};Ne.encode=function(r,e,t){e||(e=S.alloc(Ne.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!S.isBuffer(i))throw new Error("Certificate must be a Buffer");return t+=2,e.writeUInt8(r.usage,t),t+=1,e.writeUInt8(r.selector,t),t+=1,e.writeUInt8(r.matchingType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,Ne.encode.bytes=t-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(r,e){e||(e=0);let t=e,n={},i=r.readUInt16BE(e);return e+=2,n.usage=r.readUInt8(e),e+=1,n.selector=r.readUInt8(e),e+=1,n.matchingType=r.readUInt8(e),e+=1,n.certificate=r.slice(e,t+i+2),e+=n.certificate.length,Ne.decode.bytes=e-t,n};Ne.decode.bytes=0;Ne.encodingLength=function(r){return 5+S.byteLength(r.certificate)};var sn=v.record=function(r){switch(r.toUpperCase()){case"A":return Ke;case"PTR":return we;case"CNAME":return Zs;case"DNAME":return Qs;case"TXT":return ke;case"NULL":return _e;case"AAAA":return qe;case"SRV":return Fe;case"HINFO":return Me;case"CAA":return ae;case"NS":return Re;case"SOA":return De;case"MX":return et;case"OPT":return ue;case"DNSKEY":return J;case"RRSIG":return Se;case"RP":return Ae;case"NSEC":return Be;case"NSEC3":return Ue;case"SSHFP":return de;case"DS":return Le;case"NAPTR":return Te;case"TLSA":return Ne}return Pe},Y=v.answer={};Y.encode=function(r,e,t){e||(e=S.alloc(Y.encodingLength(r))),t||(t=0);let n=t;if(w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(ze.toType(r.type),t),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,t+2),e.writeUInt8(r.extendedRcode||0,t+4),e.writeUInt8(r.ednsVersion||0,t+5),e.writeUInt16BE(r.flags||0,t+6),t+=8,ue.encode(r.options||[],e,t),t+=ue.encode.bytes}else{let i=gr.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=on),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=sn(r.type);o.encode(r.data,e,t),t+=o.encode.bytes}return Y.encode.bytes=t-n,e};Y.encode.bytes=0;Y.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=w.decode(r,e),e+=w.decode.bytes,t.type=ze.toString(r.readUInt16BE(e)),t.type==="OPT")t.udpPayloadSize=r.readUInt16BE(e+2),t.extendedRcode=r.readUInt8(e+4),t.ednsVersion=r.readUInt8(e+5),t.flags=r.readUInt16BE(e+6),t.flag_do=(t.flags>>15&1)===1,t.options=ue.decode(r,e+8),e+=8+ue.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=gr.toString(i&Xs),t.flush=!!(i&on);let o=sn(t.type);t.data=o.decode(r,e+8),e+=8+o.decode.bytes}return Y.decode.bytes=e-n,t};Y.decode.bytes=0;Y.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return w.encodingLength(r.name)+8+sn(r.type).encodingLength(e)};var xe=v.question={};xe.encode=function(r,e,t){e||(e=S.alloc(xe.encodingLength(r))),t||(t=0);let n=t;return w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(ze.toType(r.type),t),t+=2,e.writeUInt16BE(gr.toClass(r.class===void 0?"IN":r.class),t),t+=2,xe.encode.bytes=t-n,r};xe.encode.bytes=0;xe.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=w.decode(r,e),e+=w.decode.bytes,n.type=ze.toString(r.readUInt16BE(e)),e+=2,n.class=gr.toString(r.readUInt16BE(e)),e+=2,!!(n.class&Xi)&&(n.class&=Ws),xe.decode.bytes=e-t,n};xe.decode.bytes=0;xe.encodingLength=function(r){return w.encodingLength(r.name)+4};v.AUTHORITATIVE_ANSWER=1024;v.TRUNCATED_RESPONSE=512;v.RECURSION_DESIRED=256;v.RECURSION_AVAILABLE=128;v.AUTHENTIC_DATA=32;v.CHECKING_DISABLED=16;v.DNSSEC_OK=32768;v.encode=function(r,e,t){let n=!e;n&&(e=S.alloc(v.encodingLength(r))),t||(t=0);let i=t;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),Ee.encode(r,e,t),t+=Ee.encode.bytes,t=Gt(r.questions,xe,e,t),t=Gt(r.answers,Y,e,t),t=Gt(r.authorities,Y,e,t),t=Gt(r.additionals,Y,e,t),v.encode.bytes=t-i,n&&v.encode.bytes!==e.length?e.slice(0,v.encode.bytes):e};v.encode.bytes=0;v.decode=function(r,e){e||(e=0);let t=e,n=Ee.decode(r,e);return e+=Ee.decode.bytes,e=pr(n.questions,xe,r,e),e=pr(n.answers,Y,r,e),e=pr(n.authorities,Y,r,e),e=pr(n.additionals,Y,r,e),v.decode.bytes=e-t,n};v.decode.bytes=0;v.encodingLength=function(r){return Ee.encodingLength(r)+Tt(r.questions||[],xe)+Tt(r.answers||[],Y)+Tt(r.authorities||[],Y)+Tt(r.additionals||[],Y)};v.streamEncode=function(r){let e=v.encode(r),t=S.alloc(2);t.writeUInt16BE(e.byteLength);let n=S.concat([t,e]);return v.streamEncode.bytes=n.byteLength,n};v.streamEncode.bytes=0;v.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=v.decode(r.slice(2));return v.streamDecode.bytes=v.decode.bytes,t};v.streamDecode.bytes=0;function Tt(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Gt(r,e,t,n){for(let i=0;i<r.length;i++)e.encode(r[i],t,n),n+=e.encode.bytes;return n}function pr(r,e,t,n){for(let i=0;i<r.length;i++)r[i]=e.decode(t,n),n+=e.decode.bytes;return n}});var Ji=ve((Pu,Qi)=>{"use strict";var Zi=ic;process.nextTick(nc,42);Qi.exports=Js;function Js(r){var e=n;return t;function t(i){e(i||tc)}function n(i){var o=[i];e=s,r(a);function s(c){o.push(c)}function a(c){var d=arguments;for(e=ec(c)?n:m;o.length;)m(o.shift());function m(l){Zi(rc,l,d)}}}}function ec(r){return Object.prototype.toString.call(r)==="[object Error]"}function tc(){}function rc(r,e){r.apply(null,e)}function nc(r){r===42&&(Zi=process.nextTick)}function ic(r,e,t){process.nextTick(function(){r(e,t)})}});var ro=ve((Ru,to)=>{var cn=Wi(),oc=ne("dgram"),sc=Ji(),cc=ne("events"),dn=ne("os"),an=function(){};to.exports=function(r){r||(r={});var e=new cc.EventEmitter,t=typeof r.port=="number"?r.port:5353,n=r.type||"udp4",i=r.ip||r.host||(n==="udp4"?"224.0.0.251":null),o={address:i,port:t},s={},a=!1,c=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=r.socket||oc.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});d.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),d.on("message",function(l,u){try{l=cn.decode(l)}catch(p){e.emit("warning",p);return}e.emit("packet",l,u),l.type==="query"&&e.emit("query",l,u),l.type==="response"&&e.emit("response",l,u)}),d.on("listening",function(){t||(t=o.port=d.address().port),r.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),d.setMulticastTTL(r.ttl||255),d.setMulticastLoopback(r.loopback!==!1))});var m=sc(function(l){if(!t||r.bind===!1)return l(null);d.once("error",l),d.bind(t,r.bind||r.interface,function(){d.removeListener("error",l),l(null)})});return m(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,u,p){if(typeof u=="function")return e.send(l,null,u);p||(p=an),u?!u.host&&!u.address&&(u.address=o.address):u=o,m(h);function h(y){if(a)return p();if(y)return p(y);var g=cn.encode(l);d.send(g,0,g.length,u.port,u.address||u.host,p)}},e.response=e.respond=function(l,u,p){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|cn.AUTHORITATIVE_ANSWER,e.send(l,u,p)},e.query=function(l,u,p,h){if(typeof u=="function")return e.query(l,null,null,u);if(typeof u=="object"&&u&&u.port)return e.query(l,null,u,p);if(typeof p=="function")return e.query(l,u,null,p);h||(h=an),typeof l=="string"&&(l=[{name:l,type:u||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,p,h)},e.destroy=function(l){if(l||(l=an),a)return process.nextTick(l);a=!0,clearInterval(c);for(var u in s)try{d.dropMembership(i,u)}catch{}s={},d.close(l)},e.update=function(){for(var l=r.interface?[].concat(r.interface):dc(),u=!1,p=0;p<l.length;p++){var h=l[p];if(!s[h])try{d.addMembership(i,h),s[h]=!0,u=!0}catch(y){e.emit("warning",y)}}if(u){if(d.setMulticastInterface)try{d.setMulticastInterface(r.interface||ac())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function ac(){for(var r=dn.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var o=n[i];if(eo(o.family)&&!o.internal)return dn.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function dc(){for(var r=dn.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],o=0;o<i.length;o++){var s=i[o];if(eo(s.family)){t.push(s.address);break}}return t}function eo(r){return r===4||r==="IPv4"}});var Es=ve(cr=>{(function(){var r,e,t,n,i,o,s,a;a=function(c){var d,m,l,u;return d=(c&255<<24)>>>24,m=(c&255<<16)>>>16,l=(c&65280)>>>8,u=c&255,[d,m,l,u].join(".")},s=function(c){var d,m,l,u,p,h;for(d=[],l=u=0;u<=3&&c.length!==0;l=++u){if(l>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}h=e(c),p=h[0],m=h[1],c=c.substring(m),d.push(p)}if(c.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),o=t("a"),i=t("A"),e=function(c){var d,m,l,u,p;for(u=0,d=10,m="9",l=0,c.length>1&&c[l]==="0"&&(c[l+1]==="x"||c[l+1]==="X"?(l+=2,d=16):"0"<=c[l+1]&&c[l+1]<="9"&&(l++,d=8,m="7")),p=l;l<c.length;){if("0"<=c[l]&&c[l]<=m)u=u*d+(t(c[l])-n)>>>0;else if(d===16)if("a"<=c[l]&&c[l]<="f")u=u*d+(10+t(c[l])-o)>>>0;else if("A"<=c[l]&&c[l]<="F")u=u*d+(10+t(c[l])-i)>>>0;else break;else break;if(u>4294967295)throw new Error("too large");l++}if(l===p)throw new Error("empty octet");return[u,l]},r=function(){function c(d,m){var l,u,p,h;if(typeof d!="string")throw new Error("Missing `net' parameter");if(m||(h=d.split("/",2),d=h[0],m=h[1]),m||(m=32),typeof m=="string"&&m.indexOf(".")>-1){try{this.maskLong=s(m)}catch(y){throw l=y,new Error("Invalid mask: "+m)}for(u=p=32;p>=0;u=--p)if(this.maskLong===4294967295<<32-u>>>0){this.bitmask=u;break}}else if(m||m===0)this.bitmask=parseInt(m,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(d)&this.maskLong)>>>0}catch(y){throw l=y,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+m);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new c(d)),d instanceof c?this.contains(d.base)&&this.contains(d.broadcast||d.last):(s(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(d){return d==null&&(d=1),new c(a(this.netLong+this.size*d),this.mask)},c.prototype.forEach=function(d){var m,l,u;for(u=s(this.first),l=s(this.last),m=0;u<=l;)d(a(u),u,m),m++,u++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),cr.ip2long=s,cr.long2ip=a,cr.Netmask=r}).call(cr)});var Wd={};ie(Wd,{mdns:()=>Xd});var ki=Symbol.for("@libp2p/peer-discovery");var Wr=Symbol.for("@libp2p/peer-id");var Lt=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},ur=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var lr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var $t=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var _i=ne("node:events"),Mi=(r,...e)=>{try{(0,_i.setMaxListeners)(r,...e)}catch{}};var hr=class extends EventTarget{#e=new Map;constructor(){super(),Mi(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Fi=Symbol.for("@libp2p/service-capabilities"),iu=Symbol.for("@libp2p/service-dependencies");var Fs=Ut(ro(),1);var gn={};ie(gn,{base58btc:()=>K,base58flickr:()=>mc});var Du=new Uint8Array(0);function no(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ge(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function io(r){return new TextEncoder().encode(r)}function oo(r){return new TextDecoder().decode(r)}function uc(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var a=r.length,c=r.charAt(0),d=Math.log(a)/Math.log(256),m=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var y=0,g=0,f=0,x=h.length;f!==x&&h[f]===0;)f++,y++;for(var b=(x-f)*m+1>>>0,L=new Uint8Array(b);f!==x;){for(var T=h[f],B=0,U=b-1;(T!==0||B<g)&&U!==-1;U--,B++)T+=256*L[U]>>>0,L[U]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");g=B,f++}for(var N=b-g;N!==b&&L[N]===0;)N++;for(var C=c.repeat(y);N<b;++N)C+=r.charAt(L[N]);return C}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var y=0;if(h[y]!==" "){for(var g=0,f=0;h[y]===c;)g++,y++;for(var x=(h.length-y)*d+1>>>0,b=new Uint8Array(x);h[y];){var L=t[h.charCodeAt(y)];if(L===255)return;for(var T=0,B=x-1;(L!==0||T<f)&&B!==-1;B--,T++)L+=a*b[B]>>>0,b[B]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");f=T,y++}if(h[y]!==" "){for(var U=x-f;U!==x&&b[U]===0;)U++;for(var N=new Uint8Array(g+(x-U)),C=g;U!==x;)N[C++]=b[U++];return N}}}function p(h){var y=u(h);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:u,decode:p}}var lc=uc,hc=lc,co=hc;var un=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ln=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 ao(this,e)}},hn=class{decoders;constructor(e){this.decoders=e}or(e){return ao(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ao(r,e){return new hn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var pn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new un(e,t,n),this.decoder=new ln(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Nt({name:r,prefix:e,encode:t,decode:n}){return new pn(r,e,t,n)}function tt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=co(t,r);return Nt({prefix:e,name:r,encode:n,decode:o=>ge(i(o))})}function pc(r,e,t,n){let i={};for(let m=0;m<e.length;++m)i[e[m]]=m;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),a=0,c=0,d=0;for(let m=0;m<o;++m){let l=i[r[m]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,s[d++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function gc(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<t-s]),n)for(;o.length*t&7;)o+="=";return o}function F({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Nt({prefix:e,name:r,encode(i){return gc(i,n,t)},decode(i){return pc(i,n,t,r)}})}var K=tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mc=tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mn={};ie(mn,{base32:()=>Ve,base32hex:()=>xc,base32hexpad:()=>bc,base32hexpadupper:()=>Ic,base32hexupper:()=>Ec,base32pad:()=>fc,base32padupper:()=>wc,base32upper:()=>yc,base32z:()=>vc});var Ve=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yc=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),fc=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wc=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xc=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ec=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bc=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ic=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vc=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var yn={};ie(yn,{base36:()=>Yt,base36upper:()=>Sc});var Yt=tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sc=tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ac=ho,uo=128,Bc=127,Uc=~Bc,Lc=Math.pow(2,31);function ho(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Lc;)e[t++]=r&255|uo,r/=128;for(;r&Uc;)e[t++]=r&255|uo,r>>>=7;return e[t]=r|0,ho.bytes=t-n+1,e}var Tc=fn,Nc=128,lo=127;function fn(r,n){var t=0,n=n||0,i=0,o=n,s,a=r.length;do{if(o>=a)throw fn.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&lo)<<i:(s&lo)*Math.pow(2,i),i+=7}while(s>=Nc);return fn.bytes=o-n,t}var Cc=Math.pow(2,7),Oc=Math.pow(2,14),Pc=Math.pow(2,21),Rc=Math.pow(2,28),Dc=Math.pow(2,35),kc=Math.pow(2,42),_c=Math.pow(2,49),Mc=Math.pow(2,56),Fc=Math.pow(2,63),Kc=function(r){return r<Cc?1:r<Oc?2:r<Pc?3:r<Rc?4:r<Dc?5:r<kc?6:r<_c?7:r<Mc?8:r<Fc?9:10},qc={encode:Ac,decode:Tc,encodingLength:Kc},zc=qc,Xt=zc;function Wt(r,e=0){return[Xt.decode(r,e),Xt.decode.bytes]}function Ct(r,e,t=0){return Xt.encode(r,e,t),e}function Ot(r){return Xt.encodingLength(r)}function ht(r,e){let t=e.byteLength,n=Ot(r),i=n+Ot(t),o=new Uint8Array(i+t);return Ct(r,o,0),Ct(t,o,n),o.set(e,i),new Pt(r,t,e,o)}function pt(r){let e=ge(r),[t,n]=Wt(e),[i,o]=Wt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Pt(t,i,s,e)}function po(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&no(r.bytes,t.bytes)}}var Pt=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};function go(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Hc(t,wn(r),e??K.encoder);default:return jc(t,wn(r),e??Ve.encoder)}}var mo=new WeakMap;function wn(r){let e=mo.get(r);if(e==null){let t=new Map;return mo.set(r,t),t}return e}var ee=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Zt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$c)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ht(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&po(e.multihash,n.multihash)}toString(e){return go(this,e)}toJSON(){return{"/":go(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:o,bytes:s}=t;return new r(n,i,o,s??yo(n,i,o.bytes))}else if(t[Gc]===!0){let{version:n,multihash:i,code:o}=t,s=pt(i);return r.create(n,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Zt)throw new Error(`Version 0 CID must use dag-pb (code: ${Zt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=yo(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Zt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=ge(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new Pt(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,u]=Wt(e.subarray(t));return t+=u,l},i=n(),o=Zt;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,a=n(),c=n(),d=t+c,m=d-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:m,size:d}}static parse(e,t){let[n,i]=Vc(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return wn(o).set(n,e),o}};function Vc(r,e){switch(r[0]){case"Q":{let t=e??K;return[K.prefix,t.decode(`${K.prefix}${r}`)]}case K.prefix:{let t=e??K;return[K.prefix,t.decode(r)]}case Ve.prefix:{let t=e??Ve;return[Ve.prefix,t.decode(r)]}case Yt.prefix:{let t=e??Yt;return[Yt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Hc(r,e,t){let{prefix:n}=t;if(n!==K.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function jc(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var Zt=112,$c=18;function yo(r,e,t){let n=Ot(r),i=n+Ot(e),o=new Uint8Array(i+t.byteLength);return Ct(r,o,0),Ct(e,o,n),o.set(t,i),o}var Gc=Symbol.for("@ipld/js-cid/CID");var xn={};ie(xn,{identity:()=>He});var fo=0,Yc="identity",wo=ge;function Xc(r){return ht(fo,wo(r))}var He={code:fo,name:Yc,encode:wo,digest:Xc};function je(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var fr=Ut(ne("crypto"),1);var xo=ne("node:buffer");function Rt(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Ce(r,e){return Rt(xo.Buffer.concat(r,e))}var Ao=ne("node:buffer");var En={};ie(En,{base10:()=>Wc});var Wc=tt({prefix:"9",name:"base10",alphabet:"0123456789"});var bn={};ie(bn,{base16:()=>Zc,base16upper:()=>Qc});var Zc=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qc=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var In={};ie(In,{base2:()=>Jc});var Jc=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var vn={};ie(vn,{base256emoji:()=>ia});var Eo=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}"),ea=Eo.reduce((r,e,t)=>(r[t]=e,r),[]),ta=Eo.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function ra(r){return r.reduce((e,t)=>(e+=ea[t],e),"")}function na(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=ta[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var ia=Nt({prefix:"\u{1F680}",name:"base256emoji",encode:ra,decode:na});var Sn={};ie(Sn,{base64:()=>oa,base64pad:()=>sa,base64url:()=>ca,base64urlpad:()=>aa});var oa=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sa=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ca=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),aa=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var An={};ie(An,{base8:()=>da});var da=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Bn={};ie(Bn,{identity:()=>ua});var ua=Nt({prefix:"\0",name:"identity",encode:r=>oo(r),decode:r=>io(r)});var ll=new TextEncoder,hl=new TextDecoder;var Cn={};ie(Cn,{sha256:()=>Nn,sha512:()=>pa});var Tn=Ut(ne("crypto"),1);function Ln({name:r,code:e,encode:t}){return new Un(r,e,t)}var Un=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ht(this.code,t):t.then(n=>ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Nn=Ln({name:"sha2-256",code:18,encode:r=>ge(Tn.default.createHash("sha256").update(r).digest())}),pa=Ln({name:"sha2-512",code:19,encode:r=>ge(Tn.default.createHash("sha512").update(r).digest())});var Qt={...Bn,...In,...An,...En,...bn,...mn,...yn,...gn,...Sn,...vn},Al={...Cn,...xn};var Io=ne("node:buffer");function $e(r=0){return Rt(Io.Buffer.allocUnsafe(r))}function So(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var vo=So("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),On=So("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=$e(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ga={utf8:vo,"utf-8":vo,hex:Qt.base16,latin1:On,ascii:On,binary:On,...Qt},yr=ga;function Ge(r,e="utf8"){let t=yr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Rt(Ao.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Bo=ne("node:buffer");function z(r,e="utf8"){let t=yr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Bo.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Kl=fr.default.generateKeyPairSync,Jt=32;var ma=64;function Uo(r,e,t){if(r.byteLength!==Jt)throw new TypeError('"key" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==ma)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=fr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:z(r,"base64url"),kty:"OKP"}});return fr.default.verify(null,t instanceof Uint8Array?t:t.subarray(),n,e)}var wr=class{type="Ed25519";raw;constructor(e){this.raw=Pn(e,Jt)}toMultihash(){return He.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:je(this.raw,e.raw)}verify(e,t){return Uo(this.raw,t,e)}};function To(r){return r=Pn(r,Jt),new wr(r)}function Pn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Lt(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var fa=Math.pow(2,7),wa=Math.pow(2,14),xa=Math.pow(2,21),Rn=Math.pow(2,28),Dn=Math.pow(2,35),kn=Math.pow(2,42),_n=Math.pow(2,49),D=128,X=127;function se(r){if(r<fa)return 1;if(r<wa)return 2;if(r<xa)return 3;if(r<Rn)return 4;if(r<Dn)return 5;if(r<kn)return 6;if(r<_n)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Mn(r,e,t=0){switch(se(r)){case 8:e[t++]=r&255|D,r/=128;case 7:e[t++]=r&255|D,r/=128;case 6:e[t++]=r&255|D,r/=128;case 5:e[t++]=r&255|D,r/=128;case 4:e[t++]=r&255|D,r>>>=7;case 3:e[t++]=r&255|D,r>>>=7;case 2:e[t++]=r&255|D,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Ea(r,e,t=0){switch(se(r)){case 8:e.set(t++,r&255|D),r/=128;case 7:e.set(t++,r&255|D),r/=128;case 6:e.set(t++,r&255|D),r/=128;case 5:e.set(t++,r&255|D),r/=128;case 4:e.set(t++,r&255|D),r>>>=7;case 3:e.set(t++,r&255|D),r>>>=7;case 2:e.set(t++,r&255|D),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Fn(r,e){let t=r[e],n=0;if(n+=t&X,t<D||(t=r[e+1],n+=(t&X)<<7,t<D)||(t=r[e+2],n+=(t&X)<<14,t<D)||(t=r[e+3],n+=(t&X)<<21,t<D)||(t=r[e+4],n+=(t&X)*Rn,t<D)||(t=r[e+5],n+=(t&X)*Dn,t<D)||(t=r[e+6],n+=(t&X)*kn,t<D)||(t=r[e+7],n+=(t&X)*_n,t<D))return n;throw new RangeError("Could not decode varint")}function ba(r,e){let t=r.get(e),n=0;if(n+=t&X,t<D||(t=r.get(e+1),n+=(t&X)<<7,t<D)||(t=r.get(e+2),n+=(t&X)<<14,t<D)||(t=r.get(e+3),n+=(t&X)<<21,t<D)||(t=r.get(e+4),n+=(t&X)*Rn,t<D)||(t=r.get(e+5),n+=(t&X)*Dn,t<D)||(t=r.get(e+6),n+=(t&X)*kn,t<D)||(t=r.get(e+7),n+=(t&X)*_n,t<D))return n;throw new RangeError("Could not decode varint")}function Dt(r,e,t=0){return e==null&&(e=$e(se(r))),e instanceof Uint8Array?Mn(r,e,t):Ea(r,e,t)}function mt(r,e=0){return r instanceof Uint8Array?Fn(r,e):ba(r,e)}var Kn=new Float32Array([-0]),rt=new Uint8Array(Kn.buffer);function Co(r,e,t){Kn[0]=r,e[t]=rt[0],e[t+1]=rt[1],e[t+2]=rt[2],e[t+3]=rt[3]}function Oo(r,e){return rt[0]=r[e],rt[1]=r[e+1],rt[2]=r[e+2],rt[3]=r[e+3],Kn[0]}var qn=new Float64Array([-0]),W=new Uint8Array(qn.buffer);function Po(r,e,t){qn[0]=r,e[t]=W[0],e[t+1]=W[1],e[t+2]=W[2],e[t+3]=W[3],e[t+4]=W[4],e[t+5]=W[5],e[t+6]=W[6],e[t+7]=W[7]}function Ro(r,e){return W[0]=r[e],W[1]=r[e+1],W[2]=r[e+2],W[3]=r[e+3],W[4]=r[e+4],W[5]=r[e+5],W[6]=r[e+6],W[7]=r[e+7],qn[0]}var Ia=BigInt(Number.MAX_SAFE_INTEGER),va=BigInt(Number.MIN_SAFE_INTEGER),le=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+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 t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(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,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return yt;if(e<Ia&&e>va)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,i=e-(n<<32n);return t&&(n=~n|0n,i=~i|0n,++i>Do&&(i=0n,++n>Do&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(e){if(e===0)return yt;let t=e<0;t&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):yt}},yt=new le(0,0);yt.toBigInt=function(){return 0n};yt.zzEncode=yt.zzDecode=function(){return this};yt.length=function(){return 1};var Do=4294967296n;function ko(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function _o(r,e,t){if(t-e<1)return"";let i,o=[],s=0,a;for(;e<t;)a=r[e++],a<128?o[s++]=a:a>191&&a<224?o[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[s++]=55296+(a>>10),o[s++]=56320+(a&1023)):o[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function zn(r,e,t){let n=t,i,o;for(let s=0;s<r.length;++s)i=r.charCodeAt(s),i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128);return t-n}function be(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Er(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Vn=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,be(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 be(this,4);return Er(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw be(this,4);return Er(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw be(this,4);let e=Oo(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw be(this,4);let e=Ro(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw be(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return _o(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw be(this,e);this.pos+=e}else do if(this.pos>=this.len)throw be(this);while(this.buf[this.pos++]&128);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 le(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*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;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw be(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw be(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw be(this,8);let e=Er(this.buf,this.pos+=4),t=Er(this.buf,this.pos+=4);return new le(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Fn(this.buf,this.pos);return this.pos+=se(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 Hn(r){return new Vn(r instanceof Uint8Array?r:r.subarray())}function br(r,e,t){let n=Hn(r);return e.decode(n,void 0,t)}function jn(r){let e=r??8192,t=e>>>1,n,i=e;return function(s){if(s<1||s>t)return $e(s);i+s>e&&(n=$e(e),i=0);let a=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),a}}var ft=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function $n(){}var Yn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Sa=jn();function Aa(r){return globalThis.Buffer!=null?$e(r):Sa(r)}var tr=class{len;head;tail;states;constructor(){this.len=0,this.head=new ft($n,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new ft(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Xn((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(Ir,10,le.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=le.fromBigInt(e);return this._push(Ir,t.length(),t)}uint64Number(e){return this._push(Mn,se(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 t=le.fromBigInt(e).zzEncode();return this._push(Ir,t.length(),t)}sint64Number(e){let t=le.fromNumber(e).zzEncode();return this._push(Ir,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Gn,1,e?1:0)}fixed32(e){return this._push(er,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=le.fromBigInt(e);return this._push(er,4,t.lo)._push(er,4,t.hi)}fixed64Number(e){let t=le.fromNumber(e);return this._push(er,4,t.lo)._push(er,4,t.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(Co,4,e)}double(e){return this._push(Po,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Gn,1,0):this.uint32(t)._push(Ua,t,e)}string(e){let t=ko(e);return t!==0?this.uint32(t)._push(zn,t,e):this._push(Gn,1,0)}fork(){return this.states=new Yn(this),this.head=this.tail=new ft($n,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 ft($n,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Aa(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Gn(r,e,t){e[t]=r&255}function Ba(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Xn=class extends ft{next;constructor(e,t){super(Ba,e,t),this.next=void 0}};function Ir(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function er(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Ua(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(tr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(La,e,r),this},tr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Ta,e,r),this});function La(r,e,t){e.set(r,t)}function Ta(r,e,t){r.length<40?zn(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Ge(r),t)}function Wn(){return new tr}function vr(r,e){let t=Wn();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var kt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(kt||(kt={}));function Sr(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Zn(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(o,s){let a=e(o);s.int32(a)},n=function(o){let s=o.int32();return e(s)};return Sr("enum",kt.VARINT,t,n)}function Ar(r,e){return Sr("message",kt.LENGTH_DELIMITED,r,e)}var me;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(me||(me={}));var Qn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Qn||(Qn={}));(function(r){r.codec=()=>Zn(Qn)})(me||(me={}));var rr;(function(r){let e;r.codec=()=>(e==null&&(e=Ar((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),me.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=me.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>vr(t,r.codec()),r.decode=(t,n)=>br(t,r.codec(),n)})(rr||(rr={}));var Jn;(function(r){let e;r.codec=()=>(e==null&&(e=Ar((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),me.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=me.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>vr(t,r.codec()),r.decode=(t,n)=>br(t,r.codec(),n)})(Jn||(Jn={}));function Fo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Ca(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function _t(r,...e){if(!Ca(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function Ko(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Fo(r.outputLen),Fo(r.blockLen)}function Mt(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function qo(r,e){_t(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Ye=Ut(ne("node:crypto"),1),wt=Ye&&typeof Ye=="object"&&"webcrypto"in Ye?Ye.webcrypto:Ye&&typeof Ye=="object"&&"randomBytes"in Ye?Ye:void 0;function Br(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ie(r,e){return r<<32-e|r>>>e}function Oa(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function nr(r){return typeof r=="string"&&(r=Oa(r)),_t(r),r}function zo(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];_t(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let o=r[n];t.set(o,i),i+=o.length}return t}var Ft=class{clone(){return this._cloneInto()}};function Vo(r){let e=n=>r().update(nr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Ho(r=32){if(wt&&typeof wt.getRandomValues=="function")return wt.getRandomValues(new Uint8Array(r));if(wt&&typeof wt.randomBytes=="function")return wt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Pa(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),a=Number(t&o),c=n?4:0,d=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+d,a,n)}function jo(r,e,t){return r&e^~r&t}function $o(r,e,t){return r&e^r&t^e&t}var Ur=class extends Ft{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Br(this.buffer)}update(e){Mt(this);let{view:t,buffer:n,blockLen:i}=this;e=nr(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Br(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Mt(this),qo(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)t[l]=0;Pa(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=Br(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,m=this.get();if(d>m.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.setUint32(4*l,m[l],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%t&&e.buffer.set(n),e}};var Ra=new Uint32Array([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]),nt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),it=new Uint32Array(64),ei=class extends Ur{constructor(){super(64,32,8,!1),this.A=nt[0]|0,this.B=nt[1]|0,this.C=nt[2]|0,this.D=nt[3]|0,this.E=nt[4]|0,this.F=nt[5]|0,this.G=nt[6]|0,this.H=nt[7]|0}get(){let{A:e,B:t,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,t,n,i,o,s,a,c]}set(e,t,n,i,o,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)it[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let u=it[l-15],p=it[l-2],h=Ie(u,7)^Ie(u,18)^u>>>3,y=Ie(p,17)^Ie(p,19)^p>>>10;it[l]=y+it[l-7]+h+it[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:d,H:m}=this;for(let l=0;l<64;l++){let u=Ie(a,6)^Ie(a,11)^Ie(a,25),p=m+u+jo(a,c,d)+Ra[l]+it[l]|0,y=(Ie(n,2)^Ie(n,13)^Ie(n,22))+$o(n,i,o)|0;m=d,d=c,c=a,a=s+p|0,s=o,o=i,i=n,n=p+y|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,m=m+this.H|0,this.set(n,i,o,s,a,c,d,m)}roundClean(){it.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Go=Vo(()=>new ei);var Lr=class extends Ft{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ko(e);let n=nr(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return Mt(this),this.iHash.update(e),this}digestInto(e){Mt(this),_t(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ti=(r,e,t)=>new Lr(r,e).update(t).digest();ti.create=(r,e)=>new Lr(r,e);var ci={};ie(ci,{aInRange:()=>ct,abool:()=>xt,abytes:()=>Kt,bitGet:()=>Ka,bitLen:()=>oi,bitMask:()=>or,bitSet:()=>qa,bytesToHex:()=>Et,bytesToNumberBE:()=>We,bytesToNumberLE:()=>Cr,concatBytes:()=>qt,createHmacDrbg:()=>si,ensureBytes:()=>he,equalBytes:()=>Ma,hexToBytes:()=>It,hexToNumber:()=>ii,inRange:()=>ir,isBytes:()=>ot,memoized:()=>Pr,notImplemented:()=>Va,numberToBytesBE:()=>st,numberToBytesLE:()=>Or,numberToHexUnpadded:()=>bt,numberToVarBytesBE:()=>_a,utf8ToBytes:()=>Fa,validateObject:()=>at});var Tr=BigInt(0),Nr=BigInt(1),Da=BigInt(2);function ot(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Kt(r){if(!ot(r))throw new Error("Uint8Array expected")}function xt(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var ka=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Et(r){Kt(r);let e="";for(let t=0;t<r.length;t++)e+=ka[r[t]];return e}function bt(r){let e=r.toString(16);return e.length&1?"0"+e:e}function ii(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Tr:BigInt("0x"+r)}var Xe={_0:48,_9:57,A:65,F:70,a:97,f:102};function Yo(r){if(r>=Xe._0&&r<=Xe._9)return r-Xe._0;if(r>=Xe.A&&r<=Xe.F)return r-(Xe.A-10);if(r>=Xe.a&&r<=Xe.f)return r-(Xe.a-10)}function It(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,o=0;i<t;i++,o+=2){let s=Yo(r.charCodeAt(o)),a=Yo(r.charCodeAt(o+1));if(s===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function We(r){return ii(Et(r))}function Cr(r){return Kt(r),ii(Et(Uint8Array.from(r).reverse()))}function st(r,e){return It(r.toString(16).padStart(e*2,"0"))}function Or(r,e){return st(r,e).reverse()}function _a(r){return It(bt(r))}function he(r,e,t){let n;if(typeof e=="string")try{n=It(e)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(ot(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function qt(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Kt(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let o=r[n];t.set(o,i),i+=o.length}return t}function Ma(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Fa(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var ri=r=>typeof r=="bigint"&&Tr<=r;function ir(r,e,t){return ri(r)&&ri(e)&&ri(t)&&e<=r&&r<t}function ct(r,e,t,n){if(!ir(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function oi(r){let e;for(e=0;r>Tr;r>>=Nr,e+=1);return e}function Ka(r,e){return r>>BigInt(e)&Nr}function qa(r,e,t){return r|(t?Nr:Tr)<<BigInt(e)}var or=r=>(Da<<BigInt(r-1))-Nr,ni=r=>new Uint8Array(r),Xo=r=>Uint8Array.from(r);function si(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=ni(r),i=ni(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>t(i,n,...l),c=(l=ni())=>{i=a(Xo([0]),l),n=a(),l.length!==0&&(i=a(Xo([1]),l),n=a())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,u=[];for(;l<e;){n=a();let p=n.slice();u.push(p),l+=n.length}return qt(...u)};return(l,u)=>{s(),c(l);let p;for(;!(p=u(d()));)c();return s(),p}}var za={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ot(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function at(r,e,t={}){let n=(i,o,s)=>{let a=za[o];if(typeof a!="function")throw new Error("invalid validator function");let c=r[i];if(!(s&&c===void 0)&&!a(c,r))throw new Error("param "+String(i)+" is invalid. Expected "+o+", got "+c)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(t))n(i,o,!0);return r}var Va=()=>{throw new Error("not implemented")};function Pr(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let o=r(t,...n);return e.set(t,o),o}}var H=BigInt(0),q=BigInt(1),vt=BigInt(2),Ha=BigInt(3),ai=BigInt(4),Wo=BigInt(5),Zo=BigInt(8),ja=BigInt(9),$a=BigInt(16);function Z(r,e){let t=r%e;return t>=H?t:e+t}function Ga(r,e,t){if(e<H)throw new Error("invalid exponent, negatives unsupported");if(t<=H)throw new Error("invalid modulus");if(t===q)return H;let n=q;for(;e>H;)e&q&&(n=n*r%t),r=r*r%t,e>>=q;return n}function pe(r,e,t){let n=r;for(;e-- >H;)n*=n,n%=t;return n}function Rr(r,e){if(r===H)throw new Error("invert: expected non-zero number");if(e<=H)throw new Error("invert: expected positive modulus, got "+e);let t=Z(r,e),n=e,i=H,o=q,s=q,a=H;for(;t!==H;){let d=n/t,m=n%t,l=i-s*d,u=o-a*d;n=t,t=m,i=s,o=a,s=l,a=u}if(n!==q)throw new Error("invert: does not exist");return Z(i,e)}function Ya(r){let e=(r-q)/vt,t,n,i;for(t=r-q,n=0;t%vt===H;t/=vt,n++);for(i=vt;i<r&&Ga(i,e,r)!==r-q;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+q)/ai;return function(c,d){let m=c.pow(d,s);if(!c.eql(c.sqr(m),d))throw new Error("Cannot find square root");return m}}let o=(t+q)/vt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,m=a.pow(a.mul(a.ONE,i),t),l=a.pow(c,o),u=a.pow(c,t);for(;!a.eql(u,a.ONE);){if(a.eql(u,a.ZERO))return a.ZERO;let p=1;for(let y=a.sqr(u);p<d&&!a.eql(y,a.ONE);p++)y=a.sqr(y);let h=a.pow(m,q<<BigInt(d-p-1));m=a.sqr(h),l=a.mul(l,h),u=a.mul(u,m),d=p}return l}}function Xa(r){if(r%ai===Ha){let e=(r+q)/ai;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(r%Zo===Wo){let e=(r-Wo)/Zo;return function(n,i){let o=n.mul(i,vt),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,vt),s),d=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return r%$a,Ya(r)}var Wa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function di(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Wa.reduce((n,i)=>(n[i]="function",n),e);return at(r,t)}function Za(r,e,t){if(t<H)throw new Error("invalid exponent, negatives unsupported");if(t===H)return r.ONE;if(t===q)return e;let n=r.ONE,i=e;for(;t>H;)t&q&&(n=r.mul(n,i)),i=r.sqr(i),t>>=q;return n}function Qa(r,e){let t=new Array(e.length),n=e.reduce((o,s,a)=>r.is0(s)?o:(t[a]=o,r.mul(o,s)),r.ONE),i=r.inv(n);return e.reduceRight((o,s,a)=>r.is0(s)?o:(t[a]=r.mul(o,t[a]),r.mul(o,s)),i),t}function ui(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Dr(r,e,t=!1,n={}){if(r<=H)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:i,nByteLength:o}=ui(r,e);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:o,MASK:or(i),ZERO:H,ONE:q,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return H<=c&&c<r},is0:c=>c===H,isOdd:c=>(c&q)===q,neg:c=>Z(-c,r),eql:(c,d)=>c===d,sqr:c=>Z(c*c,r),add:(c,d)=>Z(c+d,r),sub:(c,d)=>Z(c-d,r),mul:(c,d)=>Z(c*d,r),pow:(c,d)=>Za(a,c,d),div:(c,d)=>Z(c*Rr(d,r),r),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>Rr(c,r),sqrt:n.sqrt||(c=>(s||(s=Xa(r)),s(a,c))),invertBatch:c=>Qa(a,c),cmov:(c,d,m)=>m?d:c,toBytes:c=>t?Or(c,o):st(c,o),fromBytes:c=>{if(c.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+c.length);return t?Cr(c):We(c)}});return Object.freeze(a)}function Qo(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function li(r){let e=Qo(r);return e+Math.ceil(e/2)}function Jo(r,e,t=!1){let n=r.length,i=Qo(e),o=li(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=t?Cr(r):We(r),a=Z(s,e-q)+q;return t?Or(a,i):st(a,i)}var es=BigInt(0),kr=BigInt(1);function hi(r,e){let t=e.negate();return r?t:e}function ts(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function pi(r,e){ts(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Ja(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function ed(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}var gi=new WeakMap,rs=new WeakMap;function mi(r){return rs.get(r)||1}function ns(r,e){return{constTimeNegate:hi,hasPrecomputes(t){return mi(t)!==1},unsafeLadder(t,n,i=r.ZERO){let o=t;for(;n>es;)n&kr&&(i=i.add(o)),o=o.double(),n>>=kr;return i},precomputeWindow(t,n){let{windows:i,windowSize:o}=pi(n,e),s=[],a=t,c=a;for(let d=0;d<i;d++){c=a,s.push(c);for(let m=1;m<o;m++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(t,n,i){let{windows:o,windowSize:s}=pi(t,e),a=r.ZERO,c=r.BASE,d=BigInt(2**t-1),m=2**t,l=BigInt(t);for(let u=0;u<o;u++){let p=u*s,h=Number(i&d);i>>=l,h>s&&(h-=m,i+=kr);let y=p,g=p+Math.abs(h)-1,f=u%2!==0,x=h<0;h===0?c=c.add(hi(f,n[y])):a=a.add(hi(x,n[g]))}return{p:a,f:c}},wNAFUnsafe(t,n,i,o=r.ZERO){let{windows:s,windowSize:a}=pi(t,e),c=BigInt(2**t-1),d=2**t,m=BigInt(t);for(let l=0;l<s;l++){let u=l*a;if(i===es)break;let p=Number(i&c);if(i>>=m,p>a&&(p-=d,i+=kr),p===0)continue;let h=n[u+Math.abs(p)-1];p<0&&(h=h.negate()),o=o.add(h)}return o},getPrecomputes(t,n,i){let o=gi.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&gi.set(n,i(o))),o},wNAFCached(t,n,i){let o=mi(t);return this.wNAF(o,this.getPrecomputes(o,t,i),n)},wNAFCachedUnsafe(t,n,i,o){let s=mi(t);return s===1?this.unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,i),n,o)},setWindowSize(t,n){ts(n,e),rs.set(t,n),gi.delete(t)}}}function is(r,e,t,n){if(Ja(t,r),ed(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,o=oi(BigInt(t.length)),s=o>12?o-3:o>4?o-2:o?2:1,a=(1<<s)-1,c=new Array(a+1).fill(i),d=Math.floor((e.BITS-1)/s)*s,m=i;for(let l=d;l>=0;l-=s){c.fill(i);for(let p=0;p<n.length;p++){let h=n[p],y=Number(h>>BigInt(l)&BigInt(a));c[y]=c[y].add(t[p])}let u=i;for(let p=c.length-1,h=i;p>0;p--)h=h.add(c[p]),u=u.add(h);if(m=m.add(u),l!==0)for(let p=0;p<s;p++)m=m.double()}return m}function yi(r){return di(r.Fp),at(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ui(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function os(r){r.lowS!==void 0&&xt("lowS",r.lowS),r.prehash!==void 0&&xt("prehash",r.prehash)}function td(r){let e=yi(r);at(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:rd,hexToBytes:nd}=ci,fi=class extends Error{constructor(e=""){super(e)}},Ze={Err:fi,_tlv:{encode:(r,e)=>{let{Err:t}=Ze;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,i=bt(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?bt(i.length/2|128):"";return bt(r)+o+i+e},decode(r,e){let{Err:t}=Ze,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let i=e[n++],o=!!(i&128),s=0;if(!o)s=i;else{let c=i&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let d=e.subarray(n,n+c);if(d.length!==c)throw new t("tlv.decode: length bytes not complete");if(d[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let m of d)s=s<<8|m;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=Ze;if(r<Qe)throw new e("integer: negative integers are not allowed");let t=bt(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=Ze;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return rd(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Ze,i=typeof r=="string"?nd(r):r;Kt(i);let{v:o,l:s}=n.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:d,l:m}=n.decode(2,c);if(m.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(d)}},hexFromSig(r){let{_tlv:e,_int:t}=Ze,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),o=n+i;return e.encode(48,o)}},Qe=BigInt(0),$=BigInt(1),np=BigInt(2),ss=BigInt(3),ip=BigInt(4);function id(r){let e=td(r),{Fp:t}=e,n=Dr(e.n,e.nBitLength),i=e.toBytes||((y,g,f)=>{let x=g.toAffine();return qt(Uint8Array.from([4]),t.toBytes(x.x),t.toBytes(x.y))}),o=e.fromBytes||(y=>{let g=y.subarray(1),f=t.fromBytes(g.subarray(0,t.BYTES)),x=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:f,y:x}});function s(y){let{a:g,b:f}=e,x=t.sqr(y),b=t.mul(x,y);return t.add(t.add(b,t.mul(y,g)),f)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return ir(y,$,e.n)}function c(y){let{allowedPrivateKeyLengths:g,nByteLength:f,wrapPrivateKey:x,n:b}=e;if(g&&typeof y!="bigint"){if(ot(y)&&(y=Et(y)),typeof y!="string"||!g.includes(y.length))throw new Error("invalid private key");y=y.padStart(f*2,"0")}let L;try{L=typeof y=="bigint"?y:We(he("private key",y,f))}catch{throw new Error("invalid private key, expected hex or "+f+" bytes, got "+typeof y)}return x&&(L=Z(L,b)),ct("private key",L,$,b),L}function d(y){if(!(y instanceof u))throw new Error("ProjectivePoint expected")}let m=Pr((y,g)=>{let{px:f,py:x,pz:b}=y;if(t.eql(b,t.ONE))return{x:f,y:x};let L=y.is0();g==null&&(g=L?t.ONE:t.inv(b));let T=t.mul(f,g),B=t.mul(x,g),U=t.mul(b,g);if(L)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:T,y:B}}),l=Pr(y=>{if(y.is0()){if(e.allowInfinityPoint&&!t.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:g,y:f}=y.toAffine();if(!t.isValid(g)||!t.isValid(f))throw new Error("bad point: x or y not FE");let x=t.sqr(f),b=s(g);if(!t.eql(x,b))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class u{constructor(g,f,x){if(this.px=g,this.py=f,this.pz=x,g==null||!t.isValid(g))throw new Error("x required");if(f==null||!t.isValid(f))throw new Error("y required");if(x==null||!t.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(g){let{x:f,y:x}=g||{};if(!g||!t.isValid(f)||!t.isValid(x))throw new Error("invalid affine point");if(g instanceof u)throw new Error("projective point not allowed");let b=L=>t.eql(L,t.ZERO);return b(f)&&b(x)?u.ZERO:new u(f,x,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let f=t.invertBatch(g.map(x=>x.pz));return g.map((x,b)=>x.toAffine(f[b])).map(u.fromAffine)}static fromHex(g){let f=u.fromAffine(o(he("pointHex",g)));return f.assertValidity(),f}static fromPrivateKey(g){return u.BASE.multiply(c(g))}static msm(g,f){return is(u,n,g,f)}_setWindowSize(g){h.setWindowSize(this,g)}assertValidity(){l(this)}hasEvenY(){let{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){d(g);let{px:f,py:x,pz:b}=this,{px:L,py:T,pz:B}=g,U=t.eql(t.mul(f,B),t.mul(L,b)),N=t.eql(t.mul(x,B),t.mul(T,b));return U&&N}negate(){return new u(this.px,t.neg(this.py),this.pz)}double(){let{a:g,b:f}=e,x=t.mul(f,ss),{px:b,py:L,pz:T}=this,B=t.ZERO,U=t.ZERO,N=t.ZERO,C=t.mul(b,b),G=t.mul(L,L),M=t.mul(T,T),_=t.mul(b,L);return _=t.add(_,_),N=t.mul(b,T),N=t.add(N,N),B=t.mul(g,N),U=t.mul(x,M),U=t.add(B,U),B=t.sub(G,U),U=t.add(G,U),U=t.mul(B,U),B=t.mul(_,B),N=t.mul(x,N),M=t.mul(g,M),_=t.sub(C,M),_=t.mul(g,_),_=t.add(_,N),N=t.add(C,C),C=t.add(N,C),C=t.add(C,M),C=t.mul(C,_),U=t.add(U,C),M=t.mul(L,T),M=t.add(M,M),C=t.mul(M,_),B=t.sub(B,C),N=t.mul(M,G),N=t.add(N,N),N=t.add(N,N),new u(B,U,N)}add(g){d(g);let{px:f,py:x,pz:b}=this,{px:L,py:T,pz:B}=g,U=t.ZERO,N=t.ZERO,C=t.ZERO,G=e.a,M=t.mul(e.b,ss),_=t.mul(f,L),ce=t.mul(x,T),E=t.mul(b,B),I=t.add(f,x),A=t.add(L,T);I=t.mul(I,A),A=t.add(_,ce),I=t.sub(I,A),A=t.add(f,b);let P=t.add(L,B);return A=t.mul(A,P),P=t.add(_,E),A=t.sub(A,P),P=t.add(x,b),U=t.add(T,B),P=t.mul(P,U),U=t.add(ce,E),P=t.sub(P,U),C=t.mul(G,A),U=t.mul(M,E),C=t.add(U,C),U=t.sub(ce,C),C=t.add(ce,C),N=t.mul(U,C),ce=t.add(_,_),ce=t.add(ce,_),E=t.mul(G,E),A=t.mul(M,A),ce=t.add(ce,E),E=t.sub(_,E),E=t.mul(G,E),A=t.add(A,E),_=t.mul(ce,A),N=t.add(N,_),_=t.mul(P,A),U=t.mul(I,U),U=t.sub(U,_),_=t.mul(I,ce),C=t.mul(P,C),C=t.add(C,_),new u(U,N,C)}subtract(g){return this.add(g.negate())}is0(){return this.equals(u.ZERO)}wNAF(g){return h.wNAFCached(this,g,u.normalizeZ)}multiplyUnsafe(g){let{endo:f,n:x}=e;ct("scalar",g,Qe,x);let b=u.ZERO;if(g===Qe)return b;if(this.is0()||g===$)return this;if(!f||h.hasPrecomputes(this))return h.wNAFCachedUnsafe(this,g,u.normalizeZ);let{k1neg:L,k1:T,k2neg:B,k2:U}=f.splitScalar(g),N=b,C=b,G=this;for(;T>Qe||U>Qe;)T&$&&(N=N.add(G)),U&$&&(C=C.add(G)),G=G.double(),T>>=$,U>>=$;return L&&(N=N.negate()),B&&(C=C.negate()),C=new u(t.mul(C.px,f.beta),C.py,C.pz),N.add(C)}multiply(g){let{endo:f,n:x}=e;ct("scalar",g,$,x);let b,L;if(f){let{k1neg:T,k1:B,k2neg:U,k2:N}=f.splitScalar(g),{p:C,f:G}=this.wNAF(B),{p:M,f:_}=this.wNAF(N);C=h.constTimeNegate(T,C),M=h.constTimeNegate(U,M),M=new u(t.mul(M.px,f.beta),M.py,M.pz),b=C.add(M),L=G.add(_)}else{let{p:T,f:B}=this.wNAF(g);b=T,L=B}return u.normalizeZ([b,L])[0]}multiplyAndAddUnsafe(g,f,x){let b=u.BASE,L=(B,U)=>U===Qe||U===$||!B.equals(b)?B.multiplyUnsafe(U):B.multiply(U),T=L(this,f).add(L(g,x));return T.is0()?void 0:T}toAffine(g){return m(this,g)}isTorsionFree(){let{h:g,isTorsionFree:f}=e;if(g===$)return!0;if(f)return f(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:f}=e;return g===$?this:f?f(u,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return xt("isCompressed",g),this.assertValidity(),i(u,this,g)}toHex(g=!0){return xt("isCompressed",g),Et(this.toRawBytes(g))}}u.BASE=new u(e.Gx,e.Gy,t.ONE),u.ZERO=new u(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,h=ns(u,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function od(r){let e=yi(r);return at(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function cs(r){let e=od(r),{Fp:t,n}=e,i=t.BYTES+1,o=2*t.BYTES+1;function s(E){return Z(E,n)}function a(E){return Rr(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:m,isWithinCurveOrder:l}=id({...e,toBytes(E,I,A){let P=I.toAffine(),R=t.toBytes(P.x),V=qt;return xt("isCompressed",A),A?V(Uint8Array.from([I.hasEvenY()?2:3]),R):V(Uint8Array.from([4]),R,t.toBytes(P.y))},fromBytes(E){let I=E.length,A=E[0],P=E.subarray(1);if(I===i&&(A===2||A===3)){let R=We(P);if(!ir(R,$,t.ORDER))throw new Error("Point is not on curve");let V=m(R),te;try{te=t.sqrt(V)}catch(fe){let re=fe instanceof Error?": "+fe.message:"";throw new Error("Point is not on curve"+re)}let Q=(te&$)===$;return(A&1)===1!==Q&&(te=t.neg(te)),{x:R,y:te}}else if(I===o&&A===4){let R=t.fromBytes(P.subarray(0,t.BYTES)),V=t.fromBytes(P.subarray(t.BYTES,2*t.BYTES));return{x:R,y:V}}else{let R=i,V=o;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+V+", got "+I)}}}),u=E=>Et(st(E,e.nByteLength));function p(E){let I=n>>$;return E>I}function h(E){return p(E)?s(-E):E}let y=(E,I,A)=>We(E.slice(I,A));class g{constructor(I,A,P){this.r=I,this.s=A,this.recovery=P,this.assertValidity()}static fromCompact(I){let A=e.nByteLength;return I=he("compactSignature",I,A*2),new g(y(I,0,A),y(I,A,2*A))}static fromDER(I){let{r:A,s:P}=Ze.toSig(he("DER",I));return new g(A,P)}assertValidity(){ct("r",this.r,$,n),ct("s",this.s,$,n)}addRecoveryBit(I){return new g(this.r,this.s,I)}recoverPublicKey(I){let{r:A,s:P,recovery:R}=this,V=B(he("msgHash",I));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");let te=R===2||R===3?A+e.n:A;if(te>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let Q=R&1?"03":"02",Oe=c.fromHex(Q+u(te)),fe=a(te),re=s(-V*fe),St=s(P*fe),Je=c.BASE.multiplyAndAddUnsafe(Oe,re,St);if(!Je)throw new Error("point at infinify");return Je.assertValidity(),Je}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return Ze.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}let f={isValidPrivateKey(E){try{return d(E),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let E=li(e.n);return Jo(e.randomBytes(E),e.n)},precompute(E=8,I=c.BASE){return I._setWindowSize(E),I.multiply(BigInt(3)),I}};function x(E,I=!0){return c.fromPrivateKey(E).toRawBytes(I)}function b(E){let I=ot(E),A=typeof E=="string",P=(I||A)&&E.length;return I?P===i||P===o:A?P===2*i||P===2*o:E instanceof c}function L(E,I,A=!0){if(b(E))throw new Error("first arg must be private key");if(!b(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(d(E)).toRawBytes(A)}let T=e.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");let I=We(E),A=E.length*8-e.nBitLength;return A>0?I>>BigInt(A):I},B=e.bits2int_modN||function(E){return s(T(E))},U=or(e.nBitLength);function N(E){return ct("num < 2^"+e.nBitLength,E,Qe,U),st(E,e.nByteLength)}function C(E,I,A=G){if(["recovered","canonical"].some(dt=>dt in A))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:R}=e,{lowS:V,prehash:te,extraEntropy:Q}=A;V==null&&(V=!0),E=he("msgHash",E),os(A),te&&(E=he("prehashed msgHash",P(E)));let Oe=B(E),fe=d(I),re=[N(fe),N(Oe)];if(Q!=null&&Q!==!1){let dt=Q===!0?R(t.BYTES):Q;re.push(he("extraEntropy",dt))}let St=qt(...re),Je=Oe;function Yr(dt){let At=T(dt);if(!l(At))return;let Xr=a(At),Ht=c.BASE.multiply(At).toAffine(),ut=s(Ht.x);if(ut===Qe)return;let jt=s(Xr*s(Je+ut*fe));if(jt===Qe)return;let Bt=(Ht.x===ut?0:2)|Number(Ht.y&$),Ri=jt;return V&&p(jt)&&(Ri=h(jt),Bt^=1),new g(ut,Ri,Bt)}return{seed:St,k2sig:Yr}}let G={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function _(E,I,A=G){let{seed:P,k2sig:R}=C(E,I,A),V=e;return si(V.hash.outputLen,V.nByteLength,V.hmac)(P,R)}c.BASE._setWindowSize(8);function ce(E,I,A,P=M){let R=E;I=he("msgHash",I),A=he("publicKey",A);let{lowS:V,prehash:te,format:Q}=P;if(os(P),"strict"in P)throw new Error("options.strict was renamed to lowS");if(Q!==void 0&&Q!=="compact"&&Q!=="der")throw new Error("format must be compact or der");let Oe=typeof R=="string"||ot(R),fe=!Oe&&!Q&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!Oe&&!fe)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let re,St;try{if(fe&&(re=new g(R.r,R.s)),Oe){try{Q!=="compact"&&(re=g.fromDER(R))}catch(Bt){if(!(Bt instanceof Ze.Err))throw Bt}!re&&Q!=="der"&&(re=g.fromCompact(R))}St=c.fromHex(A)}catch{return!1}if(!re||V&&re.hasHighS())return!1;te&&(I=e.hash(I));let{r:Je,s:Yr}=re,dt=B(I),At=a(Yr),Xr=s(dt*At),Ht=s(Je*At),ut=c.BASE.multiplyAndAddUnsafe(St,Xr,Ht)?.toAffine();return ut?s(ut.x)===Je:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:L,sign:_,verify:ce,ProjectivePoint:c,Signature:g,utils:f}}function sd(r){return{hash:r,hmac:(e,...t)=>ti(r,e,zo(...t)),randomBytes:Ho}}function as(r,e){let t=n=>cs({...r,...sd(n)});return{...t(e),create:t}}var ls=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ds=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),cd=BigInt(1),wi=BigInt(2),us=(r,e)=>(r+e/wi)/e;function ad(r){let e=ls,t=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),d=r*r*r%e,m=d*d*r%e,l=pe(m,t,e)*m%e,u=pe(l,t,e)*m%e,p=pe(u,wi,e)*d%e,h=pe(p,i,e)*p%e,y=pe(h,o,e)*h%e,g=pe(y,a,e)*y%e,f=pe(g,c,e)*g%e,x=pe(f,a,e)*y%e,b=pe(x,t,e)*m%e,L=pe(b,s,e)*h%e,T=pe(L,n,e)*d%e,B=pe(T,wi,e);if(!xi.eql(xi.sqr(B),r))throw new Error("Cannot find square root");return B}var xi=Dr(ls,void 0,void 0,{sqrt:ad}),zt=as({a:BigInt(0),b:BigInt(7),Fp:xi,n:ds,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=ds,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-cd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,s=BigInt("0x100000000000000000000000000000000"),a=us(o*r,e),c=us(-n*r,e),d=Z(r-a*t-c*i,e),m=Z(-a*n-c*o,e),l=d>s,u=m>s;if(l&&(d=e-d),u&&(m=e-m),d>s||m>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:d,k2neg:u,k2:m}}}},Go),pp=BigInt(0);var gp=zt.ProjectivePoint;var hs=Ut(ne("node:crypto"),1);var _r=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function ps(r,e,t){let n=hs.default.createHash("sha256");if(t instanceof Uint8Array)n.update(t);else for(let o of t)n.update(o);let i=n.digest();try{return zt.verify(e,i,r)}catch(o){throw new _r(String(o))}}var Mr=class{type="secp256k1";raw;_key;constructor(e){this._key=ms(e),this.raw=gs(this._key)}toMultihash(){return He.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:je(this.raw,e.raw)}verify(e,t){return ps(this._key,t,e)}};function ys(r){return new Mr(r)}function gs(r){return zt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ms(r){try{return zt.ProjectivePoint.fromHex(r),r}catch(e){throw new ur(String(e))}}function fs(r){let{Type:e,Data:t}=rr.decode(r.digest),n=t??new Uint8Array;switch(e){case me.Ed25519:return To(n);case me.secp256k1:return ys(n);default:throw new $t}}function xr(r){return rr.encode({Type:me[r.type],Data:r.raw})}var ws=Symbol.for("nodejs.util.inspect.custom"),dd=114,sr=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()})`}[Wr]=!0;toString(){return this.string==null&&(this.string=K.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ee.createV1(dd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return je(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return je(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[ws](){return`PeerId(${this.toString()})`}},Fr=class extends sr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Kr=class extends sr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},qr=class extends sr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},ud=2336,zr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=He.digest(Ge(this.url))}[ws](){return`PeerId(${this.url})`}[Wr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ee.createV1(ud,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=z(e)),e.toString()===this.toString())}};function xs(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=pt(K.decode(`z${r}`));else{if(e==null)throw new Lt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=pt(e.decode(r))}return ld(t)}function ld(r){if(pd(r))return new Fr({multihash:r});if(hd(r))try{let e=fs(r);if(e.type==="Ed25519")return new Kr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new qr({multihash:r,publicKey:e})}catch{let t=z(r.digest);return new zr(new URL(t))}throw new lr("Supplied PeerID Multihash is invalid")}function hd(r){return r.code===He.code}function pd(r){return r.code===Nn.code}var ye=ne("node:net");function Vr(r){return!!(0,ye.isIP)(r)}var bs=Ut(Es(),1),gd=["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"],md=gd.map(r=>new bs.Netmask(r));function Ei(r){for(let e of md)if(e.contains(r))return!0;return!1}function yd(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function fd(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),i=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return Ei(i)}function wd(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function xd(r){let e=r.split(":"),t=e[e.length-1];return Ei(t)}function Ed(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Is(r){return(0,ye.isIPv4)(r)?Ei(r):yd(r)?fd(r):wd(r)?xd(r):(0,ye.isIPv6)(r)?Ed(r):void 0}var bd=4,Id=41,vd=53,Sd=54,Ad=55,Bd=56;function vs(r){try{let[[e,t]]=r.stringTuples();if(t==null)return!0;if(e===vd||e===Sd||e===Ad||e===Bd)return!1;if(e===bd||e===Id)return Is(t)??!1}catch{}return!0}var Hr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,i){return this.readAtomically(()=>{let o=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",d=2**(8*i)-1;for(;;){let m=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let u=Number.parseInt(l,e);if(!Number.isNaN(u))return u});if(m===void 0)break;if(o*=e,o+=m,o>d||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let i=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[i]=s[0],t[i+1]=s[1],t[i+2]=s[2],t[i+3]=s[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];t[i]=o>>8,t[i+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,i]=e(t);if(n===16)return t;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),s=16-(n+2),[a]=e(o.subarray(0,s));return t.set(o.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var x0=new Hr;var U0=parseInt("0xFFFF",16),L0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Bs=ye.isIPv4,Od=ye.isIPv6,bi=function(r){let e=0;if(r=r.toString().trim(),Bs(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Od(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=Bs(t[n]),s;o&&(s=bi(t[n]),t[n]=z(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,z(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},Us=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let i=[];for(let o=0;o<t;o++)i.push(r[e+o]);return i.join(".")}if(t===16){let i=[];for(let o=0;o<t;o+=2)i.push(n.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Vt={},Ii={},Rd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Rd.forEach(r=>{let e=Dd(...r);Ii[e.code]=e,Vt[e.name]=e});function Dd(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function k(r){if(typeof r=="number"){if(Ii[r]!=null)return Ii[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Vt[r]!=null)return Vt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var lg=k("ip4"),hg=k("ip6"),pg=k("ipcidr");function Bi(r,e){switch(k(r).code){case 4:case 41:return _d(e);case 42:return Ai(e);case 43:return z(e,"base10");case 6:case 273:case 33:case 132:return Ns(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ai(e);case 421:return qd(e);case 444:return Ts(e);case 445:return Ts(e);case 466:return Kd(e);case 481:return globalThis.encodeURIComponent(Ai(e));default:return z(e,"base16")}}function Ui(r,e){switch(k(r).code){case 4:return Ls(e);case 41:return Ls(e);case 42:return Si(e);case 43:return Ge(e,"base10");case 6:case 273:case 33:case 132:return Li(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Si(e);case 421:return Md(e);case 444:return zd(e);case 445:return Vd(e);case 466:return Fd(e);case 481:return Si(globalThis.decodeURIComponent(e));default:return Ge(e,"base16")}}var vi=Object.values(Qt).map(r=>r.decoder),kd=function(){let r=vi[0].or(vi[1]);return vi.slice(2).forEach(e=>r=r.or(e)),r}();function Ls(r){if(!Vr(r))throw new Error("invalid ip address");return bi(r)}function _d(r){let e=Us(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Vr(e))throw new Error("invalid ip address");return e}function Li(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Ns(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Si(r){let e=Ge(r),t=Uint8Array.from(Dt(e.length));return Ce([t,e],t.length+e.length)}function Ai(r){let e=mt(r);if(r=r.slice(se(e)),r.length!==e)throw new Error("inconsistent lengths");return z(r)}function Md(r){let e;r[0]==="Q"||r[0]==="1"?e=pt(K.decode(`z${r}`)).bytes:e=ee.parse(r).multihash.bytes;let t=Uint8Array.from(Dt(e.length));return Ce([t,e],t.length+e.length)}function Fd(r){let e=kd.decode(r),t=Uint8Array.from(Dt(e.length));return Ce([t,e],t.length+e.length)}function Kd(r){let e=mt(r),t=r.slice(se(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+z(t,"base64url")}function qd(r){let e=mt(r),t=r.slice(se(e));if(t.length!==e)throw new Error("inconsistent lengths");return z(t,"base58btc")}function zd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Ve.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Li(n);return Ce([t,i],t.length+i.length)}function Vd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Ve.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Li(n);return Ce([t,i],t.length+i.length)}function Ts(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=z(e,"base32"),i=Ns(t);return`${n}:${i}`}function Cs(r){r=Ti(r);let e=[],t=[],n=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){let s=i[o],a=k(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=i.length)throw new jr("invalid address: "+r);if(a.path===!0){n=Ti(i.slice(o).join("/")),e.push([a.code,Ui(a.code,n)]),t.push([a.code,n]);break}let c=Ui(a.code,i[o]);e.push([a.code,c]),t.push([a.code,Bi(a.code,c)])}return{string:Os(t),bytes:Ci(e),tuples:e,stringTuples:t,path:n}}function Ni(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=mt(r,i),s=se(o),a=k(o),c=Hd(a,r.slice(i+s));if(c===0){e.push([o]),t.push([o]),i+=s;continue}let d=r.slice(i+s,i+s+c);if(i+=c+s,i>r.length)throw new jr("Invalid address Uint8Array: "+z(r,"base16"));e.push([o,d]);let m=Bi(o,d);if(t.push([o,m]),a.path===!0){n=m;break}}return{bytes:Uint8Array.from(r),string:Os(t),tuples:e,stringTuples:t,path:n}}function Os(r){let e=[];return r.map(t=>{let n=k(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Ti(e.join("/"))}function Ci(r){return Ce(r.map(e=>{let t=k(e[0]),n=Uint8Array.from(Dt(t.code));return e.length>1&&e[1]!=null&&(n=Ce([n,e[1]])),n}))}function Hd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=mt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+se(t)}}function Ti(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var jr=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};var jd=Symbol.for("nodejs.util.inspect.custom"),Pi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),$d=[k("dns").code,k("dns4").code,k("dns6").code,k("dnsaddr").code],Oi=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},$r=class r{bytes;#e;#t;#r;#n;[Pi]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ni(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Cs(e)}else if(Rs(e))t=Ni(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,i,o="",s=k("tcp"),a=k("udp"),c=k("ip4"),d=k("ip6"),m=k("dns6"),l=k("ip6zone");for(let[p,h]of this.stringTuples())p===l.code&&(o=`%${h??""}`),$d.includes(p)&&(t=s.name==="tcp"?"tcp":"udp",i=443,n=`${h??""}${o}`,e=p===m.code?6:4),(p===s.code||p===a.code)&&(t=k(p).name==="tcp"?"tcp":"udp",i=parseInt(h??"")),(p===c.code||p===d.code)&&(t=k(p).name==="tcp"?"tcp":"udp",n=`${h??""}${o}`,e=p===d.code?6:4);if(e==null||t==null||n==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:i}}protos(){return this.#t.map(([e])=>Object.assign({},k(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>k(e).name)}tuples(){return this.#t.map(([e,t])=>t==null?[e]:[e,t])}stringTuples(){return this.#r.map(([e,t])=>t==null?[e]:[e,t])}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),i=n.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,i))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Ci(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===Vt.p2p.code&&e.push([n,i]),n===Vt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?z(K.decode(`z${n}`),"base58btc"):z(ee.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return je(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=Ps.get(t.name);if(n==null)throw new Oi(`no available resolver for ${t.name}`);return(await n(this,e)).map(o=>ar(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[jd](){return`Multiaddr(${this.#e})`}};var Ps=new Map;function Rs(r){return!!r?.[Pi]}function ar(r){return new $r(r)}function Ds(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function ks(r,e,t,n){if(r.answers==null)return;let i,o=[];if(r.answers.forEach(s=>{switch(s.type){case"PTR":i=s;break;case"TXT":o.push(s);break;default:break}}),r.additionals.forEach(s=>{switch(s.type){case"TXT":o.push(s);break;default:break}}),!(i==null||i?.name!==t||o.length===0||i.data.startsWith(e)))try{let s=o.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>ar(c.toString().substring(8))),a=s[0].getPeerId();if(a==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",a),{id:xs(a),multiaddrs:s.map(c=>c.decapsulateCode(k("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function _s(r,e,t,n,i,o,s){if(!o){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let a=[];a.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(Gd).forEach(c=>{let d="dnsaddr="+c.toString();if(d.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",c);return}if(c.getPeerId()==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",c);return}a.push({name:t+"."+i,type:"TXT",class:"IN",ttl:120,data:d})}),s?.log.trace("responding to query"),e.respond(a)}}function Gd(r){return!!vs(r)}function Ms(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var Gr=class extends hr{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,t={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=t.broadcast!==!1,this.interval=t.interval??1e3*10,this.serviceTag=t.serviceTag??"_p2p._udp.local",this.ip=t.ip??"224.0.0.251",this.peerName=t.peerName??Ms(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=t.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[ki]=this;[Symbol.toStringTag]="@libp2p/mdns";[Fi]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Fs.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=Ds(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),_s(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let t=ks(e,this.peerName,this.serviceTag,{log:this.log});t!=null&&(this.log("discovered peer in mDNS query response %p",t.id),this.dispatchEvent(new CustomEvent("peer",{detail:t})))}catch(t){this.log.error("Error processing peer response",t)}}_onMdnsWarning(e){this.log.error("mdns warning",e)}_onMdnsError(e){this.log.error("mdns error",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function Xd(r={}){return e=>new Gr(e,r)}return js(Wd);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var Ks=Object.create;var dr=Object.defineProperty;var qs=Object.getOwnPropertyDescriptor;var zs=Object.getOwnPropertyNames;var Vs=Object.getPrototypeOf,Hs=Object.prototype.hasOwnProperty;var ne=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var ve=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ie=(r,e)=>{for(var t in e)dr(r,t,{get:e[t],enumerable:!0})},Di=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of zs(e))!Hs.call(r,i)&&i!==t&&dr(r,i,{get:()=>e[i],enumerable:!(n=qs(e,i))||n.enumerable});return r};var Ut=(r,e,t)=>(t=r!=null?Ks(Vs(r)):{},Di(e||!r||!r.__esModule?dr(t,"default",{value:r,enumerable:!0}):t,r)),js=r=>Di(dr({},"__esModule",{value:!0}),r);var Ki=ve(Qr=>{"use strict";Qr.toString=function(r){switch(r){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+r};Qr.toType=function(r){switch(r.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return r.toUpperCase().startsWith("UNKNOWN_")?parseInt(r.slice(8)):0}});var qi=ve(Jr=>{"use strict";Jr.toString=function(r){switch(r){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+r};Jr.toRcode=function(r){switch(r.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var zi=ve(en=>{"use strict";en.toString=function(r){switch(r){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+r};en.toOpcode=function(r){switch(r.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var Vi=ve(tn=>{"use strict";tn.toString=function(r){switch(r){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+r};tn.toClass=function(r){switch(r.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Hi=ve(rn=>{"use strict";rn.toString=function(r){switch(r){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return r<0?null:`OPTION_${r}`};rn.toCode=function(r){if(typeof r=="number")return r;if(!r)return-1;switch(r.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=r.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var Gi=ve(($i,nn)=>{var ji=function(r){"use strict";Object.defineProperty(r,"__esModule",{value:!0}),r.decode=l,r.encode=m,r.familyOf=d,r.name=void 0,r.sizeOf=c,r.v6=r.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,t=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,o={name:"v4",size:t,isFormat:u=>e.test(u),encode(u,p,h){h=~~h,p=p||new Uint8Array(h+t);let y=u.length,g=0;for(let f=0;f<y;){let x=u.charCodeAt(f++);x===46?(p[h++]=g,g=0):g=g*10+(x-48)}return p[h]=g,p},decode(u,p){return p=~~p,`${u[p++]}.${u[p++]}.${u[p++]}.${u[p]}`}};r.v4=o;let s={name:"v6",size:i,isFormat:u=>u.length>0&&n.test(u),encode(u,p,h){h=~~h;let y=h+i,g=-1,f=0,x=0,b=!0,L=!1;p=p||new Uint8Array(h+i);for(let T=0;T<u.length;T++){let B=u.charCodeAt(T);B===58?(b?g!==-1?(h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2):h<y&&(g=h):(L===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2),f=0,x=0),b=!0,L=!1):B===46?(h<y&&(p[h]=x),h++,x=0,f=0,b=!1,L=!0):(b=!1,B>=97?B-=87:B>=65?B-=55:(B-=48,x=x*10+B),f=(f<<4)+B)}if(b===!1)L===!0?(h<y&&(p[h]=x),h++):(h<y&&(p[h]=f>>8),h<y-1&&(p[h+1]=f&255),h+=2);else if(g===0)h<y&&(p[h]=0),h<y-1&&(p[h+1]=0),h+=2;else if(g!==-1){h+=2;for(let T=Math.min(h-1,y-1);T>=g+2;T--)p[T]=p[T-2];p[g]=0,p[g+1]=0,g=h}if(g!==h&&g!==-1)for(h>y-2&&(h=y-2);y>g;)p[--y]=h<y&&h>g?p[--h]:0;else for(;h<y;)p[h++]=0;return p},decode(u,p){p=~~p;let h="";for(let y=0;y<i;y+=2)y!==0&&(h+=":"),h+=(u[p+y]<<8|u[p+y+1]).toString(16);return h.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};r.v6=s;let a="ip";r.name=a;function c(u){if(o.isFormat(u))return o.size;if(s.isFormat(u))return s.size;throw Error(`Invalid ip address: ${u}`)}function d(u){return c(u)===o.size?1:2}function m(u,p,h){h=~~h;let y=c(u);return typeof p=="function"&&(p=p(h+y)),y===o.size?o.encode(u,p,h):s.encode(u,p,h)}function l(u,p,h){if(p=~~p,h=h||u.length-p,h===o.size)return o.decode(u,p,h);if(h===s.size)return s.decode(u,p,h);throw Error(`Invalid buffer size needs to be ${o.size} for v4 or ${s.size} for v6.`)}return"default"in r?r.default:r}({});typeof define=="function"&&define.amd?define([],function(){return ji}):typeof nn=="object"&&typeof $i=="object"&&(nn.exports=ji)});var Wi=ve(v=>{"use strict";var S=ne("buffer").Buffer,ze=Ki(),$s=qi(),Gs=zi(),gr=Vi(),on=Hi(),lt=Gi(),Ys=0,Yi=32768,sn=32768,Xs=~sn,Xi=32768,Ws=~Xi,w=v.name={};w.encode=function(r,e,t,{mail:n=!1}={}){e||(e=S.alloc(w.encodingLength(r))),t||(t=0);let i=t,o=r.replace(/^\.|\.$/gm,"");if(o.length){let s=[];if(n){let a="";o.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=o.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],t+1);e[t]=c,t+=c+1}}return e[t++]=0,w.encode.bytes=t-i,e};w.encode.bytes=0;w.decode=function(r,e,{mail:t=!1}={}){e||(e=0);let n=[],i=e,o=0,s=0,a=!1;for(;;){if(e>=r.length)throw new Error("Cannot decode name (buffer overflow)");let c=r[e++];if(s+=a?0:1,c===0)break;if(c&192)if((c&192)===192){if(e+1>r.length)throw new Error("Cannot decode name (buffer overflow)");let d=r.readUInt16BE(e-1)-49152;if(d>=i)throw new Error("Cannot decode name (bad pointer)");e=d,i=d,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)");else{if(e+c>r.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=c+1,o>254)throw new Error("Cannot decode name (name too long)");let d=r.toString("utf-8",e,e+c);t&&(d=d.replace(/\./g,"\\.")),n.push(d),e+=c,s+=a?0:c}}return w.decode.bytes=s,n.length===0?".":n.join(".")};w.decode.bytes=0;w.encodingLength=function(r){return r==="."||r===".."?1:S.byteLength(r.replace(/^\.|\.$/gm,""))+2};var O={};O.encode=function(r,e,t){e||(e=S.alloc(O.encodingLength(r))),t||(t=0);let n=e.write(r,t+1);return e[t]=n,O.encode.bytes=n+1,e};O.encode.bytes=0;O.decode=function(r,e){e||(e=0);let t=r[e],n=r.toString("utf-8",e+1,e+1+t);return O.decode.bytes=t+1,n};O.decode.bytes=0;O.encodingLength=function(r){return S.byteLength(r)+1};var Ee={};Ee.encode=function(r,e,t){e||(e=Ee.encodingLength(r)),t||(t=0);let n=(r.flags||0)&32767,i=r.type==="response"?Yi:Ys;return e.writeUInt16BE(r.id||0,t),e.writeUInt16BE(n|i,t+2),e.writeUInt16BE(r.questions.length,t+4),e.writeUInt16BE(r.answers.length,t+6),e.writeUInt16BE(r.authorities.length,t+8),e.writeUInt16BE(r.additionals.length,t+10),e};Ee.encode.bytes=12;Ee.decode=function(r,e){if(e||(e=0),r.length<12)throw new Error("Header must be 12 bytes");let t=r.readUInt16BE(e+2);return{id:r.readUInt16BE(e),type:t&Yi?"response":"query",flags:t&32767,flag_qr:(t>>15&1)===1,opcode:Gs.toString(t>>11&15),flag_aa:(t>>10&1)===1,flag_tc:(t>>9&1)===1,flag_rd:(t>>8&1)===1,flag_ra:(t>>7&1)===1,flag_z:(t>>6&1)===1,flag_ad:(t>>5&1)===1,flag_cd:(t>>4&1)===1,rcode:$s.toString(t&15),questions:new Array(r.readUInt16BE(e+4)),answers:new Array(r.readUInt16BE(e+6)),authorities:new Array(r.readUInt16BE(e+8)),additionals:new Array(r.readUInt16BE(e+10))}};Ee.decode.bytes=12;Ee.encodingLength=function(){return 12};var Pe=v.unknown={};Pe.encode=function(r,e,t){return e||(e=S.alloc(Pe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.length,t),r.copy(e,t+2),Pe.encode.bytes=r.length+2,e};Pe.encode.bytes=0;Pe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=r.slice(e+2,e+2+t);return Pe.decode.bytes=t+2,n};Pe.decode.bytes=0;Pe.encodingLength=function(r){return r.length+2};var Re=v.ns={};Re.encode=function(r,e,t){return e||(e=S.alloc(Re.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),Re.encode.bytes=w.encode.bytes+2,e};Re.encode.bytes=0;Re.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n=w.decode(r,e+2);return Re.decode.bytes=t+2,n};Re.decode.bytes=0;Re.encodingLength=function(r){return w.encodingLength(r)+2};var De=v.soa={};De.encode=function(r,e,t){e||(e=S.alloc(De.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mname,e,t),t+=w.encode.bytes,w.encode(r.rname,e,t,{mail:!0}),t+=w.encode.bytes,e.writeUInt32BE(r.serial||0,t),t+=4,e.writeUInt32BE(r.refresh||0,t),t+=4,e.writeUInt32BE(r.retry||0,t),t+=4,e.writeUInt32BE(r.expire||0,t),t+=4,e.writeUInt32BE(r.minimum||0,t),t+=4,e.writeUInt16BE(t-n-2,n),De.encode.bytes=t-n,e};De.encode.bytes=0;De.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mname=w.decode(r,e),e+=w.decode.bytes,n.rname=w.decode(r,e,{mail:!0}),e+=w.decode.bytes,n.serial=r.readUInt32BE(e),e+=4,n.refresh=r.readUInt32BE(e),e+=4,n.retry=r.readUInt32BE(e),e+=4,n.expire=r.readUInt32BE(e),e+=4,n.minimum=r.readUInt32BE(e),e+=4,De.decode.bytes=e-t,n};De.decode.bytes=0;De.encodingLength=function(r){return 22+w.encodingLength(r.mname)+w.encodingLength(r.rname)};var ke=v.txt={};ke.encode=function(r,e,t){Array.isArray(r)||(r=[r]);for(let i=0;i<r.length;i++)if(typeof r[i]=="string"&&(r[i]=S.from(r[i])),!S.isBuffer(r[i]))throw new Error("Must be a Buffer");e||(e=S.alloc(ke.encodingLength(r))),t||(t=0);let n=t;return t+=2,r.forEach(function(i){e[t++]=i.length,i.copy(e,t,0,i.length),t+=i.length}),e.writeUInt16BE(t-n-2,n),ke.encode.bytes=t-n,e};ke.encode.bytes=0;ke.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=[];for(;n>0;){let o=r[e++];if(--n,n<o)throw new Error("Buffer overflow");i.push(r.slice(e,e+o)),e+=o,n-=o}return ke.decode.bytes=e-t,i};ke.decode.bytes=0;ke.encodingLength=function(r){Array.isArray(r)||(r=[r]);let e=2;return r.forEach(function(t){typeof t=="string"?e+=S.byteLength(t)+1:e+=t.length+1}),e};var _e=v.null={};_e.encode=function(r,e,t){e||(e=S.alloc(_e.encodingLength(r))),t||(t=0),typeof r=="string"&&(r=S.from(r)),r||(r=S.alloc(0));let n=t;t+=2;let i=r.length;return r.copy(e,t,0,i),t+=i,e.writeUInt16BE(t-n-2,n),_e.encode.bytes=t-n,e};_e.encode.bytes=0;_e.decode=function(r,e){e||(e=0);let t=e,n=r.readUInt16BE(e);e+=2;let i=r.slice(e,e+n);return e+=n,_e.decode.bytes=e-t,i};_e.decode.bytes=0;_e.encodingLength=function(r){return r?(S.isBuffer(r)?r.length:S.byteLength(r))+2:2};var Me=v.hinfo={};Me.encode=function(r,e,t){e||(e=S.alloc(Me.encodingLength(r))),t||(t=0);let n=t;return t+=2,O.encode(r.cpu,e,t),t+=O.encode.bytes,O.encode(r.os,e,t),t+=O.encode.bytes,e.writeUInt16BE(t-n-2,n),Me.encode.bytes=t-n,e};Me.encode.bytes=0;Me.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.cpu=O.decode(r,e),e+=O.decode.bytes,n.os=O.decode(r,e),e+=O.decode.bytes,Me.decode.bytes=e-t,n};Me.decode.bytes=0;Me.encodingLength=function(r){return O.encodingLength(r.cpu)+O.encodingLength(r.os)+2};var we=v.ptr={},Zs=v.cname=we,Qs=v.dname=we;we.encode=function(r,e,t){return e||(e=S.alloc(we.encodingLength(r))),t||(t=0),w.encode(r,e,t+2),e.writeUInt16BE(w.encode.bytes,t),we.encode.bytes=w.encode.bytes+2,e};we.encode.bytes=0;we.decode=function(r,e){e||(e=0);let t=w.decode(r,e+2);return we.decode.bytes=w.decode.bytes+2,t};we.decode.bytes=0;we.encodingLength=function(r){return w.encodingLength(r)+2};var Fe=v.srv={};Fe.encode=function(r,e,t){e||(e=S.alloc(Fe.encodingLength(r))),t||(t=0),e.writeUInt16BE(r.priority||0,t+2),e.writeUInt16BE(r.weight||0,t+4),e.writeUInt16BE(r.port||0,t+6),w.encode(r.target,e,t+8);let n=w.encode.bytes+6;return e.writeUInt16BE(n,t),Fe.encode.bytes=n+2,e};Fe.encode.bytes=0;Fe.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e),n={};return n.priority=r.readUInt16BE(e+2),n.weight=r.readUInt16BE(e+4),n.port=r.readUInt16BE(e+6),n.target=w.decode(r,e+8),Fe.decode.bytes=t+2,n};Fe.decode.bytes=0;Fe.encodingLength=function(r){return 8+w.encodingLength(r.target)};var ae=v.caa={};ae.ISSUER_CRITICAL=128;ae.encode=function(r,e,t){let n=ae.encodingLength(r);return e||(e=S.alloc(ae.encodingLength(r))),t||(t=0),r.issuerCritical&&(r.flags=ae.ISSUER_CRITICAL),e.writeUInt16BE(n-2,t),t+=2,e.writeUInt8(r.flags||0,t),t+=1,O.encode(r.tag,e,t),t+=O.encode.bytes,e.write(r.value,t),t+=S.byteLength(r.value),ae.encode.bytes=n,e};ae.encode.bytes=0;ae.decode=function(r,e){e||(e=0);let t=r.readUInt16BE(e);e+=2;let n=e,i={};return i.flags=r.readUInt8(e),e+=1,i.tag=O.decode(r,e),e+=O.decode.bytes,i.value=r.toString("utf-8",e,n+t),i.issuerCritical=!!(i.flags&ae.ISSUER_CRITICAL),ae.decode.bytes=t+2,i};ae.decode.bytes=0;ae.encodingLength=function(r){return O.encodingLength(r.tag)+O.encodingLength(r.value)+2};var et=v.mx={};et.encode=function(r,e,t){e||(e=S.alloc(et.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,w.encode(r.exchange,e,t),t+=w.encode.bytes,e.writeUInt16BE(t-n-2,n),et.encode.bytes=t-n,e};et.encode.bytes=0;et.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.preference=r.readUInt16BE(e),e+=2,n.exchange=w.decode(r,e),e+=w.decode.bytes,et.decode.bytes=e-t,n};et.encodingLength=function(r){return 4+w.encodingLength(r.exchange)};var Ke=v.a={};Ke.encode=function(r,e,t){return e||(e=S.alloc(Ke.encodingLength(r))),t||(t=0),e.writeUInt16BE(4,t),t+=2,lt.v4.encode(r,e,t),Ke.encode.bytes=6,e};Ke.encode.bytes=0;Ke.decode=function(r,e){e||(e=0),e+=2;let t=lt.v4.decode(r,e);return Ke.decode.bytes=6,t};Ke.decode.bytes=0;Ke.encodingLength=function(){return 6};var qe=v.aaaa={};qe.encode=function(r,e,t){return e||(e=S.alloc(qe.encodingLength(r))),t||(t=0),e.writeUInt16BE(16,t),t+=2,lt.v6.encode(r,e,t),qe.encode.bytes=18,e};qe.encode.bytes=0;qe.decode=function(r,e){e||(e=0),e+=2;let t=lt.v6.decode(r,e);return qe.decode.bytes=18,t};qe.decode.bytes=0;qe.encodingLength=function(){return 18};var oe=v.option={};oe.encode=function(r,e,t){e||(e=S.alloc(oe.encodingLength(r))),t||(t=0);let n=t,i=on.toCode(r.code);if(e.writeUInt16BE(i,t),t+=2,r.data)e.writeUInt16BE(r.data.length,t),t+=2,r.data.copy(e,t),t+=r.data.length;else switch(i){case 8:let o=r.sourcePrefixLength||0,s=r.family||lt.familyOf(r.ip),a=lt.encode(r.ip,S.alloc),c=Math.ceil(o/8);e.writeUInt16BE(c+4,t),t+=2,e.writeUInt16BE(s,t),t+=2,e.writeUInt8(o,t++),e.writeUInt8(r.scopePrefixLength||0,t++),a.copy(e,t,0,c),t+=c;break;case 11:r.timeout?(e.writeUInt16BE(2,t),t+=2,e.writeUInt16BE(r.timeout,t),t+=2):(e.writeUInt16BE(0,t),t+=2);break;case 12:let d=r.length||0;e.writeUInt16BE(d,t),t+=2,e.fill(0,t,t+d),t+=d;break;case 14:let m=r.tags.length*2;e.writeUInt16BE(m,t),t+=2;for(let l of r.tags)e.writeUInt16BE(l,t),t+=2;break;default:throw new Error(`Unknown roption code: ${r.code}`)}return oe.encode.bytes=t-n,e};oe.encode.bytes=0;oe.decode=function(r,e){e||(e=0);let t={};t.code=r.readUInt16BE(e),t.type=on.toString(t.code),e+=2;let n=r.readUInt16BE(e);switch(e+=2,t.data=r.slice(e,e+n),t.code){case 8:t.family=r.readUInt16BE(e),e+=2,t.sourcePrefixLength=r.readUInt8(e++),t.scopePrefixLength=r.readUInt8(e++);let i=S.alloc(t.family===1?4:16);r.copy(i,0,e,e+n-4),t.ip=lt.decode(i);break;case 11:n>0&&(t.timeout=r.readUInt16BE(e),e+=2);break;case 14:t.tags=[];for(let o=0;o<n;o+=2)t.tags.push(r.readUInt16BE(e)),e+=2}return oe.decode.bytes=n+4,t};oe.decode.bytes=0;oe.encodingLength=function(r){if(r.data)return r.data.length+4;switch(on.toCode(r.code)){case 8:let t=r.sourcePrefixLength||0;return Math.ceil(t/8)+8;case 11:return typeof r.timeout=="number"?6:4;case 12:return r.length+4;case 14:return 4+r.tags.length*2}throw new Error(`Unknown roption code: ${r.code}`)};var ue=v.opt={};ue.encode=function(r,e,t){e||(e=S.alloc(ue.encodingLength(r))),t||(t=0);let n=t,i=Tt(r,oe);return e.writeUInt16BE(i,t),t=Gt(r,oe,e,t+2),ue.encode.bytes=t-n,e};ue.encode.bytes=0;ue.decode=function(r,e){e||(e=0);let t=e,n=[],i=r.readUInt16BE(e);e+=2;let o=0;for(;i>0;)n[o++]=oe.decode(r,e),e+=oe.decode.bytes,i-=oe.decode.bytes;return ue.decode.bytes=e-t,n};ue.decode.bytes=0;ue.encodingLength=function(r){return 2+Tt(r||[],oe)};var J=v.dnskey={};J.PROTOCOL_DNSSEC=3;J.ZONE_KEY=128;J.SECURE_ENTRYPOINT=32768;J.encode=function(r,e,t){e||(e=S.alloc(J.encodingLength(r))),t||(t=0);let n=t,i=r.key;if(!S.isBuffer(i))throw new Error("Key must be a Buffer");return t+=2,e.writeUInt16BE(r.flags,t),t+=2,e.writeUInt8(J.PROTOCOL_DNSSEC,t),t+=1,e.writeUInt8(r.algorithm,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,J.encode.bytes=t-n,e.writeUInt16BE(J.encode.bytes-2,n),e};J.encode.bytes=0;J.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);if(e+=2,n.flags=r.readUInt16BE(e),e+=2,r.readUInt8(e)!==J.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=r.readUInt8(e),e+=1,n.key=r.slice(e,t+i+2),e+=n.key.length,J.decode.bytes=e-t,n};J.decode.bytes=0;J.encodingLength=function(r){return 6+S.byteLength(r.key)};var Se=v.rrsig={};Se.encode=function(r,e,t){e||(e=S.alloc(Se.encodingLength(r))),t||(t=0);let n=t,i=r.signature;if(!S.isBuffer(i))throw new Error("Signature must be a Buffer");return t+=2,e.writeUInt16BE(ze.toType(r.typeCovered),t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.labels,t),t+=1,e.writeUInt32BE(r.originalTTL,t),t+=4,e.writeUInt32BE(r.expiration,t),t+=4,e.writeUInt32BE(r.inception,t),t+=4,e.writeUInt16BE(r.keyTag,t),t+=2,w.encode(r.signersName,e,t),t+=w.encode.bytes,i.copy(e,t,0,i.length),t+=i.length,Se.encode.bytes=t-n,e.writeUInt16BE(Se.encode.bytes-2,n),e};Se.encode.bytes=0;Se.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.typeCovered=ze.toString(r.readUInt16BE(e)),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.labels=r.readUInt8(e),e+=1,n.originalTTL=r.readUInt32BE(e),e+=4,n.expiration=r.readUInt32BE(e),e+=4,n.inception=r.readUInt32BE(e),e+=4,n.keyTag=r.readUInt16BE(e),e+=2,n.signersName=w.decode(r,e),e+=w.decode.bytes,n.signature=r.slice(e,t+i+2),e+=n.signature.length,Se.decode.bytes=e-t,n};Se.decode.bytes=0;Se.encodingLength=function(r){return 20+w.encodingLength(r.signersName)+S.byteLength(r.signature)};var Ae=v.rp={};Ae.encode=function(r,e,t){e||(e=S.alloc(Ae.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.mbox||".",e,t,{mail:!0}),t+=w.encode.bytes,w.encode(r.txt||".",e,t),t+=w.encode.bytes,Ae.encode.bytes=t-n,e.writeUInt16BE(Ae.encode.bytes-2,n),e};Ae.encode.bytes=0;Ae.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.mbox=w.decode(r,e,{mail:!0})||".",e+=w.decode.bytes,n.txt=w.decode(r,e)||".",e+=w.decode.bytes,Ae.decode.bytes=e-t,n};Ae.decode.bytes=0;Ae.encodingLength=function(r){return 2+w.encodingLength(r.mbox||".")+w.encodingLength(r.txt||".")};var j={};j.encode=function(r,e,t){e||(e=S.alloc(j.encodingLength(r))),t||(t=0);let n=t;for(var i=[],o=0;o<r.length;o++){var s=ze.toType(r[o]);i[s>>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(o=0;o<i.length;o++)if(i[o]!==void 0){var a=S.from(i[o]);e.writeUInt8(o,t),t+=1,e.writeUInt8(a.length,t),t+=1,a.copy(e,t),t+=a.length}return j.encode.bytes=t-n,e};j.encode.bytes=0;j.decode=function(r,e,t){e||(e=0);let n=e;for(var i=[];e-n<t;){var o=r.readUInt8(e);e+=1;var s=r.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=r.readUInt8(e+a),d=0;d<8;d++)if(c&1<<7-d){var m=ze.toString(o<<8|a<<3|d);i.push(m)}e+=s}return j.decode.bytes=e-n,i};j.decode.bytes=0;j.encodingLength=function(r){for(var e=[],t=0;t<r.length;t++){var n=ze.toType(r[t]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var i=0;for(t=0;t<e.length;t++)e[t]!==void 0&&(i+=2+Math.ceil((e[t]+1)/8));return i};var Be=v.nsec={};Be.encode=function(r,e,t){e||(e=S.alloc(Be.encodingLength(r))),t||(t=0);let n=t;return t+=2,w.encode(r.nextDomain,e,t),t+=w.encode.bytes,j.encode(r.rrtypes,e,t),t+=j.encode.bytes,Be.encode.bytes=t-n,e.writeUInt16BE(Be.encode.bytes-2,n),e};Be.encode.bytes=0;Be.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.nextDomain=w.decode(r,e),e+=w.decode.bytes,n.rrtypes=j.decode(r,e,i-(e-t)),e+=j.decode.bytes,Be.decode.bytes=e-t,n};Be.decode.bytes=0;Be.encodingLength=function(r){return 2+w.encodingLength(r.nextDomain)+j.encodingLength(r.rrtypes)};var Ue=v.nsec3={};Ue.encode=function(r,e,t){e||(e=S.alloc(Ue.encodingLength(r))),t||(t=0);let n=t,i=r.salt;if(!S.isBuffer(i))throw new Error("salt must be a Buffer");let o=r.nextDomain;if(!S.isBuffer(o))throw new Error("nextDomain must be a Buffer");return t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.flags,t),t+=1,e.writeUInt16BE(r.iterations,t),t+=2,e.writeUInt8(i.length,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,e.writeUInt8(o.length,t),t+=1,o.copy(e,t,0,o.length),t+=o.length,j.encode(r.rrtypes,e,t),t+=j.encode.bytes,Ue.encode.bytes=t-n,e.writeUInt16BE(Ue.encode.bytes-2,n),e};Ue.encode.bytes=0;Ue.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);e+=2,n.algorithm=r.readUInt8(e),e+=1,n.flags=r.readUInt8(e),e+=1,n.iterations=r.readUInt16BE(e),e+=2;let o=r.readUInt8(e);e+=1,n.salt=r.slice(e,e+o),e+=o;let s=r.readUInt8(e);return e+=1,n.nextDomain=r.slice(e,e+s),e+=s,n.rrtypes=j.decode(r,e,i-(e-t)),e+=j.decode.bytes,Ue.decode.bytes=e-t,n};Ue.decode.bytes=0;Ue.encodingLength=function(r){return 8+r.salt.length+r.nextDomain.length+j.encodingLength(r.rrtypes)};var Le=v.ds={};Le.encode=function(r,e,t){e||(e=S.alloc(Le.encodingLength(r))),t||(t=0);let n=t,i=r.digest;if(!S.isBuffer(i))throw new Error("Digest must be a Buffer");return t+=2,e.writeUInt16BE(r.keyTag,t),t+=2,e.writeUInt8(r.algorithm,t),t+=1,e.writeUInt8(r.digestType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,Le.encode.bytes=t-n,e.writeUInt16BE(Le.encode.bytes-2,n),e};Le.encode.bytes=0;Le.decode=function(r,e){e||(e=0);let t=e;var n={},i=r.readUInt16BE(e);return e+=2,n.keyTag=r.readUInt16BE(e),e+=2,n.algorithm=r.readUInt8(e),e+=1,n.digestType=r.readUInt8(e),e+=1,n.digest=r.slice(e,t+i+2),e+=n.digest.length,Le.decode.bytes=e-t,n};Le.decode.bytes=0;Le.encodingLength=function(r){return 6+S.byteLength(r.digest)};var de=v.sshfp={};de.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};de.encode=function(e,t,n){t||(t=S.alloc(de.encodingLength(e))),n||(n=0);let i=n;n+=2,t[n]=e.algorithm,n+=1,t[n]=e.hash,n+=1;let o=S.from(e.fingerprint.toUpperCase(),"hex");if(o.length!==de.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return o.copy(t,n),n+=o.byteLength,de.encode.bytes=n-i,t.writeUInt16BE(de.encode.bytes-2,i),t};de.encode.bytes=0;de.decode=function(e,t){t||(t=0);let n=t,i={};t+=2,i.algorithm=e[t],t+=1,i.hash=e[t],t+=1;let o=de.getFingerprintLengthForHashType(i.hash);return i.fingerprint=e.slice(t,t+o).toString("hex").toUpperCase(),t+=o,de.decode.bytes=t-n,i};de.decode.bytes=0;de.encodingLength=function(r){return 4+S.from(r.fingerprint,"hex").byteLength};var Te=v.naptr={};Te.encode=function(r,e,t){e||(e=S.alloc(Te.encodingLength(r))),t||(t=0);let n=t;return t+=2,e.writeUInt16BE(r.order||0,t),t+=2,e.writeUInt16BE(r.preference||0,t),t+=2,O.encode(r.flags,e,t),t+=O.encode.bytes,O.encode(r.services,e,t),t+=O.encode.bytes,O.encode(r.regexp,e,t),t+=O.encode.bytes,w.encode(r.replacement,e,t),t+=w.encode.bytes,Te.encode.bytes=t-n,e.writeUInt16BE(Te.encode.bytes-2,n),e};Te.encode.bytes=0;Te.decode=function(r,e){e||(e=0);let t=e,n={};return e+=2,n.order=r.readUInt16BE(e),e+=2,n.preference=r.readUInt16BE(e),e+=2,n.flags=O.decode(r,e),e+=O.decode.bytes,n.services=O.decode(r,e),e+=O.decode.bytes,n.regexp=O.decode(r,e),e+=O.decode.bytes,n.replacement=w.decode(r,e),e+=w.decode.bytes,Te.decode.bytes=e-t,n};Te.decode.bytes=0;Te.encodingLength=function(r){return O.encodingLength(r.flags)+O.encodingLength(r.services)+O.encodingLength(r.regexp)+w.encodingLength(r.replacement)+6};var Ne=v.tlsa={};Ne.encode=function(r,e,t){e||(e=S.alloc(Ne.encodingLength(r))),t||(t=0);let n=t,i=r.certificate;if(!S.isBuffer(i))throw new Error("Certificate must be a Buffer");return t+=2,e.writeUInt8(r.usage,t),t+=1,e.writeUInt8(r.selector,t),t+=1,e.writeUInt8(r.matchingType,t),t+=1,i.copy(e,t,0,i.length),t+=i.length,Ne.encode.bytes=t-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(r,e){e||(e=0);let t=e,n={},i=r.readUInt16BE(e);return e+=2,n.usage=r.readUInt8(e),e+=1,n.selector=r.readUInt8(e),e+=1,n.matchingType=r.readUInt8(e),e+=1,n.certificate=r.slice(e,t+i+2),e+=n.certificate.length,Ne.decode.bytes=e-t,n};Ne.decode.bytes=0;Ne.encodingLength=function(r){return 5+S.byteLength(r.certificate)};var cn=v.record=function(r){switch(r.toUpperCase()){case"A":return Ke;case"PTR":return we;case"CNAME":return Zs;case"DNAME":return Qs;case"TXT":return ke;case"NULL":return _e;case"AAAA":return qe;case"SRV":return Fe;case"HINFO":return Me;case"CAA":return ae;case"NS":return Re;case"SOA":return De;case"MX":return et;case"OPT":return ue;case"DNSKEY":return J;case"RRSIG":return Se;case"RP":return Ae;case"NSEC":return Be;case"NSEC3":return Ue;case"SSHFP":return de;case"DS":return Le;case"NAPTR":return Te;case"TLSA":return Ne}return Pe},Y=v.answer={};Y.encode=function(r,e,t){e||(e=S.alloc(Y.encodingLength(r))),t||(t=0);let n=t;if(w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(ze.toType(r.type),t),r.type.toUpperCase()==="OPT"){if(r.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(r.udpPayloadSize||4096,t+2),e.writeUInt8(r.extendedRcode||0,t+4),e.writeUInt8(r.ednsVersion||0,t+5),e.writeUInt16BE(r.flags||0,t+6),t+=8,ue.encode(r.options||[],e,t),t+=ue.encode.bytes}else{let i=gr.toClass(r.class===void 0?"IN":r.class);r.flush&&(i|=sn),e.writeUInt16BE(i,t+2),e.writeUInt32BE(r.ttl||0,t+4),t+=8;let o=cn(r.type);o.encode(r.data,e,t),t+=o.encode.bytes}return Y.encode.bytes=t-n,e};Y.encode.bytes=0;Y.decode=function(r,e){e||(e=0);let t={},n=e;if(t.name=w.decode(r,e),e+=w.decode.bytes,t.type=ze.toString(r.readUInt16BE(e)),t.type==="OPT")t.udpPayloadSize=r.readUInt16BE(e+2),t.extendedRcode=r.readUInt8(e+4),t.ednsVersion=r.readUInt8(e+5),t.flags=r.readUInt16BE(e+6),t.flag_do=(t.flags>>15&1)===1,t.options=ue.decode(r,e+8),e+=8+ue.decode.bytes;else{let i=r.readUInt16BE(e+2);t.ttl=r.readUInt32BE(e+4),t.class=gr.toString(i&Xs),t.flush=!!(i&sn);let o=cn(t.type);t.data=o.decode(r,e+8),e+=8+o.decode.bytes}return Y.decode.bytes=e-n,t};Y.decode.bytes=0;Y.encodingLength=function(r){let e=r.data!==null&&r.data!==void 0?r.data:r.options;return w.encodingLength(r.name)+8+cn(r.type).encodingLength(e)};var xe=v.question={};xe.encode=function(r,e,t){e||(e=S.alloc(xe.encodingLength(r))),t||(t=0);let n=t;return w.encode(r.name,e,t),t+=w.encode.bytes,e.writeUInt16BE(ze.toType(r.type),t),t+=2,e.writeUInt16BE(gr.toClass(r.class===void 0?"IN":r.class),t),t+=2,xe.encode.bytes=t-n,r};xe.encode.bytes=0;xe.decode=function(r,e){e||(e=0);let t=e,n={};return n.name=w.decode(r,e),e+=w.decode.bytes,n.type=ze.toString(r.readUInt16BE(e)),e+=2,n.class=gr.toString(r.readUInt16BE(e)),e+=2,!!(n.class&Xi)&&(n.class&=Ws),xe.decode.bytes=e-t,n};xe.decode.bytes=0;xe.encodingLength=function(r){return w.encodingLength(r.name)+4};v.AUTHORITATIVE_ANSWER=1024;v.TRUNCATED_RESPONSE=512;v.RECURSION_DESIRED=256;v.RECURSION_AVAILABLE=128;v.AUTHENTIC_DATA=32;v.CHECKING_DISABLED=16;v.DNSSEC_OK=32768;v.encode=function(r,e,t){let n=!e;n&&(e=S.alloc(v.encodingLength(r))),t||(t=0);let i=t;return r.questions||(r.questions=[]),r.answers||(r.answers=[]),r.authorities||(r.authorities=[]),r.additionals||(r.additionals=[]),Ee.encode(r,e,t),t+=Ee.encode.bytes,t=Gt(r.questions,xe,e,t),t=Gt(r.answers,Y,e,t),t=Gt(r.authorities,Y,e,t),t=Gt(r.additionals,Y,e,t),v.encode.bytes=t-i,n&&v.encode.bytes!==e.length?e.slice(0,v.encode.bytes):e};v.encode.bytes=0;v.decode=function(r,e){e||(e=0);let t=e,n=Ee.decode(r,e);return e+=Ee.decode.bytes,e=pr(n.questions,xe,r,e),e=pr(n.answers,Y,r,e),e=pr(n.authorities,Y,r,e),e=pr(n.additionals,Y,r,e),v.decode.bytes=e-t,n};v.decode.bytes=0;v.encodingLength=function(r){return Ee.encodingLength(r)+Tt(r.questions||[],xe)+Tt(r.answers||[],Y)+Tt(r.authorities||[],Y)+Tt(r.additionals||[],Y)};v.streamEncode=function(r){let e=v.encode(r),t=S.alloc(2);t.writeUInt16BE(e.byteLength);let n=S.concat([t,e]);return v.streamEncode.bytes=n.byteLength,n};v.streamEncode.bytes=0;v.streamDecode=function(r){let e=r.readUInt16BE(0);if(r.byteLength<e+2)return null;let t=v.decode(r.slice(2));return v.streamDecode.bytes=v.decode.bytes,t};v.streamDecode.bytes=0;function Tt(r,e){let t=0;for(let n=0;n<r.length;n++)t+=e.encodingLength(r[n]);return t}function Gt(r,e,t,n){for(let i=0;i<r.length;i++)e.encode(r[i],t,n),n+=e.encode.bytes;return n}function pr(r,e,t,n){for(let i=0;i<r.length;i++)r[i]=e.decode(t,n),n+=e.decode.bytes;return n}});var Ji=ve((Pu,Qi)=>{"use strict";var Zi=ic;process.nextTick(nc,42);Qi.exports=Js;function Js(r){var e=n;return t;function t(i){e(i||tc)}function n(i){var o=[i];e=s,r(a);function s(c){o.push(c)}function a(c){var d=arguments;for(e=ec(c)?n:m;o.length;)m(o.shift());function m(l){Zi(rc,l,d)}}}}function ec(r){return Object.prototype.toString.call(r)==="[object Error]"}function tc(){}function rc(r,e){r.apply(null,e)}function nc(r){r===42&&(Zi=process.nextTick)}function ic(r,e,t){process.nextTick(function(){r(e,t)})}});var ro=ve((Ru,to)=>{var an=Wi(),oc=ne("dgram"),sc=Ji(),cc=ne("events"),un=ne("os"),dn=function(){};to.exports=function(r){r||(r={});var e=new cc.EventEmitter,t=typeof r.port=="number"?r.port:5353,n=r.type||"udp4",i=r.ip||r.host||(n==="udp4"?"224.0.0.251":null),o={address:i,port:t},s={},a=!1,c=null;if(n==="udp6"&&(!i||!r.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var d=r.socket||oc.createSocket({type:n,reuseAddr:r.reuseAddr!==!1,toString:function(){return n}});d.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),d.on("message",function(l,u){try{l=an.decode(l)}catch(p){e.emit("warning",p);return}e.emit("packet",l,u),l.type==="query"&&e.emit("query",l,u),l.type==="response"&&e.emit("response",l,u)}),d.on("listening",function(){t||(t=o.port=d.address().port),r.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),d.setMulticastTTL(r.ttl||255),d.setMulticastLoopback(r.loopback!==!1))});var m=sc(function(l){if(!t||r.bind===!1)return l(null);d.once("error",l),d.bind(t,r.bind||r.interface,function(){d.removeListener("error",l),l(null)})});return m(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,u,p){if(typeof u=="function")return e.send(l,null,u);p||(p=dn),u?!u.host&&!u.address&&(u.address=o.address):u=o,m(h);function h(y){if(a)return p();if(y)return p(y);var g=an.encode(l);d.send(g,0,g.length,u.port,u.address||u.host,p)}},e.response=e.respond=function(l,u,p){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|an.AUTHORITATIVE_ANSWER,e.send(l,u,p)},e.query=function(l,u,p,h){if(typeof u=="function")return e.query(l,null,null,u);if(typeof u=="object"&&u&&u.port)return e.query(l,null,u,p);if(typeof p=="function")return e.query(l,u,null,p);h||(h=dn),typeof l=="string"&&(l=[{name:l,type:u||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,p,h)},e.destroy=function(l){if(l||(l=dn),a)return process.nextTick(l);a=!0,clearInterval(c);for(var u in s)try{d.dropMembership(i,u)}catch{}s={},d.close(l)},e.update=function(){for(var l=r.interface?[].concat(r.interface):dc(),u=!1,p=0;p<l.length;p++){var h=l[p];if(!s[h])try{d.addMembership(i,h),s[h]=!0,u=!0}catch(y){e.emit("warning",y)}}if(u){if(d.setMulticastInterface)try{d.setMulticastInterface(r.interface||ac())}catch(y){e.emit("warning",y)}e.emit("networkInterface")}},e};function ac(){for(var r=un.networkInterfaces(),e=Object.keys(r),t=0;t<e.length;t++)for(var n=r[e[t]],i=0;i<n.length;i++){var o=n[i];if(eo(o.family)&&!o.internal)return un.platform()==="darwin"&&e[t]==="en0"?o.address:"0.0.0.0"}return"127.0.0.1"}function dc(){for(var r=un.networkInterfaces(),e=Object.keys(r),t=[],n=0;n<e.length;n++)for(var i=r[e[n]],o=0;o<i.length;o++){var s=i[o];if(eo(s.family)){t.push(s.address);break}}return t}function eo(r){return r===4||r==="IPv4"}});var Es=ve(cr=>{(function(){var r,e,t,n,i,o,s,a;a=function(c){var d,m,l,u;return d=(c&255<<24)>>>24,m=(c&255<<16)>>>16,l=(c&65280)>>>8,u=c&255,[d,m,l,u].join(".")},s=function(c){var d,m,l,u,p,h;for(d=[],l=u=0;u<=3&&c.length!==0;l=++u){if(l>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}h=e(c),p=h[0],m=h[1],c=c.substring(m),d.push(p)}if(c.length!==0)throw new Error("Invalid IP");switch(d.length){case 1:if(d[0]>4294967295)throw new Error("Invalid IP");return d[0]>>>0;case 2:if(d[0]>255||d[1]>16777215)throw new Error("Invalid IP");return(d[0]<<24|d[1])>>>0;case 3:if(d[0]>255||d[1]>255||d[2]>65535)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2])>>>0;case 4:if(d[0]>255||d[1]>255||d[2]>255||d[3]>255)throw new Error("Invalid IP");return(d[0]<<24|d[1]<<16|d[2]<<8|d[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),o=t("a"),i=t("A"),e=function(c){var d,m,l,u,p;for(u=0,d=10,m="9",l=0,c.length>1&&c[l]==="0"&&(c[l+1]==="x"||c[l+1]==="X"?(l+=2,d=16):"0"<=c[l+1]&&c[l+1]<="9"&&(l++,d=8,m="7")),p=l;l<c.length;){if("0"<=c[l]&&c[l]<=m)u=u*d+(t(c[l])-n)>>>0;else if(d===16)if("a"<=c[l]&&c[l]<="f")u=u*d+(10+t(c[l])-o)>>>0;else if("A"<=c[l]&&c[l]<="F")u=u*d+(10+t(c[l])-i)>>>0;else break;else break;if(u>4294967295)throw new Error("too large");l++}if(l===p)throw new Error("empty octet");return[u,l]},r=function(){function c(d,m){var l,u,p,h;if(typeof d!="string")throw new Error("Missing `net' parameter");if(m||(h=d.split("/",2),d=h[0],m=h[1]),m||(m=32),typeof m=="string"&&m.indexOf(".")>-1){try{this.maskLong=s(m)}catch(y){throw l=y,new Error("Invalid mask: "+m)}for(u=p=32;p>=0;u=--p)if(this.maskLong===4294967295<<32-u>>>0){this.bitmask=u;break}}else if(m||m===0)this.bitmask=parseInt(m,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(s(d)&this.maskLong)>>>0}catch(y){throw l=y,new Error("Invalid net address: "+d)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+m);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(d){return typeof d=="string"&&(d.indexOf("/")>0||d.split(".").length!==4)&&(d=new c(d)),d instanceof c?this.contains(d.base)&&this.contains(d.broadcast||d.last):(s(d)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(d){return d==null&&(d=1),new c(a(this.netLong+this.size*d),this.mask)},c.prototype.forEach=function(d){var m,l,u;for(u=s(this.first),l=s(this.last),m=0;u<=l;)d(a(u),u,m),m++,u++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),cr.ip2long=s,cr.long2ip=a,cr.Netmask=r}).call(cr)});var Wd={};ie(Wd,{mdns:()=>Xd});var ki=Symbol.for("@libp2p/peer-discovery");var Zr=Symbol.for("@libp2p/peer-id");var Lt=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},ur=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var lr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var $t=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var _i=ne("node:events"),Mi=(r,...e)=>{try{(0,_i.setMaxListeners)(r,...e)}catch{}};var hr=class extends EventTarget{#e=new Map;constructor(){super(),Mi(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let i=this.#e.get(e);i!=null&&(i=i.filter(({callback:o})=>o!==t),this.#e.set(e,i))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:i})=>!i),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new CustomEvent(e,t))}};var Fi=Symbol.for("@libp2p/service-capabilities"),iu=Symbol.for("@libp2p/service-dependencies");var Fs=Ut(ro(),1);var mn={};ie(mn,{base58btc:()=>K,base58flickr:()=>mc});var Du=new Uint8Array(0);function no(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function ge(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function io(r){return new TextEncoder().encode(r)}function oo(r){return new TextDecoder().decode(r)}function uc(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var i=0;i<r.length;i++){var o=r.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var a=r.length,c=r.charAt(0),d=Math.log(a)/Math.log(256),m=Math.log(256)/Math.log(a);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var y=0,g=0,f=0,x=h.length;f!==x&&h[f]===0;)f++,y++;for(var b=(x-f)*m+1>>>0,L=new Uint8Array(b);f!==x;){for(var T=h[f],B=0,U=b-1;(T!==0||B<g)&&U!==-1;U--,B++)T+=256*L[U]>>>0,L[U]=T%a>>>0,T=T/a>>>0;if(T!==0)throw new Error("Non-zero carry");g=B,f++}for(var N=b-g;N!==b&&L[N]===0;)N++;for(var C=c.repeat(y);N<b;++N)C+=r.charAt(L[N]);return C}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var y=0;if(h[y]!==" "){for(var g=0,f=0;h[y]===c;)g++,y++;for(var x=(h.length-y)*d+1>>>0,b=new Uint8Array(x);h[y];){var L=t[h.charCodeAt(y)];if(L===255)return;for(var T=0,B=x-1;(L!==0||T<f)&&B!==-1;B--,T++)L+=a*b[B]>>>0,b[B]=L%256>>>0,L=L/256>>>0;if(L!==0)throw new Error("Non-zero carry");f=T,y++}if(h[y]!==" "){for(var U=x-f;U!==x&&b[U]===0;)U++;for(var N=new Uint8Array(g+(x-U)),C=g;U!==x;)N[C++]=b[U++];return N}}}function p(h){var y=u(h);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:u,decode:p}}var lc=uc,hc=lc,co=hc;var ln=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},hn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;let i=t.codePointAt(0);if(i===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=i,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 ao(this,e)}},pn=class{decoders;constructor(e){this.decoders=e}or(e){return ao(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ao(r,e){return new pn({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var gn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new ln(e,t,n),this.decoder=new hn(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Nt({name:r,prefix:e,encode:t,decode:n}){return new gn(r,e,t,n)}function tt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:i}=co(t,r);return Nt({prefix:e,name:r,encode:n,decode:o=>ge(i(o))})}function pc(r,e,t,n){let i={};for(let m=0;m<e.length;++m)i[e[m]]=m;let o=r.length;for(;r[o-1]==="=";)--o;let s=new Uint8Array(o*t/8|0),a=0,c=0,d=0;for(let m=0;m<o;++m){let l=i[r[m]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,a+=t,a>=8&&(a-=8,s[d++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return s}function gc(r,e,t){let n=e[e.length-1]==="=",i=(1<<t)-1,o="",s=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],s+=8;s>t;)s-=t,o+=e[i&a>>s];if(s!==0&&(o+=e[i&a<<t-s]),n)for(;o.length*t&7;)o+="=";return o}function F({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Nt({prefix:e,name:r,encode(i){return gc(i,n,t)},decode(i){return pc(i,n,t,r)}})}var K=tt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),mc=tt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var yn={};ie(yn,{base32:()=>Ve,base32hex:()=>xc,base32hexpad:()=>bc,base32hexpadupper:()=>Ic,base32hexupper:()=>Ec,base32pad:()=>fc,base32padupper:()=>wc,base32upper:()=>yc,base32z:()=>vc});var Ve=F({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),yc=F({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),fc=F({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),wc=F({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xc=F({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ec=F({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bc=F({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ic=F({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),vc=F({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var fn={};ie(fn,{base36:()=>Yt,base36upper:()=>Sc});var Yt=tt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Sc=tt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ac=ho,uo=128,Bc=127,Uc=~Bc,Lc=Math.pow(2,31);function ho(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Lc;)e[t++]=r&255|uo,r/=128;for(;r&Uc;)e[t++]=r&255|uo,r>>>=7;return e[t]=r|0,ho.bytes=t-n+1,e}var Tc=wn,Nc=128,lo=127;function wn(r,n){var t=0,n=n||0,i=0,o=n,s,a=r.length;do{if(o>=a)throw wn.bytes=0,new RangeError("Could not decode varint");s=r[o++],t+=i<28?(s&lo)<<i:(s&lo)*Math.pow(2,i),i+=7}while(s>=Nc);return wn.bytes=o-n,t}var Cc=Math.pow(2,7),Oc=Math.pow(2,14),Pc=Math.pow(2,21),Rc=Math.pow(2,28),Dc=Math.pow(2,35),kc=Math.pow(2,42),_c=Math.pow(2,49),Mc=Math.pow(2,56),Fc=Math.pow(2,63),Kc=function(r){return r<Cc?1:r<Oc?2:r<Pc?3:r<Rc?4:r<Dc?5:r<kc?6:r<_c?7:r<Mc?8:r<Fc?9:10},qc={encode:Ac,decode:Tc,encodingLength:Kc},zc=qc,Xt=zc;function Wt(r,e=0){return[Xt.decode(r,e),Xt.decode.bytes]}function Ct(r,e,t=0){return Xt.encode(r,e,t),e}function Ot(r){return Xt.encodingLength(r)}function ht(r,e){let t=e.byteLength,n=Ot(r),i=n+Ot(t),o=new Uint8Array(i+t);return Ct(r,o,0),Ct(t,o,n),o.set(e,i),new Pt(r,t,e,o)}function pt(r){let e=ge(r),[t,n]=Wt(e),[i,o]=Wt(e.subarray(n)),s=e.subarray(n+o);if(s.byteLength!==i)throw new Error("Incorrect length");return new Pt(t,i,s,e)}function po(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&no(r.bytes,t.bytes)}}var Pt=class{code;size;digest;bytes;constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}};function go(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Hc(t,xn(r),e??K.encoder);default:return jc(t,xn(r),e??Ve.encoder)}}var mo=new WeakMap;function xn(r){let e=mo.get(r);if(e==null){let t=new Map;return mo.set(r,t),t}return e}var ee=class r{code;version;multihash;bytes;"/";constructor(e,t,n,i){this.code=t,this.version=e,this.multihash=n,this.bytes=i,this["/"]=i}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Zt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$c)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=ht(e,t);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&po(e.multihash,n.multihash)}toString(e){return go(this,e)}toJSON(){return{"/":go(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:i,multihash:o,bytes:s}=t;return new r(n,i,o,s??yo(n,i,o.bytes))}else if(t[Gc]===!0){let{version:n,multihash:i,code:o}=t,s=pt(i);return r.create(n,o,s)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Zt)throw new Error(`Version 0 CID must use dag-pb (code: ${Zt}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let i=yo(e,t,n.bytes);return new r(e,t,n,i)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Zt,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,i=ge(e.subarray(n,n+t.multihashSize));if(i.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=i.subarray(t.multihashSize-t.digestSize),s=new Pt(t.multihashCode,t.digestSize,o,i);return[t.version===0?r.createV0(s):r.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,u]=Wt(e.subarray(t));return t+=u,l},i=n(),o=Zt;if(i===18?(i=0,t=0):o=n(),i!==0&&i!==1)throw new RangeError(`Invalid CID version ${i}`);let s=t,a=n(),c=n(),d=t+c,m=d-s;return{version:i,codec:o,multihashCode:a,digestSize:c,multihashSize:m,size:d}}static parse(e,t){let[n,i]=Vc(e,t),o=r.decode(i);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return xn(o).set(n,e),o}};function Vc(r,e){switch(r[0]){case"Q":{let t=e??K;return[K.prefix,t.decode(`${K.prefix}${r}`)]}case K.prefix:{let t=e??K;return[K.prefix,t.decode(r)]}case Ve.prefix:{let t=e??Ve;return[Ve.prefix,t.decode(r)]}case Yt.prefix:{let t=e??Yt;return[Yt.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Hc(r,e,t){let{prefix:n}=t;if(n!==K.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let i=e.get(n);if(i==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return i}function jc(r,e,t){let{prefix:n}=t,i=e.get(n);if(i==null){let o=t.encode(r);return e.set(n,o),o}else return i}var Zt=112,$c=18;function yo(r,e,t){let n=Ot(r),i=n+Ot(e),o=new Uint8Array(i+t.byteLength);return Ct(r,o,0),Ct(e,o,n),o.set(t,i),o}var Gc=Symbol.for("@ipld/js-cid/CID");var En={};ie(En,{identity:()=>He});var fo=0,Yc="identity",wo=ge;function Xc(r){return ht(fo,wo(r))}var He={code:fo,name:Yc,encode:wo,digest:Xc};function je(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}var fr=Ut(ne("crypto"),1);var xo=ne("node:buffer");function Rt(r){return new Uint8Array(r.buffer,r.byteOffset,r.byteLength)}function Ce(r,e){return Rt(xo.Buffer.concat(r,e))}var Ao=ne("node:buffer");var bn={};ie(bn,{base10:()=>Wc});var Wc=tt({prefix:"9",name:"base10",alphabet:"0123456789"});var In={};ie(In,{base16:()=>Zc,base16upper:()=>Qc});var Zc=F({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qc=F({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var vn={};ie(vn,{base2:()=>Jc});var Jc=F({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Sn={};ie(Sn,{base256emoji:()=>ia});var Eo=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}"),ea=Eo.reduce((r,e,t)=>(r[t]=e,r),[]),ta=Eo.reduce((r,e,t)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return r[n]=t,r},[]);function ra(r){return r.reduce((e,t)=>(e+=ea[t],e),"")}function na(r){let e=[];for(let t of r){let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);let i=ta[n];if(i==null)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var ia=Nt({prefix:"\u{1F680}",name:"base256emoji",encode:ra,decode:na});var An={};ie(An,{base64:()=>oa,base64pad:()=>sa,base64url:()=>ca,base64urlpad:()=>aa});var oa=F({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sa=F({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ca=F({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),aa=F({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Bn={};ie(Bn,{base8:()=>da});var da=F({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Un={};ie(Un,{identity:()=>ua});var ua=Nt({prefix:"\0",name:"identity",encode:r=>oo(r),decode:r=>io(r)});var ll=new TextEncoder,hl=new TextDecoder;var On={};ie(On,{sha256:()=>Cn,sha512:()=>pa});var Nn=Ut(ne("crypto"),1);function Tn({name:r,code:e,encode:t}){return new Ln(r,e,t)}var Ln=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ht(this.code,t):t.then(n=>ht(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Cn=Tn({name:"sha2-256",code:18,encode:r=>ge(Nn.default.createHash("sha256").update(r).digest())}),pa=Tn({name:"sha2-512",code:19,encode:r=>ge(Nn.default.createHash("sha512").update(r).digest())});var Qt={...Un,...vn,...Bn,...bn,...In,...yn,...fn,...mn,...An,...Sn},Al={...On,...En};var Io=ne("node:buffer");function $e(r=0){return Rt(Io.Buffer.allocUnsafe(r))}function So(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var vo=So("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Pn=So("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=$e(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ga={utf8:vo,"utf-8":vo,hex:Qt.base16,latin1:Pn,ascii:Pn,binary:Pn,...Qt},yr=ga;function Ge(r,e="utf8"){let t=yr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Rt(Ao.Buffer.from(r,"utf-8")):t.decoder.decode(`${t.prefix}${r}`)}var Bo=ne("node:buffer");function z(r,e="utf8"){let t=yr[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Bo.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):t.encoder.encode(r).substring(1)}var Kl=fr.default.generateKeyPairSync,Jt=32;var ma=64;function Uo(r,e,t){if(r.byteLength!==Jt)throw new TypeError('"key" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==ma)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=fr.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:z(r,"base64url"),kty:"OKP"}});return fr.default.verify(null,t instanceof Uint8Array?t:t.subarray(),n,e)}var wr=class{type="Ed25519";raw;constructor(e){this.raw=Rn(e,Jt)}toMultihash(){return He.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:je(this.raw,e.raw)}verify(e,t){return Uo(this.raw,t,e)}};function To(r){return r=Rn(r,Jt),new wr(r)}function Rn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Lt(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}var fa=Math.pow(2,7),wa=Math.pow(2,14),xa=Math.pow(2,21),Dn=Math.pow(2,28),kn=Math.pow(2,35),_n=Math.pow(2,42),Mn=Math.pow(2,49),D=128,X=127;function se(r){if(r<fa)return 1;if(r<wa)return 2;if(r<xa)return 3;if(r<Dn)return 4;if(r<kn)return 5;if(r<_n)return 6;if(r<Mn)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Fn(r,e,t=0){switch(se(r)){case 8:e[t++]=r&255|D,r/=128;case 7:e[t++]=r&255|D,r/=128;case 6:e[t++]=r&255|D,r/=128;case 5:e[t++]=r&255|D,r/=128;case 4:e[t++]=r&255|D,r>>>=7;case 3:e[t++]=r&255|D,r>>>=7;case 2:e[t++]=r&255|D,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Ea(r,e,t=0){switch(se(r)){case 8:e.set(t++,r&255|D),r/=128;case 7:e.set(t++,r&255|D),r/=128;case 6:e.set(t++,r&255|D),r/=128;case 5:e.set(t++,r&255|D),r/=128;case 4:e.set(t++,r&255|D),r>>>=7;case 3:e.set(t++,r&255|D),r>>>=7;case 2:e.set(t++,r&255|D),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Kn(r,e){let t=r[e],n=0;if(n+=t&X,t<D||(t=r[e+1],n+=(t&X)<<7,t<D)||(t=r[e+2],n+=(t&X)<<14,t<D)||(t=r[e+3],n+=(t&X)<<21,t<D)||(t=r[e+4],n+=(t&X)*Dn,t<D)||(t=r[e+5],n+=(t&X)*kn,t<D)||(t=r[e+6],n+=(t&X)*_n,t<D)||(t=r[e+7],n+=(t&X)*Mn,t<D))return n;throw new RangeError("Could not decode varint")}function ba(r,e){let t=r.get(e),n=0;if(n+=t&X,t<D||(t=r.get(e+1),n+=(t&X)<<7,t<D)||(t=r.get(e+2),n+=(t&X)<<14,t<D)||(t=r.get(e+3),n+=(t&X)<<21,t<D)||(t=r.get(e+4),n+=(t&X)*Dn,t<D)||(t=r.get(e+5),n+=(t&X)*kn,t<D)||(t=r.get(e+6),n+=(t&X)*_n,t<D)||(t=r.get(e+7),n+=(t&X)*Mn,t<D))return n;throw new RangeError("Could not decode varint")}function Dt(r,e,t=0){return e==null&&(e=$e(se(r))),e instanceof Uint8Array?Fn(r,e,t):Ea(r,e,t)}function mt(r,e=0){return r instanceof Uint8Array?Kn(r,e):ba(r,e)}var qn=new Float32Array([-0]),rt=new Uint8Array(qn.buffer);function Co(r,e,t){qn[0]=r,e[t]=rt[0],e[t+1]=rt[1],e[t+2]=rt[2],e[t+3]=rt[3]}function Oo(r,e){return rt[0]=r[e],rt[1]=r[e+1],rt[2]=r[e+2],rt[3]=r[e+3],qn[0]}var zn=new Float64Array([-0]),W=new Uint8Array(zn.buffer);function Po(r,e,t){zn[0]=r,e[t]=W[0],e[t+1]=W[1],e[t+2]=W[2],e[t+3]=W[3],e[t+4]=W[4],e[t+5]=W[5],e[t+6]=W[6],e[t+7]=W[7]}function Ro(r,e){return W[0]=r[e],W[1]=r[e+1],W[2]=r[e+2],W[3]=r[e+3],W[4]=r[e+4],W[5]=r[e+5],W[6]=r[e+6],W[7]=r[e+7],zn[0]}var Ia=BigInt(Number.MAX_SAFE_INTEGER),va=BigInt(Number.MIN_SAFE_INTEGER),le=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+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 t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(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,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return yt;if(e<Ia&&e>va)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,i=e-(n<<32n);return t&&(n=~n|0n,i=~i|0n,++i>Do&&(i=0n,++n>Do&&(n=0n))),new r(Number(i),Number(n))}static fromNumber(e){if(e===0)return yt;let t=e<0;t&&(e=-e);let n=e>>>0,i=(e-n)/4294967296>>>0;return t&&(i=~i>>>0,n=~n>>>0,++n>4294967295&&(n=0,++i>4294967295&&(i=0))),new r(n,i)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):yt}},yt=new le(0,0);yt.toBigInt=function(){return 0n};yt.zzEncode=yt.zzDecode=function(){return this};yt.length=function(){return 1};var Do=4294967296n;function ko(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function _o(r,e,t){if(t-e<1)return"";let i,o=[],s=0,a;for(;e<t;)a=r[e++],a<128?o[s++]=a:a>191&&a<224?o[s++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[s++]=55296+(a>>10),o[s++]=56320+(a&1023)):o[s++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,s>8191&&((i??(i=[])).push(String.fromCharCode.apply(String,o)),s=0);return i!=null?(s>0&&i.push(String.fromCharCode.apply(String,o.slice(0,s))),i.join("")):String.fromCharCode.apply(String,o.slice(0,s))}function Vn(r,e,t){let n=t,i,o;for(let s=0;s<r.length;++s)i=r.charCodeAt(s),i<128?e[t++]=i:i<2048?(e[t++]=i>>6|192,e[t++]=i&63|128):(i&64512)===55296&&((o=r.charCodeAt(s+1))&64512)===56320?(i=65536+((i&1023)<<10)+(o&1023),++s,e[t++]=i>>18|240,e[t++]=i>>12&63|128,e[t++]=i>>6&63|128,e[t++]=i&63|128):(e[t++]=i>>12|224,e[t++]=i>>6&63|128,e[t++]=i&63|128);return t-n}function be(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Er(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Hn=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,be(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 be(this,4);return Er(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw be(this,4);return Er(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw be(this,4);let e=Oo(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw be(this,4);let e=Ro(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw be(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return _o(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw be(this,e);this.pos+=e}else do if(this.pos>=this.len)throw be(this);while(this.buf[this.pos++]&128);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 le(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*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;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw be(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw be(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw be(this,8);let e=Er(this.buf,this.pos+=4),t=Er(this.buf,this.pos+=4);return new le(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Kn(this.buf,this.pos);return this.pos+=se(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 jn(r){return new Hn(r instanceof Uint8Array?r:r.subarray())}function br(r,e,t){let n=jn(r);return e.decode(n,void 0,t)}function $n(r){let e=r??8192,t=e>>>1,n,i=e;return function(s){if(s<1||s>t)return $e(s);i+s>e&&(n=$e(e),i=0);let a=n.subarray(i,i+=s);return i&7&&(i=(i|7)+1),a}}var ft=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Gn(){}var Xn=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Sa=$n();function Aa(r){return globalThis.Buffer!=null?$e(r):Sa(r)}var tr=class{len;head;tail;states;constructor(){this.len=0,this.head=new ft(Gn,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new ft(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Wn((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(Ir,10,le.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=le.fromBigInt(e);return this._push(Ir,t.length(),t)}uint64Number(e){return this._push(Fn,se(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 t=le.fromBigInt(e).zzEncode();return this._push(Ir,t.length(),t)}sint64Number(e){let t=le.fromNumber(e).zzEncode();return this._push(Ir,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Yn,1,e?1:0)}fixed32(e){return this._push(er,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=le.fromBigInt(e);return this._push(er,4,t.lo)._push(er,4,t.hi)}fixed64Number(e){let t=le.fromNumber(e);return this._push(er,4,t.lo)._push(er,4,t.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(Co,4,e)}double(e){return this._push(Po,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Yn,1,0):this.uint32(t)._push(Ua,t,e)}string(e){let t=ko(e);return t!==0?this.uint32(t)._push(Vn,t,e):this._push(Yn,1,0)}fork(){return this.states=new Xn(this),this.head=this.tail=new ft(Gn,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 ft(Gn,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=Aa(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Yn(r,e,t){e[t]=r&255}function Ba(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var Wn=class extends ft{next;constructor(e,t){super(Ba,e,t),this.next=void 0}};function Ir(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function er(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Ua(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(tr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(La,e,r),this},tr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Ta,e,r),this});function La(r,e,t){e.set(r,t)}function Ta(r,e,t){r.length<40?Vn(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(Ge(r),t)}function Zn(){return new tr}function vr(r,e){let t=Zn();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var kt;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(kt||(kt={}));function Sr(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Qn(r){function e(i){if(r[i.toString()]==null)throw new Error("Invalid enum value");return r[i]}let t=function(o,s){let a=e(o);s.int32(a)},n=function(o){let s=o.int32();return e(s)};return Sr("enum",kt.VARINT,t,n)}function Ar(r,e){return Sr("message",kt.LENGTH_DELIMITED,r,e)}var me;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(me||(me={}));var Jn;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Jn||(Jn={}));(function(r){r.codec=()=>Qn(Jn)})(me||(me={}));var rr;(function(r){let e;r.codec=()=>(e==null&&(e=Ar((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),me.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=me.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>vr(t,r.codec()),r.decode=(t,n)=>br(t,r.codec(),n)})(rr||(rr={}));var ei;(function(r){let e;r.codec=()=>(e==null&&(e=Ar((t,n,i={})=>{i.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),me.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),i.lengthDelimited!==!1&&n.ldelim()},(t,n,i={})=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=me.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>vr(t,r.codec()),r.decode=(t,n)=>br(t,r.codec(),n)})(ei||(ei={}));function Fo(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Ca(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function _t(r,...e){if(!Ca(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error("Uint8Array expected of length "+e+", got length="+r.length)}function Ko(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Fo(r.outputLen),Fo(r.blockLen)}function Mt(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function qo(r,e){_t(r);let t=e.outputLen;if(r.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}var Ye=Ut(ne("node:crypto"),1),wt=Ye&&typeof Ye=="object"&&"webcrypto"in Ye?Ye.webcrypto:Ye&&typeof Ye=="object"&&"randomBytes"in Ye?Ye:void 0;function Br(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ie(r,e){return r<<32-e|r>>>e}function Oa(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function nr(r){return typeof r=="string"&&(r=Oa(r)),_t(r),r}function zo(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];_t(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let o=r[n];t.set(o,i),i+=o.length}return t}var Ft=class{clone(){return this._cloneInto()}};function Vo(r){let e=n=>r().update(nr(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Ho(r=32){if(wt&&typeof wt.getRandomValues=="function")return wt.getRandomValues(new Uint8Array(r));if(wt&&typeof wt.randomBytes=="function")return wt.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Pa(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let i=BigInt(32),o=BigInt(4294967295),s=Number(t>>i&o),a=Number(t&o),c=n?4:0,d=n?0:4;r.setUint32(e+c,s,n),r.setUint32(e+d,a,n)}function jo(r,e,t){return r&e^~r&t}function $o(r,e,t){return r&e^r&t^e&t}var Ur=class extends Ft{constructor(e,t,n,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Br(this.buffer)}update(e){Mt(this);let{view:t,buffer:n,blockLen:i}=this;e=nr(e);let o=e.length;for(let s=0;s<o;){let a=Math.min(i-this.pos,o-s);if(a===i){let c=Br(e);for(;i<=o-s;s+=i)this.process(c,s);continue}n.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Mt(this),qo(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:i,isLE:o}=this,{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>i-s&&(this.process(n,0),s=0);for(let l=s;l<i;l++)t[l]=0;Pa(n,i-8,BigInt(this.length*8),o),this.process(n,0);let a=Br(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let d=c/4,m=this.get();if(d>m.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)a.setUint32(4*l,m[l],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:i,finished:o,destroyed:s,pos:a}=this;return e.length=i,e.pos=a,e.finished=o,e.destroyed=s,i%t&&e.buffer.set(n),e}};var Ra=new Uint32Array([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]),nt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),it=new Uint32Array(64),ti=class extends Ur{constructor(){super(64,32,8,!1),this.A=nt[0]|0,this.B=nt[1]|0,this.C=nt[2]|0,this.D=nt[3]|0,this.E=nt[4]|0,this.F=nt[5]|0,this.G=nt[6]|0,this.H=nt[7]|0}get(){let{A:e,B:t,C:n,D:i,E:o,F:s,G:a,H:c}=this;return[e,t,n,i,o,s,a,c]}set(e,t,n,i,o,s,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=c|0}process(e,t){for(let l=0;l<16;l++,t+=4)it[l]=e.getUint32(t,!1);for(let l=16;l<64;l++){let u=it[l-15],p=it[l-2],h=Ie(u,7)^Ie(u,18)^u>>>3,y=Ie(p,17)^Ie(p,19)^p>>>10;it[l]=y+it[l-7]+h+it[l-16]|0}let{A:n,B:i,C:o,D:s,E:a,F:c,G:d,H:m}=this;for(let l=0;l<64;l++){let u=Ie(a,6)^Ie(a,11)^Ie(a,25),p=m+u+jo(a,c,d)+Ra[l]+it[l]|0,y=(Ie(n,2)^Ie(n,13)^Ie(n,22))+$o(n,i,o)|0;m=d,d=c,c=a,a=s+p|0,s=o,o=i,i=n,n=p+y|0}n=n+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,d=d+this.G|0,m=m+this.H|0,this.set(n,i,o,s,a,c,d,m)}roundClean(){it.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Go=Vo(()=>new ti);var Lr=class extends Ft{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Ko(e);let n=nr(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let i=this.blockLen,o=new Uint8Array(i);o.set(n.length>i?e.create().update(n).digest():n);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),o.fill(0)}update(e){return Mt(this),this.iHash.update(e),this}digestInto(e){Mt(this),_t(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ri=(r,e,t)=>new Lr(r,e).update(t).digest();ri.create=(r,e)=>new Lr(r,e);var ai={};ie(ai,{aInRange:()=>ct,abool:()=>xt,abytes:()=>Kt,bitGet:()=>Ka,bitLen:()=>si,bitMask:()=>or,bitSet:()=>qa,bytesToHex:()=>Et,bytesToNumberBE:()=>We,bytesToNumberLE:()=>Cr,concatBytes:()=>qt,createHmacDrbg:()=>ci,ensureBytes:()=>he,equalBytes:()=>Ma,hexToBytes:()=>It,hexToNumber:()=>oi,inRange:()=>ir,isBytes:()=>ot,memoized:()=>Pr,notImplemented:()=>Va,numberToBytesBE:()=>st,numberToBytesLE:()=>Or,numberToHexUnpadded:()=>bt,numberToVarBytesBE:()=>_a,utf8ToBytes:()=>Fa,validateObject:()=>at});var Tr=BigInt(0),Nr=BigInt(1),Da=BigInt(2);function ot(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function Kt(r){if(!ot(r))throw new Error("Uint8Array expected")}function xt(r,e){if(typeof e!="boolean")throw new Error(r+" boolean expected, got "+e)}var ka=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Et(r){Kt(r);let e="";for(let t=0;t<r.length;t++)e+=ka[r[t]];return e}function bt(r){let e=r.toString(16);return e.length&1?"0"+e:e}function oi(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Tr:BigInt("0x"+r)}var Xe={_0:48,_9:57,A:65,F:70,a:97,f:102};function Yo(r){if(r>=Xe._0&&r<=Xe._9)return r-Xe._0;if(r>=Xe.A&&r<=Xe.F)return r-(Xe.A-10);if(r>=Xe.a&&r<=Xe.f)return r-(Xe.a-10)}function It(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let i=0,o=0;i<t;i++,o+=2){let s=Yo(r.charCodeAt(o)),a=Yo(r.charCodeAt(o+1));if(s===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[i]=s*16+a}return n}function We(r){return oi(Et(r))}function Cr(r){return Kt(r),oi(Et(Uint8Array.from(r).reverse()))}function st(r,e){return It(r.toString(16).padStart(e*2,"0"))}function Or(r,e){return st(r,e).reverse()}function _a(r){return It(bt(r))}function he(r,e,t){let n;if(typeof e=="string")try{n=It(e)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(ot(e))n=Uint8Array.from(e);else throw new Error(r+" must be hex string or Uint8Array");let i=n.length;if(typeof t=="number"&&i!==t)throw new Error(r+" of length "+t+" expected, got "+i);return n}function qt(...r){let e=0;for(let n=0;n<r.length;n++){let i=r[n];Kt(i),e+=i.length}let t=new Uint8Array(e);for(let n=0,i=0;n<r.length;n++){let o=r[n];t.set(o,i),i+=o.length}return t}function Ma(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Fa(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var ni=r=>typeof r=="bigint"&&Tr<=r;function ir(r,e,t){return ni(r)&&ni(e)&&ni(t)&&e<=r&&r<t}function ct(r,e,t,n){if(!ir(e,t,n))throw new Error("expected valid "+r+": "+t+" <= n < "+n+", got "+e)}function si(r){let e;for(e=0;r>Tr;r>>=Nr,e+=1);return e}function Ka(r,e){return r>>BigInt(e)&Nr}function qa(r,e,t){return r|(t?Nr:Tr)<<BigInt(e)}var or=r=>(Da<<BigInt(r-1))-Nr,ii=r=>new Uint8Array(r),Xo=r=>Uint8Array.from(r);function ci(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=ii(r),i=ii(r),o=0,s=()=>{n.fill(1),i.fill(0),o=0},a=(...l)=>t(i,n,...l),c=(l=ii())=>{i=a(Xo([0]),l),n=a(),l.length!==0&&(i=a(Xo([1]),l),n=a())},d=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,u=[];for(;l<e;){n=a();let p=n.slice();u.push(p),l+=n.length}return qt(...u)};return(l,u)=>{s(),c(l);let p;for(;!(p=u(d()));)c();return s(),p}}var za={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||ot(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function at(r,e,t={}){let n=(i,o,s)=>{let a=za[o];if(typeof a!="function")throw new Error("invalid validator function");let c=r[i];if(!(s&&c===void 0)&&!a(c,r))throw new Error("param "+String(i)+" is invalid. Expected "+o+", got "+c)};for(let[i,o]of Object.entries(e))n(i,o,!1);for(let[i,o]of Object.entries(t))n(i,o,!0);return r}var Va=()=>{throw new Error("not implemented")};function Pr(r){let e=new WeakMap;return(t,...n)=>{let i=e.get(t);if(i!==void 0)return i;let o=r(t,...n);return e.set(t,o),o}}var H=BigInt(0),q=BigInt(1),vt=BigInt(2),Ha=BigInt(3),di=BigInt(4),Wo=BigInt(5),Zo=BigInt(8),ja=BigInt(9),$a=BigInt(16);function Z(r,e){let t=r%e;return t>=H?t:e+t}function Ga(r,e,t){if(e<H)throw new Error("invalid exponent, negatives unsupported");if(t<=H)throw new Error("invalid modulus");if(t===q)return H;let n=q;for(;e>H;)e&q&&(n=n*r%t),r=r*r%t,e>>=q;return n}function pe(r,e,t){let n=r;for(;e-- >H;)n*=n,n%=t;return n}function Rr(r,e){if(r===H)throw new Error("invert: expected non-zero number");if(e<=H)throw new Error("invert: expected positive modulus, got "+e);let t=Z(r,e),n=e,i=H,o=q,s=q,a=H;for(;t!==H;){let d=n/t,m=n%t,l=i-s*d,u=o-a*d;n=t,t=m,i=s,o=a,s=l,a=u}if(n!==q)throw new Error("invert: does not exist");return Z(i,e)}function Ya(r){let e=(r-q)/vt,t,n,i;for(t=r-q,n=0;t%vt===H;t/=vt,n++);for(i=vt;i<r&&Ga(i,e,r)!==r-q;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let s=(r+q)/di;return function(c,d){let m=c.pow(d,s);if(!c.eql(c.sqr(m),d))throw new Error("Cannot find square root");return m}}let o=(t+q)/vt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let d=n,m=a.pow(a.mul(a.ONE,i),t),l=a.pow(c,o),u=a.pow(c,t);for(;!a.eql(u,a.ONE);){if(a.eql(u,a.ZERO))return a.ZERO;let p=1;for(let y=a.sqr(u);p<d&&!a.eql(y,a.ONE);p++)y=a.sqr(y);let h=a.pow(m,q<<BigInt(d-p-1));m=a.sqr(h),l=a.mul(l,h),u=a.mul(u,m),d=p}return l}}function Xa(r){if(r%di===Ha){let e=(r+q)/di;return function(n,i){let o=n.pow(i,e);if(!n.eql(n.sqr(o),i))throw new Error("Cannot find square root");return o}}if(r%Zo===Wo){let e=(r-Wo)/Zo;return function(n,i){let o=n.mul(i,vt),s=n.pow(o,e),a=n.mul(i,s),c=n.mul(n.mul(a,vt),s),d=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(d),i))throw new Error("Cannot find square root");return d}}return r%$a,Ya(r)}var Wa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ui(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Wa.reduce((n,i)=>(n[i]="function",n),e);return at(r,t)}function Za(r,e,t){if(t<H)throw new Error("invalid exponent, negatives unsupported");if(t===H)return r.ONE;if(t===q)return e;let n=r.ONE,i=e;for(;t>H;)t&q&&(n=r.mul(n,i)),i=r.sqr(i),t>>=q;return n}function Qa(r,e){let t=new Array(e.length),n=e.reduce((o,s,a)=>r.is0(s)?o:(t[a]=o,r.mul(o,s)),r.ONE),i=r.inv(n);return e.reduceRight((o,s,a)=>r.is0(s)?o:(t[a]=r.mul(o,t[a]),r.mul(o,s)),i),t}function li(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Dr(r,e,t=!1,n={}){if(r<=H)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:i,nByteLength:o}=li(r,e);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let s,a=Object.freeze({ORDER:r,isLE:t,BITS:i,BYTES:o,MASK:or(i),ZERO:H,ONE:q,create:c=>Z(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof c);return H<=c&&c<r},is0:c=>c===H,isOdd:c=>(c&q)===q,neg:c=>Z(-c,r),eql:(c,d)=>c===d,sqr:c=>Z(c*c,r),add:(c,d)=>Z(c+d,r),sub:(c,d)=>Z(c-d,r),mul:(c,d)=>Z(c*d,r),pow:(c,d)=>Za(a,c,d),div:(c,d)=>Z(c*Rr(d,r),r),sqrN:c=>c*c,addN:(c,d)=>c+d,subN:(c,d)=>c-d,mulN:(c,d)=>c*d,inv:c=>Rr(c,r),sqrt:n.sqrt||(c=>(s||(s=Xa(r)),s(a,c))),invertBatch:c=>Qa(a,c),cmov:(c,d,m)=>m?d:c,toBytes:c=>t?Or(c,o):st(c,o),fromBytes:c=>{if(c.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+c.length);return t?Cr(c):We(c)}});return Object.freeze(a)}function Qo(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function hi(r){let e=Qo(r);return e+Math.ceil(e/2)}function Jo(r,e,t=!1){let n=r.length,i=Qo(e),o=hi(e);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let s=t?Cr(r):We(r),a=Z(s,e-q)+q;return t?Or(a,i):st(a,i)}var es=BigInt(0),kr=BigInt(1);function pi(r,e){let t=e.negate();return r?t:e}function ts(r,e){if(!Number.isSafeInteger(r)||r<=0||r>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+r)}function gi(r,e){ts(r,e);let t=Math.ceil(e/r)+1,n=2**(r-1);return{windows:t,windowSize:n}}function Ja(r,e){if(!Array.isArray(r))throw new Error("array expected");r.forEach((t,n)=>{if(!(t instanceof e))throw new Error("invalid point at index "+n)})}function ed(r,e){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((t,n)=>{if(!e.isValid(t))throw new Error("invalid scalar at index "+n)})}var mi=new WeakMap,rs=new WeakMap;function yi(r){return rs.get(r)||1}function ns(r,e){return{constTimeNegate:pi,hasPrecomputes(t){return yi(t)!==1},unsafeLadder(t,n,i=r.ZERO){let o=t;for(;n>es;)n&kr&&(i=i.add(o)),o=o.double(),n>>=kr;return i},precomputeWindow(t,n){let{windows:i,windowSize:o}=gi(n,e),s=[],a=t,c=a;for(let d=0;d<i;d++){c=a,s.push(c);for(let m=1;m<o;m++)c=c.add(a),s.push(c);a=c.double()}return s},wNAF(t,n,i){let{windows:o,windowSize:s}=gi(t,e),a=r.ZERO,c=r.BASE,d=BigInt(2**t-1),m=2**t,l=BigInt(t);for(let u=0;u<o;u++){let p=u*s,h=Number(i&d);i>>=l,h>s&&(h-=m,i+=kr);let y=p,g=p+Math.abs(h)-1,f=u%2!==0,x=h<0;h===0?c=c.add(pi(f,n[y])):a=a.add(pi(x,n[g]))}return{p:a,f:c}},wNAFUnsafe(t,n,i,o=r.ZERO){let{windows:s,windowSize:a}=gi(t,e),c=BigInt(2**t-1),d=2**t,m=BigInt(t);for(let l=0;l<s;l++){let u=l*a;if(i===es)break;let p=Number(i&c);if(i>>=m,p>a&&(p-=d,i+=kr),p===0)continue;let h=n[u+Math.abs(p)-1];p<0&&(h=h.negate()),o=o.add(h)}return o},getPrecomputes(t,n,i){let o=mi.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&mi.set(n,i(o))),o},wNAFCached(t,n,i){let o=yi(t);return this.wNAF(o,this.getPrecomputes(o,t,i),n)},wNAFCachedUnsafe(t,n,i,o){let s=yi(t);return s===1?this.unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,i),n,o)},setWindowSize(t,n){ts(n,e),rs.set(t,n),mi.delete(t)}}}function is(r,e,t,n){if(Ja(t,r),ed(n,e),t.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let i=r.ZERO,o=si(BigInt(t.length)),s=o>12?o-3:o>4?o-2:o?2:1,a=(1<<s)-1,c=new Array(a+1).fill(i),d=Math.floor((e.BITS-1)/s)*s,m=i;for(let l=d;l>=0;l-=s){c.fill(i);for(let p=0;p<n.length;p++){let h=n[p],y=Number(h>>BigInt(l)&BigInt(a));c[y]=c[y].add(t[p])}let u=i;for(let p=c.length-1,h=i;p>0;p--)h=h.add(c[p]),u=u.add(h);if(m=m.add(u),l!==0)for(let p=0;p<s;p++)m=m.double()}return m}function fi(r){return ui(r.Fp),at(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...li(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}function os(r){r.lowS!==void 0&&xt("lowS",r.lowS),r.prehash!==void 0&&xt("prehash",r.prehash)}function td(r){let e=fi(r);at(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:i}=e;if(t){if(!n.eql(i,n.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:rd,hexToBytes:nd}=ai,wi=class extends Error{constructor(e=""){super(e)}},Ze={Err:wi,_tlv:{encode:(r,e)=>{let{Err:t}=Ze;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,i=bt(n);if(i.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?bt(i.length/2|128):"";return bt(r)+o+i+e},decode(r,e){let{Err:t}=Ze,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let i=e[n++],o=!!(i&128),s=0;if(!o)s=i;else{let c=i&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let d=e.subarray(n,n+c);if(d.length!==c)throw new t("tlv.decode: length bytes not complete");if(d[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let m of d)s=s<<8|m;if(n+=c,s<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(r){let{Err:e}=Ze;if(r<Qe)throw new e("integer: negative integers are not allowed");let t=bt(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return t},decode(r){let{Err:e}=Ze;if(r[0]&128)throw new e("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return rd(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=Ze,i=typeof r=="string"?nd(r):r;Kt(i);let{v:o,l:s}=n.decode(48,i);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:d,l:m}=n.decode(2,c);if(m.length)throw new e("invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(d)}},hexFromSig(r){let{_tlv:e,_int:t}=Ze,n=e.encode(2,t.encode(r.r)),i=e.encode(2,t.encode(r.s)),o=n+i;return e.encode(48,o)}},Qe=BigInt(0),$=BigInt(1),np=BigInt(2),ss=BigInt(3),ip=BigInt(4);function id(r){let e=td(r),{Fp:t}=e,n=Dr(e.n,e.nBitLength),i=e.toBytes||((y,g,f)=>{let x=g.toAffine();return qt(Uint8Array.from([4]),t.toBytes(x.x),t.toBytes(x.y))}),o=e.fromBytes||(y=>{let g=y.subarray(1),f=t.fromBytes(g.subarray(0,t.BYTES)),x=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:f,y:x}});function s(y){let{a:g,b:f}=e,x=t.sqr(y),b=t.mul(x,y);return t.add(t.add(b,t.mul(y,g)),f)}if(!t.eql(t.sqr(e.Gy),s(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return ir(y,$,e.n)}function c(y){let{allowedPrivateKeyLengths:g,nByteLength:f,wrapPrivateKey:x,n:b}=e;if(g&&typeof y!="bigint"){if(ot(y)&&(y=Et(y)),typeof y!="string"||!g.includes(y.length))throw new Error("invalid private key");y=y.padStart(f*2,"0")}let L;try{L=typeof y=="bigint"?y:We(he("private key",y,f))}catch{throw new Error("invalid private key, expected hex or "+f+" bytes, got "+typeof y)}return x&&(L=Z(L,b)),ct("private key",L,$,b),L}function d(y){if(!(y instanceof u))throw new Error("ProjectivePoint expected")}let m=Pr((y,g)=>{let{px:f,py:x,pz:b}=y;if(t.eql(b,t.ONE))return{x:f,y:x};let L=y.is0();g==null&&(g=L?t.ONE:t.inv(b));let T=t.mul(f,g),B=t.mul(x,g),U=t.mul(b,g);if(L)return{x:t.ZERO,y:t.ZERO};if(!t.eql(U,t.ONE))throw new Error("invZ was invalid");return{x:T,y:B}}),l=Pr(y=>{if(y.is0()){if(e.allowInfinityPoint&&!t.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:g,y:f}=y.toAffine();if(!t.isValid(g)||!t.isValid(f))throw new Error("bad point: x or y not FE");let x=t.sqr(f),b=s(g);if(!t.eql(x,b))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class u{constructor(g,f,x){if(this.px=g,this.py=f,this.pz=x,g==null||!t.isValid(g))throw new Error("x required");if(f==null||!t.isValid(f))throw new Error("y required");if(x==null||!t.isValid(x))throw new Error("z required");Object.freeze(this)}static fromAffine(g){let{x:f,y:x}=g||{};if(!g||!t.isValid(f)||!t.isValid(x))throw new Error("invalid affine point");if(g instanceof u)throw new Error("projective point not allowed");let b=L=>t.eql(L,t.ZERO);return b(f)&&b(x)?u.ZERO:new u(f,x,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){let f=t.invertBatch(g.map(x=>x.pz));return g.map((x,b)=>x.toAffine(f[b])).map(u.fromAffine)}static fromHex(g){let f=u.fromAffine(o(he("pointHex",g)));return f.assertValidity(),f}static fromPrivateKey(g){return u.BASE.multiply(c(g))}static msm(g,f){return is(u,n,g,f)}_setWindowSize(g){h.setWindowSize(this,g)}assertValidity(){l(this)}hasEvenY(){let{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){d(g);let{px:f,py:x,pz:b}=this,{px:L,py:T,pz:B}=g,U=t.eql(t.mul(f,B),t.mul(L,b)),N=t.eql(t.mul(x,B),t.mul(T,b));return U&&N}negate(){return new u(this.px,t.neg(this.py),this.pz)}double(){let{a:g,b:f}=e,x=t.mul(f,ss),{px:b,py:L,pz:T}=this,B=t.ZERO,U=t.ZERO,N=t.ZERO,C=t.mul(b,b),G=t.mul(L,L),M=t.mul(T,T),_=t.mul(b,L);return _=t.add(_,_),N=t.mul(b,T),N=t.add(N,N),B=t.mul(g,N),U=t.mul(x,M),U=t.add(B,U),B=t.sub(G,U),U=t.add(G,U),U=t.mul(B,U),B=t.mul(_,B),N=t.mul(x,N),M=t.mul(g,M),_=t.sub(C,M),_=t.mul(g,_),_=t.add(_,N),N=t.add(C,C),C=t.add(N,C),C=t.add(C,M),C=t.mul(C,_),U=t.add(U,C),M=t.mul(L,T),M=t.add(M,M),C=t.mul(M,_),B=t.sub(B,C),N=t.mul(M,G),N=t.add(N,N),N=t.add(N,N),new u(B,U,N)}add(g){d(g);let{px:f,py:x,pz:b}=this,{px:L,py:T,pz:B}=g,U=t.ZERO,N=t.ZERO,C=t.ZERO,G=e.a,M=t.mul(e.b,ss),_=t.mul(f,L),ce=t.mul(x,T),E=t.mul(b,B),I=t.add(f,x),A=t.add(L,T);I=t.mul(I,A),A=t.add(_,ce),I=t.sub(I,A),A=t.add(f,b);let P=t.add(L,B);return A=t.mul(A,P),P=t.add(_,E),A=t.sub(A,P),P=t.add(x,b),U=t.add(T,B),P=t.mul(P,U),U=t.add(ce,E),P=t.sub(P,U),C=t.mul(G,A),U=t.mul(M,E),C=t.add(U,C),U=t.sub(ce,C),C=t.add(ce,C),N=t.mul(U,C),ce=t.add(_,_),ce=t.add(ce,_),E=t.mul(G,E),A=t.mul(M,A),ce=t.add(ce,E),E=t.sub(_,E),E=t.mul(G,E),A=t.add(A,E),_=t.mul(ce,A),N=t.add(N,_),_=t.mul(P,A),U=t.mul(I,U),U=t.sub(U,_),_=t.mul(I,ce),C=t.mul(P,C),C=t.add(C,_),new u(U,N,C)}subtract(g){return this.add(g.negate())}is0(){return this.equals(u.ZERO)}wNAF(g){return h.wNAFCached(this,g,u.normalizeZ)}multiplyUnsafe(g){let{endo:f,n:x}=e;ct("scalar",g,Qe,x);let b=u.ZERO;if(g===Qe)return b;if(this.is0()||g===$)return this;if(!f||h.hasPrecomputes(this))return h.wNAFCachedUnsafe(this,g,u.normalizeZ);let{k1neg:L,k1:T,k2neg:B,k2:U}=f.splitScalar(g),N=b,C=b,G=this;for(;T>Qe||U>Qe;)T&$&&(N=N.add(G)),U&$&&(C=C.add(G)),G=G.double(),T>>=$,U>>=$;return L&&(N=N.negate()),B&&(C=C.negate()),C=new u(t.mul(C.px,f.beta),C.py,C.pz),N.add(C)}multiply(g){let{endo:f,n:x}=e;ct("scalar",g,$,x);let b,L;if(f){let{k1neg:T,k1:B,k2neg:U,k2:N}=f.splitScalar(g),{p:C,f:G}=this.wNAF(B),{p:M,f:_}=this.wNAF(N);C=h.constTimeNegate(T,C),M=h.constTimeNegate(U,M),M=new u(t.mul(M.px,f.beta),M.py,M.pz),b=C.add(M),L=G.add(_)}else{let{p:T,f:B}=this.wNAF(g);b=T,L=B}return u.normalizeZ([b,L])[0]}multiplyAndAddUnsafe(g,f,x){let b=u.BASE,L=(B,U)=>U===Qe||U===$||!B.equals(b)?B.multiplyUnsafe(U):B.multiply(U),T=L(this,f).add(L(g,x));return T.is0()?void 0:T}toAffine(g){return m(this,g)}isTorsionFree(){let{h:g,isTorsionFree:f}=e;if(g===$)return!0;if(f)return f(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:g,clearCofactor:f}=e;return g===$?this:f?f(u,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return xt("isCompressed",g),this.assertValidity(),i(u,this,g)}toHex(g=!0){return xt("isCompressed",g),Et(this.toRawBytes(g))}}u.BASE=new u(e.Gx,e.Gy,t.ONE),u.ZERO=new u(t.ZERO,t.ONE,t.ZERO);let p=e.nBitLength,h=ns(u,e.endo?Math.ceil(p/2):p);return{CURVE:e,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:a}}function od(r){let e=fi(r);return at(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function cs(r){let e=od(r),{Fp:t,n}=e,i=t.BYTES+1,o=2*t.BYTES+1;function s(E){return Z(E,n)}function a(E){return Rr(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:d,weierstrassEquation:m,isWithinCurveOrder:l}=id({...e,toBytes(E,I,A){let P=I.toAffine(),R=t.toBytes(P.x),V=qt;return xt("isCompressed",A),A?V(Uint8Array.from([I.hasEvenY()?2:3]),R):V(Uint8Array.from([4]),R,t.toBytes(P.y))},fromBytes(E){let I=E.length,A=E[0],P=E.subarray(1);if(I===i&&(A===2||A===3)){let R=We(P);if(!ir(R,$,t.ORDER))throw new Error("Point is not on curve");let V=m(R),te;try{te=t.sqrt(V)}catch(fe){let re=fe instanceof Error?": "+fe.message:"";throw new Error("Point is not on curve"+re)}let Q=(te&$)===$;return(A&1)===1!==Q&&(te=t.neg(te)),{x:R,y:te}}else if(I===o&&A===4){let R=t.fromBytes(P.subarray(0,t.BYTES)),V=t.fromBytes(P.subarray(t.BYTES,2*t.BYTES));return{x:R,y:V}}else{let R=i,V=o;throw new Error("invalid Point, expected length of "+R+", or uncompressed "+V+", got "+I)}}}),u=E=>Et(st(E,e.nByteLength));function p(E){let I=n>>$;return E>I}function h(E){return p(E)?s(-E):E}let y=(E,I,A)=>We(E.slice(I,A));class g{constructor(I,A,P){this.r=I,this.s=A,this.recovery=P,this.assertValidity()}static fromCompact(I){let A=e.nByteLength;return I=he("compactSignature",I,A*2),new g(y(I,0,A),y(I,A,2*A))}static fromDER(I){let{r:A,s:P}=Ze.toSig(he("DER",I));return new g(A,P)}assertValidity(){ct("r",this.r,$,n),ct("s",this.s,$,n)}addRecoveryBit(I){return new g(this.r,this.s,I)}recoverPublicKey(I){let{r:A,s:P,recovery:R}=this,V=B(he("msgHash",I));if(R==null||![0,1,2,3].includes(R))throw new Error("recovery id invalid");let te=R===2||R===3?A+e.n:A;if(te>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let Q=R&1?"03":"02",Oe=c.fromHex(Q+u(te)),fe=a(te),re=s(-V*fe),St=s(P*fe),Je=c.BASE.multiplyAndAddUnsafe(Oe,re,St);if(!Je)throw new Error("point at infinify");return Je.assertValidity(),Je}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return It(this.toDERHex())}toDERHex(){return Ze.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return It(this.toCompactHex())}toCompactHex(){return u(this.r)+u(this.s)}}let f={isValidPrivateKey(E){try{return d(E),!0}catch{return!1}},normPrivateKeyToScalar:d,randomPrivateKey:()=>{let E=hi(e.n);return Jo(e.randomBytes(E),e.n)},precompute(E=8,I=c.BASE){return I._setWindowSize(E),I.multiply(BigInt(3)),I}};function x(E,I=!0){return c.fromPrivateKey(E).toRawBytes(I)}function b(E){let I=ot(E),A=typeof E=="string",P=(I||A)&&E.length;return I?P===i||P===o:A?P===2*i||P===2*o:E instanceof c}function L(E,I,A=!0){if(b(E))throw new Error("first arg must be private key");if(!b(I))throw new Error("second arg must be public key");return c.fromHex(I).multiply(d(E)).toRawBytes(A)}let T=e.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");let I=We(E),A=E.length*8-e.nBitLength;return A>0?I>>BigInt(A):I},B=e.bits2int_modN||function(E){return s(T(E))},U=or(e.nBitLength);function N(E){return ct("num < 2^"+e.nBitLength,E,Qe,U),st(E,e.nByteLength)}function C(E,I,A=G){if(["recovered","canonical"].some(dt=>dt in A))throw new Error("sign() legacy options not supported");let{hash:P,randomBytes:R}=e,{lowS:V,prehash:te,extraEntropy:Q}=A;V==null&&(V=!0),E=he("msgHash",E),os(A),te&&(E=he("prehashed msgHash",P(E)));let Oe=B(E),fe=d(I),re=[N(fe),N(Oe)];if(Q!=null&&Q!==!1){let dt=Q===!0?R(t.BYTES):Q;re.push(he("extraEntropy",dt))}let St=qt(...re),Je=Oe;function Xr(dt){let At=T(dt);if(!l(At))return;let Wr=a(At),Ht=c.BASE.multiply(At).toAffine(),ut=s(Ht.x);if(ut===Qe)return;let jt=s(Wr*s(Je+ut*fe));if(jt===Qe)return;let Bt=(Ht.x===ut?0:2)|Number(Ht.y&$),Ri=jt;return V&&p(jt)&&(Ri=h(jt),Bt^=1),new g(ut,Ri,Bt)}return{seed:St,k2sig:Xr}}let G={lowS:e.lowS,prehash:!1},M={lowS:e.lowS,prehash:!1};function _(E,I,A=G){let{seed:P,k2sig:R}=C(E,I,A),V=e;return ci(V.hash.outputLen,V.nByteLength,V.hmac)(P,R)}c.BASE._setWindowSize(8);function ce(E,I,A,P=M){let R=E;I=he("msgHash",I),A=he("publicKey",A);let{lowS:V,prehash:te,format:Q}=P;if(os(P),"strict"in P)throw new Error("options.strict was renamed to lowS");if(Q!==void 0&&Q!=="compact"&&Q!=="der")throw new Error("format must be compact or der");let Oe=typeof R=="string"||ot(R),fe=!Oe&&!Q&&typeof R=="object"&&R!==null&&typeof R.r=="bigint"&&typeof R.s=="bigint";if(!Oe&&!fe)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let re,St;try{if(fe&&(re=new g(R.r,R.s)),Oe){try{Q!=="compact"&&(re=g.fromDER(R))}catch(Bt){if(!(Bt instanceof Ze.Err))throw Bt}!re&&Q!=="der"&&(re=g.fromCompact(R))}St=c.fromHex(A)}catch{return!1}if(!re||V&&re.hasHighS())return!1;te&&(I=e.hash(I));let{r:Je,s:Xr}=re,dt=B(I),At=a(Xr),Wr=s(dt*At),Ht=s(Je*At),ut=c.BASE.multiplyAndAddUnsafe(St,Wr,Ht)?.toAffine();return ut?s(ut.x)===Je:!1}return{CURVE:e,getPublicKey:x,getSharedSecret:L,sign:_,verify:ce,ProjectivePoint:c,Signature:g,utils:f}}function sd(r){return{hash:r,hmac:(e,...t)=>ri(r,e,zo(...t)),randomBytes:Ho}}function as(r,e){let t=n=>cs({...r,...sd(n)});return{...t(e),create:t}}var ls=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ds=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),cd=BigInt(1),xi=BigInt(2),us=(r,e)=>(r+e/xi)/e;function ad(r){let e=ls,t=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),d=r*r*r%e,m=d*d*r%e,l=pe(m,t,e)*m%e,u=pe(l,t,e)*m%e,p=pe(u,xi,e)*d%e,h=pe(p,i,e)*p%e,y=pe(h,o,e)*h%e,g=pe(y,a,e)*y%e,f=pe(g,c,e)*g%e,x=pe(f,a,e)*y%e,b=pe(x,t,e)*m%e,L=pe(b,s,e)*h%e,T=pe(L,n,e)*d%e,B=pe(T,xi,e);if(!Ei.eql(Ei.sqr(B),r))throw new Error("Cannot find square root");return B}var Ei=Dr(ls,void 0,void 0,{sqrt:ad}),zt=as({a:BigInt(0),b:BigInt(7),Fp:Ei,n:ds,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=ds,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-cd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,s=BigInt("0x100000000000000000000000000000000"),a=us(o*r,e),c=us(-n*r,e),d=Z(r-a*t-c*i,e),m=Z(-a*n-c*o,e),l=d>s,u=m>s;if(l&&(d=e-d),u&&(m=e-m),d>s||m>s)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:l,k1:d,k2neg:u,k2:m}}}},Go),pp=BigInt(0);var gp=zt.ProjectivePoint;var hs=Ut(ne("node:crypto"),1);var _r=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function ps(r,e,t){let n=hs.default.createHash("sha256");if(t instanceof Uint8Array)n.update(t);else for(let o of t)n.update(o);let i=n.digest();try{return zt.verify(e,i,r)}catch(o){throw new _r(String(o))}}var Mr=class{type="secp256k1";raw;_key;constructor(e){this._key=ms(e),this.raw=gs(this._key)}toMultihash(){return He.digest(xr(this))}toCID(){return ee.createV1(114,this.toMultihash())}toString(){return K.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:je(this.raw,e.raw)}verify(e,t){return ps(this._key,t,e)}};function ys(r){return new Mr(r)}function gs(r){return zt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ms(r){try{return zt.ProjectivePoint.fromHex(r),r}catch(e){throw new ur(String(e))}}function fs(r){let{Type:e,Data:t}=rr.decode(r.digest),n=t??new Uint8Array;switch(e){case me.Ed25519:return To(n);case me.secp256k1:return ys(n);default:throw new $t}}function xr(r){return rr.encode({Type:me[r.type],Data:r.raw})}var ws=Symbol.for("nodejs.util.inspect.custom"),dd=114,sr=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()})`}[Zr]=!0;toString(){return this.string==null&&(this.string=K.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ee.createV1(dd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return je(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return je(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[ws](){return`PeerId(${this.toString()})`}},Fr=class extends sr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},Kr=class extends sr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},qr=class extends sr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},ud=2336,zr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=He.digest(Ge(this.url))}[ws](){return`PeerId(${this.url})`}[Zr]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ee.createV1(ud,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=z(e)),e.toString()===this.toString())}};function xs(r,e){let t;if(r.charAt(0)==="1"||r.charAt(0)==="Q")t=pt(K.decode(`z${r}`));else{if(e==null)throw new Lt('Please pass a multibase decoder for strings that do not start with "1" or "Q"');t=pt(e.decode(r))}return ld(t)}function ld(r){if(pd(r))return new Fr({multihash:r});if(hd(r))try{let e=fs(r);if(e.type==="Ed25519")return new Kr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new qr({multihash:r,publicKey:e})}catch{let t=z(r.digest);return new zr(new URL(t))}throw new lr("Supplied PeerID Multihash is invalid")}function hd(r){return r.code===He.code}function pd(r){return r.code===Cn.code}var ye=ne("node:net");function Vr(r){return!!(0,ye.isIP)(r)}var bs=Ut(Es(),1),gd=["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"],md=gd.map(r=>new bs.Netmask(r));function bi(r){for(let e of md)if(e.contains(r))return!0;return!1}function yd(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function fd(r){let e=r.split(":");if(e.length<2)return!1;let t=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),i=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(t.substring(0,2),16)}.${parseInt(t.substring(2),16)}`;return bi(i)}function wd(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function xd(r){let e=r.split(":"),t=e[e.length-1];return bi(t)}function Ed(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Is(r){return(0,ye.isIPv4)(r)?bi(r):yd(r)?fd(r):wd(r)?xd(r):(0,ye.isIPv6)(r)?Ed(r):void 0}var bd=4,Id=41,vd=53,Sd=54,Ad=55,Bd=56;function vs(r){try{let[[e,t]]=r.stringTuples();if(t==null)return!0;if(e===vd||e===Sd||e===Ad||e===Bd)return!1;if(e===bd||e===Id)return Is(t)??!1}catch{}return!0}var Hr=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,i){return this.readAtomically(()=>{let o=0,s=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",d=2**(8*i)-1;for(;;){let m=this.readAtomically(()=>{let l=this.readChar();if(l===void 0)return;let u=Number.parseInt(l,e);if(!Number.isNaN(u))return u});if(m===void 0)break;if(o*=e,o+=m,o>d||(s+=1,t!==void 0&&s>t))return}if(s!==0)return!n&&c&&s>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let i=n*2;if(n<t.length-3){let s=this.readSeparator(":",n,()=>this.readIPv4Addr());if(s!==void 0)return t[i]=s[0],t[i+1]=s[1],t[i+2]=s[2],t[i+3]=s[3],[i+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[i,!1];t[i]=o>>8,t[i+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,i]=e(t);if(n===16)return t;if(i||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),s=16-(n+2),[a]=e(o.subarray(0,s));return t.set(o.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var x0=new Hr;var U0=parseInt("0xFFFF",16),L0=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Bs=ye.isIPv4,Od=ye.isIPv6,Ii=function(r){let e=0;if(r=r.toString().trim(),Bs(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(Od(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=Bs(t[n]),s;o&&(s=Ii(t[n]),t[n]=z(s.slice(0,2),"base16")),s!=null&&++n<8&&t.splice(n,0,z(s.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let i=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);i[e++]=o>>8&255,i[e++]=o&255}return i}throw new Error("invalid ip address")},Us=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let i=[];for(let o=0;o<t;o++)i.push(r[e+o]);return i.join(".")}if(t===16){let i=[];for(let o=0;o<t;o+=2)i.push(n.getUint16(e+o).toString(16));return i.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var Vt={},vi={},Rd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Rd.forEach(r=>{let e=Dd(...r);vi[e.code]=e,Vt[e.name]=e});function Dd(r,e,t,n,i){return{code:r,size:e,name:t,resolvable:!!n,path:!!i}}function k(r){if(typeof r=="number"){if(vi[r]!=null)return vi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Vt[r]!=null)return Vt[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var lg=k("ip4"),hg=k("ip6"),pg=k("ipcidr");function Ui(r,e){switch(k(r).code){case 4:case 41:return _d(e);case 42:return Bi(e);case 43:return z(e,"base10");case 6:case 273:case 33:case 132:return Ns(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Bi(e);case 421:return qd(e);case 444:return Ts(e);case 445:return Ts(e);case 466:return Kd(e);case 481:return globalThis.encodeURIComponent(Bi(e));default:return z(e,"base16")}}function Li(r,e){switch(k(r).code){case 4:return Ls(e);case 41:return Ls(e);case 42:return Ai(e);case 43:return Ge(e,"base10");case 6:case 273:case 33:case 132:return Ti(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ai(e);case 421:return Md(e);case 444:return zd(e);case 445:return Vd(e);case 466:return Fd(e);case 481:return Ai(globalThis.decodeURIComponent(e));default:return Ge(e,"base16")}}var Si=Object.values(Qt).map(r=>r.decoder),kd=function(){let r=Si[0].or(Si[1]);return Si.slice(2).forEach(e=>r=r.or(e)),r}();function Ls(r){if(!Vr(r))throw new Error("invalid ip address");return Ii(r)}function _d(r){let e=Us(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Vr(e))throw new Error("invalid ip address");return e}function Ti(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function Ns(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Ai(r){let e=Ge(r),t=Uint8Array.from(Dt(e.length));return Ce([t,e],t.length+e.length)}function Bi(r){let e=mt(r);if(r=r.slice(se(e)),r.length!==e)throw new Error("inconsistent lengths");return z(r)}function Md(r){let e;r[0]==="Q"||r[0]==="1"?e=pt(K.decode(`z${r}`)).bytes:e=ee.parse(r).multihash.bytes;let t=Uint8Array.from(Dt(e.length));return Ce([t,e],t.length+e.length)}function Fd(r){let e=kd.decode(r),t=Uint8Array.from(Dt(e.length));return Ce([t,e],t.length+e.length)}function Kd(r){let e=mt(r),t=r.slice(se(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+z(t,"base64url")}function qd(r){let e=mt(r),t=r.slice(se(e));if(t.length!==e)throw new Error("inconsistent lengths");return z(t,"base58btc")}function zd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=Ve.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Ti(n);return Ce([t,i],t.length+i.length)}function Vd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=Ve.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let i=Ti(n);return Ce([t,i],t.length+i.length)}function Ts(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=z(e,"base32"),i=Ns(t);return`${n}:${i}`}function Cs(r){r=Ni(r);let e=[],t=[],n=null,i=r.split("/").slice(1);if(i.length===1&&i[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<i.length;o++){let s=i[o],a=k(s);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=i.length)throw new jr("invalid address: "+r);if(a.path===!0){n=Ni(i.slice(o).join("/")),e.push([a.code,Li(a.code,n)]),t.push([a.code,n]);break}let c=Li(a.code,i[o]);e.push([a.code,c]),t.push([a.code,Ui(a.code,c)])}return{string:Os(t),bytes:$r(e),tuples:e,stringTuples:t,path:n}}function Ci(r){let e=[],t=[],n=null,i=0;for(;i<r.length;){let o=mt(r,i),s=se(o),a=k(o),c=Hd(a,r.slice(i+s));if(c===0){e.push([o]),t.push([o]),i+=s;continue}let d=r.slice(i+s,i+s+c);if(i+=c+s,i>r.length)throw new jr("Invalid address Uint8Array: "+z(r,"base16"));e.push([o,d]);let m=Ui(o,d);if(t.push([o,m]),a.path===!0){n=m;break}}return{bytes:Uint8Array.from(r),string:Os(t),tuples:e,stringTuples:t,path:n}}function Os(r){let e=[];return r.map(t=>{let n=k(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),Ni(e.join("/"))}function $r(r){return Ce(r.map(e=>{let t=k(e[0]),n=Uint8Array.from(Dt(t.code));return e.length>1&&e[1]!=null&&(n=Ce([n,e[1]])),n}))}function Hd(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=mt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+se(t)}}function Ni(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}var jr=class extends Error{static name="ParseError";name="ParseError";constructor(e){super(`Error parsing address: ${e}`)}};var jd=Symbol.for("nodejs.util.inspect.custom"),Pi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),$d=[k("dns").code,k("dns4").code,k("dns6").code,k("dnsaddr").code],Oi=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},Gr=class r{bytes;#e;#t;#r;#n;[Pi]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ci(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=Cs(e)}else if(Rs(e))t=Ci(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#e=t.string,this.#t=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let e,t,n,i,o="",s=k("tcp"),a=k("udp"),c=k("ip4"),d=k("ip6"),m=k("dns6"),l=k("ip6zone");for(let[p,h]of this.stringTuples())p===l.code&&(o=`%${h??""}`),$d.includes(p)&&(t=s.name==="tcp"?"tcp":"udp",i=443,n=`${h??""}${o}`,e=p===m.code?6:4),(p===s.code||p===a.code)&&(t=k(p).name==="tcp"?"tcp":"udp",i=parseInt(h??"")),(p===c.code||p===d.code)&&(t=k(p).name==="tcp"?"tcp":"udp",n=`${h??""}${o}`,e=p===d.code?6:4);if(e==null||t==null||n==null||i==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:i}}protos(){return this.#t.map(([e])=>Object.assign({},k(e)))}protoCodes(){return this.#t.map(([e])=>e)}protoNames(){return this.#t.map(([e])=>k(e).name)}tuples(){return this.#t.map(([e,t])=>t==null?[e]:[e,t])}stringTuples(){return this.#r.map(([e,t])=>t==null?[e]:[e,t])}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),i=n.lastIndexOf(t);if(i<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,i))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r($r(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,i])=>{n===Vt.p2p.code&&e.push([n,i]),n===Vt["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?z(K.decode(`z${n}`),"base58btc"):z(ee.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return je(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=Ps.get(t.name);if(n==null)throw new Oi(`no available resolver for ${t.name}`);return(await n(this,e)).map(o=>ar(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[jd](){return`Multiaddr(${this.#e})`}};var Ps=new Map;function Rs(r){return!!r?.[Pi]}function ar(r){return new Gr(r)}function Ds(r,e,t,n){let i=()=>{n?.log.trace("query",e),r.query({questions:[{name:e,type:"PTR"}]})};return i(),setInterval(i,t)}function ks(r,e,t,n){if(r.answers==null)return;let i,o=[];if(r.answers.forEach(s=>{switch(s.type){case"PTR":i=s;break;case"TXT":o.push(s);break;default:break}}),r.additionals.forEach(s=>{switch(s.type){case"TXT":o.push(s);break;default:break}}),!(i==null||i?.name!==t||o.length===0||i.data.startsWith(e)))try{let s=o.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>ar(c.toString().substring(8))),a=s[0].getPeerId();if(a==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",a),{id:xs(a),multiaddrs:s.map(c=>c.decapsulateCode(k("p2p").code))}}catch(s){n?.log.error("failed to parse mdns response",s)}}function _s(r,e,t,n,i,o,s){if(!o){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&r.questions[0]!=null&&r.questions[0].name===i){let a=[];a.push({name:i,type:"PTR",class:"IN",ttl:120,data:t+"."+i}),n.filter(Gd).forEach(c=>{let d="dnsaddr="+c.toString();if(d.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",c);return}if(c.getPeerId()==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",c);return}a.push({name:t+"."+i,type:"TXT",class:"IN",ttl:120,data:d})}),s?.log.trace("responding to query"),e.respond(a)}}function Gd(r){return!!vs(r)}function Ms(r){let e="",t="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<r;n++)e+=t.charAt(Math.floor(Math.random()*t.length));return e}var Yr=class extends hr{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,t={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=t.broadcast!==!1,this.interval=t.interval??1e3*10,this.serviceTag=t.serviceTag??"_p2p._udp.local",this.ip=t.ip??"224.0.0.251",this.peerName=t.peerName??Ms(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=t.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[ki]=this;[Symbol.toStringTag]="@libp2p/mdns";[Fi]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Fs.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=Ds(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),_s(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let t=ks(e,this.peerName,this.serviceTag,{log:this.log});t!=null&&(this.log("discovered peer in mDNS query response %p",t.id),this.dispatchEvent(new CustomEvent("peer",{detail:t})))}catch(t){this.log.error("Error processing peer response",t)}}_onMdnsWarning(e){this.log.error("mdns warning",e)}_onMdnsError(e){this.log.error("mdns error",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function Xd(r={}){return e=>new Yr(e,r)}return js(Wd);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/hashes/esm/utils.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/mdns",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.24",
|
|
4
4
|
"description": "Node.js libp2p mDNS discovery implementation for peer discovery",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/peer-discovery-mdns#readme",
|
|
@@ -50,19 +50,19 @@
|
|
|
50
50
|
"test:electron-main": "aegir test -t electron-main"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@libp2p/interface": "^2.
|
|
54
|
-
"@libp2p/interface-internal": "^2.3.
|
|
55
|
-
"@libp2p/peer-id": "^5.0.
|
|
56
|
-
"@libp2p/utils": "^6.5.
|
|
53
|
+
"@libp2p/interface": "^2.6.0",
|
|
54
|
+
"@libp2p/interface-internal": "^2.3.2",
|
|
55
|
+
"@libp2p/peer-id": "^5.0.13",
|
|
56
|
+
"@libp2p/utils": "^6.5.2",
|
|
57
57
|
"@multiformats/multiaddr": "^12.3.3",
|
|
58
58
|
"@types/multicast-dns": "^7.2.4",
|
|
59
59
|
"dns-packet": "^5.6.1",
|
|
60
60
|
"multicast-dns": "^7.2.5"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@libp2p/crypto": "^5.0.
|
|
64
|
-
"@libp2p/interface-compliance-tests": "^6.3.
|
|
65
|
-
"@libp2p/logger": "^5.1.
|
|
63
|
+
"@libp2p/crypto": "^5.0.12",
|
|
64
|
+
"@libp2p/interface-compliance-tests": "^6.3.2",
|
|
65
|
+
"@libp2p/logger": "^5.1.9",
|
|
66
66
|
"aegir": "^45.0.5",
|
|
67
67
|
"p-wait-for": "^5.0.2",
|
|
68
68
|
"sinon-ts": "^2.0.0"
|