@libp2p/mdns 12.0.29-47cf9cdc1 → 12.0.29-d5534174d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +3 -3
- package/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 pa=Object.create;var Dr=Object.defineProperty;var fa=Object.getOwnPropertyDescriptor;var ga=Object.getOwnPropertyNames;var ma=Object.getPrototypeOf,ya=Object.prototype.hasOwnProperty;var me=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ce=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},ye=(t,e)=>{for(var r in e)Dr(t,r,{get:e[r],enumerable:!0})},Bi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ga(e))!ya.call(t,o)&&o!==r&&Dr(t,o,{get:()=>e[o],enumerable:!(n=fa(e,o))||n.enumerable});return t};var ir=(t,e,r)=>(r=t!=null?pa(ma(t)):{},Bi(e||!t||!t.__esModule?Dr(r,"default",{value:t,enumerable:!0}):r,t)),wa=t=>Bi(Dr({},"__esModule",{value:!0}),t);var Oi=Ce(Ln=>{"use strict";Ln.toString=function(t){switch(t){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+t};Ln.toType=function(t){switch(t.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var Di=Ce(On=>{"use strict";On.toString=function(t){switch(t){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+t};On.toRcode=function(t){switch(t.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var Ui=Ce(Dn=>{"use strict";Dn.toString=function(t){switch(t){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+t};Dn.toOpcode=function(t){switch(t.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var _i=Ce(Un=>{"use strict";Un.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};Un.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Pi=Ce(_n=>{"use strict";_n.toString=function(t){switch(t){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return t<0?null:`OPTION_${t}`};_n.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var Fi=Ce((Ni,Pn)=>{var Ri=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=l,t.familyOf=u,t.name=void 0,t.sizeOf=a,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,o=16,i={name:"v4",size:r,isFormat:f=>e.test(f),encode(f,h,p){p=~~p,h=h||new Uint8Array(p+r);let w=f.length,I=0;for(let x=0;x<w;){let C=f.charCodeAt(x++);C===46?(h[p++]=I,I=0):I=I*10+(C-48)}return h[p]=I,h},decode(f,h){return h=~~h,`${f[h++]}.${f[h++]}.${f[h++]}.${f[h]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:f=>f.length>0&&n.test(f),encode(f,h,p){p=~~p;let w=p+o,I=-1,x=0,C=0,q=!0,F=!1;h=h||new Uint8Array(p+o);for(let H=0;H<f.length;H++){let k=f.charCodeAt(H);k===58?(q?I!==-1?(p<w&&(h[p]=0),p<w-1&&(h[p+1]=0),p+=2):p<w&&(I=p):(F===!0?(p<w&&(h[p]=C),p++):(p<w&&(h[p]=x>>8),p<w-1&&(h[p+1]=x&255),p+=2),x=0,C=0),q=!0,F=!1):k===46?(p<w&&(h[p]=C),p++,C=0,x=0,q=!1,F=!0):(q=!1,k>=97?k-=87:k>=65?k-=55:(k-=48,C=C*10+k),x=(x<<4)+k)}if(q===!1)F===!0?(p<w&&(h[p]=C),p++):(p<w&&(h[p]=x>>8),p<w-1&&(h[p+1]=x&255),p+=2);else if(I===0)p<w&&(h[p]=0),p<w-1&&(h[p+1]=0),p+=2;else if(I!==-1){p+=2;for(let H=Math.min(p-1,w-1);H>=I+2;H--)h[H]=h[H-2];h[I]=0,h[I+1]=0,I=p}if(I!==p&&I!==-1)for(p>w-2&&(p=w-2);w>I;)h[--w]=p<w&&p>I?h[--p]:0;else for(;p<w;)h[p++]=0;return h},decode(f,h){h=~~h;let p="";for(let w=0;w<o;w+=2)w!==0&&(p+=":"),p+=(f[h+w]<<8|f[h+w+1]).toString(16);return p.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let c="ip";t.name=c;function a(f){if(i.isFormat(f))return i.size;if(s.isFormat(f))return s.size;throw Error(`Invalid ip address: ${f}`)}function u(f){return a(f)===i.size?1:2}function l(f,h,p){p=~~p;let w=a(f);return typeof h=="function"&&(h=h(p+w)),w===i.size?i.encode(f,h,p):s.encode(f,h,p)}function d(f,h,p){if(h=~~h,p=p||f.length-h,p===i.size)return i.decode(f,h,p);if(p===s.size)return s.decode(f,h,p);throw Error(`Invalid buffer size needs to be ${i.size} for v4 or ${s.size} for v6.`)}return"default"in t?t.default:t})({});typeof define=="function"&&define.amd?define([],function(){return Ri}):typeof Pn=="object"&&typeof Ni=="object"&&(Pn.exports=Ri)});var Mi=Ce(B=>{"use strict";var A=me("buffer").Buffer,ct=Oi(),Ea=Di(),Ia=Ui(),Fr=_i(),Rn=Pi(),Ct=Fi(),Sa=0,ki=32768,Nn=32768,va=~Nn,Ki=32768,Ba=~Ki,y=B.name={};y.encode=function(t,e,r,{mail:n=!1}={}){e||(e=A.alloc(y.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let c="";i.split(".").forEach(a=>{a.endsWith("\\")?c+=(c.length?".":"")+a.slice(0,-1):s.length===0&&c.length?s.push(c+"."+a):s.push(a)})}else s=i.split(".");for(let c=0;c<s.length;c++){let a=e.write(s[c],r+1);e[r]=a,r+=a+1}}return e[r++]=0,y.encode.bytes=r-o,e};y.encode.bytes=0;y.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,c=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let a=t[e++];if(s+=c?0:1,a===0)break;if((a&192)===0){if(e+a>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");let u=t.toString("utf-8",e,e+a);r&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=a,s+=c?0:a}else if((a&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let u=t.readUInt16BE(e-1)-49152;if(u>=o)throw new Error("Cannot decode name (bad pointer)");e=u,o=u,s+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)")}return y.decode.bytes=s,n.length===0?".":n.join(".")};y.decode.bytes=0;y.encodingLength=function(t){return t==="."||t===".."?1:A.byteLength(t.replace(/^\.|\.$/gm,""))+2};var U={};U.encode=function(t,e,r){e||(e=A.alloc(U.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,U.encode.bytes=n+1,e};U.encode.bytes=0;U.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return U.decode.bytes=r+1,n};U.decode.bytes=0;U.encodingLength=function(t){return A.byteLength(t)+1};var De={};De.encode=function(t,e,r){e||(e=De.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?ki:Sa;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|o,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};De.encode.bytes=12;De.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&ki?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Ia.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:Ea.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};De.decode.bytes=12;De.encodingLength=function(){return 12};var Qe=B.unknown={};Qe.encode=function(t,e,r){return e||(e=A.alloc(Qe.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),Qe.encode.bytes=t.length+2,e};Qe.encode.bytes=0;Qe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return Qe.decode.bytes=r+2,n};Qe.decode.bytes=0;Qe.encodingLength=function(t){return t.length+2};var Je=B.ns={};Je.encode=function(t,e,r){return e||(e=A.alloc(Je.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Je.encode.bytes=y.encode.bytes+2,e};Je.encode.bytes=0;Je.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=y.decode(t,e+2);return Je.decode.bytes=r+2,n};Je.decode.bytes=0;Je.encodingLength=function(t){return y.encodingLength(t)+2};var et=B.soa={};et.encode=function(t,e,r){e||(e=A.alloc(et.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mname,e,r),r+=y.encode.bytes,y.encode(t.rname,e,r,{mail:!0}),r+=y.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),et.encode.bytes=r-n,e};et.encode.bytes=0;et.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=y.decode(t,e),e+=y.decode.bytes,n.rname=y.decode(t,e,{mail:!0}),e+=y.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,et.decode.bytes=e-r,n};et.decode.bytes=0;et.encodingLength=function(t){return 22+y.encodingLength(t.mname)+y.encodingLength(t.rname)};var tt=B.txt={};tt.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let o=0;o<t.length;o++)if(typeof t[o]=="string"&&(t[o]=A.from(t[o])),!A.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=A.alloc(tt.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(o){e[r++]=o.length,o.copy(e,r,0,o.length),r+=o.length}),e.writeUInt16BE(r-n-2,n),tt.encode.bytes=r-n,e};tt.encode.bytes=0;tt.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=[];for(;n>0;){let i=t[e++];if(--n,n<i)throw new Error("Buffer overflow");o.push(t.slice(e,e+i)),e+=i,n-=i}return tt.decode.bytes=e-r,o};tt.decode.bytes=0;tt.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=A.byteLength(r)+1:e+=r.length+1}),e};var rt=B.null={};rt.encode=function(t,e,r){e||(e=A.alloc(rt.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=A.from(t)),t||(t=A.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),rt.encode.bytes=r-n,e};rt.encode.bytes=0;rt.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,rt.decode.bytes=e-r,o};rt.decode.bytes=0;rt.encodingLength=function(t){return t?(A.isBuffer(t)?t.length:A.byteLength(t))+2:2};var nt=B.hinfo={};nt.encode=function(t,e,r){e||(e=A.alloc(nt.encodingLength(t))),r||(r=0);let n=r;return r+=2,U.encode(t.cpu,e,r),r+=U.encode.bytes,U.encode(t.os,e,r),r+=U.encode.bytes,e.writeUInt16BE(r-n-2,n),nt.encode.bytes=r-n,e};nt.encode.bytes=0;nt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=U.decode(t,e),e+=U.decode.bytes,n.os=U.decode(t,e),e+=U.decode.bytes,nt.decode.bytes=e-r,n};nt.decode.bytes=0;nt.encodingLength=function(t){return U.encodingLength(t.cpu)+U.encodingLength(t.os)+2};var Le=B.ptr={},Aa=B.cname=Le,Ca=B.dname=Le;Le.encode=function(t,e,r){return e||(e=A.alloc(Le.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Le.encode.bytes=y.encode.bytes+2,e};Le.encode.bytes=0;Le.decode=function(t,e){e||(e=0);let r=y.decode(t,e+2);return Le.decode.bytes=y.decode.bytes+2,r};Le.decode.bytes=0;Le.encodingLength=function(t){return y.encodingLength(t)+2};var ot=B.srv={};ot.encode=function(t,e,r){e||(e=A.alloc(ot.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),y.encode(t.target,e,r+8);let n=y.encode.bytes+6;return e.writeUInt16BE(n,r),ot.encode.bytes=n+2,e};ot.encode.bytes=0;ot.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=y.decode(t,e+8),ot.decode.bytes=r+2,n};ot.decode.bytes=0;ot.encodingLength=function(t){return 8+y.encodingLength(t.target)};var we=B.caa={};we.ISSUER_CRITICAL=128;we.encode=function(t,e,r){let n=we.encodingLength(t);return e||(e=A.alloc(we.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=we.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,U.encode(t.tag,e,r),r+=U.encode.bytes,e.write(t.value,r),r+=A.byteLength(t.value),we.encode.bytes=n,e};we.encode.bytes=0;we.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=U.decode(t,e),e+=U.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&we.ISSUER_CRITICAL),we.decode.bytes=r+2,o};we.decode.bytes=0;we.encodingLength=function(t){return U.encodingLength(t.tag)+U.encodingLength(t.value)+2};var gt=B.mx={};gt.encode=function(t,e,r){e||(e=A.alloc(gt.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,y.encode(t.exchange,e,r),r+=y.encode.bytes,e.writeUInt16BE(r-n-2,n),gt.encode.bytes=r-n,e};gt.encode.bytes=0;gt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=y.decode(t,e),e+=y.decode.bytes,gt.decode.bytes=e-r,n};gt.encodingLength=function(t){return 4+y.encodingLength(t.exchange)};var it=B.a={};it.encode=function(t,e,r){return e||(e=A.alloc(it.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,Ct.v4.encode(t,e,r),it.encode.bytes=6,e};it.encode.bytes=0;it.decode=function(t,e){e||(e=0),e+=2;let r=Ct.v4.decode(t,e);return it.decode.bytes=6,r};it.decode.bytes=0;it.encodingLength=function(){return 6};var st=B.aaaa={};st.encode=function(t,e,r){return e||(e=A.alloc(st.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,Ct.v6.encode(t,e,r),st.encode.bytes=18,e};st.encode.bytes=0;st.decode=function(t,e){e||(e=0),e+=2;let r=Ct.v6.decode(t,e);return st.decode.bytes=18,r};st.decode.bytes=0;st.encodingLength=function(){return 18};var pe=B.option={};pe.encode=function(t,e,r){e||(e=A.alloc(pe.encodingLength(t))),r||(r=0);let n=r,o=Rn.toCode(t.code);if(e.writeUInt16BE(o,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(o){case 8:let i=t.sourcePrefixLength||0,s=t.family||Ct.familyOf(t.ip),c=Ct.encode(t.ip,A.alloc),a=Math.ceil(i/8);e.writeUInt16BE(a+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),c.copy(e,r,0,a),r+=a;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let u=t.length||0;e.writeUInt16BE(u,r),r+=2,e.fill(0,r,r+u),r+=u;break;case 14:let l=t.tags.length*2;e.writeUInt16BE(l,r),r+=2;for(let d of t.tags)e.writeUInt16BE(d,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return pe.encode.bytes=r-n,e};pe.encode.bytes=0;pe.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=Rn.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let o=A.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=Ct.decode(o);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return pe.decode.bytes=n+4,r};pe.decode.bytes=0;pe.encodingLength=function(t){if(t.data)return t.data.length+4;switch(Rn.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var xe=B.opt={};xe.encode=function(t,e,r){e||(e=A.alloc(xe.encodingLength(t))),r||(r=0);let n=r,o=Nt(t,pe);return e.writeUInt16BE(o,r),r=cr(t,pe,e,r+2),xe.encode.bytes=r-n,e};xe.encode.bytes=0;xe.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=pe.decode(t,e),e+=pe.decode.bytes,o-=pe.decode.bytes;return xe.decode.bytes=e-r,n};xe.decode.bytes=0;xe.encodingLength=function(t){return 2+Nt(t||[],pe)};var ae=B.dnskey={};ae.PROTOCOL_DNSSEC=3;ae.ZONE_KEY=128;ae.SECURE_ENTRYPOINT=32768;ae.encode=function(t,e,r){e||(e=A.alloc(ae.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!A.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(ae.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ae.encode.bytes=r-n,e.writeUInt16BE(ae.encode.bytes-2,n),e};ae.encode.bytes=0;ae.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==ae.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+o+2),e+=n.key.length,ae.decode.bytes=e-r,n};ae.decode.bytes=0;ae.encodingLength=function(t){return 6+A.byteLength(t.key)};var ke=B.rrsig={};ke.encode=function(t,e,r){e||(e=A.alloc(ke.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!A.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(ct.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,y.encode(t.signersName,e,r),r+=y.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=ct.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=y.decode(t,e),e+=y.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 20+y.encodingLength(t.signersName)+A.byteLength(t.signature)};var Ke=B.rp={};Ke.encode=function(t,e,r){e||(e=A.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mbox||".",e,r,{mail:!0}),r+=y.encode.bytes,y.encode(t.txt||".",e,r),r+=y.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=y.decode(t,e,{mail:!0})||".",e+=y.decode.bytes,n.txt=y.decode(t,e)||".",e+=y.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+y.encodingLength(t.mbox||".")+y.encodingLength(t.txt||".")};var J={};J.encode=function(t,e,r){e||(e=A.alloc(J.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=ct.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var c=A.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return J.encode.bytes=r-n,e};J.encode.bytes=0;J.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var s=t.readUInt8(e);e+=1;for(var c=0;c<s;c++)for(var a=t.readUInt8(e+c),u=0;u<8;u++)if(a&1<<7-u){var l=ct.toString(i<<8|c<<3|u);o.push(l)}e+=s}return J.decode.bytes=e-n,o};J.decode.bytes=0;J.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=ct.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Me=B.nsec={};Me.encode=function(t,e,r){e||(e=A.alloc(Me.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.nextDomain,e,r),r+=y.encode.bytes,J.encode(t.rrtypes,e,r),r+=J.encode.bytes,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=y.decode(t,e),e+=y.decode.bytes,n.rrtypes=J.decode(t,e,o-(e-r)),e+=J.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 2+y.encodingLength(t.nextDomain)+J.encodingLength(t.rrtypes)};var He=B.nsec3={};He.encode=function(t,e,r){e||(e=A.alloc(He.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!A.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!A.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,J.encode(t.rrtypes,e,r),r+=J.encode.bytes,He.encode.bytes=r-n,e.writeUInt16BE(He.encode.bytes-2,n),e};He.encode.bytes=0;He.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=J.decode(t,e,o-(e-r)),e+=J.decode.bytes,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+J.encodingLength(t.rrtypes)};var qe=B.ds={};qe.encode=function(t,e,r){e||(e=A.alloc(qe.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!A.isBuffer(o))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,qe.encode.bytes=r-n,e.writeUInt16BE(qe.encode.bytes-2,n),e};qe.encode.bytes=0;qe.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+o+2),e+=n.digest.length,qe.decode.bytes=e-r,n};qe.decode.bytes=0;qe.encodingLength=function(t){return 6+A.byteLength(t.digest)};var be=B.sshfp={};be.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};be.encode=function(e,r,n){r||(r=A.alloc(be.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=A.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==be.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,be.encode.bytes=n-o,r.writeUInt16BE(be.encode.bytes-2,o),r};be.encode.bytes=0;be.decode=function(e,r){r||(r=0);let n=r,o={};r+=2,o.algorithm=e[r],r+=1,o.hash=e[r],r+=1;let i=be.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,be.decode.bytes=r-n,o};be.decode.bytes=0;be.encodingLength=function(t){return 4+A.from(t.fingerprint,"hex").byteLength};var ze=B.naptr={};ze.encode=function(t,e,r){e||(e=A.alloc(ze.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,U.encode(t.flags,e,r),r+=U.encode.bytes,U.encode(t.services,e,r),r+=U.encode.bytes,U.encode(t.regexp,e,r),r+=U.encode.bytes,y.encode(t.replacement,e,r),r+=y.encode.bytes,ze.encode.bytes=r-n,e.writeUInt16BE(ze.encode.bytes-2,n),e};ze.encode.bytes=0;ze.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=U.decode(t,e),e+=U.decode.bytes,n.services=U.decode(t,e),e+=U.decode.bytes,n.regexp=U.decode(t,e),e+=U.decode.bytes,n.replacement=y.decode(t,e),e+=y.decode.bytes,ze.decode.bytes=e-r,n};ze.decode.bytes=0;ze.encodingLength=function(t){return U.encodingLength(t.flags)+U.encodingLength(t.services)+U.encodingLength(t.regexp)+y.encodingLength(t.replacement)+6};var $e=B.tlsa={};$e.encode=function(t,e,r){e||(e=A.alloc($e.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!A.isBuffer(o))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,$e.encode.bytes=r-n,e.writeUInt16BE($e.encode.bytes-2,n),e};$e.encode.bytes=0;$e.decode=function(t,e){e||(e=0);let r=e,n={},o=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+o+2),e+=n.certificate.length,$e.decode.bytes=e-r,n};$e.decode.bytes=0;$e.encodingLength=function(t){return 5+A.byteLength(t.certificate)};var Fn=B.record=function(t){switch(t.toUpperCase()){case"A":return it;case"PTR":return Le;case"CNAME":return Aa;case"DNAME":return Ca;case"TXT":return tt;case"NULL":return rt;case"AAAA":return st;case"SRV":return ot;case"HINFO":return nt;case"CAA":return we;case"NS":return Je;case"SOA":return et;case"MX":return gt;case"OPT":return xe;case"DNSKEY":return ae;case"RRSIG":return ke;case"RP":return Ke;case"NSEC":return Me;case"NSEC3":return He;case"SSHFP":return be;case"DS":return qe;case"NAPTR":return ze;case"TLSA":return $e}return Qe},te=B.answer={};te.encode=function(t,e,r){e||(e=A.alloc(te.encodingLength(t))),r||(r=0);let n=r;if(y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ct.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,xe.encode(t.options||[],e,r),r+=xe.encode.bytes}else{let o=Fr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=Nn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=Fn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return te.encode.bytes=r-n,e};te.encode.bytes=0;te.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=y.decode(t,e),e+=y.decode.bytes,r.type=ct.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=xe.decode(t,e+8),e+=8+xe.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Fr.toString(o&va),r.flush=!!(o&Nn);let i=Fn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return te.decode.bytes=e-n,r};te.decode.bytes=0;te.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return y.encodingLength(t.name)+8+Fn(t.type).encodingLength(e)};var Oe=B.question={};Oe.encode=function(t,e,r){e||(e=A.alloc(Oe.encodingLength(t))),r||(r=0);let n=r;return y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ct.toType(t.type),r),r+=2,e.writeUInt16BE(Fr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Oe.encode.bytes=r-n,t};Oe.encode.bytes=0;Oe.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=y.decode(t,e),e+=y.decode.bytes,n.type=ct.toString(t.readUInt16BE(e)),e+=2,n.class=Fr.toString(t.readUInt16BE(e)),e+=2,n.class&Ki&&(n.class&=Ba),Oe.decode.bytes=e-r,n};Oe.decode.bytes=0;Oe.encodingLength=function(t){return y.encodingLength(t.name)+4};B.AUTHORITATIVE_ANSWER=1024;B.TRUNCATED_RESPONSE=512;B.RECURSION_DESIRED=256;B.RECURSION_AVAILABLE=128;B.AUTHENTIC_DATA=32;B.CHECKING_DISABLED=16;B.DNSSEC_OK=32768;B.encode=function(t,e,r){let n=!e;n&&(e=A.alloc(B.encodingLength(t))),r||(r=0);let o=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),De.encode(t,e,r),r+=De.encode.bytes,r=cr(t.questions,Oe,e,r),r=cr(t.answers,te,e,r),r=cr(t.authorities,te,e,r),r=cr(t.additionals,te,e,r),B.encode.bytes=r-o,n&&B.encode.bytes!==e.length?e.slice(0,B.encode.bytes):e};B.encode.bytes=0;B.decode=function(t,e){e||(e=0);let r=e,n=De.decode(t,e);return e+=De.decode.bytes,e=Nr(n.questions,Oe,t,e),e=Nr(n.answers,te,t,e),e=Nr(n.authorities,te,t,e),e=Nr(n.additionals,te,t,e),B.decode.bytes=e-r,n};B.decode.bytes=0;B.encodingLength=function(t){return De.encodingLength(t)+Nt(t.questions||[],Oe)+Nt(t.answers||[],te)+Nt(t.authorities||[],te)+Nt(t.additionals||[],te)};B.streamEncode=function(t){let e=B.encode(t),r=A.alloc(2);r.writeUInt16BE(e.byteLength);let n=A.concat([r,e]);return B.streamEncode.bytes=n.byteLength,n};B.streamEncode.bytes=0;B.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=B.decode(t.slice(2));return B.streamDecode.bytes=B.decode.bytes,r};B.streamDecode.bytes=0;function Nt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function cr(t,e,r,n){for(let o=0;o<t.length;o++)e.encode(t[o],r,n),n+=e.encode.bytes;return n}function Nr(t,e,r,n){for(let o=0;o<t.length;o++)t[o]=e.decode(r,n),n+=e.decode.bytes;return n}});var zi=Ce((ip,qi)=>{"use strict";var Hi=_a;process.nextTick(Ua,42);qi.exports=Ta;function Ta(t){var e=n;return r;function r(o){e(o||Oa)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var u=arguments;for(e=La(a)?n:l;i.length;)l(i.shift());function l(d){Hi(Da,d,u)}}}}function La(t){return Object.prototype.toString.call(t)==="[object Error]"}function Oa(){}function Da(t,e){t.apply(null,e)}function Ua(t){t===42&&(Hi=process.nextTick)}function _a(t,e,r){process.nextTick(function(){t(e,r)})}});var ji=Ce((sp,Vi)=>{var kn=Mi(),Pa=me("dgram"),Ra=zi(),Na=me("events"),Mn=me("os"),Kn=function(){};Vi.exports=function(t){t||(t={});var e=new Na.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",o=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),i={address:o,port:r},s={},c=!1,a=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=t.socket||Pa.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,f){try{d=kn.decode(d)}catch(h){e.emit("warning",h);return}e.emit("packet",d,f),d.type==="query"&&e.emit("query",d,f),d.type==="response"&&e.emit("response",d,f)}),u.on("listening",function(){r||(r=i.port=u.address().port),t.multicast!==!1&&(e.update(),a=setInterval(e.update,5e3),u.setMulticastTTL(t.ttl||255),u.setMulticastLoopback(t.loopback!==!1))});var l=Ra(function(d){if(!r||t.bind===!1)return d(null);u.once("error",d),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",d),d(null)})});return l(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,f,h){if(typeof f=="function")return e.send(d,null,f);h||(h=Kn),f?!f.host&&!f.address&&(f.address=i.address):f=i,l(p);function p(w){if(c)return h();if(w)return h(w);var I=kn.encode(d);u.send(I,0,I.length,f.port,f.address||f.host,h)}},e.response=e.respond=function(d,f,h){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|kn.AUTHORITATIVE_ANSWER,e.send(d,f,h)},e.query=function(d,f,h,p){if(typeof f=="function")return e.query(d,null,null,f);if(typeof f=="object"&&f&&f.port)return e.query(d,null,f,h);if(typeof h=="function")return e.query(d,f,null,h);p||(p=Kn),typeof d=="string"&&(d=[{name:d,type:f||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,h,p)},e.destroy=function(d){if(d||(d=Kn),c)return process.nextTick(d);c=!0,clearInterval(a);for(var f in s)try{u.dropMembership(o,f)}catch{}s={},u.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):ka(),f=!1,h=0;h<d.length;h++){var p=d[h];if(!s[p])try{u.addMembership(o,p),s[p]=!0,f=!0}catch(w){e.emit("warning",w)}}if(f){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||Fa())}catch(w){e.emit("warning",w)}e.emit("networkInterface")}},e};function Fa(){for(var t=Mn.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],o=0;o<n.length;o++){var i=n[o];if($i(i.family)&&!i.internal)return Mn.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function ka(){for(var t=Mn.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var o=t[e[n]],i=0;i<o.length;i++){var s=o[i];if($i(s.family)){r.push(s.address);break}}return r}function $i(t){return t===4||t==="IPv4"}});var li=Ce(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.Netmask4Impl=void 0;Jt.ip2long=Qt;Jt.long2ip=Xe;function Xe(t){let e=(t&-16777216)>>>24,r=(t&255<<16)>>>16,n=(t&65280)>>>8,o=t&255;return[e,r,n,o].join(".")}var ul=48,dl=97,ll=65;function hl(t){let e=0,r=10,n="9",o=0;t.length>1&&t[o]==="0"&&(t[o+1]==="x"||t[o+1]==="X"?(o+=2,r=16):"0"<=t[o+1]&&t[o+1]<="9"&&(o++,r=8,n="7"));let i=o;for(;o<t.length;){if("0"<=t[o]&&t[o]<=n)e=e*r+(t.charCodeAt(o)-ul)>>>0;else if(r===16)if("a"<=t[o]&&t[o]<="f")e=e*r+(10+t.charCodeAt(o)-dl)>>>0;else if("A"<=t[o]&&t[o]<="F")e=e*r+(10+t.charCodeAt(o)-ll)>>>0;else break;else break;if(e>4294967295)throw new Error("too large");o++}if(o===i)throw new Error("empty octet");return[e,o]}function Qt(t){let e=[];for(let r=0;r<=3&&t.length!==0;r++){if(r>0){if(t[0]!==".")throw new Error("Invalid IP");t=t.substring(1)}let[n,o]=hl(t);t=t.substring(o),e.push(n)}if(t.length!==0)throw new Error("Invalid IP");switch(e.length){case 1:if(e[0]>4294967295)throw new Error("Invalid IP");return e[0]>>>0;case 2:if(e[0]>255||e[1]>16777215)throw new Error("Invalid IP");return(e[0]<<24|e[1])>>>0;case 3:if(e[0]>255||e[1]>255||e[2]>65535)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2])>>>0;case 4:if(e[0]>255||e[1]>255||e[2]>255||e[3]>255)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0;default:throw new Error("Invalid IP")}}var di=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(!n){let o=e.split("/",2);e=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=Qt(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(Qt(e)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=Xe(this.netLong),this.mask=Xe(this.maskLong),this.hostmask=Xe(~this.maskLong),this.first=this.bitmask<=30?Xe(this.netLong+1):this.base,this.last=this.bitmask<=30?Xe(this.netLong+this.size-2):Xe(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?Xe(this.netLong+this.size-1):void 0}contains(e){return typeof e=="string"&&(e.indexOf("/")>0||e.split(".").length!==4)&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):(Qt(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new t(Xe(this.netLong+this.size*e),this.mask)}forEach(e){let r=Qt(this.first),n=Qt(this.last),o=0;for(;r<=n;)e(Xe(r),r,o),o++,r++}toString(){return this.base+"/"+this.bitmask}};Jt.Netmask4Impl=di});var Mc=Ce(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.Netmask6Impl=void 0;er.ip6bigint=pi;er.bigint2ip6=_t;var pl=li(),hi=(1n<<128n)-1n;function pi(t){let e=t.indexOf("%");e!==-1&&(t=t.substring(0,e));let r=t.lastIndexOf(":");if(r!==-1&&t.indexOf(".",r)!==-1){let n=t.substring(r+1),o=(0,pl.ip2long)(n),i=t.substring(0,r+1)+"0:0";return Kc(i)&~0xffffffffn|BigInt(o)}return Kc(t)}function Kc(t){let e=t.indexOf("::"),r;if(e!==-1){let o=t.substring(0,e),i=t.substring(e+2),s=o===""?[]:o.split(":"),c=i===""?[]:i.split(":"),a=8-s.length-c.length;if(a<0)throw new Error("Invalid IPv6: too many groups");r=[...s,...Array(a).fill("0"),...c]}else r=t.split(":");if(r.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+r.length);let n=0n;for(let o=0;o<8;o++){let i=r[o];if(i.length===0||i.length>4)throw new Error('Invalid IPv6: bad group "'+i+'"');let s=parseInt(i,16);if(isNaN(s)||s<0||s>65535)throw new Error('Invalid IPv6: bad group "'+i+'"');n=n<<16n|BigInt(s)}return n}function _t(t){if(t<0n||t>hi)throw new Error("Invalid IPv6 address value");let e=[];for(let s=0;s<8;s++)e.unshift(Number(t&0xffffn)),t>>=16n;let r=-1,n=0,o=-1,i=0;for(let s=0;s<8;s++)e[s]===0?o===-1?(o=s,i=1):i++:(i>n&&i>=2&&(r=o,n=i),o=-1,i=0);if(i>n&&i>=2&&(r=o,n=i),r!==-1&&r+n===8&&r>0)return e.slice(0,r).map(c=>c.toString(16)).join(":")+"::";if(r===0)return"::"+e.slice(n).map(c=>c.toString(16)).join(":");if(r>0){let s=e.slice(0,r).map(a=>a.toString(16)),c=e.slice(r+n).map(a=>a.toString(16));return s.join(":")+"::"+c.join(":")}else return e.map(s=>s.toString(16)).join(":")}var fi=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(n==null){let o=e.indexOf("/");o!==-1?(n=parseInt(e.substring(o+1),10),e=e.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=hi>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=pi(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=_t(this.netBigint),this.mask=_t(this.maskBigint),this.hostmask=_t(~this.maskBigint&hi),this.first=this.base,this.last=_t(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(e){return typeof e=="string"&&e.indexOf("/")>0&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.last):(pi(e)&this.maskBigint)===this.netBigint}next(e=1){let r=1n<<BigInt(128-this.bitmask);return new t(_t(this.netBigint+r*BigInt(e)),this.bitmask)}forEach(e){let r=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,i=0;for(;r<=o;)e(_t(r),Number(r),i),i++,r++}toString(){return this.base+"/"+this.bitmask}};er.Netmask6Impl=fi});var Hc=Ce(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.long2ip=At.ip2long=At.Netmask=void 0;var In=li();Object.defineProperty(At,"ip2long",{enumerable:!0,get:function(){return In.ip2long}});Object.defineProperty(At,"long2ip",{enumerable:!0,get:function(){return In.long2ip}});var fl=Mc(),gi=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");(e.indexOf("/")!==-1?e.substring(0,e.indexOf("/")):e).indexOf(":")!==-1?this._impl=new fl.Netmask6Impl(e,r):this._impl=new In.Netmask4Impl(e,r),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof In.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(e){return typeof e=="string"&&(e.indexOf("/")>0?e=new t(e):e.indexOf(":")===-1&&e.split(".").length!==4&&(e=new t(e))),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):this._impl.contains(e)}next(e=1){let r=this._impl.next(e);return new t(r.base,r.bitmask)}forEach(e){this._impl.forEach(e)}toString(){return this._impl.toString()}};At.Netmask=gi});var xh={};ye(xh,{mdns:()=>bh});var Te=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 _r=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Pr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var sr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Ai=Symbol.for("@libp2p/peer-discovery");var Tn=Symbol.for("@libp2p/peer-id");var Ci=me("node:events"),Ti=(t,...e)=>{try{(0,Ci.setMaxListeners)(t,...e)}catch{}};function ba(t){return typeof t?.handleEvent=="function"}function xa(t){return(t!==!0&&t!==!1&&t?.once)??!1}var Rr=class extends EventTarget{#e=new Map;constructor(){super(),Ti(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=xa(n);super.addEventListener(e,s=>{if(o){let c=this.#e.get(s.type);c!=null&&(c=c.filter(({callback:a})=>a!==r),this.#e.set(s.type,c))}ba(r)?r.handleEvent(s):r(s)},n);let i=this.#e.get(e);i==null&&(i=[],this.#e.set(e,i)),i.push({callback:r,once:o})}removeEventListener(e,r,n){super.removeEventListener(e.toString(),r??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:i})=>i!==r),this.#e.set(e,o))}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var Li=Symbol.for("@libp2p/service-capabilities");var ua=ir(ji(),1);var Vn={};ye(Vn,{base58btc:()=>G,base58flickr:()=>ja});var cp=new Uint8Array(0);function Gi(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function ue(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Tt(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Tt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Wi(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var Yi=4096;function Xi(t){let e=t.length;if(e<=Yi)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.subarray(n,n+=Yi));return r}function Ka(t){return t?.buffer instanceof ArrayBuffer}function Tt(t){return Ka(t)?t:t.slice()}function Ma(t,e,r){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(n[c]!==255)throw new TypeError(s+" is ambiguous");if(n[c]=i,r){var a=s.toLowerCase().charCodeAt(0),u=s.toUpperCase().charCodeAt(0);a!==c&&(n[a]=i),u!==c&&(n[u]=i)}}var l=t.length,d=t.charAt(0),f=Math.log(l)/Math.log(256),h=Math.log(256)/Math.log(l);function p(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var C=0,q=0,F=0,H=x.length;F!==H&&x[F]===0;)F++,C++;for(var k=(H-F)*h+1>>>0,W=new Uint8Array(k);F!==H;){for(var Q=x[F],ge=0,K=k-1;(Q!==0||ge<q)&&K!==-1;K--,ge++)Q+=256*W[K]>>>0,W[K]=Q%l>>>0,Q=Q/l>>>0;if(Q!==0)throw new Error("Non-zero carry");q=ge,F++}for(var ce=k-q;ce!==k&&W[ce]===0;)ce++;for(var _=d.repeat(C);ce<k;++ce)_+=t.charAt(W[ce]);return _}function w(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var C=0;if(x[C]!==" "){for(var q=0,F=0;x[C]===d;)q++,C++;for(var H=(x.length-C)*f+1>>>0,k=new Uint8Array(H);x[C];){var W=n[x.charCodeAt(C)];if(W===255)return;for(var Q=0,ge=H-1;(W!==0||Q<F)&&ge!==-1;ge--,Q++)W+=l*k[ge]>>>0,k[ge]=W%256>>>0,W=W/256>>>0;if(W!==0)throw new Error("Non-zero carry");F=Q,C++}if(x[C]!==" "){for(var K=H-F;K!==H&&k[K]===0;)K++;for(var ce=new Uint8Array(q+(H-K)),_=q;K!==H;)ce[_++]=k[K++];return ce}}}function I(x){var C=w(x);if(C)return C;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:w,decode:I}}var Ha=Ma,qa=Ha,Qi=qa;var Hn=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},qn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ji(this,e)}},zn=class{decoders;constructor(e){this.decoders=e}or(e){return Ji(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ji(t,e){return new zn({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var $n=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new Hn(e,r,n),this.decoder=new qn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ft({name:t,prefix:e,encode:r,decode:n}){return new $n(t,e,r,n)}function mt({name:t,prefix:e,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:i}=Qi(r,t,n);return Ft({prefix:e,name:t,encode:o,decode:s=>ue(i(s))})}function za(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,c=0,a=0;for(let u=0;u<o;++u){let l=e[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|l,s+=r,s>=8&&(s-=8,i[a++]=255&c>>s)}if(s>=r||(255&c<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function $a(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,c=0;for(let a=0;a<t.length;++a)for(c=c<<8|t[a],s+=8;s>r;)s-=r,i+=e[o&c>>s];if(s!==0&&(i+=e[o&c<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Va(t,e){let r={};for(let n=0;n<t.length;++n)if(r[t[n]]=n,e){let o=t[n].toLowerCase(),i=t[n].toUpperCase();o!==t[n]&&(r[o]=n),i!==t[n]&&(r[i]=n)}return r}function V({name:t,prefix:e,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let i=Va(n,o);return Ft({prefix:e,name:t,encode(s){return $a(s,n,r)},decode(s){return za(s,i,r,t)}})}var G=mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ja=mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jn={};ye(jn,{base32:()=>yt,base32hex:()=>Xa,base32hexpad:()=>Qa,base32hexpadupper:()=>Ja,base32hexupper:()=>Za,base32pad:()=>Ga,base32padupper:()=>Wa,base32upper:()=>Ya,base32z:()=>eu});var yt=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Ya=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Ga=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Wa=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Xa=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),Za=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),Qa=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),Ja=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),eu=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Yn={};ye(Yn,{base36:()=>ar,base36upper:()=>tu});var ar=mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),tu=mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var ru=rs,es=128,nu=127,ou=~nu,iu=Math.pow(2,31);function rs(t,e,r){e=e||[],r=r||0;for(var n=r;t>=iu;)e[r++]=t&255|es,t/=128;for(;t&ou;)e[r++]=t&255|es,t>>>=7;return e[r]=t|0,rs.bytes=r-n+1,e}var su=Gn,cu=128,ts=127;function Gn(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Gn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&ts)<<o:(s&ts)*Math.pow(2,o),o+=7}while(s>=cu);return Gn.bytes=i-n,r}var au=Math.pow(2,7),uu=Math.pow(2,14),du=Math.pow(2,21),lu=Math.pow(2,28),hu=Math.pow(2,35),pu=Math.pow(2,42),fu=Math.pow(2,49),gu=Math.pow(2,56),mu=Math.pow(2,63),yu=function(t){return t<au?1:t<uu?2:t<du?3:t<lu?4:t<hu?5:t<pu?6:t<fu?7:t<gu?8:t<mu?9:10},wu={encode:ru,decode:su,encodingLength:yu},bu=wu,ur=bu;function dr(t,e=0){let r=ur.decode(t,e),n=ur.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&t[e+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[r,n]}function kt(t,e,r=0){return ur.encode(t,e,r),e}function Kt(t){return ur.encodingLength(t)}function Ht(t,e){let r=e.byteLength,n=Kt(t),o=n+Kt(r),i=new Uint8Array(o+r);return kt(t,i,0),kt(r,i,n),i.set(e,o),new Mt(t,r,e,i)}function lr(t){let e=ue(t),[r,n]=dr(e),[o,i]=dr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Mt(r,o,s,e)}function ns(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Gi(t.bytes,r.bytes)}}var Mt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Tt(n),this.bytes=Tt(o)}};function os(t,e){let{bytes:r,version:n}=t;return n===0?Eu(r,Wn(t),e??G.encoder):Iu(r,Wn(t),e??yt.encoder)}var is=new WeakMap;function Wn(t){let e=is.get(t);if(e==null){let r=new Map;return is.set(t,r),r}return e}var re=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Tt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==hr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Su)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Ht(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&ns(e.multihash,n.multihash)}toString(e){return os(this,e)}toJSON(){return{"/":os(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??ss(n,o,i.bytes))}else if(r[vu]===!0){let{version:n,multihash:o,code:i}=r,s=lr(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==hr)throw new Error(`Version 0 CID must use dag-pb (code: ${hr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=ss(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,hr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=ue(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Mt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,f]=dr(e.subarray(r));return r+=f,d},o=n(),i=hr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,c=n(),a=n(),u=r+a,l=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:l,size:u}}static parse(e,r){let[n,o]=xu(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Wn(i).set(n,e),i}};function xu(t,e){switch(t[0]){case"Q":{let r=e??G;return[G.prefix,r.decode(`${G.prefix}${t}`)]}case G.prefix:{let r=e??G;return[G.prefix,r.decode(t)]}case yt.prefix:{let r=e??yt;return[yt.prefix,r.decode(t)]}case ar.prefix:{let r=e??ar;return[ar.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Eu(t,e,r){let{prefix:n}=r;if(n!==G.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function Iu(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var hr=112,Su=18;function ss(t,e,r){let n=Kt(t),o=n+Kt(e),i=new Uint8Array(o+r.byteLength);return kt(t,i,0),kt(e,i,n),i.set(r,o),i}var vu=Symbol.for("@ipld/js-cid/CID");var Xn={};ye(Xn,{identity:()=>Ue});var cs=0,Bu="identity",as=ue;function Au(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ht(cs,as(t))}var Ue={code:cs,name:Bu,encode:as,digest:Au};function fe(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Cu(t){return t.buffer instanceof ArrayBuffer}function wt(t){return Cu(t)?t:t.slice()}async function us(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,wt(e),wt(r.subarray()));return n?.signal?.throwIfAborted(),i}var Zn=me("node:buffer");function bt(t){if(t.buffer instanceof ArrayBuffer)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let e=t.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function Ve(t=0){return bt(Zn.Buffer.alloc(t))}function Ee(t=0){return bt(Zn.Buffer.allocUnsafe(t))}var ds=me("node:buffer");function _e(t,e){return bt(ds.Buffer.concat(t,e))}var hs=Symbol.for("@achingbrain/uint8arraylist");function ls(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function Kr(t){return!!t?.[hs]}var Ie=class t{bufs;length;[hs]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Kr(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Kr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=ls(this.bufs,e);return r.buf[r.index]}set(e,r){let n=ls(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(Kr(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return _e(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:_e(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=n,i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],c=o,a=c+s.byteLength;if(o=a,e>=a)continue;let u=e>=c&&e<a,l=r>c&&r<=a;if(u&&l){if(e===c&&r===a){n.push(s);break}let d=e-c;n.push(s.subarray(d,d+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(l){if(r===a){n.push(s);break}n.push(s.subarray(0,r-c));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Kr(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let d=0;d<i;d++)s[d]=-1;for(let d=0;d<o;d++)s[n[d]]=d;let c=s,a=this.byteLength-n.byteLength,u=n.byteLength-1,l;for(let d=r;d<=a;d+=l){l=0;for(let f=u;f>=0;f--){let h=this.get(d+f);if(n[f]!==h){l=Math.max(1,f-c[h]);break}}if(l===0)return d}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Ve(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Ve(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!fe(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var ws=me("node:buffer");var Qn={};ye(Qn,{base10:()=>Tu});var Tu=mt({prefix:"9",name:"base10",alphabet:"0123456789"});var Jn={};ye(Jn,{base16:()=>Lu,base16upper:()=>Ou});var Lu=V({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),Ou=V({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var eo={};ye(eo,{base2:()=>Du});var Du=V({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var to={};ye(to,{base256emoji:()=>Nu});var ps=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}"),Uu=ps.reduce((t,e,r)=>(t[r]=e,t),[]),_u=ps.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Pu(t){return t.reduce((e,r)=>(e+=Uu[r],e),"")}function Ru(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=_u[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Nu=Ft({prefix:"\u{1F680}",name:"base256emoji",encode:Pu,decode:Ru});var no={};ye(no,{base64:()=>Fu,base64pad:()=>ku,base64url:()=>ro,base64urlpad:()=>Ku});var Fu=V({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ku=V({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ro=V({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ku=V({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var oo={};ye(oo,{base8:()=>Mu});var Mu=V({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var io={};ye(io,{identity:()=>Hu});var Hu=Ft({prefix:"\0",name:"identity",encode:t=>Xi(ue(t)),decode:t=>ue(Wi(t))});var jp=new TextEncoder,Yp=new TextDecoder;var lo={};ye(lo,{sha256:()=>uo,sha512:()=>Vu});var ao=ir(me("node:crypto"),1);var $u=20;function co({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new so(t,e,r,n,o)}var so=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??$u,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?fs(n,this.code,r?.truncate):n.then(o=>fs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function fs(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ht(e,t)}var uo=co({name:"sha2-256",code:18,encode:t=>ue(ao.default.createHash("sha256").update(t).digest())}),Vu=co({name:"sha2-512",code:19,encode:t=>ue(ao.default.createHash("sha512").update(t).digest())});var pr={...io,...eo,...oo,...Qn,...Jn,...jn,...Yn,...Vn,...no,...to},s0={...lo,...Xn};function ys(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ms=ys("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),ho=ys("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Ee(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),ju={utf8:ms,"utf-8":ms,hex:pr.base16,latin1:ho,ascii:ho,binary:ho,...pr},Mr=ju;function de(t,e="utf8"){let r=Mr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?bt(ws.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var bs=me("node:buffer");function j(t,e="utf8"){let r=Mr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?bs.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Yu=parseInt("11111",2),po=parseInt("10000000",2),Gu=parseInt("01111111",2),xs={0:fr,1:fr,2:Wu,3:Qu,4:Ju,5:Zu,6:Xu,16:fr,22:fr,48:fr};function fo(t,e={offset:0}){let r=t[e.offset]&Yu;if(e.offset++,xs[r]!=null)return xs[r](t,e);throw new Error("No decoder for tag "+r)}function gr(t,e){let r=0;if((t[e.offset]&po)===po){let n=t[e.offset]&Gu,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++){if(e.offset>=t.byteLength)throw new Error("invalid DER element length");o+=t[e.offset].toString(16).padStart(2,"0")}r=parseInt(o,16)}else r=t[e.offset],e.offset++;if(!Number.isInteger(r)||r<0||r>t.byteLength-e.offset)throw new Error("invalid DER element length");return r}function fr(t,e){gr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=fo(t,e);if(n===null)break;r.push(n)}return r}function Wu(t,e){let r=gr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function Xu(t,e){let r=gr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let c=`${i}.${s}`,a=[];for(;e.offset<n;){let u=t[e.offset];if(e.offset++,a.push(u&127),u<128){a.reverse();let l=0;for(let d=0;d<a.length;d++)l+=a[d]<<d*7;c+=`.${l}`,a=[]}}return c}function Zu(t,e){return e.offset++,null}function Qu(t,e){let r=gr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function Ju(t,e){let r=gr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function ed(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new Ie;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function go(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=ed(t.byteLength);return new Ie(Uint8Array.from([e.byteLength|po]),e)}function Es(t){let e=new Ie,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new Ie(Uint8Array.from([2]),go(e),e)}function Is(t){let e=Uint8Array.from([0]),r=new Ie(e,t);return new Ie(Uint8Array.from([3]),go(r),r)}function Hr(t,e=48){let r=new Ie;for(let n of t)r.append(n);return new Ie(Uint8Array.from([e]),go(r),r)}var td=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),rd=Uint8Array.from([6,5,43,129,4,0,34]),nd=Uint8Array.from([6,5,43,129,4,0,35]),od={ext:!0,kty:"EC",crv:"P-256"},id={ext:!0,kty:"EC",crv:"P-384"},sd={ext:!0,kty:"EC",crv:"P-521"},mo=32,yo=48,wo=66;function Ss(t){let e=fo(t);return vs(e)}function vs(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===mo*2+1)return n=j(e.subarray(r,r+mo),"base64url"),o=j(e.subarray(r+mo),"base64url"),new zt({...od,key_ops:["verify"],x:n,y:o});if(e.byteLength===yo*2+1)return n=j(e.subarray(r,r+yo),"base64url"),o=j(e.subarray(r+yo),"base64url"),new zt({...id,key_ops:["verify"],x:n,y:o});if(e.byteLength===wo*2+1)return n=j(e.subarray(r,r+wo),"base64url"),o=j(e.subarray(r+wo),"base64url"),new zt({...sd,key_ops:["verify"],x:n,y:o});throw new Te(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Bs(t){return Hr([Es(Uint8Array.from([1])),Hr([cd(t.crv)],160),Hr([Is(new Ie(Uint8Array.from([4]),de(t.x??"","base64url"),de(t.y??"","base64url")))],161)]).subarray()}function cd(t){if(t==="P-256")return td;if(t==="P-384")return rd;if(t==="P-521")return nd;throw new Te(`Invalid curve ${t}`)}var zt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Bs(this.jwk)),this._raw}toMultihash(){return Ue.digest($t(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:fe(this.raw,e.raw)}async verify(e,r,n){return us(this.jwk,r,e,n)}};var sn=ir(me("crypto"),1);var ad=t=>t/2**32|0,ud=t=>t>>>0;function As(t,e,r,n){let o=ad(r),i=ud(r);t.setUint32(e,n?i:o,n),t.setUint32(e+4,n?o:i,n)}function qr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var bo=t=>t?`"${t}" `:"";function at(t,e=""){if(typeof t!="number")throw new TypeError(bo(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(bo(e)+"expected integer >= 0, got "+t);return t}function je(t,e,r=""){if(qr(t)&&(e===void 0||t.length===e))return t;e!==void 0&&at(e,"length");let n=qr(t),o=e!==void 0?` of length ${e}`:"",i=n?`length=${t.length}`:`type=${typeof t}`,s=bo(r)+"expected Uint8Array"+o+", got "+i;throw n?new RangeError(s):new TypeError(s)}function zr(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(at(t.outputLen),at(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var Cs=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function Vt(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function $r(t,e){je(t,void 0,"output");let r=e.outputLen;if(!(t.length>=r))throw new RangeError('"output" expected length >= '+r)}function mr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Vr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Pe(t,e){return t<<32-e|t>>>e}var Ls=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",dd=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function jr(t){if(je(t),Ls)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=dd[t[r]];return e}function Ts(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function xo(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(Ls)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Ts(t.charCodeAt(i)),c=Ts(t.charCodeAt(i+1));if(s===void 0||c===void 0){let a=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+a+'" at index '+i)}n[o]=s*16+c}return n}function Os(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];je(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function ld(t,e,r="opts"){return Cs(t,"defaults"),e!==void 0&&Cs(e,r),Object.assign(t,e)}function Ds(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=ld({},e,"info");let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Us(t=32){at(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var _s=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Ps(t,e,r){return t&e^~t&r}function Rs(t,e,r){return t&e^t&r^e&r}var Yr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Vr(this.buffer)}update(e){Vt(this),je(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length,s=!1;for(let c=0;c<i;){let a=Math.min(o-this.pos,i-c);if(a===o){let u=Vr(e);for(;o<=i-c;c+=o)this.process(u,c);s=!0;continue}n.set(c===0&&a===i?e:e.subarray(c,c+a),this.pos),this.pos+=a,c+=a,this.pos===o&&(this.process(r,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){Vt(this),$r(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,r.fill(0,s),this.padOffset>o-s&&(this.process(n,0),r.fill(0)),As(n,o-8,this.length*8,i),this.process(n,0),this.roundClean();let c=e===r?n:Vr(e),a=this.outputLen,u=a/4,l=this.get();if(a%4||u>l.length)throw new Error("invalid outputLen");for(let d=0;d<u;d++)c.setUint32(4*d,l[d],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:r,length:n,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=n,e.pos=s,s&&e.buffer.set(r),e}clone(){return this._cloneInto()}},Ns=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var hd=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),xt=new Uint32Array(64),Eo=class extends Yr{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,r){super(64,e,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,r){for(let d=0;d<16;d++,r+=4)xt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let f=xt[d-15],h=xt[d-2],p=Pe(f,7)^Pe(f,18)^f>>>3,w=Pe(h,17)^Pe(h,19)^h>>>10;xt[d]=w+xt[d-7]+p+xt[d-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:u,H:l}=this;for(let d=0;d<64;d++){let f=Pe(c,6)^Pe(c,11)^Pe(c,25),h=l+f+Ps(c,a,u)+hd[d]+xt[d]|0,w=(Pe(n,2)^Pe(n,13)^Pe(n,22))+Rs(n,o,i)|0;l=u,u=a,a=c,c=s+h|0,s=i,i=o,o=n,n=h+w|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,i,s,c,a,u,l)}roundClean(){mr(xt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),mr(this.buffer)}},Io=class extends Eo{constructor(){super(32,Ns)}};var Fs=Ds(()=>new Io,_s(1));function Wr(t,e,r=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let n=0;n<t.length;n++)r(t[n],`${e}[${n}]`);return t}var X=(t,e,r)=>je(t,e,r),So=at;function Ks(t,e=""){if(typeof t!="string"){let r=e&&`"${e}" `;throw new TypeError(r+"expected string, got type="+typeof t)}return t}function Et(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function Lt(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var vo=jr,ut=(...t)=>Os(...t),Xr=t=>xo(t),jt=qr,Zr=t=>Us(t),Gr=BigInt(0),ks=BigInt(1),pd=t=>t?`"${t}" `:"";function Ye(t,e=""){if(typeof t!="boolean")throw new TypeError(pd(e)+"expected boolean, got type="+typeof t);return t}function Qr(t){if(typeof t=="bigint"){if(!It(t))throw new RangeError("positive bigint expected, got "+t)}else So(t);return t}function Yt(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function yr(t){let e=Qr(t).toString(16);return e.length&1?"0"+e:e}function Ms(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Gr:BigInt("0x"+t)}function Ge(t){return Ms(jr(t))}function Bo(t){return Ms(jr(fd(je(t)).reverse()))}function Jr(t,e){if(at(e),e===0)throw new Error("zero output length is invalid");t=Qr(t);let r=e*2,n=t.toString(16);if(n.length>r)throw new RangeError("number is too large");return xo(n.padStart(r,"0"))}function Ao(t,e){return Jr(t,e).reverse()}function fd(t){return Uint8Array.from(X(t))}function It(t){return typeof t=="bigint"&&Gr<=t}function Co(t,e,r){return It(t)&&It(e)&&It(r)&&e<=t&&t<r}function To(t,e,r,n){if(!Co(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Gt(t){if(t<Gr)throw new Error("expected non-negative bigint, got "+t);return t===Gr?0:t.toString(2).length}var wr=t=>(Yt(t,"n"),(ks<<BigInt(t))-ks);function Hs(t,e,r){if(at(t,"hashLen"),at(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=I=>new Uint8Array(I),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(t),u=n(t),l=0,d=()=>{a.fill(1),u.fill(0),l=0},f=(...I)=>r(u,ut(a,...I)),h=(I=o)=>{u=f(i,I),a=f(),I.length!==0&&(u=f(s,I),a=f())},p=()=>{if(l++>=c)throw new Error("drbg: tried max amount of iterations");let I=0,x=[];for(;I<e;){a=f();let C=a.slice();x.push(C),I+=a.length}return ut(...x)};return(I,x)=>{d(),h(I);let C;for(;(C=x(p()))===void 0;)h();return d(),C}}function St(t,e={},r={},n="object"){Et(t,n),Et(e,"fields"),Et(r,"optFields");function o(s,c,a){let u=n==="object"?`param "${String(s)}"`:`"${n}.${String(s)}"`,l=t[s];if(!Object.hasOwn(t,s)&&(a?l!==void 0:c!=="function"))throw new TypeError(`${u} is invalid: expected own property`);if(a&&l===void 0)return;let d=typeof l;if(d!==c||l===null)throw new TypeError(`${u} is invalid: expected ${c}, got ${d}`)}let i=(s,c)=>Object.entries(s).forEach(([a,u])=>o(a,u,c));i(e,!1),i(r,!0)}var Z=BigInt(0),N=BigInt(1),vt=BigInt(2),Vs=BigInt(3),Lo=BigInt(4),js=BigInt(5),gd=BigInt(7),Ys=BigInt(8),md=BigInt(9),yd=BigInt(15),Gs=BigInt(16),wd=BigInt("0x10000000000000000");function Se(t,e){if(e<=Z)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=Z?r:e+r}function Ws(t,e,r){if(r<=N)throw new Error("pow: expected modulus > 1, got "+r);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<Z)throw new Error("invalid exponent, negatives unsupported");if(e===Z)return N;if(e===N)return t;let n=t%r;if(n<Z&&(n+=r),e<wd){let c=N;for(;e>Z;)e&N&&(c=c*n%r),n=n*n%r,e>>=N;return c}let o=[];for(;e>Z;)o.push(Number(e&yd)),e>>=Lo;let i=new Array(16);i[0]=N,i[1]=n;for(let c=2;c<16;c++)i[c]=i[c-1]*n%r;let s=i[o[o.length-1]];for(let c=o.length-2;c>=0;c--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;let a=o[c];a!==0&&(s=s*i[a]%r)}return s}function ve(t,e,r){if(r<=N)throw new Error("pow2: expected modulus > 1, got "+r);if(e<Z)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >Z;)n*=n,n%=r;return n}function qs(t,e){if(t===Z)throw new Error("invert: expected non-zero number");if(e<=N)throw new Error("invert: expected modulus > 1, got "+e);let r=Se(t,e),n=e,o=Z,i=N;for(;r!==Z;){let c=n/r,a=n-r*c,u=o-i*c;n=r,r=a,o=i,i=u}if(n!==N)throw new Error("invert: does not exist");return Se(o,e)}function Xs(t,e){if(e<=N)throw new Error("invertCt: expected prime modulus > 1, got "+e);let r=Se(t,e);if(r===Z)throw new Error("invertCt: expected non-zero number");let n=Ws(r,e-vt,e);if(Se(r*n,e)!==N)throw new Error("invertCt: does not exist");return n}function Oo(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Do(t,e){if((t&N)===Z)throw new Error(e+": expected odd modulus, got "+t)}function Zs(t,e){let r=t,n=(r.ORDER+N)/Lo,o=r.pow(e,n);return Oo(r,o,e),o}function bd(t,e){let r=t,n=(r.ORDER-js)/Ys,o=r.mul(e,vt),i=r.pow(o,n),s=r.mul(e,i),c=r.mul(r.mul(s,vt),i),a=r.mul(s,r.sub(c,r.ONE));return Oo(r,a,e),a}function xd(t){let e=Xt(t),r=Qs(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+gd)/Gs;return((c,a)=>{let u=c,l=u.pow(a,s),d=u.mul(l,n),f=u.mul(l,o),h=u.mul(l,i),p=u.eql(u.sqr(d),a),w=u.eql(u.sqr(f),a);l=u.cmov(l,d,p),d=u.cmov(h,f,w);let I=u.eql(u.sqr(d),a),x=u.cmov(l,d,I);return Oo(u,x,a),x})}function Qs(t){if(t<Vs)throw new Error("sqrt is not defined for small field");Do(t,"tonelliShanks");let e=t-N,r=0;for(;e%vt===Z;)e/=vt,r++;let n=vt,o=Xt(t);for(;zs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Zs;let i=o.pow(n,e),s=(e+N)/vt;return function(a,u){let l=a;if(l.is0(u))return u;if(zs(l,u)!==1)throw new Error("Cannot find square root");let d=r,f=l.mul(l.ONE,i),h=l.pow(u,e),p=l.pow(u,s);for(;!l.eql(h,l.ONE);){if(l.is0(h))throw new Error("Cannot find square root: probably non-prime P");let w=1,I=l.sqr(h);for(;!l.eql(I,l.ONE);)if(w++,I=l.sqr(I),w===d)throw new Error("Cannot find square root");let x=N<<BigInt(d-w-1),C=l.pow(f,x);d=w,f=l.sqr(C),h=l.mul(h,f),p=l.mul(p,C)}return p}}function Ed(t){return Do(t,"Fp.sqrt"),t%Lo===Vs?Zs:t%Ys===js?bd:t%Gs===md?xd(t):Qs(t)}var Id=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Wt(t){if(Et(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);Yt(t.BYTES,"BYTES"),Yt(t.BITS,"BITS");for(let e of Id)Lt(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=N)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Uo(t,e,r=!1){Wt(t),Wr(e,"nums"),Ye(r,"passZero");let n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),i=e.reduce((c,a,u)=>n.is0(a)?c:(o[u]=c,n.mul(c,a)),n.ONE),s=n.inv(i);return e.reduceRight((c,a,u)=>n.is0(a)?c:(o[u]=n.mul(c,o[u]),n.mul(c,a)),s),o}function zs(t,e){Wt(t);let r=t;Do(r.ORDER,"FpLegendre");let n=(r.ORDER-N)/vt,o=r.pow(e,n),i=r.eql(o,r.ONE),s=r.eql(o,r.ZERO),c=r.eql(o,r.neg(r.ONE));if(!i&&!s&&!c)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function Sd(t,e){if(e!==void 0&&So(e),t<=Z)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let r=Gt(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${r})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var $s=new WeakMap,en=class{ORDER;BITS;BYTES;isLE;ZERO=Z;ONE=N;_lengths;_mod;constructor(e,r={}){if(e<=N)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=Sd(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return Se(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return Z<=e&&e<this.ORDER}is0(e){return e===Z}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&N)===N}neg(e){return Se(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return Se(e*e,this.ORDER)}add(e,r){return Se(e+r,this.ORDER)}sub(e,r){return Se(e-r,this.ORDER)}mul(e,r){return Se(e*r,this.ORDER)}pow(e,r){return Ws(e,r,this.ORDER)}div(e,r){return Se(e*qs(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return qs(e,this.ORDER)}sqrt(e){let r=$s.get(this);return r||$s.set(this,r=Ed(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?Ao(e,this.BYTES):Jr(e,this.BYTES)}fromBytes(e,r=!1){X(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:c}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=new Uint8Array(o);u.set(e,i?0:u.length-e.length),e=u}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let a=i?Bo(e):Ge(e);if(c&&(a=Se(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return Uo(this,e,!0)}cmov(e,r,n){return Ye(n,"condition"),n?r:e}};function Xt(t,e={}){return Object.freeze(en.prototype),new en(t,e)}function Js(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=N)throw new Error("field order must be greater than 1");let e=Gt(t-N);return Math.ceil(e/8)}function tn(t){let e=Js(t);return e+Math.ceil(e/2)}function rn(t,e,r=!1){X(t);let n=t.length,o=Js(e),i=Math.max(tn(e),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Bo(t):Ge(t),c=Se(s,e-N)+N;return r?Ao(c,o):Jr(c,o)}var Ro=BigInt(0),br=BigInt(1),vd=BigInt(4),_o=16,ec=128,Bd=5,tc=2**31;function Zt(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);Lt(e.fromAffine,"Point.fromAffine"),Lt(e.fromBytes,"Point.fromBytes"),Lt(e.fromHex,"Point.fromHex"),Et(e.BASE,"Point.BASE"),Et(e.ZERO,"Point.ZERO"),Wt(e.Fp),Wt(e.Fn)}function nc(t,e){Zt(t),oc(e,t);let r=Uo(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Ad(t,e,r=1){if(!Number.isSafeInteger(t)||t<r||t>e)throw new Error("invalid window size, expected ["+r+".."+e+"], got W="+t)}function Cd(t,e){let r=t*(4*e+128);if(r>tc)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+tc/2**20+" MiB")}function No(t,e){if(t!==void 0){Lt(t,"randomBytes");try{let r=t(e);if(!jt(r)||r.length!==e)return}catch{return}return t}}function oc(t,e){Wr(t,"points"),t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function Td(t,e,r){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,o)=>{if(!(r===void 0?e.isValid(n):It(n)&&n<r))throw new Error("invalid scalar at index "+o)})}var ic=new WeakMap;function Po(t){return ic.get(t)||1}function Ld(t,e){let r=t.double(),n=[t];for(let o=1;o<e;o++)n.push(n[o-1].add(r));return n}function Od(t,e){let r=2**e,n=r/2,o=BigInt(r-1),i=[];for(;t>Ro;){let s=0;t&br&&(s=Number(t&o),s>=n&&(s-=r),t-=BigInt(s)),i.push(s),t>>=br}return i}function Dd(t,e,r){let n=2**e,o=n/2,i=BigInt(n-1),s=BigInt(e),c=[];for(let a=0;a<r;a++){let u=Number(t&i);t>>=s,u>o&&(u-=n,t+=br),c.push(u)}if(t!==Ro)throw new Error("invalid wnaf");return c}function Ud(t,e,r){let n=0;for(let i of r)n=Math.max(n,i.length);let o=t;for(let i=n-1;i>=0;i--){i!==n-1&&(o=o.double());for(let s=0;s<r.length;s++){let c=r[s][i];if(c){let a=e[s][Math.abs(c)-1>>1];o=o.add(c<0?a.negate():a)}}}return o}var nn=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,r){Zt(e),this.randomBytes=No(r,_o),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,r,n){let o=Math.ceil(n/r)+1,i=2**(r-1),s=[],c=e;for(let a=0;a<o;a++){let u=c;for(let l=0;l<i;l++)s.push(u),u=u.add(c);c=s[s.length-1].double()}return{W:r,bits:n,windows:o,comp:s}}wnafCachedCT(e,r){let{W:n,windows:o,comp:i}=e,s=2**(n-1),c=Dd(r,n,o),a=this.ZERO,u=this.BASE;for(let l=0;l<o;l++){let d=c[l],f=l*s,h=Math.abs(d)-1,p=i[f];for(let I=1;I<s;I++)p=I===h?i[f+I]:p;let w=p.negate();d===0?u=u.add(i[f]):a=a.add(d<0?w:p)}return{p:a,f:u}}getWnafPrecomputes(e,r,n,o){let i=this.wnafPrecomputes.get(r),s=i?.find(c=>c.W===e&&c.bits===n);return s||(s=this.buildWnafTable(r,e,n),typeof o=="function"&&(s={...s,comp:o(s.comp)}),i||(i=[],this.wnafPrecomputes.set(r,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,r){if(this.assertPoint(e),!Co(r,br,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,r,n,o){let i=Po(e);return i===1?this.fixedWindowCT(e,r,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,o),r)}mulCT(e,r,n){return this.validateMulInput(e,r),this.runCT(e,r,this.bits,n)}mulCTBlinded(e,r,n){if(this.validateMulInput(e,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+ec,i=this.randomBytes(_o);if(!jt(i)||i.length!==_o)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=r+Ge(i)*this.Point.Fn.ORDER;return this.runCT(e,s,o,n)}fixedWindowCT(e,r,n){let o=Bd,i=1<<o,s=wr(o),c=new Array(i);c[0]=this.ZERO;for(let l=1;l<i;l++)c[l]=c[l-1].add(e);let a=Math.ceil(n/o),u=this.ZERO;for(let l=a-1;l>=0;l--){if(l!==a-1)for(let h=0;h<o;h++)u=u.double();let d=Number(r>>BigInt(l*o)&s),f=c[0];for(let h=1;h<i;h++)f=h===d?c[h]:f;u=u.add(f)}return{p:u,f:u}}shouldBlind(e,r){return this.randomBytes===void 0?!1:r===br?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,r,n,o){return this.shouldBlind(e,n)?this.mulCTBlinded(e,r,o):this.mulCT(e,r,o)}mulUnsafe(e,r,n){if(this.assertPoint(e),!It(r))throw new Error("invalid scalar");let o=Po(e);if(o===1||r>=this.Point.Fn.ORDER)return on(this.Point,[e],[r],!0);let i=this.getWnafPrecomputes(o,e,this.bits,n);return this.wnafCachedCT(i,r).p}setWindowSize(e,r){this.assertPoint(e),Ad(r,this.bits);let n=Math.ceil((this.bits+ec)/r)+1;Cd(n*2**(r-1),this.Point.Fp.BYTES),ic.set(e,r),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Po(e)!==1}};function on(t,e,r,n=!1){if(Zt(t),oc(e,t),Ye(n,"allowOversized"),Td(r,t.Fn,n?t.Fn.ORDER**vd:void 0),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let o=e.map(s=>Ld(s,4)),i=r.map(s=>Od(s,4));return Ud(t.ZERO,o,i)}function rc(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Wt(e),e}else return Xt(t,{isLE:r})}function sc(t,e,r={},n){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);St(r);for(let a of["p","n","h"]){let u=e[a];if(!(It(u)&&u!==Ro))throw new Error(`CURVE.${a} must be positive bigint`)}let o=rc(e.p,r.Fp,n),i=rc(e.n,r.Fn,n),c=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let a of c)if(!o.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function cc(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var of=sn.default.generateKeyPairSync,xr=32;var _d=64;function ac(t,e,r){if(t.byteLength!==xr)throw new TypeError('"key" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==_d)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=sn.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:j(t,"base64url"),kty:"OKP"}});return sn.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function dc(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var cn=class{type="Ed25519";raw;constructor(e){this.raw=Fo(e,xr)}toMultihash(){return Ue.digest($t(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:fe(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=ac(this.raw,r,e);return dc(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function lc(t){return t=Fo(t,xr),new cn(t)}function Fo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Te(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Rd=Math.pow(2,7),Nd=Math.pow(2,14),Fd=Math.pow(2,21),ko=Math.pow(2,28),Ko=Math.pow(2,35),Mo=Math.pow(2,42),Ho=Math.pow(2,49),z=128,ie=127;function We(t){if(t<Rd)return 1;if(t<Nd)return 2;if(t<Fd)return 3;if(t<ko)return 4;if(t<Ko)return 5;if(t<Mo)return 6;if(t<Ho)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Er(t,e,r=0){switch(We(t)){case 8:e[r++]=t&255|z,t/=128;case 7:e[r++]=t&255|z,t/=128;case 6:e[r++]=t&255|z,t/=128;case 5:e[r++]=t&255|z,t/=128;case 4:e[r++]=t&255|z,t>>>=7;case 3:e[r++]=t&255|z,t>>>=7;case 2:e[r++]=t&255|z,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function qo(t,e){let r=t[e],n=0;if(n+=r&ie,r<z||(r=t[e+1],n+=(r&ie)<<7,r<z)||(r=t[e+2],n+=(r&ie)<<14,r<z)||(r=t[e+3],n+=(r&ie)<<21,r<z)||(r=t[e+4],n+=(r&ie)*ko,r<z)||(r=t[e+5],n+=(r&ie)*Ko,r<z)||(r=t[e+6],n+=(r&ie)*Mo,r<z)||(r=t[e+7],n+=(r&ie)*Ho,r<z))return n;throw new RangeError("Could not decode varint")}function kd(t,e){let r=t.get(e),n=0;if(n+=r&ie,r<z||(r=t.get(e+1),n+=(r&ie)<<7,r<z)||(r=t.get(e+2),n+=(r&ie)<<14,r<z)||(r=t.get(e+3),n+=(r&ie)<<21,r<z)||(r=t.get(e+4),n+=(r&ie)*ko,r<z)||(r=t.get(e+5),n+=(r&ie)*Ko,r<z)||(r=t.get(e+6),n+=(r&ie)*Mo,r<z)||(r=t.get(e+7),n+=(r&ie)*Ho,r<z))return n;throw new RangeError("Could not decode varint")}function zo(t,e=0){return t instanceof Uint8Array?qo(t,e):kd(t,e)}var $o=new Float32Array([-0]),Bt=new Uint8Array($o.buffer);function hc(t,e,r){$o[0]=t,e[r]=Bt[0],e[r+1]=Bt[1],e[r+2]=Bt[2],e[r+3]=Bt[3]}function pc(t,e){return Bt[0]=t[e],Bt[1]=t[e+1],Bt[2]=t[e+2],Bt[3]=t[e+3],$o[0]}var Vo=new Float64Array([-0]),se=new Uint8Array(Vo.buffer);function fc(t,e,r){Vo[0]=t,e[r]=se[0],e[r+1]=se[1],e[r+2]=se[2],e[r+3]=se[3],e[r+4]=se[4],e[r+5]=se[5],e[r+6]=se[6],e[r+7]=se[7]}function gc(t,e){return se[0]=t[e],se[1]=t[e+1],se[2]=t[e+2],se[3]=t[e+3],se[4]=t[e+4],se[5]=t[e+5],se[6]=t[e+6],se[7]=t[e+7],Vo[0]}var Md=BigInt(Number.MAX_SAFE_INTEGER),Hd=BigInt(Number.MIN_SAFE_INTEGER),Be=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Ot;if(e<Md&&e>Hd)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>mc&&(o=0n,++n>mc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ot;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Ot}},Ot=new Be(0,0);Ot.toBigInt=function(){return 0n};Ot.zzEncode=Ot.zzDecode=function(){return this};Ot.length=function(){return 1};var mc=4294967296n;function yc(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function wc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,c;for(;e<r;)c=t[e++],c<128?i[s++]=c:c>191&&c<224?i[s++]=(c&31)<<6|t[e++]&63:c>239&&c<365?(c=((c&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(c>>10),i[s++]=56320+(c&1023)):i[s++]=(c&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function jo(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Re(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function an(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Yo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=wt(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,Re(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 Re(this,4);return an(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Re(this,4);return an(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Re(this,4);let e=pc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Re(this,4);let e=gc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Re(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return wc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Re(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Re(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Be(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Re(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Re(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Re(this,8);let e=an(this.buf,this.pos+=4),r=an(this.buf,this.pos+=4);return new Be(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=qo(this.buf,this.pos);return this.pos+=We(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 Ir(t){return new Yo(t instanceof Uint8Array?t:t.subarray())}function un(t,e,r){let n=Ir(t);return e.decode(n,void 0,r)}function Go(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Ee(s);o+s>e&&(n=Ee(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Dt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Wo(){}var Zo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},qd=Go();function zd(t){return globalThis.Buffer!=null?Ee(t):qd(t)}var vr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Dt(Wo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Dt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Qo((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(dn,10,Be.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Be.fromBigInt(e);return this._push(dn,r.length(),r)}uint64Number(e){return this._push(Er,We(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Be.fromBigInt(e).zzEncode();return this._push(dn,r.length(),r)}sint64Number(e){let r=Be.fromNumber(e).zzEncode();return this._push(dn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Xo,1,e?1:0)}fixed32(e){return this._push(Sr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Be.fromBigInt(e);return this._push(Sr,4,r.lo)._push(Sr,4,r.hi)}fixed64Number(e){let r=Be.fromNumber(e);return this._push(Sr,4,r.lo)._push(Sr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(hc,4,e)}double(e){return this._push(fc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Xo,1,0):this.uint32(r)._push(Vd,r,e)}string(e){let r=yc(e);return r!==0?this.uint32(r)._push(jo,r,e):this._push(Xo,1,0)}fork(){return this.states=new Zo(this),this.head=this.tail=new Dt(Wo,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 Dt(Wo,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=zd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Xo(t,e,r){e[r]=t&255}function $d(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Qo=class extends Dt{next;constructor(e,r){super($d,e,r),this.next=void 0}};function dn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Sr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Vd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(vr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(jd,e,t),this},vr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Yd,e,t),this});function jd(t,e,r){e.set(t,r)}function Yd(t,e,r){t.length<40?jo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(de(t),r)}function Jo(){return new vr}function ln(t,e){let r=Jo();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*hn(t,e,r){let n=Ir(t);yield*e.stream(n,void 0,"$",r)}var pn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function fn(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function ei(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,c){let a=e(s);c.int32(a)},n=function(s){let c=s.int32();return e(c)},o=function*(s){let c=s.int32();yield e(c)};return fn("enum",pn.VARINT,r,n,o)}function gn(t,e,r){return fn("message",pn.LENGTH_DELIMITED,t,e,r)}var le;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(le||(le={}));var ti;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(ti||(ti={}));(function(t){t.codec=()=>ei(ti)})(le||(le={}));var Br;(function(t){let e;t.codec=()=>(e==null&&(e=gn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),le.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),c.lengthDelimited!==!1&&s.ldelim()},(i,s,c={})=>{let a={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{a.Type=le.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(l&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{yield{field:`${c}.Type`,value:le.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(l&7);break}}}})),e);function r(i){return ln(i,t.codec())}t.encode=r;function n(i,s){return un(i,t.codec(),s)}t.decode=n;function o(i,s){return hn(i,t.codec(),s)}t.stream=o})(Br||(Br={}));var ri;(function(t){let e;t.codec=()=>(e==null&&(e=gn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),le.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),c.lengthDelimited!==!1&&s.ldelim()},(i,s,c={})=>{let a={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{a.Type=le.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(l&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{yield{field:`${c}.Type`,value:le.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(l&7);break}}}})),e);function r(i){return ln(i,t.codec())}t.encode=r;function n(i,s){return un(i,t.codec(),s)}t.decode=n;function o(i,s){return hn(i,t.codec(),s)}t.stream=o})(ri||(ri={}));var Tc=ir(me("node:crypto"),1);var mn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(zr(e),je(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),mr(o)}update(e){return Vt(this),this.iHash.update(e),this}digestInto(e){Vt(this),$r(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:c,canXOF:a}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.canXOF=a,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},xc=(()=>{let t=((e,r,n)=>new mn(e,r).update(n).digest());return t.create=(e,r)=>new mn(e,r),t})();var Wd=BigInt(0),ni=class extends Error{constructor(e=""){super(e)}},dt={Err:ni,_tlv:{encode:(t,e)=>{let{Err:r}=dt;if(Yt(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(Ks(e,"data"),e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=yr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?yr(o.length/2|128):"";return yr(t)+i+o+e},decode(t,e){let{Err:r}=dt;e=X(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.decode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of u)s=s<<8|l;if(n+=a,s<128)throw new r("tlv.decode(long): not minimal encoding")}let c=e.subarray(n,n+s);if(c.length!==s)throw new r("tlv.decode: wrong value length");return{v:c,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=dt;if(Qr(t),t<Wd)throw new e("integer: negative integers are not allowed");let r=yr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=dt;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ge(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=dt,o=X(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,i),{v:u,l}=n.decode(2,a);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(c),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=dt;St(t,{r:"bigint",s:"bigint"},{},"sig");let n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},oi=(Object.freeze(dt._tlv),Object.freeze(dt._int),Object.freeze(dt));var Ec=(t,e)=>(t+(t>=0?e:-e)/Ic)/e;function Xd(t,e,r){To("scalar",t,lt,r);let[[n,o],[i,s]]=e,c=Ec(s*t,r),a=Ec(-o*t,r),u=t-c*n-a*i,l=-c*o-a*s,d=u<lt,f=l<lt;d&&(u=-u),f&&(l=-l);let h=wr(Math.ceil(Gt(r)/2))+Ut;if(u<lt||u>=h||l<lt||l>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:u,k2neg:f,k2:l}}function ci(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function ii(t,e){St(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return Ye(r.lowS,"lowS"),Ye(r.prehash,"prehash"),r.format!==void 0&&ci(r.format),r}var lt=BigInt(0),Ut=BigInt(1),Ic=BigInt(2),si=BigInt(3),Zd=BigInt(4);function Sc(t,e={}){let r=sc("weierstrass",t,e),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:c}=i;St(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:a,allowInfinityPoint:u}=e,l=e.randomBytes===void 0?Zr:e.randomBytes;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=Bc(n,o);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(P,m,S){if(u&&m.is0())return Uint8Array.of(0);let{x:T,y:O}=m.toAffine(),b=n.toBytes(T);if(Ye(S,"isCompressed"),S){f();let g=!n.isOdd(O);return ut(vc(g),b)}else return ut(Uint8Array.of(4),b,n.toBytes(O))}function p(P){X(P,void 0,"Point");let{publicKey:m,publicKeyUncompressed:S}=d,T=P.length,O=P[0],b=P.subarray(1);if(u&&T===1&&O===0)return{x:n.ZERO,y:n.ZERO};if(T===m&&(O===2||O===3)){let g=n.fromBytes(b);if(!n.isValid(g))throw new Error("bad point: is not on curve, wrong x");let E=q(g),v;try{v=n.sqrt(E)}catch(M){let R=M instanceof Error?": "+M.message:"";throw new Error("bad point: is not on curve, sqrt error"+R)}f();let D=n.isOdd(v);return(O&1)===1!==D&&(v=n.neg(v)),{x:g,y:v}}else if(T===S&&O===4){let g=n.BYTES,E=n.fromBytes(b.subarray(0,g)),v=n.fromBytes(b.subarray(g,g*2));if(!F(E,v))throw new Error("bad point: is not on curve");return{x:E,y:v}}else throw new Error(`bad point: got length ${T}, expected compressed=${m} or uncompressed=${S}`)}let w=e.toBytes===void 0?h:e.toBytes,I=e.fromBytes===void 0?p:e.fromBytes,x=n.mul(i.b,si),C=n.is0(i.a)?P=>n.ZERO:P=>n.mul(i.a,P);function q(P){let m=n.sqr(P),S=n.mul(m,P);return n.add(n.add(S,n.mul(P,i.a)),i.b)}function F(P,m){let S=n.sqr(m),T=q(P);return n.eql(S,T)}if(!F(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let H=n.mul(n.pow(i.a,si),Zd),k=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(H,k)))throw new Error("bad curve params: a or b");function W(P,m,S=!1){if(!n.isValid(m)||S&&n.is0(m))throw new Error(`bad point coordinate ${P}`);return m}function Q(P){if(!(P instanceof _))throw new Error("Weierstrass Point expected")}function ge(P){if(!a||!a.basises)throw new Error("no endo");return Xd(P,a.basises,o.ORDER)}function K(P,m,S,T){if(!o.isValid(T))throw new RangeError("invalid scalar: out of range");if(a){let{k1neg:O,k1:b,k2neg:g,k2:E}=ge(T),v=new _(n.mul(S.X,a.beta),S.Y,S.Z);P.push(O?S.negate():S,g?v.negate():v),m.push(b,E)}else P.push(S),m.push(T)}let ce=new WeakSet;class _{static BASE=new _(i.Gx,i.Gy,n.ONE);static ZERO=new _(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(m,S,T){this.X=W("x",m),this.Y=W("y",S,!0),this.Z=W("z",T),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){let{x:S,y:T}=m||{};if(!m||!n.isValid(S)||!n.isValid(T))throw new Error("invalid affine point");if(m instanceof _)throw new Error("projective point not allowed");return n.is0(S)&&n.is0(T)?_.ZERO:new _(S,T,n.ONE)}static fromBytes(m){let S=_.fromAffine(I(X(m,void 0,"point")));return S.assertValidity(),S}static fromHex(m){return _.fromBytes(Xr(m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=6,S=!0){return Ze.setWindowSize(this,m),S||this.multiply(si),this}assertValidity(){let m=this;if(m.is0()){if(e.allowInfinityPoint&&n.is0(m.X)&&n.eql(m.Y,n.ONE)&&n.is0(m.Z))return;throw new Error("bad point: ZERO")}if(ce.has(m))return;let{x:S,y:T}=m.toAffine();if(!n.isValid(S)||!n.isValid(T))throw new Error("bad point: x or y not field elements");if(!F(S,T))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");ce.add(m)}hasEvenY(){let{y:m}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(m)}equals(m){Q(m);let{X:S,Y:T,Z:O}=this,{X:b,Y:g,Z:E}=m,v=n.eql(n.mul(S,E),n.mul(b,O)),D=n.eql(n.mul(T,E),n.mul(g,O));return v&&D}negate(){return new _(this.X,n.neg(this.Y),this.Z)}double(){let{X:m,Y:S,Z:T}=this,O=n.ZERO,b=n.ZERO,g=n.ZERO,E=n.mul(m,m),v=n.mul(S,S),D=n.mul(T,T),L=n.mul(m,S);return L=n.add(L,L),g=n.mul(m,T),g=n.add(g,g),O=C(g),b=n.mul(x,D),b=n.add(O,b),O=n.sub(v,b),b=n.add(v,b),b=n.mul(O,b),O=n.mul(L,O),g=n.mul(x,g),D=C(D),L=n.sub(E,D),L=C(L),L=n.add(L,g),g=n.add(E,E),E=n.add(g,E),E=n.add(E,D),E=n.mul(E,L),b=n.add(b,E),D=n.mul(S,T),D=n.add(D,D),E=n.mul(D,L),O=n.sub(O,E),g=n.mul(D,v),g=n.add(g,g),g=n.add(g,g),new _(O,b,g)}add(m){Q(m);let{X:S,Y:T,Z:O}=this,{X:b,Y:g,Z:E}=m,v=n.ZERO,D=n.ZERO,L=n.ZERO,M=n.mul(S,b),R=n.mul(T,g),Y=n.mul(O,E),he=n.add(S,T),$=n.add(b,g);he=n.mul(he,$),$=n.add(M,R),he=n.sub(he,$),$=n.add(S,O);let oe=n.add(b,E);return $=n.mul($,oe),oe=n.add(M,Y),$=n.sub($,oe),oe=n.add(T,O),v=n.add(g,E),oe=n.mul(oe,v),v=n.add(R,Y),oe=n.sub(oe,v),L=C($),v=n.mul(x,Y),L=n.add(v,L),v=n.sub(R,L),L=n.add(R,L),D=n.mul(v,L),R=n.add(M,M),R=n.add(R,M),Y=C(Y),$=n.mul(x,$),R=n.add(R,Y),Y=n.sub(M,Y),Y=C(Y),$=n.add($,Y),M=n.mul(R,$),D=n.add(D,M),M=n.mul(oe,$),v=n.mul(he,v),v=n.sub(v,M),M=n.mul(he,R),L=n.mul(oe,L),L=n.add(L,M),new _(v,D,L)}subtract(m){return Q(m),this.add(m.negate())}is0(){return this.equals(_.ZERO)}multiply(m){if(!o.isValidNot0(m))throw new RangeError("invalid scalar: out of range");let{p:S,f:T}=Ze.mulSecret(this,m,s,rr);return rr([S,T])[0]}multiplyUnsafe(m){let S=this,T=m;if(!o.isValid(T))throw new RangeError("invalid scalar: out of range");if(T===lt||S.is0())return _.ZERO;if(T===Ut)return S;if(Ze.hasWindowSize(this))return Ze.mulUnsafe(S,T,rr);let O=[],b=[];return K(O,b,S,T),on(_,O,b)}mulAddUnsafe(m,S,T){Q(S);let O=[],b=[];return K(O,b,this,m),K(O,b,S,T),on(_,O,b)}toAffine(m){let S=this,T=m;if(T!=null&&!n.isValid(T))throw new RangeError('"invertedZ" expected valid field element');let{X:O,Y:b,Z:g}=S;if(n.eql(g,n.ONE))return{x:O,y:b};let E=S.is0();T==null&&(T=E?n.ONE:n.inv(g));let v=n.mul(O,T),D=n.mul(b,T),L=n.mul(g,T);if(E)return{x:n.ZERO,y:n.ZERO};if(!n.eql(L,n.ONE))throw new Error("invZ was invalid");return{x:v,y:D}}isTorsionFree(){let{isTorsionFree:m}=e;return s===Ut?!0:m?m(_,this):Ze.mulUnsafe(this,c).is0()}clearCofactor(){let{clearCofactor:m}=e;return s===Ut?this:m?m(_,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Ut?this.is0():this.clearCofactor().is0()}toBytes(m=!0){return Ye(m,"isCompressed"),this.assertValidity(),w(_,this,m)}toHex(m=!0){return vo(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let rr=P=>nc(_,P),Ze=new nn(_,l);return Ze.bits>=6&&_.BASE.precompute(6),Object.freeze(_.prototype),Object.freeze(_),_}function vc(t){return Uint8Array.of(t?2:3)}function Bc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Qd(t,e={}){Zt(t);let{Fn:r}=t,n=e.randomBytes===void 0?Zr:e.randomBytes,o=Object.assign(Bc(t.Fp,r),{seed:Math.max(tn(r.ORDER),16)});function i(h){try{let p=r.fromBytes(h);return r.isValidNot0(p)}catch{return!1}}function s(h,p){let{publicKey:w,publicKeyUncompressed:I}=o;try{let x=h.length;return p===!0&&x!==w||p===!1&&x!==I?!1:!!t.fromBytes(h)}catch{return!1}}function c(h){return h=h===void 0?n(o.seed):h,rn(X(h,o.seed,"seed"),r.ORDER)}function a(h,p=!0){return t.BASE.multiply(r.fromBytes(h)).toBytes(p)}function u(h){let{secretKey:p,publicKey:w,publicKeyUncompressed:I}=o,x=r._lengths;if(!jt(h))return;let C=X(h,void 0,"key").length,q=C===w||C===I,F=C===p||!!x?.includes(C);if(!(q&&F))return q}function l(h,p,w=!0){if(u(h)===!0)throw new Error("first arg must be private key");if(u(p)===!1)throw new Error("second arg must be public key");let I=r.fromBytes(h);return t.fromBytes(p).multiply(I).toBytes(w)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},f=cc(c,a);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:l,keygen:f,Point:t,utils:d,lengths:o})}function Ac(t,e,r={}){Zt(t);let n=e;zr(n),St(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},r),i=o.randomBytes===void 0?Zr:o.randomBytes,s=o.hmac===void 0?(b,g)=>xc(n,b,g):o.hmac,{Fp:c,Fn:a}=t,{ORDER:u,BITS:l}=a,d=tn(u),f=No(i,d),{keygen:h,getPublicKey:p,getSharedSecret:w,utils:I,lengths:x}=Qd(t,o),C={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},q=u*Ic+Ut<c.ORDER;function F(b){let g=u>>Ut;return b>g}function H(b,g){if(!a.isValidNot0(g))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return g}function k(){if(!c.isOdd)throw new Error("Field doesn't support isOdd")}function W(b,g,E){return k(),(b===E?0:2)|Number(c.isOdd(g))}function Q(){if(q)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function ge(b,g){ci(g);let E=x.signature,v=g==="compact"?E:g==="recovered"?E+1:void 0;return X(b,v)}class K{r;s;recovery;constructor(g,E,v){if(this.r=H("r",g),this.s=H("s",E),v!=null){if(Q(),![0,1,2,3].includes(v))throw new Error("invalid recovery id");this.recovery=v}Object.freeze(this)}static fromBytes(g,E=C.format){ge(g,E);let v;if(E==="der"){let{r:R,s:Y}=oi.toSig(X(g));return new K(R,Y)}E==="recovered"&&(v=g[0],E="compact",g=g.subarray(1));let D=x.signature/2,L=g.subarray(0,D),M=g.subarray(D,D*2);return new K(a.fromBytes(L),a.fromBytes(M),v)}static fromHex(g,E){return this.fromBytes(Xr(g),E)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new K(this.r,this.s,g)}recoverPublicKey(g){let{r:E,s:v}=this,D=this.assertRecovery(),L=D===2||D===3?E+u:E;if(!c.isValid(L))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let M=c.toBytes(L),R=t.fromBytes(ut(vc((D&1)===0),M)),Y=a.inv(L),he=_(X(g,void 0,"msgHash")),$=a.create(-he*Y),oe=a.create(v*Y),Ne=t.BASE.mulAddUnsafe($,R,oe);if(Ne.is0())throw new Error("invalid recovery: point at infinify");return Ne.assertValidity(),Ne}hasHighS(){return F(this.s)}toBytes(g=C.format){if(ci(g),g==="der")return Xr(oi.hexFromSig(this));let{r:E,s:v}=this,D=a.toBytes(E),L=a.toBytes(v);return g==="recovered"?(Q(),ut(Uint8Array.of(this.assertRecovery()),D,L)):ut(D,L)}toHex(g){return vo(this.toBytes(g))}}Object.freeze(K.prototype),Object.freeze(K);let ce=o.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let E=Ge(g),v=g.length*8-l;return v>0?E>>BigInt(v):E}:o.bits2int,_=o.bits2int_modN===void 0?function(g){return a.create(ce(g))}:o.bits2int_modN,rr=wr(l);function Ze(b){return To("num < 2^"+l,b,lt,rr),a.toBytes(b)}function P(b,g){return X(b,void 0,"message"),g?X(n(b),void 0,"prehashed message"):b}function m(b,g,E){let{lowS:v,prehash:D,extraEntropy:L}=ii(E,C);b=P(b,D);let M=_(b),R=a.fromBytes(g);if(!a.isValidNot0(R))throw new Error("invalid private key");let Y=[Ze(R),Ze(M)];if(L!=null&&L!==!1){let Ne=L===!0?i(x.secretKey):L;Y.push(X(Ne,void 0,"extraEntropy"))}let he=ut(...Y),$=M;function oe(Ne){let Rt=ce(Ne);if(!a.isValidNot0(Rt))return;let nr=t.BASE.multiply(Rt).toAffine(),ft=a.create(nr.x);if(ft===lt)return;let Fe;if(f!==void 0){let or=Ge(rn(f(d),u)),da=a.inv(a.mul(or,Rt)),la=a.mul(or,$),ha=a.mul(or,R);Fe=a.create(da*a.create(la+ha*ft))}else{let or=Xs(Rt,u);Fe=a.create(or*a.create($+ft*R))}if(Fe===lt)return;let Cn=W(nr.x,nr.y,ft),vi=Fe;return v&&F(Fe)&&(vi=a.neg(Fe),Cn^=1),new K(ft,vi,q?void 0:Cn)}return{seed:he,k2sig:oe}}function S(b,g,E={}){let{seed:v,k2sig:D}=m(b,g,E);return Hs(n.outputLen,a.BYTES,s)(v,D).toBytes(E.format)}function T(b,g,E,v={}){let{lowS:D,prehash:L,format:M}=ii(v,C);if(E=X(E,void 0,"publicKey"),g=P(g,L),!jt(b)){let R=b instanceof K?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+R)}ge(b,M);try{let R=K.fromBytes(b,M),Y=t.fromBytes(E);if(D&&R.hasHighS())return!1;let{r:he,s:$}=R,oe=_(g),Ne=a.inv($),Rt=a.create(oe*Ne),nr=a.create(he*Ne),ft=t.BASE.mulAddUnsafe(Rt,Y,nr);if(ft.is0())return!1;let Fe=ft.toAffine();return!(a.create(Fe.x)!==he||M==="recovered"&&R.recovery!==W(Fe.x,Fe.y,he))}catch{return!1}}function O(b,g,E={}){let{prehash:v}=ii(E,C);return g=P(g,v),K.fromBytes(b,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:h,getPublicKey:p,getSharedSecret:w,utils:I,lengths:x,Point:t,sign:S,verify:T,recoverPublicKey:O,Signature:K,hash:n})}var ui={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Jd={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Cc=BigInt(2);function el(t){let e=ui.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),c=BigInt(44),a=BigInt(88),u=t*t*t%e,l=u*u*t%e,d=ve(l,r,e)*l%e,f=ve(d,r,e)*l%e,h=ve(f,Cc,e)*u%e,p=ve(h,o,e)*h%e,w=ve(p,i,e)*p%e,I=ve(w,c,e)*w%e,x=ve(I,a,e)*I%e,C=ve(x,c,e)*w%e,q=ve(C,r,e)*l%e,F=ve(q,s,e)*p%e,H=ve(F,n,e)*u%e,k=ve(H,Cc,e);if(!ai.eql(ai.sqr(k),t))throw new Error("Cannot find square root");return k}var ai=Xt(ui.p,{sqrt:el}),tl=Sc(ui,{Fp:ai,endo:Jd}),Ar=Ac(tl,Fs);var yn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Lc(t,e,r,n){n?.signal?.throwIfAborted();let o=Tc.default.createHash("sha256");if(r instanceof Uint8Array)o.update(r);else for(let s of r)o.update(s);let i=o.digest();try{return Ar.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new yn(String(s))}}var wn=class{type="secp256k1";raw;_key;constructor(e){this._key=Dc(e),this.raw=Oc(this._key)}toMultihash(){return Ue.digest($t(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:fe(this.raw,e.raw)}verify(e,r,n){return Lc(this._key,r,e,n)}};function Uc(t){return new wn(t)}function Oc(t){return Ar.Point.fromBytes(t).toBytes()}function Dc(t){try{return Ar.Point.fromBytes(t),t}catch(e){throw new Ur(String(e))}}function _c(t){let{Type:e,Data:r}=Br.decode(t.digest),n=r??new Uint8Array;switch(e){case le.Ed25519:return lc(n);case le.secp256k1:return Uc(n);case le.ECDSA:return Ss(n);default:throw new sr}}function $t(t){return Br.encode({Type:le[t.type],Data:t.raw})}var Pc=Symbol.for("nodejs.util.inspect.custom"),rl=114,Cr=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()})`}[Tn]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return re.createV1(rl,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return fe(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return fe(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Pc](){return`PeerId(${this.toString()})`}},bn=class extends Cr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},xn=class extends Cr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},En=class extends Cr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},nl=2336,Tr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ue.digest(de(this.url))}[Pc](){return`PeerId(${this.url})`}[Tn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return re.createV1(nl,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=j(e)),e.toString()===this.toString())}};var ol=114,Rc=2336;function Nc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=lr(G.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return il(re.parse(t));if(e==null)throw new Te('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=lr(e.decode(t))}return Fc(r)}function Fc(t){if(cl(t))return new bn({multihash:t});if(sl(t))try{let e=_c(t);if(e.type==="Ed25519")return new xn({multihash:t,publicKey:e});if(e.type==="secp256k1")return new En({multihash:t,publicKey:e})}catch{let r=j(t.digest);return new Tr(new URL(r))}throw new Pr("Supplied PeerID Multihash is invalid")}function il(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==ol&&t.code!==Rc)throw new _r("Supplied PeerID CID is invalid");if(t.code===Rc){let e=j(t.multihash.digest);return new Tr(new URL(e))}return Fc(t.multihash)}function sl(t){return t.code===Ue.code}function cl(t){return t.code===uo.code}function al(t){let e=t.getComponents(),r={},n=0;return e[n]?.name==="ip6zone"&&(r.zone=`${e[n].value}`,n++),e[n]?.name==="ip4"||e[n]?.name==="ip6"||e[n]?.name==="dns"||e[n]?.name==="dns4"||e[n]?.name==="dns6"?(r.type=e[n].name,r.host=e[n].value,n++):e[n]?.name==="dnsaddr"&&(r.type=e[n].name,r.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(r.protocol=e[n].name==="tcp"?"tcp":"udp",r.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(r.type==="ip4"?r.cidr=parseInt(`${e[n].value}`):r.type==="ip6"&&(r.cidr=`${e[n].value}`),n++),r.type==null||r.host==null?null:(e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(r.sni=e[n+1].value,n+=2),r)}function kc(t){let e=al(t);if(e==null)throw new Te(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Ae=me("node:net");var qc=ir(Hc(),1),gl=["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"],ml=gl.map(t=>new qc.Netmask(t));function mi(t){for(let e of ml)if(e.contains(t))return!0;return!1}function yl(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function wl(t){let e=t.split(":");if(e.length<2)return!1;let r=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}`;return mi(o)}function bl(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function xl(t){let e=t.split(":"),r=e[e.length-1];return mi(r)}function El(t){return/^::$/.test(t)||/^::1$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}function zc(t){if((0,Ae.isIPv4)(t))return mi(t);if(yl(t))return wl(t);if(bl(t))return xl(t);if((0,Ae.isIPv6)(t))return El(t)}function $c(t){try{let e=kc(t);switch(e.type){case"ip4":case"ip6":return zc(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var ne=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ht=class extends Error{static name="ValidationError";name="ValidationError"},Sn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},vn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function wi(t){return e=>j(e,t)}function bi(t){return e=>de(e,t)}function tr(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function Pt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function Vc(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=de(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Pt(n);return _e([r,o],r.length+o.length)}function jc(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=yt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Pt(n);return _e([r,o],r.length+o.length)}function xi(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=j(e,"base32"),o=tr(r);return`${n}:${o}`}var Ei=function(t){t=t.toString().trim();let e=new Uint8Array(4);return t.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new ne("Invalid byte value in IP address");e[n]=o}),e},Yc=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,Ae.isIPv4)(r[n]),s;i&&(s=Ei(r[n]),r[n]=j(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,j(s.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new ne("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},Gc=function(t){if(t.byteLength!==4)throw new ne("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},Wc=function(t){if(t.byteLength!==16)throw new ne("IPv6 address was incorrect length");let e=[];for(let n=0;n<t.byteLength;n+=2){let o=t[n],i=t[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let r=e.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new ne(`Invalid IPv6 address "${r}"`)}};function Xc(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new ne(`Invalid IPv6 address "${t}"`)}}var yi=Object.values(pr).map(t=>t.decoder),Il=(function(){let t=yi[0].or(yi[1]);return yi.slice(2).forEach(e=>t=t.or(e)),t})();function Zc(t){return Il.decode(t)}function Qc(t){return e=>t.encoder.encode(e)}function Sl(t){if(parseInt(t).toString()!==t)throw new ht("Value must be an integer")}function vl(t){if(t<0)throw new ht("Value must be a positive integer, or zero")}function Bl(t){return e=>{if(e>t)throw new ht(`Value must be smaller than or equal to ${t}`)}}function Al(...t){return e=>{for(let r of t)r(e)}}var Lr=Al(Sl,vl,Bl(65535));var ee=-1,Ii=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let r;if(typeof e=="string"?r=this.protocolsByName.get(e):r=this.protocolsByCode.get(e),r==null)throw new vn(`Protocol ${e} was unknown`);return r}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(r=>{this.protocolsByName.set(r,e)})}removeProtocol(e){let r=this.protocolsByCode.get(e);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},pt=new Ii,hh=[{code:4,name:"ip4",size:32,valueToBytes:Ei,bytesToValue:Gc,validate:t=>{if(!(0,Ae.isIPv4)(t))throw new ht(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Lr},{code:273,name:"udp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Lr},{code:33,name:"dccp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Lr},{code:41,name:"ip6",size:128,valueToBytes:Yc,bytesToValue:Wc,stringToValue:Xc,validate:t=>{if(!(0,Ae.isIPv6)(t))throw new ht(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:ee},{code:43,name:"ipcidr",size:8,bytesToValue:wi("base10"),valueToBytes:bi("base10")},{code:53,name:"dns",size:ee},{code:54,name:"dns4",size:ee},{code:55,name:"dns6",size:ee},{code:56,name:"dnsaddr",size:ee},{code:132,name:"sctp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Lr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ee,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:ee,bytesToValue:wi("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?bi("base58btc")(t):re.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:xi,valueToBytes:Vc},{code:445,name:"onion3",size:296,bytesToValue:xi,valueToBytes:jc},{code:446,name:"garlic64",size:ee},{code:447,name:"garlic32",size:ee},{code:448,name:"tls"},{code:449,name:"sni",size:ee},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ee,bytesToValue:Qc(ro),valueToBytes:Zc},{code:480,name:"http"},{code:481,name:"http-path",size:ee,stringToValue:t=>`/${decodeURIComponent(t)}`,valueToString:t=>encodeURIComponent(t.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ee}];hh.forEach(t=>{pt.addProtocol(t)});function Jc(t){let e=[],r=0;for(;r<t.length;){let n=zo(t,r),o=pt.getProtocol(n),i=We(n),s=ph(o,t,r+i),c=0;s>0&&o.size===ee&&(c=We(s));let a=i+c+s,u={code:n,name:o.name,bytes:wt(t.subarray(r,r+a))};if(s>0){let l=r+i+c,d=t.subarray(l,l+s);u.value=o.bytesToValue?.(d)??j(d)}e.push(u),r+=a}return e}function ea(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=pt.getProtocol(n.code),i=We(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??de(n.value),c=s.byteLength,o.size===ee&&(a=We(c)));let u=new Uint8Array(i+a+c),l=0;Er(n.code,u,l),l+=i,s!=null&&(o.size===ee&&(Er(c,u,l),l+=a),u.set(s,l)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return _e(r,e)}function ta(t){if(t.charAt(0)!=="/")throw new ne('String multiaddr must start with "/"');let e=[],r="protocol",n="",o="";for(let i=1;i<t.length;i++){let s=t.charAt(i);s!=="/"&&(r==="protocol"?o+=t.charAt(i):n+=t.charAt(i));let c=i===t.length-1;if(s==="/"||c){let a=pt.getProtocol(o);if(r==="protocol"){if(a.size==null||a.size===0){e.push({code:a.code,name:a.name}),n="",o="",r="protocol";continue}else if(c)throw new ne(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:a.code,name:a.name};if(a.size!=null&&a.size!==0){if(n==="")throw new ne(`Component ${o} was missing value`);u.value=a.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ne("Incomplete multiaddr");return e}function ra(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=pt.getProtocol(e.code);if(r==null)throw new ne(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function ph(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:zo(e,r)}var fh=Symbol.for("nodejs.util.inspect.custom"),Si=Symbol.for("@multiformats/multiaddr");function gh(t){if(t==null&&(t="/"),na(t))return t.getComponents();if(t instanceof Uint8Array)return Jc(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),ta(t);if(Array.isArray(t))return t;throw new ne("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Bn=class t{[Si]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=gh(e),r.validate!==!1&&mh(this)}get bytes(){return this.#r==null&&(this.#r=ea(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=ra(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Sn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}equals(e){return fe(this.bytes,e.bytes)}[fh](){return`Multiaddr(${this.toString()})`}};function mh(t){t.getComponents().forEach(e=>{let r=pt.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function na(t){return!!t?.[Si]}function oa(t){return new Bn(t)}function ia(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function sa(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{s.type==="TXT"&&i.push(s)}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(a=>a.data).filter(a=>a.toString().startsWith("dnsaddr=")).map(a=>oa(a.toString().substring(8))),c=s[0].getComponents().findLast(a=>a.code===421)?.value;if(c==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",c),{id:Nc(c),multiaddrs:s.map(a=>a.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response - %e",s)}}function ca(t,e,r,n,o,i,s){if(!i){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===o){let c=[];c.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(yh).forEach(a=>{let u="dnsaddr="+a.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",a);return}if(a.getComponents().findLast(l=>l.code===421)?.value==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",a);return}c.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(c)}}function yh(t){return!!$c(t)}function aa(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var An=class extends Rr{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,r={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=r.broadcast!==!1,this.interval=r.interval??1e3*10,this.serviceTag=r.serviceTag??"_p2p._udp.local",this.ip=r.ip??"224.0.0.251",this.peerName=r.peerName??aa(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=r.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[Ai]=this;[Symbol.toStringTag]="@libp2p/mdns";[Li]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,ua.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=ia(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),ca(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let r=sa(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new CustomEvent("peer",{detail:r})))}catch(r){this.log.error("error processing peer response - %e",r)}}_onMdnsWarning(e){this.log.error("mdns warning - %e",e)}_onMdnsError(e){this.log.error("mdns error - %e",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function bh(t={}){return e=>new An(e,t)}return wa(xh);})();
|
|
2
|
+
"use strict";var Libp2PMdns=(()=>{var ga=Object.create;var Dr=Object.defineProperty;var ma=Object.getOwnPropertyDescriptor;var ya=Object.getOwnPropertyNames;var wa=Object.getPrototypeOf,ba=Object.prototype.hasOwnProperty;var me=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Ce=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},ye=(t,e)=>{for(var r in e)Dr(t,r,{get:e[r],enumerable:!0})},Ai=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of ya(e))!ba.call(t,o)&&o!==r&&Dr(t,o,{get:()=>e[o],enumerable:!(n=ma(e,o))||n.enumerable});return t};var ir=(t,e,r)=>(r=t!=null?ga(wa(t)):{},Ai(e||!t||!t.__esModule?Dr(r,"default",{value:t,enumerable:!0}):r,t)),xa=t=>Ai(Dr({},"__esModule",{value:!0}),t);var Ui=Ce(On=>{"use strict";On.toString=function(t){switch(t){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+t};On.toType=function(t){switch(t.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return t.toUpperCase().startsWith("UNKNOWN_")?parseInt(t.slice(8)):0}});var _i=Ce(Dn=>{"use strict";Dn.toString=function(t){switch(t){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+t};Dn.toRcode=function(t){switch(t.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var Pi=Ce(Un=>{"use strict";Un.toString=function(t){switch(t){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+t};Un.toOpcode=function(t){switch(t.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var Ri=Ce(_n=>{"use strict";_n.toString=function(t){switch(t){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+t};_n.toClass=function(t){switch(t.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var Ni=Ce(Pn=>{"use strict";Pn.toString=function(t){switch(t){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return t<0?null:`OPTION_${t}`};Pn.toCode=function(t){if(typeof t=="number")return t;if(!t)return-1;switch(t.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let e=t.match(/_(\d+)$/);return e?parseInt(e[1],10):-1}});var Ki=Ce((ki,Rn)=>{var Fi=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=d,t.encode=l,t.familyOf=u,t.name=void 0,t.sizeOf=c,t.v6=t.v4=void 0;let e=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,o=16,i={name:"v4",size:r,isFormat:f=>e.test(f),encode(f,h,p){p=~~p,h=h||new Uint8Array(p+r);let w=f.length,I=0;for(let x=0;x<w;){let C=f.charCodeAt(x++);C===46?(h[p++]=I,I=0):I=I*10+(C-48)}return h[p]=I,h},decode(f,h){return h=~~h,`${f[h++]}.${f[h++]}.${f[h++]}.${f[h]}`}};t.v4=i;let s={name:"v6",size:o,isFormat:f=>f.length>0&&n.test(f),encode(f,h,p){p=~~p;let w=p+o,I=-1,x=0,C=0,q=!0,F=!1;h=h||new Uint8Array(p+o);for(let H=0;H<f.length;H++){let k=f.charCodeAt(H);k===58?(q?I!==-1?(p<w&&(h[p]=0),p<w-1&&(h[p+1]=0),p+=2):p<w&&(I=p):(F===!0?(p<w&&(h[p]=C),p++):(p<w&&(h[p]=x>>8),p<w-1&&(h[p+1]=x&255),p+=2),x=0,C=0),q=!0,F=!1):k===46?(p<w&&(h[p]=C),p++,C=0,x=0,q=!1,F=!0):(q=!1,k>=97?k-=87:k>=65?k-=55:(k-=48,C=C*10+k),x=(x<<4)+k)}if(q===!1)F===!0?(p<w&&(h[p]=C),p++):(p<w&&(h[p]=x>>8),p<w-1&&(h[p+1]=x&255),p+=2);else if(I===0)p<w&&(h[p]=0),p<w-1&&(h[p+1]=0),p+=2;else if(I!==-1){p+=2;for(let H=Math.min(p-1,w-1);H>=I+2;H--)h[H]=h[H-2];h[I]=0,h[I+1]=0,I=p}if(I!==p&&I!==-1)for(p>w-2&&(p=w-2);w>I;)h[--w]=p<w&&p>I?h[--p]:0;else for(;p<w;)h[p++]=0;return h},decode(f,h){h=~~h;let p="";for(let w=0;w<o;w+=2)w!==0&&(p+=":"),p+=(f[h+w]<<8|f[h+w+1]).toString(16);return p.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};t.v6=s;let a="ip";t.name=a;function c(f){if(i.isFormat(f))return i.size;if(s.isFormat(f))return s.size;throw Error(`Invalid ip address: ${f}`)}function u(f){return c(f)===i.size?1:2}function l(f,h,p){p=~~p;let w=c(f);return typeof h=="function"&&(h=h(p+w)),w===i.size?i.encode(f,h,p):s.encode(f,h,p)}function d(f,h,p){if(h=~~h,p=p||f.length-h,p===i.size)return i.decode(f,h,p);if(p===s.size)return s.decode(f,h,p);throw Error(`Invalid buffer size needs to be ${i.size} for v4 or ${s.size} for v6.`)}return"default"in t?t.default:t})({});typeof define=="function"&&define.amd?define([],function(){return Fi}):typeof Rn=="object"&&typeof ki=="object"&&(Rn.exports=Fi)});var qi=Ce(B=>{"use strict";var A=me("buffer").Buffer,ct=Ui(),va=_i(),Ba=Pi(),Fr=Ri(),Nn=Ni(),Ct=Ki(),Aa=0,Mi=32768,Fn=32768,Ca=~Fn,Hi=32768,La=~Hi,y=B.name={};y.encode=function(t,e,r,{mail:n=!1}={}){e||(e=A.alloc(y.encodingLength(t))),r||(r=0);let o=r,i=t.replace(/^\.|\.$/gm,"");if(i.length){let s=[];if(n){let a="";i.split(".").forEach(c=>{c.endsWith("\\")?a+=(a.length?".":"")+c.slice(0,-1):s.length===0&&a.length?s.push(a+"."+c):s.push(c)})}else s=i.split(".");for(let a=0;a<s.length;a++){let c=e.write(s[a],r+1);e[r]=c,r+=c+1}}return e[r++]=0,y.encode.bytes=r-o,e};y.encode.bytes=0;y.decode=function(t,e,{mail:r=!1}={}){e||(e=0);let n=[],o=e,i=0,s=0,a=!1;for(;;){if(e>=t.length)throw new Error("Cannot decode name (buffer overflow)");let c=t[e++];if(s+=a?0:1,c===0)break;if((c&192)===0){if(e+c>t.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=c+1,i>254)throw new Error("Cannot decode name (name too long)");let u=t.toString("utf-8",e,e+c);r&&(u=u.replace(/\./g,"\\.")),n.push(u),e+=c,s+=a?0:c}else if((c&192)===192){if(e+1>t.length)throw new Error("Cannot decode name (buffer overflow)");let u=t.readUInt16BE(e-1)-49152;if(u>=o)throw new Error("Cannot decode name (bad pointer)");e=u,o=u,s+=a?0:1,a=!0}else throw new Error("Cannot decode name (bad label)")}return y.decode.bytes=s,n.length===0?".":n.join(".")};y.decode.bytes=0;y.encodingLength=function(t){return t==="."||t===".."?1:A.byteLength(t.replace(/^\.|\.$/gm,""))+2};var U={};U.encode=function(t,e,r){e||(e=A.alloc(U.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,U.encode.bytes=n+1,e};U.encode.bytes=0;U.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return U.decode.bytes=r+1,n};U.decode.bytes=0;U.encodingLength=function(t){return A.byteLength(t)+1};var De={};De.encode=function(t,e,r){e||(e=De.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Mi:Aa;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|o,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};De.encode.bytes=12;De.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&Mi?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Ba.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:va.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};De.decode.bytes=12;De.encodingLength=function(){return 12};var Qe=B.unknown={};Qe.encode=function(t,e,r){return e||(e=A.alloc(Qe.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),Qe.encode.bytes=t.length+2,e};Qe.encode.bytes=0;Qe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return Qe.decode.bytes=r+2,n};Qe.decode.bytes=0;Qe.encodingLength=function(t){return t.length+2};var Je=B.ns={};Je.encode=function(t,e,r){return e||(e=A.alloc(Je.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Je.encode.bytes=y.encode.bytes+2,e};Je.encode.bytes=0;Je.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=y.decode(t,e+2);return Je.decode.bytes=r+2,n};Je.decode.bytes=0;Je.encodingLength=function(t){return y.encodingLength(t)+2};var et=B.soa={};et.encode=function(t,e,r){e||(e=A.alloc(et.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mname,e,r),r+=y.encode.bytes,y.encode(t.rname,e,r,{mail:!0}),r+=y.encode.bytes,e.writeUInt32BE(t.serial||0,r),r+=4,e.writeUInt32BE(t.refresh||0,r),r+=4,e.writeUInt32BE(t.retry||0,r),r+=4,e.writeUInt32BE(t.expire||0,r),r+=4,e.writeUInt32BE(t.minimum||0,r),r+=4,e.writeUInt16BE(r-n-2,n),et.encode.bytes=r-n,e};et.encode.bytes=0;et.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=y.decode(t,e),e+=y.decode.bytes,n.rname=y.decode(t,e,{mail:!0}),e+=y.decode.bytes,n.serial=t.readUInt32BE(e),e+=4,n.refresh=t.readUInt32BE(e),e+=4,n.retry=t.readUInt32BE(e),e+=4,n.expire=t.readUInt32BE(e),e+=4,n.minimum=t.readUInt32BE(e),e+=4,et.decode.bytes=e-r,n};et.decode.bytes=0;et.encodingLength=function(t){return 22+y.encodingLength(t.mname)+y.encodingLength(t.rname)};var tt=B.txt={};tt.encode=function(t,e,r){Array.isArray(t)||(t=[t]);for(let o=0;o<t.length;o++)if(typeof t[o]=="string"&&(t[o]=A.from(t[o])),!A.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=A.alloc(tt.encodingLength(t))),r||(r=0);let n=r;return r+=2,t.forEach(function(o){e[r++]=o.length,o.copy(e,r,0,o.length),r+=o.length}),e.writeUInt16BE(r-n-2,n),tt.encode.bytes=r-n,e};tt.encode.bytes=0;tt.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=[];for(;n>0;){let i=t[e++];if(--n,n<i)throw new Error("Buffer overflow");o.push(t.slice(e,e+i)),e+=i,n-=i}return tt.decode.bytes=e-r,o};tt.decode.bytes=0;tt.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=A.byteLength(r)+1:e+=r.length+1}),e};var rt=B.null={};rt.encode=function(t,e,r){e||(e=A.alloc(rt.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=A.from(t)),t||(t=A.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),rt.encode.bytes=r-n,e};rt.encode.bytes=0;rt.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,rt.decode.bytes=e-r,o};rt.decode.bytes=0;rt.encodingLength=function(t){return t?(A.isBuffer(t)?t.length:A.byteLength(t))+2:2};var nt=B.hinfo={};nt.encode=function(t,e,r){e||(e=A.alloc(nt.encodingLength(t))),r||(r=0);let n=r;return r+=2,U.encode(t.cpu,e,r),r+=U.encode.bytes,U.encode(t.os,e,r),r+=U.encode.bytes,e.writeUInt16BE(r-n-2,n),nt.encode.bytes=r-n,e};nt.encode.bytes=0;nt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=U.decode(t,e),e+=U.decode.bytes,n.os=U.decode(t,e),e+=U.decode.bytes,nt.decode.bytes=e-r,n};nt.decode.bytes=0;nt.encodingLength=function(t){return U.encodingLength(t.cpu)+U.encodingLength(t.os)+2};var Te=B.ptr={},Ta=B.cname=Te,Oa=B.dname=Te;Te.encode=function(t,e,r){return e||(e=A.alloc(Te.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Te.encode.bytes=y.encode.bytes+2,e};Te.encode.bytes=0;Te.decode=function(t,e){e||(e=0);let r=y.decode(t,e+2);return Te.decode.bytes=y.decode.bytes+2,r};Te.decode.bytes=0;Te.encodingLength=function(t){return y.encodingLength(t)+2};var ot=B.srv={};ot.encode=function(t,e,r){e||(e=A.alloc(ot.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.priority||0,r+2),e.writeUInt16BE(t.weight||0,r+4),e.writeUInt16BE(t.port||0,r+6),y.encode(t.target,e,r+8);let n=y.encode.bytes+6;return e.writeUInt16BE(n,r),ot.encode.bytes=n+2,e};ot.encode.bytes=0;ot.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n={};return n.priority=t.readUInt16BE(e+2),n.weight=t.readUInt16BE(e+4),n.port=t.readUInt16BE(e+6),n.target=y.decode(t,e+8),ot.decode.bytes=r+2,n};ot.decode.bytes=0;ot.encodingLength=function(t){return 8+y.encodingLength(t.target)};var we=B.caa={};we.ISSUER_CRITICAL=128;we.encode=function(t,e,r){let n=we.encodingLength(t);return e||(e=A.alloc(we.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=we.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,U.encode(t.tag,e,r),r+=U.encode.bytes,e.write(t.value,r),r+=A.byteLength(t.value),we.encode.bytes=n,e};we.encode.bytes=0;we.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=U.decode(t,e),e+=U.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&we.ISSUER_CRITICAL),we.decode.bytes=r+2,o};we.decode.bytes=0;we.encodingLength=function(t){return U.encodingLength(t.tag)+U.encodingLength(t.value)+2};var gt=B.mx={};gt.encode=function(t,e,r){e||(e=A.alloc(gt.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,y.encode(t.exchange,e,r),r+=y.encode.bytes,e.writeUInt16BE(r-n-2,n),gt.encode.bytes=r-n,e};gt.encode.bytes=0;gt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=y.decode(t,e),e+=y.decode.bytes,gt.decode.bytes=e-r,n};gt.encodingLength=function(t){return 4+y.encodingLength(t.exchange)};var it=B.a={};it.encode=function(t,e,r){return e||(e=A.alloc(it.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,Ct.v4.encode(t,e,r),it.encode.bytes=6,e};it.encode.bytes=0;it.decode=function(t,e){e||(e=0),e+=2;let r=Ct.v4.decode(t,e);return it.decode.bytes=6,r};it.decode.bytes=0;it.encodingLength=function(){return 6};var st=B.aaaa={};st.encode=function(t,e,r){return e||(e=A.alloc(st.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,Ct.v6.encode(t,e,r),st.encode.bytes=18,e};st.encode.bytes=0;st.decode=function(t,e){e||(e=0),e+=2;let r=Ct.v6.decode(t,e);return st.decode.bytes=18,r};st.decode.bytes=0;st.encodingLength=function(){return 18};var pe=B.option={};pe.encode=function(t,e,r){e||(e=A.alloc(pe.encodingLength(t))),r||(r=0);let n=r,o=Nn.toCode(t.code);if(e.writeUInt16BE(o,r),r+=2,t.data)e.writeUInt16BE(t.data.length,r),r+=2,t.data.copy(e,r),r+=t.data.length;else switch(o){case 8:let i=t.sourcePrefixLength||0,s=t.family||Ct.familyOf(t.ip),a=Ct.encode(t.ip,A.alloc),c=Math.ceil(i/8);e.writeUInt16BE(c+4,r),r+=2,e.writeUInt16BE(s,r),r+=2,e.writeUInt8(i,r++),e.writeUInt8(t.scopePrefixLength||0,r++),a.copy(e,r,0,c),r+=c;break;case 11:t.timeout?(e.writeUInt16BE(2,r),r+=2,e.writeUInt16BE(t.timeout,r),r+=2):(e.writeUInt16BE(0,r),r+=2);break;case 12:let u=t.length||0;e.writeUInt16BE(u,r),r+=2,e.fill(0,r,r+u),r+=u;break;case 14:let l=t.tags.length*2;e.writeUInt16BE(l,r),r+=2;for(let d of t.tags)e.writeUInt16BE(d,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return pe.encode.bytes=r-n,e};pe.encode.bytes=0;pe.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=Nn.toString(r.code),e+=2;let n=t.readUInt16BE(e);switch(e+=2,r.data=t.slice(e,e+n),r.code){case 8:r.family=t.readUInt16BE(e),e+=2,r.sourcePrefixLength=t.readUInt8(e++),r.scopePrefixLength=t.readUInt8(e++);let o=A.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=Ct.decode(o);break;case 11:n>0&&(r.timeout=t.readUInt16BE(e),e+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(t.readUInt16BE(e)),e+=2}return pe.decode.bytes=n+4,r};pe.decode.bytes=0;pe.encodingLength=function(t){if(t.data)return t.data.length+4;switch(Nn.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var xe=B.opt={};xe.encode=function(t,e,r){e||(e=A.alloc(xe.encodingLength(t))),r||(r=0);let n=r,o=Nt(t,pe);return e.writeUInt16BE(o,r),r=cr(t,pe,e,r+2),xe.encode.bytes=r-n,e};xe.encode.bytes=0;xe.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=pe.decode(t,e),e+=pe.decode.bytes,o-=pe.decode.bytes;return xe.decode.bytes=e-r,n};xe.decode.bytes=0;xe.encodingLength=function(t){return 2+Nt(t||[],pe)};var ae=B.dnskey={};ae.PROTOCOL_DNSSEC=3;ae.ZONE_KEY=128;ae.SECURE_ENTRYPOINT=32768;ae.encode=function(t,e,r){e||(e=A.alloc(ae.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!A.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(ae.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ae.encode.bytes=r-n,e.writeUInt16BE(ae.encode.bytes-2,n),e};ae.encode.bytes=0;ae.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);if(e+=2,n.flags=t.readUInt16BE(e),e+=2,t.readUInt8(e)!==ae.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return e+=1,n.algorithm=t.readUInt8(e),e+=1,n.key=t.slice(e,r+o+2),e+=n.key.length,ae.decode.bytes=e-r,n};ae.decode.bytes=0;ae.encodingLength=function(t){return 6+A.byteLength(t.key)};var ke=B.rrsig={};ke.encode=function(t,e,r){e||(e=A.alloc(ke.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!A.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(ct.toType(t.typeCovered),r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.labels,r),r+=1,e.writeUInt32BE(t.originalTTL,r),r+=4,e.writeUInt32BE(t.expiration,r),r+=4,e.writeUInt32BE(t.inception,r),r+=4,e.writeUInt16BE(t.keyTag,r),r+=2,y.encode(t.signersName,e,r),r+=y.encode.bytes,o.copy(e,r,0,o.length),r+=o.length,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=ct.toString(t.readUInt16BE(e)),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.labels=t.readUInt8(e),e+=1,n.originalTTL=t.readUInt32BE(e),e+=4,n.expiration=t.readUInt32BE(e),e+=4,n.inception=t.readUInt32BE(e),e+=4,n.keyTag=t.readUInt16BE(e),e+=2,n.signersName=y.decode(t,e),e+=y.decode.bytes,n.signature=t.slice(e,r+o+2),e+=n.signature.length,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 20+y.encodingLength(t.signersName)+A.byteLength(t.signature)};var Ke=B.rp={};Ke.encode=function(t,e,r){e||(e=A.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.mbox||".",e,r,{mail:!0}),r+=y.encode.bytes,y.encode(t.txt||".",e,r),r+=y.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=y.decode(t,e,{mail:!0})||".",e+=y.decode.bytes,n.txt=y.decode(t,e)||".",e+=y.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+y.encodingLength(t.mbox||".")+y.encodingLength(t.txt||".")};var J={};J.encode=function(t,e,r){e||(e=A.alloc(J.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=ct.toType(t[i]);o[s>>8]===void 0&&(o[s>>8]=[]),o[s>>8][s>>3&31]|=1<<7-(s&7)}for(i=0;i<o.length;i++)if(o[i]!==void 0){var a=A.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(a.length,r),r+=1,a.copy(e,r),r+=a.length}return J.encode.bytes=r-n,e};J.encode.bytes=0;J.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var s=t.readUInt8(e);e+=1;for(var a=0;a<s;a++)for(var c=t.readUInt8(e+a),u=0;u<8;u++)if(c&1<<7-u){var l=ct.toString(i<<8|a<<3|u);o.push(l)}e+=s}return J.decode.bytes=e-n,o};J.decode.bytes=0;J.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=ct.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Me=B.nsec={};Me.encode=function(t,e,r){e||(e=A.alloc(Me.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.nextDomain,e,r),r+=y.encode.bytes,J.encode(t.rrtypes,e,r),r+=J.encode.bytes,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=y.decode(t,e),e+=y.decode.bytes,n.rrtypes=J.decode(t,e,o-(e-r)),e+=J.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 2+y.encodingLength(t.nextDomain)+J.encodingLength(t.rrtypes)};var He=B.nsec3={};He.encode=function(t,e,r){e||(e=A.alloc(He.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!A.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!A.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,J.encode(t.rrtypes,e,r),r+=J.encode.bytes,He.encode.bytes=r-n,e.writeUInt16BE(He.encode.bytes-2,n),e};He.encode.bytes=0;He.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=J.decode(t,e,o-(e-r)),e+=J.decode.bytes,He.decode.bytes=e-r,n};He.decode.bytes=0;He.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+J.encodingLength(t.rrtypes)};var qe=B.ds={};qe.encode=function(t,e,r){e||(e=A.alloc(qe.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!A.isBuffer(o))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,qe.encode.bytes=r-n,e.writeUInt16BE(qe.encode.bytes-2,n),e};qe.encode.bytes=0;qe.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+o+2),e+=n.digest.length,qe.decode.bytes=e-r,n};qe.decode.bytes=0;qe.encodingLength=function(t){return 6+A.byteLength(t.digest)};var be=B.sshfp={};be.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};be.encode=function(e,r,n){r||(r=A.alloc(be.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=A.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==be.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,be.encode.bytes=n-o,r.writeUInt16BE(be.encode.bytes-2,o),r};be.encode.bytes=0;be.decode=function(e,r){r||(r=0);let n=r,o={};r+=2,o.algorithm=e[r],r+=1,o.hash=e[r],r+=1;let i=be.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,be.decode.bytes=r-n,o};be.decode.bytes=0;be.encodingLength=function(t){return 4+A.from(t.fingerprint,"hex").byteLength};var ze=B.naptr={};ze.encode=function(t,e,r){e||(e=A.alloc(ze.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,U.encode(t.flags,e,r),r+=U.encode.bytes,U.encode(t.services,e,r),r+=U.encode.bytes,U.encode(t.regexp,e,r),r+=U.encode.bytes,y.encode(t.replacement,e,r),r+=y.encode.bytes,ze.encode.bytes=r-n,e.writeUInt16BE(ze.encode.bytes-2,n),e};ze.encode.bytes=0;ze.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=U.decode(t,e),e+=U.decode.bytes,n.services=U.decode(t,e),e+=U.decode.bytes,n.regexp=U.decode(t,e),e+=U.decode.bytes,n.replacement=y.decode(t,e),e+=y.decode.bytes,ze.decode.bytes=e-r,n};ze.decode.bytes=0;ze.encodingLength=function(t){return U.encodingLength(t.flags)+U.encodingLength(t.services)+U.encodingLength(t.regexp)+y.encodingLength(t.replacement)+6};var $e=B.tlsa={};$e.encode=function(t,e,r){e||(e=A.alloc($e.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!A.isBuffer(o))throw new Error("Certificate must be a Buffer");return r+=2,e.writeUInt8(t.usage,r),r+=1,e.writeUInt8(t.selector,r),r+=1,e.writeUInt8(t.matchingType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,$e.encode.bytes=r-n,e.writeUInt16BE($e.encode.bytes-2,n),e};$e.encode.bytes=0;$e.decode=function(t,e){e||(e=0);let r=e,n={},o=t.readUInt16BE(e);return e+=2,n.usage=t.readUInt8(e),e+=1,n.selector=t.readUInt8(e),e+=1,n.matchingType=t.readUInt8(e),e+=1,n.certificate=t.slice(e,r+o+2),e+=n.certificate.length,$e.decode.bytes=e-r,n};$e.decode.bytes=0;$e.encodingLength=function(t){return 5+A.byteLength(t.certificate)};var kn=B.record=function(t){switch(t.toUpperCase()){case"A":return it;case"PTR":return Te;case"CNAME":return Ta;case"DNAME":return Oa;case"TXT":return tt;case"NULL":return rt;case"AAAA":return st;case"SRV":return ot;case"HINFO":return nt;case"CAA":return we;case"NS":return Je;case"SOA":return et;case"MX":return gt;case"OPT":return xe;case"DNSKEY":return ae;case"RRSIG":return ke;case"RP":return Ke;case"NSEC":return Me;case"NSEC3":return He;case"SSHFP":return be;case"DS":return qe;case"NAPTR":return ze;case"TLSA":return $e}return Qe},te=B.answer={};te.encode=function(t,e,r){e||(e=A.alloc(te.encodingLength(t))),r||(r=0);let n=r;if(y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ct.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,xe.encode(t.options||[],e,r),r+=xe.encode.bytes}else{let o=Fr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=Fn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=kn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return te.encode.bytes=r-n,e};te.encode.bytes=0;te.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=y.decode(t,e),e+=y.decode.bytes,r.type=ct.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=xe.decode(t,e+8),e+=8+xe.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Fr.toString(o&Ca),r.flush=!!(o&Fn);let i=kn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return te.decode.bytes=e-n,r};te.decode.bytes=0;te.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return y.encodingLength(t.name)+8+kn(t.type).encodingLength(e)};var Oe=B.question={};Oe.encode=function(t,e,r){e||(e=A.alloc(Oe.encodingLength(t))),r||(r=0);let n=r;return y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ct.toType(t.type),r),r+=2,e.writeUInt16BE(Fr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Oe.encode.bytes=r-n,t};Oe.encode.bytes=0;Oe.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=y.decode(t,e),e+=y.decode.bytes,n.type=ct.toString(t.readUInt16BE(e)),e+=2,n.class=Fr.toString(t.readUInt16BE(e)),e+=2,n.class&Hi&&(n.class&=La),Oe.decode.bytes=e-r,n};Oe.decode.bytes=0;Oe.encodingLength=function(t){return y.encodingLength(t.name)+4};B.AUTHORITATIVE_ANSWER=1024;B.TRUNCATED_RESPONSE=512;B.RECURSION_DESIRED=256;B.RECURSION_AVAILABLE=128;B.AUTHENTIC_DATA=32;B.CHECKING_DISABLED=16;B.DNSSEC_OK=32768;B.encode=function(t,e,r){let n=!e;n&&(e=A.alloc(B.encodingLength(t))),r||(r=0);let o=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),De.encode(t,e,r),r+=De.encode.bytes,r=cr(t.questions,Oe,e,r),r=cr(t.answers,te,e,r),r=cr(t.authorities,te,e,r),r=cr(t.additionals,te,e,r),B.encode.bytes=r-o,n&&B.encode.bytes!==e.length?e.slice(0,B.encode.bytes):e};B.encode.bytes=0;B.decode=function(t,e){e||(e=0);let r=e,n=De.decode(t,e);return e+=De.decode.bytes,e=Nr(n.questions,Oe,t,e),e=Nr(n.answers,te,t,e),e=Nr(n.authorities,te,t,e),e=Nr(n.additionals,te,t,e),B.decode.bytes=e-r,n};B.decode.bytes=0;B.encodingLength=function(t){return De.encodingLength(t)+Nt(t.questions||[],Oe)+Nt(t.answers||[],te)+Nt(t.authorities||[],te)+Nt(t.additionals||[],te)};B.streamEncode=function(t){let e=B.encode(t),r=A.alloc(2);r.writeUInt16BE(e.byteLength);let n=A.concat([r,e]);return B.streamEncode.bytes=n.byteLength,n};B.streamEncode.bytes=0;B.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=B.decode(t.slice(2));return B.streamDecode.bytes=B.decode.bytes,r};B.streamDecode.bytes=0;function Nt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function cr(t,e,r,n){for(let o=0;o<t.length;o++)e.encode(t[o],r,n),n+=e.encode.bytes;return n}function Nr(t,e,r,n){for(let o=0;o<t.length;o++)t[o]=e.decode(r,n),n+=e.decode.bytes;return n}});var Vi=Ce((ap,$i)=>{"use strict";var zi=Na;process.nextTick(Ra,42);$i.exports=Da;function Da(t){var e=n;return r;function r(o){e(o||_a)}function n(o){var i=[o];e=s,t(a);function s(c){i.push(c)}function a(c){var u=arguments;for(e=Ua(c)?n:l;i.length;)l(i.shift());function l(d){zi(Pa,d,u)}}}}function Ua(t){return Object.prototype.toString.call(t)==="[object Error]"}function _a(){}function Pa(t,e){t.apply(null,e)}function Ra(t){t===42&&(zi=process.nextTick)}function Na(t,e,r){process.nextTick(function(){t(e,r)})}});var Gi=Ce((up,Yi)=>{var Kn=qi(),Fa=me("dgram"),ka=Vi(),Ka=me("events"),Hn=me("os"),Mn=function(){};Yi.exports=function(t){t||(t={});var e=new Ka.EventEmitter,r=typeof t.port=="number"?t.port:5353,n=t.type||"udp4",o=t.ip||t.host||(n==="udp4"?"224.0.0.251":null),i={address:o,port:r},s={},a=!1,c=null;if(n==="udp6"&&(!o||!t.interface))throw new Error("For IPv6 multicast you must specify `ip` and `interface`");var u=t.socket||Fa.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(d){d.code==="EACCES"||d.code==="EADDRINUSE"?e.emit("error",d):e.emit("warning",d)}),u.on("message",function(d,f){try{d=Kn.decode(d)}catch(h){e.emit("warning",h);return}e.emit("packet",d,f),d.type==="query"&&e.emit("query",d,f),d.type==="response"&&e.emit("response",d,f)}),u.on("listening",function(){r||(r=i.port=u.address().port),t.multicast!==!1&&(e.update(),c=setInterval(e.update,5e3),u.setMulticastTTL(t.ttl||255),u.setMulticastLoopback(t.loopback!==!1))});var l=ka(function(d){if(!r||t.bind===!1)return d(null);u.once("error",d),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",d),d(null)})});return l(function(d){if(d)return e.emit("error",d);e.emit("ready")}),e.send=function(d,f,h){if(typeof f=="function")return e.send(d,null,f);h||(h=Mn),f?!f.host&&!f.address&&(f.address=i.address):f=i,l(p);function p(w){if(a)return h();if(w)return h(w);var I=Kn.encode(d);u.send(I,0,I.length,f.port,f.address||f.host,h)}},e.response=e.respond=function(d,f,h){Array.isArray(d)&&(d={answers:d}),d.type="response",d.flags=(d.flags||0)|Kn.AUTHORITATIVE_ANSWER,e.send(d,f,h)},e.query=function(d,f,h,p){if(typeof f=="function")return e.query(d,null,null,f);if(typeof f=="object"&&f&&f.port)return e.query(d,null,f,h);if(typeof h=="function")return e.query(d,f,null,h);p||(p=Mn),typeof d=="string"&&(d=[{name:d,type:f||"ANY"}]),Array.isArray(d)&&(d={type:"query",questions:d}),d.type="query",e.send(d,h,p)},e.destroy=function(d){if(d||(d=Mn),a)return process.nextTick(d);a=!0,clearInterval(c);for(var f in s)try{u.dropMembership(o,f)}catch{}s={},u.close(d)},e.update=function(){for(var d=t.interface?[].concat(t.interface):Ha(),f=!1,h=0;h<d.length;h++){var p=d[h];if(!s[p])try{u.addMembership(o,p),s[p]=!0,f=!0}catch(w){e.emit("warning",w)}}if(f){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||Ma())}catch(w){e.emit("warning",w)}e.emit("networkInterface")}},e};function Ma(){for(var t=Hn.networkInterfaces(),e=Object.keys(t),r=0;r<e.length;r++)for(var n=t[e[r]],o=0;o<n.length;o++){var i=n[o];if(ji(i.family)&&!i.internal)return Hn.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function Ha(){for(var t=Hn.networkInterfaces(),e=Object.keys(t),r=[],n=0;n<e.length;n++)for(var o=t[e[n]],i=0;i<o.length;i++){var s=o[i];if(ji(s.family)){r.push(s.address);break}}return r}function ji(t){return t===4||t==="IPv4"}});var hi=Ce(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.Netmask4Impl=void 0;Jt.ip2long=Qt;Jt.long2ip=Xe;function Xe(t){let e=(t&-16777216)>>>24,r=(t&255<<16)>>>16,n=(t&65280)>>>8,o=t&255;return[e,r,n,o].join(".")}var hl=48,pl=97,fl=65;function gl(t){let e=0,r=10,n="9",o=0;t.length>1&&t[o]==="0"&&(t[o+1]==="x"||t[o+1]==="X"?(o+=2,r=16):"0"<=t[o+1]&&t[o+1]<="9"&&(o++,r=8,n="7"));let i=o;for(;o<t.length;){if("0"<=t[o]&&t[o]<=n)e=e*r+(t.charCodeAt(o)-hl)>>>0;else if(r===16)if("a"<=t[o]&&t[o]<="f")e=e*r+(10+t.charCodeAt(o)-pl)>>>0;else if("A"<=t[o]&&t[o]<="F")e=e*r+(10+t.charCodeAt(o)-fl)>>>0;else break;else break;if(e>4294967295)throw new Error("too large");o++}if(o===i)throw new Error("empty octet");return[e,o]}function Qt(t){let e=[];for(let r=0;r<=3&&t.length!==0;r++){if(r>0){if(t[0]!==".")throw new Error("Invalid IP");t=t.substring(1)}let[n,o]=gl(t);t=t.substring(o),e.push(n)}if(t.length!==0)throw new Error("Invalid IP");switch(e.length){case 1:if(e[0]>4294967295)throw new Error("Invalid IP");return e[0]>>>0;case 2:if(e[0]>255||e[1]>16777215)throw new Error("Invalid IP");return(e[0]<<24|e[1])>>>0;case 3:if(e[0]>255||e[1]>255||e[2]>65535)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2])>>>0;case 4:if(e[0]>255||e[1]>255||e[2]>255||e[3]>255)throw new Error("Invalid IP");return(e[0]<<24|e[1]<<16|e[2]<<8|e[3])>>>0;default:throw new Error("Invalid IP")}}var li=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(!n){let o=e.split("/",2);e=o[0],n=o[1]}if(n||(n=32),typeof n=="string"&&n.indexOf(".")>-1){try{this.maskLong=Qt(n)}catch{throw new Error("Invalid mask: "+n)}this.bitmask=NaN;for(let o=32;o>=0;o--)if(this.maskLong===4294967295<<32-o>>>0){this.bitmask=o;break}}else if(n||n===0)this.bitmask=parseInt(n,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(Qt(e)&this.maskLong)>>>0}catch{throw new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+n);this.size=Math.pow(2,32-this.bitmask),this.base=Xe(this.netLong),this.mask=Xe(this.maskLong),this.hostmask=Xe(~this.maskLong),this.first=this.bitmask<=30?Xe(this.netLong+1):this.base,this.last=this.bitmask<=30?Xe(this.netLong+this.size-2):Xe(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?Xe(this.netLong+this.size-1):void 0}contains(e){return typeof e=="string"&&(e.indexOf("/")>0||e.split(".").length!==4)&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):(Qt(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new t(Xe(this.netLong+this.size*e),this.mask)}forEach(e){let r=Qt(this.first),n=Qt(this.last),o=0;for(;r<=n;)e(Xe(r),r,o),o++,r++}toString(){return this.base+"/"+this.bitmask}};Jt.Netmask4Impl=li});var qc=Ce(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.Netmask6Impl=void 0;er.ip6bigint=fi;er.bigint2ip6=_t;var ml=hi(),pi=(1n<<128n)-1n;function fi(t){let e=t.indexOf("%");e!==-1&&(t=t.substring(0,e));let r=t.lastIndexOf(":");if(r!==-1&&t.indexOf(".",r)!==-1){let n=t.substring(r+1),o=(0,ml.ip2long)(n),i=t.substring(0,r+1)+"0:0";return Hc(i)&~0xffffffffn|BigInt(o)}return Hc(t)}function Hc(t){let e=t.indexOf("::"),r;if(e!==-1){let o=t.substring(0,e),i=t.substring(e+2),s=o===""?[]:o.split(":"),a=i===""?[]:i.split(":"),c=8-s.length-a.length;if(c<0)throw new Error("Invalid IPv6: too many groups");r=[...s,...Array(c).fill("0"),...a]}else r=t.split(":");if(r.length!==8)throw new Error("Invalid IPv6: expected 8 groups, got "+r.length);let n=0n;for(let o=0;o<8;o++){let i=r[o];if(i.length===0||i.length>4)throw new Error('Invalid IPv6: bad group "'+i+'"');let s=parseInt(i,16);if(isNaN(s)||s<0||s>65535)throw new Error('Invalid IPv6: bad group "'+i+'"');n=n<<16n|BigInt(s)}return n}function _t(t){if(t<0n||t>pi)throw new Error("Invalid IPv6 address value");let e=[];for(let s=0;s<8;s++)e.unshift(Number(t&0xffffn)),t>>=16n;let r=-1,n=0,o=-1,i=0;for(let s=0;s<8;s++)e[s]===0?o===-1?(o=s,i=1):i++:(i>n&&i>=2&&(r=o,n=i),o=-1,i=0);if(i>n&&i>=2&&(r=o,n=i),r!==-1&&r+n===8&&r>0)return e.slice(0,r).map(a=>a.toString(16)).join(":")+"::";if(r===0)return"::"+e.slice(n).map(a=>a.toString(16)).join(":");if(r>0){let s=e.slice(0,r).map(c=>c.toString(16)),a=e.slice(r+n).map(c=>c.toString(16));return s.join(":")+"::"+a.join(":")}else return e.map(s=>s.toString(16)).join(":")}var gi=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");let n=r;if(n==null){let o=e.indexOf("/");o!==-1?(n=parseInt(e.substring(o+1),10),e=e.substring(0,o)):n=128}if(isNaN(n)||n<0||n>128)throw new Error("Invalid mask for IPv6: "+n);this.bitmask=n,this.bitmask===0?this.maskBigint=0n:this.maskBigint=pi>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=fi(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=_t(this.netBigint),this.mask=_t(this.maskBigint),this.hostmask=_t(~this.maskBigint&pi),this.first=this.base,this.last=_t(this.netBigint+(1n<<BigInt(128-this.bitmask))-1n),this.broadcast=void 0}contains(e){return typeof e=="string"&&e.indexOf("/")>0&&(e=new t(e)),e instanceof t?this.contains(e.base)&&this.contains(e.last):(fi(e)&this.maskBigint)===this.netBigint}next(e=1){let r=1n<<BigInt(128-this.bitmask);return new t(_t(this.netBigint+r*BigInt(e)),this.bitmask)}forEach(e){let r=this.netBigint,n=1n<<BigInt(128-this.bitmask),o=this.netBigint+n-1n,i=0;for(;r<=o;)e(_t(r),Number(r),i),i++,r++}toString(){return this.base+"/"+this.bitmask}};er.Netmask6Impl=gi});var zc=Ce(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.long2ip=At.ip2long=At.Netmask=void 0;var In=hi();Object.defineProperty(At,"ip2long",{enumerable:!0,get:function(){return In.ip2long}});Object.defineProperty(At,"long2ip",{enumerable:!0,get:function(){return In.long2ip}});var yl=qc(),mi=class t{constructor(e,r){if(typeof e!="string")throw new Error("Missing `net' parameter");(e.indexOf("/")!==-1?e.substring(0,e.indexOf("/")):e).indexOf(":")!==-1?this._impl=new yl.Netmask6Impl(e,r):this._impl=new In.Netmask4Impl(e,r),this.base=this._impl.base,this.mask=this._impl.mask,this.hostmask=this._impl.hostmask,this.bitmask=this._impl.bitmask,this.size=this._impl.size,this.first=this._impl.first,this.last=this._impl.last,this.broadcast=this._impl.broadcast,this._impl instanceof In.Netmask4Impl?(this.maskLong=this._impl.maskLong,this.netLong=this._impl.netLong):(this.maskLong=0,this.netLong=0)}contains(e){return typeof e=="string"&&(e.indexOf("/")>0?e=new t(e):e.indexOf(":")===-1&&e.split(".").length!==4&&(e=new t(e))),e instanceof t?this.contains(e.base)&&this.contains(e.broadcast||e.last):this._impl.contains(e)}next(e=1){let r=this._impl.next(e);return new t(r.base,r.bitmask)}forEach(e){this._impl.forEach(e)}toString(){return this._impl.toString()}};At.Netmask=mi});var Sh={};ye(Sh,{mdns:()=>Ih});var Le=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 _r=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},Pr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var sr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Ci=Symbol.for("@libp2p/peer-discovery");var Ln=Symbol.for("@libp2p/peer-id");var Li=me("node:events"),Ti=(t,...e)=>{try{(0,Li.setMaxListeners)(t,...e)}catch{}};function Ea(t){return typeof t?.handleEvent=="function"}function Ia(t){return t===!0||t===!1}function Sa(t){return Ia(t)?t:t?.capture??!1}function Tn(t){let e={capture:Sa(t),once:!!t?.once};return t?.passive!=null&&(e.passive=t?.passive),t?.signal!=null&&(e.signal=t?.signal),e}function Oi(t,e){return Tn(t).capture===Tn(e).capture}var Rr=class extends EventTarget{#e=new Map;constructor(){super(),Ti(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=Tn(n);if(o?.signal?.aborted===!0)return;let i=u=>{o.once&&this.removeEventListener(e,r,o),Ea(r)?r.handleEvent(u):r(u)},s=this.#e.get(e);if(s==null&&(s=[],this.#e.set(e,s)),s.some(u=>u.callback!==r?!1:Oi(u.options,o)))return;super.addEventListener(e,i,o);let c=()=>{this.removeEventListener(e,r,o)};o.signal?.addEventListener("abort",c),s.push({callback:r,wrapper:i,options:o,onAbort:c})}removeEventListener(e,r,n){let o=this.#e.get(e);if(o==null){super.removeEventListener(e,r??null,n);return}this.#e.set(e,o.filter(i=>i.callback===r&&Oi(i.options,n)?(super.removeEventListener(e,i.wrapper,n),i.options?.signal?.removeEventListener("abort",i.onAbort),!1):!0))}safeDispatchEvent(e,r={}){return this.dispatchEvent(new CustomEvent(e,r))}};var Di=Symbol.for("@libp2p/service-capabilities");var la=ir(Gi(),1);var jn={};ye(jn,{base58btc:()=>G,base58flickr:()=>Wa});var dp=new Uint8Array(0);function Xi(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function ue(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Lt(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Lt(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Zi(t){let e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}var Wi=4096;function Qi(t){let e=t.length;if(e<=Wi)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.subarray(n,n+=Wi));return r}function qa(t){return t?.buffer instanceof ArrayBuffer}function Lt(t){return qa(t)?t:t.slice()}function za(t,e,r){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),o=0;o<n.length;o++)n[o]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),a=s.charCodeAt(0);if(n[a]!==255)throw new TypeError(s+" is ambiguous");if(n[a]=i,r){var c=s.toLowerCase().charCodeAt(0),u=s.toUpperCase().charCodeAt(0);c!==a&&(n[c]=i),u!==a&&(n[u]=i)}}var l=t.length,d=t.charAt(0),f=Math.log(l)/Math.log(256),h=Math.log(256)/Math.log(l);function p(x){if(x instanceof Uint8Array||(ArrayBuffer.isView(x)?x=new Uint8Array(x.buffer,x.byteOffset,x.byteLength):Array.isArray(x)&&(x=Uint8Array.from(x))),!(x instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(x.length===0)return"";for(var C=0,q=0,F=0,H=x.length;F!==H&&x[F]===0;)F++,C++;for(var k=(H-F)*h+1>>>0,W=new Uint8Array(k);F!==H;){for(var Q=x[F],ge=0,K=k-1;(Q!==0||ge<q)&&K!==-1;K--,ge++)Q+=256*W[K]>>>0,W[K]=Q%l>>>0,Q=Q/l>>>0;if(Q!==0)throw new Error("Non-zero carry");q=ge,F++}for(var ce=k-q;ce!==k&&W[ce]===0;)ce++;for(var _=d.repeat(C);ce<k;++ce)_+=t.charAt(W[ce]);return _}function w(x){if(typeof x!="string")throw new TypeError("Expected String");if(x.length===0)return new Uint8Array;var C=0;if(x[C]!==" "){for(var q=0,F=0;x[C]===d;)q++,C++;for(var H=(x.length-C)*f+1>>>0,k=new Uint8Array(H);x[C];){var W=n[x.charCodeAt(C)];if(W===255)return;for(var Q=0,ge=H-1;(W!==0||Q<F)&&ge!==-1;ge--,Q++)W+=l*k[ge]>>>0,k[ge]=W%256>>>0,W=W/256>>>0;if(W!==0)throw new Error("Non-zero carry");F=Q,C++}if(x[C]!==" "){for(var K=H-F;K!==H&&k[K]===0;)K++;for(var ce=new Uint8Array(q+(H-K)),_=q;K!==H;)ce[_++]=k[K++];return ce}}}function I(x){var C=w(x);if(C)return C;throw new Error(`Non-${e} character`)}return{encode:p,decodeUnsafe:w,decode:I}}var $a=za,Va=$a,es=Va;var qn=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},zn=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){this.name=e,this.prefix=r;let o=r.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return ts(this,e)}},$n=class{decoders;constructor(e){this.decoders=e}or(e){return ts(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function ts(t,e){return new $n({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var Vn=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new qn(e,r,n),this.decoder=new zn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ft({name:t,prefix:e,encode:r,decode:n}){return new Vn(t,e,r,n)}function mt({name:t,prefix:e,alphabet:r,caseInsensitive:n=!1}){let{encode:o,decode:i}=es(r,t,n);return Ft({prefix:e,name:t,encode:o,decode:s=>ue(i(s))})}function ja(t,e,r,n){let o=t.length;for(;t[o-1]==="=";)--o;let i=new Uint8Array(o*r/8|0),s=0,a=0,c=0;for(let u=0;u<o;++u){let l=e[t[u]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<r|l,s+=r,s>=8&&(s-=8,i[c++]=255&a>>s)}if(s>=r||(255&a<<8-s)!==0)throw new SyntaxError("Unexpected end of data");return i}function Ya(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,i="",s=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],s+=8;s>r;)s-=r,i+=e[o&a>>s];if(s!==0&&(i+=e[o&a<<r-s]),n)for(;(i.length*r&7)!==0;)i+="=";return i}function Ga(t,e){let r={};for(let n=0;n<t.length;++n)if(r[t[n]]=n,e){let o=t[n].toLowerCase(),i=t[n].toUpperCase();o!==t[n]&&(r[o]=n),i!==t[n]&&(r[i]=n)}return r}function V({name:t,prefix:e,bitsPerChar:r,alphabet:n,caseInsensitive:o=!1}){let i=Ga(n,o);return Ft({prefix:e,name:t,encode(s){return Ya(s,n,r)},decode(s){return ja(s,i,r,t)}})}var G=mt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Wa=mt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Yn={};ye(Yn,{base32:()=>yt,base32hex:()=>Ja,base32hexpad:()=>tu,base32hexpadupper:()=>ru,base32hexupper:()=>eu,base32pad:()=>Za,base32padupper:()=>Qa,base32upper:()=>Xa,base32z:()=>nu});var yt=V({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5,caseInsensitive:!0}),Xa=V({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5,caseInsensitive:!0}),Za=V({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5,caseInsensitive:!0}),Qa=V({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5,caseInsensitive:!0}),Ja=V({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5,caseInsensitive:!0}),eu=V({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5,caseInsensitive:!0}),tu=V({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5,caseInsensitive:!0}),ru=V({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5,caseInsensitive:!0}),nu=V({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Gn={};ye(Gn,{base36:()=>ar,base36upper:()=>ou});var ar=mt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz",caseInsensitive:!0}),ou=mt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",caseInsensitive:!0});var iu=os,rs=128,su=127,cu=~su,au=Math.pow(2,31);function os(t,e,r){e=e||[],r=r||0;for(var n=r;t>=au;)e[r++]=t&255|rs,t/=128;for(;t&cu;)e[r++]=t&255|rs,t>>>=7;return e[r]=t|0,os.bytes=r-n+1,e}var uu=Wn,du=128,ns=127;function Wn(t,n){var r=0,n=n||0,o=0,i=n,s,a=t.length;do{if(i>=a)throw Wn.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&ns)<<o:(s&ns)*Math.pow(2,o),o+=7}while(s>=du);return Wn.bytes=i-n,r}var lu=Math.pow(2,7),hu=Math.pow(2,14),pu=Math.pow(2,21),fu=Math.pow(2,28),gu=Math.pow(2,35),mu=Math.pow(2,42),yu=Math.pow(2,49),wu=Math.pow(2,56),bu=Math.pow(2,63),xu=function(t){return t<lu?1:t<hu?2:t<pu?3:t<fu?4:t<gu?5:t<mu?6:t<yu?7:t<wu?8:t<bu?9:10},Eu={encode:iu,decode:uu,encodingLength:xu},Iu=Eu,ur=Iu;function dr(t,e=0){let r=ur.decode(t,e),n=ur.decode.bytes;if(n>9)throw new RangeError("Invalid varint: too long");if(n>1&&t[e+n-1]===0)throw new RangeError("Invalid varint: not minimally encoded");return[r,n]}function kt(t,e,r=0){return ur.encode(t,e,r),e}function Kt(t){return ur.encodingLength(t)}function Ht(t,e){let r=e.byteLength,n=Kt(t),o=n+Kt(r),i=new Uint8Array(o+r);return kt(t,i,0),kt(r,i,n),i.set(e,o),new Mt(t,r,e,i)}function lr(t){let e=ue(t),[r,n]=dr(e),[o,i]=dr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Mt(r,o,s,e)}function is(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Xi(t.bytes,r.bytes)}}var Mt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Lt(n),this.bytes=Lt(o)}};function ss(t,e){let{bytes:r,version:n}=t;return n===0?vu(r,Xn(t),e??G.encoder):Bu(r,Xn(t),e??yt.encoder)}var cs=new WeakMap;function Xn(t){let e=cs.get(t);if(e==null){let r=new Map;return cs.set(t,r),r}return e}var re=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Lt(o),this["/"]=this.bytes}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==hr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Au)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Ht(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&is(e.multihash,n.multihash)}toString(e){return ss(this,e)}toJSON(){return{"/":ss(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:i,bytes:s}=r;return new t(n,o,i,s??as(n,o,i.bytes))}else if(r[Cu]===!0){let{version:n,multihash:o,code:i}=r,s=lr(o);return t.create(n,i,s)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==hr)throw new Error(`Version 0 CID must use dag-pb (code: ${hr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=as(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,hr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=ue(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Mt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[d,f]=dr(e.subarray(r));return r+=f,d},o=n(),i=hr;if(o===18?(o=0,r=0):i=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let s=r,a=n(),c=n(),u=r+c,l=u-s;return{version:o,codec:i,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,r){let[n,o]=Su(e,r),i=t.decode(o);if(i.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Xn(i).set(n,e),i}};function Su(t,e){switch(t[0]){case"Q":{let r=e??G;return[G.prefix,r.decode(`${G.prefix}${t}`)]}case G.prefix:{let r=e??G;return[G.prefix,r.decode(t)]}case yt.prefix:{let r=e??yt;return[yt.prefix,r.decode(t)]}case ar.prefix:{let r=e??ar;return[ar.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function vu(t,e,r){let{prefix:n}=r;if(n!==G.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let i=r.encode(t).slice(1);return e.set(n,i),i}else return o}function Bu(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let i=r.encode(t);return e.set(n,i),i}else return o}var hr=112,Au=18;function as(t,e,r){let n=Kt(t),o=n+Kt(e),i=new Uint8Array(o+r.byteLength);return kt(t,i,0),kt(e,i,n),i.set(r,o),i}var Cu=Symbol.for("@ipld/js-cid/CID");var Zn={};ye(Zn,{identity:()=>Ue});var us=0,Lu="identity",ds=ue;function Tu(t,e){if(e?.truncate!=null&&e.truncate!==t.byteLength){if(e.truncate<0||e.truncate>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,e.truncate)}return Ht(us,ds(t))}var Ue={code:us,name:Lu,encode:ds,digest:Tu};function fe(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Ou(t){return t.buffer instanceof ArrayBuffer}function wt(t){return Ou(t)?t:t.slice()}async function ls(t,e,r,n){let o=await crypto.subtle.importKey("jwk",t,{name:"ECDSA",namedCurve:t.crv??"P-256"},!1,["verify"]);n?.signal?.throwIfAborted();let i=await crypto.subtle.verify({name:"ECDSA",hash:{name:"SHA-256"}},o,wt(e),wt(r.subarray()));return n?.signal?.throwIfAborted(),i}var Qn=me("node:buffer");function bt(t){if(t.buffer instanceof ArrayBuffer)return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);let e=t.slice();return new Uint8Array(e.buffer,0,e.byteLength)}function Ve(t=0){return bt(Qn.Buffer.alloc(t))}function Ee(t=0){return bt(Qn.Buffer.allocUnsafe(t))}var hs=me("node:buffer");function _e(t,e){return bt(hs.Buffer.concat(t,e))}var fs=Symbol.for("@achingbrain/uint8arraylist");function ps(t,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let r=0;for(let n of t){let o=r+n.byteLength;if(e<o)return{buf:n,index:e-r};r=o}throw new RangeError("index is out of bounds")}function Kr(t){return!!t?.[fs]}var Ie=class t{bufs;length;[fs]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let r=0;for(let n of e)if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.push(n);else if(Kr(n)){r+=n.byteLength;for(let o of n.bufs)this.bufs.push(o)}else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}prepend(...e){this.prependAll(e)}prependAll(e){let r=0;for(let n of e.reverse())if(n instanceof Uint8Array)r+=n.byteLength,this.bufs.unshift(n);else if(Kr(n))r+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=r}get(e){let r=ps(this.bufs,e);return r.buf[r.index]}set(e,r){let n=ps(this.bufs,e);n.buf[n.index]=r}write(e,r=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(r+n,e[n]);else if(Kr(e))for(let n=0;n<e.length;n++)this.set(r+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,r){let{bufs:n,length:o}=this._subList(e,r);return _e(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:_e(n,o)}sublist(e,r){let{bufs:n,length:o}=this._subList(e,r),i=new t;return i.length=o,i.bufs=n,i}_subList(e,r){if(e=e??0,r=r??this.length,e<0&&(e=this.length+e),r<0&&(r=this.length+r),e<0||r>this.length)throw new RangeError("index is out of bounds");if(e===r)return{bufs:[],length:0};if(e===0&&r===this.length)return{bufs:[...this.bufs],length:this.length};let n=[],o=0;for(let i=0;i<this.bufs.length;i++){let s=this.bufs[i],a=o,c=a+s.byteLength;if(o=c,e>=c)continue;let u=e>=a&&e<c,l=r>a&&r<=c;if(u&&l){if(e===a&&r===c){n.push(s);break}let d=e-a;n.push(s.subarray(d,d+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-a));continue}if(l){if(r===c){n.push(s);break}n.push(s.subarray(0,r-a));break}n.push(s)}return{bufs:n,length:r-e}}indexOf(e,r=0){if(!Kr(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let d=0;d<i;d++)s[d]=-1;for(let d=0;d<o;d++)s[n[d]]=d;let a=s,c=this.byteLength-n.byteLength,u=n.byteLength-1,l;for(let d=r;d<=c;d+=l){l=0;for(let f=u;f>=0;f--){let h=this.get(d+f);if(n[f]!==h){l=Math.max(1,f-a[h]);break}}if(l===0)return d}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,r),this.write(n,e)}getInt16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,r)}setInt16(e,r,n){let o=Ve(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt16(0,r,n),this.write(o,e)}getInt32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,r)}setInt32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setInt32(0,r,n),this.write(o,e)}getBigInt64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,r)}setBigInt64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigInt64(0,r,n),this.write(o,e)}getUint8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint8(0)}setUint8(e,r){let n=Ee(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,r),this.write(n,e)}getUint16(e,r){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,r)}setUint16(e,r,n){let o=Ve(2);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint16(0,r,n),this.write(o,e)}getUint32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,r)}setUint32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setUint32(0,r,n),this.write(o,e)}getBigUint64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,r)}setBigUint64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setBigUint64(0,r,n),this.write(o,e)}getFloat32(e,r){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,r)}setFloat32(e,r,n){let o=Ve(4);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat32(0,r,n),this.write(o,e)}getFloat64(e,r){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,r)}setFloat64(e,r,n){let o=Ve(8);new DataView(o.buffer,o.byteOffset,o.byteLength).setFloat64(0,r,n),this.write(o,e)}equals(e){if(e==null||!(e instanceof t)||e.bufs.length!==this.bufs.length)return!1;for(let r=0;r<this.bufs.length;r++)if(!fe(this.bufs[r],e.bufs[r]))return!1;return!0}static fromUint8Arrays(e,r){let n=new t;return n.bufs=e,r==null&&(r=e.reduce((o,i)=>o+i.byteLength,0)),n.length=r,n}};var xs=me("node:buffer");var Jn={};ye(Jn,{base10:()=>Du});var Du=mt({prefix:"9",name:"base10",alphabet:"0123456789"});var eo={};ye(eo,{base16:()=>Uu,base16upper:()=>_u});var Uu=V({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4,caseInsensitive:!0}),_u=V({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4,caseInsensitive:!0});var to={};ye(to,{base2:()=>Pu});var Pu=V({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ro={};ye(ro,{base256emoji:()=>Ku});var gs=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ru=gs.reduce((t,e,r)=>(t[r]=e,t),[]),Nu=gs.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Fu(t){return t.reduce((e,r)=>(e+=Ru[r],e),"")}function ku(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Nu[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Ku=Ft({prefix:"\u{1F680}",name:"base256emoji",encode:Fu,decode:ku});var oo={};ye(oo,{base64:()=>Mu,base64pad:()=>Hu,base64url:()=>no,base64urlpad:()=>qu});var Mu=V({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Hu=V({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),no=V({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),qu=V({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var io={};ye(io,{base8:()=>zu});var zu=V({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var so={};ye(so,{identity:()=>$u});var $u=Ft({prefix:"\0",name:"identity",encode:t=>Qi(ue(t)),decode:t=>ue(Zi(t))});var Wp=new TextEncoder,Xp=new TextDecoder;var ho={};ye(ho,{sha256:()=>lo,sha512:()=>Gu});var uo=ir(me("node:crypto"),1);var Yu=20;function ao({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new co(t,e,r,n,o)}var co=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Yu,this.maxDigestLength=i}digest(e,r){if(r?.truncate!=null){if(r.truncate<this.minDigestLength)throw new Error(`Invalid truncate option, must be greater than or equal to ${this.minDigestLength}`);if(this.maxDigestLength!=null&&r.truncate>this.maxDigestLength)throw new Error(`Invalid truncate option, must be less than or equal to ${this.maxDigestLength}`)}if(e instanceof Uint8Array){let n=this.encode(e);return n instanceof Uint8Array?ms(n,this.code,r?.truncate):n.then(o=>ms(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function ms(t,e,r){if(r!=null&&r!==t.byteLength){if(r>t.byteLength)throw new Error(`Invalid truncate option, must be less than or equal to ${t.byteLength}`);t=t.subarray(0,r)}return Ht(e,t)}var lo=ao({name:"sha2-256",code:18,encode:t=>ue(uo.default.createHash("sha256").update(t).digest())}),Gu=ao({name:"sha2-512",code:19,encode:t=>ue(uo.default.createHash("sha512").update(t).digest())});var pr={...so,...to,...io,...Jn,...eo,...Yn,...Gn,...jn,...oo,...ro},u0={...ho,...Zn};function bs(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ws=bs("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),po=bs("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);let e=Ee(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Wu={utf8:ws,"utf-8":ws,hex:pr.base16,latin1:po,ascii:po,binary:po,...pr},Mr=Wu;function de(t,e="utf8"){let r=Mr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?bt(xs.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var Es=me("node:buffer");function j(t,e="utf8"){let r=Mr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Es.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Xu=parseInt("11111",2),fo=parseInt("10000000",2),Zu=parseInt("01111111",2),Is={0:fr,1:fr,2:Qu,3:td,4:rd,5:ed,6:Ju,16:fr,22:fr,48:fr};function go(t,e={offset:0}){let r=t[e.offset]&Xu;if(e.offset++,Is[r]!=null)return Is[r](t,e);throw new Error("No decoder for tag "+r)}function gr(t,e){let r=0;if((t[e.offset]&fo)===fo){let n=t[e.offset]&Zu,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++){if(e.offset>=t.byteLength)throw new Error("invalid DER element length");o+=t[e.offset].toString(16).padStart(2,"0")}r=parseInt(o,16)}else r=t[e.offset],e.offset++;if(!Number.isInteger(r)||r<0||r>t.byteLength-e.offset)throw new Error("invalid DER element length");return r}function fr(t,e){gr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=go(t,e);if(n===null)break;r.push(n)}return r}function Qu(t,e){let r=gr(t,e),n=e.offset,o=e.offset+r,i=[];for(let s=n;s<o;s++)s===n&&t[s]===0||i.push(t[s]);return e.offset+=r,Uint8Array.from(i)}function Ju(t,e){let r=gr(t,e),n=e.offset+r,o=t[e.offset];e.offset++;let i=0,s=0;o<40?(i=0,s=o):o<80?(i=1,s=o-40):(i=2,s=o-80);let a=`${i}.${s}`,c=[];for(;e.offset<n;){let u=t[e.offset];if(e.offset++,c.push(u&127),u<128){c.reverse();let l=0;for(let d=0;d<c.length;d++)l+=c[d]<<d*7;a+=`.${l}`,c=[]}}return a}function ed(t,e){return e.offset++,null}function td(t,e){let r=gr(t,e),n=t[e.offset];e.offset++;let o=t.subarray(e.offset,e.offset+r-1);if(e.offset+=r,n!==0)throw new Error("Unused bits in bit string is unimplemented");return o}function rd(t,e){let r=gr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function nd(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new Ie;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function mo(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=nd(t.byteLength);return new Ie(Uint8Array.from([e.byteLength|fo]),e)}function Ss(t){let e=new Ie,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new Ie(Uint8Array.from([2]),mo(e),e)}function vs(t){let e=Uint8Array.from([0]),r=new Ie(e,t);return new Ie(Uint8Array.from([3]),mo(r),r)}function Hr(t,e=48){let r=new Ie;for(let n of t)r.append(n);return new Ie(Uint8Array.from([e]),mo(r),r)}var od=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),id=Uint8Array.from([6,5,43,129,4,0,34]),sd=Uint8Array.from([6,5,43,129,4,0,35]),cd={ext:!0,kty:"EC",crv:"P-256"},ad={ext:!0,kty:"EC",crv:"P-384"},ud={ext:!0,kty:"EC",crv:"P-521"},yo=32,wo=48,bo=66;function Bs(t){let e=go(t);return As(e)}function As(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===yo*2+1)return n=j(e.subarray(r,r+yo),"base64url"),o=j(e.subarray(r+yo),"base64url"),new zt({...cd,key_ops:["verify"],x:n,y:o});if(e.byteLength===wo*2+1)return n=j(e.subarray(r,r+wo),"base64url"),o=j(e.subarray(r+wo),"base64url"),new zt({...ad,key_ops:["verify"],x:n,y:o});if(e.byteLength===bo*2+1)return n=j(e.subarray(r,r+bo),"base64url"),o=j(e.subarray(r+bo),"base64url"),new zt({...ud,key_ops:["verify"],x:n,y:o});throw new Le(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Cs(t){return Hr([Ss(Uint8Array.from([1])),Hr([dd(t.crv)],160),Hr([vs(new Ie(Uint8Array.from([4]),de(t.x??"","base64url"),de(t.y??"","base64url")))],161)]).subarray()}function dd(t){if(t==="P-256")return od;if(t==="P-384")return id;if(t==="P-521")return sd;throw new Le(`Invalid curve ${t}`)}var zt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Cs(this.jwk)),this._raw}toMultihash(){return Ue.digest($t(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:fe(this.raw,e.raw)}async verify(e,r,n){return ls(this.jwk,r,e,n)}};var sn=ir(me("crypto"),1);var ld=t=>t/2**32|0,hd=t=>t>>>0;function Ls(t,e,r,n){let o=ld(r),i=hd(r);t.setUint32(e,n?i:o,n),t.setUint32(e+4,n?o:i,n)}function qr(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}var xo=t=>t?`"${t}" `:"";function at(t,e=""){if(typeof t!="number")throw new TypeError(xo(e)+"expected number, got "+typeof t);if(!Number.isSafeInteger(t)||t<0)throw new RangeError(xo(e)+"expected integer >= 0, got "+t);return t}function je(t,e,r=""){if(qr(t)&&(e===void 0||t.length===e))return t;e!==void 0&&at(e,"length");let n=qr(t),o=e!==void 0?` of length ${e}`:"",i=n?`length=${t.length}`:`type=${typeof t}`,s=xo(r)+"expected Uint8Array"+o+", got "+i;throw n?new RangeError(s):new TypeError(s)}function zr(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("expected hash wrapped by utils.createHasher");if(at(t.outputLen),at(t.blockLen),t.outputLen<1||t.blockLen<1)throw new Error("hash blockLen / outputLen must be >= 1")}var Ts=(t,e)=>{if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError((e==="object"?"":`"${e}" `)+"expected object, got type="+typeof t)};function Vt(t,e=!0){if(t.destroyed)throw new Error("hash was destroyed");if(e&&t.finished)throw new Error("digest() was already called")}function $r(t,e){je(t,void 0,"output");let r=e.outputLen;if(!(t.length>=r))throw new RangeError('"output" expected length >= '+r)}function mr(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function Vr(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Pe(t,e){return t<<32-e|t>>>e}var Ds=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",pd=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function jr(t){if(je(t),Ds)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=pd[t[r]];return e}function Os(t){return t>=48&&t<=57?t-48:t>=65&&t<=70?t-55:t>=97&&t<=102?t-87:void 0}function Eo(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(Ds)try{return Uint8Array.fromHex(t)}catch(o){throw o instanceof SyntaxError?new RangeError(o.message):o}let e=t.length,r=e/2;if(e%2)throw new RangeError("hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(r);for(let o=0,i=0;o<r;o++,i+=2){let s=Os(t.charCodeAt(i)),a=Os(t.charCodeAt(i+1));if(s===void 0||a===void 0){let c=t[i]+t[i+1];throw new RangeError('hex string expected, got non-hex character "'+c+'" at index '+i)}n[o]=s*16+a}return n}function Us(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];je(o),e+=o.length}let r=new Uint8Array(e);for(let n=0,o=0;n<t.length;n++){let i=t[n];r.set(i,o),o+=i.length}return r}function fd(t,e,r="opts"){return Ts(t,"defaults"),e!==void 0&&Ts(e,r),Object.assign(t,e)}function _s(t,e={}){if(typeof t!="function")throw new TypeError('"hashCons" expected function, got type='+typeof t);e=fd({},e,"info");let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function Ps(t=32){at(t,"bytesLength");let e=typeof globalThis=="object"?globalThis.crypto:null;if(typeof e?.getRandomValues!="function")throw new Error("crypto.getRandomValues must be defined");if(t>65536)throw new RangeError(`"bytesLength" expected <= 65536, got ${t}`);return e.getRandomValues(new Uint8Array(t))}var Rs=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Ns(t,e,r){return t&e^~t&r}function Fs(t,e,r){return t&e^t&r^e&r}var Yr=class{blockLen;outputLen;canXOF=!1;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,r,n,o){this.blockLen=e,this.outputLen=r,this.padOffset=n,this.isLE=o,this.buffer=new Uint8Array(e),this.view=Vr(this.buffer)}update(e){Vt(this),je(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length,s=!1;for(let a=0;a<i;){let c=Math.min(o-this.pos,i-a);if(c===o){let u=Vr(e);for(;o<=i-a;a+=o)this.process(u,a);s=!0;continue}n.set(a===0&&c===i?e:e.subarray(a,a+c),this.pos),this.pos+=c,a+=c,this.pos===o&&(this.process(r,0),this.pos=0,s=!0)}return this.length+=e.length,s&&this.roundClean(),this}digestInto(e){Vt(this),$r(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,r.fill(0,s),this.padOffset>o-s&&(this.process(n,0),r.fill(0)),Ls(n,o-8,this.length*8,i),this.process(n,0),this.roundClean();let a=e===r?n:Vr(e),c=this.outputLen,u=c/4,l=this.get();if(c%4||u>l.length)throw new Error("invalid outputLen");for(let d=0;d<u;d++)a.setUint32(4*d,l[d],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneIntoMeta(e){let{buffer:r,length:n,finished:o,destroyed:i,pos:s}=this;return e.destroyed=i,e.finished=o,e.length=n,e.pos=s,s&&e.buffer.set(r),e}clone(){return this._cloneInto()}},ks=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var gd=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),xt=new Uint32Array(64),Io=class extends Yr{A=0;B=0;C=0;D=0;E=0;F=0;G=0;H=0;constructor(e,r){super(64,e,8,!1),this.A=r[0]|0,this.B=r[1]|0,this.C=r[2]|0,this.D=r[3]|0,this.E=r[4]|0,this.F=r[5]|0,this.G=r[6]|0,this.H=r[7]|0}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:a,H:c}=this;return[e,r,n,o,i,s,a,c]}set(e,r,n,o,i,s,a,c){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=a|0,this.H=c|0}_cloneInto(e){return(e||=new this.constructor).set(...this.get()),this._cloneIntoMeta(e)}process(e,r){for(let d=0;d<16;d++,r+=4)xt[d]=e.getUint32(r,!1);for(let d=16;d<64;d++){let f=xt[d-15],h=xt[d-2],p=Pe(f,7)^Pe(f,18)^f>>>3,w=Pe(h,17)^Pe(h,19)^h>>>10;xt[d]=w+xt[d-7]+p+xt[d-16]|0}let{A:n,B:o,C:i,D:s,E:a,F:c,G:u,H:l}=this;for(let d=0;d<64;d++){let f=Pe(a,6)^Pe(a,11)^Pe(a,25),h=l+f+Ns(a,c,u)+gd[d]+xt[d]|0,w=(Pe(n,2)^Pe(n,13)^Pe(n,22))+Fs(n,o,i)|0;l=u,u=c,c=a,a=s+h|0,s=i,i=o,o=n,n=h+w|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,o,i,s,a,c,u,l)}roundClean(){mr(xt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),mr(this.buffer)}},So=class extends Io{constructor(){super(32,ks)}};var Ks=_s(()=>new So,Rs(1));function Wr(t,e,r=()=>{}){if(!Array.isArray(t))throw new TypeError(`"${e}" expected array, got type=${typeof t}`);for(let n=0;n<t.length;n++)r(t[n],`${e}[${n}]`);return t}var X=(t,e,r)=>je(t,e,r),vo=at;function Hs(t,e=""){if(typeof t!="string"){let r=e&&`"${e}" `;throw new TypeError(r+"expected string, got type="+typeof t)}return t}function Et(t,e="object"){if(t===null||typeof t!="object"||Array.isArray(t))throw new TypeError(e==="object"?"expected valid options object":`"${e}" expected object, got type=${typeof t}`);return t}function Tt(t,e){if(typeof t!="function")throw new TypeError(`"${e}" is invalid: expected function, got ${typeof t}`);return t}var Bo=jr,ut=(...t)=>Us(...t),Xr=t=>Eo(t),jt=qr,Zr=t=>Ps(t),Gr=BigInt(0),Ms=BigInt(1),md=t=>t?`"${t}" `:"";function Ye(t,e=""){if(typeof t!="boolean")throw new TypeError(md(e)+"expected boolean, got type="+typeof t);return t}function Qr(t){if(typeof t=="bigint"){if(!It(t))throw new RangeError("positive bigint expected, got "+t)}else vo(t);return t}function Yt(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(r+"expected number, got type="+typeof t)}if(!Number.isSafeInteger(t)){let r=e&&`"${e}" `;throw new RangeError(r+"expected safe integer, got "+t)}}function yr(t){let e=Qr(t).toString(16);return e.length&1?"0"+e:e}function qs(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?Gr:BigInt("0x"+t)}function Ge(t){return qs(jr(t))}function Ao(t){return qs(jr(yd(je(t)).reverse()))}function Jr(t,e){if(at(e),e===0)throw new Error("zero output length is invalid");t=Qr(t);let r=e*2,n=t.toString(16);if(n.length>r)throw new RangeError("number is too large");return Eo(n.padStart(r,"0"))}function Co(t,e){return Jr(t,e).reverse()}function yd(t){return Uint8Array.from(X(t))}function It(t){return typeof t=="bigint"&&Gr<=t}function Lo(t,e,r){return It(t)&&It(e)&&It(r)&&e<=t&&t<r}function To(t,e,r,n){if(!Lo(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Gt(t){if(t<Gr)throw new Error("expected non-negative bigint, got "+t);return t===Gr?0:t.toString(2).length}var wr=t=>(Yt(t,"n"),(Ms<<BigInt(t))-Ms);function zs(t,e,r){if(at(t,"hashLen"),at(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=I=>new Uint8Array(I),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),a=1e3,c=n(t),u=n(t),l=0,d=()=>{c.fill(1),u.fill(0),l=0},f=(...I)=>r(u,ut(c,...I)),h=(I=o)=>{u=f(i,I),c=f(),I.length!==0&&(u=f(s,I),c=f())},p=()=>{if(l++>=a)throw new Error("drbg: tried max amount of iterations");let I=0,x=[];for(;I<e;){c=f();let C=c.slice();x.push(C),I+=c.length}return ut(...x)};return(I,x)=>{d(),h(I);let C;for(;(C=x(p()))===void 0;)h();return d(),C}}function St(t,e={},r={},n="object"){Et(t,n),Et(e,"fields"),Et(r,"optFields");function o(s,a,c){let u=n==="object"?`param "${String(s)}"`:`"${n}.${String(s)}"`,l=t[s];if(!Object.hasOwn(t,s)&&(c?l!==void 0:a!=="function"))throw new TypeError(`${u} is invalid: expected own property`);if(c&&l===void 0)return;let d=typeof l;if(d!==a||l===null)throw new TypeError(`${u} is invalid: expected ${a}, got ${d}`)}let i=(s,a)=>Object.entries(s).forEach(([c,u])=>o(c,u,a));i(e,!1),i(r,!0)}var Z=BigInt(0),N=BigInt(1),vt=BigInt(2),Ys=BigInt(3),Oo=BigInt(4),Gs=BigInt(5),wd=BigInt(7),Ws=BigInt(8),bd=BigInt(9),xd=BigInt(15),Xs=BigInt(16),Ed=BigInt("0x10000000000000000");function Se(t,e){if(e<=Z)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=Z?r:e+r}function Zs(t,e,r){if(r<=N)throw new Error("pow: expected modulus > 1, got "+r);if(typeof e!="bigint")throw new TypeError("invalid exponent: expected bigint, got "+typeof e);if(e<Z)throw new Error("invalid exponent, negatives unsupported");if(e===Z)return N;if(e===N)return t;let n=t%r;if(n<Z&&(n+=r),e<Ed){let a=N;for(;e>Z;)e&N&&(a=a*n%r),n=n*n%r,e>>=N;return a}let o=[];for(;e>Z;)o.push(Number(e&xd)),e>>=Oo;let i=new Array(16);i[0]=N,i[1]=n;for(let a=2;a<16;a++)i[a]=i[a-1]*n%r;let s=i[o[o.length-1]];for(let a=o.length-2;a>=0;a--){s=s*s%r,s=s*s%r,s=s*s%r,s=s*s%r;let c=o[a];c!==0&&(s=s*i[c]%r)}return s}function ve(t,e,r){if(r<=N)throw new Error("pow2: expected modulus > 1, got "+r);if(e<Z)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >Z;)n*=n,n%=r;return n}function $s(t,e){if(t===Z)throw new Error("invert: expected non-zero number");if(e<=N)throw new Error("invert: expected modulus > 1, got "+e);let r=Se(t,e),n=e,o=Z,i=N;for(;r!==Z;){let a=n/r,c=n-r*a,u=o-i*a;n=r,r=c,o=i,i=u}if(n!==N)throw new Error("invert: does not exist");return Se(o,e)}function Qs(t,e){if(e<=N)throw new Error("invertCt: expected prime modulus > 1, got "+e);let r=Se(t,e);if(r===Z)throw new Error("invertCt: expected non-zero number");let n=Zs(r,e-vt,e);if(Se(r*n,e)!==N)throw new Error("invertCt: does not exist");return n}function Do(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Uo(t,e){if((t&N)===Z)throw new Error(e+": expected odd modulus, got "+t)}function Js(t,e){let r=t,n=(r.ORDER+N)/Oo,o=r.pow(e,n);return Do(r,o,e),o}function Id(t,e){let r=t,n=(r.ORDER-Gs)/Ws,o=r.mul(e,vt),i=r.pow(o,n),s=r.mul(e,i),a=r.mul(r.mul(s,vt),i),c=r.mul(s,r.sub(a,r.ONE));return Do(r,c,e),c}function Sd(t){let e=Xt(t),r=ec(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+wd)/Xs;return((a,c)=>{let u=a,l=u.pow(c,s),d=u.mul(l,n),f=u.mul(l,o),h=u.mul(l,i),p=u.eql(u.sqr(d),c),w=u.eql(u.sqr(f),c);l=u.cmov(l,d,p),d=u.cmov(h,f,w);let I=u.eql(u.sqr(d),c),x=u.cmov(l,d,I);return Do(u,x,c),x})}function ec(t){if(t<Ys)throw new Error("sqrt is not defined for small field");Uo(t,"tonelliShanks");let e=t-N,r=0;for(;e%vt===Z;)e/=vt,r++;let n=vt,o=Xt(t);for(;Vs(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Js;let i=o.pow(n,e),s=(e+N)/vt;return function(c,u){let l=c;if(l.is0(u))return u;if(Vs(l,u)!==1)throw new Error("Cannot find square root");let d=r,f=l.mul(l.ONE,i),h=l.pow(u,e),p=l.pow(u,s);for(;!l.eql(h,l.ONE);){if(l.is0(h))throw new Error("Cannot find square root: probably non-prime P");let w=1,I=l.sqr(h);for(;!l.eql(I,l.ONE);)if(w++,I=l.sqr(I),w===d)throw new Error("Cannot find square root");let x=N<<BigInt(d-w-1),C=l.pow(f,x);d=w,f=l.sqr(C),h=l.mul(h,f),p=l.mul(p,C)}return p}}function vd(t){return Uo(t,"Fp.sqrt"),t%Oo===Ys?Js:t%Ws===Gs?Id:t%Xs===bd?Sd(t):ec(t)}var Bd=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Wt(t){if(Et(t,"field"),typeof t.ORDER!="bigint")throw new TypeError('param "ORDER" is invalid: expected bigint, got '+typeof t.ORDER);Yt(t.BYTES,"BYTES"),Yt(t.BITS,"BITS");for(let e of Bd)Tt(t[e],"field."+e);if(t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=N)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function _o(t,e,r=!1){Wt(t),Wr(e,"nums"),Ye(r,"passZero");let n=t,o=new Array(e.length).fill(r?n.ZERO:void 0),i=e.reduce((a,c,u)=>n.is0(c)?a:(o[u]=a,n.mul(a,c)),n.ONE),s=n.inv(i);return e.reduceRight((a,c,u)=>n.is0(c)?a:(o[u]=n.mul(a,o[u]),n.mul(a,c)),s),o}function Vs(t,e){Wt(t);let r=t;Uo(r.ORDER,"FpLegendre");let n=(r.ORDER-N)/vt,o=r.pow(e,n),i=r.eql(o,r.ONE),s=r.eql(o,r.ZERO),a=r.eql(o,r.neg(r.ONE));if(!i&&!s&&!a)throw new Error("invalid Legendre symbol result");return i?1:s?0:-1}function Ad(t,e){if(e!==void 0&&vo(e),t<=Z)throw new Error("invalid n length: expected positive n, got "+t);if(e!==void 0&&e<1)throw new Error("invalid n length: expected positive bit length, got "+e);let r=Gt(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected nBitLength (${e}) >= bitLen(n) (${r})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var js=new WeakMap,en=class{ORDER;BITS;BYTES;isLE;ZERO=Z;ONE=N;_lengths;_mod;constructor(e,r={}){if(e<=N)throw new Error("invalid field: expected ORDER > 1, got "+e);let n;this.isLE=!1,r!=null&&typeof r=="object"&&(typeof r.BITS=="number"&&(n=r.BITS),typeof r.sqrt=="function"&&Object.defineProperty(this,"sqrt",{value:r.sqrt,enumerable:!0}),typeof r.isLE=="boolean"&&(this.isLE=r.isLE),r.allowedLengths&&(this._lengths=Object.freeze(r.allowedLengths.slice())),typeof r.modFromBytes=="boolean"&&(this._mod=r.modFromBytes));let{nBitLength:o,nByteLength:i}=Ad(e,n);if(i>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");this.ORDER=e,this.BITS=o,this.BYTES=i,Object.freeze(this)}create(e){return Se(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return Z<=e&&e<this.ORDER}is0(e){return e===Z}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&N)===N}neg(e){return Se(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return Se(e*e,this.ORDER)}add(e,r){return Se(e+r,this.ORDER)}sub(e,r){return Se(e-r,this.ORDER)}mul(e,r){return Se(e*r,this.ORDER)}pow(e,r){return Zs(e,r,this.ORDER)}div(e,r){return Se(e*$s(r,this.ORDER),this.ORDER)}sqrN(e){return e*e}addN(e,r){return e+r}subN(e,r){return e-r}mulN(e,r){return e*r}inv(e){return $s(e,this.ORDER)}sqrt(e){let r=js.get(this);return r||js.set(this,r=vd(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?Co(e,this.BYTES):Jr(e,this.BYTES)}fromBytes(e,r=!1){X(e);let{_lengths:n,BYTES:o,isLE:i,ORDER:s,_mod:a}=this;if(n){if(e.length<1||!n.includes(e.length)||e.length>o)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);let u=new Uint8Array(o);u.set(e,i?0:u.length-e.length),e=u}if(e.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);let c=i?Ao(e):Ge(e);if(a&&(c=Se(c,s)),!r&&!this.isValid(c))throw new Error("invalid field element: outside of range 0..ORDER");return c}invertBatch(e){return _o(this,e,!0)}cmov(e,r,n){return Ye(n,"condition"),n?r:e}};function Xt(t,e={}){return Object.freeze(en.prototype),new en(t,e)}function tc(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=N)throw new Error("field order must be greater than 1");let e=Gt(t-N);return Math.ceil(e/8)}function tn(t){let e=tc(t);return e+Math.ceil(e/2)}function rn(t,e,r=!1){X(t);let n=t.length,o=tc(e),i=Math.max(tn(e),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Ao(t):Ge(t),a=Se(s,e-N)+N;return r?Co(a,o):Jr(a,o)}var No=BigInt(0),br=BigInt(1),Cd=BigInt(4),Po=16,rc=128,Ld=5,nc=2**31;function Zt(t){let e=t;if(typeof e!="function")throw new TypeError('"Point" expected constructor, got type='+typeof t);Tt(e.fromAffine,"Point.fromAffine"),Tt(e.fromBytes,"Point.fromBytes"),Tt(e.fromHex,"Point.fromHex"),Et(e.BASE,"Point.BASE"),Et(e.ZERO,"Point.ZERO"),Wt(e.Fp),Wt(e.Fn)}function ic(t,e){Zt(t),sc(e,t);let r=_o(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Td(t,e,r=1){if(!Number.isSafeInteger(t)||t<r||t>e)throw new Error("invalid window size, expected ["+r+".."+e+"], got W="+t)}function Od(t,e){let r=t*(4*e+128);if(r>nc)throw new Error("invalid window size: table would need ~"+Math.ceil(r/2**20)+" MiB, max "+nc/2**20+" MiB")}function Fo(t,e){if(t!==void 0){Tt(t,"randomBytes");try{let r=t(e);if(!jt(r)||r.length!==e)return}catch{return}return t}}function sc(t,e){Wr(t,"points"),t.forEach((r,n)=>{if(!(r instanceof e))throw new Error("invalid point at index "+n)})}function Dd(t,e,r){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,o)=>{if(!(r===void 0?e.isValid(n):It(n)&&n<r))throw new Error("invalid scalar at index "+o)})}var cc=new WeakMap;function Ro(t){return cc.get(t)||1}function Ud(t,e){let r=t.double(),n=[t];for(let o=1;o<e;o++)n.push(n[o-1].add(r));return n}function _d(t,e){let r=2**e,n=r/2,o=BigInt(r-1),i=[];for(;t>No;){let s=0;t&br&&(s=Number(t&o),s>=n&&(s-=r),t-=BigInt(s)),i.push(s),t>>=br}return i}function Pd(t,e,r){let n=2**e,o=n/2,i=BigInt(n-1),s=BigInt(e),a=[];for(let c=0;c<r;c++){let u=Number(t&i);t>>=s,u>o&&(u-=n,t+=br),a.push(u)}if(t!==No)throw new Error("invalid wnaf");return a}function Rd(t,e,r){let n=0;for(let i of r)n=Math.max(n,i.length);let o=t;for(let i=n-1;i>=0;i--){i!==n-1&&(o=o.double());for(let s=0;s<r.length;s++){let a=r[s][i];if(a){let c=e[s][Math.abs(a)-1>>1];o=o.add(a<0?c.negate():c)}}}return o}var nn=class{Point;BASE;ZERO;randomBytes;wnafPrecomputes=new WeakMap;baseCanBeBlinded;bits;constructor(e,r){Zt(e),this.randomBytes=Fo(r,Po),this.Point=e,this.BASE=e.BASE,this.ZERO=e.ZERO,this.bits=e.Fn.BITS}buildWnafTable(e,r,n){let o=Math.ceil(n/r)+1,i=2**(r-1),s=[],a=e;for(let c=0;c<o;c++){let u=a;for(let l=0;l<i;l++)s.push(u),u=u.add(a);a=s[s.length-1].double()}return{W:r,bits:n,windows:o,comp:s}}wnafCachedCT(e,r){let{W:n,windows:o,comp:i}=e,s=2**(n-1),a=Pd(r,n,o),c=this.ZERO,u=this.BASE;for(let l=0;l<o;l++){let d=a[l],f=l*s,h=Math.abs(d)-1,p=i[f];for(let I=1;I<s;I++)p=I===h?i[f+I]:p;let w=p.negate();d===0?u=u.add(i[f]):c=c.add(d<0?w:p)}return{p:c,f:u}}getWnafPrecomputes(e,r,n,o){let i=this.wnafPrecomputes.get(r),s=i?.find(a=>a.W===e&&a.bits===n);return s||(s=this.buildWnafTable(r,e,n),typeof o=="function"&&(s={...s,comp:o(s.comp)}),i||(i=[],this.wnafPrecomputes.set(r,i)),i.push(s)),s}assertPoint(e){if(!(e instanceof this.Point))throw new TypeError('"point" expected Point instance, got type='+typeof e)}validateMulInput(e,r){if(this.assertPoint(e),!Lo(r,br,this.Point.Fn.ORDER))throw new Error("invalid scalar")}runCT(e,r,n,o){let i=Ro(e);return i===1?this.fixedWindowCT(e,r,n):this.wnafCachedCT(this.getWnafPrecomputes(i,e,n,o),r)}mulCT(e,r,n){return this.validateMulInput(e,r),this.runCT(e,r,this.bits,n)}mulCTBlinded(e,r,n){if(this.validateMulInput(e,r),this.randomBytes===void 0)throw new Error("randomBytes is required for scalar blinding");let o=this.Point.Fn.BITS+rc,i=this.randomBytes(Po);if(!jt(i)||i.length!==Po)throw new Error("randomBytes returned invalid byte array");i[0]=i[0]&63|128;let s=r+Ge(i)*this.Point.Fn.ORDER;return this.runCT(e,s,o,n)}fixedWindowCT(e,r,n){let o=Ld,i=1<<o,s=wr(o),a=new Array(i);a[0]=this.ZERO;for(let l=1;l<i;l++)a[l]=a[l-1].add(e);let c=Math.ceil(n/o),u=this.ZERO;for(let l=c-1;l>=0;l--){if(l!==c-1)for(let h=0;h<o;h++)u=u.double();let d=Number(r>>BigInt(l*o)&s),f=a[0];for(let h=1;h<i;h++)f=h===d?a[h]:f;u=u.add(f)}return{p:u,f:u}}shouldBlind(e,r){return this.randomBytes===void 0?!1:r===br?!0:e!==this.BASE?!1:(this.baseCanBeBlinded===void 0&&(this.baseCanBeBlinded=this.mulUnsafe(this.BASE,this.Point.Fn.ORDER).is0()),this.baseCanBeBlinded)}mulSecret(e,r,n,o){return this.shouldBlind(e,n)?this.mulCTBlinded(e,r,o):this.mulCT(e,r,o)}mulUnsafe(e,r,n){if(this.assertPoint(e),!It(r))throw new Error("invalid scalar");let o=Ro(e);if(o===1||r>=this.Point.Fn.ORDER)return on(this.Point,[e],[r],!0);let i=this.getWnafPrecomputes(o,e,this.bits,n);return this.wnafCachedCT(i,r).p}setWindowSize(e,r){this.assertPoint(e),Td(r,this.bits);let n=Math.ceil((this.bits+rc)/r)+1;Od(n*2**(r-1),this.Point.Fp.BYTES),cc.set(e,r),this.wnafPrecomputes.delete(e)}hasWindowSize(e){return Ro(e)!==1}};function on(t,e,r,n=!1){if(Zt(t),sc(e,t),Ye(n,"allowOversized"),Dd(r,t.Fn,n?t.Fn.ORDER**Cd:void 0),e.length!==r.length)throw new Error("arrays of points and scalars must have equal length");let o=e.map(s=>Ud(s,4)),i=r.map(s=>_d(s,4));return Rd(t.ZERO,o,i)}function oc(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Wt(e),e}else return Xt(t,{isLE:r})}function ac(t,e,r={},n){if(t!=="weierstrass"&&t!=="edwards")throw new Error('expected curve type "weierstrass" or "edwards"');if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);St(r);for(let c of["p","n","h"]){let u=e[c];if(!(It(u)&&u!==No))throw new Error(`CURVE.${c} must be positive bigint`)}let o=oc(e.p,r.Fp,n),i=oc(e.n,r.Fn,n),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(let c of a)if(!o.isValid(e[c]))throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:o,Fn:i}}function uc(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var af=sn.default.generateKeyPairSync,xr=32;var Nd=64;function dc(t,e,r){if(t.byteLength!==xr)throw new TypeError('"key" must be 32 bytes in length.');if(!(t instanceof Uint8Array))throw new TypeError('"key" must be a node.js Buffer, or Uint8Array.');if(e.byteLength!==Nd)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=sn.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:j(t,"base64url"),kty:"OKP"}});return sn.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function hc(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var cn=class{type="Ed25519";raw;constructor(e){this.raw=ko(e,xr)}toMultihash(){return Ue.digest($t(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:fe(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=dc(this.raw,r,e);return hc(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function pc(t){return t=ko(t,xr),new cn(t)}function ko(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Le(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var kd=Math.pow(2,7),Kd=Math.pow(2,14),Md=Math.pow(2,21),Ko=Math.pow(2,28),Mo=Math.pow(2,35),Ho=Math.pow(2,42),qo=Math.pow(2,49),z=128,ie=127;function We(t){if(t<kd)return 1;if(t<Kd)return 2;if(t<Md)return 3;if(t<Ko)return 4;if(t<Mo)return 5;if(t<Ho)return 6;if(t<qo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Er(t,e,r=0){switch(We(t)){case 8:e[r++]=t&255|z,t/=128;case 7:e[r++]=t&255|z,t/=128;case 6:e[r++]=t&255|z,t/=128;case 5:e[r++]=t&255|z,t/=128;case 4:e[r++]=t&255|z,t>>>=7;case 3:e[r++]=t&255|z,t>>>=7;case 2:e[r++]=t&255|z,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function zo(t,e){let r=t[e],n=0;if(n+=r&ie,r<z||(r=t[e+1],n+=(r&ie)<<7,r<z)||(r=t[e+2],n+=(r&ie)<<14,r<z)||(r=t[e+3],n+=(r&ie)<<21,r<z)||(r=t[e+4],n+=(r&ie)*Ko,r<z)||(r=t[e+5],n+=(r&ie)*Mo,r<z)||(r=t[e+6],n+=(r&ie)*Ho,r<z)||(r=t[e+7],n+=(r&ie)*qo,r<z))return n;throw new RangeError("Could not decode varint")}function Hd(t,e){let r=t.get(e),n=0;if(n+=r&ie,r<z||(r=t.get(e+1),n+=(r&ie)<<7,r<z)||(r=t.get(e+2),n+=(r&ie)<<14,r<z)||(r=t.get(e+3),n+=(r&ie)<<21,r<z)||(r=t.get(e+4),n+=(r&ie)*Ko,r<z)||(r=t.get(e+5),n+=(r&ie)*Mo,r<z)||(r=t.get(e+6),n+=(r&ie)*Ho,r<z)||(r=t.get(e+7),n+=(r&ie)*qo,r<z))return n;throw new RangeError("Could not decode varint")}function $o(t,e=0){return t instanceof Uint8Array?zo(t,e):Hd(t,e)}var Vo=new Float32Array([-0]),Bt=new Uint8Array(Vo.buffer);function fc(t,e,r){Vo[0]=t,e[r]=Bt[0],e[r+1]=Bt[1],e[r+2]=Bt[2],e[r+3]=Bt[3]}function gc(t,e){return Bt[0]=t[e],Bt[1]=t[e+1],Bt[2]=t[e+2],Bt[3]=t[e+3],Vo[0]}var jo=new Float64Array([-0]),se=new Uint8Array(jo.buffer);function mc(t,e,r){jo[0]=t,e[r]=se[0],e[r+1]=se[1],e[r+2]=se[2],e[r+3]=se[3],e[r+4]=se[4],e[r+5]=se[5],e[r+6]=se[6],e[r+7]=se[7]}function yc(t,e){return se[0]=t[e],se[1]=t[e+1],se[2]=t[e+2],se[3]=t[e+3],se[4]=t[e+4],se[5]=t[e+5],se[6]=t[e+6],se[7]=t[e+7],jo[0]}var zd=BigInt(Number.MAX_SAFE_INTEGER),$d=BigInt(Number.MIN_SAFE_INTEGER),Be=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Ot;if(e<zd&&e>$d)return this.fromNumber(Number(e));let r=e<0n;r&&(e=-e);let n=e>>32n,o=e-(n<<32n);return r&&(n=~n|0n,o=~o|0n,++o>wc&&(o=0n,++n>wc&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ot;let r=e<0;r&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return r&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new t(n,o)}static from(e){return typeof e=="number"?t.fromNumber(e):typeof e=="bigint"?t.fromBigInt(e):typeof e=="string"?t.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new t(e.low>>>0,e.high>>>0):Ot}},Ot=new Be(0,0);Ot.toBigInt=function(){return 0n};Ot.zzEncode=Ot.zzDecode=function(){return this};Ot.length=function(){return 1};var wc=4294967296n;function bc(t){let e=0,r=0;for(let n=0;n<t.length;++n)r=t.charCodeAt(n),r<128?e+=1:r<2048?e+=2:(r&64512)===55296&&(t.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function xc(t,e,r){if(r-e<1)return"";let o,i=[],s=0,a;for(;e<r;)a=t[e++],a<128?i[s++]=a:a>191&&a<224?i[s++]=(a&31)<<6|t[e++]&63:a>239&&a<365?(a=((a&7)<<18|(t[e++]&63)<<12|(t[e++]&63)<<6|t[e++]&63)-65536,i[s++]=55296+(a>>10),i[s++]=56320+(a&1023)):i[s++]=(a&15)<<12|(t[e++]&63)<<6|t[e++]&63,s>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o!=null?(s>0&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))}function Yo(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Re(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function an(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var Go=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=wt(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,Re(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 Re(this,4);return an(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Re(this,4);return an(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Re(this,4);let e=gc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Re(this,4);let e=yc(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Re(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return xc(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Re(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Re(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Be(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Re(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Re(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Re(this,8);let e=an(this.buf,this.pos+=4),r=an(this.buf,this.pos+=4);return new Be(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=zo(this.buf,this.pos);return this.pos+=We(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 Ir(t){return new Go(t instanceof Uint8Array?t:t.subarray())}function un(t,e,r){let n=Ir(t);return e.decode(n,void 0,r)}function Wo(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Ee(s);o+s>e&&(n=Ee(e),o=0);let a=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),a}}var Dt=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Xo(){}var Qo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Vd=Wo();function jd(t){return globalThis.Buffer!=null?Ee(t):Vd(t)}var vr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Dt(Xo,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Dt(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Jo((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(dn,10,Be.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Be.fromBigInt(e);return this._push(dn,r.length(),r)}uint64Number(e){return this._push(Er,We(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=Be.fromBigInt(e).zzEncode();return this._push(dn,r.length(),r)}sint64Number(e){let r=Be.fromNumber(e).zzEncode();return this._push(dn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Zo,1,e?1:0)}fixed32(e){return this._push(Sr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Be.fromBigInt(e);return this._push(Sr,4,r.lo)._push(Sr,4,r.hi)}fixed64Number(e){let r=Be.fromNumber(e);return this._push(Sr,4,r.lo)._push(Sr,4,r.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(fc,4,e)}double(e){return this._push(mc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Zo,1,0):this.uint32(r)._push(Gd,r,e)}string(e){let r=bc(e);return r!==0?this.uint32(r)._push(Yo,r,e):this._push(Zo,1,0)}fork(){return this.states=new Qo(this),this.head=this.tail=new Dt(Xo,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 Dt(Xo,0,0),this.len=0),this}ldelim(){let e=this.head,r=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=r,this.len+=n),this}finish(){let e=this.head.next,r=jd(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Zo(t,e,r){e[r]=t&255}function Yd(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Jo=class extends Dt{next;constructor(e,r){super(Yd,e,r),this.next=void 0}};function dn(t,e,r){for(;t.hi!==0;)e[r++]=t.lo&127|128,t.lo=(t.lo>>>7|t.hi<<25)>>>0,t.hi>>>=7;for(;t.lo>127;)e[r++]=t.lo&127|128,t.lo=t.lo>>>7;e[r++]=t.lo}function Sr(t,e,r){e[r]=t&255,e[r+1]=t>>>8&255,e[r+2]=t>>>16&255,e[r+3]=t>>>24}function Gd(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(vr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Wd,e,t),this},vr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Xd,e,t),this});function Wd(t,e,r){e.set(t,r)}function Xd(t,e,r){t.length<40?Yo(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(de(t),r)}function ei(){return new vr}function ln(t,e){let r=ei();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*hn(t,e,r){let n=Ir(t);yield*e.stream(n,void 0,"$",r)}var pn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function fn(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function ti(t){function e(i){if(t[i.toString()]==null)throw new Error("Invalid enum value");return t[i]}let r=function(s,a){let c=e(s);a.int32(c)},n=function(s){let a=s.int32();return e(a)},o=function*(s){let a=s.int32();yield e(a)};return fn("enum",pn.VARINT,r,n,o)}function gn(t,e,r){return fn("message",pn.LENGTH_DELIMITED,t,e,r)}var le;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(le||(le={}));var ri;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(ri||(ri={}));(function(t){t.codec=()=>ti(ri)})(le||(le={}));var Br;(function(t){let e;t.codec=()=>(e==null&&(e=gn((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),le.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{c.Type=le.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(l&7);break}}}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{yield{field:`${a}.Type`,value:le.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(l&7);break}}}})),e);function r(i){return ln(i,t.codec())}t.encode=r;function n(i,s){return un(i,t.codec(),s)}t.decode=n;function o(i,s){return hn(i,t.codec(),s)}t.stream=o})(Br||(Br={}));var ni;(function(t){let e;t.codec=()=>(e==null&&(e=gn((i,s,a={})=>{a.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),le.codec().encode(i.Type,s)),i.Data!=null&&(s.uint32(18),s.bytes(i.Data)),a.lengthDelimited!==!1&&s.ldelim()},(i,s,a={})=>{let c={},u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{c.Type=le.codec().decode(i);break}case 2:{c.Data=i.bytes();break}default:{i.skipType(l&7);break}}}return c},function*(i,s,a,c={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let l=i.uint32();switch(l>>>3){case 1:{yield{field:`${a}.Type`,value:le.codec().decode(i)};break}case 2:{yield{field:`${a}.Data`,value:i.bytes()};break}default:{i.skipType(l&7);break}}}})),e);function r(i){return ln(i,t.codec())}t.encode=r;function n(i,s){return un(i,t.codec(),s)}t.decode=n;function o(i,s){return hn(i,t.codec(),s)}t.stream=o})(ni||(ni={}));var Oc=ir(me("node:crypto"),1);var mn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(zr(e),je(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("expected Hash instance");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),mr(o)}update(e){return Vt(this),this.iHash.update(e),this}digestInto(e){Vt(this),$r(e,this),this.finished=!0;let r=e.subarray(0,this.outputLen);this.iHash.digestInto(r),this.oHash.update(r),this.oHash.digestInto(r),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});let{oHash:r,iHash:n,finished:o,destroyed:i,blockLen:s,outputLen:a,canXOF:c}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=a,e.canXOF=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ic=(()=>{let t=((e,r,n)=>new mn(e,r).update(n).digest());return t.create=(e,r)=>new mn(e,r),t})();var Qd=BigInt(0),oi=class extends Error{constructor(e=""){super(e)}},dt={Err:oi,_tlv:{encode:(t,e)=>{let{Err:r}=dt;if(Yt(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(Hs(e,"data"),e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=yr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?yr(o.length/2|128):"";return yr(t)+i+o+e},decode(t,e){let{Err:r}=dt;e=X(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.decode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let c=o&127;if(!c)throw new r("tlv.decode(long): indefinite length not supported");if(c>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+c);if(u.length!==c)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let l of u)s=s<<8|l;if(n+=c,s<128)throw new r("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+s)}}},_int:{encode(t){let{Err:e}=dt;if(Qr(t),t<Qd)throw new e("integer: negative integers are not allowed");let r=yr(t);if(Number.parseInt(r[0],16)&8&&(r="00"+r),r.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return r},decode(t){let{Err:e}=dt;if(t.length<1)throw new e("invalid signature integer: empty");if(t[0]&128)throw new e("invalid signature integer: negative");if(t.length>1&&t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return Ge(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=dt,o=X(t,void 0,"signature"),{v:i,l:s}=n.decode(48,o);if(s.length)throw new e("invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,i),{v:u,l}=n.decode(2,c);if(l.length)throw new e("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(u)}},hexFromSig(t){let{_tlv:e,_int:r}=dt;St(t,{r:"bigint",s:"bigint"},{},"sig");let n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}},ii=(Object.freeze(dt._tlv),Object.freeze(dt._int),Object.freeze(dt));var Sc=(t,e)=>(t+(t>=0?e:-e)/vc)/e;function Jd(t,e,r){To("scalar",t,lt,r);let[[n,o],[i,s]]=e,a=Sc(s*t,r),c=Sc(-o*t,r),u=t-a*n-c*i,l=-a*o-c*s,d=u<lt,f=l<lt;d&&(u=-u),f&&(l=-l);let h=wr(Math.ceil(Gt(r)/2))+Ut;if(u<lt||u>=h||l<lt||l>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:d,k1:u,k2neg:f,k2:l}}function ai(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function si(t,e){St(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return Ye(r.lowS,"lowS"),Ye(r.prehash,"prehash"),r.format!==void 0&&ai(r.format),r}var lt=BigInt(0),Ut=BigInt(1),vc=BigInt(2),ci=BigInt(3),el=BigInt(4);function Bc(t,e={}){let r=ac("weierstrass",t,e),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:a}=i;St(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",randomBytes:"function"});let{endo:c,allowInfinityPoint:u}=e,l=e.randomBytes===void 0?Zr:e.randomBytes;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let d=Cc(n,o);function f(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function h(P,m,S){if(u&&m.is0())return Uint8Array.of(0);let{x:L,y:O}=m.toAffine(),b=n.toBytes(L);if(Ye(S,"isCompressed"),S){f();let g=!n.isOdd(O);return ut(Ac(g),b)}else return ut(Uint8Array.of(4),b,n.toBytes(O))}function p(P){X(P,void 0,"Point");let{publicKey:m,publicKeyUncompressed:S}=d,L=P.length,O=P[0],b=P.subarray(1);if(u&&L===1&&O===0)return{x:n.ZERO,y:n.ZERO};if(L===m&&(O===2||O===3)){let g=n.fromBytes(b);if(!n.isValid(g))throw new Error("bad point: is not on curve, wrong x");let E=q(g),v;try{v=n.sqrt(E)}catch(M){let R=M instanceof Error?": "+M.message:"";throw new Error("bad point: is not on curve, sqrt error"+R)}f();let D=n.isOdd(v);return(O&1)===1!==D&&(v=n.neg(v)),{x:g,y:v}}else if(L===S&&O===4){let g=n.BYTES,E=n.fromBytes(b.subarray(0,g)),v=n.fromBytes(b.subarray(g,g*2));if(!F(E,v))throw new Error("bad point: is not on curve");return{x:E,y:v}}else throw new Error(`bad point: got length ${L}, expected compressed=${m} or uncompressed=${S}`)}let w=e.toBytes===void 0?h:e.toBytes,I=e.fromBytes===void 0?p:e.fromBytes,x=n.mul(i.b,ci),C=n.is0(i.a)?P=>n.ZERO:P=>n.mul(i.a,P);function q(P){let m=n.sqr(P),S=n.mul(m,P);return n.add(n.add(S,n.mul(P,i.a)),i.b)}function F(P,m){let S=n.sqr(m),L=q(P);return n.eql(S,L)}if(!F(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let H=n.mul(n.pow(i.a,ci),el),k=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(H,k)))throw new Error("bad curve params: a or b");function W(P,m,S=!1){if(!n.isValid(m)||S&&n.is0(m))throw new Error(`bad point coordinate ${P}`);return m}function Q(P){if(!(P instanceof _))throw new Error("Weierstrass Point expected")}function ge(P){if(!c||!c.basises)throw new Error("no endo");return Jd(P,c.basises,o.ORDER)}function K(P,m,S,L){if(!o.isValid(L))throw new RangeError("invalid scalar: out of range");if(c){let{k1neg:O,k1:b,k2neg:g,k2:E}=ge(L),v=new _(n.mul(S.X,c.beta),S.Y,S.Z);P.push(O?S.negate():S,g?v.negate():v),m.push(b,E)}else P.push(S),m.push(L)}let ce=new WeakSet;class _{static BASE=new _(i.Gx,i.Gy,n.ONE);static ZERO=new _(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(m,S,L){this.X=W("x",m),this.Y=W("y",S,!0),this.Z=W("z",L),Object.freeze(this)}static CURVE(){return i}static fromAffine(m){let{x:S,y:L}=m||{};if(!m||!n.isValid(S)||!n.isValid(L))throw new Error("invalid affine point");if(m instanceof _)throw new Error("projective point not allowed");return n.is0(S)&&n.is0(L)?_.ZERO:new _(S,L,n.ONE)}static fromBytes(m){let S=_.fromAffine(I(X(m,void 0,"point")));return S.assertValidity(),S}static fromHex(m){return _.fromBytes(Xr(m))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(m=6,S=!0){return Ze.setWindowSize(this,m),S||this.multiply(ci),this}assertValidity(){let m=this;if(m.is0()){if(e.allowInfinityPoint&&n.is0(m.X)&&n.eql(m.Y,n.ONE)&&n.is0(m.Z))return;throw new Error("bad point: ZERO")}if(ce.has(m))return;let{x:S,y:L}=m.toAffine();if(!n.isValid(S)||!n.isValid(L))throw new Error("bad point: x or y not field elements");if(!F(S,L))throw new Error("bad point: equation left != right");if(!m.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");ce.add(m)}hasEvenY(){let{y:m}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(m)}equals(m){Q(m);let{X:S,Y:L,Z:O}=this,{X:b,Y:g,Z:E}=m,v=n.eql(n.mul(S,E),n.mul(b,O)),D=n.eql(n.mul(L,E),n.mul(g,O));return v&&D}negate(){return new _(this.X,n.neg(this.Y),this.Z)}double(){let{X:m,Y:S,Z:L}=this,O=n.ZERO,b=n.ZERO,g=n.ZERO,E=n.mul(m,m),v=n.mul(S,S),D=n.mul(L,L),T=n.mul(m,S);return T=n.add(T,T),g=n.mul(m,L),g=n.add(g,g),O=C(g),b=n.mul(x,D),b=n.add(O,b),O=n.sub(v,b),b=n.add(v,b),b=n.mul(O,b),O=n.mul(T,O),g=n.mul(x,g),D=C(D),T=n.sub(E,D),T=C(T),T=n.add(T,g),g=n.add(E,E),E=n.add(g,E),E=n.add(E,D),E=n.mul(E,T),b=n.add(b,E),D=n.mul(S,L),D=n.add(D,D),E=n.mul(D,T),O=n.sub(O,E),g=n.mul(D,v),g=n.add(g,g),g=n.add(g,g),new _(O,b,g)}add(m){Q(m);let{X:S,Y:L,Z:O}=this,{X:b,Y:g,Z:E}=m,v=n.ZERO,D=n.ZERO,T=n.ZERO,M=n.mul(S,b),R=n.mul(L,g),Y=n.mul(O,E),he=n.add(S,L),$=n.add(b,g);he=n.mul(he,$),$=n.add(M,R),he=n.sub(he,$),$=n.add(S,O);let oe=n.add(b,E);return $=n.mul($,oe),oe=n.add(M,Y),$=n.sub($,oe),oe=n.add(L,O),v=n.add(g,E),oe=n.mul(oe,v),v=n.add(R,Y),oe=n.sub(oe,v),T=C($),v=n.mul(x,Y),T=n.add(v,T),v=n.sub(R,T),T=n.add(R,T),D=n.mul(v,T),R=n.add(M,M),R=n.add(R,M),Y=C(Y),$=n.mul(x,$),R=n.add(R,Y),Y=n.sub(M,Y),Y=C(Y),$=n.add($,Y),M=n.mul(R,$),D=n.add(D,M),M=n.mul(oe,$),v=n.mul(he,v),v=n.sub(v,M),M=n.mul(he,R),T=n.mul(oe,T),T=n.add(T,M),new _(v,D,T)}subtract(m){return Q(m),this.add(m.negate())}is0(){return this.equals(_.ZERO)}multiply(m){if(!o.isValidNot0(m))throw new RangeError("invalid scalar: out of range");let{p:S,f:L}=Ze.mulSecret(this,m,s,rr);return rr([S,L])[0]}multiplyUnsafe(m){let S=this,L=m;if(!o.isValid(L))throw new RangeError("invalid scalar: out of range");if(L===lt||S.is0())return _.ZERO;if(L===Ut)return S;if(Ze.hasWindowSize(this))return Ze.mulUnsafe(S,L,rr);let O=[],b=[];return K(O,b,S,L),on(_,O,b)}mulAddUnsafe(m,S,L){Q(S);let O=[],b=[];return K(O,b,this,m),K(O,b,S,L),on(_,O,b)}toAffine(m){let S=this,L=m;if(L!=null&&!n.isValid(L))throw new RangeError('"invertedZ" expected valid field element');let{X:O,Y:b,Z:g}=S;if(n.eql(g,n.ONE))return{x:O,y:b};let E=S.is0();L==null&&(L=E?n.ONE:n.inv(g));let v=n.mul(O,L),D=n.mul(b,L),T=n.mul(g,L);if(E)return{x:n.ZERO,y:n.ZERO};if(!n.eql(T,n.ONE))throw new Error("invZ was invalid");return{x:v,y:D}}isTorsionFree(){let{isTorsionFree:m}=e;return s===Ut?!0:m?m(_,this):Ze.mulUnsafe(this,a).is0()}clearCofactor(){let{clearCofactor:m}=e;return s===Ut?this:m?m(_,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===Ut?this.is0():this.clearCofactor().is0()}toBytes(m=!0){return Ye(m,"isCompressed"),this.assertValidity(),w(_,this,m)}toHex(m=!0){return Bo(this.toBytes(m))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let rr=P=>ic(_,P),Ze=new nn(_,l);return Ze.bits>=6&&_.BASE.precompute(6),Object.freeze(_.prototype),Object.freeze(_),_}function Ac(t){return Uint8Array.of(t?2:3)}function Cc(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function tl(t,e={}){Zt(t);let{Fn:r}=t,n=e.randomBytes===void 0?Zr:e.randomBytes,o=Object.assign(Cc(t.Fp,r),{seed:Math.max(tn(r.ORDER),16)});function i(h){try{let p=r.fromBytes(h);return r.isValidNot0(p)}catch{return!1}}function s(h,p){let{publicKey:w,publicKeyUncompressed:I}=o;try{let x=h.length;return p===!0&&x!==w||p===!1&&x!==I?!1:!!t.fromBytes(h)}catch{return!1}}function a(h){return h=h===void 0?n(o.seed):h,rn(X(h,o.seed,"seed"),r.ORDER)}function c(h,p=!0){return t.BASE.multiply(r.fromBytes(h)).toBytes(p)}function u(h){let{secretKey:p,publicKey:w,publicKeyUncompressed:I}=o,x=r._lengths;if(!jt(h))return;let C=X(h,void 0,"key").length,q=C===w||C===I,F=C===p||!!x?.includes(C);if(!(q&&F))return q}function l(h,p,w=!0){if(u(h)===!0)throw new Error("first arg must be private key");if(u(p)===!1)throw new Error("second arg must be public key");let I=r.fromBytes(h);return t.fromBytes(p).multiply(I).toBytes(w)}let d={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:a},f=uc(a,c);return Object.freeze(d),Object.freeze(o),Object.freeze({getPublicKey:c,getSharedSecret:l,keygen:f,Point:t,utils:d,lengths:o})}function Lc(t,e,r={}){Zt(t);let n=e;zr(n),St(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});let o=Object.assign({},r),i=o.randomBytes===void 0?Zr:o.randomBytes,s=o.hmac===void 0?(b,g)=>Ic(n,b,g):o.hmac,{Fp:a,Fn:c}=t,{ORDER:u,BITS:l}=c,d=tn(u),f=Fo(i,d),{keygen:h,getPublicKey:p,getSharedSecret:w,utils:I,lengths:x}=tl(t,o),C={prehash:!0,lowS:typeof o.lowS=="boolean"?o.lowS:!0,format:"compact",extraEntropy:!1},q=u*vc+Ut<a.ORDER;function F(b){let g=u>>Ut;return b>g}function H(b,g){if(!c.isValidNot0(g))throw new Error(`invalid signature ${b}: out of range 1..Point.Fn.ORDER`);return g}function k(){if(!a.isOdd)throw new Error("Field doesn't support isOdd")}function W(b,g,E){return k(),(b===E?0:2)|Number(a.isOdd(g))}function Q(){if(q)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function ge(b,g){ai(g);let E=x.signature,v=g==="compact"?E:g==="recovered"?E+1:void 0;return X(b,v)}class K{r;s;recovery;constructor(g,E,v){if(this.r=H("r",g),this.s=H("s",E),v!=null){if(Q(),![0,1,2,3].includes(v))throw new Error("invalid recovery id");this.recovery=v}Object.freeze(this)}static fromBytes(g,E=C.format){ge(g,E);let v;if(E==="der"){let{r:R,s:Y}=ii.toSig(X(g));return new K(R,Y)}E==="recovered"&&(v=g[0],E="compact",g=g.subarray(1));let D=x.signature/2,T=g.subarray(0,D),M=g.subarray(D,D*2);return new K(c.fromBytes(T),c.fromBytes(M),v)}static fromHex(g,E){return this.fromBytes(Xr(g),E)}assertRecovery(){let{recovery:g}=this;if(g==null)throw new Error("invalid recovery id: must be present");return g}addRecoveryBit(g){return new K(this.r,this.s,g)}recoverPublicKey(g){let{r:E,s:v}=this,D=this.assertRecovery(),T=D===2||D===3?E+u:E;if(!a.isValid(T))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let M=a.toBytes(T),R=t.fromBytes(ut(Ac((D&1)===0),M)),Y=c.inv(T),he=_(X(g,void 0,"msgHash")),$=c.create(-he*Y),oe=c.create(v*Y),Ne=t.BASE.mulAddUnsafe($,R,oe);if(Ne.is0())throw new Error("invalid recovery: point at infinify");return Ne.assertValidity(),Ne}hasHighS(){return F(this.s)}toBytes(g=C.format){if(ai(g),g==="der")return Xr(ii.hexFromSig(this));let{r:E,s:v}=this,D=c.toBytes(E),T=c.toBytes(v);return g==="recovered"?(Q(),ut(Uint8Array.of(this.assertRecovery()),D,T)):ut(D,T)}toHex(g){return Bo(this.toBytes(g))}}Object.freeze(K.prototype),Object.freeze(K);let ce=o.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let E=Ge(g),v=g.length*8-l;return v>0?E>>BigInt(v):E}:o.bits2int,_=o.bits2int_modN===void 0?function(g){return c.create(ce(g))}:o.bits2int_modN,rr=wr(l);function Ze(b){return To("num < 2^"+l,b,lt,rr),c.toBytes(b)}function P(b,g){return X(b,void 0,"message"),g?X(n(b),void 0,"prehashed message"):b}function m(b,g,E){let{lowS:v,prehash:D,extraEntropy:T}=si(E,C);b=P(b,D);let M=_(b),R=c.fromBytes(g);if(!c.isValidNot0(R))throw new Error("invalid private key");let Y=[Ze(R),Ze(M)];if(T!=null&&T!==!1){let Ne=T===!0?i(x.secretKey):T;Y.push(X(Ne,void 0,"extraEntropy"))}let he=ut(...Y),$=M;function oe(Ne){let Rt=ce(Ne);if(!c.isValidNot0(Rt))return;let nr=t.BASE.multiply(Rt).toAffine(),ft=c.create(nr.x);if(ft===lt)return;let Fe;if(f!==void 0){let or=Ge(rn(f(d),u)),ha=c.inv(c.mul(or,Rt)),pa=c.mul(or,$),fa=c.mul(or,R);Fe=c.create(ha*c.create(pa+fa*ft))}else{let or=Qs(Rt,u);Fe=c.create(or*c.create($+ft*R))}if(Fe===lt)return;let Cn=W(nr.x,nr.y,ft),Bi=Fe;return v&&F(Fe)&&(Bi=c.neg(Fe),Cn^=1),new K(ft,Bi,q?void 0:Cn)}return{seed:he,k2sig:oe}}function S(b,g,E={}){let{seed:v,k2sig:D}=m(b,g,E);return zs(n.outputLen,c.BYTES,s)(v,D).toBytes(E.format)}function L(b,g,E,v={}){let{lowS:D,prehash:T,format:M}=si(v,C);if(E=X(E,void 0,"publicKey"),g=P(g,T),!jt(b)){let R=b instanceof K?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+R)}ge(b,M);try{let R=K.fromBytes(b,M),Y=t.fromBytes(E);if(D&&R.hasHighS())return!1;let{r:he,s:$}=R,oe=_(g),Ne=c.inv($),Rt=c.create(oe*Ne),nr=c.create(he*Ne),ft=t.BASE.mulAddUnsafe(Rt,Y,nr);if(ft.is0())return!1;let Fe=ft.toAffine();return!(c.create(Fe.x)!==he||M==="recovered"&&R.recovery!==W(Fe.x,Fe.y,he))}catch{return!1}}function O(b,g,E={}){let{prehash:v}=si(E,C);return g=P(g,v),K.fromBytes(b,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:h,getPublicKey:p,getSharedSecret:w,utils:I,lengths:x,Point:t,sign:S,verify:L,recoverPublicKey:O,Signature:K,hash:n})}var di={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},rl={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Tc=BigInt(2);function nl(t){let e=di.p,r=BigInt(3),n=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),c=BigInt(88),u=t*t*t%e,l=u*u*t%e,d=ve(l,r,e)*l%e,f=ve(d,r,e)*l%e,h=ve(f,Tc,e)*u%e,p=ve(h,o,e)*h%e,w=ve(p,i,e)*p%e,I=ve(w,a,e)*w%e,x=ve(I,c,e)*I%e,C=ve(x,a,e)*w%e,q=ve(C,r,e)*l%e,F=ve(q,s,e)*p%e,H=ve(F,n,e)*u%e,k=ve(H,Tc,e);if(!ui.eql(ui.sqr(k),t))throw new Error("Cannot find square root");return k}var ui=Xt(di.p,{sqrt:nl}),ol=Bc(di,{Fp:ui,endo:rl}),Ar=Lc(ol,Ks);var yn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Dc(t,e,r,n){n?.signal?.throwIfAborted();let o=Oc.default.createHash("sha256");if(r instanceof Uint8Array)o.update(r);else for(let s of r)o.update(s);let i=o.digest();try{return Ar.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new yn(String(s))}}var wn=class{type="secp256k1";raw;_key;constructor(e){this._key=_c(e),this.raw=Uc(this._key)}toMultihash(){return Ue.digest($t(this))}toCID(){return re.createV1(114,this.toMultihash())}toString(){return G.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:fe(this.raw,e.raw)}verify(e,r,n){return Dc(this._key,r,e,n)}};function Pc(t){return new wn(t)}function Uc(t){return Ar.Point.fromBytes(t).toBytes()}function _c(t){try{return Ar.Point.fromBytes(t),t}catch(e){throw new Ur(String(e))}}function Rc(t){let{Type:e,Data:r}=Br.decode(t.digest),n=r??new Uint8Array;switch(e){case le.Ed25519:return pc(n);case le.secp256k1:return Pc(n);case le.ECDSA:return Bs(n);default:throw new sr}}function $t(t){return Br.encode({Type:le[t.type],Data:t.raw})}var Nc=Symbol.for("nodejs.util.inspect.custom"),il=114,Cr=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()})`}[Ln]=!0;toString(){return this.string==null&&(this.string=G.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return re.createV1(il,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return fe(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return fe(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Nc](){return`PeerId(${this.toString()})`}},bn=class extends Cr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},xn=class extends Cr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},En=class extends Cr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},sl=2336,Lr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Ue.digest(de(this.url))}[Nc](){return`PeerId(${this.url})`}[Ln]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return re.createV1(sl,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=j(e)),e.toString()===this.toString())}};var cl=114,Fc=2336;function kc(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=lr(G.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return al(re.parse(t));if(e==null)throw new Le('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=lr(e.decode(t))}return Kc(r)}function Kc(t){if(dl(t))return new bn({multihash:t});if(ul(t))try{let e=Rc(t);if(e.type==="Ed25519")return new xn({multihash:t,publicKey:e});if(e.type==="secp256k1")return new En({multihash:t,publicKey:e})}catch{let r=j(t.digest);return new Lr(new URL(r))}throw new Pr("Supplied PeerID Multihash is invalid")}function al(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==cl&&t.code!==Fc)throw new _r("Supplied PeerID CID is invalid");if(t.code===Fc){let e=j(t.multihash.digest);return new Lr(new URL(e))}return Kc(t.multihash)}function ul(t){return t.code===Ue.code}function dl(t){return t.code===lo.code}function ll(t){let e=t.getComponents(),r={},n=0;return e[n]?.name==="ip6zone"&&(r.zone=`${e[n].value}`,n++),e[n]?.name==="ip4"||e[n]?.name==="ip6"||e[n]?.name==="dns"||e[n]?.name==="dns4"||e[n]?.name==="dns6"?(r.type=e[n].name,r.host=e[n].value,n++):e[n]?.name==="dnsaddr"&&(r.type=e[n].name,r.host=`_dnsaddr.${e[n].value}`,n++),(e[n]?.name==="tcp"||e[n]?.name==="udp")&&(r.protocol=e[n].name==="tcp"?"tcp":"udp",r.port=parseInt(`${e[n].value}`),n++),e[n]?.name==="ipcidr"&&(r.type==="ip4"?r.cidr=parseInt(`${e[n].value}`):r.type==="ip6"&&(r.cidr=`${e[n].value}`),n++),r.type==null||r.host==null?null:(e[n]?.name==="tls"&&e[n+1]?.name==="sni"&&(r.sni=e[n+1].value,n+=2),r)}function Mc(t){let e=ll(t);if(e==null)throw new Le(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Ae=me("node:net");var $c=ir(zc(),1),wl=["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"],bl=wl.map(t=>new $c.Netmask(t));function yi(t){for(let e of bl)if(e.contains(t))return!0;return!1}function xl(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function El(t){let e=t.split(":");if(e.length<2)return!1;let r=e[e.length-1].padStart(4,"0"),n=e[e.length-2].padStart(4,"0"),o=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}`;return yi(o)}function Il(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function Sl(t){let e=t.split(":"),r=e[e.length-1];return yi(r)}function vl(t){return/^::$/.test(t)||/^::1$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t)}function Vc(t){if((0,Ae.isIPv4)(t))return yi(t);if(xl(t))return El(t);if(Il(t))return Sl(t);if((0,Ae.isIPv6)(t))return vl(t)}function jc(t){try{let e=Mc(t);switch(e.type){case"ip4":case"ip6":return Vc(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var ne=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ht=class extends Error{static name="ValidationError";name="ValidationError"},Sn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},vn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function bi(t){return e=>j(e,t)}function xi(t){return e=>de(e,t)}function tr(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function Pt(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function Yc(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let r=de(e[0],"base32"),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Pt(n);return _e([r,o],r.length+o.length)}function Gc(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=yt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Pt(n);return _e([r,o],r.length+o.length)}function Ei(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=j(e,"base32"),o=tr(r);return`${n}:${o}`}var Ii=function(t){t=t.toString().trim();let e=new Uint8Array(4);return t.split(/\./g).forEach((r,n)=>{let o=parseInt(r,10);if(isNaN(o)||o<0||o>255)throw new ne("Invalid byte value in IP address");e[n]=o}),e},Wc=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,Ae.isIPv4)(r[n]),s;i&&(s=Ii(r[n]),r[n]=j(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,j(s.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new ne("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},Xc=function(t){if(t.byteLength!==4)throw new ne("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},Zc=function(t){if(t.byteLength!==16)throw new ne("IPv6 address was incorrect length");let e=[];for(let n=0;n<t.byteLength;n+=2){let o=t[n],i=t[n+1],s=`${o.toString(16).padStart(2,"0")}${i.toString(16).padStart(2,"0")}`;e.push(s)}let r=e.join(":");try{let n=new URL(`http://[${r}]`);return n.hostname.substring(1,n.hostname.length-1)}catch{throw new ne(`Invalid IPv6 address "${r}"`)}};function Qc(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new ne(`Invalid IPv6 address "${t}"`)}}var wi=Object.values(pr).map(t=>t.decoder),Bl=(function(){let t=wi[0].or(wi[1]);return wi.slice(2).forEach(e=>t=t.or(e)),t})();function Jc(t){return Bl.decode(t)}function ea(t){return e=>t.encoder.encode(e)}function Al(t){if(parseInt(t).toString()!==t)throw new ht("Value must be an integer")}function Cl(t){if(t<0)throw new ht("Value must be a positive integer, or zero")}function Ll(t){return e=>{if(e>t)throw new ht(`Value must be smaller than or equal to ${t}`)}}function Tl(...t){return e=>{for(let r of t)r(e)}}var Tr=Tl(Al,Cl,Ll(65535));var ee=-1,Si=class{protocolsByCode=new Map;protocolsByName=new Map;getProtocol(e){let r;if(typeof e=="string"?r=this.protocolsByName.get(e):r=this.protocolsByCode.get(e),r==null)throw new vn(`Protocol ${e} was unknown`);return r}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(r=>{this.protocolsByName.set(r,e)})}removeProtocol(e){let r=this.protocolsByCode.get(e);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},pt=new Si,gh=[{code:4,name:"ip4",size:32,valueToBytes:Ii,bytesToValue:Xc,validate:t=>{if(!(0,Ae.isIPv4)(t))throw new ht(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Tr},{code:273,name:"udp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Tr},{code:33,name:"dccp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Tr},{code:41,name:"ip6",size:128,valueToBytes:Wc,bytesToValue:Zc,stringToValue:Qc,validate:t=>{if(!(0,Ae.isIPv6)(t))throw new ht(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:ee},{code:43,name:"ipcidr",size:8,bytesToValue:bi("base10"),valueToBytes:xi("base10")},{code:53,name:"dns",size:ee},{code:54,name:"dns4",size:ee},{code:55,name:"dns6",size:ee},{code:56,name:"dnsaddr",size:ee},{code:132,name:"sctp",size:16,valueToBytes:Pt,bytesToValue:tr,validate:Tr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:ee,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:ee,bytesToValue:bi("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?xi("base58btc")(t):re.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:Ei,valueToBytes:Yc},{code:445,name:"onion3",size:296,bytesToValue:Ei,valueToBytes:Gc},{code:446,name:"garlic64",size:ee},{code:447,name:"garlic32",size:ee},{code:448,name:"tls"},{code:449,name:"sni",size:ee},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:ee,bytesToValue:ea(no),valueToBytes:Jc},{code:480,name:"http"},{code:481,name:"http-path",size:ee,stringToValue:t=>`/${decodeURIComponent(t)}`,valueToString:t=>encodeURIComponent(t.substring(1))},{code:443,name:"https"},{code:477,name:"ws"},{code:478,name:"wss"},{code:479,name:"p2p-websocket-star"},{code:277,name:"p2p-stardust"},{code:275,name:"p2p-webrtc-star"},{code:276,name:"p2p-webrtc-direct"},{code:280,name:"webrtc-direct"},{code:281,name:"webrtc"},{code:290,name:"p2p-circuit"},{code:777,name:"memory",size:ee}];gh.forEach(t=>{pt.addProtocol(t)});function ta(t){let e=[],r=0;for(;r<t.length;){let n=$o(t,r),o=pt.getProtocol(n),i=We(n),s=mh(o,t,r+i),a=0;s>0&&o.size===ee&&(a=We(s));let c=i+a+s,u={code:n,name:o.name,bytes:wt(t.subarray(r,r+c))};if(s>0){let l=r+i+a,d=t.subarray(l,l+s);u.value=o.bytesToValue?.(d)??j(d)}e.push(u),r+=c}return e}function ra(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=pt.getProtocol(n.code),i=We(n.code),s,a=0,c=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??de(n.value),a=s.byteLength,o.size===ee&&(c=We(a)));let u=new Uint8Array(i+c+a),l=0;Er(n.code,u,l),l+=i,s!=null&&(o.size===ee&&(Er(a,u,l),l+=c),u.set(s,l)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return _e(r,e)}function na(t){if(t.charAt(0)!=="/")throw new ne('String multiaddr must start with "/"');let e=[],r="protocol",n="",o="";for(let i=1;i<t.length;i++){let s=t.charAt(i);s!=="/"&&(r==="protocol"?o+=t.charAt(i):n+=t.charAt(i));let a=i===t.length-1;if(s==="/"||a){let c=pt.getProtocol(o);if(r==="protocol"){if(c.size==null||c.size===0){e.push({code:c.code,name:c.name}),n="",o="",r="protocol";continue}else if(a)throw new ne(`Component ${o} was missing value`);r="value"}else if(r==="value"){let u={code:c.code,name:c.name};if(c.size!=null&&c.size!==0){if(n==="")throw new ne(`Component ${o} was missing value`);u.value=c.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ne("Incomplete multiaddr");return e}function oa(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=pt.getProtocol(e.code);if(r==null)throw new ne(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function mh(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:$o(e,r)}var yh=Symbol.for("nodejs.util.inspect.custom"),vi=Symbol.for("@multiformats/multiaddr");function wh(t){if(t==null&&(t="/"),ia(t))return t.getComponents();if(t instanceof Uint8Array)return ta(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),na(t);if(Array.isArray(t))return t;throw new ne("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Bn=class t{[vi]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=wh(e),r.validate!==!1&&bh(this)}get bytes(){return this.#r==null&&(this.#r=ra(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=oa(this.#e)),this.#t}toJSON(){return this.toString()}getComponents(){return[...this.#e.map(e=>({...e}))]}encapsulate(e){let r=new t(e);return new t([...this.#e,...r.getComponents()],{validate:!1})}decapsulate(e){let r=e.toString(),n=this.toString(),o=n.lastIndexOf(r);if(o<0)throw new Sn(`Address ${this.toString()} does not contain subaddress: ${r}`);return new t(n.slice(0,o),{validate:!1})}decapsulateCode(e){let r;for(let n=this.#e.length-1;n>-1;n--)if(this.#e[n].code===e){r=n;break}return new t(this.#e.slice(0,r),{validate:!1})}equals(e){return fe(this.bytes,e.bytes)}[yh](){return`Multiaddr(${this.toString()})`}};function bh(t){t.getComponents().forEach(e=>{let r=pt.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function ia(t){return!!t?.[vi]}function sa(t){return new Bn(t)}function ca(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function aa(t,e,r,n){if(t.answers==null)return;let o,i=[];if(t.answers.forEach(s=>{switch(s.type){case"PTR":o=s;break;case"TXT":i.push(s);break;default:break}}),t.additionals.forEach(s=>{s.type==="TXT"&&i.push(s)}),!(o==null||o?.name!==r||i.length===0||o.data.startsWith(e)))try{let s=i.flatMap(c=>c.data).filter(c=>c.toString().startsWith("dnsaddr=")).map(c=>sa(c.toString().substring(8))),a=s[0].getComponents().findLast(c=>c.code===421)?.value;if(a==null)throw new Error("Multiaddr doesn't contain PeerId");return n?.log("peer found %p",a),{id:kc(a),multiaddrs:s.map(c=>c.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response - %e",s)}}function ua(t,e,r,n,o,i,s){if(!i){s?.log("not responding to mDNS query as broadcast mode is false");return}if(n.length!==0&&t.questions[0]!=null&&t.questions[0].name===o){let a=[];a.push({name:o,type:"PTR",class:"IN",ttl:120,data:r+"."+o}),n.filter(xh).forEach(c=>{let u="dnsaddr="+c.toString();if(u.length>255){s?.log("multiaddr %a is too long to use in mDNS query response",c);return}if(c.getComponents().findLast(l=>l.code===421)?.value==null){s?.log("multiaddr %a did not have a peer ID so cannot be used in mDNS query response",c);return}a.push({name:r+"."+o,type:"TXT",class:"IN",ttl:120,data:u})}),s?.log.trace("responding to query"),e.respond(a)}}function xh(t){return!!jc(t)}function da(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var An=class extends Rr{mdns;log;broadcast;interval;serviceTag;peerName;port;ip;_queryInterval;components;constructor(e,r={}){if(super(),this.log=e.logger.forComponent("libp2p:mdns"),this.broadcast=r.broadcast!==!1,this.interval=r.interval??1e3*10,this.serviceTag=r.serviceTag??"_p2p._udp.local",this.ip=r.ip??"224.0.0.251",this.peerName=r.peerName??da(63),this.peerName.length>=64)throw new Error("Peer name should be less than 64 chars long");this.port=r.port??5353,this.components=e,this._queryInterval=null,this._onMdnsQuery=this._onMdnsQuery.bind(this),this._onMdnsResponse=this._onMdnsResponse.bind(this),this._onMdnsWarning=this._onMdnsWarning.bind(this),this._onMdnsError=this._onMdnsError.bind(this)}[Ci]=this;[Symbol.toStringTag]="@libp2p/mdns";[Di]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,la.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=ca(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),ua(e,this.mdns,this.peerName,this.components.addressManager.getAddresses(),this.serviceTag,this.broadcast,{log:this.log}))}_onMdnsResponse(e){this.log.trace("received mDNS query response");try{let r=aa(e,this.peerName,this.serviceTag,{log:this.log});r!=null&&(this.log("discovered peer in mDNS query response %p",r.id),this.dispatchEvent(new CustomEvent("peer",{detail:r})))}catch(r){this.log.error("error processing peer response - %e",r)}}_onMdnsWarning(e){this.log.error("mdns warning - %e",e)}_onMdnsError(e){this.log.error("mdns error - %e",e)}async stop(){this.mdns!=null&&(this.mdns.removeListener("query",this._onMdnsQuery),this.mdns.removeListener("response",this._onMdnsResponse),this.mdns.removeListener("warning",this._onMdnsWarning),this.mdns.removeListener("error",this._onMdnsError),this._queryInterval!=null&&(clearInterval(this._queryInterval),this._queryInterval=null),await new Promise(e=>{this.mdns!=null?this.mdns.destroy(e):e()}),this.mdns=void 0)}};function Ih(t={}){return e=>new An(e,t)}return xa(Sh);})();
|
|
3
3
|
/*! Bundled license information:
|
|
4
4
|
|
|
5
5
|
@noble/curves/utils.js:
|