@libp2p/mdns 12.0.23-b7c6dc0f2 → 12.0.24-a34745c01

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PMdns = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PMdns=(()=>{var Iu=Object.create;var Vr=Object.defineProperty;var Au=Object.getOwnPropertyDescriptor;var Bu=Object.getOwnPropertyNames;var Cu=Object.getPrototypeOf,Lu=Object.prototype.hasOwnProperty;var G=(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 ve=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),V=(t,e)=>{for(var r in e)Vr(t,r,{get:e[r],enumerable:!0})},ds=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Bu(e))!Lu.call(t,o)&&o!==r&&Vr(t,o,{get:()=>e[o],enumerable:!(n=Au(e,o))||n.enumerable});return t};var Nt=(t,e,r)=>(r=t!=null?Iu(Cu(t)):{},ds(e||!t||!t.__esModule?Vr(r,"default",{value:t,enumerable:!0}):r,t)),Du=t=>ds(Vr({},"__esModule",{value:!0}),t);var ms=ve(Mn=>{"use strict";Mn.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};Mn.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 gs=ve(qn=>{"use strict";qn.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};qn.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 ys=ve(Vn=>{"use strict";Vn.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};Vn.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 bs=ve(zn=>{"use strict";zn.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};zn.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 xs=ve(Hn=>{"use strict";Hn.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}`};Hn.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 vs=ve((Es,$n)=>{var ws=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=l,t.encode=p,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,d){d=~~d,h=h||new Uint8Array(d+r);let m=f.length,x=0;for(let v=0;v<m;){let C=f.charCodeAt(v++);C===46?(h[d++]=x,x=0):x=x*10+(C-48)}return h[d]=x,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,d){d=~~d;let m=d+o,x=-1,v=0,C=0,R=!0,P=!1;h=h||new Uint8Array(d+o);for(let U=0;U<f.length;U++){let F=f.charCodeAt(U);F===58?(R?x!==-1?(d<m&&(h[d]=0),d<m-1&&(h[d+1]=0),d+=2):d<m&&(x=d):(P===!0?(d<m&&(h[d]=C),d++):(d<m&&(h[d]=v>>8),d<m-1&&(h[d+1]=v&255),d+=2),v=0,C=0),R=!0,P=!1):F===46?(d<m&&(h[d]=C),d++,C=0,v=0,R=!1,P=!0):(R=!1,F>=97?F-=87:F>=65?F-=55:(F-=48,C=C*10+F),v=(v<<4)+F)}if(R===!1)P===!0?(d<m&&(h[d]=C),d++):(d<m&&(h[d]=v>>8),d<m-1&&(h[d+1]=v&255),d+=2);else if(x===0)d<m&&(h[d]=0),d<m-1&&(h[d+1]=0),d+=2;else if(x!==-1){d+=2;for(let U=Math.min(d-1,m-1);U>=x+2;U--)h[U]=h[U-2];h[x]=0,h[x+1]=0,x=d}if(x!==d&&x!==-1)for(d>m-2&&(d=m-2);m>x;)h[--m]=d<m&&d>x?h[--d]:0;else for(;d<m;)h[d++]=0;return h},decode(f,h){h=~~h;let d="";for(let m=0;m<o;m+=2)m!==0&&(d+=":"),d+=(f[h+m]<<8|f[h+m+1]).toString(16);return d.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 p(f,h,d){d=~~d;let m=a(f);return typeof h=="function"&&(h=h(d+m)),m===i.size?i.encode(f,h,d):s.encode(f,h,d)}function l(f,h,d){if(h=~~h,d=d||f.length-h,d===i.size)return i.decode(f,h,d);if(d===s.size)return s.decode(f,h,d);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 ws}):typeof $n=="object"&&typeof Es=="object"&&($n.exports=ws)});var As=ve(A=>{"use strict";var B=G("buffer").Buffer,rt=ms(),Tu=gs(),_u=ys(),Gr=bs(),jn=xs(),wt=vs(),Pu=0,Ss=32768,Yn=32768,Nu=~Yn,Is=32768,Ru=~Is,y=A.name={};y.encode=function(t,e,r,{mail:n=!1}={}){e||(e=B.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:B.byteLength(t.replace(/^\.|\.$/gm,""))+2};var N={};N.encode=function(t,e,r){e||(e=B.alloc(N.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,N.encode.bytes=n+1,e};N.encode.bytes=0;N.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return N.decode.bytes=r+1,n};N.decode.bytes=0;N.encodingLength=function(t){return B.byteLength(t)+1};var Le={};Le.encode=function(t,e,r){e||(e=Le.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Ss:Pu;return e.writeUInt16BE(t.id||0,r),e.writeUInt16BE(n|o,r+2),e.writeUInt16BE(t.questions.length,r+4),e.writeUInt16BE(t.answers.length,r+6),e.writeUInt16BE(t.authorities.length,r+8),e.writeUInt16BE(t.additionals.length,r+10),e};Le.encode.bytes=12;Le.decode=function(t,e){if(e||(e=0),t.length<12)throw new Error("Header must be 12 bytes");let r=t.readUInt16BE(e+2);return{id:t.readUInt16BE(e),type:r&Ss?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:_u.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:Tu.toString(r&15),questions:new Array(t.readUInt16BE(e+4)),answers:new Array(t.readUInt16BE(e+6)),authorities:new Array(t.readUInt16BE(e+8)),additionals:new Array(t.readUInt16BE(e+10))}};Le.decode.bytes=12;Le.encodingLength=function(){return 12};var Ye=A.unknown={};Ye.encode=function(t,e,r){return e||(e=B.alloc(Ye.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),Ye.encode.bytes=t.length+2,e};Ye.encode.bytes=0;Ye.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return Ye.decode.bytes=r+2,n};Ye.decode.bytes=0;Ye.encodingLength=function(t){return t.length+2};var Ge=A.ns={};Ge.encode=function(t,e,r){return e||(e=B.alloc(Ge.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Ge.encode.bytes=y.encode.bytes+2,e};Ge.encode.bytes=0;Ge.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=y.decode(t,e+2);return Ge.decode.bytes=r+2,n};Ge.decode.bytes=0;Ge.encodingLength=function(t){return y.encodingLength(t)+2};var We=A.soa={};We.encode=function(t,e,r){e||(e=B.alloc(We.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),We.encode.bytes=r-n,e};We.encode.bytes=0;We.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mname=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,We.decode.bytes=e-r,n};We.decode.bytes=0;We.encodingLength=function(t){return 22+y.encodingLength(t.mname)+y.encodingLength(t.rname)};var Xe=A.txt={};Xe.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]=B.from(t[o])),!B.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=B.alloc(Xe.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),Xe.encode.bytes=r-n,e};Xe.encode.bytes=0;Xe.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 Xe.decode.bytes=e-r,o};Xe.decode.bytes=0;Xe.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=B.byteLength(r)+1:e+=r.length+1}),e};var Ze=A.null={};Ze.encode=function(t,e,r){e||(e=B.alloc(Ze.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=B.from(t)),t||(t=B.alloc(0));let n=r;r+=2;let o=t.length;return t.copy(e,r,0,o),r+=o,e.writeUInt16BE(r-n-2,n),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.decode=function(t,e){e||(e=0);let r=e,n=t.readUInt16BE(e);e+=2;let o=t.slice(e,e+n);return e+=n,Ze.decode.bytes=e-r,o};Ze.decode.bytes=0;Ze.encodingLength=function(t){return t?(B.isBuffer(t)?t.length:B.byteLength(t))+2:2};var Qe=A.hinfo={};Qe.encode=function(t,e,r){e||(e=B.alloc(Qe.encodingLength(t))),r||(r=0);let n=r;return r+=2,N.encode(t.cpu,e,r),r+=N.encode.bytes,N.encode(t.os,e,r),r+=N.encode.bytes,e.writeUInt16BE(r-n-2,n),Qe.encode.bytes=r-n,e};Qe.encode.bytes=0;Qe.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.cpu=N.decode(t,e),e+=N.decode.bytes,n.os=N.decode(t,e),e+=N.decode.bytes,Qe.decode.bytes=e-r,n};Qe.decode.bytes=0;Qe.encodingLength=function(t){return N.encodingLength(t.cpu)+N.encodingLength(t.os)+2};var Be=A.ptr={},Fu=A.cname=Be,ku=A.dname=Be;Be.encode=function(t,e,r){return e||(e=B.alloc(Be.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),Be.encode.bytes=y.encode.bytes+2,e};Be.encode.bytes=0;Be.decode=function(t,e){e||(e=0);let r=y.decode(t,e+2);return Be.decode.bytes=y.decode.bytes+2,r};Be.decode.bytes=0;Be.encodingLength=function(t){return y.encodingLength(t)+2};var Je=A.srv={};Je.encode=function(t,e,r){e||(e=B.alloc(Je.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),Je.encode.bytes=n+2,e};Je.encode.bytes=0;Je.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),Je.decode.bytes=r+2,n};Je.decode.bytes=0;Je.encodingLength=function(t){return 8+y.encodingLength(t.target)};var me=A.caa={};me.ISSUER_CRITICAL=128;me.encode=function(t,e,r){let n=me.encodingLength(t);return e||(e=B.alloc(me.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=me.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,N.encode(t.tag,e,r),r+=N.encode.bytes,e.write(t.value,r),r+=B.byteLength(t.value),me.encode.bytes=n,e};me.encode.bytes=0;me.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=N.decode(t,e),e+=N.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&me.ISSUER_CRITICAL),me.decode.bytes=r+2,o};me.decode.bytes=0;me.encodingLength=function(t){return N.encodingLength(t.tag)+N.encodingLength(t.value)+2};var dt=A.mx={};dt.encode=function(t,e,r){e||(e=B.alloc(dt.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),dt.encode.bytes=r-n,e};dt.encode.bytes=0;dt.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.preference=t.readUInt16BE(e),e+=2,n.exchange=y.decode(t,e),e+=y.decode.bytes,dt.decode.bytes=e-r,n};dt.encodingLength=function(t){return 4+y.encodingLength(t.exchange)};var et=A.a={};et.encode=function(t,e,r){return e||(e=B.alloc(et.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,wt.v4.encode(t,e,r),et.encode.bytes=6,e};et.encode.bytes=0;et.decode=function(t,e){e||(e=0),e+=2;let r=wt.v4.decode(t,e);return et.decode.bytes=6,r};et.decode.bytes=0;et.encodingLength=function(){return 6};var tt=A.aaaa={};tt.encode=function(t,e,r){return e||(e=B.alloc(tt.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,wt.v6.encode(t,e,r),tt.encode.bytes=18,e};tt.encode.bytes=0;tt.decode=function(t,e){e||(e=0),e+=2;let r=wt.v6.decode(t,e);return tt.decode.bytes=18,r};tt.decode.bytes=0;tt.encodingLength=function(){return 18};var pe=A.option={};pe.encode=function(t,e,r){e||(e=B.alloc(pe.encodingLength(t))),r||(r=0);let n=r,o=jn.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||wt.familyOf(t.ip),c=wt.encode(t.ip,B.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 p=t.tags.length*2;e.writeUInt16BE(p,r),r+=2;for(let l of t.tags)e.writeUInt16BE(l,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return 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=jn.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=B.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=wt.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(jn.toCode(t.code)){case 8:let r=t.sourcePrefixLength||0;return Math.ceil(r/8)+8;case 11:return typeof t.timeout=="number"?6:4;case 12:return t.length+4;case 14:return 4+t.tags.length*2}throw new Error(`Unknown roption code: ${t.code}`)};var ye=A.opt={};ye.encode=function(t,e,r){e||(e=B.alloc(ye.encodingLength(t))),r||(r=0);let n=r,o=Rt(t,pe);return e.writeUInt16BE(o,r),r=ur(t,pe,e,r+2),ye.encode.bytes=r-n,e};ye.encode.bytes=0;ye.decode=function(t,e){e||(e=0);let r=e,n=[],o=t.readUInt16BE(e);e+=2;let i=0;for(;o>0;)n[i++]=pe.decode(t,e),e+=pe.decode.bytes,o-=pe.decode.bytes;return ye.decode.bytes=e-r,n};ye.decode.bytes=0;ye.encodingLength=function(t){return 2+Rt(t||[],pe)};var de=A.dnskey={};de.PROTOCOL_DNSSEC=3;de.ZONE_KEY=128;de.SECURE_ENTRYPOINT=32768;de.encode=function(t,e,r){e||(e=B.alloc(de.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!B.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(de.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,de.encode.bytes=r-n,e.writeUInt16BE(de.encode.bytes-2,n),e};de.encode.bytes=0;de.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)!==de.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,de.decode.bytes=e-r,n};de.decode.bytes=0;de.encodingLength=function(t){return 6+B.byteLength(t.key)};var Pe=A.rrsig={};Pe.encode=function(t,e,r){e||(e=B.alloc(Pe.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!B.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(rt.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,Pe.encode.bytes=r-n,e.writeUInt16BE(Pe.encode.bytes-2,n),e};Pe.encode.bytes=0;Pe.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=rt.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,Pe.decode.bytes=e-r,n};Pe.decode.bytes=0;Pe.encodingLength=function(t){return 20+y.encodingLength(t.signersName)+B.byteLength(t.signature)};var Ne=A.rp={};Ne.encode=function(t,e,r){e||(e=B.alloc(Ne.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,Ne.encode.bytes=r-n,e.writeUInt16BE(Ne.encode.bytes-2,n),e};Ne.encode.bytes=0;Ne.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.mbox=y.decode(t,e,{mail:!0})||".",e+=y.decode.bytes,n.txt=y.decode(t,e)||".",e+=y.decode.bytes,Ne.decode.bytes=e-r,n};Ne.decode.bytes=0;Ne.encodingLength=function(t){return 2+y.encodingLength(t.mbox||".")+y.encodingLength(t.txt||".")};var Z={};Z.encode=function(t,e,r){e||(e=B.alloc(Z.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=rt.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=B.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return Z.encode.bytes=r-n,e};Z.encode.bytes=0;Z.decode=function(t,e,r){e||(e=0);let n=e;for(var o=[];e-n<r;){var i=t.readUInt8(e);e+=1;var s=t.readUInt8(e);e+=1;for(var c=0;c<s;c++)for(var a=t.readUInt8(e+c),u=0;u<8;u++)if(a&1<<7-u){var p=rt.toString(i<<8|c<<3|u);o.push(p)}e+=s}return Z.decode.bytes=e-n,o};Z.decode.bytes=0;Z.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=rt.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Re=A.nsec={};Re.encode=function(t,e,r){e||(e=B.alloc(Re.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.nextDomain,e,r),r+=y.encode.bytes,Z.encode(t.rrtypes,e,r),r+=Z.encode.bytes,Re.encode.bytes=r-n,e.writeUInt16BE(Re.encode.bytes-2,n),e};Re.encode.bytes=0;Re.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=y.decode(t,e),e+=y.decode.bytes,n.rrtypes=Z.decode(t,e,o-(e-r)),e+=Z.decode.bytes,Re.decode.bytes=e-r,n};Re.decode.bytes=0;Re.encodingLength=function(t){return 2+y.encodingLength(t.nextDomain)+Z.encodingLength(t.rrtypes)};var Fe=A.nsec3={};Fe.encode=function(t,e,r){e||(e=B.alloc(Fe.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!B.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!B.isBuffer(i))throw new Error("nextDomain must be a Buffer");return r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.flags,r),r+=1,e.writeUInt16BE(t.iterations,r),r+=2,e.writeUInt8(o.length,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,e.writeUInt8(i.length,r),r+=1,i.copy(e,r,0,i.length),r+=i.length,Z.encode(t.rrtypes,e,r),r+=Z.encode.bytes,Fe.encode.bytes=r-n,e.writeUInt16BE(Fe.encode.bytes-2,n),e};Fe.encode.bytes=0;Fe.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=Z.decode(t,e,o-(e-r)),e+=Z.decode.bytes,Fe.decode.bytes=e-r,n};Fe.decode.bytes=0;Fe.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+Z.encodingLength(t.rrtypes)};var ke=A.ds={};ke.encode=function(t,e,r){e||(e=B.alloc(ke.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!B.isBuffer(o))throw new Error("Digest must be a Buffer");return r+=2,e.writeUInt16BE(t.keyTag,r),r+=2,e.writeUInt8(t.algorithm,r),r+=1,e.writeUInt8(t.digestType,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,ke.encode.bytes=r-n,e.writeUInt16BE(ke.encode.bytes-2,n),e};ke.encode.bytes=0;ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.keyTag=t.readUInt16BE(e),e+=2,n.algorithm=t.readUInt8(e),e+=1,n.digestType=t.readUInt8(e),e+=1,n.digest=t.slice(e,r+o+2),e+=n.digest.length,ke.decode.bytes=e-r,n};ke.decode.bytes=0;ke.encodingLength=function(t){return 6+B.byteLength(t.digest)};var ge=A.sshfp={};ge.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ge.encode=function(e,r,n){r||(r=B.alloc(ge.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=B.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==ge.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,ge.encode.bytes=n-o,r.writeUInt16BE(ge.encode.bytes-2,o),r};ge.encode.bytes=0;ge.decode=function(e,r){r||(r=0);let n=r,o={};r+=2,o.algorithm=e[r],r+=1,o.hash=e[r],r+=1;let i=ge.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,ge.decode.bytes=r-n,o};ge.decode.bytes=0;ge.encodingLength=function(t){return 4+B.from(t.fingerprint,"hex").byteLength};var Ke=A.naptr={};Ke.encode=function(t,e,r){e||(e=B.alloc(Ke.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,N.encode(t.flags,e,r),r+=N.encode.bytes,N.encode(t.services,e,r),r+=N.encode.bytes,N.encode(t.regexp,e,r),r+=N.encode.bytes,y.encode(t.replacement,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.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=N.decode(t,e),e+=N.decode.bytes,n.services=N.decode(t,e),e+=N.decode.bytes,n.regexp=N.decode(t,e),e+=N.decode.bytes,n.replacement=y.decode(t,e),e+=y.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return N.encodingLength(t.flags)+N.encodingLength(t.services)+N.encodingLength(t.regexp)+y.encodingLength(t.replacement)+6};var Me=A.tlsa={};Me.encode=function(t,e,r){e||(e=B.alloc(Me.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!B.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,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.decode=function(t,e){e||(e=0);let r=e,n={},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,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 5+B.byteLength(t.certificate)};var Gn=A.record=function(t){switch(t.toUpperCase()){case"A":return et;case"PTR":return Be;case"CNAME":return Fu;case"DNAME":return ku;case"TXT":return Xe;case"NULL":return Ze;case"AAAA":return tt;case"SRV":return Je;case"HINFO":return Qe;case"CAA":return me;case"NS":return Ge;case"SOA":return We;case"MX":return dt;case"OPT":return ye;case"DNSKEY":return de;case"RRSIG":return Pe;case"RP":return Ne;case"NSEC":return Re;case"NSEC3":return Fe;case"SSHFP":return ge;case"DS":return ke;case"NAPTR":return Ke;case"TLSA":return Me}return Ye},ne=A.answer={};ne.encode=function(t,e,r){e||(e=B.alloc(ne.encodingLength(t))),r||(r=0);let n=r;if(y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(rt.toType(t.type),r),t.type.toUpperCase()==="OPT"){if(t.name!==".")throw new Error("OPT name must be root.");e.writeUInt16BE(t.udpPayloadSize||4096,r+2),e.writeUInt8(t.extendedRcode||0,r+4),e.writeUInt8(t.ednsVersion||0,r+5),e.writeUInt16BE(t.flags||0,r+6),r+=8,ye.encode(t.options||[],e,r),r+=ye.encode.bytes}else{let o=Gr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=Yn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=Gn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return ne.encode.bytes=r-n,e};ne.encode.bytes=0;ne.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=y.decode(t,e),e+=y.decode.bytes,r.type=rt.toString(t.readUInt16BE(e)),r.type==="OPT")r.udpPayloadSize=t.readUInt16BE(e+2),r.extendedRcode=t.readUInt8(e+4),r.ednsVersion=t.readUInt8(e+5),r.flags=t.readUInt16BE(e+6),r.flag_do=(r.flags>>15&1)===1,r.options=ye.decode(t,e+8),e+=8+ye.decode.bytes;else{let o=t.readUInt16BE(e+2);r.ttl=t.readUInt32BE(e+4),r.class=Gr.toString(o&Nu),r.flush=!!(o&Yn);let i=Gn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return ne.decode.bytes=e-n,r};ne.decode.bytes=0;ne.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return y.encodingLength(t.name)+8+Gn(t.type).encodingLength(e)};var Ce=A.question={};Ce.encode=function(t,e,r){e||(e=B.alloc(Ce.encodingLength(t))),r||(r=0);let n=r;return y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(rt.toType(t.type),r),r+=2,e.writeUInt16BE(Gr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Ce.encode.bytes=r-n,t};Ce.encode.bytes=0;Ce.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=y.decode(t,e),e+=y.decode.bytes,n.type=rt.toString(t.readUInt16BE(e)),e+=2,n.class=Gr.toString(t.readUInt16BE(e)),e+=2,n.class&Is&&(n.class&=Ru),Ce.decode.bytes=e-r,n};Ce.decode.bytes=0;Ce.encodingLength=function(t){return y.encodingLength(t.name)+4};A.AUTHORITATIVE_ANSWER=1024;A.TRUNCATED_RESPONSE=512;A.RECURSION_DESIRED=256;A.RECURSION_AVAILABLE=128;A.AUTHENTIC_DATA=32;A.CHECKING_DISABLED=16;A.DNSSEC_OK=32768;A.encode=function(t,e,r){let n=!e;n&&(e=B.alloc(A.encodingLength(t))),r||(r=0);let o=r;return t.questions||(t.questions=[]),t.answers||(t.answers=[]),t.authorities||(t.authorities=[]),t.additionals||(t.additionals=[]),Le.encode(t,e,r),r+=Le.encode.bytes,r=ur(t.questions,Ce,e,r),r=ur(t.answers,ne,e,r),r=ur(t.authorities,ne,e,r),r=ur(t.additionals,ne,e,r),A.encode.bytes=r-o,n&&A.encode.bytes!==e.length?e.slice(0,A.encode.bytes):e};A.encode.bytes=0;A.decode=function(t,e){e||(e=0);let r=e,n=Le.decode(t,e);return e+=Le.decode.bytes,e=Yr(n.questions,Ce,t,e),e=Yr(n.answers,ne,t,e),e=Yr(n.authorities,ne,t,e),e=Yr(n.additionals,ne,t,e),A.decode.bytes=e-r,n};A.decode.bytes=0;A.encodingLength=function(t){return Le.encodingLength(t)+Rt(t.questions||[],Ce)+Rt(t.answers||[],ne)+Rt(t.authorities||[],ne)+Rt(t.additionals||[],ne)};A.streamEncode=function(t){let e=A.encode(t),r=B.alloc(2);r.writeUInt16BE(e.byteLength);let n=B.concat([r,e]);return A.streamEncode.bytes=n.byteLength,n};A.streamEncode.bytes=0;A.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=A.decode(t.slice(2));return A.streamDecode.bytes=A.decode.bytes,r};A.streamDecode.bytes=0;function Rt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function ur(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 Yr(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 Ls=ve((f0,Cs)=>{"use strict";var Bs=Hu;process.nextTick(zu,42);Cs.exports=Ku;function Ku(t){var e=n;return r;function r(o){e(o||qu)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var u=arguments;for(e=Mu(a)?n:p;i.length;)p(i.shift());function p(l){Bs(Vu,l,u)}}}}function Mu(t){return Object.prototype.toString.call(t)==="[object Error]"}function qu(){}function Vu(t,e){t.apply(null,e)}function zu(t){t===42&&(Bs=process.nextTick)}function Hu(t,e,r){process.nextTick(function(){t(e,r)})}});var Os=ve((m0,Us)=>{var Wn=As(),$u=G("dgram"),ju=Ls(),Yu=G("events"),Zn=G("os"),Xn=function(){};Us.exports=function(t){t||(t={});var e=new Yu.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||$u.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),u.on("message",function(l,f){try{l=Wn.decode(l)}catch(h){e.emit("warning",h);return}e.emit("packet",l,f),l.type==="query"&&e.emit("query",l,f),l.type==="response"&&e.emit("response",l,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 p=ju(function(l){if(!r||t.bind===!1)return l(null);u.once("error",l),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",l),l(null)})});return p(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,f,h){if(typeof f=="function")return e.send(l,null,f);h||(h=Xn),f?!f.host&&!f.address&&(f.address=i.address):f=i,p(d);function d(m){if(c)return h();if(m)return h(m);var x=Wn.encode(l);u.send(x,0,x.length,f.port,f.address||f.host,h)}},e.response=e.respond=function(l,f,h){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|Wn.AUTHORITATIVE_ANSWER,e.send(l,f,h)},e.query=function(l,f,h,d){if(typeof f=="function")return e.query(l,null,null,f);if(typeof f=="object"&&f&&f.port)return e.query(l,null,f,h);if(typeof h=="function")return e.query(l,f,null,h);d||(d=Xn),typeof l=="string"&&(l=[{name:l,type:f||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,h,d)},e.destroy=function(l){if(l||(l=Xn),c)return process.nextTick(l);c=!0,clearInterval(a);for(var f in s)try{u.dropMembership(o,f)}catch{}s={},u.close(l)},e.update=function(){for(var l=t.interface?[].concat(t.interface):Wu(),f=!1,h=0;h<l.length;h++){var d=l[h];if(!s[d])try{u.addMembership(o,d),s[d]=!0,f=!0}catch(m){e.emit("warning",m)}}if(f){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||Gu())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function Gu(){for(var t=Zn.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(Ds(i.family)&&!i.internal)return Zn.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function Wu(){for(var t=Zn.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(Ds(s.family)){r.push(s.address);break}}return r}function Ds(t){return t===4||t==="IPv4"}});var Gi=ve(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.Netmask4Impl=void 0;nr.ip2long=rr;nr.long2ip=$e;function $e(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 gp=48,yp=97,bp=65;function xp(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)-gp)>>>0;else if(r===16)if("a"<=t[o]&&t[o]<="f")e=e*r+(10+t.charCodeAt(o)-yp)>>>0;else if("A"<=t[o]&&t[o]<="F")e=e*r+(10+t.charCodeAt(o)-bp)>>>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 rr(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]=xp(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 Yi=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=rr(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=(rr(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=$e(this.netLong),this.mask=$e(this.maskLong),this.hostmask=$e(~this.maskLong),this.first=this.bitmask<=30?$e(this.netLong+1):this.base,this.last=this.bitmask<=30?$e(this.netLong+this.size-2):$e(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?$e(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):(rr(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new t($e(this.netLong+this.size*e),this.mask)}forEach(e){let r=rr(this.first),n=rr(this.last),o=0;for(;r<=n;)e($e(r),r,o),o++,r++}toString(){return this.base+"/"+this.bitmask}};nr.Netmask4Impl=Yi});var ja=ve(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.Netmask6Impl=void 0;or.ip6bigint=Xi;or.bigint2ip6=Ot;var wp=Gi(),Wi=(1n<<128n)-1n;function Xi(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,wp.ip2long)(n),i=t.substring(0,r+1)+"0:0";return $a(i)&~0xffffffffn|BigInt(o)}return $a(t)}function $a(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 Ot(t){if(t<0n||t>Wi)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 Zi=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=Wi>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=Xi(e)&this.maskBigint}catch{throw new Error("Invalid IPv6 net address: "+e)}this.size=Number(1n<<BigInt(128-this.bitmask)),this.base=Ot(this.netBigint),this.mask=Ot(this.maskBigint),this.hostmask=Ot(~this.maskBigint&Wi),this.first=this.base,this.last=Ot(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):(Xi(e)&this.maskBigint)===this.netBigint}next(e=1){let r=1n<<BigInt(128-this.bitmask);return new t(Ot(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(Ot(r),Number(r),i),i++,r++}toString(){return this.base+"/"+this.bitmask}};or.Netmask6Impl=Zi});var Ya=ve(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});xt.long2ip=xt.ip2long=xt.Netmask=void 0;var _n=Gi();Object.defineProperty(xt,"ip2long",{enumerable:!0,get:function(){return _n.ip2long}});Object.defineProperty(xt,"long2ip",{enumerable:!0,get:function(){return _n.long2ip}});var Ep=ja(),Qi=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 Ep.Netmask6Impl(e,r):this._impl=new _n.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 _n.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()}};xt.Netmask=Qi});var Df={};V(Df,{mdns:()=>Lf});var Se=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},zr=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var Hr=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},$r=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var ar=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var ls=Symbol.for("@libp2p/peer-discovery");var Kn=Symbol.for("@libp2p/peer-id");var hs=G("node:events"),ps=(t,...e)=>{try{(0,hs.setMaxListeners)(t,...e)}catch{}};function Uu(t){return typeof t?.handleEvent=="function"}function Ou(t){return(t!==!0&&t!==!1&&t?.once)??!1}var jr=class extends EventTarget{#e=new Map;constructor(){super(),ps(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=Ou(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))}Uu(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 fs=Symbol.for("@libp2p/service-capabilities");var Su=Nt(Os(),1);var ro={};V(ro,{base58btc:()=>W,base58flickr:()=>rd});var g0=new Uint8Array(0);function Ts(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 Ie(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function _s(t){return new TextEncoder().encode(t)}function Ps(t){return new TextDecoder().decode(t)}function Xu(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,a=t.charAt(0),u=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var m=0,x=0,v=0,C=d.length;v!==C&&d[v]===0;)v++,m++;for(var R=(C-v)*p+1>>>0,P=new Uint8Array(R);v!==C;){for(var U=d[v],F=0,K=R-1;(U!==0||F<x)&&K!==-1;K--,F++)U+=256*P[K]>>>0,P[K]=U%c>>>0,U=U/c>>>0;if(U!==0)throw new Error("Non-zero carry");x=F,v++}for(var O=R-x;O!==R&&P[O]===0;)O++;for(var ce=a.repeat(m);O<R;++O)ce+=t.charAt(P[O]);return ce}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var m=0;if(d[m]!==" "){for(var x=0,v=0;d[m]===a;)x++,m++;for(var C=(d.length-m)*u+1>>>0,R=new Uint8Array(C);d[m];){var P=r[d.charCodeAt(m)];if(P===255)return;for(var U=0,F=C-1;(P!==0||U<v)&&F!==-1;F--,U++)P+=c*R[F]>>>0,R[F]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");v=U,m++}if(d[m]!==" "){for(var K=C-v;K!==C&&R[K]===0;)K++;for(var O=new Uint8Array(x+(C-K)),ce=x;K!==C;)O[ce++]=R[K++];return O}}}function h(d){var m=f(d);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var Zu=Xu,Qu=Zu,Rs=Qu;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")}},Jn=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 Fs(this,e)}},eo=class{decoders;constructor(e){this.decoders=e}or(e){return Fs(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 Fs(t,e){return new eo({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var to=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 Jn(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 to(t,e,r,n)}function lt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Rs(r,t);return Ft({prefix:e,name:t,encode:n,decode:i=>Ie(o(i))})}function Ju(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 p=e[t[u]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|p,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 ed(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 td(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function H({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=td(n);return Ft({prefix:e,name:t,encode(i){return ed(i,n,r)},decode(i){return Ju(i,o,r,t)}})}var W=lt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),rd=lt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var no={};V(no,{base32:()=>ht,base32hex:()=>sd,base32hexpad:()=>ad,base32hexpadupper:()=>ud,base32hexupper:()=>cd,base32pad:()=>od,base32padupper:()=>id,base32upper:()=>nd,base32z:()=>dd});var ht=H({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),nd=H({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),od=H({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),id=H({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),sd=H({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),cd=H({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ad=H({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ud=H({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),dd=H({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var oo={};V(oo,{base36:()=>dr,base36upper:()=>ld});var dr=lt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ld=lt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var hd=Ms,ks=128,pd=127,fd=~pd,md=Math.pow(2,31);function Ms(t,e,r){e=e||[],r=r||0;for(var n=r;t>=md;)e[r++]=t&255|ks,t/=128;for(;t&fd;)e[r++]=t&255|ks,t>>>=7;return e[r]=t|0,Ms.bytes=r-n+1,e}var gd=io,yd=128,Ks=127;function io(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw io.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Ks)<<o:(s&Ks)*Math.pow(2,o),o+=7}while(s>=yd);return io.bytes=i-n,r}var bd=Math.pow(2,7),xd=Math.pow(2,14),wd=Math.pow(2,21),Ed=Math.pow(2,28),vd=Math.pow(2,35),Sd=Math.pow(2,42),Id=Math.pow(2,49),Ad=Math.pow(2,56),Bd=Math.pow(2,63),Cd=function(t){return t<bd?1:t<xd?2:t<wd?3:t<Ed?4:t<vd?5:t<Sd?6:t<Id?7:t<Ad?8:t<Bd?9:10},Ld={encode:hd,decode:gd,encodingLength:Cd},Dd=Ld,lr=Dd;function hr(t,e=0){return[lr.decode(t,e),lr.decode.bytes]}function kt(t,e,r=0){return lr.encode(t,e,r),e}function Kt(t){return lr.encodingLength(t)}function qt(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 pr(t){let e=Ie(t),[r,n]=hr(e),[o,i]=hr(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 qs(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ts(t.bytes,r.bytes)}}var Mt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Vs(t,e){let{bytes:r,version:n}=t;return n===0?Od(r,so(t),e??W.encoder):Td(r,so(t),e??ht.encoder)}var zs=new WeakMap;function so(t){let e=zs.get(t);if(e==null){let r=new Map;return zs.set(t,r),r}return e}var oe=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==fr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==_d)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=qt(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&&qs(e.multihash,n.multihash)}toString(e){return Vs(this,e)}toJSON(){return{"/":Vs(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??Hs(n,o,i.bytes))}else if(r[Pd]===!0){let{version:n,multihash:o,code:i}=r,s=pr(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!==fr)throw new Error(`Version 0 CID must use dag-pb (code: ${fr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Hs(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,fr,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=Ie(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[l,f]=hr(e.subarray(r));return r+=f,l},o=n(),i=fr;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,p=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:p,size:u}}static parse(e,r){let[n,o]=Ud(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 so(i).set(n,e),i}};function Ud(t,e){switch(t[0]){case"Q":{let r=e??W;return[W.prefix,r.decode(`${W.prefix}${t}`)]}case W.prefix:{let r=e??W;return[W.prefix,r.decode(t)]}case ht.prefix:{let r=e??ht;return[ht.prefix,r.decode(t)]}case dr.prefix:{let r=e??dr;return[dr.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 Od(t,e,r){let{prefix:n}=r;if(n!==W.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 Td(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 fr=112,_d=18;function Hs(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 Pd=Symbol.for("@ipld/js-cid/CID");var co={};V(co,{identity:()=>De});var $s=0,Nd="identity",js=Ie;function Rd(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 qt($s,js(t))}var De={code:$s,name:Nd,encode:js,digest:Rd};function nt(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 Fd(t){return t.buffer instanceof ArrayBuffer}function ao(t){return Fd(t)?t:t.slice()}async function Ys(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,ao(e),ao(r.subarray()));return n?.signal?.throwIfAborted(),i}var uo=G("node:buffer");function mr(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function ot(t=0){return mr(uo.Buffer.alloc(t))}function lo(t=0){return mr(uo.Buffer.allocUnsafe(t))}var Gs=G("node:buffer");function ho(t,e){return mr(Gs.Buffer.concat(t,e))}function Ws(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var Zs=Symbol.for("@achingbrain/uint8arraylist");function Xs(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 Xr(t){return!!t?.[Zs]}var be=class t{bufs;length;[Zs]=!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(Xr(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(Xr(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=Xs(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Xs(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(Xr(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 ho(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:ho(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,p=r>c&&r<=a;if(u&&p){if(e===c&&r===a){n.push(s);break}let l=e-c;n.push(s.subarray(l,l+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(p){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(!Xr(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let c=s,a=this.byteLength-n.byteLength,u=n.byteLength-1,p;for(let l=r;l<=a;l+=p){p=0;for(let f=u;f>=0;f--){let h=this.get(l+f);if(n[f]!==h){p=Math.max(1,f-c[h]);break}}if(p===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=lo(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=ot(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=ot(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=ot(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=lo(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=ot(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=ot(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=ot(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=ot(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=ot(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(!Ws(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 Ec=G("node:buffer");var yo={};V(yo,{base10:()=>$d});var G0=new Uint8Array(0);function Qs(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function Ae(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return Et(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return Et(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Js(t){return new TextEncoder().encode(t)}function ec(t){return new TextDecoder().decode(t)}function kd(t){return t?.buffer instanceof ArrayBuffer}function Et(t){return kd(t)?t:t.slice()}function Kd(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,a=t.charAt(0),u=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var m=0,x=0,v=0,C=d.length;v!==C&&d[v]===0;)v++,m++;for(var R=(C-v)*p+1>>>0,P=new Uint8Array(R);v!==C;){for(var U=d[v],F=0,K=R-1;(U!==0||F<x)&&K!==-1;K--,F++)U+=256*P[K]>>>0,P[K]=U%c>>>0,U=U/c>>>0;if(U!==0)throw new Error("Non-zero carry");x=F,v++}for(var O=R-x;O!==R&&P[O]===0;)O++;for(var ce=a.repeat(m);O<R;++O)ce+=t.charAt(P[O]);return ce}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var m=0;if(d[m]!==" "){for(var x=0,v=0;d[m]===a;)x++,m++;for(var C=(d.length-m)*u+1>>>0,R=new Uint8Array(C);d[m];){var P=r[d.charCodeAt(m)];if(P===255)return;for(var U=0,F=C-1;(P!==0||U<v)&&F!==-1;F--,U++)P+=c*R[F]>>>0,R[F]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");v=U,m++}if(d[m]!==" "){for(var K=C-v;K!==C&&R[K]===0;)K++;for(var O=new Uint8Array(x+(C-K)),ce=x;K!==C;)O[ce++]=R[K++];return O}}}function h(d){var m=f(d);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var Md=Kd,qd=Md,rc=qd;var po=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")}},fo=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 nc(this,e)}},mo=class{decoders;constructor(e){this.decoders=e}or(e){return nc(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 nc(t,e){return new mo({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var go=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 po(e,r,n),this.decoder=new fo(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function zt({name:t,prefix:e,encode:r,decode:n}){return new go(t,e,r,n)}function pt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=rc(r,t);return zt({prefix:e,name:t,encode:n,decode:i=>Ae(o(i))})}function Vd(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 p=e[t[u]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|p,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 zd(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 Hd(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function $({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Hd(n);return zt({prefix:e,name:t,encode(i){return zd(i,n,r)},decode(i){return Vd(i,o,r,t)}})}var $d=pt({prefix:"9",name:"base10",alphabet:"0123456789"});var bo={};V(bo,{base16:()=>jd,base16upper:()=>Yd});var jd=$({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Yd=$({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var xo={};V(xo,{base2:()=>Gd});var Gd=$({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wo={};V(wo,{base256emoji:()=>Jd});var oc=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}"),Wd=oc.reduce((t,e,r)=>(t[r]=e,t),[]),Xd=oc.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Zd(t){return t.reduce((e,r)=>(e+=Wd[r],e),"")}function Qd(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Xd[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Jd=zt({prefix:"\u{1F680}",name:"base256emoji",encode:Zd,decode:Qd});var Eo={};V(Eo,{base32:()=>Ht,base32hex:()=>nl,base32hexpad:()=>il,base32hexpadupper:()=>sl,base32hexupper:()=>ol,base32pad:()=>tl,base32padupper:()=>rl,base32upper:()=>el,base32z:()=>cl});var Ht=$({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),el=$({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tl=$({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),rl=$({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nl=$({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ol=$({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),il=$({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),sl=$({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cl=$({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var vo={};V(vo,{base36:()=>gr,base36upper:()=>al});var gr=pt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),al=pt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var So={};V(So,{base58btc:()=>qe,base58flickr:()=>ul});var qe=pt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ul=pt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Io={};V(Io,{base64:()=>dl,base64pad:()=>ll,base64url:()=>hl,base64urlpad:()=>pl});var dl=$({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ll=$({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),hl=$({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),pl=$({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ao={};V(Ao,{base8:()=>fl});var fl=$({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Bo={};V(Bo,{identity:()=>ml});var ml=zt({prefix:"\0",name:"identity",encode:t=>ec(t),decode:t=>Js(t)});var dm=new TextEncoder,lm=new TextDecoder;var Lo={};V(Lo,{identity:()=>kl});var bl=cc,ic=128,xl=127,wl=~xl,El=Math.pow(2,31);function cc(t,e,r){e=e||[],r=r||0;for(var n=r;t>=El;)e[r++]=t&255|ic,t/=128;for(;t&wl;)e[r++]=t&255|ic,t>>>=7;return e[r]=t|0,cc.bytes=r-n+1,e}var vl=Co,Sl=128,sc=127;function Co(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw Co.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&sc)<<o:(s&sc)*Math.pow(2,o),o+=7}while(s>=Sl);return Co.bytes=i-n,r}var Il=Math.pow(2,7),Al=Math.pow(2,14),Bl=Math.pow(2,21),Cl=Math.pow(2,28),Ll=Math.pow(2,35),Dl=Math.pow(2,42),Ul=Math.pow(2,49),Ol=Math.pow(2,56),Tl=Math.pow(2,63),_l=function(t){return t<Il?1:t<Al?2:t<Bl?3:t<Cl?4:t<Ll?5:t<Dl?6:t<Ul?7:t<Ol?8:t<Tl?9:10},Pl={encode:bl,decode:vl,encodingLength:_l},Nl=Pl,yr=Nl;function br(t,e=0){return[yr.decode(t,e),yr.decode.bytes]}function $t(t,e,r=0){return yr.encode(t,e,r),e}function jt(t){return yr.encodingLength(t)}function Gt(t,e){let r=e.byteLength,n=jt(t),o=n+jt(r),i=new Uint8Array(o+r);return $t(t,i,0),$t(r,i,n),i.set(e,o),new Yt(t,r,e,i)}function ac(t){let e=Ae(t),[r,n]=br(e),[o,i]=br(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new Yt(r,o,s,e)}function uc(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Qs(t.bytes,r.bytes)}}var Yt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=Et(n),this.bytes=Et(o)}};var dc=0,Rl="identity",lc=Ae;function Fl(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 Gt(dc,lc(t))}var kl={code:dc,name:Rl,encode:lc,digest:Fl};var To={};V(To,{sha256:()=>Ml,sha512:()=>ql});var Oo=Nt(G("node:crypto"),1);var Kl=20;function Uo({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Do(t,e,r,n,o)}var Do=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Kl,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?hc(n,this.code,r?.truncate):n.then(o=>hc(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function hc(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 Gt(e,t)}var Ml=Uo({name:"sha2-256",code:18,encode:t=>Ae(Oo.default.createHash("sha256").update(t).digest())}),ql=Uo({name:"sha2-512",code:19,encode:t=>Ae(Oo.default.createHash("sha512").update(t).digest())});function fc(t,e){let{bytes:r,version:n}=t;return n===0?zl(r,_o(t),e??qe.encoder):Hl(r,_o(t),e??Ht.encoder)}var mc=new WeakMap;function _o(t){let e=mc.get(t);if(e==null){let r=new Map;return mc.set(t,r),r}return e}var Qr=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=Et(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!==wr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==$l)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=Gt(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&&uc(e.multihash,n.multihash)}toString(e){return fc(this,e)}toJSON(){return{"/":fc(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??gc(n,o,i.bytes))}else if(r[jl]===!0){let{version:n,multihash:o,code:i}=r,s=ac(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!==wr)throw new Error(`Version 0 CID must use dag-pb (code: ${wr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=gc(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,wr,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=Ae(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let i=o.subarray(r.multihashSize-r.digestSize),s=new Yt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,f]=br(e.subarray(r));return r+=f,l},o=n(),i=wr;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,p=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:p,size:u}}static parse(e,r){let[n,o]=Vl(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 _o(i).set(n,e),i}};function Vl(t,e){switch(t[0]){case"Q":{let r=e??qe;return[qe.prefix,r.decode(`${qe.prefix}${t}`)]}case qe.prefix:{let r=e??qe;return[qe.prefix,r.decode(t)]}case Ht.prefix:{let r=e??Ht;return[Ht.prefix,r.decode(t)]}case gr.prefix:{let r=e??gr;return[gr.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 zl(t,e,r){let{prefix:n}=r;if(n!==qe.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 Hl(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 wr=112,$l=18;function gc(t,e,r){let n=jt(t),o=n+jt(e),i=new Uint8Array(o+r.byteLength);return $t(t,i,0),$t(e,i,n),i.set(r,o),i}var jl=Symbol.for("@ipld/js-cid/CID");var Po={...Bo,...xo,...Ao,...yo,...bo,...Eo,...vo,...So,...Io,...wo},Pm={...To,...Lo};var yc=G("node:buffer");function Er(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 bc(t=0){return Er(yc.Buffer.allocUnsafe(t))}function wc(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var xc=wc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),No=wc("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=bc(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Yl={utf8:xc,"utf-8":xc,hex:Po.base16,latin1:No,ascii:No,binary:No,...Po},Jr=Yl;function vt(t,e="utf8"){let r=Jr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?Er(Ec.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var vc=G("node:buffer");function fe(t,e="utf8"){let r=Jr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?vc.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Gl=parseInt("11111",2),Ro=parseInt("10000000",2),Wl=parseInt("01111111",2),Sc={0:vr,1:vr,2:Xl,3:Jl,4:eh,5:Ql,6:Zl,16:vr,22:vr,48:vr};function Fo(t,e={offset:0}){let r=t[e.offset]&Gl;if(e.offset++,Sc[r]!=null)return Sc[r](t,e);throw new Error("No decoder for tag "+r)}function Sr(t,e){let r=0;if((t[e.offset]&Ro)===Ro){let n=t[e.offset]&Wl,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function vr(t,e){Sr(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Fo(t,e);if(n===null)break;r.push(n)}return r}function Xl(t,e){let r=Sr(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 Zl(t,e){let r=Sr(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 p=0;for(let l=0;l<a.length;l++)p+=a[l]<<l*7;c+=`.${p}`,a=[]}}return c}function Ql(t,e){return e.offset++,null}function Jl(t,e){let r=Sr(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 eh(t,e){let r=Sr(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function th(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new be;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function ko(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=th(t.byteLength);return new be(Uint8Array.from([e.byteLength|Ro]),e)}function Ic(t){let e=new be,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new be(Uint8Array.from([2]),ko(e),e)}function Ac(t){let e=Uint8Array.from([0]),r=new be(e,t);return new be(Uint8Array.from([3]),ko(r),r)}function en(t,e=48){let r=new be;for(let n of t)r.append(n);return new be(Uint8Array.from([e]),ko(r),r)}var rh=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),nh=Uint8Array.from([6,5,43,129,4,0,34]),oh=Uint8Array.from([6,5,43,129,4,0,35]),ih={ext:!0,kty:"EC",crv:"P-256"},sh={ext:!0,kty:"EC",crv:"P-384"},ch={ext:!0,kty:"EC",crv:"P-521"},Ko=32,Mo=48,qo=66;function Bc(t){let e=Fo(t);return Cc(e)}function Cc(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===Ko*2+1)return n=fe(e.subarray(r,r+Ko),"base64url"),o=fe(e.subarray(r+Ko),"base64url"),new Wt({...ih,key_ops:["verify"],x:n,y:o});if(e.byteLength===Mo*2+1)return n=fe(e.subarray(r,r+Mo),"base64url"),o=fe(e.subarray(r+Mo),"base64url"),new Wt({...sh,key_ops:["verify"],x:n,y:o});if(e.byteLength===qo*2+1)return n=fe(e.subarray(r,r+qo),"base64url"),o=fe(e.subarray(r+qo),"base64url"),new Wt({...ch,key_ops:["verify"],x:n,y:o});throw new Se(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function Lc(t){return en([Ic(Uint8Array.from([1])),en([ah(t.crv)],160),en([Ac(new be(Uint8Array.from([4]),vt(t.x??"","base64url"),vt(t.y??"","base64url")))],161)]).subarray()}function ah(t){if(t==="P-256")return rh;if(t==="P-384")return nh;if(t==="P-521")return oh;throw new Se(`Invalid curve ${t}`)}var Wt=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=Lc(this.jwk)),this._raw}toMultihash(){return De.digest(Xt(this))}toCID(){return oe.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:nt(this.raw,e.raw)}async verify(e,r,n){return Ys(this.jwk,r,e,n)}};var mn=Nt(G("crypto"),1);function Vo(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function ft(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(`${r}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new RangeError(`${r}expected integer >= 0, got ${t}`)}}function Ve(t,e,r=""){let n=Vo(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,c=i?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`,u=s+"expected Uint8Array"+c+", got "+a;throw n?new RangeError(u):new TypeError(u)}return t}function tn(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(ft(t.outputLen),ft(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Zt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function rn(t,e){Ve(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function St(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function nn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Ue(t,e){return t<<32-e|t>>>e}var Uc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",uh=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function on(t){if(Ve(t),Uc)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=uh[t[r]];return e}var it={_0:48,_9:57,A:65,F:70,a:97,f:102};function Dc(t){if(t>=it._0&&t<=it._9)return t-it._0;if(t>=it.A&&t<=it.F)return t-(it.A-10);if(t>=it.a&&t<=it.f)return t-(it.a-10)}function zo(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(Uc)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=Dc(t.charCodeAt(i)),c=Dc(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 Oc(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];Ve(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 Tc(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function _c(t=32){ft(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 Pc=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function Nc(t,e,r){return t&e^~t&r}function Rc(t,e,r){return t&e^t&r^e&r}var sn=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=nn(this.buffer)}update(e){Zt(this),Ve(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=nn(e);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Zt(this),rn(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,St(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=nn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=a/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,p[l],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},st=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var dh=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mt=new Uint32Array(64),Ho=class extends sn{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,r){for(let l=0;l<16;l++,r+=4)mt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let f=mt[l-15],h=mt[l-2],d=Ue(f,7)^Ue(f,18)^f>>>3,m=Ue(h,17)^Ue(h,19)^h>>>10;mt[l]=m+mt[l-7]+d+mt[l-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:u,H:p}=this;for(let l=0;l<64;l++){let f=Ue(c,6)^Ue(c,11)^Ue(c,25),h=p+f+Nc(c,a,u)+dh[l]+mt[l]|0,m=(Ue(n,2)^Ue(n,13)^Ue(n,22))+Rc(n,o,i)|0;p=u,u=a,a=c,c=s+h|0,s=i,i=o,o=n,n=h+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,p=p+this.H|0,this.set(n,o,i,s,c,a,u,p)}roundClean(){St(mt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),St(this.buffer)}},$o=class extends Ho{A=st[0]|0;B=st[1]|0;C=st[2]|0;D=st[3]|0;E=st[4]|0;F=st[5]|0;G=st[6]|0;H=st[7]|0;constructor(){super(32)}};var Fc=Tc(()=>new $o,Pc(1));var Q=(t,e,r)=>Ve(t,e,r),Yo=ft,Go=on,ct=(...t)=>Oc(...t),un=t=>zo(t),Wo=Vo,Xo=t=>_c(t),an=BigInt(0),jo=BigInt(1);function It(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new TypeError(r+"expected boolean, got type="+typeof t)}return t}function dn(t){if(typeof t=="bigint"){if(!cn(t))throw new RangeError("positive bigint expected, got "+t)}else Yo(t);return t}function Ir(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 Ar(t){let e=dn(t).toString(16);return e.length&1?"0"+e:e}function kc(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?an:BigInt("0x"+t)}function Qt(t){return kc(on(t))}function Zo(t){return kc(on(lh(Ve(t)).reverse()))}function ln(t,e){if(ft(e),e===0)throw new RangeError("zero length");t=dn(t);let r=t.toString(16);if(r.length>e*2)throw new RangeError("number too large");return zo(r.padStart(e*2,"0"))}function Qo(t,e){return ln(t,e).reverse()}function lh(t){return Uint8Array.from(Q(t))}var cn=t=>typeof t=="bigint"&&an<=t;function hh(t,e,r){return cn(t)&&cn(e)&&cn(r)&&e<=t&&t<r}function Jo(t,e,r,n){if(!hh(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Jt(t){if(t<an)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>an;t>>=jo,e+=1);return e}var Br=t=>(jo<<BigInt(t))-jo;function Kc(t,e,r){if(ft(t,"hashLen"),ft(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=x=>new Uint8Array(x),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(t),u=n(t),p=0,l=()=>{a.fill(1),u.fill(0),p=0},f=(...x)=>r(u,ct(a,...x)),h=(x=o)=>{u=f(i,x),a=f(),x.length!==0&&(u=f(s,x),a=f())},d=()=>{if(p++>=c)throw new Error("drbg: tried max amount of iterations");let x=0,v=[];for(;x<e;){a=f();let C=a.slice();v.push(C),x+=a.length}return ct(...v)};return(x,v)=>{l(),h(x);let C;for(;(C=v(d()))===void 0;)h();return l(),C}}function At(t,e={},r={}){if(Object.prototype.toString.call(t)!=="[object Object]")throw new TypeError("expected valid options object");function n(i,s,c){if(!c&&s!=="function"&&!Object.hasOwn(t,i))throw new TypeError(`param "${i}" is invalid: expected own property`);let a=t[i];if(c&&a===void 0)return;let u=typeof a;if(u!==s||a===null)throw new TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(e,!1),o(r,!0)}var ie=BigInt(0),X=BigInt(1),Bt=BigInt(2),zc=BigInt(3),Hc=BigInt(4),$c=BigInt(5),ph=BigInt(7),jc=BigInt(8),fh=BigInt(9),Yc=BigInt(16);function Oe(t,e){if(e<=ie)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=ie?r:e+r}function xe(t,e,r){if(e<ie)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >ie;)n*=n,n%=r;return n}function Mc(t,e){if(t===ie)throw new Error("invert: expected non-zero number");if(e<=ie)throw new Error("invert: expected positive modulus, got "+e);let r=Oe(t,e),n=e,o=ie,i=X,s=X,c=ie;for(;r!==ie;){let u=n/r,p=n-r*u,l=o-s*u,f=i-c*u;n=r,r=p,o=s,i=c,s=l,c=f}if(n!==X)throw new Error("invert: does not exist");return Oe(o,e)}function ei(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Gc(t,e){let r=t,n=(r.ORDER+X)/Hc,o=r.pow(e,n);return ei(r,o,e),o}function mh(t,e){let r=t,n=(r.ORDER-$c)/jc,o=r.mul(e,Bt),i=r.pow(o,n),s=r.mul(e,i),c=r.mul(r.mul(s,Bt),i),a=r.mul(s,r.sub(c,r.ONE));return ei(r,a,e),a}function gh(t){let e=er(t),r=Wc(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+ph)/Yc;return((c,a)=>{let u=c,p=u.pow(a,s),l=u.mul(p,n),f=u.mul(p,o),h=u.mul(p,i),d=u.eql(u.sqr(l),a),m=u.eql(u.sqr(f),a);p=u.cmov(p,l,d),l=u.cmov(h,f,m);let x=u.eql(u.sqr(l),a),v=u.cmov(p,l,x);return ei(u,v,a),v})}function Wc(t){if(t<zc)throw new Error("sqrt is not defined for small field");let e=t-X,r=0;for(;e%Bt===ie;)e/=Bt,r++;let n=Bt,o=er(t);for(;qc(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Gc;let i=o.pow(n,e),s=(e+X)/Bt;return function(a,u){let p=a;if(p.is0(u))return u;if(qc(p,u)!==1)throw new Error("Cannot find square root");let l=r,f=p.mul(p.ONE,i),h=p.pow(u,e),d=p.pow(u,s);for(;!p.eql(h,p.ONE);){if(p.is0(h))return p.ZERO;let m=1,x=p.sqr(h);for(;!p.eql(x,p.ONE);)if(m++,x=p.sqr(x),m===l)throw new Error("Cannot find square root");let v=X<<BigInt(l-m-1),C=p.pow(f,v);l=m,f=p.sqr(C),h=p.mul(h,f),d=p.mul(d,C)}return d}}function yh(t){return t%Hc===zc?Gc:t%jc===$c?mh:t%Yc===fh?gh(t):Wc(t)}var bh=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ti(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=bh.reduce((n,o)=>(n[o]="function",n),e);if(At(t,r),Ir(t.BYTES,"BYTES"),Ir(t.BITS,"BITS"),t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=X)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function xh(t,e,r){let n=t;if(r<ie)throw new Error("invalid exponent, negatives unsupported");if(r===ie)return n.ONE;if(r===X)return e;let o=n.ONE,i=e;for(;r>ie;)r&X&&(o=n.mul(o,i)),i=n.sqr(i),r>>=X;return o}function pn(t,e,r=!1){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 qc(t,e){let r=t,n=(r.ORDER-X)/Bt,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 wh(t,e){if(e!==void 0&&Yo(e),t<=ie)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=Jt(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${e})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Vc=new WeakMap,hn=class{ORDER;BITS;BYTES;isLE;ZERO=ie;ONE=X;_lengths;_mod;constructor(e,r={}){if(e<=X)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}=wh(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 Oe(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return ie<=e&&e<this.ORDER}is0(e){return e===ie}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&X)===X}neg(e){return Oe(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return Oe(e*e,this.ORDER)}add(e,r){return Oe(e+r,this.ORDER)}sub(e,r){return Oe(e-r,this.ORDER)}mul(e,r){return Oe(e*r,this.ORDER)}pow(e,r){return xh(this,e,r)}div(e,r){return Oe(e*Mc(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 Mc(e,this.ORDER)}sqrt(e){let r=Vc.get(this);return r||Vc.set(this,r=yh(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?Qo(e,this.BYTES):ln(e,this.BYTES)}fromBytes(e,r=!1){Q(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?Zo(e):Qt(e);if(c&&(a=Oe(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return pn(this,e)}cmov(e,r,n){return It(n,"condition"),n?r:e}};Object.freeze(hn.prototype);function er(t,e={}){return new hn(t,e)}function Xc(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=X)throw new Error("field order must be greater than 1");let e=Jt(t-X);return Math.ceil(e/8)}function ri(t){let e=Xc(t);return e+Math.ceil(e/2)}function ni(t,e,r=!1){Q(t);let n=t.length,o=Xc(e),i=Math.max(ri(e),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?Zo(t):Qt(t),c=Oe(s,e-X)+X;return r?Qo(c,o):ln(c,o)}var tr=BigInt(0),Ct=BigInt(1);function Cr(t,e){let r=e.negate();return t?r:e}function ci(t,e){let r=pn(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function ea(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function oi(t,e){ea(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=Br(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Zc(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=Ct);let u=e*n,p=u+Math.abs(c)-1,l=c===0,f=c<0,h=e%2!==0;return{nextN:a,offset:p,isZero:l,isNeg:f,isNegF:h,offsetF:u}}var ii=new WeakMap,ta=new WeakMap;function si(t){return ta.get(t)||1}function Qc(t){if(t!==tr)throw new Error("invalid wNAF")}var fn=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>tr;)r&Ct&&(n=n.add(o)),o=o.double(),r>>=Ct;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=oi(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let u=1;u<o;u++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=oi(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:u,isZero:p,isNeg:l,isNegF:f,offsetF:h}=Zc(n,c,s);n=a,p?i=i.add(Cr(f,r[h])):o=o.add(Cr(l,r[u]))}return Qc(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=oi(e,this.bits);for(let s=0;s<i.windows&&n!==tr;s++){let{nextN:c,offset:a,isZero:u,isNeg:p}=Zc(n,s,i);if(n=c,!u){let l=r[a];o=o.add(p?l.negate():l)}}return Qc(n),o}getPrecomputes(e,r,n){let o=ii.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),ii.set(r,o))),o}cached(e,r,n){let o=si(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=si(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){ea(r,this.bits),ta.set(e,r),ii.delete(e)}hasCache(e){return si(e)!==1}};function ra(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>tr||n>tr;)r&Ct&&(i=i.add(o)),n&Ct&&(s=s.add(o)),o=o.double(),r>>=Ct,n>>=Ct;return{p1:i,p2:s}}function Jc(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return ti(e),e}else return er(t,{isLE:r})}function na(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let a of["p","n","h"]){let u=e[a];if(!(typeof u=="bigint"&&u>tr))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Jc(e.p,r.Fp,n),i=Jc(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 oa(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var Ng=mn.default.generateKeyPairSync,Lr=32;var vh=64;function ia(t,e,r){if(t.byteLength!==Lr)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!==vh)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=mn.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:fe(t,"base64url"),kty:"OKP"}});return mn.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function ca(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var gn=class{type="Ed25519";raw;constructor(e){this.raw=ai(e,Lr)}toMultihash(){return De.digest(Xt(this))}toCID(){return oe.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:nt(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=ia(this.raw,r,e);return ca(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function aa(t){return t=ai(t,Lr),new gn(t)}function ai(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Se(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Ih=Math.pow(2,7),Ah=Math.pow(2,14),Bh=Math.pow(2,21),ui=Math.pow(2,28),di=Math.pow(2,35),li=Math.pow(2,42),hi=Math.pow(2,49),z=128,ae=127;function ze(t){if(t<Ih)return 1;if(t<Ah)return 2;if(t<Bh)return 3;if(t<ui)return 4;if(t<di)return 5;if(t<li)return 6;if(t<hi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Dr(t,e,r=0){switch(ze(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 pi(t,e){let r=t[e],n=0;if(n+=r&ae,r<z||(r=t[e+1],n+=(r&ae)<<7,r<z)||(r=t[e+2],n+=(r&ae)<<14,r<z)||(r=t[e+3],n+=(r&ae)<<21,r<z)||(r=t[e+4],n+=(r&ae)*ui,r<z)||(r=t[e+5],n+=(r&ae)*di,r<z)||(r=t[e+6],n+=(r&ae)*li,r<z)||(r=t[e+7],n+=(r&ae)*hi,r<z))return n;throw new RangeError("Could not decode varint")}function Ch(t,e){let r=t.get(e),n=0;if(n+=r&ae,r<z||(r=t.get(e+1),n+=(r&ae)<<7,r<z)||(r=t.get(e+2),n+=(r&ae)<<14,r<z)||(r=t.get(e+3),n+=(r&ae)<<21,r<z)||(r=t.get(e+4),n+=(r&ae)*ui,r<z)||(r=t.get(e+5),n+=(r&ae)*di,r<z)||(r=t.get(e+6),n+=(r&ae)*li,r<z)||(r=t.get(e+7),n+=(r&ae)*hi,r<z))return n;throw new RangeError("Could not decode varint")}function fi(t,e=0){return t instanceof Uint8Array?pi(t,e):Ch(t,e)}var mi=new Float32Array([-0]),gt=new Uint8Array(mi.buffer);function ua(t,e,r){mi[0]=t,e[r]=gt[0],e[r+1]=gt[1],e[r+2]=gt[2],e[r+3]=gt[3]}function da(t,e){return gt[0]=t[e],gt[1]=t[e+1],gt[2]=t[e+2],gt[3]=t[e+3],mi[0]}var gi=new Float64Array([-0]),ue=new Uint8Array(gi.buffer);function la(t,e,r){gi[0]=t,e[r]=ue[0],e[r+1]=ue[1],e[r+2]=ue[2],e[r+3]=ue[3],e[r+4]=ue[4],e[r+5]=ue[5],e[r+6]=ue[6],e[r+7]=ue[7]}function ha(t,e){return ue[0]=t[e],ue[1]=t[e+1],ue[2]=t[e+2],ue[3]=t[e+3],ue[4]=t[e+4],ue[5]=t[e+5],ue[6]=t[e+6],ue[7]=t[e+7],gi[0]}var Dh=BigInt(Number.MAX_SAFE_INTEGER),Uh=BigInt(Number.MIN_SAFE_INTEGER),we=class t{lo;hi;constructor(e,r){this.lo=e|0,this.hi=r|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(r+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let r=~this.lo+1>>>0,n=~this.hi>>>0;return r===0&&(n=n+1>>>0),-(BigInt(r)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,r=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?r===0?e<16384?e<128?1:2:e<2097152?3:4:r<16384?r<128?5:6:r<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Lt;if(e<Dh&&e>Uh)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>pa&&(o=0n,++n>pa&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Lt;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):Lt}},Lt=new we(0,0);Lt.toBigInt=function(){return 0n};Lt.zzEncode=Lt.zzDecode=function(){return this};Lt.length=function(){return 1};var pa=4294967296n;function fa(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 ma(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 yi(t,e,r){let n=r,o,i;for(let s=0;s<t.length;++s)o=t.charCodeAt(s),o<128?e[r++]=o:o<2048?(e[r++]=o>>6|192,e[r++]=o&63|128):(o&64512)===55296&&((i=t.charCodeAt(s+1))&64512)===56320?(o=65536+((o&1023)<<10)+(i&1023),++s,e[r++]=o>>18|240,e[r++]=o>>12&63|128,e[r++]=o>>6&63|128,e[r++]=o&63|128):(e[r++]=o>>12|224,e[r++]=o>>6&63|128,e[r++]=o&63|128);return r-n}function Te(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function yn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var bi=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Te(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Te(this,4);return yn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Te(this,4);return yn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Te(this,4);let e=da(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Te(this,4);let e=ha(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),r=this.pos,n=this.pos+e;if(n>this.len)throw Te(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return ma(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Te(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Te(this);while((this.buf[this.pos++]&128)!==0);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new we(0,0),r=0;if(this.len-this.pos>4){for(;r<4;++r)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;r=0}else{for(;r<3;++r){if(this.pos>=this.len)throw Te(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<r*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<r*7)>>>0,e}if(this.len-this.pos>4){for(;r<5;++r)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;r<5;++r){if(this.pos>=this.len)throw Te(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<r*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Te(this,8);let e=yn(this.buf,this.pos+=4),r=yn(this.buf,this.pos+=4);return new we(e,r)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=pi(this.buf,this.pos);return this.pos+=ze(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Ur(t){return new bi(t instanceof Uint8Array?t:t.subarray())}function bn(t,e,r){let n=Ur(t);return e.decode(n,void 0,r)}var ya=G("node:buffer");function xn(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Dt(t=0){return xn(ya.Buffer.allocUnsafe(t))}var Ia=G("node:buffer");var xi={};V(xi,{base10:()=>Oh});var Oh=lt({prefix:"9",name:"base10",alphabet:"0123456789"});var wi={};V(wi,{base16:()=>Th,base16upper:()=>_h});var Th=H({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),_h=H({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ei={};V(Ei,{base2:()=>Ph});var Ph=H({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var vi={};V(vi,{base256emoji:()=>Kh});var ba=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}"),Nh=ba.reduce((t,e,r)=>(t[r]=e,t),[]),Rh=ba.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function Fh(t){return t.reduce((e,r)=>(e+=Nh[r],e),"")}function kh(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Rh[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Kh=Ft({prefix:"\u{1F680}",name:"base256emoji",encode:Fh,decode:kh});var Ii={};V(Ii,{base64:()=>Mh,base64pad:()=>qh,base64url:()=>Si,base64urlpad:()=>Vh});var Mh=H({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qh=H({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Si=H({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vh=H({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ai={};V(Ai,{base8:()=>zh});var zh=H({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Bi={};V(Bi,{identity:()=>Hh});var Hh=Ft({prefix:"\0",name:"identity",encode:t=>Ps(t),decode:t=>_s(t)});var Ay=new TextEncoder,By=new TextDecoder;var Oi={};V(Oi,{sha256:()=>Ui,sha512:()=>Gh});var Di=Nt(G("crypto"),1);var Yh=20;function Li({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new Ci(t,e,r,n,o)}var Ci=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Yh,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?xa(n,this.code,r?.truncate):n.then(o=>xa(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function xa(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 qt(e,t)}var Ui=Li({name:"sha2-256",code:18,encode:t=>Ie(Di.default.createHash("sha256").update(t).digest())}),Gh=Li({name:"sha2-512",code:19,encode:t=>Ie(Di.default.createHash("sha512").update(t).digest())});var yt={...Bi,...Ei,...Ai,...xi,...wi,...no,...oo,...ro,...Ii,...vi},Ky={...Oi,...co};function va(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Ea=va("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ti=va("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=Dt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Wh={utf8:Ea,"utf-8":Ea,hex:yt.base16,latin1:Ti,ascii:Ti,binary:Ti,...yt},Sa=Wh;function Aa(t,e="utf8"){let r=Sa[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?xn(Ia.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function _i(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Dt(s);o+s>e&&(n=Dt(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Ut=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Pi(){}var Ri=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Xh=_i();function Zh(t){return globalThis.Buffer!=null?Dt(t):Xh(t)}var Tr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ut(Pi,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Ut(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Fi((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(wn,10,we.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=we.fromBigInt(e);return this._push(wn,r.length(),r)}uint64Number(e){return this._push(Dr,ze(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let r=we.fromBigInt(e).zzEncode();return this._push(wn,r.length(),r)}sint64Number(e){let r=we.fromNumber(e).zzEncode();return this._push(wn,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ni,1,e?1:0)}fixed32(e){return this._push(Or,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=we.fromBigInt(e);return this._push(Or,4,r.lo)._push(Or,4,r.hi)}fixed64Number(e){let r=we.fromNumber(e);return this._push(Or,4,r.lo)._push(Or,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(ua,4,e)}double(e){return this._push(la,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Ni,1,0):this.uint32(r)._push(Jh,r,e)}string(e){let r=fa(e);return r!==0?this.uint32(r)._push(yi,r,e):this._push(Ni,1,0)}fork(){return this.states=new Ri(this),this.head=this.tail=new Ut(Pi,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 Ut(Pi,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=Zh(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Ni(t,e,r){e[r]=t&255}function Qh(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Fi=class extends Ut{next;constructor(e,r){super(Qh,e,r),this.next=void 0}};function wn(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 Or(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 Jh(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Tr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(ep,e,t),this},Tr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(tp,e,t),this});function ep(t,e,r){e.set(t,r)}function tp(t,e,r){t.length<40?yi(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Aa(t),r)}function ki(){return new Tr}function En(t,e){let r=ki();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*vn(t,e,r){let n=Ur(t);yield*e.stream(n,void 0,"$",r)}var Sn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function In(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function Ki(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 In("enum",Sn.VARINT,r,n,o)}function An(t,e,r){return In("message",Sn.LENGTH_DELIMITED,t,e,r)}var le;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(le||(le={}));var Mi;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(Mi||(Mi={}));(function(t){t.codec=()=>Ki(Mi)})(le||(le={}));var _r;(function(t){let e;t.codec=()=>(e==null&&(e=An((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 p=i.uint32();switch(p>>>3){case 1:{a.Type=le.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(p&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>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(p&7);break}}}})),e);function r(i){return En(i,t.codec())}t.encode=r;function n(i,s){return bn(i,t.codec(),s)}t.decode=n;function o(i,s){return vn(i,t.codec(),s)}t.stream=o})(_r||(_r={}));var qi;(function(t){let e;t.codec=()=>(e==null&&(e=An((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 p=i.uint32();switch(p>>>3){case 1:{a.Type=le.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(p&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>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(p&7);break}}}})),e);function r(i){return En(i,t.codec())}t.encode=r;function n(i,s){return bn(i,t.codec(),s)}t.decode=n;function o(i,s){return vn(i,t.codec(),s)}t.stream=o})(qi||(qi={}));var Pa=Nt(G("node:crypto"),1);var Bn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(tn(e),Ve(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),St(o)}update(e){return Zt(this),this.iHash.update(e),this}digestInto(e){Zt(this),rn(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}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ba=(()=>{let t=((e,r,n)=>new Bn(e,r).update(n).digest());return t.create=(e,r)=>new Bn(e,r),t})();var Ca=(t,e)=>(t+(t>=0?e:-e)/La)/e;function np(t,e,r){Jo("scalar",t,He,r);let[[n,o],[i,s]]=e,c=Ca(s*t,r),a=Ca(-o*t,r),u=t-c*n-a*i,p=-c*o-a*s,l=u<He,f=p<He;l&&(u=-u),f&&(p=-p);let h=Br(Math.ceil(Jt(r)/2))+bt;if(u<He||u>=h||p<He||p>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:u,k2neg:f,k2:p}}function zi(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Vi(t,e){At(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return It(r.lowS,"lowS"),It(r.prehash,"prehash"),r.format!==void 0&&zi(r.format),r}var Hi=class extends Error{constructor(e=""){super(e)}},_e={Err:Hi,_tlv:{encode:(t,e)=>{let{Err:r}=_e;if(Ir(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(typeof e!="string")throw new TypeError('"data" expected string, got type='+typeof e);if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Ar(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Ar(o.length/2|128):"";return Ar(t)+i+o+e},decode(t,e){let{Err:r}=_e;e=Q(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let p of u)s=s<<8|p;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}=_e;if(dn(t),t<He)throw new e("integer: negative integers are not allowed");let r=Ar(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}=_e;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 Qt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=_e,o=Q(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:p}=n.decode(2,a);if(p.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}=_e,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}};Object.freeze(_e._tlv);Object.freeze(_e._int);Object.freeze(_e);var He=BigInt(0),bt=BigInt(1),La=BigInt(2),Cn=BigInt(3),op=BigInt(4);function Da(t,e={}){let r=na("weierstrass",t,e),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:c}=i;At(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a,allowInfinityPoint:u}=e;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let p=Oa(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(j,b,L){if(u&&b.is0())return Uint8Array.of(0);let{x:T,y:w}=b.toAffine(),g=n.toBytes(T);if(It(L,"isCompressed"),L){l();let E=!n.isOdd(w);return ct(Ua(E),g)}else return ct(Uint8Array.of(4),g,n.toBytes(w))}function h(j){Q(j,void 0,"Point");let{publicKey:b,publicKeyUncompressed:L}=p,T=j.length,w=j[0],g=j.subarray(1);if(u&&T===1&&w===0)return{x:n.ZERO,y:n.ZERO};if(T===b&&(w===2||w===3)){let E=n.fromBytes(g);if(!n.isValid(E))throw new Error("bad point: is not on curve, wrong x");let I=x(E),S;try{S=n.sqrt(I)}catch(q){let M=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+M)}l();let D=n.isOdd(S);return(w&1)===1!==D&&(S=n.neg(S)),{x:E,y:S}}else if(T===L&&w===4){let E=n.BYTES,I=n.fromBytes(g.subarray(0,E)),S=n.fromBytes(g.subarray(E,E*2));if(!v(I,S))throw new Error("bad point: is not on curve");return{x:I,y:S}}else throw new Error(`bad point: got length ${T}, expected compressed=${b} or uncompressed=${L}`)}let d=e.toBytes===void 0?f:e.toBytes,m=e.fromBytes===void 0?h:e.fromBytes;function x(j){let b=n.sqr(j),L=n.mul(b,j);return n.add(n.add(L,n.mul(j,i.a)),i.b)}function v(j,b){let L=n.sqr(b),T=x(j);return n.eql(L,T)}if(!v(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let C=n.mul(n.pow(i.a,Cn),op),R=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(C,R)))throw new Error("bad curve params: a or b");function P(j,b,L=!1){if(!n.isValid(b)||L&&n.is0(b))throw new Error(`bad point coordinate ${j}`);return b}function U(j){if(!(j instanceof O))throw new Error("Weierstrass Point expected")}function F(j){if(!a||!a.basises)throw new Error("no endo");return np(j,a.basises,o.ORDER)}function K(j,b,L,T,w){return L=new O(n.mul(L.X,j),L.Y,L.Z),b=Cr(T,b),L=Cr(w,L),b.add(L)}class O{static BASE=new O(i.Gx,i.Gy,n.ONE);static ZERO=new O(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(b,L,T){this.X=P("x",b),this.Y=P("y",L,!0),this.Z=P("z",T),Object.freeze(this)}static CURVE(){return i}static fromAffine(b){let{x:L,y:T}=b||{};if(!b||!n.isValid(L)||!n.isValid(T))throw new Error("invalid affine point");if(b instanceof O)throw new Error("projective point not allowed");return n.is0(L)&&n.is0(T)?O.ZERO:new O(L,T,n.ONE)}static fromBytes(b){let L=O.fromAffine(m(Q(b,void 0,"point")));return L.assertValidity(),L}static fromHex(b){return O.fromBytes(un(b))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(b=8,L=!0){return je.createCache(this,b),L||this.multiply(Cn),this}assertValidity(){let b=this;if(b.is0()){if(e.allowInfinityPoint&&n.is0(b.X)&&n.eql(b.Y,n.ONE)&&n.is0(b.Z))return;throw new Error("bad point: ZERO")}let{x:L,y:T}=b.toAffine();if(!n.isValid(L)||!n.isValid(T))throw new Error("bad point: x or y not field elements");if(!v(L,T))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:b}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(b)}equals(b){U(b);let{X:L,Y:T,Z:w}=this,{X:g,Y:E,Z:I}=b,S=n.eql(n.mul(L,I),n.mul(g,w)),D=n.eql(n.mul(T,I),n.mul(E,w));return S&&D}negate(){return new O(this.X,n.neg(this.Y),this.Z)}double(){let{a:b,b:L}=i,T=n.mul(L,Cn),{X:w,Y:g,Z:E}=this,I=n.ZERO,S=n.ZERO,D=n.ZERO,_=n.mul(w,w),q=n.mul(g,g),M=n.mul(E,E),k=n.mul(w,g);return k=n.add(k,k),D=n.mul(w,E),D=n.add(D,D),I=n.mul(b,D),S=n.mul(T,M),S=n.add(I,S),I=n.sub(q,S),S=n.add(q,S),S=n.mul(I,S),I=n.mul(k,I),D=n.mul(T,D),M=n.mul(b,M),k=n.sub(_,M),k=n.mul(b,k),k=n.add(k,D),D=n.add(_,_),_=n.add(D,_),_=n.add(_,M),_=n.mul(_,k),S=n.add(S,_),M=n.mul(g,E),M=n.add(M,M),_=n.mul(M,k),I=n.sub(I,_),D=n.mul(M,q),D=n.add(D,D),D=n.add(D,D),new O(I,S,D)}add(b){U(b);let{X:L,Y:T,Z:w}=this,{X:g,Y:E,Z:I}=b,S=n.ZERO,D=n.ZERO,_=n.ZERO,q=i.a,M=n.mul(i.b,Cn),k=n.mul(L,g),ee=n.mul(T,E),te=n.mul(w,I),re=n.add(L,T),Y=n.add(g,E);re=n.mul(re,Y),Y=n.add(k,ee),re=n.sub(re,Y),Y=n.add(L,w);let he=n.add(g,I);return Y=n.mul(Y,he),he=n.add(k,te),Y=n.sub(Y,he),he=n.add(T,w),S=n.add(E,I),he=n.mul(he,S),S=n.add(ee,te),he=n.sub(he,S),_=n.mul(q,Y),S=n.mul(M,te),_=n.add(S,_),S=n.sub(ee,_),_=n.add(ee,_),D=n.mul(S,_),ee=n.add(k,k),ee=n.add(ee,k),te=n.mul(q,te),Y=n.mul(M,Y),ee=n.add(ee,te),te=n.sub(k,te),te=n.mul(q,te),Y=n.add(Y,te),k=n.mul(ee,Y),D=n.add(D,k),k=n.mul(he,Y),S=n.mul(re,S),S=n.sub(S,k),k=n.mul(re,ee),_=n.mul(he,_),_=n.add(_,k),new O(S,D,_)}subtract(b){return U(b),this.add(b.negate())}is0(){return this.equals(O.ZERO)}multiply(b){let{endo:L}=e;if(!o.isValidNot0(b))throw new RangeError("invalid scalar: out of range");let T,w,g=E=>je.cached(this,E,I=>ci(O,I));if(L){let{k1neg:E,k1:I,k2neg:S,k2:D}=F(b),{p:_,f:q}=g(I),{p:M,f:k}=g(D);w=q.add(k),T=K(L.beta,_,M,E,S)}else{let{p:E,f:I}=g(b);T=E,w=I}return ci(O,[T,w])[0]}multiplyUnsafe(b){let{endo:L}=e,T=this,w=b;if(!o.isValid(w))throw new RangeError("invalid scalar: out of range");if(w===He||T.is0())return O.ZERO;if(w===bt)return T;if(je.hasCache(this))return this.multiply(w);if(L){let{k1neg:g,k1:E,k2neg:I,k2:S}=F(w),{p1:D,p2:_}=ra(O,T,E,S);return K(L.beta,D,_,g,I)}else return je.unsafe(T,w)}toAffine(b){let L=this,T=b,{X:w,Y:g,Z:E}=L;if(n.eql(E,n.ONE))return{x:w,y:g};let I=L.is0();T==null&&(T=I?n.ONE:n.inv(E));let S=n.mul(w,T),D=n.mul(g,T),_=n.mul(E,T);if(I)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:S,y:D}}isTorsionFree(){let{isTorsionFree:b}=e;return s===bt?!0:b?b(O,this):je.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:b}=e;return s===bt?this:b?b(O,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===bt?this.is0():this.clearCofactor().is0()}toBytes(b=!0){return It(b,"isCompressed"),this.assertValidity(),d(O,this,b)}toHex(b=!0){return Go(this.toBytes(b))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ce=o.BITS,je=new fn(O,e.endo?Math.ceil(ce/2):ce);return ce>=8&&O.BASE.precompute(8),Object.freeze(O.prototype),Object.freeze(O),O}function Ua(t){return Uint8Array.of(t?2:3)}function Oa(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function ip(t,e={}){let{Fn:r}=t,n=e.randomBytes===void 0?Xo:e.randomBytes,o=Object.assign(Oa(t.Fp,r),{seed:Math.max(ri(r.ORDER),16)});function i(h){try{let d=r.fromBytes(h);return r.isValidNot0(d)}catch{return!1}}function s(h,d){let{publicKey:m,publicKeyUncompressed:x}=o;try{let v=h.length;return d===!0&&v!==m||d===!1&&v!==x?!1:!!t.fromBytes(h)}catch{return!1}}function c(h){return h=h===void 0?n(o.seed):h,ni(Q(h,o.seed,"seed"),r.ORDER)}function a(h,d=!0){return t.BASE.multiply(r.fromBytes(h)).toBytes(d)}function u(h){let{secretKey:d,publicKey:m,publicKeyUncompressed:x}=o,v=r._lengths;if(!Wo(h))return;let C=Q(h,void 0,"key").length,R=C===m||C===x,P=C===d||!!v?.includes(C);if(!(R&&P))return R}function p(h,d,m=!0){if(u(h)===!0)throw new Error("first arg must be private key");if(u(d)===!1)throw new Error("second arg must be public key");let x=r.fromBytes(h);return t.fromBytes(d).multiply(x).toBytes(m)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},f=oa(c,a);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:p,keygen:f,Point:t,utils:l,lengths:o})}function Ta(t,e,r={}){let n=e;tn(n),At(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?Xo:r.randomBytes,i=r.hmac===void 0?(w,g)=>Ba(n,w,g):r.hmac,{Fp:s,Fn:c}=t,{ORDER:a,BITS:u}=c,{keygen:p,getPublicKey:l,getSharedSecret:f,utils:h,lengths:d}=ip(t,r),m={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},x=a*La+bt<s.ORDER;function v(w){let g=a>>bt;return w>g}function C(w,g){if(!c.isValidNot0(g))throw new Error(`invalid signature ${w}: out of range 1..Point.Fn.ORDER`);return g}function R(){if(x)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function P(w,g){zi(g);let E=d.signature,I=g==="compact"?E:g==="recovered"?E+1:void 0;return Q(w,I)}class U{r;s;recovery;constructor(g,E,I){if(this.r=C("r",g),this.s=C("s",E),I!=null){if(R(),![0,1,2,3].includes(I))throw new Error("invalid recovery id");this.recovery=I}Object.freeze(this)}static fromBytes(g,E=m.format){P(g,E);let I;if(E==="der"){let{r:q,s:M}=_e.toSig(Q(g));return new U(q,M)}E==="recovered"&&(I=g[0],E="compact",g=g.subarray(1));let S=d.signature/2,D=g.subarray(0,S),_=g.subarray(S,S*2);return new U(c.fromBytes(D),c.fromBytes(_),I)}static fromHex(g,E){return this.fromBytes(un(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 U(this.r,this.s,g)}recoverPublicKey(g){let{r:E,s:I}=this,S=this.assertRecovery(),D=S===2||S===3?E+a:E;if(!s.isValid(D))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let _=s.toBytes(D),q=t.fromBytes(ct(Ua((S&1)===0),_)),M=c.inv(D),k=K(Q(g,void 0,"msgHash")),ee=c.create(-k*M),te=c.create(I*M),re=t.BASE.multiplyUnsafe(ee).add(q.multiplyUnsafe(te));if(re.is0())throw new Error("invalid recovery: point at infinify");return re.assertValidity(),re}hasHighS(){return v(this.s)}toBytes(g=m.format){if(zi(g),g==="der")return un(_e.hexFromSig(this));let{r:E,s:I}=this,S=c.toBytes(E),D=c.toBytes(I);return g==="recovered"?(R(),ct(Uint8Array.of(this.assertRecovery()),S,D)):ct(S,D)}toHex(g){return Go(this.toBytes(g))}}Object.freeze(U.prototype),Object.freeze(U);let F=r.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let E=Qt(g),I=g.length*8-u;return I>0?E>>BigInt(I):E}:r.bits2int,K=r.bits2int_modN===void 0?function(g){return c.create(F(g))}:r.bits2int_modN,O=Br(u);function ce(w){return Jo("num < 2^"+u,w,He,O),c.toBytes(w)}function je(w,g){return Q(w,void 0,"message"),g?Q(n(w),void 0,"prehashed message"):w}function j(w,g,E){let{lowS:I,prehash:S,extraEntropy:D}=Vi(E,m);w=je(w,S);let _=K(w),q=c.fromBytes(g);if(!c.isValidNot0(q))throw new Error("invalid private key");let M=[ce(q),ce(_)];if(D!=null&&D!==!1){let re=D===!0?o(d.secretKey):D;M.push(Q(re,void 0,"extraEntropy"))}let k=ct(...M),ee=_;function te(re){let Y=F(re);if(!c.isValidNot0(Y))return;let he=c.inv(Y),Pt=t.BASE.multiply(Y).toAffine(),cr=c.create(Pt.x);if(cr===He)return;let qr=c.create(he*c.create(ee+cr*q));if(qr===He)return;let as=(Pt.x===cr?0:2)|Number(Pt.y&bt),us=qr;return I&&v(qr)&&(us=c.neg(qr),as^=1),new U(cr,us,x?void 0:as)}return{seed:k,k2sig:te}}function b(w,g,E={}){let{seed:I,k2sig:S}=j(w,g,E);return Kc(n.outputLen,c.BYTES,i)(I,S).toBytes(E.format)}function L(w,g,E,I={}){let{lowS:S,prehash:D,format:_}=Vi(I,m);if(E=Q(E,void 0,"publicKey"),g=je(g,D),!Wo(w)){let q=w instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+q)}P(w,_);try{let q=U.fromBytes(w,_),M=t.fromBytes(E);if(S&&q.hasHighS())return!1;let{r:k,s:ee}=q,te=K(g),re=c.inv(ee),Y=c.create(te*re),he=c.create(k*re),Pt=t.BASE.multiplyUnsafe(Y).add(M.multiplyUnsafe(he));return Pt.is0()?!1:c.create(Pt.x)===k}catch{return!1}}function T(w,g,E={}){let{prehash:I}=Vi(E,m);return g=je(g,I),U.fromBytes(w,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:p,getPublicKey:l,getSharedSecret:f,utils:h,lengths:d,Point:t,sign:b,verify:L,recoverPublicKey:T,Signature:U,hash:n})}var ji={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},sp={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var _a=BigInt(2);function cp(t){let e=ji.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,p=u*u*t%e,l=xe(p,r,e)*p%e,f=xe(l,r,e)*p%e,h=xe(f,_a,e)*u%e,d=xe(h,o,e)*h%e,m=xe(d,i,e)*d%e,x=xe(m,c,e)*m%e,v=xe(x,a,e)*x%e,C=xe(v,c,e)*m%e,R=xe(C,r,e)*p%e,P=xe(R,s,e)*d%e,U=xe(P,n,e)*u%e,F=xe(U,_a,e);if(!$i.eql($i.sqr(F),t))throw new Error("Cannot find square root");return F}var $i=er(ji.p,{sqrt:cp}),ap=Da(ji,{Fp:$i,endo:sp}),Pr=Ta(ap,Fc);var Ln=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Na(t,e,r,n){n?.signal?.throwIfAborted();let o=Pa.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 Pr.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new Ln(String(s))}}var Dn=class{type="secp256k1";raw;_key;constructor(e){this._key=Fa(e),this.raw=Ra(this._key)}toMultihash(){return De.digest(Xt(this))}toCID(){return oe.createV1(114,this.toMultihash())}toString(){return W.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:nt(this.raw,e.raw)}verify(e,r,n){return Na(this._key,r,e,n)}};function ka(t){return new Dn(t)}function Ra(t){return Pr.Point.fromBytes(t).toBytes()}function Fa(t){try{return Pr.Point.fromBytes(t),t}catch(e){throw new zr(String(e))}}function Ka(t){let{Type:e,Data:r}=_r.decode(t.digest),n=r??new Uint8Array;switch(e){case le.Ed25519:return aa(n);case le.secp256k1:return ka(n);case le.ECDSA:return Bc(n);default:throw new ar}}function Xt(t){return _r.encode({Type:le[t.type],Data:t.raw})}var Ma=Symbol.for("nodejs.util.inspect.custom"),up=114,Nr=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()})`}[Kn]=!0;toString(){return this.string==null&&(this.string=W.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return oe.createV1(up,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return nt(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return nt(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Ma](){return`PeerId(${this.toString()})`}},Un=class extends Nr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},On=class extends Nr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Tn=class extends Nr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},dp=2336,Rr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=De.digest(vt(this.url))}[Ma](){return`PeerId(${this.url})`}[Kn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return oe.createV1(dp,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=fe(e)),e.toString()===this.toString())}};var lp=114,qa=2336;function Va(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=pr(W.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return hp(oe.parse(t));if(e==null)throw new Se('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=pr(e.decode(t))}return za(r)}function za(t){if(fp(t))return new Un({multihash:t});if(pp(t))try{let e=Ka(t);if(e.type==="Ed25519")return new On({multihash:t,publicKey:e});if(e.type==="secp256k1")return new Tn({multihash:t,publicKey:e})}catch{let r=fe(t.digest);return new Rr(new URL(r))}throw new $r("Supplied PeerID Multihash is invalid")}function hp(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==lp&&t.code!==qa)throw new Hr("Supplied PeerID CID is invalid");if(t.code===qa){let e=fe(t.multihash.digest);return new Rr(new URL(e))}return za(t.multihash)}function pp(t){return t.code===De.code}function fp(t){return t.code===Ui.code}function mp(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 Ha(t){let e=mp(t);if(e==null)throw new Se(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Ee=G("node:net");var Ga=Nt(Ya(),1),vp=["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"],Sp=vp.map(t=>new Ga.Netmask(t));function Ji(t){for(let e of Sp)if(e.contains(t))return!0;return!1}function Ip(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function Ap(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 Ji(o)}function Bp(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function Cp(t){let e=t.split(":"),r=e[e.length-1];return Ji(r)}function Lp(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 Wa(t){if((0,Ee.isIPv4)(t))return Ji(t);if(Ip(t))return Ap(t);if(Bp(t))return Cp(t);if((0,Ee.isIPv6)(t))return Lp(t)}function Xa(t){try{let e=Ha(t);switch(e.type){case"ip4":case"ip6":return Wa(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}function Za(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var Qa=G("node:buffer");function ir(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Fr(t,e){return ir(Qa.Buffer.concat(t,e))}var nu=G("node:buffer");var Ja=G("node:buffer");function eu(t=0){return ir(Ja.Buffer.allocUnsafe(t))}function ru(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var tu=ru("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),es=ru("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=eu(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Dp={utf8:tu,"utf-8":tu,hex:yt.base16,latin1:es,ascii:es,binary:es,...yt},Pn=Dp;function kr(t,e="utf8"){let r=Pn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ir(nu.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var ou=G("node:buffer");function Tt(t,e="utf8"){let r=Pn[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?ou.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var se=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},at=class extends Error{static name="ValidationError";name="ValidationError"},Nn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Rn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function rs(t){return e=>Tt(e,t)}function ns(t){return e=>kr(e,t)}function sr(t){return new DataView(t.buffer).getUint16(t.byteOffset).toString()}function _t(t){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,typeof t=="string"?parseInt(t):t),new Uint8Array(e)}function iu(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=kr(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=_t(n);return Fr([r,o],r.length+o.length)}function su(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=ht.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=_t(n);return Fr([r,o],r.length+o.length)}function os(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=Tt(e,"base32"),o=sr(r);return`${n}:${o}`}var is=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 se("Invalid byte value in IP address");e[n]=o}),e},cu=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,Ee.isIPv4)(r[n]),s;i&&(s=is(r[n]),r[n]=Tt(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,Tt(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 se("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},au=function(t){if(t.byteLength!==4)throw new se("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},uu=function(t){if(t.byteLength!==16)throw new se("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 se(`Invalid IPv6 address "${r}"`)}};function du(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new se(`Invalid IPv6 address "${t}"`)}}var ts=Object.values(yt).map(t=>t.decoder),Up=(function(){let t=ts[0].or(ts[1]);return ts.slice(2).forEach(e=>t=t.or(e)),t})();function lu(t){return Up.decode(t)}function hu(t){return e=>t.encoder.encode(e)}function Op(t){if(parseInt(t).toString()!==t)throw new at("Value must be an integer")}function Tp(t){if(t<0)throw new at("Value must be a positive integer, or zero")}function _p(t){return e=>{if(e>t)throw new at(`Value must be smaller than or equal to ${t}`)}}function Pp(...t){return e=>{for(let r of t)r(e)}}var Kr=Pp(Op,Tp,_p(65535));var J=-1,ss=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 Rn(`Protocol ${e} was unknown`);return r}addProtocol(e){this.protocolsByCode.set(e.code,e),this.protocolsByName.set(e.name,e),e.aliases?.forEach(r=>{this.protocolsByName.set(r,e)})}removeProtocol(e){let r=this.protocolsByCode.get(e);r!=null&&(this.protocolsByCode.delete(r.code),this.protocolsByName.delete(r.name),r.aliases?.forEach(n=>{this.protocolsByName.delete(n)}))}},ut=new ss,Ef=[{code:4,name:"ip4",size:32,valueToBytes:is,bytesToValue:au,validate:t=>{if(!(0,Ee.isIPv4)(t))throw new at(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:_t,bytesToValue:sr,validate:Kr},{code:273,name:"udp",size:16,valueToBytes:_t,bytesToValue:sr,validate:Kr},{code:33,name:"dccp",size:16,valueToBytes:_t,bytesToValue:sr,validate:Kr},{code:41,name:"ip6",size:128,valueToBytes:cu,bytesToValue:uu,stringToValue:du,validate:t=>{if(!(0,Ee.isIPv6)(t))throw new at(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:J},{code:43,name:"ipcidr",size:8,bytesToValue:rs("base10"),valueToBytes:ns("base10")},{code:53,name:"dns",size:J},{code:54,name:"dns4",size:J},{code:55,name:"dns6",size:J},{code:56,name:"dnsaddr",size:J},{code:132,name:"sctp",size:16,valueToBytes:_t,bytesToValue:sr,validate:Kr},{code:301,name:"udt"},{code:302,name:"utp"},{code:400,name:"unix",size:J,stringToValue:t=>decodeURIComponent(t),valueToString:t=>encodeURIComponent(t)},{code:421,name:"p2p",aliases:["ipfs"],size:J,bytesToValue:rs("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?ns("base58btc")(t):oe.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:os,valueToBytes:iu},{code:445,name:"onion3",size:296,bytesToValue:os,valueToBytes:su},{code:446,name:"garlic64",size:J},{code:447,name:"garlic32",size:J},{code:448,name:"tls"},{code:449,name:"sni",size:J},{code:454,name:"noise"},{code:460,name:"quic"},{code:461,name:"quic-v1"},{code:465,name:"webtransport"},{code:466,name:"certhash",size:J,bytesToValue:hu(Si),valueToBytes:lu},{code:480,name:"http"},{code:481,name:"http-path",size:J,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:J}];Ef.forEach(t=>{ut.addProtocol(t)});function pu(t){let e=[],r=0;for(;r<t.length;){let n=fi(t,r),o=ut.getProtocol(n),i=ze(n),s=vf(o,t,r+i),c=0;s>0&&o.size===J&&(c=ze(s));let a=i+c+s,u={code:n,name:o.name,bytes:t.subarray(r,r+a)};if(s>0){let p=r+i+c,l=t.subarray(p,p+s);u.value=o.bytesToValue?.(l)??Tt(l)}e.push(u),r+=a}return e}function fu(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=ut.getProtocol(n.code),i=ze(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??kr(n.value),c=s.byteLength,o.size===J&&(a=ze(c)));let u=new Uint8Array(i+a+c),p=0;Dr(n.code,u,p),p+=i,s!=null&&(o.size===J&&(Dr(c,u,p),p+=a),u.set(s,p)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return Fr(r,e)}function mu(t){if(t.charAt(0)!=="/")throw new se('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=ut.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 se(`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 se(`Component ${o} was missing value`);u.value=a.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new se("Incomplete multiaddr");return e}function gu(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=ut.getProtocol(e.code);if(r==null)throw new se(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function vf(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:fi(e,r)}var Sf=Symbol.for("nodejs.util.inspect.custom"),cs=Symbol.for("@multiformats/multiaddr");function If(t){if(t==null&&(t="/"),yu(t))return t.getComponents();if(t instanceof Uint8Array)return pu(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),mu(t);if(Array.isArray(t))return t;throw new se("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Fn=class t{[cs]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=If(e),r.validate!==!1&&Af(this)}get bytes(){return this.#r==null&&(this.#r=fu(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=gu(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 Nn(`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 Za(this.bytes,e.bytes)}[Sf](){return`Multiaddr(${this.toString()})`}};function Af(t){t.getComponents().forEach(e=>{let r=ut.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function yu(t){return!!t?.[cs]}function bu(t){return new Fn(t)}function xu(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function wu(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=>bu(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:Va(c),multiaddrs:s.map(a=>a.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response - %e",s)}}function Eu(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(Bf).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(p=>p.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 Bf(t){return!!Xa(t)}function vu(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var kn=class extends jr{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??vu(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)}[ls]=this;[Symbol.toStringTag]="@libp2p/mdns";[fs]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,Su.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=xu(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),Eu(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=wu(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 Lf(t={}){return e=>new kn(e,t)}return Du(Df);})();
2
+ "use strict";var Libp2PMdns=(()=>{var wu=Object.create;var zr=Object.defineProperty;var Eu=Object.getOwnPropertyDescriptor;var Iu=Object.getOwnPropertyNames;var Su=Object.getPrototypeOf,vu=Object.prototype.hasOwnProperty;var Z=(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 ve=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),V=(t,e)=>{for(var r in e)zr(t,r,{get:e[r],enumerable:!0})},as=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Iu(e))!vu.call(t,o)&&o!==r&&zr(t,o,{get:()=>e[o],enumerable:!(n=Eu(e,o))||n.enumerable});return t};var Nt=(t,e,r)=>(r=t!=null?wu(Su(t)):{},as(e||!t||!t.__esModule?zr(r,"default",{value:t,enumerable:!0}):r,t)),Au=t=>as(zr({},"__esModule",{value:!0}),t);var ps=ve(Mn=>{"use strict";Mn.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};Mn.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 fs=ve(qn=>{"use strict";qn.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};qn.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 ms=ve(Vn=>{"use strict";Vn.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};Vn.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 gs=ve(zn=>{"use strict";zn.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};zn.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 ys=ve(Hn=>{"use strict";Hn.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}`};Hn.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 ws=ve((bs,$n)=>{var xs=(function(t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.decode=l,t.encode=p,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,d){d=~~d,h=h||new Uint8Array(d+r);let m=f.length,b=0;for(let I=0;I<m;){let C=f.charCodeAt(I++);C===46?(h[d++]=b,b=0):b=b*10+(C-48)}return h[d]=b,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,d){d=~~d;let m=d+o,b=-1,I=0,C=0,N=!0,P=!1;h=h||new Uint8Array(d+o);for(let U=0;U<f.length;U++){let R=f.charCodeAt(U);R===58?(N?b!==-1?(d<m&&(h[d]=0),d<m-1&&(h[d+1]=0),d+=2):d<m&&(b=d):(P===!0?(d<m&&(h[d]=C),d++):(d<m&&(h[d]=I>>8),d<m-1&&(h[d+1]=I&255),d+=2),I=0,C=0),N=!0,P=!1):R===46?(d<m&&(h[d]=C),d++,C=0,I=0,N=!1,P=!0):(N=!1,R>=97?R-=87:R>=65?R-=55:(R-=48,C=C*10+R),I=(I<<4)+R)}if(N===!1)P===!0?(d<m&&(h[d]=C),d++):(d<m&&(h[d]=I>>8),d<m-1&&(h[d+1]=I&255),d+=2);else if(b===0)d<m&&(h[d]=0),d<m-1&&(h[d+1]=0),d+=2;else if(b!==-1){d+=2;for(let U=Math.min(d-1,m-1);U>=b+2;U--)h[U]=h[U-2];h[b]=0,h[b+1]=0,b=d}if(b!==d&&b!==-1)for(d>m-2&&(d=m-2);m>b;)h[--m]=d<m&&d>b?h[--d]:0;else for(;d<m;)h[d++]=0;return h},decode(f,h){h=~~h;let d="";for(let m=0;m<o;m+=2)m!==0&&(d+=":"),d+=(f[h+m]<<8|f[h+m+1]).toString(16);return d.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 p(f,h,d){d=~~d;let m=a(f);return typeof h=="function"&&(h=h(d+m)),m===i.size?i.encode(f,h,d):s.encode(f,h,d)}function l(f,h,d){if(h=~~h,d=d||f.length-h,d===i.size)return i.decode(f,h,d);if(d===s.size)return s.decode(f,h,d);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 xs}):typeof $n=="object"&&typeof bs=="object"&&($n.exports=xs)});var Ss=ve(A=>{"use strict";var B=Z("buffer").Buffer,ot=ps(),Lu=fs(),Du=ms(),Xr=gs(),jn=ys(),It=ws(),Uu=0,Es=32768,Gn=32768,Tu=~Gn,Is=32768,Ou=~Is,y=A.name={};y.encode=function(t,e,r,{mail:n=!1}={}){e||(e=B.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:B.byteLength(t.replace(/^\.|\.$/gm,""))+2};var F={};F.encode=function(t,e,r){e||(e=B.alloc(F.encodingLength(t))),r||(r=0);let n=e.write(t,r+1);return e[r]=n,F.encode.bytes=n+1,e};F.encode.bytes=0;F.decode=function(t,e){e||(e=0);let r=t[e],n=t.toString("utf-8",e+1,e+1+r);return F.decode.bytes=r+1,n};F.decode.bytes=0;F.encodingLength=function(t){return B.byteLength(t)+1};var Te={};Te.encode=function(t,e,r){e||(e=Te.encodingLength(t)),r||(r=0);let n=(t.flags||0)&32767,o=t.type==="response"?Es:Uu;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};Te.encode.bytes=12;Te.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&Es?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Du.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:Lu.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))}};Te.decode.bytes=12;Te.encodingLength=function(){return 12};var Xe=A.unknown={};Xe.encode=function(t,e,r){return e||(e=B.alloc(Xe.encodingLength(t))),r||(r=0),e.writeUInt16BE(t.length,r),t.copy(e,r+2),Xe.encode.bytes=t.length+2,e};Xe.encode.bytes=0;Xe.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=t.slice(e+2,e+2+r);return Xe.decode.bytes=r+2,n};Xe.decode.bytes=0;Xe.encodingLength=function(t){return t.length+2};var We=A.ns={};We.encode=function(t,e,r){return e||(e=B.alloc(We.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),We.encode.bytes=y.encode.bytes+2,e};We.encode.bytes=0;We.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e),n=y.decode(t,e+2);return We.decode.bytes=r+2,n};We.decode.bytes=0;We.encodingLength=function(t){return y.encodingLength(t)+2};var Ze=A.soa={};Ze.encode=function(t,e,r){e||(e=B.alloc(Ze.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),Ze.encode.bytes=r-n,e};Ze.encode.bytes=0;Ze.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.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,Ze.decode.bytes=e-r,n};Ze.decode.bytes=0;Ze.encodingLength=function(t){return 22+y.encodingLength(t.mname)+y.encodingLength(t.rname)};var Qe=A.txt={};Qe.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]=B.from(t[o])),!B.isBuffer(t[o]))throw new Error("Must be a Buffer");e||(e=B.alloc(Qe.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),Qe.encode.bytes=r-n,e};Qe.encode.bytes=0;Qe.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 Qe.decode.bytes=e-r,o};Qe.decode.bytes=0;Qe.encodingLength=function(t){Array.isArray(t)||(t=[t]);let e=2;return t.forEach(function(r){typeof r=="string"?e+=B.byteLength(r)+1:e+=r.length+1}),e};var Je=A.null={};Je.encode=function(t,e,r){e||(e=B.alloc(Je.encodingLength(t))),r||(r=0),typeof t=="string"&&(t=B.from(t)),t||(t=B.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),Je.encode.bytes=r-n,e};Je.encode.bytes=0;Je.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,Je.decode.bytes=e-r,o};Je.decode.bytes=0;Je.encodingLength=function(t){return t?(B.isBuffer(t)?t.length:B.byteLength(t))+2:2};var et=A.hinfo={};et.encode=function(t,e,r){e||(e=B.alloc(et.encodingLength(t))),r||(r=0);let n=r;return r+=2,F.encode(t.cpu,e,r),r+=F.encode.bytes,F.encode(t.os,e,r),r+=F.encode.bytes,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.cpu=F.decode(t,e),e+=F.decode.bytes,n.os=F.decode(t,e),e+=F.decode.bytes,et.decode.bytes=e-r,n};et.decode.bytes=0;et.encodingLength=function(t){return F.encodingLength(t.cpu)+F.encodingLength(t.os)+2};var De=A.ptr={},_u=A.cname=De,Pu=A.dname=De;De.encode=function(t,e,r){return e||(e=B.alloc(De.encodingLength(t))),r||(r=0),y.encode(t,e,r+2),e.writeUInt16BE(y.encode.bytes,r),De.encode.bytes=y.encode.bytes+2,e};De.encode.bytes=0;De.decode=function(t,e){e||(e=0);let r=y.decode(t,e+2);return De.decode.bytes=y.decode.bytes+2,r};De.decode.bytes=0;De.encodingLength=function(t){return y.encodingLength(t)+2};var tt=A.srv={};tt.encode=function(t,e,r){e||(e=B.alloc(tt.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),tt.encode.bytes=n+2,e};tt.encode.bytes=0;tt.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),tt.decode.bytes=r+2,n};tt.decode.bytes=0;tt.encodingLength=function(t){return 8+y.encodingLength(t.target)};var ge=A.caa={};ge.ISSUER_CRITICAL=128;ge.encode=function(t,e,r){let n=ge.encodingLength(t);return e||(e=B.alloc(ge.encodingLength(t))),r||(r=0),t.issuerCritical&&(t.flags=ge.ISSUER_CRITICAL),e.writeUInt16BE(n-2,r),r+=2,e.writeUInt8(t.flags||0,r),r+=1,F.encode(t.tag,e,r),r+=F.encode.bytes,e.write(t.value,r),r+=B.byteLength(t.value),ge.encode.bytes=n,e};ge.encode.bytes=0;ge.decode=function(t,e){e||(e=0);let r=t.readUInt16BE(e);e+=2;let n=e,o={};return o.flags=t.readUInt8(e),e+=1,o.tag=F.decode(t,e),e+=F.decode.bytes,o.value=t.toString("utf-8",e,n+r),o.issuerCritical=!!(o.flags&ge.ISSUER_CRITICAL),ge.decode.bytes=r+2,o};ge.decode.bytes=0;ge.encodingLength=function(t){return F.encodingLength(t.tag)+F.encodingLength(t.value)+2};var lt=A.mx={};lt.encode=function(t,e,r){e||(e=B.alloc(lt.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),lt.encode.bytes=r-n,e};lt.encode.bytes=0;lt.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,lt.decode.bytes=e-r,n};lt.encodingLength=function(t){return 4+y.encodingLength(t.exchange)};var rt=A.a={};rt.encode=function(t,e,r){return e||(e=B.alloc(rt.encodingLength(t))),r||(r=0),e.writeUInt16BE(4,r),r+=2,It.v4.encode(t,e,r),rt.encode.bytes=6,e};rt.encode.bytes=0;rt.decode=function(t,e){e||(e=0),e+=2;let r=It.v4.decode(t,e);return rt.decode.bytes=6,r};rt.decode.bytes=0;rt.encodingLength=function(){return 6};var nt=A.aaaa={};nt.encode=function(t,e,r){return e||(e=B.alloc(nt.encodingLength(t))),r||(r=0),e.writeUInt16BE(16,r),r+=2,It.v6.encode(t,e,r),nt.encode.bytes=18,e};nt.encode.bytes=0;nt.decode=function(t,e){e||(e=0),e+=2;let r=It.v6.decode(t,e);return nt.decode.bytes=18,r};nt.decode.bytes=0;nt.encodingLength=function(){return 18};var me=A.option={};me.encode=function(t,e,r){e||(e=B.alloc(me.encodingLength(t))),r||(r=0);let n=r,o=jn.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||It.familyOf(t.ip),c=It.encode(t.ip,B.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 p=t.tags.length*2;e.writeUInt16BE(p,r),r+=2;for(let l of t.tags)e.writeUInt16BE(l,r),r+=2;break;default:throw new Error(`Unknown roption code: ${t.code}`)}return me.encode.bytes=r-n,e};me.encode.bytes=0;me.decode=function(t,e){e||(e=0);let r={};r.code=t.readUInt16BE(e),r.type=jn.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=B.alloc(r.family===1?4:16);t.copy(o,0,e,e+n-4),r.ip=It.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 me.decode.bytes=n+4,r};me.decode.bytes=0;me.encodingLength=function(t){if(t.data)return t.data.length+4;switch(jn.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=A.opt={};xe.encode=function(t,e,r){e||(e=B.alloc(xe.encodingLength(t))),r||(r=0);let n=r,o=Rt(t,me);return e.writeUInt16BE(o,r),r=lr(t,me,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++]=me.decode(t,e),e+=me.decode.bytes,o-=me.decode.bytes;return xe.decode.bytes=e-r,n};xe.decode.bytes=0;xe.encodingLength=function(t){return 2+Rt(t||[],me)};var le=A.dnskey={};le.PROTOCOL_DNSSEC=3;le.ZONE_KEY=128;le.SECURE_ENTRYPOINT=32768;le.encode=function(t,e,r){e||(e=B.alloc(le.encodingLength(t))),r||(r=0);let n=r,o=t.key;if(!B.isBuffer(o))throw new Error("Key must be a Buffer");return r+=2,e.writeUInt16BE(t.flags,r),r+=2,e.writeUInt8(le.PROTOCOL_DNSSEC,r),r+=1,e.writeUInt8(t.algorithm,r),r+=1,o.copy(e,r,0,o.length),r+=o.length,le.encode.bytes=r-n,e.writeUInt16BE(le.encode.bytes-2,n),e};le.encode.bytes=0;le.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)!==le.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,le.decode.bytes=e-r,n};le.decode.bytes=0;le.encodingLength=function(t){return 6+B.byteLength(t.key)};var Re=A.rrsig={};Re.encode=function(t,e,r){e||(e=B.alloc(Re.encodingLength(t))),r||(r=0);let n=r,o=t.signature;if(!B.isBuffer(o))throw new Error("Signature must be a Buffer");return r+=2,e.writeUInt16BE(ot.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,Re.encode.bytes=r-n,e.writeUInt16BE(Re.encode.bytes-2,n),e};Re.encode.bytes=0;Re.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.typeCovered=ot.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,Re.decode.bytes=e-r,n};Re.decode.bytes=0;Re.encodingLength=function(t){return 20+y.encodingLength(t.signersName)+B.byteLength(t.signature)};var ke=A.rp={};ke.encode=function(t,e,r){e||(e=B.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 Q={};Q.encode=function(t,e,r){e||(e=B.alloc(Q.encodingLength(t))),r||(r=0);let n=r;for(var o=[],i=0;i<t.length;i++){var s=ot.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=B.from(o[i]);e.writeUInt8(i,r),r+=1,e.writeUInt8(c.length,r),r+=1,c.copy(e,r),r+=c.length}return Q.encode.bytes=r-n,e};Q.encode.bytes=0;Q.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 p=ot.toString(i<<8|c<<3|u);o.push(p)}e+=s}return Q.decode.bytes=e-n,o};Q.decode.bytes=0;Q.encodingLength=function(t){for(var e=[],r=0;r<t.length;r++){var n=ot.toType(t[r]);e[n>>8]=Math.max(e[n>>8]||0,n&255)}var o=0;for(r=0;r<e.length;r++)e[r]!==void 0&&(o+=2+Math.ceil((e[r]+1)/8));return o};var Ke=A.nsec={};Ke.encode=function(t,e,r){e||(e=B.alloc(Ke.encodingLength(t))),r||(r=0);let n=r;return r+=2,y.encode(t.nextDomain,e,r),r+=y.encode.bytes,Q.encode(t.rrtypes,e,r),r+=Q.encode.bytes,Ke.encode.bytes=r-n,e.writeUInt16BE(Ke.encode.bytes-2,n),e};Ke.encode.bytes=0;Ke.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);return e+=2,n.nextDomain=y.decode(t,e),e+=y.decode.bytes,n.rrtypes=Q.decode(t,e,o-(e-r)),e+=Q.decode.bytes,Ke.decode.bytes=e-r,n};Ke.decode.bytes=0;Ke.encodingLength=function(t){return 2+y.encodingLength(t.nextDomain)+Q.encodingLength(t.rrtypes)};var Me=A.nsec3={};Me.encode=function(t,e,r){e||(e=B.alloc(Me.encodingLength(t))),r||(r=0);let n=r,o=t.salt;if(!B.isBuffer(o))throw new Error("salt must be a Buffer");let i=t.nextDomain;if(!B.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,Q.encode(t.rrtypes,e,r),r+=Q.encode.bytes,Me.encode.bytes=r-n,e.writeUInt16BE(Me.encode.bytes-2,n),e};Me.encode.bytes=0;Me.decode=function(t,e){e||(e=0);let r=e;var n={},o=t.readUInt16BE(e);e+=2,n.algorithm=t.readUInt8(e),e+=1,n.flags=t.readUInt8(e),e+=1,n.iterations=t.readUInt16BE(e),e+=2;let i=t.readUInt8(e);e+=1,n.salt=t.slice(e,e+i),e+=i;let s=t.readUInt8(e);return e+=1,n.nextDomain=t.slice(e,e+s),e+=s,n.rrtypes=Q.decode(t,e,o-(e-r)),e+=Q.decode.bytes,Me.decode.bytes=e-r,n};Me.decode.bytes=0;Me.encodingLength=function(t){return 8+t.salt.length+t.nextDomain.length+Q.encodingLength(t.rrtypes)};var qe=A.ds={};qe.encode=function(t,e,r){e||(e=B.alloc(qe.encodingLength(t))),r||(r=0);let n=r,o=t.digest;if(!B.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+B.byteLength(t.digest)};var ye=A.sshfp={};ye.getFingerprintLengthForHashType=function(e){switch(e){case 1:return 20;case 2:return 32}};ye.encode=function(e,r,n){r||(r=B.alloc(ye.encodingLength(e))),n||(n=0);let o=n;n+=2,r[n]=e.algorithm,n+=1,r[n]=e.hash,n+=1;let i=B.from(e.fingerprint.toUpperCase(),"hex");if(i.length!==ye.getFingerprintLengthForHashType(e.hash))throw new Error("Invalid fingerprint length");return i.copy(r,n),n+=i.byteLength,ye.encode.bytes=n-o,r.writeUInt16BE(ye.encode.bytes-2,o),r};ye.encode.bytes=0;ye.decode=function(e,r){r||(r=0);let n=r,o={};r+=2,o.algorithm=e[r],r+=1,o.hash=e[r],r+=1;let i=ye.getFingerprintLengthForHashType(o.hash);return o.fingerprint=e.slice(r,r+i).toString("hex").toUpperCase(),r+=i,ye.decode.bytes=r-n,o};ye.decode.bytes=0;ye.encodingLength=function(t){return 4+B.from(t.fingerprint,"hex").byteLength};var Ve=A.naptr={};Ve.encode=function(t,e,r){e||(e=B.alloc(Ve.encodingLength(t))),r||(r=0);let n=r;return r+=2,e.writeUInt16BE(t.order||0,r),r+=2,e.writeUInt16BE(t.preference||0,r),r+=2,F.encode(t.flags,e,r),r+=F.encode.bytes,F.encode(t.services,e,r),r+=F.encode.bytes,F.encode(t.regexp,e,r),r+=F.encode.bytes,y.encode(t.replacement,e,r),r+=y.encode.bytes,Ve.encode.bytes=r-n,e.writeUInt16BE(Ve.encode.bytes-2,n),e};Ve.encode.bytes=0;Ve.decode=function(t,e){e||(e=0);let r=e,n={};return e+=2,n.order=t.readUInt16BE(e),e+=2,n.preference=t.readUInt16BE(e),e+=2,n.flags=F.decode(t,e),e+=F.decode.bytes,n.services=F.decode(t,e),e+=F.decode.bytes,n.regexp=F.decode(t,e),e+=F.decode.bytes,n.replacement=y.decode(t,e),e+=y.decode.bytes,Ve.decode.bytes=e-r,n};Ve.decode.bytes=0;Ve.encodingLength=function(t){return F.encodingLength(t.flags)+F.encodingLength(t.services)+F.encodingLength(t.regexp)+y.encodingLength(t.replacement)+6};var ze=A.tlsa={};ze.encode=function(t,e,r){e||(e=B.alloc(ze.encodingLength(t))),r||(r=0);let n=r,o=t.certificate;if(!B.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,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={},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,ze.decode.bytes=e-r,n};ze.decode.bytes=0;ze.encodingLength=function(t){return 5+B.byteLength(t.certificate)};var Yn=A.record=function(t){switch(t.toUpperCase()){case"A":return rt;case"PTR":return De;case"CNAME":return _u;case"DNAME":return Pu;case"TXT":return Qe;case"NULL":return Je;case"AAAA":return nt;case"SRV":return tt;case"HINFO":return et;case"CAA":return ge;case"NS":return We;case"SOA":return Ze;case"MX":return lt;case"OPT":return xe;case"DNSKEY":return le;case"RRSIG":return Re;case"RP":return ke;case"NSEC":return Ke;case"NSEC3":return Me;case"SSHFP":return ye;case"DS":return qe;case"NAPTR":return Ve;case"TLSA":return ze}return Xe},oe=A.answer={};oe.encode=function(t,e,r){e||(e=B.alloc(oe.encodingLength(t))),r||(r=0);let n=r;if(y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ot.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=Xr.toClass(t.class===void 0?"IN":t.class);t.flush&&(o|=Gn),e.writeUInt16BE(o,r+2),e.writeUInt32BE(t.ttl||0,r+4),r+=8;let i=Yn(t.type);i.encode(t.data,e,r),r+=i.encode.bytes}return oe.encode.bytes=r-n,e};oe.encode.bytes=0;oe.decode=function(t,e){e||(e=0);let r={},n=e;if(r.name=y.decode(t,e),e+=y.decode.bytes,r.type=ot.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=Xr.toString(o&Tu),r.flush=!!(o&Gn);let i=Yn(r.type);r.data=i.decode(t,e+8),e+=8+i.decode.bytes}return oe.decode.bytes=e-n,r};oe.decode.bytes=0;oe.encodingLength=function(t){let e=t.data!==null&&t.data!==void 0?t.data:t.options;return y.encodingLength(t.name)+8+Yn(t.type).encodingLength(e)};var Ue=A.question={};Ue.encode=function(t,e,r){e||(e=B.alloc(Ue.encodingLength(t))),r||(r=0);let n=r;return y.encode(t.name,e,r),r+=y.encode.bytes,e.writeUInt16BE(ot.toType(t.type),r),r+=2,e.writeUInt16BE(Xr.toClass(t.class===void 0?"IN":t.class),r),r+=2,Ue.encode.bytes=r-n,t};Ue.encode.bytes=0;Ue.decode=function(t,e){e||(e=0);let r=e,n={};return n.name=y.decode(t,e),e+=y.decode.bytes,n.type=ot.toString(t.readUInt16BE(e)),e+=2,n.class=Xr.toString(t.readUInt16BE(e)),e+=2,n.class&Is&&(n.class&=Ou),Ue.decode.bytes=e-r,n};Ue.decode.bytes=0;Ue.encodingLength=function(t){return y.encodingLength(t.name)+4};A.AUTHORITATIVE_ANSWER=1024;A.TRUNCATED_RESPONSE=512;A.RECURSION_DESIRED=256;A.RECURSION_AVAILABLE=128;A.AUTHENTIC_DATA=32;A.CHECKING_DISABLED=16;A.DNSSEC_OK=32768;A.encode=function(t,e,r){let n=!e;n&&(e=B.alloc(A.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=[]),Te.encode(t,e,r),r+=Te.encode.bytes,r=lr(t.questions,Ue,e,r),r=lr(t.answers,oe,e,r),r=lr(t.authorities,oe,e,r),r=lr(t.additionals,oe,e,r),A.encode.bytes=r-o,n&&A.encode.bytes!==e.length?e.slice(0,A.encode.bytes):e};A.encode.bytes=0;A.decode=function(t,e){e||(e=0);let r=e,n=Te.decode(t,e);return e+=Te.decode.bytes,e=Yr(n.questions,Ue,t,e),e=Yr(n.answers,oe,t,e),e=Yr(n.authorities,oe,t,e),e=Yr(n.additionals,oe,t,e),A.decode.bytes=e-r,n};A.decode.bytes=0;A.encodingLength=function(t){return Te.encodingLength(t)+Rt(t.questions||[],Ue)+Rt(t.answers||[],oe)+Rt(t.authorities||[],oe)+Rt(t.additionals||[],oe)};A.streamEncode=function(t){let e=A.encode(t),r=B.alloc(2);r.writeUInt16BE(e.byteLength);let n=B.concat([r,e]);return A.streamEncode.bytes=n.byteLength,n};A.streamEncode.bytes=0;A.streamDecode=function(t){let e=t.readUInt16BE(0);if(t.byteLength<e+2)return null;let r=A.decode(t.slice(2));return A.streamDecode.bytes=A.decode.bytes,r};A.streamDecode.bytes=0;function Rt(t,e){let r=0;for(let n=0;n<t.length;n++)r+=e.encodingLength(t[n]);return r}function lr(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 Yr(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 Bs=ve((hf,As)=>{"use strict";var vs=Mu;process.nextTick(Ku,42);As.exports=Fu;function Fu(t){var e=n;return r;function r(o){e(o||Ru)}function n(o){var i=[o];e=s,t(c);function s(a){i.push(a)}function c(a){var u=arguments;for(e=Nu(a)?n:p;i.length;)p(i.shift());function p(l){vs(ku,l,u)}}}}function Nu(t){return Object.prototype.toString.call(t)==="[object Error]"}function Ru(){}function ku(t,e){t.apply(null,e)}function Ku(t){t===42&&(vs=process.nextTick)}function Mu(t,e,r){process.nextTick(function(){t(e,r)})}});var Ds=ve((pf,Ls)=>{var Xn=Ss(),qu=Z("dgram"),Vu=Bs(),zu=Z("events"),Zn=Z("os"),Wn=function(){};Ls.exports=function(t){t||(t={});var e=new zu.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||qu.createSocket({type:n,reuseAddr:t.reuseAddr!==!1,toString:function(){return n}});u.on("error",function(l){l.code==="EACCES"||l.code==="EADDRINUSE"?e.emit("error",l):e.emit("warning",l)}),u.on("message",function(l,f){try{l=Xn.decode(l)}catch(h){e.emit("warning",h);return}e.emit("packet",l,f),l.type==="query"&&e.emit("query",l,f),l.type==="response"&&e.emit("response",l,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 p=Vu(function(l){if(!r||t.bind===!1)return l(null);u.once("error",l),u.bind(r,t.bind||t.interface,function(){u.removeListener("error",l),l(null)})});return p(function(l){if(l)return e.emit("error",l);e.emit("ready")}),e.send=function(l,f,h){if(typeof f=="function")return e.send(l,null,f);h||(h=Wn),f?!f.host&&!f.address&&(f.address=i.address):f=i,p(d);function d(m){if(c)return h();if(m)return h(m);var b=Xn.encode(l);u.send(b,0,b.length,f.port,f.address||f.host,h)}},e.response=e.respond=function(l,f,h){Array.isArray(l)&&(l={answers:l}),l.type="response",l.flags=(l.flags||0)|Xn.AUTHORITATIVE_ANSWER,e.send(l,f,h)},e.query=function(l,f,h,d){if(typeof f=="function")return e.query(l,null,null,f);if(typeof f=="object"&&f&&f.port)return e.query(l,null,f,h);if(typeof h=="function")return e.query(l,f,null,h);d||(d=Wn),typeof l=="string"&&(l=[{name:l,type:f||"ANY"}]),Array.isArray(l)&&(l={type:"query",questions:l}),l.type="query",e.send(l,h,d)},e.destroy=function(l){if(l||(l=Wn),c)return process.nextTick(l);c=!0,clearInterval(a);for(var f in s)try{u.dropMembership(o,f)}catch{}s={},u.close(l)},e.update=function(){for(var l=t.interface?[].concat(t.interface):$u(),f=!1,h=0;h<l.length;h++){var d=l[h];if(!s[d])try{u.addMembership(o,d),s[d]=!0,f=!0}catch(m){e.emit("warning",m)}}if(f){if(u.setMulticastInterface)try{u.setMulticastInterface(t.interface||Hu())}catch(m){e.emit("warning",m)}e.emit("networkInterface")}},e};function Hu(){for(var t=Zn.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(Cs(i.family)&&!i.internal)return Zn.platform()==="darwin"&&e[r]==="en0"?i.address:"0.0.0.0"}return"127.0.0.1"}function $u(){for(var t=Zn.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(Cs(s.family)){r.push(s.address);break}}return r}function Cs(t){return t===4||t==="IPv4"}});var qi=ve(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.Netmask4Impl=void 0;ir.ip2long=or;ir.long2ip=Ge;function Ge(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 up=48,dp=97,lp=65;function hp(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)-up)>>>0;else if(r===16)if("a"<=t[o]&&t[o]<="f")e=e*r+(10+t.charCodeAt(o)-dp)>>>0;else if("A"<=t[o]&&t[o]<="F")e=e*r+(10+t.charCodeAt(o)-lp)>>>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 or(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]=hp(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 Mi=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=or(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=(or(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=Ge(this.netLong),this.mask=Ge(this.maskLong),this.hostmask=Ge(~this.maskLong),this.first=this.bitmask<=30?Ge(this.netLong+1):this.base,this.last=this.bitmask<=30?Ge(this.netLong+this.size-2):Ge(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?Ge(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):(or(e)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0}next(e=1){return new t(Ge(this.netLong+this.size*e),this.mask)}forEach(e){let r=or(this.first),n=or(this.last),o=0;for(;r<=n;)e(Ge(r),r,o),o++,r++}toString(){return this.base+"/"+this.bitmask}};ir.Netmask4Impl=Mi});var Wa=ve(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.Netmask6Impl=void 0;sr.ip6bigint=zi;sr.bigint2ip6=_t;var pp=qi(),Vi=(1n<<128n)-1n;function zi(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,pp.ip2long)(n),i=t.substring(0,r+1)+"0:0";return Xa(i)&~0xffffffffn|BigInt(o)}return Xa(t)}function Xa(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>Vi)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 Hi=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=Vi>>BigInt(128-this.bitmask)<<BigInt(128-this.bitmask);try{this.netBigint=zi(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&Vi),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):(zi(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}};sr.Netmask6Impl=Hi});var Za=ve(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.long2ip=Et.ip2long=Et.Netmask=void 0;var Pn=qi();Object.defineProperty(Et,"ip2long",{enumerable:!0,get:function(){return Pn.ip2long}});Object.defineProperty(Et,"long2ip",{enumerable:!0,get:function(){return Pn.long2ip}});var fp=Wa(),$i=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 fp.Netmask6Impl(e,r):this._impl=new Pn.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 Pn.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()}};Et.Netmask=$i});var B0={};V(B0,{mdns:()=>A0});var Ae=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Hr=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"}},jr=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var dr=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var us=Symbol.for("@libp2p/peer-discovery");var Kn=Symbol.for("@libp2p/peer-id");var ds=Z("node:events"),ls=(t,...e)=>{try{(0,ds.setMaxListeners)(t,...e)}catch{}};function Bu(t){return typeof t?.handleEvent=="function"}function Cu(t){return(t!==!0&&t!==!1&&t?.once)??!1}var Gr=class extends EventTarget{#e=new Map;constructor(){super(),ls(1/0,this)}listenerCount(e){let r=this.#e.get(e);return r==null?0:r.length}addEventListener(e,r,n){let o=Cu(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))}Bu(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 hs=Symbol.for("@libp2p/service-capabilities");var bu=Nt(Ds(),1);var ro={};V(ro,{base58btc:()=>X,base58flickr:()=>Ju});var ff=new Uint8Array(0);function Us(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 Be(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return St(t);if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return St(new Uint8Array(t.buffer,t.byteOffset,t.byteLength));throw new Error("Unknown type, must be binary type")}function Ts(t){return new TextEncoder().encode(t)}function Os(t){return new TextDecoder().decode(t)}function ju(t){return t?.buffer instanceof ArrayBuffer}function St(t){return ju(t)?t:t.slice()}function Gu(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,a=t.charAt(0),u=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var m=0,b=0,I=0,C=d.length;I!==C&&d[I]===0;)I++,m++;for(var N=(C-I)*p+1>>>0,P=new Uint8Array(N);I!==C;){for(var U=d[I],R=0,K=N-1;(U!==0||R<b)&&K!==-1;K--,R++)U+=256*P[K]>>>0,P[K]=U%c>>>0,U=U/c>>>0;if(U!==0)throw new Error("Non-zero carry");b=R,I++}for(var T=N-b;T!==N&&P[T]===0;)T++;for(var ae=a.repeat(m);T<N;++T)ae+=t.charAt(P[T]);return ae}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var m=0;if(d[m]!==" "){for(var b=0,I=0;d[m]===a;)b++,m++;for(var C=(d.length-m)*u+1>>>0,N=new Uint8Array(C);d[m];){var P=r[d.charCodeAt(m)];if(P===255)return;for(var U=0,R=C-1;(P!==0||U<I)&&R!==-1;R--,U++)P+=c*N[R]>>>0,N[R]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");I=U,m++}if(d[m]!==" "){for(var K=C-I;K!==C&&N[K]===0;)K++;for(var T=new Uint8Array(b+(C-K)),ae=b;K!==C;)T[ae++]=N[K++];return T}}}function h(d){var m=f(d);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var Yu=Gu,Xu=Yu,Ps=Xu;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")}},Jn=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 Fs(this,e)}},eo=class{decoders;constructor(e){this.decoders=e}or(e){return Fs(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 Fs(t,e){return new eo({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var to=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 Jn(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function kt({name:t,prefix:e,encode:r,decode:n}){return new to(t,e,r,n)}function ht({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=Ps(r,t);return kt({prefix:e,name:t,encode:n,decode:i=>Be(o(i))})}function Wu(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 p=e[t[u]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|p,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 Zu(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 Qu(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function H({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Qu(n);return kt({prefix:e,name:t,encode(i){return Zu(i,n,r)},decode(i){return Wu(i,o,r,t)}})}var X=ht({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ju=ht({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var no={};V(no,{base32:()=>pt,base32hex:()=>nd,base32hexpad:()=>id,base32hexpadupper:()=>sd,base32hexupper:()=>od,base32pad:()=>td,base32padupper:()=>rd,base32upper:()=>ed,base32z:()=>cd});var pt=H({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),ed=H({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),td=H({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),rd=H({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nd=H({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),od=H({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),id=H({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),sd=H({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cd=H({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var oo={};V(oo,{base36:()=>hr,base36upper:()=>ad});var hr=ht({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ad=ht({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ud=ks,Ns=128,dd=127,ld=~dd,hd=Math.pow(2,31);function ks(t,e,r){e=e||[],r=r||0;for(var n=r;t>=hd;)e[r++]=t&255|Ns,t/=128;for(;t&ld;)e[r++]=t&255|Ns,t>>>=7;return e[r]=t|0,ks.bytes=r-n+1,e}var pd=io,fd=128,Rs=127;function io(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw io.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&Rs)<<o:(s&Rs)*Math.pow(2,o),o+=7}while(s>=fd);return io.bytes=i-n,r}var md=Math.pow(2,7),gd=Math.pow(2,14),yd=Math.pow(2,21),xd=Math.pow(2,28),bd=Math.pow(2,35),wd=Math.pow(2,42),Ed=Math.pow(2,49),Id=Math.pow(2,56),Sd=Math.pow(2,63),vd=function(t){return t<md?1:t<gd?2:t<yd?3:t<xd?4:t<bd?5:t<wd?6:t<Ed?7:t<Id?8:t<Sd?9:10},Ad={encode:ud,decode:pd,encodingLength:vd},Bd=Ad,pr=Bd;function fr(t,e=0){return[pr.decode(t,e),pr.decode.bytes]}function Kt(t,e,r=0){return pr.encode(t,e,r),e}function Mt(t){return pr.encodingLength(t)}function Vt(t,e){let r=e.byteLength,n=Mt(t),o=n+Mt(r),i=new Uint8Array(o+r);return Kt(t,i,0),Kt(r,i,n),i.set(e,o),new qt(t,r,e,i)}function mr(t){let e=Be(t),[r,n]=fr(e),[o,i]=fr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new qt(r,o,s,e)}function Ks(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Us(t.bytes,r.bytes)}}var qt=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=St(n),this.bytes=St(o)}};function Ms(t,e){let{bytes:r,version:n}=t;return n===0?Ld(r,so(t),e??X.encoder):Dd(r,so(t),e??pt.encoder)}var qs=new WeakMap;function so(t){let e=qs.get(t);if(e==null){let r=new Map;return qs.set(t,r),r}return e}var ie=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=St(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!==gr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Ud)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=Vt(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&&Ks(e.multihash,n.multihash)}toString(e){return Ms(this,e)}toJSON(){return{"/":Ms(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??Vs(n,o,i.bytes))}else if(r[Td]===!0){let{version:n,multihash:o,code:i}=r,s=mr(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!==gr)throw new Error(`Version 0 CID must use dag-pb (code: ${gr}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Vs(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,gr,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=Be(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 qt(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,f]=fr(e.subarray(r));return r+=f,l},o=n(),i=gr;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,p=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:p,size:u}}static parse(e,r){let[n,o]=Cd(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 so(i).set(n,e),i}};function Cd(t,e){switch(t[0]){case"Q":{let r=e??X;return[X.prefix,r.decode(`${X.prefix}${t}`)]}case X.prefix:{let r=e??X;return[X.prefix,r.decode(t)]}case pt.prefix:{let r=e??pt;return[pt.prefix,r.decode(t)]}case hr.prefix:{let r=e??hr;return[hr.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 Ld(t,e,r){let{prefix:n}=r;if(n!==X.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 Dd(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 gr=112,Ud=18;function Vs(t,e,r){let n=Mt(t),o=n+Mt(e),i=new Uint8Array(o+r.byteLength);return Kt(t,i,0),Kt(e,i,n),i.set(r,o),i}var Td=Symbol.for("@ipld/js-cid/CID");var co={};V(co,{identity:()=>Oe});var zs=0,Od="identity",Hs=Be;function _d(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 Vt(zs,Hs(t))}var Oe={code:zs,name:Od,encode:Hs,digest:_d};function Ce(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 Pd(t){return t.buffer instanceof ArrayBuffer}function Ht(t){return Pd(t)?t:t.slice()}async function $s(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,Ht(e),Ht(r.subarray()));return n?.signal?.throwIfAborted(),i}var ao=Z("node:buffer");function yr(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function it(t=0){return yr(ao.Buffer.alloc(t))}function uo(t=0){return yr(ao.Buffer.allocUnsafe(t))}var js=Z("node:buffer");function lo(t,e){return yr(js.Buffer.concat(t,e))}function Gs(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}var Xs=Symbol.for("@achingbrain/uint8arraylist");function Ys(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 Zr(t){return!!t?.[Xs]}var be=class t{bufs;length;[Xs]=!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(Zr(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(Zr(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=Ys(this.bufs,e);return r.buf[r.index]}set(e,r){let n=Ys(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(Zr(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 lo(n,o)}subarray(e,r){let{bufs:n,length:o}=this._subList(e,r);return n.length===1?n[0]:lo(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,p=r>c&&r<=a;if(u&&p){if(e===c&&r===a){n.push(s);break}let l=e-c;n.push(s.subarray(l,l+(r-e)));break}if(u){if(e===0){n.push(s);continue}n.push(s.subarray(e-c));continue}if(p){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(!Zr(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(r=Number(r??0),isNaN(r)&&(r=0),r<0&&(r=this.length+r),r<0&&(r=0),e.length===0)return r>this.length?this.length:r;let o=n.byteLength;if(o===0)throw new TypeError("search must be at least 1 byte long");let i=256,s=new Int32Array(i);for(let l=0;l<i;l++)s[l]=-1;for(let l=0;l<o;l++)s[n[l]]=l;let c=s,a=this.byteLength-n.byteLength,u=n.byteLength-1,p;for(let l=r;l<=a;l+=p){p=0;for(let f=u;f>=0;f--){let h=this.get(l+f);if(n[f]!==h){p=Math.max(1,f-c[h]);break}}if(p===0)return l}return-1}getInt8(e){let r=this.subarray(e,e+1);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt8(0)}setInt8(e,r){let n=uo(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=it(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=it(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=it(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=uo(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=it(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=it(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=it(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=it(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=it(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(!Gs(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 rc=Z("node:buffer");var ho={};V(ho,{base10:()=>Fd});var Fd=ht({prefix:"9",name:"base10",alphabet:"0123456789"});var po={};V(po,{base16:()=>Nd,base16upper:()=>Rd});var Nd=H({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Rd=H({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fo={};V(fo,{base2:()=>kd});var kd=H({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var mo={};V(mo,{base256emoji:()=>zd});var Ws=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}"),Kd=Ws.reduce((t,e,r)=>(t[r]=e,t),[]),Md=Ws.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function qd(t){return t.reduce((e,r)=>(e+=Kd[r],e),"")}function Vd(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=Md[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var zd=kt({prefix:"\u{1F680}",name:"base256emoji",encode:qd,decode:Vd});var yo={};V(yo,{base64:()=>Hd,base64pad:()=>$d,base64url:()=>go,base64urlpad:()=>jd});var Hd=H({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$d=H({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),go=H({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),jd=H({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var xo={};V(xo,{base8:()=>Gd});var Gd=H({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var bo={};V(bo,{identity:()=>Yd});var Yd=kt({prefix:"\0",name:"identity",encode:t=>Os(t),decode:t=>Ts(t)});var em=new TextEncoder,tm=new TextDecoder;var vo={};V(vo,{sha256:()=>So,sha512:()=>Qd});var Io=Nt(Z("node:crypto"),1);var Zd=20;function Eo({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new wo(t,e,r,n,o)}var wo=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Zd,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?Zs(n,this.code,r?.truncate):n.then(o=>Zs(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function Zs(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 Vt(e,t)}var So=Eo({name:"sha2-256",code:18,encode:t=>Be(Io.default.createHash("sha256").update(t).digest())}),Qd=Eo({name:"sha2-512",code:19,encode:t=>Be(Io.default.createHash("sha512").update(t).digest())});var xr={...bo,...fo,...xo,...ho,...po,...no,...oo,...ro,...yo,...mo},fm={...vo,...co};var Js=Z("node:buffer");function vt(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 br(t=0){return vt(Js.Buffer.allocUnsafe(t))}function tc(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var ec=tc("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ao=tc("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=br(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Jd={utf8:ec,"utf-8":ec,hex:xr.base16,latin1:Ao,ascii:Ao,binary:Ao,...xr},Qr=Jd;function we(t,e="utf8"){let r=Qr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?vt(rc.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}var nc=Z("node:buffer");function $(t,e="utf8"){let r=Qr[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?nc.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var el=parseInt("11111",2),Bo=parseInt("10000000",2),tl=parseInt("01111111",2),oc={0:wr,1:wr,2:rl,3:il,4:sl,5:ol,6:nl,16:wr,22:wr,48:wr};function Co(t,e={offset:0}){let r=t[e.offset]&el;if(e.offset++,oc[r]!=null)return oc[r](t,e);throw new Error("No decoder for tag "+r)}function Er(t,e){let r=0;if((t[e.offset]&Bo)===Bo){let n=t[e.offset]&tl,o="0x";e.offset++;for(let i=0;i<n;i++,e.offset++)o+=t[e.offset].toString(16).padStart(2,"0");r=parseInt(o,16)}else r=t[e.offset],e.offset++;return r}function wr(t,e){Er(t,e);let r=[];for(;!(e.offset>=t.byteLength);){let n=Co(t,e);if(n===null)break;r.push(n)}return r}function rl(t,e){let r=Er(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 nl(t,e){let r=Er(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 p=0;for(let l=0;l<a.length;l++)p+=a[l]<<l*7;c+=`.${p}`,a=[]}}return c}function ol(t,e){return e.offset++,null}function il(t,e){let r=Er(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 sl(t,e){let r=Er(t,e),n=t.subarray(e.offset,e.offset+r);return e.offset+=r,n}function cl(t){let e=t.toString(16);e.length%2===1&&(e="0"+e);let r=new be;for(let n=0;n<e.length;n+=2)r.append(Uint8Array.from([parseInt(`${e[n]}${e[n+1]}`,16)]));return r}function Lo(t){if(t.byteLength<128)return Uint8Array.from([t.byteLength]);let e=cl(t.byteLength);return new be(Uint8Array.from([e.byteLength|Bo]),e)}function ic(t){let e=new be,r=128;return(t.subarray()[0]&r)===r&&e.append(Uint8Array.from([0])),e.append(t),new be(Uint8Array.from([2]),Lo(e),e)}function sc(t){let e=Uint8Array.from([0]),r=new be(e,t);return new be(Uint8Array.from([3]),Lo(r),r)}function Jr(t,e=48){let r=new be;for(let n of t)r.append(n);return new be(Uint8Array.from([e]),Lo(r),r)}var al=Uint8Array.from([6,8,42,134,72,206,61,3,1,7]),ul=Uint8Array.from([6,5,43,129,4,0,34]),dl=Uint8Array.from([6,5,43,129,4,0,35]),ll={ext:!0,kty:"EC",crv:"P-256"},hl={ext:!0,kty:"EC",crv:"P-384"},pl={ext:!0,kty:"EC",crv:"P-521"},Do=32,Uo=48,To=66;function cc(t){let e=Co(t);return ac(e)}function ac(t){let e=t[1][1][0],r=1,n,o;if(e.byteLength===Do*2+1)return n=$(e.subarray(r,r+Do),"base64url"),o=$(e.subarray(r+Do),"base64url"),new $t({...ll,key_ops:["verify"],x:n,y:o});if(e.byteLength===Uo*2+1)return n=$(e.subarray(r,r+Uo),"base64url"),o=$(e.subarray(r+Uo),"base64url"),new $t({...hl,key_ops:["verify"],x:n,y:o});if(e.byteLength===To*2+1)return n=$(e.subarray(r,r+To),"base64url"),o=$(e.subarray(r+To),"base64url"),new $t({...pl,key_ops:["verify"],x:n,y:o});throw new Ae(`coordinates were wrong length, got ${e.byteLength}, expected 65, 97 or 133`)}function uc(t){return Jr([ic(Uint8Array.from([1])),Jr([fl(t.crv)],160),Jr([sc(new be(Uint8Array.from([4]),we(t.x??"","base64url"),we(t.y??"","base64url")))],161)]).subarray()}function fl(t){if(t==="P-256")return al;if(t==="P-384")return ul;if(t==="P-521")return dl;throw new Ae(`Invalid curve ${t}`)}var $t=class{type="ECDSA";jwk;_raw;constructor(e){this.jwk=e}get raw(){return this._raw==null&&(this._raw=uc(this.jwk)),this._raw}toMultihash(){return Oe.digest(jt(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ce(this.raw,e.raw)}async verify(e,r,n){return $s(this.jwk,r,e,n)}};var fn=Nt(Z("crypto"),1);function Oo(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"&&"BYTES_PER_ELEMENT"in t&&t.BYTES_PER_ELEMENT===1}function ft(t,e=""){if(typeof t!="number"){let r=e&&`"${e}" `;throw new TypeError(`${r}expected number, got ${typeof t}`)}if(!Number.isSafeInteger(t)||t<0){let r=e&&`"${e}" `;throw new RangeError(`${r}expected integer >= 0, got ${t}`)}}function He(t,e,r=""){let n=Oo(t),o=t?.length,i=e!==void 0;if(!n||i&&o!==e){let s=r&&`"${r}" `,c=i?` of length ${e}`:"",a=n?`length=${o}`:`type=${typeof t}`,u=s+"expected Uint8Array"+c+", got "+a;throw n?new RangeError(u):new TypeError(u)}return t}function en(t){if(typeof t!="function"||typeof t.create!="function")throw new TypeError("Hash must wrapped by utils.createHasher");if(ft(t.outputLen),ft(t.blockLen),t.outputLen<1)throw new Error('"outputLen" must be >= 1');if(t.blockLen<1)throw new Error('"blockLen" must be >= 1')}function Gt(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function tn(t,e){He(t,void 0,"digestInto() output");let r=e.outputLen;if(t.length<r)throw new RangeError('"digestInto() output" expected to be of length >='+r)}function At(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function rn(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function _e(t,e){return t<<32-e|t>>>e}var lc=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",ml=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function nn(t){if(He(t),lc)return t.toHex();let e="";for(let r=0;r<t.length;r++)e+=ml[t[r]];return e}var st={_0:48,_9:57,A:65,F:70,a:97,f:102};function dc(t){if(t>=st._0&&t<=st._9)return t-st._0;if(t>=st.A&&t<=st.F)return t-(st.A-10);if(t>=st.a&&t<=st.f)return t-(st.a-10)}function _o(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);if(lc)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=dc(t.charCodeAt(i)),c=dc(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 hc(...t){let e=0;for(let n=0;n<t.length;n++){let o=t[n];He(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 pc(t,e={}){let r=(o,i)=>t(i).update(o).digest(),n=t(void 0);return r.outputLen=n.outputLen,r.blockLen=n.blockLen,r.canXOF=n.canXOF,r.create=o=>t(o),Object.assign(r,e),Object.freeze(r)}function fc(t=32){ft(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 mc=t=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,t])});function gc(t,e,r){return t&e^~t&r}function yc(t,e,r){return t&e^t&r^e&r}var on=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=rn(this.buffer)}update(e){Gt(this),He(e);let{view:r,buffer:n,blockLen:o}=this,i=e.length;for(let s=0;s<i;){let c=Math.min(o-this.pos,i-s);if(c===o){let a=rn(e);for(;o<=i-s;s+=o)this.process(a,s);continue}n.set(e.subarray(s,s+c),this.pos),this.pos+=c,s+=c,this.pos===o&&(this.process(r,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Gt(this),tn(e,this),this.finished=!0;let{buffer:r,view:n,blockLen:o,isLE:i}=this,{pos:s}=this;r[s++]=128,At(this.buffer.subarray(s)),this.padOffset>o-s&&(this.process(n,0),s=0);for(let l=s;l<o;l++)r[l]=0;n.setBigUint64(o-8,BigInt(this.length*8),i),this.process(n,0);let c=rn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen must be aligned to 32bit");let u=a/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)c.setUint32(4*l,p[l],i)}digest(){let{buffer:e,outputLen:r}=this;this.digestInto(e);let n=e.slice(0,r);return this.destroy(),n}_cloneInto(e){e||=new this.constructor,e.set(...this.get());let{blockLen:r,buffer:n,length:o,finished:i,destroyed:s,pos:c}=this;return e.destroyed=s,e.finished=i,e.length=o,e.pos=c,o%r&&e.buffer.set(n),e}clone(){return this._cloneInto()}},ct=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);var gl=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),mt=new Uint32Array(64),Po=class extends on{constructor(e){super(64,e,8,!1)}get(){let{A:e,B:r,C:n,D:o,E:i,F:s,G:c,H:a}=this;return[e,r,n,o,i,s,c,a]}set(e,r,n,o,i,s,c,a){this.A=e|0,this.B=r|0,this.C=n|0,this.D=o|0,this.E=i|0,this.F=s|0,this.G=c|0,this.H=a|0}process(e,r){for(let l=0;l<16;l++,r+=4)mt[l]=e.getUint32(r,!1);for(let l=16;l<64;l++){let f=mt[l-15],h=mt[l-2],d=_e(f,7)^_e(f,18)^f>>>3,m=_e(h,17)^_e(h,19)^h>>>10;mt[l]=m+mt[l-7]+d+mt[l-16]|0}let{A:n,B:o,C:i,D:s,E:c,F:a,G:u,H:p}=this;for(let l=0;l<64;l++){let f=_e(c,6)^_e(c,11)^_e(c,25),h=p+f+gc(c,a,u)+gl[l]+mt[l]|0,m=(_e(n,2)^_e(n,13)^_e(n,22))+yc(n,o,i)|0;p=u,u=a,a=c,c=s+h|0,s=i,i=o,o=n,n=h+m|0}n=n+this.A|0,o=o+this.B|0,i=i+this.C|0,s=s+this.D|0,c=c+this.E|0,a=a+this.F|0,u=u+this.G|0,p=p+this.H|0,this.set(n,o,i,s,c,a,u,p)}roundClean(){At(mt)}destroy(){this.destroyed=!0,this.set(0,0,0,0,0,0,0,0),At(this.buffer)}},Fo=class extends Po{A=ct[0]|0;B=ct[1]|0;C=ct[2]|0;D=ct[3]|0;E=ct[4]|0;F=ct[5]|0;G=ct[6]|0;H=ct[7]|0;constructor(){super(32)}};var xc=pc(()=>new Fo,mc(1));var J=(t,e,r)=>He(t,e,r),Ro=ft,ko=nn,at=(...t)=>hc(...t),an=t=>_o(t),Ko=Oo,Mo=t=>fc(t),cn=BigInt(0),No=BigInt(1);function Bt(t,e=""){if(typeof t!="boolean"){let r=e&&`"${e}" `;throw new TypeError(r+"expected boolean, got type="+typeof t)}return t}function un(t){if(typeof t=="bigint"){if(!sn(t))throw new RangeError("positive bigint expected, got "+t)}else Ro(t);return t}function Ir(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 Sr(t){let e=un(t).toString(16);return e.length&1?"0"+e:e}function bc(t){if(typeof t!="string")throw new TypeError("hex string expected, got "+typeof t);return t===""?cn:BigInt("0x"+t)}function Yt(t){return bc(nn(t))}function qo(t){return bc(nn(yl(He(t)).reverse()))}function dn(t,e){if(ft(e),e===0)throw new RangeError("zero length");t=un(t);let r=t.toString(16);if(r.length>e*2)throw new RangeError("number too large");return _o(r.padStart(e*2,"0"))}function Vo(t,e){return dn(t,e).reverse()}function yl(t){return Uint8Array.from(J(t))}var sn=t=>typeof t=="bigint"&&cn<=t;function xl(t,e,r){return sn(t)&&sn(e)&&sn(r)&&e<=t&&t<r}function zo(t,e,r,n){if(!xl(e,r,n))throw new RangeError("expected valid "+t+": "+r+" <= n < "+n+", got "+e)}function Xt(t){if(t<cn)throw new Error("expected non-negative bigint, got "+t);let e;for(e=0;t>cn;t>>=No,e+=1);return e}var vr=t=>(No<<BigInt(t))-No;function wc(t,e,r){if(ft(t,"hashLen"),ft(e,"qByteLen"),typeof r!="function")throw new TypeError("hmacFn must be a function");let n=b=>new Uint8Array(b),o=Uint8Array.of(),i=Uint8Array.of(0),s=Uint8Array.of(1),c=1e3,a=n(t),u=n(t),p=0,l=()=>{a.fill(1),u.fill(0),p=0},f=(...b)=>r(u,at(a,...b)),h=(b=o)=>{u=f(i,b),a=f(),b.length!==0&&(u=f(s,b),a=f())},d=()=>{if(p++>=c)throw new Error("drbg: tried max amount of iterations");let b=0,I=[];for(;b<e;){a=f();let C=a.slice();I.push(C),b+=a.length}return at(...I)};return(b,I)=>{l(),h(b);let C;for(;(C=I(d()))===void 0;)h();return l(),C}}function Ct(t,e={},r={}){if(Object.prototype.toString.call(t)!=="[object Object]")throw new TypeError("expected valid options object");function n(i,s,c){if(!c&&s!=="function"&&!Object.hasOwn(t,i))throw new TypeError(`param "${i}" is invalid: expected own property`);let a=t[i];if(c&&a===void 0)return;let u=typeof a;if(u!==s||a===null)throw new TypeError(`param "${i}" is invalid: expected ${s}, got ${u}`)}let o=(i,s)=>Object.entries(i).forEach(([c,a])=>n(c,a,s));o(e,!1),o(r,!0)}var se=BigInt(0),W=BigInt(1),Lt=BigInt(2),vc=BigInt(3),Ac=BigInt(4),Bc=BigInt(5),bl=BigInt(7),Cc=BigInt(8),wl=BigInt(9),Lc=BigInt(16);function Pe(t,e){if(e<=se)throw new Error("mod: expected positive modulus, got "+e);let r=t%e;return r>=se?r:e+r}function Ee(t,e,r){if(e<se)throw new Error("pow2: expected non-negative exponent, got "+e);let n=t;for(;e-- >se;)n*=n,n%=r;return n}function Ec(t,e){if(t===se)throw new Error("invert: expected non-zero number");if(e<=se)throw new Error("invert: expected positive modulus, got "+e);let r=Pe(t,e),n=e,o=se,i=W,s=W,c=se;for(;r!==se;){let u=n/r,p=n-r*u,l=o-s*u,f=i-c*u;n=r,r=p,o=s,i=c,s=l,c=f}if(n!==W)throw new Error("invert: does not exist");return Pe(o,e)}function Ho(t,e,r){let n=t;if(!n.eql(n.sqr(e),r))throw new Error("Cannot find square root")}function Dc(t,e){let r=t,n=(r.ORDER+W)/Ac,o=r.pow(e,n);return Ho(r,o,e),o}function El(t,e){let r=t,n=(r.ORDER-Bc)/Cc,o=r.mul(e,Lt),i=r.pow(o,n),s=r.mul(e,i),c=r.mul(r.mul(s,Lt),i),a=r.mul(s,r.sub(c,r.ONE));return Ho(r,a,e),a}function Il(t){let e=Wt(t),r=Uc(t),n=r(e,e.neg(e.ONE)),o=r(e,n),i=r(e,e.neg(n)),s=(t+bl)/Lc;return((c,a)=>{let u=c,p=u.pow(a,s),l=u.mul(p,n),f=u.mul(p,o),h=u.mul(p,i),d=u.eql(u.sqr(l),a),m=u.eql(u.sqr(f),a);p=u.cmov(p,l,d),l=u.cmov(h,f,m);let b=u.eql(u.sqr(l),a),I=u.cmov(p,l,b);return Ho(u,I,a),I})}function Uc(t){if(t<vc)throw new Error("sqrt is not defined for small field");let e=t-W,r=0;for(;e%Lt===se;)e/=Lt,r++;let n=Lt,o=Wt(t);for(;Ic(o,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(r===1)return Dc;let i=o.pow(n,e),s=(e+W)/Lt;return function(a,u){let p=a;if(p.is0(u))return u;if(Ic(p,u)!==1)throw new Error("Cannot find square root");let l=r,f=p.mul(p.ONE,i),h=p.pow(u,e),d=p.pow(u,s);for(;!p.eql(h,p.ONE);){if(p.is0(h))return p.ZERO;let m=1,b=p.sqr(h);for(;!p.eql(b,p.ONE);)if(m++,b=p.sqr(b),m===l)throw new Error("Cannot find square root");let I=W<<BigInt(l-m-1),C=p.pow(f,I);l=m,f=p.sqr(C),h=p.mul(h,f),d=p.mul(d,C)}return d}}function Sl(t){return t%Ac===vc?Dc:t%Cc===Bc?El:t%Lc===wl?Il(t):Uc(t)}var vl=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function $o(t){let e={ORDER:"bigint",BYTES:"number",BITS:"number"},r=vl.reduce((n,o)=>(n[o]="function",n),e);if(Ct(t,r),Ir(t.BYTES,"BYTES"),Ir(t.BITS,"BITS"),t.BYTES<1||t.BITS<1)throw new Error("invalid field: expected BYTES/BITS > 0");if(t.ORDER<=W)throw new Error("invalid field: expected ORDER > 1, got "+t.ORDER);return t}function Al(t,e,r){let n=t;if(r<se)throw new Error("invalid exponent, negatives unsupported");if(r===se)return n.ONE;if(r===W)return e;let o=n.ONE,i=e;for(;r>se;)r&W&&(o=n.mul(o,i)),i=n.sqr(i),r>>=W;return o}function hn(t,e,r=!1){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 Ic(t,e){let r=t,n=(r.ORDER-W)/Lt,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 Bl(t,e){if(e!==void 0&&Ro(e),t<=se)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=Xt(t);if(e!==void 0&&e<r)throw new Error(`invalid n length: expected bit length (${r}) >= n.length (${e})`);let n=e!==void 0?e:r,o=Math.ceil(n/8);return{nBitLength:n,nByteLength:o}}var Sc=new WeakMap,ln=class{ORDER;BITS;BYTES;isLE;ZERO=se;ONE=W;_lengths;_mod;constructor(e,r={}){if(e<=W)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}=Bl(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 Pe(e,this.ORDER)}isValid(e){if(typeof e!="bigint")throw new TypeError("invalid field element: expected bigint, got "+typeof e);return se<=e&&e<this.ORDER}is0(e){return e===se}isValidNot0(e){return!this.is0(e)&&this.isValid(e)}isOdd(e){return(e&W)===W}neg(e){return Pe(-e,this.ORDER)}eql(e,r){return e===r}sqr(e){return Pe(e*e,this.ORDER)}add(e,r){return Pe(e+r,this.ORDER)}sub(e,r){return Pe(e-r,this.ORDER)}mul(e,r){return Pe(e*r,this.ORDER)}pow(e,r){return Al(this,e,r)}div(e,r){return Pe(e*Ec(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 Ec(e,this.ORDER)}sqrt(e){let r=Sc.get(this);return r||Sc.set(this,r=Sl(this.ORDER)),r(this,e)}toBytes(e){return this.isLE?Vo(e,this.BYTES):dn(e,this.BYTES)}fromBytes(e,r=!1){J(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?qo(e):Yt(e);if(c&&(a=Pe(a,s)),!r&&!this.isValid(a))throw new Error("invalid field element: outside of range 0..ORDER");return a}invertBatch(e){return hn(this,e)}cmov(e,r,n){return Bt(n,"condition"),n?r:e}};Object.freeze(ln.prototype);function Wt(t,e={}){return new ln(t,e)}function Tc(t){if(typeof t!="bigint")throw new Error("field order must be bigint");if(t<=W)throw new Error("field order must be greater than 1");let e=Xt(t-W);return Math.ceil(e/8)}function jo(t){let e=Tc(t);return e+Math.ceil(e/2)}function Go(t,e,r=!1){J(t);let n=t.length,o=Tc(e),i=Math.max(jo(e),16);if(n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);let s=r?qo(t):Yt(t),c=Pe(s,e-W)+W;return r?Vo(c,o):dn(c,o)}var Zt=BigInt(0),Dt=BigInt(1);function Ar(t,e){let r=e.negate();return t?r:e}function Zo(t,e){let r=hn(t.Fp,e.map(n=>n.Z));return e.map((n,o)=>t.fromAffine(n.toAffine(r[o])))}function Fc(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Yo(t,e){Fc(t,e);let r=Math.ceil(e/t)+1,n=2**(t-1),o=2**t,i=vr(t),s=BigInt(t);return{windows:r,windowSize:n,mask:i,maxNumber:o,shiftBy:s}}function Oc(t,e,r){let{windowSize:n,mask:o,maxNumber:i,shiftBy:s}=r,c=Number(t&o),a=t>>s;c>n&&(c-=i,a+=Dt);let u=e*n,p=u+Math.abs(c)-1,l=c===0,f=c<0,h=e%2!==0;return{nextN:a,offset:p,isZero:l,isNeg:f,isNegF:h,offsetF:u}}var Xo=new WeakMap,Nc=new WeakMap;function Wo(t){return Nc.get(t)||1}function _c(t){if(t!==Zt)throw new Error("invalid wNAF")}var pn=class{BASE;ZERO;Fn;bits;constructor(e,r){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=r}_unsafeLadder(e,r,n=this.ZERO){let o=e;for(;r>Zt;)r&Dt&&(n=n.add(o)),o=o.double(),r>>=Dt;return n}precomputeWindow(e,r){let{windows:n,windowSize:o}=Yo(r,this.bits),i=[],s=e,c=s;for(let a=0;a<n;a++){c=s,i.push(c);for(let u=1;u<o;u++)c=c.add(s),i.push(c);s=c.double()}return i}wNAF(e,r,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let o=this.ZERO,i=this.BASE,s=Yo(e,this.bits);for(let c=0;c<s.windows;c++){let{nextN:a,offset:u,isZero:p,isNeg:l,isNegF:f,offsetF:h}=Oc(n,c,s);n=a,p?i=i.add(Ar(f,r[h])):o=o.add(Ar(l,r[u]))}return _c(n),{p:o,f:i}}wNAFUnsafe(e,r,n,o=this.ZERO){let i=Yo(e,this.bits);for(let s=0;s<i.windows&&n!==Zt;s++){let{nextN:c,offset:a,isZero:u,isNeg:p}=Oc(n,s,i);if(n=c,!u){let l=r[a];o=o.add(p?l.negate():l)}}return _c(n),o}getPrecomputes(e,r,n){let o=Xo.get(r);return o||(o=this.precomputeWindow(r,e),e!==1&&(typeof n=="function"&&(o=n(o)),Xo.set(r,o))),o}cached(e,r,n){let o=Wo(e);return this.wNAF(o,this.getPrecomputes(o,e,n),r)}unsafe(e,r,n,o){let i=Wo(e);return i===1?this._unsafeLadder(e,r,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),r,o)}createCache(e,r){Fc(r,this.bits),Nc.set(e,r),Xo.delete(e)}hasCache(e){return Wo(e)!==1}};function Rc(t,e,r,n){let o=e,i=t.ZERO,s=t.ZERO;for(;r>Zt||n>Zt;)r&Dt&&(i=i.add(o)),n&Dt&&(s=s.add(o)),o=o.double(),r>>=Dt,n>>=Dt;return{p1:i,p2:s}}function Pc(t,e,r){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return $o(e),e}else return Wt(t,{isLE:r})}function kc(t,e,r={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(let a of["p","n","h"]){let u=e[a];if(!(typeof u=="bigint"&&u>Zt))throw new Error(`CURVE.${a} must be positive bigint`)}let o=Pc(e.p,r.Fp,n),i=Pc(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 Kc(t,e){return function(n){let o=t(n);return{secretKey:o,publicKey:e(o)}}}var Mc=Z("node:buffer");function gt(t,e){return vt(Mc.Buffer.concat(t,e))}var mg=fn.default.generateKeyPairSync,Br=32;var Cl=64;function qc(t,e,r){if(t.byteLength!==Br)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!==Cl)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=fn.default.createPublicKey({format:"jwk",key:{crv:"Ed25519",x:$(t,"base64url"),kty:"OKP"}});return fn.default.verify(null,r instanceof Uint8Array?r:r.subarray(),n,e)}function zc(t){return t==null?!1:typeof t.then=="function"&&typeof t.catch=="function"&&typeof t.finally=="function"}var mn=class{type="Ed25519";raw;constructor(e){this.raw=Qo(e,Br)}toMultihash(){return Oe.digest(jt(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ce(this.raw,e.raw)}verify(e,r,n){n?.signal?.throwIfAborted();let o=qc(this.raw,r,e);return zc(o)?o.then(i=>(n?.signal?.throwIfAborted(),i)):o}};function Hc(t){return t=Qo(t,Br),new mn(t)}function Qo(t,e){if(t=Uint8Array.from(t??[]),t.length!==e)throw new Ae(`Key must be a Uint8Array of length ${e}, got ${t.length}`);return t}var Dl=Math.pow(2,7),Ul=Math.pow(2,14),Tl=Math.pow(2,21),$c=Math.pow(2,28),jc=Math.pow(2,35),Gc=Math.pow(2,42),Yc=Math.pow(2,49),he=128,yt=127;function Cr(t){if(t<Dl)return 1;if(t<Ul)return 2;if(t<Tl)return 3;if(t<$c)return 4;if(t<jc)return 5;if(t<Gc)return 6;if(t<Yc)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Xc(t,e,r=0){switch(Cr(t)){case 8:e[r++]=t&255|he,t/=128;case 7:e[r++]=t&255|he,t/=128;case 6:e[r++]=t&255|he,t/=128;case 5:e[r++]=t&255|he,t/=128;case 4:e[r++]=t&255|he,t>>>=7;case 3:e[r++]=t&255|he,t>>>=7;case 2:e[r++]=t&255|he,t>>>=7;case 1:{e[r++]=t&255,t>>>=7;break}default:throw new Error("unreachable")}return e}function Wc(t,e){let r=t[e],n=0;if(n+=r&yt,r<he||(r=t[e+1],n+=(r&yt)<<7,r<he)||(r=t[e+2],n+=(r&yt)<<14,r<he)||(r=t[e+3],n+=(r&yt)<<21,r<he)||(r=t[e+4],n+=(r&yt)*$c,r<he)||(r=t[e+5],n+=(r&yt)*jc,r<he)||(r=t[e+6],n+=(r&yt)*Gc,r<he)||(r=t[e+7],n+=(r&yt)*Yc,r<he))return n;throw new RangeError("Could not decode varint")}var Jo=new Float32Array([-0]),xt=new Uint8Array(Jo.buffer);function Zc(t,e,r){Jo[0]=t,e[r]=xt[0],e[r+1]=xt[1],e[r+2]=xt[2],e[r+3]=xt[3]}function Qc(t,e){return xt[0]=t[e],xt[1]=t[e+1],xt[2]=t[e+2],xt[3]=t[e+3],Jo[0]}var ei=new Float64Array([-0]),ue=new Uint8Array(ei.buffer);function Jc(t,e,r){ei[0]=t,e[r]=ue[0],e[r+1]=ue[1],e[r+2]=ue[2],e[r+3]=ue[3],e[r+4]=ue[4],e[r+5]=ue[5],e[r+6]=ue[6],e[r+7]=ue[7]}function ea(t,e){return ue[0]=t[e],ue[1]=t[e+1],ue[2]=t[e+2],ue[3]=t[e+3],ue[4]=t[e+4],ue[5]=t[e+5],ue[6]=t[e+6],ue[7]=t[e+7],ei[0]}var Ol=BigInt(Number.MAX_SAFE_INTEGER),_l=BigInt(Number.MIN_SAFE_INTEGER),Ie=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 Ut;if(e<Ol&&e>_l)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>ta&&(o=0n,++n>ta&&(n=0n))),new t(Number(o),Number(n))}static fromNumber(e){if(e===0)return Ut;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):Ut}},Ut=new Ie(0,0);Ut.toBigInt=function(){return 0n};Ut.zzEncode=Ut.zzDecode=function(){return this};Ut.length=function(){return 1};var ta=4294967296n;function ra(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 na(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 ti(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 Fe(t,e){return RangeError(`index out of range: ${t.pos} + ${e??1} > ${t.len}`)}function gn(t,e){return(t[e-4]|t[e-3]<<8|t[e-2]<<16|t[e-1]<<24)>>>0}var ri=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Fe(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 Fe(this,4);return gn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Fe(this,4);return gn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Fe(this,4);let e=Qc(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Fe(this,4);let e=ea(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 Fe(this,e);return this.pos+=e,r===n?new Uint8Array(0):this.buf.subarray(r,n)}string(){let e=this.bytes();return na(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw Fe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw Fe(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 Ie(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 Fe(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 Fe(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 Fe(this,8);let e=gn(this.buf,this.pos+=4),r=gn(this.buf,this.pos+=4);return new Ie(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=Wc(this.buf,this.pos);return this.pos+=Cr(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 Lr(t){return new ri(t instanceof Uint8Array?t:t.subarray())}function yn(t,e,r){let n=Lr(t);return e.decode(n,void 0,r)}var ia=Z("node:buffer");function xn(t){return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}function Tt(t=0){return xn(ia.Buffer.allocUnsafe(t))}var La=Z("node:buffer");var ci={};V(ci,{base10:()=>Ml});var Qg=new Uint8Array(0);function sa(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 Le(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function ca(t){return new TextEncoder().encode(t)}function aa(t){return new TextDecoder().decode(t)}function Pl(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var i=t.charAt(o),s=i.charCodeAt(0);if(r[s]!==255)throw new TypeError(i+" is ambiguous");r[s]=o}var c=t.length,a=t.charAt(0),u=Math.log(c)/Math.log(256),p=Math.log(256)/Math.log(c);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var m=0,b=0,I=0,C=d.length;I!==C&&d[I]===0;)I++,m++;for(var N=(C-I)*p+1>>>0,P=new Uint8Array(N);I!==C;){for(var U=d[I],R=0,K=N-1;(U!==0||R<b)&&K!==-1;K--,R++)U+=256*P[K]>>>0,P[K]=U%c>>>0,U=U/c>>>0;if(U!==0)throw new Error("Non-zero carry");b=R,I++}for(var T=N-b;T!==N&&P[T]===0;)T++;for(var ae=a.repeat(m);T<N;++T)ae+=t.charAt(P[T]);return ae}function f(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var m=0;if(d[m]!==" "){for(var b=0,I=0;d[m]===a;)b++,m++;for(var C=(d.length-m)*u+1>>>0,N=new Uint8Array(C);d[m];){var P=r[d.charCodeAt(m)];if(P===255)return;for(var U=0,R=C-1;(P!==0||U<I)&&R!==-1;R--,U++)P+=c*N[R]>>>0,N[R]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");I=U,m++}if(d[m]!==" "){for(var K=C-I;K!==C&&N[K]===0;)K++;for(var T=new Uint8Array(b+(C-K)),ae=b;K!==C;)T[ae++]=N[K++];return T}}}function h(d){var m=f(d);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:f,decode:h}}var Fl=Pl,Nl=Fl,da=Nl;var ni=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")}},oi=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 la(this,e)}},ii=class{decoders;constructor(e){this.decoders=e}or(e){return la(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 la(t,e){return new ii({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var si=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 ni(e,r,n),this.decoder=new oi(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Qt({name:t,prefix:e,encode:r,decode:n}){return new si(t,e,r,n)}function bt({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=da(r,t);return Qt({prefix:e,name:t,encode:n,decode:i=>Le(o(i))})}function Rl(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 p=e[t[u]];if(p===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|p,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 kl(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 Kl(t){let e={};for(let r=0;r<t.length;++r)e[t[r]]=r;return e}function j({name:t,prefix:e,bitsPerChar:r,alphabet:n}){let o=Kl(n);return Qt({prefix:e,name:t,encode(i){return kl(i,n,r)},decode(i){return Rl(i,o,r,t)}})}var Ml=bt({prefix:"9",name:"base10",alphabet:"0123456789"});var ai={};V(ai,{base16:()=>ql,base16upper:()=>Vl});var ql=j({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Vl=j({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ui={};V(ui,{base2:()=>zl});var zl=j({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var di={};V(di,{base256emoji:()=>Yl});var ha=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}"),Hl=ha.reduce((t,e,r)=>(t[r]=e,t),[]),$l=ha.reduce((t,e,r)=>{let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);return t[n]=r,t},[]);function jl(t){return t.reduce((e,r)=>(e+=Hl[r],e),"")}function Gl(t){let e=[];for(let r of t){let n=r.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${r}`);let o=$l[n];if(o==null)throw new Error(`Non-base256emoji character: ${r}`);e.push(o)}return new Uint8Array(e)}var Yl=Qt({prefix:"\u{1F680}",name:"base256emoji",encode:jl,decode:Gl});var li={};V(li,{base32:()=>Jt,base32hex:()=>Ql,base32hexpad:()=>eh,base32hexpadupper:()=>th,base32hexupper:()=>Jl,base32pad:()=>Wl,base32padupper:()=>Zl,base32upper:()=>Xl,base32z:()=>rh});var Jt=j({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xl=j({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Wl=j({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Zl=j({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ql=j({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Jl=j({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),eh=j({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),th=j({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),rh=j({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hi={};V(hi,{base36:()=>Dr,base36upper:()=>nh});var Dr=bt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),nh=bt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var pi={};V(pi,{base58btc:()=>$e,base58flickr:()=>oh});var $e=bt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),oh=bt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var fi={};V(fi,{base64:()=>ih,base64pad:()=>sh,base64url:()=>ch,base64urlpad:()=>ah});var ih=j({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sh=j({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ch=j({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ah=j({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var mi={};V(mi,{base8:()=>uh});var uh=j({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gi={};V(gi,{identity:()=>dh});var dh=Qt({prefix:"\0",name:"identity",encode:t=>aa(t),decode:t=>ca(t)});var fy=new TextEncoder,my=new TextDecoder;var xi={};V(xi,{identity:()=>_h});var ph=ma,pa=128,fh=127,mh=~fh,gh=Math.pow(2,31);function ma(t,e,r){e=e||[],r=r||0;for(var n=r;t>=gh;)e[r++]=t&255|pa,t/=128;for(;t&mh;)e[r++]=t&255|pa,t>>>=7;return e[r]=t|0,ma.bytes=r-n+1,e}var yh=yi,xh=128,fa=127;function yi(t,n){var r=0,n=n||0,o=0,i=n,s,c=t.length;do{if(i>=c)throw yi.bytes=0,new RangeError("Could not decode varint");s=t[i++],r+=o<28?(s&fa)<<o:(s&fa)*Math.pow(2,o),o+=7}while(s>=xh);return yi.bytes=i-n,r}var bh=Math.pow(2,7),wh=Math.pow(2,14),Eh=Math.pow(2,21),Ih=Math.pow(2,28),Sh=Math.pow(2,35),vh=Math.pow(2,42),Ah=Math.pow(2,49),Bh=Math.pow(2,56),Ch=Math.pow(2,63),Lh=function(t){return t<bh?1:t<wh?2:t<Eh?3:t<Ih?4:t<Sh?5:t<vh?6:t<Ah?7:t<Bh?8:t<Ch?9:10},Dh={encode:ph,decode:yh,encodingLength:Lh},Uh=Dh,Ur=Uh;function Tr(t,e=0){return[Ur.decode(t,e),Ur.decode.bytes]}function er(t,e,r=0){return Ur.encode(t,e,r),e}function tr(t){return Ur.encodingLength(t)}function nr(t,e){let r=e.byteLength,n=tr(t),o=n+tr(r),i=new Uint8Array(o+r);return er(t,i,0),er(r,i,n),i.set(e,o),new rr(t,r,e,i)}function ga(t){let e=Le(t),[r,n]=Tr(e),[o,i]=Tr(e.subarray(n)),s=e.subarray(n+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new rr(r,o,s,e)}function ya(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&sa(t.bytes,r.bytes)}}var rr=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};var xa=0,Th="identity",ba=Le;function Oh(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 nr(xa,ba(t))}var _h={code:xa,name:Th,encode:ba,digest:Oh};var Ii={};V(Ii,{sha256:()=>Fh,sha512:()=>Nh});var Ei=Nt(Z("crypto"),1);var Ph=20;function wi({name:t,code:e,encode:r,minDigestLength:n,maxDigestLength:o}){return new bi(t,e,r,n,o)}var bi=class{name;code;encode;minDigestLength;maxDigestLength;constructor(e,r,n,o,i){this.name=e,this.code=r,this.encode=n,this.minDigestLength=o??Ph,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?wa(n,this.code,r?.truncate):n.then(o=>wa(o,this.code,r?.truncate))}else throw Error("Unknown type, must be binary type")}};function wa(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 nr(e,t)}var Fh=wi({name:"sha2-256",code:18,encode:t=>Le(Ei.default.createHash("sha256").update(t).digest())}),Nh=wi({name:"sha2-512",code:19,encode:t=>Le(Ei.default.createHash("sha512").update(t).digest())});function Ia(t,e){let{bytes:r,version:n}=t;return n===0?kh(r,Si(t),e??$e.encoder):Kh(r,Si(t),e??Jt.encoder)}var Sa=new WeakMap;function Si(t){let e=Sa.get(t);if(e==null){let r=new Map;return Sa.set(t,r),r}return e}var wn=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==_r)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==Mh)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=nr(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&&ya(e.multihash,n.multihash)}toString(e){return Ia(this,e)}toJSON(){return{"/":Ia(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??va(n,o,i.bytes))}else if(r[qh]===!0){let{version:n,multihash:o,code:i}=r,s=ga(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!==_r)throw new Error(`Version 0 CID must use dag-pb (code: ${_r}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=va(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,_r,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=Le(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 rr(r.multihashCode,r.digestSize,i,o);return[r.version===0?t.createV0(s):t.createV1(r.codec,s),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[l,f]=Tr(e.subarray(r));return r+=f,l},o=n(),i=_r;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,p=u-s;return{version:o,codec:i,multihashCode:c,digestSize:a,multihashSize:p,size:u}}static parse(e,r){let[n,o]=Rh(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 Si(i).set(n,e),i}};function Rh(t,e){switch(t[0]){case"Q":{let r=e??$e;return[$e.prefix,r.decode(`${$e.prefix}${t}`)]}case $e.prefix:{let r=e??$e;return[$e.prefix,r.decode(t)]}case Jt.prefix:{let r=e??Jt;return[Jt.prefix,r.decode(t)]}case Dr.prefix:{let r=e??Dr;return[Dr.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 kh(t,e,r){let{prefix:n}=r;if(n!==$e.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 Kh(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 _r=112,Mh=18;function va(t,e,r){let n=tr(t),o=n+tr(e),i=new Uint8Array(o+r.byteLength);return er(t,i,0),er(e,i,n),i.set(r,o),i}var qh=Symbol.for("@ipld/js-cid/CID");var vi={...gi,...ui,...mi,...ci,...ai,...li,...hi,...pi,...fi,...di},ky={...Ii,...xi};function Ba(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}var Aa=Ba("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Ai=Ba("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=Tt(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Vh={utf8:Aa,"utf-8":Aa,hex:vi.base16,latin1:Ai,ascii:Ai,binary:Ai,...vi},Ca=Vh;function Da(t,e="utf8"){let r=Ca[e];if(r==null)throw new Error(`Unsupported encoding "${e}"`);return e==="utf8"||e==="utf-8"?xn(La.Buffer.from(t,"utf-8")):r.decoder.decode(`${r.prefix}${t}`)}function Bi(t){let e=t??8192,r=e>>>1,n,o=e;return function(s){if(s<1||s>r)return Tt(s);o+s>e&&(n=Tt(e),o=0);let c=n.subarray(o,o+=s);return(o&7)!==0&&(o=(o|7)+1),c}}var Ot=class{fn;len;next;val;constructor(e,r,n){this.fn=e,this.len=r,this.next=void 0,this.val=n}};function Ci(){}var Di=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},zh=Bi();function Hh(t){return globalThis.Buffer!=null?Tt(t):zh(t)}var Fr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ot(Ci,0,0),this.tail=this.head,this.states=null}_push(e,r,n){return this.tail=this.tail.next=new Ot(e,r,n),this.len+=r,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Ui((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(En,10,Ie.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let r=Ie.fromBigInt(e);return this._push(En,r.length(),r)}uint64Number(e){return this._push(Xc,Cr(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=Ie.fromBigInt(e).zzEncode();return this._push(En,r.length(),r)}sint64Number(e){let r=Ie.fromNumber(e).zzEncode();return this._push(En,r.length(),r)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Li,1,e?1:0)}fixed32(e){return this._push(Pr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let r=Ie.fromBigInt(e);return this._push(Pr,4,r.lo)._push(Pr,4,r.hi)}fixed64Number(e){let r=Ie.fromNumber(e);return this._push(Pr,4,r.lo)._push(Pr,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(Zc,4,e)}double(e){return this._push(Jc,8,e)}bytes(e){let r=e.length>>>0;return r===0?this._push(Li,1,0):this.uint32(r)._push(jh,r,e)}string(e){let r=ra(e);return r!==0?this.uint32(r)._push(ti,r,e):this._push(Li,1,0)}fork(){return this.states=new Di(this),this.head=this.tail=new Ot(Ci,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 Ot(Ci,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=Hh(this.len),n=0;for(;e!=null;)e.fn(e.val,r,n),n+=e.len,e=e.next;return r}};function Li(t,e,r){e[r]=t&255}function $h(t,e,r){for(;t>127;)e[r++]=t&127|128,t>>>=7;e[r]=t}var Ui=class extends Ot{next;constructor(e,r){super($h,e,r),this.next=void 0}};function En(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 Pr(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 jh(t,e,r){e.set(t,r)}globalThis.Buffer!=null&&(Fr.prototype.bytes=function(t){let e=t.length>>>0;return this.uint32(e),e>0&&this._push(Gh,e,t),this},Fr.prototype.string=function(t){let e=globalThis.Buffer.byteLength(t);return this.uint32(e),e>0&&this._push(Yh,e,t),this});function Gh(t,e,r){e.set(t,r)}function Yh(t,e,r){t.length<40?ti(t,e,r):e.utf8Write!=null?e.utf8Write(t,r):e.set(Da(t),r)}function Ti(){return new Fr}function In(t,e){let r=Ti();return e.encode(t,r,{lengthDelimited:!1}),r.finish()}function*Sn(t,e,r){let n=Lr(t);yield*e.stream(n,void 0,"$",r)}var vn={VARINT:0,BIT64:1,LENGTH_DELIMITED:2,START_GROUP:3,END_GROUP:4,BIT32:5};function An(t,e,r,n,o){return{name:t,type:e,encode:r,decode:n,stream:o}}function Oi(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 An("enum",vn.VARINT,r,n,o)}function Bn(t,e,r){return An("message",vn.LENGTH_DELIMITED,t,e,r)}var pe;(function(t){t.RSA="RSA",t.Ed25519="Ed25519",t.secp256k1="secp256k1",t.ECDSA="ECDSA"})(pe||(pe={}));var _i;(function(t){t[t.RSA=0]="RSA",t[t.Ed25519=1]="Ed25519",t[t.secp256k1=2]="secp256k1",t[t.ECDSA=3]="ECDSA"})(_i||(_i={}));(function(t){t.codec=()=>Oi(_i)})(pe||(pe={}));var Nr;(function(t){let e;t.codec=()=>(e==null&&(e=Bn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),pe.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 p=i.uint32();switch(p>>>3){case 1:{a.Type=pe.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(p&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>3){case 1:{yield{field:`${c}.Type`,value:pe.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(p&7);break}}}})),e);function r(i){return In(i,t.codec())}t.encode=r;function n(i,s){return yn(i,t.codec(),s)}t.decode=n;function o(i,s){return Sn(i,t.codec(),s)}t.stream=o})(Nr||(Nr={}));var Pi;(function(t){let e;t.codec=()=>(e==null&&(e=Bn((i,s,c={})=>{c.lengthDelimited!==!1&&s.fork(),i.Type!=null&&(s.uint32(8),pe.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 p=i.uint32();switch(p>>>3){case 1:{a.Type=pe.codec().decode(i);break}case 2:{a.Data=i.bytes();break}default:{i.skipType(p&7);break}}}return a},function*(i,s,c,a={}){let u=s==null?i.len:i.pos+s;for(;i.pos<u;){let p=i.uint32();switch(p>>>3){case 1:{yield{field:`${c}.Type`,value:pe.codec().decode(i)};break}case 2:{yield{field:`${c}.Data`,value:i.bytes()};break}default:{i.skipType(p&7);break}}}})),e);function r(i){return In(i,t.codec())}t.encode=r;function n(i,s){return yn(i,t.codec(),s)}t.decode=n;function o(i,s){return Sn(i,t.codec(),s)}t.stream=o})(Pi||(Pi={}));var ka=Nt(Z("node:crypto"),1);var Cn=class{oHash;iHash;blockLen;outputLen;canXOF=!1;finished=!1;destroyed=!1;constructor(e,r){if(en(e),He(r,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let n=this.blockLen,o=new Uint8Array(n);o.set(r.length>n?e.create().update(r).digest():r);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),At(o)}update(e){return Gt(this),this.iHash.update(e),this}digestInto(e){Gt(this),tn(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}=this;return e=e,e.finished=o,e.destroyed=i,e.blockLen=s,e.outputLen=c,e.oHash=r._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ua=(()=>{let t=((e,r,n)=>new Cn(e,r).update(n).digest());return t.create=(e,r)=>new Cn(e,r),t})();var Ta=(t,e)=>(t+(t>=0?e:-e)/Oa)/e;function Wh(t,e,r){zo("scalar",t,je,r);let[[n,o],[i,s]]=e,c=Ta(s*t,r),a=Ta(-o*t,r),u=t-c*n-a*i,p=-c*o-a*s,l=u<je,f=p<je;l&&(u=-u),f&&(p=-p);let h=vr(Math.ceil(Xt(r)/2))+wt;if(u<je||u>=h||p<je||p>=h)throw new Error("splitScalar (endomorphism): failed for k");return{k1neg:l,k1:u,k2neg:f,k2:p}}function Ni(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Fi(t,e){Ct(t);let r={};for(let n of Object.keys(e))r[n]=t[n]===void 0?e[n]:t[n];return Bt(r.lowS,"lowS"),Bt(r.prehash,"prehash"),r.format!==void 0&&Ni(r.format),r}var Ri=class extends Error{constructor(e=""){super(e)}},Ne={Err:Ri,_tlv:{encode:(t,e)=>{let{Err:r}=Ne;if(Ir(t,"tag"),t<0||t>255)throw new r("tlv.encode: wrong tag");if(typeof e!="string")throw new TypeError('"data" expected string, got type='+typeof e);if(e.length&1)throw new r("tlv.encode: unpadded data");let n=e.length/2,o=Sr(n);if(o.length/2&128)throw new r("tlv.encode: long form length too big");let i=n>127?Sr(o.length/2|128):"";return Sr(t)+i+o+e},decode(t,e){let{Err:r}=Ne;e=J(e,void 0,"DER data");let n=0;if(t<0||t>255)throw new r("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new r("tlv.decode: wrong tlv");let o=e[n++],i=!!(o&128),s=0;if(!i)s=o;else{let a=o&127;if(!a)throw new r("tlv.decode(long): indefinite length not supported");if(a>4)throw new r("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+a);if(u.length!==a)throw new r("tlv.decode: length bytes not complete");if(u[0]===0)throw new r("tlv.decode(long): zero leftmost byte");for(let p of u)s=s<<8|p;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}=Ne;if(un(t),t<je)throw new e("integer: negative integers are not allowed");let r=Sr(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}=Ne;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 Yt(t)}},toSig(t){let{Err:e,_int:r,_tlv:n}=Ne,o=J(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:p}=n.decode(2,a);if(p.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}=Ne,n=e.encode(2,r.encode(t.r)),o=e.encode(2,r.encode(t.s)),i=n+o;return e.encode(48,i)}};Object.freeze(Ne._tlv);Object.freeze(Ne._int);Object.freeze(Ne);var je=BigInt(0),wt=BigInt(1),Oa=BigInt(2),Ln=BigInt(3),Zh=BigInt(4);function _a(t,e={}){let r=kc("weierstrass",t,e),n=r.Fp,o=r.Fn,i=r.CURVE,{h:s,n:c}=i;Ct(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object"});let{endo:a,allowInfinityPoint:u}=e;if(a&&(!n.is0(i.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');let p=Fa(n,o);function l(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function f(G,x,L){if(u&&x.is0())return Uint8Array.of(0);let{x:O,y:w}=x.toAffine(),g=n.toBytes(O);if(Bt(L,"isCompressed"),L){l();let E=!n.isOdd(w);return at(Pa(E),g)}else return at(Uint8Array.of(4),g,n.toBytes(w))}function h(G){J(G,void 0,"Point");let{publicKey:x,publicKeyUncompressed:L}=p,O=G.length,w=G[0],g=G.subarray(1);if(u&&O===1&&w===0)return{x:n.ZERO,y:n.ZERO};if(O===x&&(w===2||w===3)){let E=n.fromBytes(g);if(!n.isValid(E))throw new Error("bad point: is not on curve, wrong x");let v=b(E),S;try{S=n.sqrt(v)}catch(q){let M=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+M)}l();let D=n.isOdd(S);return(w&1)===1!==D&&(S=n.neg(S)),{x:E,y:S}}else if(O===L&&w===4){let E=n.BYTES,v=n.fromBytes(g.subarray(0,E)),S=n.fromBytes(g.subarray(E,E*2));if(!I(v,S))throw new Error("bad point: is not on curve");return{x:v,y:S}}else throw new Error(`bad point: got length ${O}, expected compressed=${x} or uncompressed=${L}`)}let d=e.toBytes===void 0?f:e.toBytes,m=e.fromBytes===void 0?h:e.fromBytes;function b(G){let x=n.sqr(G),L=n.mul(x,G);return n.add(n.add(L,n.mul(G,i.a)),i.b)}function I(G,x){let L=n.sqr(x),O=b(G);return n.eql(L,O)}if(!I(i.Gx,i.Gy))throw new Error("bad curve params: generator point");let C=n.mul(n.pow(i.a,Ln),Zh),N=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(C,N)))throw new Error("bad curve params: a or b");function P(G,x,L=!1){if(!n.isValid(x)||L&&n.is0(x))throw new Error(`bad point coordinate ${G}`);return x}function U(G){if(!(G instanceof T))throw new Error("Weierstrass Point expected")}function R(G){if(!a||!a.basises)throw new Error("no endo");return Wh(G,a.basises,o.ORDER)}function K(G,x,L,O,w){return L=new T(n.mul(L.X,G),L.Y,L.Z),x=Ar(O,x),L=Ar(w,L),x.add(L)}class T{static BASE=new T(i.Gx,i.Gy,n.ONE);static ZERO=new T(n.ZERO,n.ONE,n.ZERO);static Fp=n;static Fn=o;X;Y;Z;constructor(x,L,O){this.X=P("x",x),this.Y=P("y",L,!0),this.Z=P("z",O),Object.freeze(this)}static CURVE(){return i}static fromAffine(x){let{x:L,y:O}=x||{};if(!x||!n.isValid(L)||!n.isValid(O))throw new Error("invalid affine point");if(x instanceof T)throw new Error("projective point not allowed");return n.is0(L)&&n.is0(O)?T.ZERO:new T(L,O,n.ONE)}static fromBytes(x){let L=T.fromAffine(m(J(x,void 0,"point")));return L.assertValidity(),L}static fromHex(x){return T.fromBytes(an(x))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(x=8,L=!0){return Ye.createCache(this,x),L||this.multiply(Ln),this}assertValidity(){let x=this;if(x.is0()){if(e.allowInfinityPoint&&n.is0(x.X)&&n.eql(x.Y,n.ONE)&&n.is0(x.Z))return;throw new Error("bad point: ZERO")}let{x:L,y:O}=x.toAffine();if(!n.isValid(L)||!n.isValid(O))throw new Error("bad point: x or y not field elements");if(!I(L,O))throw new Error("bad point: equation left != right");if(!x.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:x}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(x)}equals(x){U(x);let{X:L,Y:O,Z:w}=this,{X:g,Y:E,Z:v}=x,S=n.eql(n.mul(L,v),n.mul(g,w)),D=n.eql(n.mul(O,v),n.mul(E,w));return S&&D}negate(){return new T(this.X,n.neg(this.Y),this.Z)}double(){let{a:x,b:L}=i,O=n.mul(L,Ln),{X:w,Y:g,Z:E}=this,v=n.ZERO,S=n.ZERO,D=n.ZERO,_=n.mul(w,w),q=n.mul(g,g),M=n.mul(E,E),k=n.mul(w,g);return k=n.add(k,k),D=n.mul(w,E),D=n.add(D,D),v=n.mul(x,D),S=n.mul(O,M),S=n.add(v,S),v=n.sub(q,S),S=n.add(q,S),S=n.mul(v,S),v=n.mul(k,v),D=n.mul(O,D),M=n.mul(x,M),k=n.sub(_,M),k=n.mul(x,k),k=n.add(k,D),D=n.add(_,_),_=n.add(D,_),_=n.add(_,M),_=n.mul(_,k),S=n.add(S,_),M=n.mul(g,E),M=n.add(M,M),_=n.mul(M,k),v=n.sub(v,_),D=n.mul(M,q),D=n.add(D,D),D=n.add(D,D),new T(v,S,D)}add(x){U(x);let{X:L,Y:O,Z:w}=this,{X:g,Y:E,Z:v}=x,S=n.ZERO,D=n.ZERO,_=n.ZERO,q=i.a,M=n.mul(i.b,Ln),k=n.mul(L,g),te=n.mul(O,E),re=n.mul(w,v),ne=n.add(L,O),Y=n.add(g,E);ne=n.mul(ne,Y),Y=n.add(k,te),ne=n.sub(ne,Y),Y=n.add(L,w);let fe=n.add(g,v);return Y=n.mul(Y,fe),fe=n.add(k,re),Y=n.sub(Y,fe),fe=n.add(O,w),S=n.add(E,v),fe=n.mul(fe,S),S=n.add(te,re),fe=n.sub(fe,S),_=n.mul(q,Y),S=n.mul(M,re),_=n.add(S,_),S=n.sub(te,_),_=n.add(te,_),D=n.mul(S,_),te=n.add(k,k),te=n.add(te,k),re=n.mul(q,re),Y=n.mul(M,Y),te=n.add(te,re),re=n.sub(k,re),re=n.mul(q,re),Y=n.add(Y,re),k=n.mul(te,Y),D=n.add(D,k),k=n.mul(fe,Y),S=n.mul(ne,S),S=n.sub(S,k),k=n.mul(ne,te),_=n.mul(fe,_),_=n.add(_,k),new T(S,D,_)}subtract(x){return U(x),this.add(x.negate())}is0(){return this.equals(T.ZERO)}multiply(x){let{endo:L}=e;if(!o.isValidNot0(x))throw new RangeError("invalid scalar: out of range");let O,w,g=E=>Ye.cached(this,E,v=>Zo(T,v));if(L){let{k1neg:E,k1:v,k2neg:S,k2:D}=R(x),{p:_,f:q}=g(v),{p:M,f:k}=g(D);w=q.add(k),O=K(L.beta,_,M,E,S)}else{let{p:E,f:v}=g(x);O=E,w=v}return Zo(T,[O,w])[0]}multiplyUnsafe(x){let{endo:L}=e,O=this,w=x;if(!o.isValid(w))throw new RangeError("invalid scalar: out of range");if(w===je||O.is0())return T.ZERO;if(w===wt)return O;if(Ye.hasCache(this))return this.multiply(w);if(L){let{k1neg:g,k1:E,k2neg:v,k2:S}=R(w),{p1:D,p2:_}=Rc(T,O,E,S);return K(L.beta,D,_,g,v)}else return Ye.unsafe(O,w)}toAffine(x){let L=this,O=x,{X:w,Y:g,Z:E}=L;if(n.eql(E,n.ONE))return{x:w,y:g};let v=L.is0();O==null&&(O=v?n.ONE:n.inv(E));let S=n.mul(w,O),D=n.mul(g,O),_=n.mul(E,O);if(v)return{x:n.ZERO,y:n.ZERO};if(!n.eql(_,n.ONE))throw new Error("invZ was invalid");return{x:S,y:D}}isTorsionFree(){let{isTorsionFree:x}=e;return s===wt?!0:x?x(T,this):Ye.unsafe(this,c).is0()}clearCofactor(){let{clearCofactor:x}=e;return s===wt?this:x?x(T,this):this.multiplyUnsafe(s)}isSmallOrder(){return s===wt?this.is0():this.clearCofactor().is0()}toBytes(x=!0){return Bt(x,"isCompressed"),this.assertValidity(),d(T,this,x)}toHex(x=!0){return ko(this.toBytes(x))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}}let ae=o.BITS,Ye=new pn(T,e.endo?Math.ceil(ae/2):ae);return ae>=8&&T.BASE.precompute(8),Object.freeze(T.prototype),Object.freeze(T),T}function Pa(t){return Uint8Array.of(t?2:3)}function Fa(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function Qh(t,e={}){let{Fn:r}=t,n=e.randomBytes===void 0?Mo:e.randomBytes,o=Object.assign(Fa(t.Fp,r),{seed:Math.max(jo(r.ORDER),16)});function i(h){try{let d=r.fromBytes(h);return r.isValidNot0(d)}catch{return!1}}function s(h,d){let{publicKey:m,publicKeyUncompressed:b}=o;try{let I=h.length;return d===!0&&I!==m||d===!1&&I!==b?!1:!!t.fromBytes(h)}catch{return!1}}function c(h){return h=h===void 0?n(o.seed):h,Go(J(h,o.seed,"seed"),r.ORDER)}function a(h,d=!0){return t.BASE.multiply(r.fromBytes(h)).toBytes(d)}function u(h){let{secretKey:d,publicKey:m,publicKeyUncompressed:b}=o,I=r._lengths;if(!Ko(h))return;let C=J(h,void 0,"key").length,N=C===m||C===b,P=C===d||!!I?.includes(C);if(!(N&&P))return N}function p(h,d,m=!0){if(u(h)===!0)throw new Error("first arg must be private key");if(u(d)===!1)throw new Error("second arg must be public key");let b=r.fromBytes(h);return t.fromBytes(d).multiply(b).toBytes(m)}let l={isValidSecretKey:i,isValidPublicKey:s,randomSecretKey:c},f=Kc(c,a);return Object.freeze(l),Object.freeze(o),Object.freeze({getPublicKey:a,getSharedSecret:p,keygen:f,Point:t,utils:l,lengths:o})}function Na(t,e,r={}){let n=e;en(n),Ct(r,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"}),r=Object.assign({},r);let o=r.randomBytes===void 0?Mo:r.randomBytes,i=r.hmac===void 0?(w,g)=>Ua(n,w,g):r.hmac,{Fp:s,Fn:c}=t,{ORDER:a,BITS:u}=c,{keygen:p,getPublicKey:l,getSharedSecret:f,utils:h,lengths:d}=Qh(t,r),m={prehash:!0,lowS:typeof r.lowS=="boolean"?r.lowS:!0,format:"compact",extraEntropy:!1},b=a*Oa+wt<s.ORDER;function I(w){let g=a>>wt;return w>g}function C(w,g){if(!c.isValidNot0(g))throw new Error(`invalid signature ${w}: out of range 1..Point.Fn.ORDER`);return g}function N(){if(b)throw new Error('"recovered" sig type is not supported for cofactor >2 curves')}function P(w,g){Ni(g);let E=d.signature,v=g==="compact"?E:g==="recovered"?E+1:void 0;return J(w,v)}class U{r;s;recovery;constructor(g,E,v){if(this.r=C("r",g),this.s=C("s",E),v!=null){if(N(),![0,1,2,3].includes(v))throw new Error("invalid recovery id");this.recovery=v}Object.freeze(this)}static fromBytes(g,E=m.format){P(g,E);let v;if(E==="der"){let{r:q,s:M}=Ne.toSig(J(g));return new U(q,M)}E==="recovered"&&(v=g[0],E="compact",g=g.subarray(1));let S=d.signature/2,D=g.subarray(0,S),_=g.subarray(S,S*2);return new U(c.fromBytes(D),c.fromBytes(_),v)}static fromHex(g,E){return this.fromBytes(an(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 U(this.r,this.s,g)}recoverPublicKey(g){let{r:E,s:v}=this,S=this.assertRecovery(),D=S===2||S===3?E+a:E;if(!s.isValid(D))throw new Error("invalid recovery id: sig.r+curve.n != R.x");let _=s.toBytes(D),q=t.fromBytes(at(Pa((S&1)===0),_)),M=c.inv(D),k=K(J(g,void 0,"msgHash")),te=c.create(-k*M),re=c.create(v*M),ne=t.BASE.multiplyUnsafe(te).add(q.multiplyUnsafe(re));if(ne.is0())throw new Error("invalid recovery: point at infinify");return ne.assertValidity(),ne}hasHighS(){return I(this.s)}toBytes(g=m.format){if(Ni(g),g==="der")return an(Ne.hexFromSig(this));let{r:E,s:v}=this,S=c.toBytes(E),D=c.toBytes(v);return g==="recovered"?(N(),at(Uint8Array.of(this.assertRecovery()),S,D)):at(S,D)}toHex(g){return ko(this.toBytes(g))}}Object.freeze(U.prototype),Object.freeze(U);let R=r.bits2int===void 0?function(g){if(g.length>8192)throw new Error("input is too large");let E=Yt(g),v=g.length*8-u;return v>0?E>>BigInt(v):E}:r.bits2int,K=r.bits2int_modN===void 0?function(g){return c.create(R(g))}:r.bits2int_modN,T=vr(u);function ae(w){return zo("num < 2^"+u,w,je,T),c.toBytes(w)}function Ye(w,g){return J(w,void 0,"message"),g?J(n(w),void 0,"prehashed message"):w}function G(w,g,E){let{lowS:v,prehash:S,extraEntropy:D}=Fi(E,m);w=Ye(w,S);let _=K(w),q=c.fromBytes(g);if(!c.isValidNot0(q))throw new Error("invalid private key");let M=[ae(q),ae(_)];if(D!=null&&D!==!1){let ne=D===!0?o(d.secretKey):D;M.push(J(ne,void 0,"extraEntropy"))}let k=at(...M),te=_;function re(ne){let Y=R(ne);if(!c.isValidNot0(Y))return;let fe=c.inv(Y),Ft=t.BASE.multiply(Y).toAffine(),ur=c.create(Ft.x);if(ur===je)return;let Vr=c.create(fe*c.create(te+ur*q));if(Vr===je)return;let ss=(Ft.x===ur?0:2)|Number(Ft.y&wt),cs=Vr;return v&&I(Vr)&&(cs=c.neg(Vr),ss^=1),new U(ur,cs,b?void 0:ss)}return{seed:k,k2sig:re}}function x(w,g,E={}){let{seed:v,k2sig:S}=G(w,g,E);return wc(n.outputLen,c.BYTES,i)(v,S).toBytes(E.format)}function L(w,g,E,v={}){let{lowS:S,prehash:D,format:_}=Fi(v,m);if(E=J(E,void 0,"publicKey"),g=Ye(g,D),!Ko(w)){let q=w instanceof U?", use sig.toBytes()":"";throw new Error("verify expects Uint8Array signature"+q)}P(w,_);try{let q=U.fromBytes(w,_),M=t.fromBytes(E);if(S&&q.hasHighS())return!1;let{r:k,s:te}=q,re=K(g),ne=c.inv(te),Y=c.create(re*ne),fe=c.create(k*ne),Ft=t.BASE.multiplyUnsafe(Y).add(M.multiplyUnsafe(fe));return Ft.is0()?!1:c.create(Ft.x)===k}catch{return!1}}function O(w,g,E={}){let{prehash:v}=Fi(E,m);return g=Ye(g,v),U.fromBytes(w,"recovered").recoverPublicKey(g).toBytes()}return Object.freeze({keygen:p,getPublicKey:l,getSharedSecret:f,utils:h,lengths:d,Point:t,sign:x,verify:L,recoverPublicKey:O,Signature:U,hash:n})}var Ki={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},Jh={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]};var Ra=BigInt(2);function ep(t){let e=Ki.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,p=u*u*t%e,l=Ee(p,r,e)*p%e,f=Ee(l,r,e)*p%e,h=Ee(f,Ra,e)*u%e,d=Ee(h,o,e)*h%e,m=Ee(d,i,e)*d%e,b=Ee(m,c,e)*m%e,I=Ee(b,a,e)*b%e,C=Ee(I,c,e)*m%e,N=Ee(C,r,e)*p%e,P=Ee(N,s,e)*d%e,U=Ee(P,n,e)*u%e,R=Ee(U,Ra,e);if(!ki.eql(ki.sqr(R),t))throw new Error("Cannot find square root");return R}var ki=Wt(Ki.p,{sqrt:ep}),tp=_a(Ki,{Fp:ki,endo:Jh}),Rr=Na(tp,xc);var Dn=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}};function Ka(t,e,r,n){n?.signal?.throwIfAborted();let o=ka.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 Rr.verify(e,i,t,{prehash:!1,format:"der"})}catch(s){throw new Dn(String(s))}}var Un=class{type="secp256k1";raw;_key;constructor(e){this._key=qa(e),this.raw=Ma(this._key)}toMultihash(){return Oe.digest(jt(this))}toCID(){return ie.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:Ce(this.raw,e.raw)}verify(e,r,n){return Ka(this._key,r,e,n)}};function Va(t){return new Un(t)}function Ma(t){return Rr.Point.fromBytes(t).toBytes()}function qa(t){try{return Rr.Point.fromBytes(t),t}catch(e){throw new Hr(String(e))}}function za(t){let{Type:e,Data:r}=Nr.decode(t.digest),n=r??new Uint8Array;switch(e){case pe.Ed25519:return Hc(n);case pe.secp256k1:return Va(n);case pe.ECDSA:return cc(n);default:throw new dr}}function jt(t){return Nr.encode({Type:pe[t.type],Data:t.raw})}var Ha=Symbol.for("nodejs.util.inspect.custom"),rp=114,kr=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()})`}[Kn]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return ie.createV1(rp,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return Ce(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return Ce(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[Ha](){return`PeerId(${this.toString()})`}},Tn=class extends kr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},On=class extends kr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},_n=class extends kr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},np=2336,Kr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=Oe.digest(we(this.url))}[Ha](){return`PeerId(${this.url})`}[Kn]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return ie.createV1(np,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=$(e)),e.toString()===this.toString())}};var op=114,$a=2336;function ja(t,e){let r;if(t.charAt(0)==="1"||t.charAt(0)==="Q")r=mr(X.decode(`z${t}`));else{if(t.startsWith("k51qzi5uqu5")||t.startsWith("kzwfwjn5ji4")||t.startsWith("k2k4r8")||t.startsWith("bafz"))return ip(ie.parse(t));if(e==null)throw new Ae('Please pass a multibase decoder for strings that do not start with "1" or "Q"');r=mr(e.decode(t))}return Ga(r)}function Ga(t){if(cp(t))return new Tn({multihash:t});if(sp(t))try{let e=za(t);if(e.type==="Ed25519")return new On({multihash:t,publicKey:e});if(e.type==="secp256k1")return new _n({multihash:t,publicKey:e})}catch{let r=$(t.digest);return new Kr(new URL(r))}throw new jr("Supplied PeerID Multihash is invalid")}function ip(t){if(t?.multihash==null||t.version==null||t.version===1&&t.code!==op&&t.code!==$a)throw new $r("Supplied PeerID CID is invalid");if(t.code===$a){let e=$(t.multihash.digest);return new Kr(new URL(e))}return Ga(t.multihash)}function sp(t){return t.code===Oe.code}function cp(t){return t.code===So.code}function ap(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 Ya(t){let e=ap(t);if(e==null)throw new Ae(`Multiaddr ${t} was not an IPv4, IPv6, DNS, DNS4, DNS6 or DNSADDR address`);return e}var Se=Z("node:net");var Qa=Nt(Za(),1),mp=["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"],gp=mp.map(t=>new Qa.Netmask(t));function ji(t){for(let e of gp)if(e.contains(t))return!0;return!1}function yp(t){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(t)}function xp(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 ji(o)}function bp(t){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)}function wp(t){let e=t.split(":"),r=e[e.length-1];return ji(r)}function Ep(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 Ja(t){if((0,Se.isIPv4)(t))return ji(t);if(yp(t))return xp(t);if(bp(t))return wp(t);if((0,Se.isIPv6)(t))return Ep(t)}function eu(t){try{let e=Ya(t);switch(e.type){case"ip4":case"ip6":return Ja(e.host)??!1;default:return e.host==="localhost"}}catch{return!1}}var Ip=Math.pow(2,7),Sp=Math.pow(2,14),vp=Math.pow(2,21),Gi=Math.pow(2,28),Yi=Math.pow(2,35),Xi=Math.pow(2,42),Wi=Math.pow(2,49),z=128,de=127;function cr(t){if(t<Ip)return 1;if(t<Sp)return 2;if(t<vp)return 3;if(t<Gi)return 4;if(t<Yi)return 5;if(t<Xi)return 6;if(t<Wi)return 7;if(Number.MAX_SAFE_INTEGER!=null&&t>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Zi(t,e,r=0){switch(cr(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 Ap(t,e){let r=t[e],n=0;if(n+=r&de,r<z||(r=t[e+1],n+=(r&de)<<7,r<z)||(r=t[e+2],n+=(r&de)<<14,r<z)||(r=t[e+3],n+=(r&de)<<21,r<z)||(r=t[e+4],n+=(r&de)*Gi,r<z)||(r=t[e+5],n+=(r&de)*Yi,r<z)||(r=t[e+6],n+=(r&de)*Xi,r<z)||(r=t[e+7],n+=(r&de)*Wi,r<z))return n;throw new RangeError("Could not decode varint")}function Bp(t,e){let r=t.get(e),n=0;if(n+=r&de,r<z||(r=t.get(e+1),n+=(r&de)<<7,r<z)||(r=t.get(e+2),n+=(r&de)<<14,r<z)||(r=t.get(e+3),n+=(r&de)<<21,r<z)||(r=t.get(e+4),n+=(r&de)*Gi,r<z)||(r=t.get(e+5),n+=(r&de)*Yi,r<z)||(r=t.get(e+6),n+=(r&de)*Xi,r<z)||(r=t.get(e+7),n+=(r&de)*Wi,r<z))return n;throw new RangeError("Could not decode varint")}function Qi(t,e=0){return t instanceof Uint8Array?Ap(t,e):Bp(t,e)}var ce=class extends Error{static name="InvalidMultiaddrError";name="InvalidMultiaddrError"},ut=class extends Error{static name="ValidationError";name="ValidationError"},Fn=class extends Error{static name="InvalidParametersError";name="InvalidParametersError"},Nn=class extends Error{static name="UnknownProtocolError";name="UnknownProtocolError"};function es(t){return e=>$(e,t)}function ts(t){return e=>we(e,t)}function ar(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 tu(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=we(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 gt([r,o],r.length+o.length)}function ru(t){let e=t.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let r=pt.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let o=Pt(n);return gt([r,o],r.length+o.length)}function rs(t){let e=t.subarray(0,t.length-2),r=t.subarray(t.length-2),n=$(e,"base32"),o=ar(r);return`${n}:${o}`}var ns=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 ce("Invalid byte value in IP address");e[n]=o}),e},nu=function(t){let e=0;t=t.toString().trim();let r=t.split(":",8),n;for(n=0;n<r.length;n++){let i=(0,Se.isIPv4)(r[n]),s;i&&(s=ns(r[n]),r[n]=$(s.subarray(0,2),"base16")),s!=null&&++n<8&&r.splice(n,0,$(s.subarray(2,4),"base16"))}if(r[0]==="")for(;r.length<8;)r.unshift("0");else if(r[r.length-1]==="")for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&r[n]!=="";n++);let i=[n,1];for(n=9-r.length;n>0;n--)i.push("0");r.splice.apply(r,i)}let o=new Uint8Array(e+16);for(n=0;n<r.length;n++){r[n]===""&&(r[n]="0");let i=parseInt(r[n],16);if(isNaN(i)||i<0||i>65535)throw new ce("Invalid byte value in IP address");o[e++]=i>>8&255,o[e++]=i&255}return o},ou=function(t){if(t.byteLength!==4)throw new ce("IPv4 address was incorrect length");let e=[];for(let r=0;r<t.byteLength;r++)e.push(t[r]);return e.join(".")},iu=function(t){if(t.byteLength!==16)throw new ce("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 ce(`Invalid IPv6 address "${r}"`)}};function su(t){try{let e=new URL(`http://[${t}]`);return e.hostname.substring(1,e.hostname.length-1)}catch{throw new ce(`Invalid IPv6 address "${t}"`)}}var Ji=Object.values(xr).map(t=>t.decoder),Lp=(function(){let t=Ji[0].or(Ji[1]);return Ji.slice(2).forEach(e=>t=t.or(e)),t})();function cu(t){return Lp.decode(t)}function au(t){return e=>t.encoder.encode(e)}function Dp(t){if(parseInt(t).toString()!==t)throw new ut("Value must be an integer")}function Up(t){if(t<0)throw new ut("Value must be a positive integer, or zero")}function Tp(t){return e=>{if(e>t)throw new ut(`Value must be smaller than or equal to ${t}`)}}function Op(...t){return e=>{for(let r of t)r(e)}}var Mr=Op(Dp,Up,Tp(65535));var ee=-1,os=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 Nn(`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)}))}},dt=new os,x0=[{code:4,name:"ip4",size:32,valueToBytes:ns,bytesToValue:ou,validate:t=>{if(!(0,Se.isIPv4)(t))throw new ut(`Invalid IPv4 address "${t}"`)}},{code:6,name:"tcp",size:16,valueToBytes:Pt,bytesToValue:ar,validate:Mr},{code:273,name:"udp",size:16,valueToBytes:Pt,bytesToValue:ar,validate:Mr},{code:33,name:"dccp",size:16,valueToBytes:Pt,bytesToValue:ar,validate:Mr},{code:41,name:"ip6",size:128,valueToBytes:nu,bytesToValue:iu,stringToValue:su,validate:t=>{if(!(0,Se.isIPv6)(t))throw new ut(`Invalid IPv6 address "${t}"`)}},{code:42,name:"ip6zone",size:ee},{code:43,name:"ipcidr",size:8,bytesToValue:es("base10"),valueToBytes:ts("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:ar,validate:Mr},{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:es("base58btc"),valueToBytes:t=>t.startsWith("Q")||t.startsWith("1")?ts("base58btc")(t):ie.parse(t).multihash.bytes},{code:444,name:"onion",size:96,bytesToValue:rs,valueToBytes:tu},{code:445,name:"onion3",size:296,bytesToValue:rs,valueToBytes:ru},{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:au(go),valueToBytes:cu},{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}];x0.forEach(t=>{dt.addProtocol(t)});function uu(t){let e=[],r=0;for(;r<t.length;){let n=Qi(t,r),o=dt.getProtocol(n),i=cr(n),s=b0(o,t,r+i),c=0;s>0&&o.size===ee&&(c=cr(s));let a=i+c+s,u={code:n,name:o.name,bytes:Ht(t.subarray(r,r+a))};if(s>0){let p=r+i+c,l=t.subarray(p,p+s);u.value=o.bytesToValue?.(l)??$(l)}e.push(u),r+=a}return e}function du(t){let e=0,r=[];for(let n of t){if(n.bytes==null){let o=dt.getProtocol(n.code),i=cr(n.code),s,c=0,a=0;n.value!=null&&(s=o.valueToBytes?.(n.value)??we(n.value),c=s.byteLength,o.size===ee&&(a=cr(c)));let u=new Uint8Array(i+a+c),p=0;Zi(n.code,u,p),p+=i,s!=null&&(o.size===ee&&(Zi(c,u,p),p+=a),u.set(s,p)),n.bytes=u}r.push(n.bytes),e+=n.bytes.byteLength}return gt(r,e)}function lu(t){if(t.charAt(0)!=="/")throw new ce('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=dt.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 ce(`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 ce(`Component ${o} was missing value`);u.value=a.stringToValue?.(n)??n}e.push(u),n="",o="",r="protocol"}}}if(o!==""&&n!=="")throw new ce("Incomplete multiaddr");return e}function hu(t){return`/${t.flatMap(e=>{if(e.value==null)return e.name;let r=dt.getProtocol(e.code);if(r==null)throw new ce(`Unknown protocol code ${e.code}`);return[e.name,r.valueToString?.(e.value)??e.value]}).join("/")}`}function b0(t,e,r){return t.size==null||t.size===0?0:t.size>0?t.size/8:Qi(e,r)}var w0=Symbol.for("nodejs.util.inspect.custom"),is=Symbol.for("@multiformats/multiaddr");function E0(t){if(t==null&&(t="/"),pu(t))return t.getComponents();if(t instanceof Uint8Array)return uu(t);if(typeof t=="string")return t=t.replace(/\/(\/)+/,"/").replace(/(\/)+$/,""),t===""&&(t="/"),lu(t);if(Array.isArray(t))return t;throw new ce("Must be a string, Uint8Array, Component[], or another Multiaddr")}var Rn=class t{[is]=!0;#e;#t;#r;constructor(e="/",r={}){this.#e=E0(e),r.validate!==!1&&I0(this)}get bytes(){return this.#r==null&&(this.#r=du(this.#e)),this.#r}toString(){return this.#t==null&&(this.#t=hu(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 Fn(`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 Ce(this.bytes,e.bytes)}[w0](){return`Multiaddr(${this.toString()})`}};function I0(t){t.getComponents().forEach(e=>{let r=dt.getProtocol(e.code);e.value!=null&&r.validate?.(e.value)})}function pu(t){return!!t?.[is]}function fu(t){return new Rn(t)}function mu(t,e,r,n){let o=()=>{n?.log.trace("query",e),t.query({questions:[{name:e,type:"PTR"}]})};return o(),setInterval(o,r)}function gu(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=>fu(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:ja(c),multiaddrs:s.map(a=>a.decapsulateCode(421))}}catch(s){n?.log.error("failed to parse mdns response - %e",s)}}function yu(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(S0).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(p=>p.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 S0(t){return!!eu(t)}function xu(t){let e="",r="abcdefghijklmnopqrstuvwxyz0123456789";for(let n=0;n<t;n++)e+=r.charAt(Math.floor(Math.random()*r.length));return e}var kn=class extends Gr{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??xu(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)}[us]=this;[Symbol.toStringTag]="@libp2p/mdns";[hs]=["@libp2p/peer-discovery"];isStarted(){return!!this.mdns}async start(){this.mdns==null&&(this.mdns=(0,bu.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=mu(this.mdns,this.serviceTag,this.interval,{log:this.log}))}_onMdnsQuery(e){this.mdns!=null&&(this.log.trace("received incoming mDNS query"),yu(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=gu(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 A0(t={}){return e=>new kn(e,t)}return Au(B0);})();
3
3
  /*! Bundled license information:
4
4
 
5
5
  @noble/curves/utils.js: