@libp2p/autonat 1.0.8 → 1.0.9-2e464c099

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,21 +1,10 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PAutonat = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PAutonat=(()=>{var Fl=Object.create;var tn=Object.defineProperty;var Hl=Object.getOwnPropertyDescriptor;var Ml=Object.getOwnPropertyNames;var $l=Object.getPrototypeOf,Kl=Object.prototype.hasOwnProperty;var en=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),ut=(r,t)=>{for(var e in t)tn(r,e,{get:t[e],enumerable:!0})},Ri=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ml(t))!Kl.call(r,s)&&s!==e&&tn(r,s,{get:()=>t[s],enumerable:!(n=Hl(t,s))||n.enumerable});return r};var rn=(r,t,e)=>(e=r!=null?Fl($l(r)):{},Ri(t||!r||!r.__esModule?tn(e,"default",{value:r,enumerable:!0}):e,r)),ql=r=>Ri(tn({},"__esModule",{value:!0}),r);var Pa=en(yr=>{"use strict";var Ah="[object ArrayBuffer]",le=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===Ah}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),s=r.toUint8Array(e);if(n.length!==s.byteLength)return!1;for(let o=0;o<n.length;o++)if(n[o]!==s[o])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let i of e)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of e){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return t[t.length-1]instanceof Function?this.toView(s,t[t.length-1]):s.buffer}},Co="string",Bh=/^[0-9a-f]+$/i,Ih=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Sh=/^[a-zA-Z0-9-_]+$/,In=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n.buffer}static toString(t){let e=le.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return decodeURIComponent(escape(n))}},_t=class{static toString(t,e=!1){let n=le.toArrayBuffer(t),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,e);o+=String.fromCharCode(a)}return o}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),s=new DataView(n);for(let o=0;o<t.length;o++)s.setUint16(o*2,t.charCodeAt(o),e);return n}},Sn=class r{static isHex(t){return typeof t===Co&&Bh.test(t)}static isBase64(t){return typeof t===Co&&Ih.test(t)}static isBase64Url(t){return typeof t===Co&&Sh.test(t)}static ToString(t,e="utf8"){let n=le.toUint8Array(t);switch(e.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return _t.toString(n,!0);case"utf16":case"utf16be":return _t.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return _t.fromString(t,!0);case"utf16":case"utf16be":return _t.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=le.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return In.fromString(t);case"utf16":case"utf16be":return _t.fromString(t);case"utf16le":case"usc2":return _t.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return In.toString(t);case"utf16":case"utf16be":return _t.toString(t);case"utf16le":case"usc2":return _t.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);return n.buffer}static ToBinary(t){let e=le.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=le.toUint8Array(t),n="",s=e.length;for(let o=0;o<s;o++){let i=e[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let s=0;s<e.length;s=s+2){let o=e.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(t,e=!1){return _t.toString(t,e)}static FromUtf16String(t,e=!1){return _t.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};Sn.DEFAULT_UTF8_ENCODING="utf8";function kh(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)e[o]=s[o]}return e}function Rh(...r){let t=r.map(s=>s.byteLength).reduce((s,o)=>s+o),e=new Uint8Array(t),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)e[n++]=o}),e.buffer}function Nh(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<r.byteLength;s++)if(e[s]!==n[s])return!1;return!0}yr.BufferSourceConverter=le;yr.Convert=Sn;yr.assign=kh;yr.combine=Rh;yr.isEqual=Nh});var dl=en((w1,hl)=>{"use strict";function fl(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Hd(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return fl(r,e)}catch{e.message=r.message,e.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),fl(new s,e)}}hl.exports=Hd});var wl=en(Qr=>{(function(){var r,t,e,n,s,o,i,a;a=function(c){var l,h,u,m;return l=(c&255<<24)>>>24,h=(c&255<<16)>>>16,u=(c&65280)>>>8,m=c&255,[l,h,u,m].join(".")},i=function(c){var l,h,u,m,f,p;for(l=[],u=m=0;m<=3&&c.length!==0;u=++m){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}p=t(c),f=p[0],h=p[1],c=c.substring(h),l.push(f)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},e=function(c){return c.charCodeAt(0)},n=e("0"),o=e("a"),s=e("A"),t=function(c){var l,h,u,m,f;for(m=0,l=10,h="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,l=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,l=8,h="7")),f=u;u<c.length;){if("0"<=c[u]&&c[u]<=h)m=m*l+(e(c[u])-n)>>>0;else if(l===16)if("a"<=c[u]&&c[u]<="f")m=m*l+(10+e(c[u])-o)>>>0;else if("A"<=c[u]&&c[u]<="F")m=m*l+(10+e(c[u])-s)>>>0;else break;else break;if(m>4294967295)throw new Error("too large");u++}if(u===f)throw new Error("empty octet");return[m,u]},r=function(){function c(l,h){var u,m,f,p;if(typeof l!="string")throw new Error("Missing `net' parameter");if(h||(p=l.split("/",2),l=p[0],h=p[1]),h||(h=32),typeof h=="string"&&h.indexOf(".")>-1){try{this.maskLong=i(h)}catch(d){throw u=d,new Error("Invalid mask: "+h)}for(m=f=32;f>=0;m=--f)if(this.maskLong===4294967295<<32-m>>>0){this.bitmask=m;break}}else if(h||h===0)this.bitmask=parseInt(h,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(l)&this.maskLong)>>>0}catch(d){throw u=d,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+h);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(i(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var h,u,m;for(m=i(this.first),u=i(this.last),h=0;m<=u;)l(a(m),m,h),h++,m++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Qr.ip2long=i,Qr.long2ip=a,Qr.Netmask=r}).call(Qr)});var Al=en((El,Ss)=>{(function(r){"use strict";let t="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},n=new RegExp("^0[0-7]+$","i"),s=new RegExp("^0x[a-f0-9]+$","i"),o="%[0-9a-z]{1,}",i="(?:[0-9a-f]+::?)+",a={zoneIndex:new RegExp(o,"i"),native:new RegExp(`^(::)?(${i})?([0-9a-f]+)?(::)?(${o})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${o})?)$`,"i"),transitional:new RegExp(`^((?:${i})|(?:::)(?:${i})?)${t}\\.${t}\\.${t}\\.${t}(${o})?$`,"i")};function c(f,p){if(f.indexOf("::")!==f.lastIndexOf("::"))return null;let d=0,g=-1,y=(f.match(a.zoneIndex)||[])[0],b,w;for(y&&(y=y.substring(1),f=f.replace(/%.+$/,""));(g=f.indexOf(":",g+1))>=0;)d++;if(f.substr(0,2)==="::"&&d--,f.substr(-2,2)==="::"&&d--,d>p)return null;for(w=p-d,b=":";w--;)b+="0:";return f=f.replace("::",b),f[0]===":"&&(f=f.slice(1)),f[f.length-1]===":"&&(f=f.slice(0,-1)),p=function(){let k=f.split(":"),v=[];for(let B=0;B<k.length;B++)v.push(parseInt(k[B],16));return v}(),{parts:p,zoneId:y}}function l(f,p,d,g){if(f.length!==p.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let y=0,b;for(;g>0;){if(b=d-g,b<0&&(b=0),f[y]>>b!==p[y]>>b)return!1;g-=d,y+=1}return!0}function h(f){if(s.test(f))return parseInt(f,16);if(f[0]==="0"&&!isNaN(parseInt(f[1],10))){if(n.test(f))return parseInt(f,8);throw new Error(`ipaddr: cannot parse ${f} as octal`)}return parseInt(f,10)}function u(f,p){for(;f.length<p;)f=`0${f}`;return f}let m={};m.IPv4=function(){function f(p){if(p.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let d,g;for(d=0;d<p.length;d++)if(g=p[d],!(0<=g&&g<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=p}return f.prototype.SpecialRanges={unspecified:[[new f([0,0,0,0]),8]],broadcast:[[new f([255,255,255,255]),32]],multicast:[[new f([224,0,0,0]),4]],linkLocal:[[new f([169,254,0,0]),16]],loopback:[[new f([127,0,0,0]),8]],carrierGradeNat:[[new f([100,64,0,0]),10]],private:[[new f([10,0,0,0]),8],[new f([172,16,0,0]),12],[new f([192,168,0,0]),16]],reserved:[[new f([192,0,0,0]),24],[new f([192,0,2,0]),24],[new f([192,88,99,0]),24],[new f([198,18,0,0]),15],[new f([198,51,100,0]),24],[new f([203,0,113,0]),24],[new f([240,0,0,0]),4]]},f.prototype.kind=function(){return"ipv4"},f.prototype.match=function(p,d){let g;if(d===void 0&&(g=p,p=g[0],d=g[1]),p.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return l(this.octets,p.octets,8,d)},f.prototype.prefixLengthFromSubnetMask=function(){let p=0,d=!1,g={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},y,b,w;for(y=3;y>=0;y-=1)if(b=this.octets[y],b in g){if(w=g[b],d&&w!==0)return null;w!==8&&(d=!0),p+=w}else return null;return 32-p},f.prototype.range=function(){return m.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){return this.octets.slice(0)},f.prototype.toIPv4MappedAddress=function(){return m.IPv6.parse(`::ffff:${this.toString()}`)},f.prototype.toNormalizedString=function(){return this.toString()},f.prototype.toString=function(){return this.octets.join(".")},f}(),m.IPv4.broadcastAddressFromCIDR=function(f){try{let p=this.parseCIDR(f),d=p[0].toByteArray(),g=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],b=0;for(;b<4;)y.push(parseInt(d[b],10)|parseInt(g[b],10)^255),b++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},m.IPv4.isIPv4=function(f){return this.parser(f)!==null},m.IPv4.isValid=function(f){try{return new this(this.parser(f)),!0}catch{return!1}},m.IPv4.isValidFourPartDecimal=function(f){return!!(m.IPv4.isValid(f)&&f.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},m.IPv4.networkAddressFromCIDR=function(f){let p,d,g,y,b;try{for(p=this.parseCIDR(f),g=p[0].toByteArray(),b=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],d=0;d<4;)y.push(parseInt(g[d],10)&parseInt(b[d],10)),d++;return new this(y)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},m.IPv4.parse=function(f){let p=this.parser(f);if(p===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(p)},m.IPv4.parseCIDR=function(f){let p;if(p=f.match(/^(.+)\/(\d+)$/)){let d=parseInt(p[2]);if(d>=0&&d<=32){let g=[this.parse(p[1]),d];return Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},m.IPv4.parser=function(f){let p,d,g;if(p=f.match(e.fourOctet))return function(){let y=p.slice(1,6),b=[];for(let w=0;w<y.length;w++)d=y[w],b.push(h(d));return b}();if(p=f.match(e.longValue)){if(g=h(p[1]),g>4294967295||g<0)throw new Error("ipaddr: address outside defined range");return function(){let y=[],b;for(b=0;b<=24;b+=8)y.push(g>>b&255);return y}().reverse()}else return(p=f.match(e.twoOctet))?function(){let y=p.slice(1,4),b=[];if(g=h(y[1]),g>16777215||g<0)throw new Error("ipaddr: address outside defined range");return b.push(h(y[0])),b.push(g>>16&255),b.push(g>>8&255),b.push(g&255),b}():(p=f.match(e.threeOctet))?function(){let y=p.slice(1,5),b=[];if(g=h(y[2]),g>65535||g<0)throw new Error("ipaddr: address outside defined range");return b.push(h(y[0])),b.push(h(y[1])),b.push(g>>8&255),b.push(g&255),b}():null},m.IPv4.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>32)throw new Error("ipaddr: invalid IPv4 prefix length");let p=[0,0,0,0],d=0,g=Math.floor(f/8);for(;d<g;)p[d]=255,d++;return g<4&&(p[g]=Math.pow(2,f%8)-1<<8-f%8),new this(p)},m.IPv6=function(){function f(p,d){let g,y;if(p.length===16)for(this.parts=[],g=0;g<=14;g+=2)this.parts.push(p[g]<<8|p[g+1]);else if(p.length===8)this.parts=p;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(g=0;g<this.parts.length;g++)if(y=this.parts[g],!(0<=y&&y<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");d&&(this.zoneId=d)}return f.prototype.SpecialRanges={unspecified:[new f([0,0,0,0,0,0,0,0]),128],linkLocal:[new f([65152,0,0,0,0,0,0,0]),10],multicast:[new f([65280,0,0,0,0,0,0,0]),8],loopback:[new f([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new f([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new f([0,0,0,0,0,65535,0,0]),96],rfc6145:[new f([0,0,0,0,65535,0,0,0]),96],rfc6052:[new f([100,65435,0,0,0,0,0,0]),96],"6to4":[new f([8194,0,0,0,0,0,0,0]),16],teredo:[new f([8193,0,0,0,0,0,0,0]),32],reserved:[[new f([8193,3512,0,0,0,0,0,0]),32]],benchmarking:[new f([8193,2,0,0,0,0,0,0]),48],amt:[new f([8193,3,0,0,0,0,0,0]),32],as112v6:[new f([8193,4,274,0,0,0,0,0]),48],deprecated:[new f([8193,16,0,0,0,0,0,0]),28],orchid2:[new f([8193,32,0,0,0,0,0,0]),28]},f.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},f.prototype.kind=function(){return"ipv6"},f.prototype.match=function(p,d){let g;if(d===void 0&&(g=p,p=g[0],d=g[1]),p.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return l(this.parts,p.parts,16,d)},f.prototype.prefixLengthFromSubnetMask=function(){let p=0,d=!1,g={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},y,b;for(let w=7;w>=0;w-=1)if(y=this.parts[w],y in g){if(b=g[y],d&&b!==0)return null;b!==16&&(d=!0),p+=b}else return null;return 128-p},f.prototype.range=function(){return m.subnetMatch(this,this.SpecialRanges)},f.prototype.toByteArray=function(){let p,d=[],g=this.parts;for(let y=0;y<g.length;y++)p=g[y],d.push(p>>8),d.push(p&255);return d},f.prototype.toFixedLengthString=function(){let p=function(){let g=[];for(let y=0;y<this.parts.length;y++)g.push(u(this.parts[y].toString(16),4));return g}.call(this).join(":"),d="";return this.zoneId&&(d=`%${this.zoneId}`),p+d},f.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let p=this.parts.slice(-2),d=p[0],g=p[1];return new m.IPv4([d>>8,d&255,g>>8,g&255])},f.prototype.toNormalizedString=function(){let p=function(){let g=[];for(let y=0;y<this.parts.length;y++)g.push(this.parts[y].toString(16));return g}.call(this).join(":"),d="";return this.zoneId&&(d=`%${this.zoneId}`),p+d},f.prototype.toRFC5952String=function(){let p=/((^|:)(0(:|$)){2,})/g,d=this.toNormalizedString(),g=0,y=-1,b;for(;b=p.exec(d);)b[0].length>y&&(g=b.index,y=b[0].length);return y<0?d:`${d.substring(0,g)}::${d.substring(g+y)}`},f.prototype.toString=function(){return this.toRFC5952String()},f}(),m.IPv6.broadcastAddressFromCIDR=function(f){try{let p=this.parseCIDR(f),d=p[0].toByteArray(),g=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],b=0;for(;b<16;)y.push(parseInt(d[b],10)|parseInt(g[b],10)^255),b++;return new this(y)}catch(p){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${p})`)}},m.IPv6.isIPv6=function(f){return this.parser(f)!==null},m.IPv6.isValid=function(f){if(typeof f=="string"&&f.indexOf(":")===-1)return!1;try{let p=this.parser(f);return new this(p.parts,p.zoneId),!0}catch{return!1}},m.IPv6.networkAddressFromCIDR=function(f){let p,d,g,y,b;try{for(p=this.parseCIDR(f),g=p[0].toByteArray(),b=this.subnetMaskFromPrefixLength(p[1]).toByteArray(),y=[],d=0;d<16;)y.push(parseInt(g[d],10)&parseInt(b[d],10)),d++;return new this(y)}catch(w){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${w})`)}},m.IPv6.parse=function(f){let p=this.parser(f);if(p.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(p.parts,p.zoneId)},m.IPv6.parseCIDR=function(f){let p,d,g;if((d=f.match(/^(.+)\/(\d+)$/))&&(p=parseInt(d[2]),p>=0&&p<=128))return g=[this.parse(d[1]),p],Object.defineProperty(g,"toString",{value:function(){return this.join("/")}}),g;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},m.IPv6.parser=function(f){let p,d,g,y,b,w;if(g=f.match(a.deprecatedTransitional))return this.parser(`::ffff:${g[1]}`);if(a.native.test(f))return c(f,8);if((g=f.match(a.transitional))&&(w=g[6]||"",p=c(g[1].slice(0,-1)+w,6),p.parts)){for(b=[parseInt(g[2]),parseInt(g[3]),parseInt(g[4]),parseInt(g[5])],d=0;d<b.length;d++)if(y=b[d],!(0<=y&&y<=255))return null;return p.parts.push(b[0]<<8|b[1]),p.parts.push(b[2]<<8|b[3]),{parts:p.parts,zoneId:p.zoneId}}return null},m.IPv6.subnetMaskFromPrefixLength=function(f){if(f=parseInt(f),f<0||f>128)throw new Error("ipaddr: invalid IPv6 prefix length");let p=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],d=0,g=Math.floor(f/8);for(;d<g;)p[d]=255,d++;return g<16&&(p[g]=Math.pow(2,f%8)-1<<8-f%8),new this(p)},m.fromByteArray=function(f){let p=f.length;if(p===4)return new m.IPv4(f);if(p===16)return new m.IPv6(f);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},m.isValid=function(f){return m.IPv6.isValid(f)||m.IPv4.isValid(f)},m.parse=function(f){if(m.IPv6.isValid(f))return m.IPv6.parse(f);if(m.IPv4.isValid(f))return m.IPv4.parse(f);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},m.parseCIDR=function(f){try{return m.IPv6.parseCIDR(f)}catch{try{return m.IPv4.parseCIDR(f)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},m.process=function(f){let p=this.parse(f);return p.kind()==="ipv6"&&p.isIPv4MappedAddress()?p.toIPv4Address():p},m.subnetMatch=function(f,p,d){let g,y,b,w;d==null&&(d="unicast");for(y in p)if(Object.prototype.hasOwnProperty.call(p,y)){for(b=p[y],b[0]&&!(b[0]instanceof Array)&&(b=[b]),g=0;g<b.length;g++)if(w=b[g],f.kind()===w[0].kind()&&f.match.apply(f,w))return y}return d},typeof Ss<"u"&&Ss.exports?Ss.exports=m:r.ipaddr=m})(El)});var h0={};ut(h0,{autoNAT:()=>f0});var p0=Symbol.for("@libp2p/connection");var m0=Symbol.for("@libp2p/content-routing");var w0=Symbol.for("@libp2p/peer-discovery");var Ni=Symbol.for("@libp2p/peer-id");var E0=Symbol.for("@libp2p/peer-routing");var Ti;(function(r){r.Accept="accept",r.Ignore="ignore",r.Reject="reject"})(Ti||(Ti={}));var S0=Symbol.for("@libp2p/transport");var Li;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(Li||(Li={}));var _=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var Ns="ERR_TIMEOUT";var Ts=class extends Event{detail;constructor(t,e){super(t,e),this.detail=e?.detail}},N0=globalThis.CustomEvent??Ts;var Ls=(r,...t)=>{try{[...t]}catch{}};var Ds={};ut(Ds,{base58btc:()=>ct,base58flickr:()=>Zl});var op=new Uint8Array(0);function _i(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function Xt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Ci(r){return new TextEncoder().encode(r)}function Ui(r){return new TextDecoder().decode(r)}function zl(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(e[i]!==255)throw new TypeError(o+" is ambiguous");e[i]=s}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(p){if(p instanceof Uint8Array||(ArrayBuffer.isView(p)?p=new Uint8Array(p.buffer,p.byteOffset,p.byteLength):Array.isArray(p)&&(p=Uint8Array.from(p))),!(p instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(p.length===0)return"";for(var d=0,g=0,y=0,b=p.length;y!==b&&p[y]===0;)y++,d++;for(var w=(b-y)*h+1>>>0,k=new Uint8Array(w);y!==b;){for(var v=p[y],B=0,N=w-1;(v!==0||B<g)&&N!==-1;N--,B++)v+=256*k[N]>>>0,k[N]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");g=B,y++}for(var T=w-g;T!==w&&k[T]===0;)T++;for(var z=c.repeat(d);T<w;++T)z+=r.charAt(k[T]);return z}function m(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var d=0;if(p[d]!==" "){for(var g=0,y=0;p[d]===c;)g++,d++;for(var b=(p.length-d)*l+1>>>0,w=new Uint8Array(b);p[d];){var k=e[p.charCodeAt(d)];if(k===255)return;for(var v=0,B=b-1;(k!==0||v<y)&&B!==-1;B--,v++)k+=a*w[B]>>>0,w[B]=k%256>>>0,k=k/256>>>0;if(k!==0)throw new Error("Non-zero carry");y=v,d++}if(p[d]!==" "){for(var N=b-y;N!==b&&w[N]===0;)N++;for(var T=new Uint8Array(g+(b-N)),z=g;N!==b;)T[z++]=w[N++];return T}}}function f(p){var d=m(p);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:m,decode:f}}var jl=zl,Gl=jl,Di=Gl;var _s=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Cs=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Oi(this,t)}},Us=class{decoders;constructor(t){this.decoders=t}or(t){return Oi(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Oi(r,t){return new Us({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ps=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new _s(t,e,n),this.decoder=new Cs(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function Ze({name:r,prefix:t,encode:e,decode:n}){return new Ps(r,t,e,n)}function be({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=Di(e,r);return Ze({prefix:t,name:r,encode:n,decode:o=>Xt(s(o))})}function Wl(r,t,e,n){let s={};for(let h=0;h<t.length;++h)s[t[h]]=h;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*e/8|0),a=0,c=0,l=0;for(let h=0;h<o;++h){let u=s[r[h]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,a+=e,a>=8&&(a-=8,i[l++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Yl(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,o+=t[s&a>>i];if(i!==0&&(o+=t[s&a<<e-i]),n)for(;o.length*e&7;)o+="=";return o}function tt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return Ze({prefix:t,name:r,encode(s){return Yl(s,n,e)},decode(s){return Wl(s,n,e,r)}})}var ct=be({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Zl=be({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Os={};ut(Os,{base10:()=>Jl});var Jl=be({prefix:"9",name:"base10",alphabet:"0123456789"});var Vs={};ut(Vs,{base16:()=>Xl,base16upper:()=>Ql});var Xl=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ql=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Fs={};ut(Fs,{base2:()=>tu});var tu=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Hs={};ut(Hs,{base256emoji:()=>ou});var Vi=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}"),eu=Vi.reduce((r,t,e)=>(r[e]=t,r),[]),ru=Vi.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function nu(r){return r.reduce((t,e)=>(t+=eu[e],t),"")}function su(r){let t=[];for(let e of r){let n=ru[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var ou=Ze({prefix:"\u{1F680}",name:"base256emoji",encode:nu,decode:su});var Ms={};ut(Ms,{base32:()=>Qt,base32hex:()=>lu,base32hexpad:()=>fu,base32hexpadupper:()=>hu,base32hexupper:()=>uu,base32pad:()=>au,base32padupper:()=>cu,base32upper:()=>iu,base32z:()=>du});var Qt=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),iu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),au=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),cu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),lu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),uu=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),fu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),hu=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),du=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $s={};ut($s,{base36:()=>pu,base36upper:()=>gu});var pu=be({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gu=be({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ks={};ut(Ks,{base64:()=>nn,base64pad:()=>mu,base64url:()=>yu,base64urlpad:()=>bu});var nn=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),mu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),yu=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),bu=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var qs={};ut(qs,{base8:()=>wu});var wu=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var zs={};ut(zs,{identity:()=>xu});var xu=Ze({prefix:"\0",name:"identity",encode:r=>Ui(r),decode:r=>Ci(r)});var vp=new TextEncoder,Ep=new TextDecoder;var Gs={};ut(Gs,{identity:()=>we});var Au=Mi,Fi=128,Bu=127,Iu=~Bu,Su=Math.pow(2,31);function Mi(r,t,e){t=t||[],e=e||0;for(var n=e;r>=Su;)t[e++]=r&255|Fi,r/=128;for(;r&Iu;)t[e++]=r&255|Fi,r>>>=7;return t[e]=r|0,Mi.bytes=e-n+1,t}var ku=js,Ru=128,Hi=127;function js(r,n){var e=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw js.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&Hi)<<s:(i&Hi)*Math.pow(2,s),s+=7}while(i>=Ru);return js.bytes=o-n,e}var Nu=Math.pow(2,7),Tu=Math.pow(2,14),Lu=Math.pow(2,21),_u=Math.pow(2,28),Cu=Math.pow(2,35),Uu=Math.pow(2,42),Pu=Math.pow(2,49),Du=Math.pow(2,56),Ou=Math.pow(2,63),Vu=function(r){return r<Nu?1:r<Tu?2:r<Lu?3:r<_u?4:r<Cu?5:r<Uu?6:r<Pu?7:r<Du?8:r<Ou?9:10},Fu={encode:Au,decode:ku,encodingLength:Vu},Hu=Fu,Cr=Hu;function Ur(r,t=0){return[Cr.decode(r,t),Cr.decode.bytes]}function Je(r,t,e=0){return Cr.encode(r,t,e),t}function Xe(r){return Cr.encodingLength(r)}function jt(r,t){let e=t.byteLength,n=Xe(r),s=n+Xe(e),o=new Uint8Array(s+e);return Je(r,o,0),Je(e,o,n),o.set(t,s),new Qe(r,e,t,o)}function Ve(r){let t=Xt(r),[e,n]=Ur(t),[s,o]=Ur(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new Qe(e,s,i,t)}function $i(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&_i(r.bytes,e.bytes)}}var Qe=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var Ki=0,Mu="identity",qi=Xt;function $u(r){return jt(Ki,qi(r))}var we={code:Ki,name:Mu,encode:qi,digest:$u};var Zs={};ut(Zs,{sha256:()=>gt,sha512:()=>Ku});function Ys({name:r,code:t,encode:e}){return new Ws(r,t,e)}var Ws=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?jt(this.code,e):e.then(n=>jt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function ji(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var gt=Ys({name:"sha2-256",code:18,encode:ji("SHA-256")}),Ku=Ys({name:"sha2-512",code:19,encode:ji("SHA-512")});function Gi(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return zu(e,Js(r),t??ct.encoder);default:return ju(e,Js(r),t??Qt.encoder)}}var Wi=new WeakMap;function Js(r){let t=Wi.get(r);if(t==null){let e=new Map;return Wi.set(r,e),e}return t}var Ut=class r{code;version;multihash;bytes;"/";constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}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:t,multihash:e}=this;if(t!==Pr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Gu)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:t,digest:e}=this.multihash,n=jt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&$i(t.multihash,n.multihash)}toString(t){return Gi(this,t)}toJSON(){return{"/":Gi(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:o,bytes:i}=e;return new r(n,s,o,i??Yi(n,s,o.bytes))}else if(e[Wu]===!0){let{version:n,multihash:s,code:o}=e,i=Ve(s);return r.create(n,o,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==Pr)throw new Error(`Version 0 CID must use dag-pb (code: ${Pr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=Yi(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Pr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,s=Xt(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=s.subarray(e.multihashSize-e.digestSize),i=new Qe(e.multihashCode,e.digestSize,o,s);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,m]=Ur(t.subarray(e));return e+=m,u},s=n(),o=Pr;if(s===18?(s=0,e=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=e,a=n(),c=n(),l=e+c,h=l-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:h,size:l}}static parse(t,e){let[n,s]=qu(t,e),o=r.decode(s);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Js(o).set(n,t),o}};function qu(r,t){switch(r[0]){case"Q":{let e=t??ct;return[ct.prefix,e.decode(`${ct.prefix}${r}`)]}case ct.prefix:{let e=t??ct;return[ct.prefix,e.decode(r)]}case Qt.prefix:{let e=t??Qt;return[Qt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function zu(r,t,e){let{prefix:n}=e;if(n!==ct.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return s}function ju(r,t,e){let{prefix:n}=e,s=t.get(n);if(s==null){let o=e.encode(r);return t.set(n,o),o}else return s}var Pr=112,Gu=18;function Yi(r,t,e){let n=Xe(r),s=n+Xe(t),o=new Uint8Array(s+e.byteLength);return Je(r,o,0),Je(t,o,n),o.set(e,s),o}var Wu=Symbol.for("@ipld/js-cid/CID");var xe={...zs,...Fs,...qs,...Os,...Vs,...Ms,...$s,...Ds,...Ks,...Hs},Kp={...Zs,...Gs};function mt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Yu=Symbol.for("nodejs.util.inspect.custom"),Zi=Object.values(xe).map(r=>r.decoder).reduce((r,t)=>r.or(t),xe.identity.decoder),Ji=114,Xs=36,Qs=37,Dr=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ni]=!0;toString(){return this.string==null&&(this.string=ct.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Ut.createV1(Ji,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return mt(this.multihash.bytes,t);if(typeof t=="string")return Zu(t).equals(this);if(t?.multihash?.bytes!=null)return mt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Yu](){return`PeerId(${this.toString()})`}},tr=class extends Dr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},er=class extends Dr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},rr=class extends Dr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Zu(r,t){if(t=t??Zi,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Ve(ct.decode(`z${r}`));return r.startsWith("12D")?new er({multihash:e}):r.startsWith("16U")?new rr({multihash:e}):new tr({multihash:e})}return on(Zi.decode(r))}function on(r){try{let t=Ve(r);if(t.code===we.code){if(t.digest.length===Xs)return new er({multihash:t});if(t.digest.length===Qs)return new rr({multihash:t})}if(t.code===gt.code)return new tr({multihash:t})}catch{return Ju(Ut.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Ju(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Ji)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===gt.code)return new tr({multihash:r.multihash});if(t.code===we.code){if(t.digest.length===Xs)return new er({multihash:r.multihash});if(t.digest.length===Qs)return new rr({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Xi(r,t){return r.length===Xs?new er({multihash:jt(we.code,r),privateKey:t}):r.length===Qs?new rr({multihash:jt(we.code,r),privateKey:t}):new tr({multihash:await gt.digest(r),publicKey:r,privateKey:t})}var Lo={};ut(Lo,{Ed25519PrivateKey:()=>Re,Ed25519PublicKey:()=>gr,generateKeyPair:()=>yh,generateKeyPairFromSeed:()=>Ua,unmarshalEd25519PrivateKey:()=>gh,unmarshalEd25519PublicKey:()=>mh});function ve(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function te(r=0){return globalThis.Buffer?.alloc!=null?ve(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function vt(r=0){return globalThis.Buffer?.allocUnsafe!=null?ve(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function yt(r,t){if(globalThis.Buffer!=null)return ve(globalThis.Buffer.concat(r,t));t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=vt(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return ve(e)}function ta(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Qi=ta("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),to=ta("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=vt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Xu={utf8:Qi,"utf-8":Qi,hex:xe.base16,latin1:to,ascii:to,binary:to,...xe},an=Xu;function Z(r,t="utf8"){let e=an[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ve(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Lt(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function nr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Qu(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function eo(r,...t){if(!Qu(r))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function cn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");nr(r.outputLen),nr(r.blockLen)}function sr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function ea(r,t){eo(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var ln=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ra(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ir=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Pt=(r,t)=>r<<32-t|r>>>t,tf=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!tf)throw new Error("Non little-endian hardware is not supported");var ef=async()=>{};async function na(r,t,e){let n=Date.now();for(let s=0;s<r;s++){e(s);let o=Date.now()-n;o>=0&&o<t||(await ef(),n+=o)}}function ro(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ee(r){if(typeof r=="string"&&(r=ro(r)),!ra(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function un(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];if(!ra(s))throw new Error("Uint8Array expected");t+=s.length}let e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){let o=r[n];e.set(o,s),s+=o.length}return e}var or=class{clone(){return this._cloneInto()}},rf={}.toString;function sa(r,t){if(t!==void 0&&rf.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,t)}function fn(r){let t=n=>r().update(Ee(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ar(r=32){if(ln&&typeof ln.getRandomValues=="function")return ln.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function nf(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(e>>s&o),a=Number(e&o),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}var cr=class extends or{constructor(t,e,n,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ir(this.buffer)}update(t){sr(this);let{view:e,buffer:n,blockLen:s}=this;t=Ee(t);let o=t.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=ir(t);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){sr(this),ea(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let u=i;u<s;u++)e[u]=0;nf(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=ir(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,h=this.get();if(l>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,h[u],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var hn=BigInt(4294967295),no=BigInt(32);function oa(r,t=!1){return t?{h:Number(r&hn),l:Number(r>>no&hn)}:{h:Number(r>>no&hn)|0,l:Number(r&hn)|0}}function sf(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=oa(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var of=(r,t)=>BigInt(r>>>0)<<no|BigInt(t>>>0),af=(r,t,e)=>r>>>e,cf=(r,t,e)=>r<<32-e|t>>>e,lf=(r,t,e)=>r>>>e|t<<32-e,uf=(r,t,e)=>r<<32-e|t>>>e,ff=(r,t,e)=>r<<64-e|t>>>e-32,hf=(r,t,e)=>r>>>e-32|t<<64-e,df=(r,t)=>t,pf=(r,t)=>r,gf=(r,t,e)=>r<<e|t>>>32-e,mf=(r,t,e)=>t<<e|r>>>32-e,yf=(r,t,e)=>t<<e-32|r>>>64-e,bf=(r,t,e)=>r<<e-32|t>>>64-e;function wf(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var xf=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),vf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Ef=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Af=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,Bf=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),If=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var Sf={fromBig:oa,split:sf,toBig:of,shrSH:af,shrSL:cf,rotrSH:lf,rotrSL:uf,rotrBH:ff,rotrBL:hf,rotr32H:df,rotr32L:pf,rotlSH:gf,rotlSL:mf,rotlBH:yf,rotlBL:bf,add:wf,add3L:xf,add3H:vf,add4L:Ef,add4H:Af,add5H:If,add5L:Bf},U=Sf;var[kf,Rf]=U.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),Ae=new Uint32Array(80),Be=new Uint32Array(80),so=class extends cr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:l,El:h,Fh:u,Fl:m,Gh:f,Gl:p,Hh:d,Hl:g}=this;return[t,e,n,s,o,i,a,c,l,h,u,m,f,p,d,g]}set(t,e,n,s,o,i,a,c,l,h,u,m,f,p,d,g){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=h|0,this.Fh=u|0,this.Fl=m|0,this.Gh=f|0,this.Gl=p|0,this.Hh=d|0,this.Hl=g|0}process(t,e){for(let w=0;w<16;w++,e+=4)Ae[w]=t.getUint32(e),Be[w]=t.getUint32(e+=4);for(let w=16;w<80;w++){let k=Ae[w-15]|0,v=Be[w-15]|0,B=U.rotrSH(k,v,1)^U.rotrSH(k,v,8)^U.shrSH(k,v,7),N=U.rotrSL(k,v,1)^U.rotrSL(k,v,8)^U.shrSL(k,v,7),T=Ae[w-2]|0,z=Be[w-2]|0,$=U.rotrSH(T,z,19)^U.rotrBH(T,z,61)^U.shrSH(T,z,6),D=U.rotrSL(T,z,19)^U.rotrBL(T,z,61)^U.shrSL(T,z,6),nt=U.add4L(N,D,Be[w-7],Be[w-16]),rt=U.add4H(nt,B,$,Ae[w-7],Ae[w-16]);Ae[w]=rt|0,Be[w]=nt|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:l,Dl:h,Eh:u,El:m,Fh:f,Fl:p,Gh:d,Gl:g,Hh:y,Hl:b}=this;for(let w=0;w<80;w++){let k=U.rotrSH(u,m,14)^U.rotrSH(u,m,18)^U.rotrBH(u,m,41),v=U.rotrSL(u,m,14)^U.rotrSL(u,m,18)^U.rotrBL(u,m,41),B=u&f^~u&d,N=m&p^~m&g,T=U.add5L(b,v,N,Rf[w],Be[w]),z=U.add5H(T,y,k,B,kf[w],Ae[w]),$=T|0,D=U.rotrSH(n,s,28)^U.rotrBH(n,s,34)^U.rotrBH(n,s,39),nt=U.rotrSL(n,s,28)^U.rotrBL(n,s,34)^U.rotrBL(n,s,39),rt=n&o^n&a^o&a,Tt=s&i^s&c^i&c;y=d|0,b=g|0,d=f|0,g=p|0,f=u|0,p=m|0,{h:u,l:m}=U.add(l|0,h|0,z|0,$|0),l=a|0,h=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let E=U.add3L($,nt,Tt);n=U.add3H(E,z,D,rt),s=E|0}({h:n,l:s}=U.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=U.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=U.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:h}=U.add(this.Dh|0,this.Dl|0,l|0,h|0),{h:u,l:m}=U.add(this.Eh|0,this.El|0,u|0,m|0),{h:f,l:p}=U.add(this.Fh|0,this.Fl|0,f|0,p|0),{h:d,l:g}=U.add(this.Gh|0,this.Gl|0,d|0,g|0),{h:y,l:b}=U.add(this.Hh|0,this.Hl|0,y|0,b|0),this.set(n,s,o,i,a,c,l,h,u,m,f,p,d,g,y,b)}roundClean(){Ae.fill(0),Be.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var lr=fn(()=>new so);var pn={};ut(pn,{bitGet:()=>Pf,bitLen:()=>Uf,bitMask:()=>Or,bitSet:()=>Df,bytesToHex:()=>re,bytesToNumberBE:()=>ne,bytesToNumberLE:()=>Ie,concatBytes:()=>se,createHmacDrbg:()=>ao,ensureBytes:()=>et,equalBytes:()=>_f,hexToBytes:()=>He,hexToNumber:()=>io,isBytes:()=>Dt,numberToBytesBE:()=>Se,numberToBytesLE:()=>Me,numberToHexUnpadded:()=>la,numberToVarBytesBE:()=>Lf,utf8ToBytes:()=>Cf,validateObject:()=>Gt});var ca=BigInt(0),dn=BigInt(1),Nf=BigInt(2);function Dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Tf=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function re(r){if(!Dt(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Tf[r[e]];return t}function la(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function io(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var ee={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ia(r){if(r>=ee._0&&r<=ee._9)return r-ee._0;if(r>=ee._A&&r<=ee._F)return r-(ee._A-10);if(r>=ee._a&&r<=ee._f)return r-(ee._a-10)}function He(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let s=0,o=0;s<e;s++,o+=2){let i=ia(r.charCodeAt(o)),a=ia(r.charCodeAt(o+1));if(i===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[s]=i*16+a}return n}function ne(r){return io(re(r))}function Ie(r){if(!Dt(r))throw new Error("Uint8Array expected");return io(re(Uint8Array.from(r).reverse()))}function Se(r,t){return He(r.toString(16).padStart(t*2,"0"))}function Me(r,t){return Se(r,t).reverse()}function Lf(r){return He(la(r))}function et(r,t,e){let n;if(typeof t=="string")try{n=He(t)}catch(o){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${o}`)}else if(Dt(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof e=="number"&&s!==e)throw new Error(`${r} expected ${e} bytes, got ${s}`);return n}function se(...r){let t=0;for(let s=0;s<r.length;s++){let o=r[s];if(!Dt(o))throw new Error("Uint8Array expected");t+=o.length}let e=new Uint8Array(t),n=0;for(let s=0;s<r.length;s++){let o=r[s];e.set(o,n),n+=o.length}return e}function _f(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function Cf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Uf(r){let t;for(t=0;r>ca;r>>=dn,t+=1);return t}function Pf(r,t){return r>>BigInt(t)&dn}var Df=(r,t,e)=>r|(e?dn:ca)<<BigInt(t),Or=r=>(Nf<<BigInt(r-1))-dn,oo=r=>new Uint8Array(r),aa=r=>Uint8Array.from(r);function ao(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=oo(r),s=oo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...u)=>e(s,n,...u),c=(u=oo())=>{s=a(aa([0]),u),n=a(),u.length!==0&&(s=a(aa([1]),u),n=a())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,m=[];for(;u<t;){n=a();let f=n.slice();m.push(f),u+=n.length}return se(...m)};return(u,m)=>{i(),c(u);let f;for(;!(f=m(l()));)c();return i(),f}}var Of={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Dt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Gt(r,t,e={}){let n=(s,o,i)=>{let a=Of[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=r[s];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(let[s,o]of Object.entries(t))n(s,o,!1);for(let[s,o]of Object.entries(e))n(s,o,!0);return r}var lt=BigInt(0),J=BigInt(1),$e=BigInt(2),Vf=BigInt(3),co=BigInt(4),ua=BigInt(5),fa=BigInt(8),Ff=BigInt(9),Hf=BigInt(16);function Y(r,t){let e=r%t;return e>=lt?e:t+e}function Mf(r,t,e){if(e<=lt||t<lt)throw new Error("Expected power/modulo > 0");if(e===J)return lt;let n=J;for(;t>lt;)t&J&&(n=n*r%e),r=r*r%e,t>>=J;return n}function X(r,t,e){let n=r;for(;t-- >lt;)n*=n,n%=e;return n}function gn(r,t){if(r===lt||t<=lt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Y(r,t),n=t,s=lt,o=J,i=J,a=lt;for(;e!==lt;){let l=n/e,h=n%e,u=s-i*l,m=o-a*l;n=e,e=h,s=i,o=a,i=u,a=m}if(n!==J)throw new Error("invert: does not exist");return Y(s,t)}function $f(r){let t=(r-J)/$e,e,n,s;for(e=r-J,n=0;e%$e===lt;e/=$e,n++);for(s=$e;s<r&&Mf(s,t,r)!==r-J;s++);if(n===1){let i=(r+J)/co;return function(c,l){let h=c.pow(l,i);if(!c.eql(c.sqr(h),l))throw new Error("Cannot find square root");return h}}let o=(e+J)/$e;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,h=a.pow(a.mul(a.ONE,s),e),u=a.pow(c,o),m=a.pow(c,e);for(;!a.eql(m,a.ONE);){if(a.eql(m,a.ZERO))return a.ZERO;let f=1;for(let d=a.sqr(m);f<l&&!a.eql(d,a.ONE);f++)d=a.sqr(d);let p=a.pow(h,J<<BigInt(l-f-1));h=a.sqr(p),u=a.mul(u,p),m=a.mul(m,h),l=f}return u}}function Kf(r){if(r%co===Vf){let t=(r+J)/co;return function(n,s){let o=n.pow(s,t);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%fa===ua){let t=(r-ua)/fa;return function(n,s){let o=n.mul(s,$e),i=n.pow(o,t),a=n.mul(s,i),c=n.mul(n.mul(a,$e),i),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%Hf,$f(r)}var ha=(r,t)=>(Y(r,t)&J)===J,qf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function lo(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=qf.reduce((n,s)=>(n[s]="function",n),t);return Gt(r,e)}function zf(r,t,e){if(e<lt)throw new Error("Expected power > 0");if(e===lt)return r.ONE;if(e===J)return t;let n=r.ONE,s=t;for(;e>lt;)e&J&&(n=r.mul(n,s)),s=r.sqr(s),e>>=J;return n}function jf(r,t){let e=new Array(t.length),n=t.reduce((o,i,a)=>r.is0(i)?o:(e[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return t.reduceRight((o,i,a)=>r.is0(i)?o:(e[a]=r.mul(o,e[a]),r.mul(o,i)),s),e}function uo(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function mn(r,t,e=!1,n={}){if(r<=lt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=uo(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Kf(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Or(s),ZERO:lt,ONE:J,create:c=>Y(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return lt<=c&&c<r},is0:c=>c===lt,isOdd:c=>(c&J)===J,neg:c=>Y(-c,r),eql:(c,l)=>c===l,sqr:c=>Y(c*c,r),add:(c,l)=>Y(c+l,r),sub:(c,l)=>Y(c-l,r),mul:(c,l)=>Y(c*l,r),pow:(c,l)=>zf(a,c,l),div:(c,l)=>Y(c*gn(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>gn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>jf(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>e?Me(c,o):Se(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return e?Ie(c):ne(c)}});return Object.freeze(a)}function da(r,t){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let e=r.sqrt(t);return r.isOdd(e)?r.neg(e):e}function pa(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function fo(r){let t=pa(r);return t+Math.ceil(t/2)}function ga(r,t,e=!1){let n=r.length,s=pa(t),o=fo(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=e?ne(r):Ie(r),a=Y(i,t-J)+J;return e?Me(a,s):Se(a,s)}var Wf=BigInt(0),ho=BigInt(1);function yn(r,t){let e=(s,o)=>{let i=o.negate();return s?i:o},n=s=>{let o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:e,unsafeLadder(s,o){let i=r.ZERO,a=s;for(;o>Wf;)o&ho&&(i=i.add(a)),a=a.double(),o>>=ho;return i},precomputeWindow(s,o){let{windows:i,windowSize:a}=n(o),c=[],l=s,h=l;for(let u=0;u<i;u++){h=l,c.push(h);for(let m=1;m<a;m++)h=h.add(l),c.push(h);l=h.double()}return c},wNAF(s,o,i){let{windows:a,windowSize:c}=n(s),l=r.ZERO,h=r.BASE,u=BigInt(2**s-1),m=2**s,f=BigInt(s);for(let p=0;p<a;p++){let d=p*c,g=Number(i&u);i>>=f,g>c&&(g-=m,i+=ho);let y=d,b=d+Math.abs(g)-1,w=p%2!==0,k=g<0;g===0?h=h.add(e(w,o[y])):l=l.add(e(k,o[b]))}return{p:l,f:h}},wNAFCached(s,o,i,a){let c=s._WINDOW_SIZE||1,l=o.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&o.set(s,a(l))),this.wNAF(c,l,i)}}}function Vr(r){return lo(r.Fp),Gt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...uo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ot=BigInt(0),Nt=BigInt(1),bn=BigInt(2),Yf=BigInt(8),Zf={zip215:!0};function Jf(r){let t=Vr(r);return Gt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function wn(r){let t=Jf(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=t,l=bn<<BigInt(a*8)-Nt,h=e.create,u=t.uvRatio||((A,x)=>{try{return{isValid:!0,value:e.sqrt(A*e.inv(x))}}catch{return{isValid:!1,value:Ot}}}),m=t.adjustScalarBytes||(A=>A),f=t.domain||((A,x,S)=>{if(x.length||S)throw new Error("Contexts/pre-hash are not supported");return A}),p=A=>typeof A=="bigint"&&Ot<A,d=(A,x)=>p(A)&&p(x)&&A<x,g=A=>A===Ot||d(A,l);function y(A,x){if(d(A,x))return A;throw new Error(`Expected valid scalar < ${x}, got ${typeof A} ${A}`)}function b(A){return A===Ot?A:y(A,n)}let w=new Map;function k(A){if(!(A instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(x,S,L,C){if(this.ex=x,this.ey=S,this.ez=L,this.et=C,!g(x))throw new Error("x required");if(!g(S))throw new Error("y required");if(!g(L))throw new Error("z required");if(!g(C))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(x){if(x instanceof v)throw new Error("extended point not allowed");let{x:S,y:L}=x||{};if(!g(S)||!g(L))throw new Error("invalid affine point");return new v(S,L,Nt,h(S*L))}static normalizeZ(x){let S=e.invertBatch(x.map(L=>L.ez));return x.map((L,C)=>L.toAffine(S[C])).map(v.fromAffine)}_setWindowSize(x){this._WINDOW_SIZE=x,w.delete(this)}assertValidity(){let{a:x,d:S}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:L,ey:C,ez:V,et:F}=this,G=h(L*L),M=h(C*C),K=h(V*V),st=h(K*K),Q=h(G*x),dt=h(K*h(Q+M)),pt=h(st+h(S*h(G*M)));if(dt!==pt)throw new Error("bad point: equation left != right (1)");let at=h(L*C),xt=h(V*F);if(at!==xt)throw new Error("bad point: equation left != right (2)")}equals(x){k(x);let{ex:S,ey:L,ez:C}=this,{ex:V,ey:F,ez:G}=x,M=h(S*G),K=h(V*C),st=h(L*G),Q=h(F*C);return M===K&&st===Q}is0(){return this.equals(v.ZERO)}negate(){return new v(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){let{a:x}=t,{ex:S,ey:L,ez:C}=this,V=h(S*S),F=h(L*L),G=h(bn*h(C*C)),M=h(x*V),K=S+L,st=h(h(K*K)-V-F),Q=M+F,dt=Q-G,pt=M-F,at=h(st*dt),xt=h(Q*pt),Jt=h(st*pt),Oe=h(dt*Q);return new v(at,xt,Oe,Jt)}add(x){k(x);let{a:S,d:L}=t,{ex:C,ey:V,ez:F,et:G}=this,{ex:M,ey:K,ez:st,et:Q}=x;if(S===BigInt(-1)){let vi=h((V-C)*(K+M)),Ei=h((V+C)*(K-M)),Rs=h(Ei-vi);if(Rs===Ot)return this.double();let Ai=h(F*bn*Q),Bi=h(G*bn*st),Ii=Bi+Ai,Si=Ei+vi,ki=Bi-Ai,Pl=h(Ii*Rs),Dl=h(Si*ki),Ol=h(Ii*ki),Vl=h(Rs*Si);return new v(Pl,Dl,Vl,Ol)}let dt=h(C*M),pt=h(V*K),at=h(G*L*Q),xt=h(F*st),Jt=h((C+V)*(M+K)-dt-pt),Oe=xt-at,_r=xt+at,xi=h(pt-S*dt),Ll=h(Jt*Oe),_l=h(_r*xi),Cl=h(Jt*xi),Ul=h(Oe*_r);return new v(Ll,_l,Ul,Cl)}subtract(x){return this.add(x.negate())}wNAF(x){return T.wNAFCached(this,w,x,v.normalizeZ)}multiply(x){let{p:S,f:L}=this.wNAF(y(x,n));return v.normalizeZ([S,L])[0]}multiplyUnsafe(x){let S=b(x);return S===Ot?N:this.equals(N)||S===Nt?this:this.equals(B)?this.wNAF(S).p:T.unsafeLadder(this,S)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return T.unsafeLadder(this,n).is0()}toAffine(x){let{ex:S,ey:L,ez:C}=this,V=this.is0();x==null&&(x=V?Yf:e.inv(C));let F=h(S*x),G=h(L*x),M=h(C*x);if(V)return{x:Ot,y:Nt};if(M!==Nt)throw new Error("invZ was invalid");return{x:F,y:G}}clearCofactor(){let{h:x}=t;return x===Nt?this:this.multiplyUnsafe(x)}static fromHex(x,S=!1){let{d:L,a:C}=t,V=e.BYTES;x=et("pointHex",x,V);let F=x.slice(),G=x[V-1];F[V-1]=G&-129;let M=Ie(F);M===Ot||(S?y(M,l):y(M,e.ORDER));let K=h(M*M),st=h(K-Nt),Q=h(L*K-C),{isValid:dt,value:pt}=u(st,Q);if(!dt)throw new Error("Point.fromHex: invalid y coordinate");let at=(pt&Nt)===Nt,xt=(G&128)!==0;if(!S&&pt===Ot&&xt)throw new Error("Point.fromHex: x=0 and x_0=1");return xt!==at&&(pt=h(-pt)),v.fromAffine({x:pt,y:M})}static fromPrivateKey(x){return D(x).point}toRawBytes(){let{x,y:S}=this.toAffine(),L=Me(S,e.BYTES);return L[L.length-1]|=x&Nt?128:0,L}toHex(){return re(this.toRawBytes())}}v.BASE=new v(t.Gx,t.Gy,Nt,h(t.Gx*t.Gy)),v.ZERO=new v(Ot,Nt,Nt,Ot);let{BASE:B,ZERO:N}=v,T=yn(v,a*8);function z(A){return Y(A,n)}function $(A){return z(Ie(A))}function D(A){let x=a;A=et("private key",A,x);let S=et("hashed private key",o(A),2*x),L=m(S.slice(0,x)),C=S.slice(x,2*x),V=$(L),F=B.multiply(V),G=F.toRawBytes();return{head:L,prefix:C,scalar:V,point:F,pointBytes:G}}function nt(A){return D(A).pointBytes}function rt(A=new Uint8Array,...x){let S=se(...x);return $(o(f(S,et("context",A),!!s)))}function Tt(A,x,S={}){A=et("message",A),s&&(A=s(A));let{prefix:L,scalar:C,pointBytes:V}=D(x),F=rt(S.context,L,A),G=B.multiply(F).toRawBytes(),M=rt(S.context,G,V,A),K=z(F+M*C);b(K);let st=se(G,Me(K,e.BYTES));return et("result",st,a*2)}let E=Zf;function R(A,x,S,L=E){let{context:C,zip215:V}=L,F=e.BYTES;A=et("signature",A,2*F),x=et("message",x),s&&(x=s(x));let G=Ie(A.slice(F,2*F)),M,K,st;try{M=v.fromHex(S,V),K=v.fromHex(A.slice(0,F),V),st=B.multiplyUnsafe(G)}catch{return!1}if(!V&&M.isSmallOrder())return!1;let Q=rt(C,K.toRawBytes(),M.toRawBytes(),x);return K.add(M.multiplyUnsafe(Q)).subtract(st).clearCofactor().equals(v.ZERO)}return B._setWindowSize(8),{CURVE:t,getPublicKey:nt,sign:Tt,verify:R,ExtendedPoint:v,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>i(e.BYTES),precompute(A=8,x=v.BASE){return x._setWindowSize(A),x.multiply(BigInt(3)),x}}}}var go=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),ma=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Hg=BigInt(0),Xf=BigInt(1),po=BigInt(2),Qf=BigInt(5),ya=BigInt(10),th=BigInt(20),eh=BigInt(40),ba=BigInt(80);function rh(r){let t=go,n=r*r%t*r%t,s=X(n,po,t)*n%t,o=X(s,Xf,t)*r%t,i=X(o,Qf,t)*o%t,a=X(i,ya,t)*i%t,c=X(a,th,t)*a%t,l=X(c,eh,t)*c%t,h=X(l,ba,t)*l%t,u=X(h,ba,t)*l%t,m=X(u,ya,t)*i%t;return{pow_p_5_8:X(m,po,t)*r%t,b2:n}}function nh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function sh(r,t){let e=go,n=Y(t*t*t,e),s=Y(n*n*t,e),o=rh(r*s).pow_p_5_8,i=Y(r*n*o,e),a=Y(t*i*i,e),c=i,l=Y(i*ma,e),h=a===r,u=a===Y(-r,e),m=a===Y(-r*ma,e);return h&&(i=c),(u||m)&&(i=l),ha(i,e)&&(i=Y(-i,e)),{isValid:h||u,value:i}}var oe=mn(go,void 0,!0),mo={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:oe,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:lr,randomBytes:ar,adjustScalarBytes:nh,uvRatio:sh},ur=wn(mo);function wa(r,t,e){if(t.length>255)throw new Error("Context is too big");return un(ro("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var Mg=wn({...mo,domain:wa}),$g=wn({...mo,domain:wa,prehash:lr});var oh=(oe.ORDER+BigInt(3))/BigInt(8),Kg=oe.pow(po,oh),qg=oe.sqrt(oe.neg(oe.ONE)),zg=(oe.ORDER-BigInt(5))/BigInt(8),jg=BigInt(486662);var Gg=da(oe,oe.neg(BigInt(486664)));var Wg=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Yg=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Zg=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Jg=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Xg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var fr=32,ie=64,xn=32;function xa(){let r=ur.utils.randomPrivateKey(),t=ur.getPublicKey(r);return{privateKey:Ba(r,t),publicKey:t}}function va(r){if(r.length!==xn)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let t=r,e=ur.getPublicKey(t);return{privateKey:Ba(t,e),publicKey:e}}function Ea(r,t){let e=r.subarray(0,xn);return ur.sign(t instanceof Uint8Array?t:t.subarray(),e)}function Aa(r,t,e){return ur.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}function Ba(r,t){let e=new Uint8Array(ie);for(let n=0;n<xn;n++)e[n]=r[n],e[xn+n]=t[n];return e}var bt={get(r=globalThis){let t=r.crypto;if(t==null||t.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return t}};var yo={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function bo(r){let t=r?.algorithm??"AES-GCM",e=r?.keyLength??16,n=r?.nonceLength??12,s=r?.digest??"SHA-256",o=r?.saltLength??16,i=r?.iterations??32767,a=bt.get();e*=8;async function c(u,m){let f=a.getRandomValues(new Uint8Array(o)),p=a.getRandomValues(new Uint8Array(n)),d={name:t,iv:p};typeof m=="string"&&(m=Z(m));let g;if(m.length===0){g=await a.subtle.importKey("jwk",yo,{name:"AES-GCM"},!0,["encrypt"]);try{let b={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,w,{name:t,length:e},!0,["encrypt"])}catch{g=await a.subtle.importKey("jwk",yo,{name:"AES-GCM"},!0,["encrypt"])}}else{let b={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,w,{name:t,length:e},!0,["encrypt"])}let y=await a.subtle.encrypt(d,g,u);return yt([f,d.iv,new Uint8Array(y)])}async function l(u,m){let f=u.subarray(0,o),p=u.subarray(o,o+n),d=u.subarray(o+n),g={name:t,iv:p};typeof m=="string"&&(m=Z(m));let y;if(m.length===0)try{let w={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},k=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,k,{name:t,length:e},!0,["decrypt"])}catch{y=await a.subtle.importKey("jwk",yo,{name:"AES-GCM"},!0,["decrypt"])}else{let w={name:"PBKDF2",salt:f,iterations:i,hash:{name:s}},k=await a.subtle.importKey("raw",m,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,k,{name:t,length:e},!0,["decrypt"])}let b=await a.subtle.decrypt(g,y,d);return new Uint8Array(b)}return{encrypt:c,decrypt:l}}async function hr(r,t){let n=await bo().encrypt(r,t);return nn.encode(n)}var wo=new Float32Array([-0]),ke=new Uint8Array(wo.buffer);function Sa(r,t,e){wo[0]=r,t[e]=ke[0],t[e+1]=ke[1],t[e+2]=ke[2],t[e+3]=ke[3]}function ka(r,t){return ke[0]=r[t],ke[1]=r[t+1],ke[2]=r[t+2],ke[3]=r[t+3],wo[0]}var xo=new Float64Array([-0]),Et=new Uint8Array(xo.buffer);function Ra(r,t,e){xo[0]=r,t[e]=Et[0],t[e+1]=Et[1],t[e+2]=Et[2],t[e+3]=Et[3],t[e+4]=Et[4],t[e+5]=Et[5],t[e+6]=Et[6],t[e+7]=Et[7]}function Na(r,t){return Et[0]=r[t],Et[1]=r[t+1],Et[2]=r[t+2],Et[3]=r[t+3],Et[4]=r[t+4],Et[5]=r[t+5],Et[6]=r[t+6],Et[7]=r[t+7],xo[0]}var ah=BigInt(Number.MAX_SAFE_INTEGER),ch=BigInt(Number.MIN_SAFE_INTEGER),St=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Ke;if(t<ah&&t>ch)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,s=t-(n<<32n);return e&&(n=~n|0n,s=~s|0n,++s>Ta&&(s=0n,++n>Ta&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return Ke;let e=t<0;e&&(t=-t);let n=t>>>0,s=(t-n)/4294967296>>>0;return e&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Ke}},Ke=new St(0,0);Ke.toBigInt=function(){return 0n};Ke.zzEncode=Ke.zzDecode=function(){return this};Ke.length=function(){return 1};var Ta=4294967296n;function La(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function _a(r,t,e){if(e-t<1)return"";let s,o=[],i=0,a;for(;t<e;)a=r[t++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((s??(s=[])).push(String.fromCharCode.apply(String,o)),i=0);return s!=null?(i>0&&s.push(String.fromCharCode.apply(String,o.slice(0,i))),s.join("")):String.fromCharCode.apply(String,o.slice(0,i))}function vo(r,t,e){let n=e,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128);return e-n}function Vt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function vn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Eo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Vt(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Vt(this,4);return vn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Vt(this,4);return vn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Vt(this,4);let t=ka(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Vt(this,4);let t=Na(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Vt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return _a(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Vt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Vt(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new St(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Vt(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Vt(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Vt(this,8);let t=vn(this.buf,this.pos+=4),e=vn(this.buf,this.pos+=4);return new St(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 Ao(r){return new Eo(r instanceof Uint8Array?r:r.subarray())}function Ft(r,t){let e=Ao(r);return t.decode(e)}function Bo(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return vt(i);s+i>t&&(n=vt(t),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var qe=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Io(){}var ko=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},lh=Bo();function uh(r){return globalThis.Buffer!=null?vt(r):lh(r)}var Mr=class{len;head;tail;states;constructor(){this.len=0,this.head=new qe(Io,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new qe(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Ro((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Fr,10,St.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=St.fromBigInt(t);return this._push(Fr,e.length(),e)}uint64Number(t){let e=St.fromNumber(t);return this._push(Fr,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=St.fromBigInt(t).zzEncode();return this._push(Fr,e.length(),e)}sint64Number(t){let e=St.fromNumber(t).zzEncode();return this._push(Fr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(So,1,t?1:0)}fixed32(t){return this._push(Hr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=St.fromBigInt(t);return this._push(Hr,4,e.lo)._push(Hr,4,e.hi)}fixed64Number(t){let e=St.fromNumber(t);return this._push(Hr,4,e.lo)._push(Hr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Sa,4,t)}double(t){return this._push(Ra,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(So,1,0):this.uint32(e)._push(hh,e,t)}string(t){let e=La(t);return e!==0?this.uint32(e)._push(vo,e,t):this._push(So,1,0)}fork(){return this.states=new ko(this),this.head=this.tail=new qe(Io,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 qe(Io,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=uh(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function So(r,t,e){t[e]=r&255}function fh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Ro=class extends qe{next;constructor(t,e){super(fh,t,e),this.next=void 0}};function Fr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Hr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function hh(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Mr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(dh,t,r),this},Mr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(ph,t,r),this});function dh(r,t,e){t.set(r,e)}function ph(r,t,e){r.length<40?vo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Z(r),e)}function No(){return new Mr}function Ht(r,t){let e=No();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var dr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(dr||(dr={}));function En(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function pr(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(o,i){let a=t(o);i.int32(a)},n=function(o){let i=o.int32();return t(i)};return En("enum",dr.VARINT,e,n)}function Mt(r,t){return En("message",dr.LENGTH_DELIMITED,r,t)}var ft;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(ft||(ft={}));var To;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(To||(To={}));(function(r){r.codec=()=>pr(To)})(ft||(ft={}));var ae;(function(r){let t;r.codec=()=>(t==null&&(t=Mt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let s={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let i=e.uint32();switch(i>>>3){case 1:s.Type=ft.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>Ht(e,r.codec()),r.decode=e=>Ft(e,r.codec())})(ae||(ae={}));var ce;(function(r){let t;r.codec=()=>(t==null&&(t=Mt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ft.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let s={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let i=e.uint32();switch(i>>>3){case 1:s.Type=ft.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>Ht(e,r.codec()),r.decode=e=>Ft(e,r.codec())})(ce||(ce={}));var gr=class{_key;constructor(t){this._key=mr(t,fr)}verify(t,e){return Aa(this._key,e,t)}marshal(){return this._key}get bytes(){return ae.encode({Type:ft.Ed25519,Data:this.marshal()}).subarray()}equals(t){return mt(this.bytes,t.bytes)}hash(){let t=gt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}},Re=class{_key;_publicKey;constructor(t,e){this._key=mr(t,ie),this._publicKey=mr(e,fr)}sign(t){return Ea(this._key,t)}get public(){return new gr(this._publicKey)}marshal(){return this._key}get bytes(){return ce.encode({Type:ft.Ed25519,Data:this.marshal()}).subarray()}equals(t){return mt(this.bytes,t.bytes)}async hash(){let t=gt.digest(this.bytes),e;return Lt(t)?{bytes:e}=await t:e=t.bytes,e}async id(){let t=we.digest(this.public.bytes);return ct.encode(t.bytes).substring(1)}async export(t,e="libp2p-key"){if(e==="libp2p-key")return hr(this.bytes,t);throw new _(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function gh(r){if(r.length>ie){r=mr(r,ie+fr);let n=r.subarray(0,ie),s=r.subarray(ie,r.length);return new Re(n,s)}r=mr(r,ie);let t=r.subarray(0,ie),e=r.subarray(fr);return new Re(t,e)}function mh(r){return r=mr(r,fr),new gr(r)}async function yh(){let{privateKey:r,publicKey:t}=xa();return new Re(r,t)}async function Ua(r){let{privateKey:t,publicKey:e}=va(r);return new Re(t,e)}function mr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new _(`Key must be a Uint8Array of length ${t}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function q(r,t="utf8"){let e=an[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var bh={"P-256":256,"P-384":384,"P-521":521},wh=Object.keys(bh),Qm=wh.join(" / ");var Mo={};ut(Mo,{MAX_RSA_KEY_SIZE:()=>Er,RsaPrivateKey:()=>Ge,RsaPublicKey:()=>vr,fromJwk:()=>jh,generateKeyPair:()=>Gh,unmarshalRsaPrivateKey:()=>Fo,unmarshalRsaPublicKey:()=>zh});function ze(r){if(isNaN(r)||r<=0)throw new _("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return ar(r)}var _e={};ut(_e,{exportToPem:()=>Mh,importFromPem:()=>Ac,jwkToPkcs1:()=>Oh,jwkToPkix:()=>Fh,pkcs1ToJwk:()=>Dh,pkixToJwk:()=>Vh});var Bn=class extends or{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,cn(t);let n=Ee(e);if(this.iHash=t.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 s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?t.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return sr(this),this.iHash.update(t),this}digestInto(t){sr(this),eo(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},$r=(r,t,e)=>new Bn(r,t).update(e).digest();$r.create=(r,t)=>new Bn(r,t);function vh(r,t,e,n){cn(r);let s=sa({dkLen:32,asyncTick:10},n),{c:o,dkLen:i,asyncTick:a}=s;if(nr(o),nr(i),nr(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=Ee(t),l=Ee(e),h=new Uint8Array(i),u=$r.create(r,c),m=u._cloneInto().update(l);return{c:o,dkLen:i,asyncTick:a,DK:h,PRF:u,PRFSalt:m}}function Eh(r,t,e,n,s){return r.destroy(),t.destroy(),n&&n.destroy(),s.fill(0),e}async function _o(r,t,e,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:l}=vh(r,t,e,n),h,u=new Uint8Array(4),m=ir(u),f=new Uint8Array(c.outputLen);for(let p=1,d=0;d<o;p++,d+=c.outputLen){let g=a.subarray(d,d+c.outputLen);m.setInt32(0,p,!1),(h=l._cloneInto(h)).update(u).digestInto(f),g.set(f.subarray(0,g.length)),await na(s-1,i,()=>{c._cloneInto(h).update(f).digestInto(f);for(let y=0;y<g.length;y++)g[y]^=f[y]})}return Eh(c,l,a,h,f)}var H=rn(Pa());function je(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function Ne(r,t,e=-1){let n=e,s=r,o=0,i=Math.pow(2,t);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let l=new Uint8Array(c);for(let h=a-1;h>=0;h--){let u=Math.pow(2,h*t);l[o-h-1]=Math.floor(s/u),s-=l[o-h-1]*u}return c}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function kn(...r){let t=0,e=0;for(let o of r)t+=o.length;let n=new ArrayBuffer(t),s=new Uint8Array(n);for(let o of r)s.set(o,e),e+=o.length;return s}function Uo(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=je(e,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)o[a]=r[a];return o[0]&=127,je(o,8)-n}function Da(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let i=e-t,a=Ne(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Ne(t,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),a=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<i.byteLength;c++)o[c+1]=a[c];o[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function Oa(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<e.length;s++)if(e[s]!==n[s])return!1;return!0}function kt(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(e)}var Sy=Math.log(2);function Rn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Po(r){let t=0,e=0;for(let s=0;s<r.length;s++){let o=r[s];t+=o.byteLength}let n=new Uint8Array(t);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),e),e+=o.byteLength}return n.buffer}function de(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var qr=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return Po(this.items)}},Kr=[new Uint8Array([1])],Va="0123456789";var wr="",Kt=new ArrayBuffer(0),Do=new Uint8Array(0),zr="EndOfContent",Ha="OCTET STRING",Ma="BIT STRING";function pe(r){var t;return t=class extends r{constructor(...n){var s;super(...n);let o=n[0]||{};this.isHexOnly=(s=o.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=o.valueHex?H.BufferSourceConverter.toUint8Array(o.valueHex):Do}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,o){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!de(this,i,s,o))return-1;let a=s+o;return this.valueHexView=i.subarray(s,a),this.valueHexView.length?(this.blockLength=o,a):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Kt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var ue=class{constructor({blockLength:t=0,error:e=wr,warnings:n=[],valueBeforeDecode:s=Do}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=H.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:H.Convert.ToHex(this.valueBeforeDecodeView)}}};ue.NAME="baseBlock";var At=class extends ue{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};At.NAME="valueBlock";var Nn=class extends pe(ue){constructor({idBlock:t={}}={}){var e,n,s,o;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?H.BufferSourceConverter.toUint8Array(t.valueHex):Do,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=t.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=t.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",Kt}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!t){let o=this.tagNumber;o&=31,e|=o,s[0]=e}return s.buffer}if(!this.isHexOnly){let s=Ne(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=e|31,!t){for(let c=0;c<i-1;c++)a[c+1]=o[c]|128;a[i]=o[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let s=this.valueHexView;for(let o=0;o<s.length-1;o++)n[o+1]=s[o]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!de(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(o[0]&32)===32,this.isHexOnly=!1;let a=o[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),h=255;for(;o[c]&128;){if(l[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===h){h+=255;let m=new Uint8Array(h);for(let f=0;f<l.length;f++)m[f]=l[f];l=this.valueHexView=new Uint8Array(h)}}this.blockLength=c+1,l[c-1]=o[c]&127;let u=new Uint8Array(c);for(let m=0;m<c;m++)u[m]=l[m];l=this.valueHexView=new Uint8Array(c),l.set(u),this.blockLength<=9?this.tagNumber=je(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Nn.NAME="identificationBlock";var Tn=class extends ue{constructor({lenBlock:t={}}={}){var e,n,s;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=t.length)!==null&&s!==void 0?s:0}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!de(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;if(o[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,e+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,e+this.blockLength;let i=o[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=je(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let s=Ne(this.length,8);if(s.byteLength>127)return this.error="Too big length",Kt;if(e=new ArrayBuffer(s.byteLength+1),t)return e;let o=new Uint8Array(s);n=new Uint8Array(e),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Tn.NAME="lengthBlock";var I={},wt=class extends ue{constructor({name:t=wr,optional:e=!1,primitiveSchema:n,...s}={},o){super(s),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new Nn(s),this.lenBlock=new Tn(s),this.valueBlock=o?new o(s):new At(s)}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(t,e){let n=e||new qr;e||$a(this);let s=this.idBlock.toBER(t);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(t);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(t);n.write(i),n.write(o)}return e?Kt:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return Oa(e,n)}};wt.NAME="BaseBlock";function $a(r){if(r instanceof I.Constructed)for(let t of r.valueBlock.value)$a(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Ln=class extends wt{constructor({value:t=wr,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Ln.NAME="BaseStringBlock";var _n=class extends pe(At){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};_n.NAME="PrimitiveValueBlock";var Ka,Cn=class extends wt{constructor(t={}){super(t,_n),this.idBlock.isConstructed=!1}};Ka=Cn;I.Primitive=Ka;Cn.NAME="PRIMITIVE";function Lh(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function hs(r,t=0,e=r.length){let n=t,s=new wt({},At),o=new ue;if(!de(o,r,t,e))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(t,t+e).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,t,e);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=a,e-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,t,e),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=a,e-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=wt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=I.EndOfContent;break;case 1:c=I.Boolean;break;case 2:c=I.Integer;break;case 3:c=I.BitString;break;case 4:c=I.OctetString;break;case 5:c=I.Null;break;case 6:c=I.ObjectIdentifier;break;case 10:c=I.Enumerated;break;case 12:c=I.Utf8String;break;case 13:c=I.RelativeObjectIdentifier;break;case 14:c=I.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=I.Sequence;break;case 17:c=I.Set;break;case 18:c=I.NumericString;break;case 19:c=I.PrintableString;break;case 20:c=I.TeletexString;break;case 21:c=I.VideotexString;break;case 22:c=I.IA5String;break;case 23:c=I.UTCTime;break;case 24:c=I.GeneralizedTime;break;case 25:c=I.GraphicString;break;case 26:c=I.VisibleString;break;case 27:c=I.GeneralString;break;case 28:c=I.UniversalString;break;case 29:c=I.CharacterString;break;case 30:c=I.BmpString;break;case 31:c=I.DATE;break;case 32:c=I.TimeOfDay;break;case 33:c=I.DateTime;break;case 34:c=I.Duration;break;default:{let l=s.idBlock.isConstructed?new I.Constructed:new I.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?I.Constructed:I.Primitive}return s=Lh(s,c),a=s.fromBER(r,t,s.lenBlock.isIndefiniteForm?e:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function xr(r){if(!r.byteLength){let t=new wt({},At);return t.error="Input buffer has zero length",{offset:-1,result:t}}return hs(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function _h(r,t){return r?1:t}var Wt=class extends At{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!de(this,s,e,n))return-1;if(this.valueBeforeDecodeView=s.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let o=e;for(;_h(this.isIndefiniteForm,n)>0;){let i=hs(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===zr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===zr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new qr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?Kt:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};Wt.NAME="ConstructedValueBlock";var qa,Te=class extends wt{constructor(t={}){super(t,Wt),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
2
+ "use strict";var Libp2PAutonat=(()=>{var xl=Object.create;var Zr=Object.defineProperty;var vl=Object.getOwnPropertyDescriptor;var El=Object.getOwnPropertyNames;var Bl=Object.getPrototypeOf,Al=Object.prototype.hasOwnProperty;var Es=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),lt=(r,t)=>{for(var e in t)Zr(r,e,{get:t[e],enumerable:!0})},vi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of El(t))!Al.call(r,s)&&s!==e&&Zr(r,s,{get:()=>t[s],enumerable:!(n=vl(t,s))||n.enumerable});return r};var Bs=(r,t,e)=>(e=r!=null?xl(Bl(r)):{},vi(t||!r||!r.__esModule?Zr(e,"default",{value:r,enumerable:!0}):e,r)),Sl=r=>vi(Zr({},"__esModule",{value:!0}),r);var ka=Es(hr=>{"use strict";var rh="[object ArrayBuffer]",oe=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===rh}static toArrayBuffer(t){return this.isArrayBuffer(t)?t:t.byteLength===t.buffer.byteLength||t.byteOffset===0&&t.byteLength===t.buffer.byteLength?t.buffer:this.toUint8Array(t.buffer).slice(t.byteOffset,t.byteOffset+t.byteLength).buffer}static toUint8Array(t){return this.toView(t,Uint8Array)}static toView(t,e){if(t.constructor===e)return t;if(this.isArrayBuffer(t))return new e(t);if(this.isArrayBufferView(t))return new e(t.buffer,t.byteOffset,t.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(t){return this.isArrayBufferView(t)||this.isArrayBuffer(t)}static isArrayBufferView(t){return ArrayBuffer.isView(t)||t&&this.isArrayBuffer(t.buffer)}static isEqual(t,e){let n=r.toUint8Array(t),s=r.toUint8Array(e);if(n.length!==s.byteLength)return!1;for(let o=0;o<n.length;o++)if(n[o]!==s[o])return!1;return!0}static concat(...t){let e;Array.isArray(t[0])&&!(t[1]instanceof Function)||Array.isArray(t[0])&&t[1]instanceof Function?e=t[0]:t[t.length-1]instanceof Function?e=t.slice(0,t.length-1):e=t;let n=0;for(let i of e)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of e){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return t[t.length-1]instanceof Function?this.toView(s,t[t.length-1]):s.buffer}},Ro="string",nh=/^[0-9a-f]+$/i,sh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,oh=/^[a-zA-Z0-9-_]+$/,yn=class{static fromString(t){let e=unescape(encodeURIComponent(t)),n=new Uint8Array(e.length);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return n.buffer}static toString(t){let e=oe.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return decodeURIComponent(escape(n))}},Lt=class{static toString(t,e=!1){let n=oe.toArrayBuffer(t),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,e);o+=String.fromCharCode(a)}return o}static fromString(t,e=!1){let n=new ArrayBuffer(t.length*2),s=new DataView(n);for(let o=0;o<t.length;o++)s.setUint16(o*2,t.charCodeAt(o),e);return n}},bn=class r{static isHex(t){return typeof t===Ro&&nh.test(t)}static isBase64(t){return typeof t===Ro&&sh.test(t)}static isBase64Url(t){return typeof t===Ro&&oh.test(t)}static ToString(t,e="utf8"){let n=oe.toUint8Array(t);switch(e.toLowerCase()){case"utf8":return this.ToUtf8String(n);case"binary":return this.ToBinary(n);case"hex":return this.ToHex(n);case"base64":return this.ToBase64(n);case"base64url":return this.ToBase64Url(n);case"utf16le":return Lt.toString(n,!0);case"utf16":case"utf16be":return Lt.toString(n);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromString(t,e="utf8"){if(!t)return new ArrayBuffer(0);switch(e.toLowerCase()){case"utf8":return this.FromUtf8String(t);case"binary":return this.FromBinary(t);case"hex":return this.FromHex(t);case"base64":return this.FromBase64(t);case"base64url":return this.FromBase64Url(t);case"utf16le":return Lt.fromString(t,!0);case"utf16":case"utf16be":return Lt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=oe.toUint8Array(t);if(typeof btoa<"u"){let n=this.ToString(e,"binary");return btoa(n)}else return Buffer.from(e).toString("base64")}static FromBase64(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64(e))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(e)):new Uint8Array(Buffer.from(e,"base64")).buffer}static FromBase64Url(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isBase64Url(e))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(e.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(t){return this.ToBase64(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.FromBinary(t);case"utf8":return yn.fromString(t);case"utf16":case"utf16be":return Lt.fromString(t);case"utf16le":case"usc2":return Lt.fromString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToUtf8String(t,e=r.DEFAULT_UTF8_ENCODING){switch(e){case"ascii":return this.ToBinary(t);case"utf8":return yn.toString(t);case"utf16":case"utf16be":return Lt.toString(t);case"utf16le":case"usc2":return Lt.toString(t,!0);default:throw new Error(`Unknown type of encoding '${e}'`)}}static FromBinary(t){let e=t.length,n=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);return n.buffer}static ToBinary(t){let e=oe.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=oe.toUint8Array(t),n="",s=e.length;for(let o=0;o<s;o++){let i=e[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(t){let e=this.formatString(t);if(!e)return new ArrayBuffer(0);if(!r.isHex(e))throw new TypeError("Argument 'hexString' is not HEX encoded");e.length%2&&(e=`0${e}`);let n=new Uint8Array(e.length/2);for(let s=0;s<e.length;s=s+2){let o=e.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(t,e=!1){return Lt.toString(t,e)}static FromUtf16String(t,e=!1){return Lt.fromString(t,e)}static Base64Padding(t){let e=4-t.length%4;if(e<4)for(let n=0;n<e;n++)t+="=";return t}static formatString(t){return t?.replace(/[\n\r\t ]/g,"")||""}};bn.DEFAULT_UTF8_ENCODING="utf8";function ih(r,...t){let e=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)e[o]=s[o]}return e}function ah(...r){let t=r.map(s=>s.byteLength).reduce((s,o)=>s+o),e=new Uint8Array(t),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)e[n++]=o}),e.buffer}function ch(r,t){if(!(r&&t)||r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<r.byteLength;s++)if(e[s]!==n[s])return!1;return!0}hr.BufferSourceConverter=oe;hr.Convert=bn;hr.assign=ih;hr.combine=ah;hr.isEqual=ch});var Oc=Es(Wr=>{(function(){var r,t,e,n,s,o,i,a;a=function(c){var l,f,u,h;return l=(c&255<<24)>>>24,f=(c&255<<16)>>>16,u=(c&65280)>>>8,h=c&255,[l,f,u,h].join(".")},i=function(c){var l,f,u,h,m,g;for(l=[],u=h=0;h<=3&&c.length!==0;u=++h){if(u>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}g=t(c),m=g[0],f=g[1],c=c.substring(f),l.push(m)}if(c.length!==0)throw new Error("Invalid IP");switch(l.length){case 1:if(l[0]>4294967295)throw new Error("Invalid IP");return l[0]>>>0;case 2:if(l[0]>255||l[1]>16777215)throw new Error("Invalid IP");return(l[0]<<24|l[1])>>>0;case 3:if(l[0]>255||l[1]>255||l[2]>65535)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2])>>>0;case 4:if(l[0]>255||l[1]>255||l[2]>255||l[3]>255)throw new Error("Invalid IP");return(l[0]<<24|l[1]<<16|l[2]<<8|l[3])>>>0;default:throw new Error("Invalid IP")}},e=function(c){return c.charCodeAt(0)},n=e("0"),o=e("a"),s=e("A"),t=function(c){var l,f,u,h,m;for(h=0,l=10,f="9",u=0,c.length>1&&c[u]==="0"&&(c[u+1]==="x"||c[u+1]==="X"?(u+=2,l=16):"0"<=c[u+1]&&c[u+1]<="9"&&(u++,l=8,f="7")),m=u;u<c.length;){if("0"<=c[u]&&c[u]<=f)h=h*l+(e(c[u])-n)>>>0;else if(l===16)if("a"<=c[u]&&c[u]<="f")h=h*l+(10+e(c[u])-o)>>>0;else if("A"<=c[u]&&c[u]<="F")h=h*l+(10+e(c[u])-s)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");u++}if(u===m)throw new Error("empty octet");return[h,u]},r=function(){function c(l,f){var u,h,m,g;if(typeof l!="string")throw new Error("Missing `net' parameter");if(f||(g=l.split("/",2),l=g[0],f=g[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=i(f)}catch(d){throw u=d,new Error("Invalid mask: "+f)}for(h=m=32;m>=0;h=--m)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(l)&this.maskLong)>>>0}catch(d){throw u=d,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new c(l)),l instanceof c?this.contains(l.base)&&this.contains(l.broadcast||l.last):(i(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(l){return l==null&&(l=1),new c(a(this.netLong+this.size*l),this.mask)},c.prototype.forEach=function(l){var f,u,h;for(h=i(this.first),u=i(this.last),f=0;h<=u;)l(a(h),h,f),f++,h++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),Wr.ip2long=i,Wr.long2ip=a,Wr.Netmask=r}).call(Wr)});var nl=Es((Ib,rl)=>{"use strict";function el(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Ad(r,t,e){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");e||(e={}),typeof t=="object"&&(e=t,t=""),t&&(e.code=t);try{return el(r,e)}catch{e.message=r.message,e.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),el(new s,e)}}rl.exports=Ad});var Kd={};lt(Kd,{autoNAT:()=>Md});var Ei=Symbol.for("@libp2p/peer-id");var U=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var As="ERR_TIMEOUT";var Ss=(r,...t)=>{try{[...t]}catch{}};var Ts={};lt(Ts,{base58btc:()=>at,base58flickr:()=>Ll});var jd=new Uint8Array(0);function Bi(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}function jt(r){if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")}function Ai(r){return new TextEncoder().encode(r)}function Si(r){return new TextDecoder().decode(r)}function kl(r,t){if(r.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),n=0;n<e.length;n++)e[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(e[i]!==255)throw new TypeError(o+" is ambiguous");e[i]=s}var a=r.length,c=r.charAt(0),l=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function u(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var d=0,p=0,y=0,v=g.length;y!==v&&g[y]===0;)y++,d++;for(var w=(v-y)*f+1>>>0,T=new Uint8Array(w);y!==v;){for(var x=g[y],A=0,R=w-1;(x!==0||A<p)&&R!==-1;R--,A++)x+=256*T[R]>>>0,T[R]=x%a>>>0,x=x/a>>>0;if(x!==0)throw new Error("Non-zero carry");p=A,y++}for(var N=w-p;N!==w&&T[N]===0;)N++;for(var q=c.repeat(d);N<w;++N)q+=r.charAt(T[N]);return q}function h(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var d=0;if(g[d]!==" "){for(var p=0,y=0;g[d]===c;)p++,d++;for(var v=(g.length-d)*l+1>>>0,w=new Uint8Array(v);g[d];){var T=e[g.charCodeAt(d)];if(T===255)return;for(var x=0,A=v-1;(T!==0||x<y)&&A!==-1;A--,x++)T+=a*w[A]>>>0,w[A]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");y=x,d++}if(g[d]!==" "){for(var R=v-y;R!==v&&w[R]===0;)R++;for(var N=new Uint8Array(p+(v-R)),q=p;R!==v;)N[q++]=w[R++];return N}}}function m(g){var d=h(g);if(d)return d;throw new Error(`Non-${t} character`)}return{encode:u,decodeUnsafe:h,decode:m}}var Il=kl,Rl=Il,Ii=Rl;var ks=class{name;prefix;baseEncode;constructor(t,e,n){this.name=t,this.prefix=e,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Is=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){if(this.name=t,this.prefix=e,e.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=e.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Ri(this,t)}},Rs=class{decoders;constructor(t){this.decoders=t}or(t){return Ri(this,t)}decode(t){let e=t[0],n=this.decoders[e];if(n!=null)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ri(r,t){return new Rs({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var Ns=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,e,n,s){this.name=t,this.prefix=e,this.baseEncode=n,this.baseDecode=s,this.encoder=new ks(t,e,n),this.decoder=new Is(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function ze({name:r,prefix:t,encode:e,decode:n}){return new Ns(r,t,e,n)}function pe({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=Ii(e,r);return ze({prefix:t,name:r,encode:n,decode:o=>jt(s(o))})}function Nl(r,t,e,n){let s={};for(let f=0;f<t.length;++f)s[t[f]]=f;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*e/8|0),a=0,c=0,l=0;for(let f=0;f<o;++f){let u=s[r[f]];if(u===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<e|u,a+=e,a>=8&&(a-=8,i[l++]=255&c>>a)}if(a>=e||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function Tl(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>e;)i-=e,o+=t[s&a>>i];if(i!==0&&(o+=t[s&a<<e-i]),n)for(;o.length*e&7;)o+="=";return o}function tt({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return ze({prefix:t,name:r,encode(s){return Tl(s,n,e)},decode(s){return Nl(s,n,e,r)}})}var at=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ll=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ls={};lt(Ls,{base10:()=>_l});var _l=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var _s={};lt(_s,{base16:()=>Ul,base16upper:()=>Cl});var Ul=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Cl=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Us={};lt(Us,{base2:()=>Dl});var Dl=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cs={};lt(Cs,{base256emoji:()=>Hl});var Ni=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}"),Pl=Ni.reduce((r,t,e)=>(r[e]=t,r),[]),Ol=Ni.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Vl(r){return r.reduce((t,e)=>(t+=Pl[e],t),"")}function Fl(r){let t=[];for(let e of r){let n=Ol[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Hl=ze({prefix:"\u{1F680}",name:"base256emoji",encode:Vl,decode:Fl});var Ds={};lt(Ds,{base32:()=>Wt,base32hex:()=>ql,base32hexpad:()=>zl,base32hexpadupper:()=>jl,base32hexupper:()=>Gl,base32pad:()=>Kl,base32padupper:()=>$l,base32upper:()=>Ml,base32z:()=>Wl});var Wt=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ml=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Kl=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$l=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ql=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gl=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),zl=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),jl=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Wl=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ps={};lt(Ps,{base36:()=>Yl,base36upper:()=>Zl});var Yl=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zl=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vs={};lt(Vs,{base64:()=>Os,base64pad:()=>Jl,base64url:()=>Xl,base64urlpad:()=>Ql});var Os=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Jl=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Xl=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Ql=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fs={};lt(Fs,{base8:()=>tu});var tu=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hs={};lt(Hs,{identity:()=>eu});var eu=ze({prefix:"\0",name:"identity",encode:r=>Si(r),decode:r=>Ai(r)});var l0=new TextEncoder,u0=new TextDecoder;var Ks={};lt(Ks,{identity:()=>ge});var su=_i,Ti=128,ou=127,iu=~ou,au=Math.pow(2,31);function _i(r,t,e){t=t||[],e=e||0;for(var n=e;r>=au;)t[e++]=r&255|Ti,r/=128;for(;r&iu;)t[e++]=r&255|Ti,r>>>=7;return t[e]=r|0,_i.bytes=e-n+1,t}var cu=Ms,lu=128,Li=127;function Ms(r,n){var e=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw Ms.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&Li)<<s:(i&Li)*Math.pow(2,s),s+=7}while(i>=lu);return Ms.bytes=o-n,e}var uu=Math.pow(2,7),fu=Math.pow(2,14),hu=Math.pow(2,21),du=Math.pow(2,28),pu=Math.pow(2,35),gu=Math.pow(2,42),mu=Math.pow(2,49),yu=Math.pow(2,56),bu=Math.pow(2,63),wu=function(r){return r<uu?1:r<fu?2:r<hu?3:r<du?4:r<pu?5:r<gu?6:r<mu?7:r<yu?8:r<bu?9:10},xu={encode:su,decode:cu,encodingLength:wu},vu=xu,Ar=vu;function Sr(r,t=0){return[Ar.decode(r,t),Ar.decode.bytes]}function je(r,t,e=0){return Ar.encode(r,t,e),t}function We(r){return Ar.encodingLength(r)}function Mt(r,t){let e=t.byteLength,n=We(r),s=n+We(e),o=new Uint8Array(s+e);return je(r,o,0),je(e,o,n),o.set(t,s),new Ye(r,e,t,o)}function Ce(r){let t=jt(r),[e,n]=Sr(t),[s,o]=Sr(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new Ye(e,s,i,t)}function Ui(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Bi(r.bytes,e.bytes)}}var Ye=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var Ci=0,Eu="identity",Di=jt;function Bu(r){return Mt(Ci,Di(r))}var ge={code:Ci,name:Eu,encode:Di,digest:Bu};var Gs={};lt(Gs,{sha256:()=>dt,sha512:()=>Au});function qs({name:r,code:t,encode:e}){return new $s(r,t,e)}var $s=class{name;code;encode;constructor(t,e,n){this.name=t,this.code=e,this.encode=n}digest(t){if(t instanceof Uint8Array){let e=this.encode(t);return e instanceof Uint8Array?Mt(this.code,e):e.then(n=>Mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Oi(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var dt=qs({name:"sha2-256",code:18,encode:Oi("SHA-256")}),Au=qs({name:"sha2-512",code:19,encode:Oi("SHA-512")});function Vi(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return ku(e,zs(r),t??at.encoder);default:return Iu(e,zs(r),t??Wt.encoder)}}var Fi=new WeakMap;function zs(r){let t=Fi.get(r);if(t==null){let e=new Map;return Fi.set(r,e),e}return t}var Ut=class r{code;version;multihash;bytes;"/";constructor(t,e,n,s){this.code=e,this.version=t,this.multihash=n,this.bytes=s,this["/"]=s}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:t,multihash:e}=this;if(t!==kr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Ru)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(e)}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:t,digest:e}=this.multihash,n=Mt(t,e);return r.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(t){return r.equals(this,t)}static equals(t,e){let n=e;return n!=null&&t.code===n.code&&t.version===n.version&&Ui(t.multihash,n.multihash)}toString(t){return Vi(this,t)}toJSON(){return{"/":Vi(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(t){if(t==null)return null;let e=t;if(e instanceof r)return e;if(e["/"]!=null&&e["/"]===e.bytes||e.asCID===e){let{version:n,code:s,multihash:o,bytes:i}=e;return new r(n,s,o,i??Hi(n,s,o.bytes))}else if(e[Nu]===!0){let{version:n,multihash:s,code:o}=e,i=Ce(s);return r.create(n,o,i)}else return null}static create(t,e,n){if(typeof e!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(t){case 0:{if(e!==kr)throw new Error(`Version 0 CID must use dag-pb (code: ${kr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=Hi(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,kr,t)}static createV1(t,e){return r.create(1,t,e)}static decode(t){let[e,n]=r.decodeFirst(t);if(n.length!==0)throw new Error("Incorrect length");return e}static decodeFirst(t){let e=r.inspectBytes(t),n=e.size-e.multihashSize,s=jt(t.subarray(n,n+e.multihashSize));if(s.byteLength!==e.multihashSize)throw new Error("Incorrect length");let o=s.subarray(e.multihashSize-e.digestSize),i=new Ye(e.multihashCode,e.digestSize,o,s);return[e.version===0?r.createV0(i):r.createV1(e.codec,i),t.subarray(e.size)]}static inspectBytes(t){let e=0,n=()=>{let[u,h]=Sr(t.subarray(e));return e+=h,u},s=n(),o=kr;if(s===18?(s=0,e=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=e,a=n(),c=n(),l=e+c,f=l-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:f,size:l}}static parse(t,e){let[n,s]=Su(t,e),o=r.decode(s);if(o.version===0&&t[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return zs(o).set(n,t),o}};function Su(r,t){switch(r[0]){case"Q":{let e=t??at;return[at.prefix,e.decode(`${at.prefix}${r}`)]}case at.prefix:{let e=t??at;return[at.prefix,e.decode(r)]}case Wt.prefix:{let e=t??Wt;return[Wt.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function ku(r,t,e){let{prefix:n}=e;if(n!==at.prefix)throw Error(`Cannot string encode V0 in ${e.name} encoding`);let s=t.get(n);if(s==null){let o=e.encode(r).slice(1);return t.set(n,o),o}else return s}function Iu(r,t,e){let{prefix:n}=e,s=t.get(n);if(s==null){let o=e.encode(r);return t.set(n,o),o}else return s}var kr=112,Ru=18;function Hi(r,t,e){let n=We(r),s=n+We(t),o=new Uint8Array(s+e.byteLength);return je(r,o,0),je(t,o,n),o.set(e,s),o}var Nu=Symbol.for("@ipld/js-cid/CID");var me={...Hs,...Us,...Fs,...Ls,..._s,...Ds,...Ps,...Ts,...Vs,...Cs},L0={...Gs,...Ks};function yt(r,t){if(r===t)return!0;if(r.byteLength!==t.byteLength)return!1;for(let e=0;e<r.byteLength;e++)if(r[e]!==t[e])return!1;return!0}var Tu=Symbol.for("nodejs.util.inspect.custom"),Mi=Object.values(me).map(r=>r.decoder).reduce((r,t)=>r.or(t),me.identity.decoder),Ki=114,js=36,Ws=37,Ir=class{type;multihash;privateKey;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,this.privateKey=t.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ei]=!0;toString(){return this.string==null&&(this.string=at.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Ut.createV1(Ki,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return yt(this.multihash.bytes,t);if(typeof t=="string")return Lu(t).equals(this);if(t?.multihash?.bytes!=null)return yt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Tu](){return`PeerId(${this.toString()})`}},Ze=class extends Ir{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},Je=class extends Ir{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},Xe=class extends Ir{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function Lu(r,t){if(t=t??Mi,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Ce(at.decode(`z${r}`));return r.startsWith("12D")?new Je({multihash:e}):r.startsWith("16U")?new Xe({multihash:e}):new Ze({multihash:e})}return Xr(Mi.decode(r))}function Xr(r){try{let t=Ce(r);if(t.code===ge.code){if(t.digest.length===js)return new Je({multihash:t});if(t.digest.length===Ws)return new Xe({multihash:t})}if(t.code===dt.code)return new Ze({multihash:t})}catch{return _u(Ut.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function _u(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==Ki)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===dt.code)return new Ze({multihash:r.multihash});if(t.code===ge.code){if(t.digest.length===js)return new Je({multihash:r.multihash});if(t.digest.length===Ws)return new Xe({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function $i(r,t){return r.length===js?new Je({multihash:Mt(ge.code,r),privateKey:t}):r.length===Ws?new Xe({multihash:Mt(ge.code,r),privateKey:t}):new Ze({multihash:await dt.digest(r),publicKey:r,privateKey:t})}var ko={};lt(ko,{Ed25519PrivateKey:()=>Me,Ed25519PublicKey:()=>Ur,generateKeyPair:()=>Qf,generateKeyPairFromSeed:()=>Sa,unmarshalEd25519PrivateKey:()=>Jf,unmarshalEd25519PublicKey:()=>Xf});function ye(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Yt(r=0){return globalThis.Buffer?.alloc!=null?ye(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function bt(r=0){return globalThis.Buffer?.allocUnsafe!=null?ye(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Et(r,t){if(globalThis.Buffer!=null)return ye(globalThis.Buffer.concat(r,t));t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=bt(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return ye(e)}function Gi(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var qi=Gi("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ys=Gi("ascii","a",r=>{let t="a";for(let e=0;e<r.length;e++)t+=String.fromCharCode(r[e]);return t},r=>{r=r.substring(1);let t=bt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Uu={utf8:qi,"utf-8":qi,hex:me.base16,latin1:Ys,ascii:Ys,binary:Ys,...me},Qr=Uu;function Z(r,t="utf8"){let e=Qr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?ye(globalThis.Buffer.from(r,"utf-8")):e.decoder.decode(`${e.prefix}${r}`)}function Tt(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function Qe(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Cu(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Zs(r,...t){if(!Cu(r))throw new Error("Expected Uint8Array");if(t.length>0&&!t.includes(r.length))throw new Error(`Expected Uint8Array of length ${t}, not of length=${r.length}`)}function tn(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Qe(r.outputLen),Qe(r.blockLen)}function tr(r,t=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(t&&r.finished)throw new Error("Hash#digest() has already been called")}function zi(r,t){Zs(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var en=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function ji(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var rr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Ct=(r,t)=>r<<32-t|r>>>t,Du=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Du)throw new Error("Non little-endian hardware is not supported");var Pu=async()=>{};async function Wi(r,t,e){let n=Date.now();for(let s=0;s<r;s++){e(s);let o=Date.now()-n;o>=0&&o<t||(await Pu(),n+=o)}}function Js(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function be(r){if(typeof r=="string"&&(r=Js(r)),!ji(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function rn(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];if(!ji(s))throw new Error("Uint8Array expected");t+=s.length}let e=new Uint8Array(t);for(let n=0,s=0;n<r.length;n++){let o=r[n];e.set(o,s),s+=o.length}return e}var er=class{clone(){return this._cloneInto()}},Ou={}.toString;function Yi(r,t){if(t!==void 0&&Ou.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,t)}function nn(r){let t=n=>r().update(be(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function nr(r=32){if(en&&typeof en.getRandomValues=="function")return en.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Vu(r,t,e,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(t,e,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(e>>s&o),a=Number(e&o),c=n?4:0,l=n?0:4;r.setUint32(t+c,i,n),r.setUint32(t+l,a,n)}var sr=class extends er{constructor(t,e,n,s){super(),this.blockLen=t,this.outputLen=e,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=rr(this.buffer)}update(t){tr(this);let{view:e,buffer:n,blockLen:s}=this;t=be(t);let o=t.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=rr(t);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(t.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){tr(this),zi(t,this),this.finished=!0;let{buffer:e,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;e[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>s-i&&(this.process(n,0),i=0);for(let u=i;u<s;u++)e[u]=0;Vu(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=rr(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)a.setUint32(4*u,f[u],o)}digest(){let{buffer:t,outputLen:e}=this;this.digestInto(t);let n=t.slice(0,e);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());let{blockLen:e,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return t.length=s,t.pos=a,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var sn=BigInt(4294967295),Xs=BigInt(32);function Zi(r,t=!1){return t?{h:Number(r&sn),l:Number(r>>Xs&sn)}:{h:Number(r>>Xs&sn)|0,l:Number(r&sn)|0}}function Fu(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=Zi(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var Hu=(r,t)=>BigInt(r>>>0)<<Xs|BigInt(t>>>0),Mu=(r,t,e)=>r>>>e,Ku=(r,t,e)=>r<<32-e|t>>>e,$u=(r,t,e)=>r>>>e|t<<32-e,qu=(r,t,e)=>r<<32-e|t>>>e,Gu=(r,t,e)=>r<<64-e|t>>>e-32,zu=(r,t,e)=>r>>>e-32|t<<64-e,ju=(r,t)=>t,Wu=(r,t)=>r,Yu=(r,t,e)=>r<<e|t>>>32-e,Zu=(r,t,e)=>t<<e|r>>>32-e,Ju=(r,t,e)=>t<<e-32|r>>>64-e,Xu=(r,t,e)=>r<<e-32|t>>>64-e;function Qu(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var tf=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),ef=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,rf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),nf=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,sf=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),of=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var af={fromBig:Zi,split:Fu,toBig:Hu,shrSH:Mu,shrSL:Ku,rotrSH:$u,rotrSL:qu,rotrBH:Gu,rotrBL:zu,rotr32H:ju,rotr32L:Wu,rotlSH:Yu,rotlSL:Zu,rotlBH:Ju,rotlBL:Xu,add:Qu,add3L:tf,add3H:ef,add4L:rf,add4H:nf,add5H:of,add5L:sf},C=af;var[cf,lf]=C.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(r=>BigInt(r))),we=new Uint32Array(80),xe=new Uint32Array(80),Qs=class extends sr{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:t,Al:e,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:l,El:f,Fh:u,Fl:h,Gh:m,Gl:g,Hh:d,Hl:p}=this;return[t,e,n,s,o,i,a,c,l,f,u,h,m,g,d,p]}set(t,e,n,s,o,i,a,c,l,f,u,h,m,g,d,p){this.Ah=t|0,this.Al=e|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=f|0,this.Fh=u|0,this.Fl=h|0,this.Gh=m|0,this.Gl=g|0,this.Hh=d|0,this.Hl=p|0}process(t,e){for(let w=0;w<16;w++,e+=4)we[w]=t.getUint32(e),xe[w]=t.getUint32(e+=4);for(let w=16;w<80;w++){let T=we[w-15]|0,x=xe[w-15]|0,A=C.rotrSH(T,x,1)^C.rotrSH(T,x,8)^C.shrSH(T,x,7),R=C.rotrSL(T,x,1)^C.rotrSL(T,x,8)^C.shrSL(T,x,7),N=we[w-2]|0,q=xe[w-2]|0,K=C.rotrSH(N,q,19)^C.rotrBH(N,q,61)^C.shrSH(N,q,6),P=C.rotrSL(N,q,19)^C.rotrBL(N,q,61)^C.shrSL(N,q,6),nt=C.add4L(R,P,xe[w-7],xe[w-16]),rt=C.add4H(nt,A,K,we[w-7],we[w-16]);we[w]=rt|0,xe[w]=nt|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:l,Dl:f,Eh:u,El:h,Fh:m,Fl:g,Gh:d,Gl:p,Hh:y,Hl:v}=this;for(let w=0;w<80;w++){let T=C.rotrSH(u,h,14)^C.rotrSH(u,h,18)^C.rotrBH(u,h,41),x=C.rotrSL(u,h,14)^C.rotrSL(u,h,18)^C.rotrBL(u,h,41),A=u&m^~u&d,R=h&g^~h&p,N=C.add5L(v,x,R,lf[w],xe[w]),q=C.add5H(N,y,T,A,cf[w],we[w]),K=N|0,P=C.rotrSH(n,s,28)^C.rotrBH(n,s,34)^C.rotrBH(n,s,39),nt=C.rotrSL(n,s,28)^C.rotrBL(n,s,34)^C.rotrBL(n,s,39),rt=n&o^n&a^o&a,Nt=s&i^s&c^i&c;y=d|0,v=p|0,d=m|0,p=g|0,m=u|0,g=h|0,{h:u,l:h}=C.add(l|0,f|0,q|0,K|0),l=a|0,f=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let E=C.add3L(K,nt,Nt);n=C.add3H(E,q,P,rt),s=E|0}({h:n,l:s}=C.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=C.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:a,l:c}=C.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:f}=C.add(this.Dh|0,this.Dl|0,l|0,f|0),{h:u,l:h}=C.add(this.Eh|0,this.El|0,u|0,h|0),{h:m,l:g}=C.add(this.Fh|0,this.Fl|0,m|0,g|0),{h:d,l:p}=C.add(this.Gh|0,this.Gl|0,d|0,p|0),{h:y,l:v}=C.add(this.Hh|0,this.Hl|0,y|0,v|0),this.set(n,s,o,i,a,c,l,f,u,h,m,g,d,p,y,v)}roundClean(){we.fill(0),xe.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};var or=nn(()=>new Qs);var an={};lt(an,{bitGet:()=>mf,bitLen:()=>gf,bitMask:()=>Rr,bitSet:()=>yf,bytesToHex:()=>Jt,bytesToNumberBE:()=>Xt,bytesToNumberLE:()=>ve,concatBytes:()=>Qt,createHmacDrbg:()=>ro,ensureBytes:()=>et,equalBytes:()=>df,hexToBytes:()=>Pe,hexToNumber:()=>eo,isBytes:()=>Dt,numberToBytesBE:()=>Ee,numberToBytesLE:()=>Oe,numberToHexUnpadded:()=>ta,numberToVarBytesBE:()=>hf,utf8ToBytes:()=>pf,validateObject:()=>Kt});var Qi=BigInt(0),on=BigInt(1),uf=BigInt(2);function Dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var ff=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Jt(r){if(!Dt(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=ff[r[e]];return t}function ta(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function eo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Zt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Ji(r){if(r>=Zt._0&&r<=Zt._9)return r-Zt._0;if(r>=Zt._A&&r<=Zt._F)return r-(Zt._A-10);if(r>=Zt._a&&r<=Zt._f)return r-(Zt._a-10)}function Pe(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let t=r.length,e=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);let n=new Uint8Array(e);for(let s=0,o=0;s<e;s++,o+=2){let i=Ji(r.charCodeAt(o)),a=Ji(r.charCodeAt(o+1));if(i===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[s]=i*16+a}return n}function Xt(r){return eo(Jt(r))}function ve(r){if(!Dt(r))throw new Error("Uint8Array expected");return eo(Jt(Uint8Array.from(r).reverse()))}function Ee(r,t){return Pe(r.toString(16).padStart(t*2,"0"))}function Oe(r,t){return Ee(r,t).reverse()}function hf(r){return Pe(ta(r))}function et(r,t,e){let n;if(typeof t=="string")try{n=Pe(t)}catch(o){throw new Error(`${r} must be valid hex string, got "${t}". Cause: ${o}`)}else if(Dt(t))n=Uint8Array.from(t);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof e=="number"&&s!==e)throw new Error(`${r} expected ${e} bytes, got ${s}`);return n}function Qt(...r){let t=0;for(let s=0;s<r.length;s++){let o=r[s];if(!Dt(o))throw new Error("Uint8Array expected");t+=o.length}let e=new Uint8Array(t),n=0;for(let s=0;s<r.length;s++){let o=r[s];e.set(o,n),n+=o.length}return e}function df(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r[n]^t[n];return e===0}function pf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function gf(r){let t;for(t=0;r>Qi;r>>=on,t+=1);return t}function mf(r,t){return r>>BigInt(t)&on}var yf=(r,t,e)=>r|(e?on:Qi)<<BigInt(t),Rr=r=>(uf<<BigInt(r-1))-on,to=r=>new Uint8Array(r),Xi=r=>Uint8Array.from(r);function ro(r,t,e){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof e!="function")throw new Error("hmacFn must be a function");let n=to(r),s=to(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...u)=>e(s,n,...u),c=(u=to())=>{s=a(Xi([0]),u),n=a(),u.length!==0&&(s=a(Xi([1]),u),n=a())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let u=0,h=[];for(;u<t;){n=a();let m=n.slice();h.push(m),u+=n.length}return Qt(...h)};return(u,h)=>{i(),c(u);let m;for(;!(m=h(l()));)c();return i(),m}}var bf={bigint:r=>typeof r=="bigint",function:r=>typeof r=="function",boolean:r=>typeof r=="boolean",string:r=>typeof r=="string",stringOrUint8Array:r=>typeof r=="string"||Dt(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,t)=>t.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Kt(r,t,e={}){let n=(s,o,i)=>{let a=bf[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=r[s];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(let[s,o]of Object.entries(t))n(s,o,!1);for(let[s,o]of Object.entries(e))n(s,o,!0);return r}var ct=BigInt(0),J=BigInt(1),Ve=BigInt(2),wf=BigInt(3),no=BigInt(4),ea=BigInt(5),ra=BigInt(8),xf=BigInt(9),vf=BigInt(16);function Y(r,t){let e=r%t;return e>=ct?e:t+e}function Ef(r,t,e){if(e<=ct||t<ct)throw new Error("Expected power/modulo > 0");if(e===J)return ct;let n=J;for(;t>ct;)t&J&&(n=n*r%e),r=r*r%e,t>>=J;return n}function X(r,t,e){let n=r;for(;t-- >ct;)n*=n,n%=e;return n}function cn(r,t){if(r===ct||t<=ct)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Y(r,t),n=t,s=ct,o=J,i=J,a=ct;for(;e!==ct;){let l=n/e,f=n%e,u=s-i*l,h=o-a*l;n=e,e=f,s=i,o=a,i=u,a=h}if(n!==J)throw new Error("invert: does not exist");return Y(s,t)}function Bf(r){let t=(r-J)/Ve,e,n,s;for(e=r-J,n=0;e%Ve===ct;e/=Ve,n++);for(s=Ve;s<r&&Ef(s,t,r)!==r-J;s++);if(n===1){let i=(r+J)/no;return function(c,l){let f=c.pow(l,i);if(!c.eql(c.sqr(f),l))throw new Error("Cannot find square root");return f}}let o=(e+J)/Ve;return function(a,c){if(a.pow(c,t)===a.neg(a.ONE))throw new Error("Cannot find square root");let l=n,f=a.pow(a.mul(a.ONE,s),e),u=a.pow(c,o),h=a.pow(c,e);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let m=1;for(let d=a.sqr(h);m<l&&!a.eql(d,a.ONE);m++)d=a.sqr(d);let g=a.pow(f,J<<BigInt(l-m-1));f=a.sqr(g),u=a.mul(u,g),h=a.mul(h,f),l=m}return u}}function Af(r){if(r%no===wf){let t=(r+J)/no;return function(n,s){let o=n.pow(s,t);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%ra===ea){let t=(r-ea)/ra;return function(n,s){let o=n.mul(s,Ve),i=n.pow(o,t),a=n.mul(s,i),c=n.mul(n.mul(a,Ve),i),l=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%vf,Bf(r)}var na=(r,t)=>(Y(r,t)&J)===J,Sf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function so(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Sf.reduce((n,s)=>(n[s]="function",n),t);return Kt(r,e)}function kf(r,t,e){if(e<ct)throw new Error("Expected power > 0");if(e===ct)return r.ONE;if(e===J)return t;let n=r.ONE,s=t;for(;e>ct;)e&J&&(n=r.mul(n,s)),s=r.sqr(s),e>>=J;return n}function If(r,t){let e=new Array(t.length),n=t.reduce((o,i,a)=>r.is0(i)?o:(e[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return t.reduceRight((o,i,a)=>r.is0(i)?o:(e[a]=r.mul(o,e[a]),r.mul(o,i)),s),e}function oo(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function ln(r,t,e=!1,n={}){if(r<=ct)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=oo(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Af(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Rr(s),ZERO:ct,ONE:J,create:c=>Y(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ct<=c&&c<r},is0:c=>c===ct,isOdd:c=>(c&J)===J,neg:c=>Y(-c,r),eql:(c,l)=>c===l,sqr:c=>Y(c*c,r),add:(c,l)=>Y(c+l,r),sub:(c,l)=>Y(c-l,r),mul:(c,l)=>Y(c*l,r),pow:(c,l)=>kf(a,c,l),div:(c,l)=>Y(c*cn(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>cn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>If(a,c),cmov:(c,l,f)=>f?l:c,toBytes:c=>e?Oe(c,o):Ee(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return e?ve(c):Xt(c)}});return Object.freeze(a)}function sa(r,t){if(!r.isOdd)throw new Error("Field doesn't have isOdd");let e=r.sqrt(t);return r.isOdd(e)?r.neg(e):e}function oa(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function io(r){let t=oa(r);return t+Math.ceil(t/2)}function ia(r,t,e=!1){let n=r.length,s=oa(t),o=io(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=e?Xt(r):ve(r),a=Y(i,t-J)+J;return e?Oe(a,s):Ee(a,s)}var Nf=BigInt(0),ao=BigInt(1);function un(r,t){let e=(s,o)=>{let i=o.negate();return s?i:o},n=s=>{let o=Math.ceil(t/s)+1,i=2**(s-1);return{windows:o,windowSize:i}};return{constTimeNegate:e,unsafeLadder(s,o){let i=r.ZERO,a=s;for(;o>Nf;)o&ao&&(i=i.add(a)),a=a.double(),o>>=ao;return i},precomputeWindow(s,o){let{windows:i,windowSize:a}=n(o),c=[],l=s,f=l;for(let u=0;u<i;u++){f=l,c.push(f);for(let h=1;h<a;h++)f=f.add(l),c.push(f);l=f.double()}return c},wNAF(s,o,i){let{windows:a,windowSize:c}=n(s),l=r.ZERO,f=r.BASE,u=BigInt(2**s-1),h=2**s,m=BigInt(s);for(let g=0;g<a;g++){let d=g*c,p=Number(i&u);i>>=m,p>c&&(p-=h,i+=ao);let y=d,v=d+Math.abs(p)-1,w=g%2!==0,T=p<0;p===0?f=f.add(e(w,o[y])):l=l.add(e(T,o[v]))}return{p:l,f}},wNAFCached(s,o,i,a){let c=s._WINDOW_SIZE||1,l=o.get(s);return l||(l=this.precomputeWindow(s,c),c!==1&&o.set(s,a(l))),this.wNAF(c,l,i)}}}function Nr(r){return so(r.Fp),Kt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...oo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Pt=BigInt(0),Rt=BigInt(1),fn=BigInt(2),Tf=BigInt(8),Lf={zip215:!0};function _f(r){let t=Nr(r);return Kt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function hn(r){let t=_f(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=t,l=fn<<BigInt(a*8)-Rt,f=e.create,u=t.uvRatio||((B,b)=>{try{return{isValid:!0,value:e.sqrt(B*e.inv(b))}}catch{return{isValid:!1,value:Pt}}}),h=t.adjustScalarBytes||(B=>B),m=t.domain||((B,b,k)=>{if(b.length||k)throw new Error("Contexts/pre-hash are not supported");return B}),g=B=>typeof B=="bigint"&&Pt<B,d=(B,b)=>g(B)&&g(b)&&B<b,p=B=>B===Pt||d(B,l);function y(B,b){if(d(B,b))return B;throw new Error(`Expected valid scalar < ${b}, got ${typeof B} ${B}`)}function v(B){return B===Pt?B:y(B,n)}let w=new Map;function T(B){if(!(B instanceof x))throw new Error("ExtendedPoint expected")}class x{constructor(b,k,L,_){if(this.ex=b,this.ey=k,this.ez=L,this.et=_,!p(b))throw new Error("x required");if(!p(k))throw new Error("y required");if(!p(L))throw new Error("z required");if(!p(_))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(b){if(b instanceof x)throw new Error("extended point not allowed");let{x:k,y:L}=b||{};if(!p(k)||!p(L))throw new Error("invalid affine point");return new x(k,L,Rt,f(k*L))}static normalizeZ(b){let k=e.invertBatch(b.map(L=>L.ez));return b.map((L,_)=>L.toAffine(k[_])).map(x.fromAffine)}_setWindowSize(b){this._WINDOW_SIZE=b,w.delete(this)}assertValidity(){let{a:b,d:k}=t;if(this.is0())throw new Error("bad point: ZERO");let{ex:L,ey:_,ez:V,et:F}=this,j=f(L*L),M=f(_*_),$=f(V*V),st=f($*$),Q=f(j*b),ft=f($*f(Q+M)),ht=f(st+f(k*f(j*M)));if(ft!==ht)throw new Error("bad point: equation left != right (1)");let it=f(L*_),mt=f(V*F);if(it!==mt)throw new Error("bad point: equation left != right (2)")}equals(b){T(b);let{ex:k,ey:L,ez:_}=this,{ex:V,ey:F,ez:j}=b,M=f(k*j),$=f(V*_),st=f(L*j),Q=f(F*_);return M===$&&st===Q}is0(){return this.equals(x.ZERO)}negate(){return new x(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:b}=t,{ex:k,ey:L,ez:_}=this,V=f(k*k),F=f(L*L),j=f(fn*f(_*_)),M=f(b*V),$=k+L,st=f(f($*$)-V-F),Q=M+F,ft=Q-j,ht=M-F,it=f(st*ft),mt=f(Q*ht),zt=f(st*ht),Ue=f(ft*Q);return new x(it,mt,Ue,zt)}add(b){T(b);let{a:k,d:L}=t,{ex:_,ey:V,ez:F,et:j}=this,{ex:M,ey:$,ez:st,et:Q}=b;if(k===BigInt(-1)){let pi=f((V-_)*($+M)),gi=f((V+_)*($-M)),vs=f(gi-pi);if(vs===Pt)return this.double();let mi=f(F*fn*Q),yi=f(j*fn*st),bi=yi+mi,wi=gi+pi,xi=yi-mi,ml=f(bi*vs),yl=f(wi*xi),bl=f(bi*xi),wl=f(vs*wi);return new x(ml,yl,wl,bl)}let ft=f(_*M),ht=f(V*$),it=f(j*L*Q),mt=f(F*st),zt=f((_+V)*(M+$)-ft-ht),Ue=mt-it,Br=mt+it,di=f(ht-k*ft),hl=f(zt*Ue),dl=f(Br*di),pl=f(zt*di),gl=f(Ue*Br);return new x(hl,dl,gl,pl)}subtract(b){return this.add(b.negate())}wNAF(b){return N.wNAFCached(this,w,b,x.normalizeZ)}multiply(b){let{p:k,f:L}=this.wNAF(y(b,n));return x.normalizeZ([k,L])[0]}multiplyUnsafe(b){let k=v(b);return k===Pt?R:this.equals(R)||k===Rt?this:this.equals(A)?this.wNAF(k).p:N.unsafeLadder(this,k)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return N.unsafeLadder(this,n).is0()}toAffine(b){let{ex:k,ey:L,ez:_}=this,V=this.is0();b==null&&(b=V?Tf:e.inv(_));let F=f(k*b),j=f(L*b),M=f(_*b);if(V)return{x:Pt,y:Rt};if(M!==Rt)throw new Error("invZ was invalid");return{x:F,y:j}}clearCofactor(){let{h:b}=t;return b===Rt?this:this.multiplyUnsafe(b)}static fromHex(b,k=!1){let{d:L,a:_}=t,V=e.BYTES;b=et("pointHex",b,V);let F=b.slice(),j=b[V-1];F[V-1]=j&-129;let M=ve(F);M===Pt||(k?y(M,l):y(M,e.ORDER));let $=f(M*M),st=f($-Rt),Q=f(L*$-_),{isValid:ft,value:ht}=u(st,Q);if(!ft)throw new Error("Point.fromHex: invalid y coordinate");let it=(ht&Rt)===Rt,mt=(j&128)!==0;if(!k&&ht===Pt&&mt)throw new Error("Point.fromHex: x=0 and x_0=1");return mt!==it&&(ht=f(-ht)),x.fromAffine({x:ht,y:M})}static fromPrivateKey(b){return P(b).point}toRawBytes(){let{x:b,y:k}=this.toAffine(),L=Oe(k,e.BYTES);return L[L.length-1]|=b&Rt?128:0,L}toHex(){return Jt(this.toRawBytes())}}x.BASE=new x(t.Gx,t.Gy,Rt,f(t.Gx*t.Gy)),x.ZERO=new x(Pt,Rt,Rt,Pt);let{BASE:A,ZERO:R}=x,N=un(x,a*8);function q(B){return Y(B,n)}function K(B){return q(ve(B))}function P(B){let b=a;B=et("private key",B,b);let k=et("hashed private key",o(B),2*b),L=h(k.slice(0,b)),_=k.slice(b,2*b),V=K(L),F=A.multiply(V),j=F.toRawBytes();return{head:L,prefix:_,scalar:V,point:F,pointBytes:j}}function nt(B){return P(B).pointBytes}function rt(B=new Uint8Array,...b){let k=Qt(...b);return K(o(m(k,et("context",B),!!s)))}function Nt(B,b,k={}){B=et("message",B),s&&(B=s(B));let{prefix:L,scalar:_,pointBytes:V}=P(b),F=rt(k.context,L,B),j=A.multiply(F).toRawBytes(),M=rt(k.context,j,V,B),$=q(F+M*_);v($);let st=Qt(j,Oe($,e.BYTES));return et("result",st,a*2)}let E=Lf;function I(B,b,k,L=E){let{context:_,zip215:V}=L,F=e.BYTES;B=et("signature",B,2*F),b=et("message",b),s&&(b=s(b));let j=ve(B.slice(F,2*F)),M,$,st;try{M=x.fromHex(k,V),$=x.fromHex(B.slice(0,F),V),st=A.multiplyUnsafe(j)}catch{return!1}if(!V&&M.isSmallOrder())return!1;let Q=rt(_,$.toRawBytes(),M.toRawBytes(),b);return $.add(M.multiplyUnsafe(Q)).subtract(st).clearCofactor().equals(x.ZERO)}return A._setWindowSize(8),{CURVE:t,getPublicKey:nt,sign:Nt,verify:I,ExtendedPoint:x,utils:{getExtendedPublicKey:P,randomPrivateKey:()=>i(e.BYTES),precompute(B=8,b=x.BASE){return b._setWindowSize(B),b.multiply(BigInt(3)),b}}}}var lo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),aa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ip=BigInt(0),Uf=BigInt(1),co=BigInt(2),Cf=BigInt(5),ca=BigInt(10),Df=BigInt(20),Pf=BigInt(40),la=BigInt(80);function Of(r){let t=lo,n=r*r%t*r%t,s=X(n,co,t)*n%t,o=X(s,Uf,t)*r%t,i=X(o,Cf,t)*o%t,a=X(i,ca,t)*i%t,c=X(a,Df,t)*a%t,l=X(c,Pf,t)*c%t,f=X(l,la,t)*l%t,u=X(f,la,t)*l%t,h=X(u,ca,t)*i%t;return{pow_p_5_8:X(h,co,t)*r%t,b2:n}}function Vf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Ff(r,t){let e=lo,n=Y(t*t*t,e),s=Y(n*n*t,e),o=Of(r*s).pow_p_5_8,i=Y(r*n*o,e),a=Y(t*i*i,e),c=i,l=Y(i*aa,e),f=a===r,u=a===Y(-r,e),h=a===Y(-r*aa,e);return f&&(i=c),(u||h)&&(i=l),na(i,e)&&(i=Y(-i,e)),{isValid:f||u,value:i}}var te=ln(lo,void 0,!0),uo={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:te,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:or,randomBytes:nr,adjustScalarBytes:Vf,uvRatio:Ff},ir=hn(uo);function ua(r,t,e){if(t.length>255)throw new Error("Context is too big");return rn(Js("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var Rp=hn({...uo,domain:ua}),Np=hn({...uo,domain:ua,prehash:or});var Hf=(te.ORDER+BigInt(3))/BigInt(8),Tp=te.pow(co,Hf),Lp=te.sqrt(te.neg(te.ONE)),_p=(te.ORDER-BigInt(5))/BigInt(8),Up=BigInt(486662);var Cp=sa(te,te.neg(BigInt(486664)));var Dp=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Pp=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),Op=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),Vp=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var Fp=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var ar=32,ee=64,dn=32;function fa(){let r=ir.utils.randomPrivateKey(),t=ir.getPublicKey(r);return{privateKey:ga(r,t),publicKey:t}}function ha(r){if(r.length!==dn)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let t=r,e=ir.getPublicKey(t);return{privateKey:ga(t,e),publicKey:e}}function da(r,t){let e=r.subarray(0,dn);return ir.sign(t instanceof Uint8Array?t:t.subarray(),e)}function pa(r,t,e){return ir.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}function ga(r,t){let e=new Uint8Array(ee);for(let n=0;n<dn;n++)e[n]=r[n],e[dn+n]=t[n];return e}var Bt={get(r=globalThis){let t=r.crypto;if(t==null||t.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return t}};var fo={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function ma(r){let t=r?.algorithm??"AES-GCM",e=r?.keyLength??16,n=r?.nonceLength??12,s=r?.digest??"SHA-256",o=r?.saltLength??16,i=r?.iterations??32767,a=Bt.get();e*=8;async function c(u,h){let m=a.getRandomValues(new Uint8Array(o)),g=a.getRandomValues(new Uint8Array(n)),d={name:t,iv:g};typeof h=="string"&&(h=Z(h));let p;if(h.length===0){p=await a.subtle.importKey("jwk",fo,{name:"AES-GCM"},!0,["encrypt"]);try{let v={name:"PBKDF2",salt:m,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(v,w,{name:t,length:e},!0,["encrypt"])}catch{p=await a.subtle.importKey("jwk",fo,{name:"AES-GCM"},!0,["encrypt"])}}else{let v={name:"PBKDF2",salt:m,iterations:i,hash:{name:s}},w=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);p=await a.subtle.deriveKey(v,w,{name:t,length:e},!0,["encrypt"])}let y=await a.subtle.encrypt(d,p,u);return Et([m,d.iv,new Uint8Array(y)])}async function l(u,h){let m=u.subarray(0,o),g=u.subarray(o,o+n),d=u.subarray(o+n),p={name:t,iv:g};typeof h=="string"&&(h=Z(h));let y;if(h.length===0)try{let w={name:"PBKDF2",salt:m,iterations:i,hash:{name:s}},T=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,T,{name:t,length:e},!0,["decrypt"])}catch{y=await a.subtle.importKey("jwk",fo,{name:"AES-GCM"},!0,["decrypt"])}else{let w={name:"PBKDF2",salt:m,iterations:i,hash:{name:s}},T=await a.subtle.importKey("raw",h,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,T,{name:t,length:e},!0,["decrypt"])}let v=await a.subtle.decrypt(p,y,d);return new Uint8Array(v)}return{encrypt:c,decrypt:l}}async function cr(r,t){let n=await ma().encrypt(r,t);return Os.encode(n)}var ho=new Float32Array([-0]),Be=new Uint8Array(ho.buffer);function ya(r,t,e){ho[0]=r,t[e]=Be[0],t[e+1]=Be[1],t[e+2]=Be[2],t[e+3]=Be[3]}function ba(r,t){return Be[0]=r[t],Be[1]=r[t+1],Be[2]=r[t+2],Be[3]=r[t+3],ho[0]}var po=new Float64Array([-0]),wt=new Uint8Array(po.buffer);function wa(r,t,e){po[0]=r,t[e]=wt[0],t[e+1]=wt[1],t[e+2]=wt[2],t[e+3]=wt[3],t[e+4]=wt[4],t[e+5]=wt[5],t[e+6]=wt[6],t[e+7]=wt[7]}function xa(r,t){return wt[0]=r[t],wt[1]=r[t+1],wt[2]=r[t+2],wt[3]=r[t+3],wt[4]=r[t+4],wt[5]=r[t+5],wt[6]=r[t+6],wt[7]=r[t+7],po[0]}var $f=BigInt(Number.MAX_SAFE_INTEGER),qf=BigInt(Number.MIN_SAFE_INTEGER),St=class r{lo;hi;constructor(t,e){this.lo=t|0,this.hi=e|0}toNumber(t=!1){if(!t&&this.hi>>>31>0){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(e+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(t=!1){if(t)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let e=~this.lo+1>>>0,n=~this.hi>>>0;return e===0&&(n=n+1>>>0),-(BigInt(e)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(t=!1){return this.toBigInt(t).toString()}zzEncode(){let t=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^t)>>>0,this.lo=(this.lo<<1^t)>>>0,this}zzDecode(){let t=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^t)>>>0,this.hi=(this.hi>>>1^t)>>>0,this}length(){let t=this.lo,e=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?e===0?t<16384?t<128?1:2:t<2097152?3:4:e<16384?e<128?5:6:e<2097152?7:8:n<128?9:10}static fromBigInt(t){if(t===0n)return Fe;if(t<$f&&t>qf)return this.fromNumber(Number(t));let e=t<0n;e&&(t=-t);let n=t>>32n,s=t-(n<<32n);return e&&(n=~n|0n,s=~s|0n,++s>va&&(s=0n,++n>va&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return Fe;let e=t<0;e&&(t=-t);let n=t>>>0,s=(t-n)/4294967296>>>0;return e&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(t){return typeof t=="number"?r.fromNumber(t):typeof t=="bigint"?r.fromBigInt(t):typeof t=="string"?r.fromBigInt(BigInt(t)):t.low!=null||t.high!=null?new r(t.low>>>0,t.high>>>0):Fe}},Fe=new St(0,0);Fe.toBigInt=function(){return 0n};Fe.zzEncode=Fe.zzDecode=function(){return this};Fe.length=function(){return 1};var va=4294967296n;function Ea(r){let t=0,e=0;for(let n=0;n<r.length;++n)e=r.charCodeAt(n),e<128?t+=1:e<2048?t+=2:(e&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,t+=4):t+=3;return t}function Ba(r,t,e){if(e-t<1)return"";let s,o=[],i=0,a;for(;t<e;)a=r[t++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[t++]&63:a>239&&a<365?(a=((a&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[t++]&63)<<6|r[t++]&63,i>8191&&((s??(s=[])).push(String.fromCharCode.apply(String,o)),i=0);return s!=null?(i>0&&s.push(String.fromCharCode.apply(String,o.slice(0,i))),s.join("")):String.fromCharCode.apply(String,o.slice(0,i))}function go(r,t,e){let n=e,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?t[e++]=s:s<2048?(t[e++]=s>>6|192,t[e++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,t[e++]=s>>18|240,t[e++]=s>>12&63|128,t[e++]=s>>6&63|128,t[e++]=s&63|128):(t[e++]=s>>12|224,t[e++]=s>>6&63|128,t[e++]=s&63|128);return e-n}function Ot(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function pn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var mo=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(t){this.buf=t,this.pos=0,this.len=t.length}uint32(){let t=4294967295;if(t=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(t=(t|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(t=(t|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return t;if((this.pos+=5)>this.len)throw this.pos=this.len,Ot(this,10);return t}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw Ot(this,4);return pn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ot(this,4);return pn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Ot(this,4);let t=ba(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ot(this,4);let t=xa(this.buf,this.pos);return this.pos+=8,t}bytes(){let t=this.uint32(),e=this.pos,n=this.pos+t;if(n>this.len)throw Ot(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Ba(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw Ot(this,t);this.pos+=t}else do if(this.pos>=this.len)throw Ot(this);while(this.buf[this.pos++]&128);return this}skipType(t){switch(t){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(t=this.uint32()&7)!==4;)this.skipType(t);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${t} at offset ${this.pos}`)}return this}readLongVarint(){let t=new St(0,0),e=0;if(this.len-this.pos>4){for(;e<4;++e)if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t;if(t.lo=(t.lo|(this.buf[this.pos]&127)<<28)>>>0,t.hi=(t.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return t;e=0}else{for(;e<3;++e){if(this.pos>=this.len)throw Ot(this);if(t.lo=(t.lo|(this.buf[this.pos]&127)<<e*7)>>>0,this.buf[this.pos++]<128)return t}return t.lo=(t.lo|(this.buf[this.pos++]&127)<<e*7)>>>0,t}if(this.len-this.pos>4){for(;e<5;++e)if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}else for(;e<5;++e){if(this.pos>=this.len)throw Ot(this);if(t.hi=(t.hi|(this.buf[this.pos]&127)<<e*7+3)>>>0,this.buf[this.pos++]<128)return t}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ot(this,8);let t=pn(this.buf,this.pos+=4),e=pn(this.buf,this.pos+=4);return new St(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){return this.readLongVarint().toNumber(!0)}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 yo(r){return new mo(r instanceof Uint8Array?r:r.subarray())}function re(r,t){let e=yo(r);return t.decode(e)}function bo(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return bt(i);s+i>t&&(n=bt(t),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var He=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function wo(){}var vo=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Gf=bo();function zf(r){return globalThis.Buffer!=null?bt(r):Gf(r)}var _r=class{len;head;tail;states;constructor(){this.len=0,this.head=new He(wo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new He(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Eo((t=t>>>0)<128?1:t<16384?2:t<2097152?3:t<268435456?4:5,t)).len,this}int32(t){return t<0?this._push(Tr,10,St.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=St.fromBigInt(t);return this._push(Tr,e.length(),e)}uint64Number(t){let e=St.fromNumber(t);return this._push(Tr,e.length(),e)}uint64String(t){return this.uint64(BigInt(t))}int64(t){return this.uint64(t)}int64Number(t){return this.uint64Number(t)}int64String(t){return this.uint64String(t)}sint64(t){let e=St.fromBigInt(t).zzEncode();return this._push(Tr,e.length(),e)}sint64Number(t){let e=St.fromNumber(t).zzEncode();return this._push(Tr,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(xo,1,t?1:0)}fixed32(t){return this._push(Lr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=St.fromBigInt(t);return this._push(Lr,4,e.lo)._push(Lr,4,e.hi)}fixed64Number(t){let e=St.fromNumber(t);return this._push(Lr,4,e.lo)._push(Lr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(ya,4,t)}double(t){return this._push(wa,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(xo,1,0):this.uint32(e)._push(Wf,e,t)}string(t){let e=Ea(t);return e!==0?this.uint32(e)._push(go,e,t):this._push(xo,1,0)}fork(){return this.states=new vo(this),this.head=this.tail=new He(wo,0,0),this.len=0,this}reset(){return this.states!=null?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new He(wo,0,0),this.len=0),this}ldelim(){let t=this.head,e=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=t.next,this.tail=e,this.len+=n),this}finish(){let t=this.head.next,e=zf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function xo(r,t,e){t[e]=r&255}function jf(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Eo=class extends He{next;constructor(t,e){super(jf,t,e),this.next=void 0}};function Tr(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Lr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function Wf(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(_r.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(Yf,t,r),this},_r.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Zf,t,r),this});function Yf(r,t,e){t.set(r,e)}function Zf(r,t,e){r.length<40?go(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Z(r),e)}function Bo(){return new _r}function ne(r,t){let e=Bo();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var lr;(function(r){r[r.VARINT=0]="VARINT",r[r.BIT64=1]="BIT64",r[r.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",r[r.START_GROUP=3]="START_GROUP",r[r.END_GROUP=4]="END_GROUP",r[r.BIT32=5]="BIT32"})(lr||(lr={}));function gn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function ur(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(o,i){let a=t(o);i.int32(a)},n=function(o){let i=o.int32();return t(i)};return gn("enum",lr.VARINT,e,n)}function se(r,t){return gn("message",lr.LENGTH_DELIMITED,r,t)}var pt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(pt||(pt={}));var Ao;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(Ao||(Ao={}));(function(r){r.codec=()=>ur(Ao)})(pt||(pt={}));var Ae;(function(r){let t;r.codec=()=>(t==null&&(t=se((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),pt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let s={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let i=e.uint32();switch(i>>>3){case 1:s.Type=pt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>ne(e,r.codec()),r.decode=e=>re(e,r.codec())})(Ae||(Ae={}));var Se;(function(r){let t;r.codec=()=>(t==null&&(t=se((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),pt.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let s={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let i=e.uint32();switch(i>>>3){case 1:s.Type=pt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>ne(e,r.codec()),r.decode=e=>re(e,r.codec())})(Se||(Se={}));var Ur=class{_key;constructor(t){this._key=fr(t,ar)}verify(t,e){return pa(this._key,e,t)}marshal(){return this._key}get bytes(){return Ae.encode({Type:pt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return yt(this.bytes,t.bytes)}hash(){let t=dt.digest(this.bytes);return Tt(t)?t.then(({bytes:e})=>e):t.bytes}},Me=class{_key;_publicKey;constructor(t,e){this._key=fr(t,ee),this._publicKey=fr(e,ar)}sign(t){return da(this._key,t)}get public(){return new Ur(this._publicKey)}marshal(){return this._key}get bytes(){return Se.encode({Type:pt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return yt(this.bytes,t.bytes)}async hash(){let t=dt.digest(this.bytes),e;return Tt(t)?{bytes:e}=await t:e=t.bytes,e}async id(){let t=ge.digest(this.public.bytes);return at.encode(t.bytes).substring(1)}async export(t,e="libp2p-key"){if(e==="libp2p-key")return cr(this.bytes,t);throw new U(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Jf(r){if(r.length>ee){r=fr(r,ee+ar);let n=r.subarray(0,ee),s=r.subarray(ee,r.length);return new Me(n,s)}r=fr(r,ee);let t=r.subarray(0,ee),e=r.subarray(ar);return new Me(t,e)}function Xf(r){return r=fr(r,ar),new Ur(r)}async function Qf(){let{privateKey:r,publicKey:t}=fa();return new Me(r,t)}async function Sa(r){let{privateKey:t,publicKey:e}=ha(r);return new Me(t,e)}function fr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new U(`Key must be a Uint8Array of length ${t}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function G(r,t="utf8"){let e=Qr[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(r.buffer,r.byteOffset,r.byteLength).toString("utf8"):e.encoder.encode(r).substring(1)}var Po={};lt(Po,{MAX_RSA_KEY_SIZE:()=>Gr,RsaPrivateKey:()=>mr,RsaPublicKey:()=>qr,fromJwk:()=>kh,generateKeyPair:()=>Ih,unmarshalRsaPrivateKey:()=>Co,unmarshalRsaPublicKey:()=>Sh});function Ke(r){if(isNaN(r)||r<=0)throw new U("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return nr(r)}var Ne={};lt(Ne,{exportToPem:()=>xh,importFromPem:()=>vh,jwkToPkcs1:()=>mh,jwkToPkix:()=>bh,pkcs1ToJwk:()=>gh,pkixToJwk:()=>yh});var mn=class extends er{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,tn(t);let n=be(e);if(this.iHash=t.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 s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?t.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=t.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(t){return tr(this),this.iHash.update(t),this}digestInto(t){tr(this),Zs(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){let t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));let{oHash:e,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Cr=(r,t,e)=>new mn(r,t).update(e).digest();Cr.create=(r,t)=>new mn(r,t);function th(r,t,e,n){tn(r);let s=Yi({dkLen:32,asyncTick:10},n),{c:o,dkLen:i,asyncTick:a}=s;if(Qe(o),Qe(i),Qe(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=be(t),l=be(e),f=new Uint8Array(i),u=Cr.create(r,c),h=u._cloneInto().update(l);return{c:o,dkLen:i,asyncTick:a,DK:f,PRF:u,PRFSalt:h}}function eh(r,t,e,n,s){return r.destroy(),t.destroy(),n&&n.destroy(),s.fill(0),e}async function Io(r,t,e,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:l}=th(r,t,e,n),f,u=new Uint8Array(4),h=rr(u),m=new Uint8Array(c.outputLen);for(let g=1,d=0;d<o;g++,d+=c.outputLen){let p=a.subarray(d,d+c.outputLen);h.setInt32(0,g,!1),(f=l._cloneInto(f)).update(u).digestInto(m),p.set(m.subarray(0,p.length)),await Wi(s-1,i,()=>{c._cloneInto(f).update(m).digestInto(m);for(let y=0;y<p.length;y++)p[y]^=m[y]})}return eh(c,l,a,f,m)}var H=Bs(ka());function $e(r,t){let e=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)e+=r[r.length-1-n]*Math.pow(2,t*n);return e}function ke(r,t,e=-1){let n=e,s=r,o=0,i=Math.pow(2,t);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let l=new Uint8Array(c);for(let f=a-1;f>=0;f--){let u=Math.pow(2,f*t);l[o-f-1]=Math.floor(s/u),s-=l[o-f-1]*u}return c}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function wn(...r){let t=0,e=0;for(let o of r)t+=o.length;let n=new ArrayBuffer(t),s=new Uint8Array(n);for(let o of r)s.set(o,e),e+=o.length;return s}function No(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let a=0;a<this.valueHex.byteLength;a++)e[a]=0;e[0]=r[0]&128;let n=$e(e,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)o[a]=r[a];return o[0]&=127,$e(o,8)-n}function Ia(r){let t=r<0?r*-1:r,e=128;for(let n=1;n<8;n++){if(t<=e){if(r<0){let i=e-t,a=ke(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=ke(t,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),a=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<i.byteLength;c++)o[c+1]=a[c];o[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function Ra(r,t){if(r.byteLength!==t.byteLength)return!1;let e=new Uint8Array(r),n=new Uint8Array(t);for(let s=0;s<e.length;s++)if(e[s]!==n[s])return!1;return!0}function kt(r,t){let e=r.toString(10);if(t<e.length)return"";let n=t-e.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(e)}var qg=Math.log(2);function xn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function To(r){let t=0,e=0;for(let s=0;s<r.length;s++){let o=r[s];t+=o.byteLength}let n=new Uint8Array(t);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),e),e+=o.byteLength}return n.buffer}function le(r,t,e,n){return t instanceof Uint8Array?t.byteLength?e<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):t.byteLength-e-n<0?(r.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):!0:(r.error="Wrong parameter: inputBuffer has zero length",!1):(r.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}var Pr=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return To(this.items)}},Dr=[new Uint8Array([1])],Na="0123456789";var pr="",Ft=new ArrayBuffer(0),Lo=new Uint8Array(0),Or="EndOfContent",La="OCTET STRING",_a="BIT STRING";function ue(r){var t;return t=class extends r{constructor(...n){var s;super(...n);let o=n[0]||{};this.isHexOnly=(s=o.isHexOnly)!==null&&s!==void 0?s:!1,this.valueHexView=o.valueHex?H.BufferSourceConverter.toUint8Array(o.valueHex):Lo}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,s,o){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!le(this,i,s,o))return-1;let a=s+o;return this.valueHexView=i.subarray(s,a),this.valueHexView.length?(this.blockLength=o,a):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",Ft)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var ie=class{constructor({blockLength:t=0,error:e=pr,warnings:n=[],valueBeforeDecode:s=Lo}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=H.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(t){this.valueBeforeDecodeView=new Uint8Array(t)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:H.Convert.ToHex(this.valueBeforeDecodeView)}}};ie.NAME="baseBlock";var xt=class extends ie{fromBER(t,e,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(t,e){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};xt.NAME="valueBlock";var vn=class extends ue(ie){constructor({idBlock:t={}}={}){var e,n,s,o;super(),t?(this.isHexOnly=(e=t.isHexOnly)!==null&&e!==void 0?e:!1,this.valueHexView=t.valueHex?H.BufferSourceConverter.toUint8Array(t.valueHex):Lo,this.tagClass=(n=t.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=t.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=t.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(t=!1){let e=0;switch(this.tagClass){case 1:e|=0;break;case 2:e|=64;break;case 3:e|=128;break;case 4:e|=192;break;default:return this.error="Unknown tag class",Ft}if(this.isConstructed&&(e|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!t){let o=this.tagNumber;o&=31,e|=o,s[0]=e}return s.buffer}if(!this.isHexOnly){let s=ke(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=e|31,!t){for(let c=0;c<i-1;c++)a[c+1]=o[c]|128;a[i]=o[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=e|31,!t){let s=this.valueHexView;for(let o=0;o<s.length-1;o++)n[o+1]=s[o]|128;n[this.valueHexView.byteLength]=s[s.length-1]}return n.buffer}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!le(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(o[0]&32)===32,this.isHexOnly=!1;let a=o[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,l=this.valueHexView=new Uint8Array(255),f=255;for(;o[c]&128;){if(l[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let h=new Uint8Array(f);for(let m=0;m<l.length;m++)h[m]=l[m];l=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,l[c-1]=o[c]&127;let u=new Uint8Array(c);for(let h=0;h<c;h++)u[h]=l[h];l=this.valueHexView=new Uint8Array(c),l.set(u),this.blockLength<=9?this.tagNumber=$e(l,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(this.tagClass===1&&this.isConstructed)switch(this.tagNumber){case 1:case 2:case 5:case 6:case 9:case 13:case 14:case 23:case 24:case 31:case 32:case 33:case 34:return this.error="Constructed encoding used for primitive type",-1}return e+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};vn.NAME="identificationBlock";var En=class extends ie{constructor({lenBlock:t={}}={}){var e,n,s;super(),this.isIndefiniteForm=(e=t.isIndefiniteForm)!==null&&e!==void 0?e:!1,this.longFormUsed=(n=t.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=t.length)!==null&&s!==void 0?s:0}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!le(this,s,e,n))return-1;let o=s.subarray(e,e+n);if(o.length===0)return this.error="Zero buffer length",-1;if(o[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=o[0]===128,this.isIndefiniteForm)return this.blockLength=1,e+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,e+this.blockLength;let i=o[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let a=e+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=$e(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,e+this.blockLength}toBER(t=!1){let e,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=128),e;if(this.longFormUsed){let s=ke(this.length,8);if(s.byteLength>127)return this.error="Too big length",Ft;if(e=new ArrayBuffer(s.byteLength+1),t)return e;let o=new Uint8Array(s);n=new Uint8Array(e),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return e}return e=new ArrayBuffer(1),t===!1&&(n=new Uint8Array(e),n[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};En.NAME="lengthBlock";var S={},gt=class extends ie{constructor({name:t=pr,optional:e=!1,primitiveSchema:n,...s}={},o){super(s),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new vn(s),this.lenBlock=new En(s),this.valueBlock=o?new o(s):new xt(s)}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}toBER(t,e){let n=e||new Pr;e||Ua(this);let s=this.idBlock.toBER(t);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(t,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(t);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(t);n.write(i),n.write(o)}return e?Ft:n.final()}toJSON(){let t={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(t.primitiveSchema=this.primitiveSchema.toJSON()),t}toString(t="ascii"){return t==="ascii"?this.onAsciiEncoding():H.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(t){if(this===t)return!0;if(!(t instanceof this.constructor))return!1;let e=this.toBER(),n=t.toBER();return Ra(e,n)}};gt.NAME="BaseBlock";function Ua(r){if(r instanceof S.Constructed)for(let t of r.valueBlock.value)Ua(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Bn=class extends gt{constructor({value:t=pr,...e}={},n){super(e,n),t&&this.fromString(t)}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}fromBER(t,e,n){let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.fromBuffer(this.valueBlock.valueHexView),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};Bn.NAME="BaseStringBlock";var An=class extends ue(xt){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};An.NAME="PrimitiveValueBlock";var Ca,Sn=class extends gt{constructor(t={}){super(t,An),this.idBlock.isConstructed=!1}};Ca=Sn;S.Primitive=Ca;Sn.NAME="PRIMITIVE";function uh(r,t){if(r instanceof t)return r;let e=new t;return e.idBlock=r.idBlock,e.lenBlock=r.lenBlock,e.warnings=r.warnings,e.valueBeforeDecodeView=r.valueBeforeDecodeView,e}function ss(r,t=0,e=r.length){let n=t,s=new gt({},xt),o=new ie;if(!le(o,r,t,e))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(t,t+e).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,t,e);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=a,e-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,t,e),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=a,e-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=gt;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=S.EndOfContent;break;case 1:c=S.Boolean;break;case 2:c=S.Integer;break;case 3:c=S.BitString;break;case 4:c=S.OctetString;break;case 5:c=S.Null;break;case 6:c=S.ObjectIdentifier;break;case 10:c=S.Enumerated;break;case 12:c=S.Utf8String;break;case 13:c=S.RelativeObjectIdentifier;break;case 14:c=S.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=S.Sequence;break;case 17:c=S.Set;break;case 18:c=S.NumericString;break;case 19:c=S.PrintableString;break;case 20:c=S.TeletexString;break;case 21:c=S.VideotexString;break;case 22:c=S.IA5String;break;case 23:c=S.UTCTime;break;case 24:c=S.GeneralizedTime;break;case 25:c=S.GraphicString;break;case 26:c=S.VisibleString;break;case 27:c=S.GeneralString;break;case 28:c=S.UniversalString;break;case 29:c=S.CharacterString;break;case 30:c=S.BmpString;break;case 31:c=S.DATE;break;case 32:c=S.TimeOfDay;break;case 33:c=S.DateTime;break;case 34:c=S.Duration;break;default:{let l=s.idBlock.isConstructed?new S.Constructed:new S.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?S.Constructed:S.Primitive}return s=uh(s,c),a=s.fromBER(r,t,s.lenBlock.isIndefiniteForm?e:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function gr(r){if(!r.byteLength){let t=new gt({},xt);return t.error="Input buffer has zero length",{offset:-1,result:t}}return ss(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function fh(r,t){return r?1:t}var $t=class extends xt{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);if(!le(this,s,e,n))return-1;if(this.valueBeforeDecodeView=s.subarray(e,e+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),e;let o=e;for(;fh(this.isIndefiniteForm,n)>0;){let i=ss(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Or)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Or?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new Pr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?Ft:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};$t.NAME="ConstructedValueBlock";var Da,Ie=class extends gt{constructor(t={}){super(t,$t),this.idBlock.isConstructed=!0}fromBER(t,e,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(t,e,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return s===-1?(this.error=this.valueBlock.error,s):(this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.valueBlock.error.length||(this.blockLength+=this.valueBlock.blockLength),s)}onAsciiEncoding(){let t=[];for(let n of this.valueBlock.value)t.push(n.toString("ascii").split(`
3
3
  `).map(s=>` ${s}`).join(`
4
4
  `));let e=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return t.length?`${e} :
5
5
  ${t.join(`
6
- `)}`:`${e} :`}};qa=Te;I.Constructed=qa;Te.NAME="CONSTRUCTED";var Un=class extends At{fromBER(t,e,n){return e}toBER(t){return Kt}};Un.override="EndOfContentValueBlock";var za,Pn=class extends wt{constructor(t={}){super(t,Un),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};za=Pn;I.EndOfContent=za;Pn.NAME=zr;var ja,Le=class extends wt{constructor(t={}){super(t,At),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let s=new Uint8Array(n);s[0]=5,s[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};ja=Le;I.Null=ja;Le.NAME="NULL";var Dn=class extends pe(At){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=H.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);return de(this,s,e,n)?(this.valueHexView=s.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Uo.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Dn.NAME="BooleanValueBlock";var Ga,On=class extends wt{constructor(t={}){super(t,Dn),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Ga=On;I.Boolean=Ga;On.NAME="BOOLEAN";var Vn=class extends pe(Wt){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=Wt.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==Ha)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(t,e,n),this.blockLength=n;return s}toBER(t,e){return this.isConstructed?Wt.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Vn.NAME="OctetStringValueBlock";var Wa,fe=class r extends wt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Vn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),e;if(!this.valueBlock.isConstructed){let o=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(o.byteLength){let i=hs(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Te.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return H.BufferSourceConverter.concat(t)}};Wa=fe;I.OctetString=Wa;fe.NAME=Ha;var Fn=class extends pe(Wt){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let s=-1;if(this.isConstructed){if(s=Wt.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ma)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return s}let o=H.BufferSourceConverter.toUint8Array(t);if(!de(this,o,e,n))return-1;let i=o.subarray(e,e+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=hs(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,e+n}toBER(t,e){if(this.isConstructed)return Wt.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Kt;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};Fn.NAME="BitStringValueBlock";var Ya,br=class extends wt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Fn),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Te.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let s of e)t.push(s.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Ya=br;I.BitString=Ya;br.NAME=Ma;var Za;function Ch(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l=0,h=c<i?i:c,u=0;for(let m=h;m>=0;m--,u++){switch(!0){case u<a.length:l=o[i-u]+a[c-u]+e[0];break;default:l=o[i-u]+e[0]}switch(e[0]=l/10,!0){case u>=o.length:o=kn(new Uint8Array([l%10]),o);break;default:o[i-u]=l%10}}return e[0]>0&&(o=kn(e,o)),o}function Fa(r){if(r>=Kr.length)for(let t=Kr.length;t<=r;t++){let e=new Uint8Array([0]),n=Kr[t-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+e[0]]);e[0]=o[0]/10,n[s]=o[0]%10}e[0]>0&&(n=kn(e,n)),Kr.push(n)}return Kr[r]}function Uh(r,t){let e=0,n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l,h=0;for(let u=c;u>=0;u--,h++)switch(l=o[i-h]-a[c-h]-e,!0){case l<0:e=1,o[i-h]=l+10;break;default:e=0,o[i-h]=l}if(e>0)for(let u=i-c+1;u>=0;u--,h++)if(l=o[i-h]-e,l<0)e=1,o[i-h]=l+10;else{e=0,o[i-h]=l;break}return o.slice()}var jr=class extends pe(At){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=Uo.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Da(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,s=0){let o=this.fromBER(t,e,n);if(o===-1)return o;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):s!==0&&i.length<s&&(s-i.length>1&&(s=i.length+1),this.valueHexView=i.subarray(s-i.length)),o}toDER(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let s=super.fromBER(t,e,n);return s===-1||this.setValueHex(),s}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let l=0;l<8;l++){if((s&1)===1)switch(n){case t:e=Uh(Fa(n),e),i="-";break;default:e=Ch(e,Fa(n))}n++,s>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(i+=Va.charAt(e[c]));return a===!1&&(i+=Va.charAt(0)),i}};Za=jr;jr.NAME="IntegerValueBlock";Object.defineProperty(Za.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Ja,ot=class r extends wt{constructor(t={}){super(t,jr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Rn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){Rn();let e=BigInt(t),n=new qr,s=e.toString(16).replace(/^-/,""),o=new Uint8Array(H.Convert.FromHex(s));if(e<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${H.Convert.ToHex(a)}`)+e,h=H.BufferSourceConverter.toUint8Array(H.Convert.FromHex(l.toString(16)));h[0]|=128,n.write(h)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Ja=ot;I.Integer=Ja;ot.NAME="INTEGER";var Xa,Hn=class extends ot{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Xa=Hn;I.Enumerated=Xa;Hn.NAME="ENUMERATED";var Gr=class extends pe(At){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let s=H.BufferSourceConverter.toUint8Array(t);if(!de(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=je(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){Rn();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(e.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=Ne(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Kt;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let t="";if(this.isHexOnly)t=H.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Gr.NAME="sidBlock";var Mn=class extends At{constructor({value:t=wr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Gr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.value.length===0&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t){let e=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(t);if(s.byteLength===0)return this.error=this.value[n].error,Kt;e.push(s)}return Po(e)}fromString(t){this.value=[];let e=0,n=0,s="",o=!1;do if(n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1,o){let i=this.value[0],a=0;switch(i.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(s,10);if(isNaN(c))return;i.valueDec=c+a,o=!1}else{let i=new Gr;if(s>Number.MAX_SAFE_INTEGER){Rn();let a=BigInt(s);i.valueBigInt=a}else if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,o=!0),this.value.push(i)}while(n!==-1)}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e?(s=`{${s}}`,this.value[n].isFirstSid?t=`2.{${s} - 80}`:t+=s):t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};Mn.NAME="ObjectIdentifierValueBlock";var Qa,$t=class extends wt{constructor(t={}){super(t,Mn),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Qa=$t;I.ObjectIdentifier=Qa;$t.NAME="OBJECT IDENTIFIER";var Wr=class extends pe(ue){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let s=H.BufferSourceConverter.toUint8Array(t);if(!de(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=je(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=Ne(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Kt;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let t="";return this.isHexOnly?t=H.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Wr.NAME="relativeSidBlock";var $n=class extends At{constructor({value:t=wr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Wr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t,e){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(t);if(o.byteLength===0)return this.error=this.value[s].error,Kt;n.push(o)}return Po(n)}fromString(t){this.value=[];let e=0,n=0,s="";do{n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1;let o=new Wr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(s=`{${s}}`),t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};$n.NAME="RelativeObjectIdentifierValueBlock";var tc,Kn=class extends wt{constructor(t={}){super(t,$n),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};tc=Kn;I.RelativeObjectIdentifier=tc;Kn.NAME="RelativeObjectIdentifier";var ec,ht=class extends Te{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};ec=ht;I.Sequence=ec;ht.NAME="SEQUENCE";var rc,qn=class extends Te{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};rc=qn;I.Set=rc;qn.NAME="SET";var zn=class extends pe(At){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=wr}toJSON(){return{...super.toJSON(),value:this.value}}};zn.NAME="StringValueBlock";var jn=class extends zn{};jn.NAME="SimpleStringValueBlock";var It=class extends Ln{constructor({...t}={}){super(t,jn)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,H.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);this.valueBlock.value=t}};It.NAME="SIMPLE STRING";var Gn=class extends It{fromBuffer(t){this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=H.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=H.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf8String(t)),this.valueBlock.value=t}};Gn.NAME="Utf8StringValueBlock";var nc,he=class extends Gn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};nc=he;I.Utf8String=nc;he.NAME="UTF8String";var Wn=class extends It{fromBuffer(t){this.valueBlock.value=H.Convert.ToUtf16String(t),this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf16String(t))}};Wn.NAME="BmpStringValueBlock";var sc,Yn=class extends Wn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};sc=Yn;I.BmpString=sc;Yn.NAME="BMPString";var Zn=class extends It{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);for(let s=0;s<n.length;s+=4)n[s]=n[s+3],n[s+1]=n[s+2],n[s+2]=0,n[s+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let s=0;s<e;s++){let o=Ne(t.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[s*4+c+a]=i[c]}this.valueBlock.value=t}};Zn.NAME="UniversalStringValueBlock";var oc,Jn=class extends Zn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};oc=Jn;I.UniversalString=oc;Jn.NAME="UniversalString";var ic,Xn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};ic=Xn;I.NumericString=ic;Xn.NAME="NumericString";var ac,Qn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};ac=Qn;I.PrintableString=ac;Qn.NAME="PrintableString";var cc,ts=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};cc=ts;I.TeletexString=cc;ts.NAME="TeletexString";var lc,es=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};lc=es;I.VideotexString=lc;es.NAME="VideotexString";var uc,rs=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};uc=rs;I.IA5String=uc;rs.NAME="IA5String";var fc,ns=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};fc=ns;I.GraphicString=fc;ns.NAME="GraphicString";var hc,Yr=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};hc=Yr;I.VisibleString=hc;Yr.NAME="VisibleString";var dc,ss=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};dc=ss;I.GeneralString=dc;ss.NAME="GeneralString";var pc,os=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};pc=os;I.CharacterString=pc;os.NAME="CharacterString";var gc,Zr=class extends Yr{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let s=0;s<t.length;s++)this.valueBlock.valueHexView[s]=t.charCodeAt(s)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,H.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);if(n===null){this.error="Wrong input string for conversion";return}let s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=kt(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=kt(this.month,2),e[2]=kt(this.day,2),e[3]=kt(this.hour,2),e[4]=kt(this.minute,2),e[5]=kt(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};gc=Zr;I.UTCTime=gc;Zr.NAME="UTCTime";var mc,is=class extends Zr{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",s="",o=0,i,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let u=new Number(t[t.length-1]);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let u=1,m=n.indexOf("+"),f="";if(m===-1&&(m=n.indexOf("-"),u=-1),m!==-1){if(f=n.substring(m+1),n=n.substring(0,m),f.length!==2&&f.length!==4)throw new Error("Wrong input string for conversion");let p=parseInt(f.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(a=u*p,f.length===4){if(p=parseInt(f.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");c=u*p}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let u=new Number(`0${n.substring(l)}`);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");o=u.valueOf(),s=n.substring(0,l)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=60*o;this.minute=Math.floor(u),u=60*(u-this.minute),this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=60*o;this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=1e3*o;this.millisecond=Math.floor(u)}break;default:throw new Error("Wrong input string for conversion")}let h=i.exec(s);if(h===null)throw new Error("Wrong input string for conversion");for(let u=1;u<h.length;u++)switch(u){case 1:this.year=parseInt(h[u],10);break;case 2:this.month=parseInt(h[u],10);break;case 3:this.day=parseInt(h[u],10);break;case 4:this.hour=parseInt(h[u],10)+a;break;case 5:this.minute=parseInt(h[u],10)+c;break;case 6:this.second=parseInt(h[u],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let u=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=u.getUTCFullYear(),this.month=u.getUTCMonth(),this.day=u.getUTCDay(),this.hour=u.getUTCHours(),this.minute=u.getUTCMinutes(),this.second=u.getUTCSeconds(),this.millisecond=u.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(kt(this.year,4)),e.push(kt(this.month,2)),e.push(kt(this.day,2)),e.push(kt(this.hour,2)),e.push(kt(this.minute,2)),e.push(kt(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(kt(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};mc=is;I.GeneralizedTime=mc;is.NAME="GeneralizedTime";var yc,as=class extends he{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};yc=as;I.DATE=yc;as.NAME="DATE";var bc,cs=class extends he{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};bc=cs;I.TimeOfDay=bc;cs.NAME="TimeOfDay";var wc,ls=class extends he{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};wc=ls;I.DateTime=wc;ls.NAME="DateTime";var xc,us=class extends he{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};xc=us;I.Duration=xc;us.NAME="Duration";var vc,fs=class extends he{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};vc=fs;I.TIME=vc;fs.NAME="TIME";function Dh(r){let{result:t}=xr(r),e=t.valueBlock.value;return{n:q(Yt(e[1].toBigInt()),"base64url"),e:q(Yt(e[2].toBigInt()),"base64url"),d:q(Yt(e[3].toBigInt()),"base64url"),p:q(Yt(e[4].toBigInt()),"base64url"),q:q(Yt(e[5].toBigInt()),"base64url"),dp:q(Yt(e[6].toBigInt()),"base64url"),dq:q(Yt(e[7].toBigInt()),"base64url"),qi:q(Yt(e[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Oh(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new _("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ht({value:[new ot({value:0}),ot.fromBigInt(Zt(Z(r.n,"base64url"))),ot.fromBigInt(Zt(Z(r.e,"base64url"))),ot.fromBigInt(Zt(Z(r.d,"base64url"))),ot.fromBigInt(Zt(Z(r.p,"base64url"))),ot.fromBigInt(Zt(Z(r.q,"base64url"))),ot.fromBigInt(Zt(Z(r.dp,"base64url"))),ot.fromBigInt(Zt(Z(r.dq,"base64url"))),ot.fromBigInt(Zt(Z(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Vh(r){let{result:t}=xr(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:q(Yt(e[0].toBigInt()),"base64url"),e:q(Yt(e[1].toBigInt()),"base64url")}}function Fh(r){if(r.n==null||r.e==null)throw new _("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ht({value:[new ht({value:[new $t({value:"1.2.840.113549.1.1.1"}),new Le]}),new br({valueHex:new ht({value:[ot.fromBigInt(Zt(Z(r.n,"base64url"))),ot.fromBigInt(Zt(Z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Yt(r){let t=r.toString(16);t.length%2>0&&(t=`0${t}`);let e=t.length/2,n=new Uint8Array(e),s=0,o=0;for(;s<e;)n[s]=parseInt(t.slice(o,o+2),16),s+=1,o+=2;return n}function Zt(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}var Hh=16,Oo=32,Vo=1e4;async function Mh(r,t){let e=bt.get(),s=new ht({value:[new ot({value:0}),new ht({value:[new $t({value:"1.2.840.113549.1.1.1"}),new Le]}),new fe({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=ze(Hh),a=await _o(lr,t,i,{c:Vo,dkLen:Oo}),c=ze(16),l=await e.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),h=await e.subtle.encrypt({name:"AES-CBC",iv:c},l,o),u=new ht({value:[new fe({valueHex:i}),new ot({value:Vo}),new ot({value:Oo}),new ht({value:[new $t({value:"1.2.840.113549.2.11"}),new Le]})]}),m=new ht({value:[new $t({value:"1.2.840.113549.1.5.13"}),new ht({value:[new ht({value:[new $t({value:"1.2.840.113549.1.5.12"}),u]}),new ht({value:[new $t({value:"2.16.840.1.101.3.4.1.42"}),new fe({valueHex:c})]})]})]}),p=new ht({value:[m,new fe({valueHex:h})]}).toBER(),d=new Uint8Array(p,0,p.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...q(d,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
7
- `)}async function Ac(r,t){let e=bt.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=Z(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=xr(s),{iv:i,salt:a,iterations:c,keySize:l,cipherText:h}=$h(o),u=await _o(lr,t,a,{c,dkLen:l}),m=await e.subtle.importKey("raw",u,"AES-CBC",!1,["decrypt"]),f=Jr(await e.subtle.decrypt({name:"AES-CBC",iv:i},m,h)),{result:p}=xr(f);n=Ec(p)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=Z(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=xr(s);n=Ec(o)}else throw new _("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Fo(n)}function $h(r){let t=r.valueBlock.value[0];if(t.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new _("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=t.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new _("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let o=n.valueBlock.value[1],i=Jr(o.valueBlock.value[0].getValue()),a=Vo,c=Oo;if(o.valueBlock.value.length===3)a=Number(o.valueBlock.value[1].toBigInt()),c=Number(o.valueBlock.value[2].toBigInt());else if(o.valueBlock.value.length===2)throw new _("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let l=t.valueBlock.value[1].valueBlock.value[1],h=l.valueBlock.value[0].toString();if(h!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(h!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(h!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(h!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(h!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new _("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let u=Jr(l.valueBlock.value[1].getValue());return{cipherText:Jr(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:u}}function Ec(r){return Jr(r.valueBlock.value[2].getValue())}function Jr(r){return new Uint8Array(r,0,r.byteLength)}async function Bc(r){let t=await bt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await kc(t);return{privateKey:e[0],publicKey:e[1]}}async function Ho(r){let e=[await bt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Kh(r)],n=await kc({privateKey:e[0],publicKey:e[1]});return{privateKey:n[0],publicKey:n[1]}}async function Ic(r,t){let e=await bt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await bt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Sc(r,t,e){let n=await bt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return bt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function kc(r){if(r.privateKey==null||r.publicKey==null)throw new _("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([bt.get().subtle.exportKey("jwk",r.privateKey),bt.get().subtle.exportKey("jwk",r.publicKey)])}async function Kh(r){return bt.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function ds(r){if(r.kty!=="RSA")throw new _("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new _("invalid key modulus","ERR_INVALID_KEY_MODULUS");return Z(r.n,"base64url").length*8}var Er=8192,vr=class{_key;constructor(t){this._key=t}verify(t,e){return Sc(this._key,e,t)}marshal(){return _e.jwkToPkix(this._key)}get bytes(){return ae.encode({Type:ft.RSA,Data:this.marshal()}).subarray()}equals(t){return mt(this.bytes,t.bytes)}hash(){let t=gt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}},Ge=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e}genSecret(){return ze(16)}sign(t){return Ic(this._key,t)}get public(){if(this._publicKey==null)throw new _("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new vr(this._publicKey)}marshal(){return _e.jwkToPkcs1(this._key)}get bytes(){return ce.encode({Type:ft.RSA,Data:this.marshal()}).subarray()}equals(t){return mt(this.bytes,t.bytes)}hash(){let t=gt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return q(t,"base58btc")}async export(t,e="pkcs-8"){if(e==="pkcs-8")return _e.exportToPem(this,t);if(e==="libp2p-key")return hr(this.bytes,t);throw new _(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Fo(r){let t=_e.pkcs1ToJwk(r);if(ds(t)>Er)throw new _("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Ho(t);return new Ge(e.privateKey,e.publicKey)}function zh(r){let t=_e.pkixToJwk(r);if(ds(t)>Er)throw new _("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new vr(t)}async function jh(r){if(ds(r)>Er)throw new _("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Ho(r);return new Ge(t.privateKey,t.publicKey)}async function Gh(r){if(r>Er)throw new _("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Bc(r);return new Ge(t.privateKey,t.publicKey)}var jo={};ut(jo,{Secp256k1PrivateKey:()=>Br,Secp256k1PublicKey:()=>Ar,generateKeyPair:()=>cd,unmarshalSecp256k1PrivateKey:()=>id,unmarshalSecp256k1PublicKey:()=>ad});var Wh=(r,t,e)=>r&t^~r&e,Yh=(r,t,e)=>r&t^r&e^t&e,Zh=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Ce=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ue=new Uint32Array(64),$o=class extends cr{constructor(){super(64,32,8,!1),this.A=Ce[0]|0,this.B=Ce[1]|0,this.C=Ce[2]|0,this.D=Ce[3]|0,this.E=Ce[4]|0,this.F=Ce[5]|0,this.G=Ce[6]|0,this.H=Ce[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[t,e,n,s,o,i,a,c]}set(t,e,n,s,o,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let u=0;u<16;u++,e+=4)Ue[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let m=Ue[u-15],f=Ue[u-2],p=Pt(m,7)^Pt(m,18)^m>>>3,d=Pt(f,17)^Pt(f,19)^f>>>10;Ue[u]=d+Ue[u-7]+p+Ue[u-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:l,H:h}=this;for(let u=0;u<64;u++){let m=Pt(a,6)^Pt(a,11)^Pt(a,25),f=h+m+Wh(a,c,l)+Zh[u]+Ue[u]|0,d=(Pt(n,2)^Pt(n,13)^Pt(n,22))+Yh(n,s,o)|0;h=l,l=c,c=a,a=i+f|0,i=o,o=s,s=n,n=f+d|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,h=h+this.H|0,this.set(n,s,o,i,a,c,l,h)}roundClean(){Ue.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Rc=fn(()=>new $o);function Jh(r){let t=Vr(r);Gt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:s}=t;if(e){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:Xh,hexToBytes:Qh}=pn,We={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=We;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Xh(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=We,e=typeof r=="string"?Qh(r):r;if(!Dt(e))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:s,l:o}=We._parseInt(e.subarray(2)),{d:i,l:a}=We._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){let t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,e=l=>{let h=l.toString(16);return h.length&1?`0${h}`:h},n=t(e(r.s)),s=t(e(r.r)),o=n.length/2,i=s.length/2,a=e(o),c=e(i);return`30${e(i+o+4)}02${c}${s}02${a}${n}`}},ge=BigInt(0),Ct=BigInt(1),Xy=BigInt(2),Nc=BigInt(3),Qy=BigInt(4);function td(r){let t=Jh(r),{Fp:e}=t,n=t.toBytes||((p,d,g)=>{let y=d.toAffine();return se(Uint8Array.from([4]),e.toBytes(y.x),e.toBytes(y.y))}),s=t.fromBytes||(p=>{let d=p.subarray(1),g=e.fromBytes(d.subarray(0,e.BYTES)),y=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:g,y}});function o(p){let{a:d,b:g}=t,y=e.sqr(p),b=e.mul(y,p);return e.add(e.add(b,e.mul(p,d)),g)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function i(p){return typeof p=="bigint"&&ge<p&&p<t.n}function a(p){if(!i(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(p){let{allowedPrivateKeyLengths:d,nByteLength:g,wrapPrivateKey:y,n:b}=t;if(d&&typeof p!="bigint"){if(Dt(p)&&(p=re(p)),typeof p!="string"||!d.includes(p.length))throw new Error("Invalid key");p=p.padStart(g*2,"0")}let w;try{w=typeof p=="bigint"?p:ne(et("private key",p,g))}catch{throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof p}`)}return y&&(w=Y(w,b)),a(w),w}let l=new Map;function h(p){if(!(p instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,g,y){if(this.px=d,this.py=g,this.pz=y,d==null||!e.isValid(d))throw new Error("x required");if(g==null||!e.isValid(g))throw new Error("y required");if(y==null||!e.isValid(y))throw new Error("z required")}static fromAffine(d){let{x:g,y}=d||{};if(!d||!e.isValid(g)||!e.isValid(y))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");let b=w=>e.eql(w,e.ZERO);return b(g)&&b(y)?u.ZERO:new u(g,y,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let g=e.invertBatch(d.map(y=>y.pz));return d.map((y,b)=>y.toAffine(g[b])).map(u.fromAffine)}static fromHex(d){let g=u.fromAffine(s(et("pointHex",d)));return g.assertValidity(),g}static fromPrivateKey(d){return u.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:d,y:g}=this.toAffine();if(!e.isValid(d)||!e.isValid(g))throw new Error("bad point: x or y not FE");let y=e.sqr(g),b=o(d);if(!e.eql(y,b))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){h(d);let{px:g,py:y,pz:b}=this,{px:w,py:k,pz:v}=d,B=e.eql(e.mul(g,v),e.mul(w,b)),N=e.eql(e.mul(y,v),e.mul(k,b));return B&&N}negate(){return new u(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:g}=t,y=e.mul(g,Nc),{px:b,py:w,pz:k}=this,v=e.ZERO,B=e.ZERO,N=e.ZERO,T=e.mul(b,b),z=e.mul(w,w),$=e.mul(k,k),D=e.mul(b,w);return D=e.add(D,D),N=e.mul(b,k),N=e.add(N,N),v=e.mul(d,N),B=e.mul(y,$),B=e.add(v,B),v=e.sub(z,B),B=e.add(z,B),B=e.mul(v,B),v=e.mul(D,v),N=e.mul(y,N),$=e.mul(d,$),D=e.sub(T,$),D=e.mul(d,D),D=e.add(D,N),N=e.add(T,T),T=e.add(N,T),T=e.add(T,$),T=e.mul(T,D),B=e.add(B,T),$=e.mul(w,k),$=e.add($,$),T=e.mul($,D),v=e.sub(v,T),N=e.mul($,z),N=e.add(N,N),N=e.add(N,N),new u(v,B,N)}add(d){h(d);let{px:g,py:y,pz:b}=this,{px:w,py:k,pz:v}=d,B=e.ZERO,N=e.ZERO,T=e.ZERO,z=t.a,$=e.mul(t.b,Nc),D=e.mul(g,w),nt=e.mul(y,k),rt=e.mul(b,v),Tt=e.add(g,y),E=e.add(w,k);Tt=e.mul(Tt,E),E=e.add(D,nt),Tt=e.sub(Tt,E),E=e.add(g,b);let R=e.add(w,v);return E=e.mul(E,R),R=e.add(D,rt),E=e.sub(E,R),R=e.add(y,b),B=e.add(k,v),R=e.mul(R,B),B=e.add(nt,rt),R=e.sub(R,B),T=e.mul(z,E),B=e.mul($,rt),T=e.add(B,T),B=e.sub(nt,T),T=e.add(nt,T),N=e.mul(B,T),nt=e.add(D,D),nt=e.add(nt,D),rt=e.mul(z,rt),E=e.mul($,E),nt=e.add(nt,rt),rt=e.sub(D,rt),rt=e.mul(z,rt),E=e.add(E,rt),D=e.mul(nt,E),N=e.add(N,D),D=e.mul(R,E),B=e.mul(Tt,B),B=e.sub(B,D),D=e.mul(Tt,nt),T=e.mul(R,T),T=e.add(T,D),new u(B,N,T)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return f.wNAFCached(this,l,d,g=>{let y=e.invertBatch(g.map(b=>b.pz));return g.map((b,w)=>b.toAffine(y[w])).map(u.fromAffine)})}multiplyUnsafe(d){let g=u.ZERO;if(d===ge)return g;if(a(d),d===Ct)return this;let{endo:y}=t;if(!y)return f.unsafeLadder(this,d);let{k1neg:b,k1:w,k2neg:k,k2:v}=y.splitScalar(d),B=g,N=g,T=this;for(;w>ge||v>ge;)w&Ct&&(B=B.add(T)),v&Ct&&(N=N.add(T)),T=T.double(),w>>=Ct,v>>=Ct;return b&&(B=B.negate()),k&&(N=N.negate()),N=new u(e.mul(N.px,y.beta),N.py,N.pz),B.add(N)}multiply(d){a(d);let g=d,y,b,{endo:w}=t;if(w){let{k1neg:k,k1:v,k2neg:B,k2:N}=w.splitScalar(g),{p:T,f:z}=this.wNAF(v),{p:$,f:D}=this.wNAF(N);T=f.constTimeNegate(k,T),$=f.constTimeNegate(B,$),$=new u(e.mul($.px,w.beta),$.py,$.pz),y=T.add($),b=z.add(D)}else{let{p:k,f:v}=this.wNAF(g);y=k,b=v}return u.normalizeZ([y,b])[0]}multiplyAndAddUnsafe(d,g,y){let b=u.BASE,w=(v,B)=>B===ge||B===Ct||!v.equals(b)?v.multiplyUnsafe(B):v.multiply(B),k=w(this,g).add(w(d,y));return k.is0()?void 0:k}toAffine(d){let{px:g,py:y,pz:b}=this,w=this.is0();d==null&&(d=w?e.ONE:e.inv(b));let k=e.mul(g,d),v=e.mul(y,d),B=e.mul(b,d);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(B,e.ONE))throw new Error("invZ was invalid");return{x:k,y:v}}isTorsionFree(){let{h:d,isTorsionFree:g}=t;if(d===Ct)return!0;if(g)return g(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:g}=t;return d===Ct?this:g?g(u,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return this.assertValidity(),n(u,this,d)}toHex(d=!0){return re(this.toRawBytes(d))}}u.BASE=new u(t.Gx,t.Gy,e.ONE),u.ZERO=new u(e.ZERO,e.ONE,e.ZERO);let m=t.nBitLength,f=yn(u,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function ed(r){let t=Vr(r);return Gt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Tc(r){let t=ed(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return ge<E&&E<e.ORDER}function a(E){return Y(E,n)}function c(E){return gn(E,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:m}=td({...t,toBytes(E,R,O){let A=R.toAffine(),x=e.toBytes(A.x),S=se;return O?S(Uint8Array.from([R.hasEvenY()?2:3]),x):S(Uint8Array.from([4]),x,e.toBytes(A.y))},fromBytes(E){let R=E.length,O=E[0],A=E.subarray(1);if(R===s&&(O===2||O===3)){let x=ne(A);if(!i(x))throw new Error("Point is not on curve");let S=u(x),L=e.sqrt(S),C=(L&Ct)===Ct;return(O&1)===1!==C&&(L=e.neg(L)),{x,y:L}}else if(R===o&&O===4){let x=e.fromBytes(A.subarray(0,e.BYTES)),S=e.fromBytes(A.subarray(e.BYTES,2*e.BYTES));return{x,y:S}}else throw new Error(`Point of length ${R} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),f=E=>re(Se(E,t.nByteLength));function p(E){let R=n>>Ct;return E>R}function d(E){return p(E)?a(-E):E}let g=(E,R,O)=>ne(E.slice(R,O));class y{constructor(R,O,A){this.r=R,this.s=O,this.recovery=A,this.assertValidity()}static fromCompact(R){let O=t.nByteLength;return R=et("compactSignature",R,O*2),new y(g(R,0,O),g(R,O,2*O))}static fromDER(R){let{r:O,s:A}=We.toSig(et("DER",R));return new y(O,A)}assertValidity(){if(!m(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!m(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(R){return new y(this.r,this.s,R)}recoverPublicKey(R){let{r:O,s:A,recovery:x}=this,S=N(et("msgHash",R));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let L=x===2||x===3?O+t.n:O;if(L>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let C=x&1?"03":"02",V=l.fromHex(C+f(L)),F=c(L),G=a(-S*F),M=a(A*F),K=l.BASE.multiplyAndAddUnsafe(V,G,M);if(!K)throw new Error("point at infinify");return K.assertValidity(),K}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return He(this.toDERHex())}toDERHex(){return We.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return He(this.toCompactHex())}toCompactHex(){return f(this.r)+f(this.s)}}let b={isValidPrivateKey(E){try{return h(E),!0}catch{return!1}},normPrivateKeyToScalar:h,randomPrivateKey:()=>{let E=fo(t.n);return ga(t.randomBytes(E),t.n)},precompute(E=8,R=l.BASE){return R._setWindowSize(E),R.multiply(BigInt(3)),R}};function w(E,R=!0){return l.fromPrivateKey(E).toRawBytes(R)}function k(E){let R=Dt(E),O=typeof E=="string",A=(R||O)&&E.length;return R?A===s||A===o:O?A===2*s||A===2*o:E instanceof l}function v(E,R,O=!0){if(k(E))throw new Error("first arg must be private key");if(!k(R))throw new Error("second arg must be public key");return l.fromHex(R).multiply(h(E)).toRawBytes(O)}let B=t.bits2int||function(E){let R=ne(E),O=E.length*8-t.nBitLength;return O>0?R>>BigInt(O):R},N=t.bits2int_modN||function(E){return a(B(E))},T=Or(t.nBitLength);function z(E){if(typeof E!="bigint")throw new Error("bigint expected");if(!(ge<=E&&E<T))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Se(E,t.nByteLength)}function $(E,R,O=D){if(["recovered","canonical"].some(Q=>Q in O))throw new Error("sign() legacy options not supported");let{hash:A,randomBytes:x}=t,{lowS:S,prehash:L,extraEntropy:C}=O;S==null&&(S=!0),E=et("msgHash",E),L&&(E=et("prehashed msgHash",A(E)));let V=N(E),F=h(R),G=[z(F),z(V)];if(C!=null){let Q=C===!0?x(e.BYTES):C;G.push(et("extraEntropy",Q))}let M=se(...G),K=V;function st(Q){let dt=B(Q);if(!m(dt))return;let pt=c(dt),at=l.BASE.multiply(dt).toAffine(),xt=a(at.x);if(xt===ge)return;let Jt=a(pt*a(K+xt*F));if(Jt===ge)return;let Oe=(at.x===xt?0:2)|Number(at.y&Ct),_r=Jt;return S&&p(Jt)&&(_r=d(Jt),Oe^=1),new y(xt,_r,Oe)}return{seed:M,k2sig:st}}let D={lowS:t.lowS,prehash:!1},nt={lowS:t.lowS,prehash:!1};function rt(E,R,O=D){let{seed:A,k2sig:x}=$(E,R,O),S=t;return ao(S.hash.outputLen,S.nByteLength,S.hmac)(A,x)}l.BASE._setWindowSize(8);function Tt(E,R,O,A=nt){let x=E;if(R=et("msgHash",R),O=et("publicKey",O),"strict"in A)throw new Error("options.strict was renamed to lowS");let{lowS:S,prehash:L}=A,C,V;try{if(typeof x=="string"||Dt(x))try{C=y.fromDER(x)}catch(at){if(!(at instanceof We.Err))throw at;C=y.fromCompact(x)}else if(typeof x=="object"&&typeof x.r=="bigint"&&typeof x.s=="bigint"){let{r:at,s:xt}=x;C=new y(at,xt)}else throw new Error("PARSE");V=l.fromHex(O)}catch(at){if(at.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(S&&C.hasHighS())return!1;L&&(R=t.hash(R));let{r:F,s:G}=C,M=N(R),K=c(G),st=a(M*K),Q=a(F*K),dt=l.BASE.multiplyAndAddUnsafe(V,st,Q)?.toAffine();return dt?a(dt.x)===F:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:v,sign:rt,verify:Tt,ProjectivePoint:l,Signature:y,utils:b}}function rd(r){return{hash:r,hmac:(t,...e)=>$r(r,t,un(...e)),randomBytes:ar}}function Lc(r,t){let e=n=>Tc({...r,...rd(n)});return Object.freeze({...e(t),create:e})}var Uc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),_c=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),nd=BigInt(1),Ko=BigInt(2),Cc=(r,t)=>(r+t/Ko)/t;function sd(r){let t=Uc,e=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,h=l*l*r%t,u=X(h,e,t)*h%t,m=X(u,e,t)*h%t,f=X(m,Ko,t)*l%t,p=X(f,s,t)*f%t,d=X(p,o,t)*p%t,g=X(d,a,t)*d%t,y=X(g,c,t)*g%t,b=X(y,a,t)*d%t,w=X(b,e,t)*h%t,k=X(w,i,t)*p%t,v=X(k,n,t)*l%t,B=X(v,Ko,t);if(!qo.eql(qo.sqr(B),r))throw new Error("Cannot find square root");return B}var qo=mn(Uc,void 0,void 0,{sqrt:sd}),qt=Lc({a:BigInt(0),b:BigInt(7),Fp:qo,n:_c,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=_c,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-nd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),a=Cc(o*r,t),c=Cc(-n*r,t),l=Y(r-a*e-c*s,t),h=Y(-a*n-c*o,t),u=l>i,m=h>i;if(u&&(l=t-l),m&&(h=t-h),l>i||h>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:l,k2neg:m,k2:h}}}},Rc),cb=BigInt(0);var lb=qt.ProjectivePoint;function Pc(){return qt.utils.randomPrivateKey()}function Dc(r,t){let e=gt.digest(t instanceof Uint8Array?t:t.subarray());if(Lt(e))return e.then(({digest:n})=>qt.sign(n,r).toDERRawBytes()).catch(n=>{throw new _(String(n),"ERR_INVALID_INPUT")});try{return qt.sign(e.digest,r).toDERRawBytes()}catch(n){throw new _(String(n),"ERR_INVALID_INPUT")}}function Oc(r,t,e){let n=gt.digest(e instanceof Uint8Array?e:e.subarray());if(Lt(n))return n.then(({digest:s})=>qt.verify(t,s,r)).catch(s=>{throw new _(String(s),"ERR_INVALID_INPUT")});try{return qt.verify(t,n.digest,r)}catch(s){throw new _(String(s),"ERR_INVALID_INPUT")}}function Vc(r){return qt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Fc(r){try{qt.getPublicKey(r,!0)}catch(t){throw new _(String(t),"ERR_INVALID_PRIVATE_KEY")}}function zo(r){try{qt.ProjectivePoint.fromHex(r)}catch(t){throw new _(String(t),"ERR_INVALID_PUBLIC_KEY")}}function Hc(r){try{return qt.getPublicKey(r,!0)}catch(t){throw new _(String(t),"ERR_INVALID_PRIVATE_KEY")}}var Ar=class{_key;constructor(t){zo(t),this._key=t}verify(t,e){return Oc(this._key,e,t)}marshal(){return Vc(this._key)}get bytes(){return ae.encode({Type:ft.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return mt(this.bytes,t.bytes)}async hash(){let t=gt.digest(this.bytes),e;return Lt(t)?{bytes:e}=await t:e=t.bytes,e}},Br=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e??Hc(t),Fc(this._key),zo(this._publicKey)}sign(t){return Dc(this._key,t)}get public(){return new Ar(this._publicKey)}marshal(){return this._key}get bytes(){return ce.encode({Type:ft.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return mt(this.bytes,t.bytes)}hash(){let t=gt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return q(t,"base58btc")}async export(t,e="libp2p-key"){if(e==="libp2p-key")return hr(this.bytes,t);throw new _(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function id(r){return new Br(r)}function ad(r){return new Ar(r)}async function cd(){let r=Pc();return new Br(r)}var Mc={rsa:Mo,ed25519:Lo,secp256k1:jo};function ld(r){let t=Object.keys(Mc).join(" / ");return new _(`invalid or unsupported key type ${r}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Go(r){if(r=r.toLowerCase(),r==="rsa"||r==="ed25519"||r==="secp256k1")return Mc[r];throw ld(r)}async function $c(r,t){return Go(r).generateKeyPair(t??2048)}function Kc(r,t){return t=(t??"rsa").toLowerCase(),Go(t),r.bytes}function qc(r,t){return t=(t??"rsa").toLowerCase(),Go(t),r.bytes}var Wo;(function(r){let t;r.codec=()=>(t==null&&(t=Mt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.id!=null&&(n.uint32(10),n.bytes(e.id)),e.pubKey!=null&&(n.uint32(18),n.bytes(e.pubKey)),e.privKey!=null&&(n.uint32(26),n.bytes(e.privKey)),s.lengthDelimited!==!1&&n.ldelim()},(e,n)=>{let s={},o=n==null?e.len:e.pos+n;for(;e.pos<o;){let i=e.uint32();switch(i>>>3){case 1:s.id=e.bytes();break;case 2:s.pubKey=e.bytes();break;case 3:s.privKey=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>Ht(e,r.codec()),r.decode=e=>Ft(e,r.codec())})(Wo||(Wo={}));var zc=async()=>{let r=await $c("Ed25519"),t=await ud(r);if(t.type==="Ed25519")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function ud(r){return Xi(Kc(r.public),qc(r))}var fd=Math.pow(2,7),hd=Math.pow(2,14),dd=Math.pow(2,21),Yo=Math.pow(2,28),Zo=Math.pow(2,35),Jo=Math.pow(2,42),Xo=Math.pow(2,49),j=128,Bt=127;function Rt(r){if(r<fd)return 1;if(r<hd)return 2;if(r<dd)return 3;if(r<Yo)return 4;if(r<Zo)return 5;if(r<Jo)return 6;if(r<Xo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function pd(r,t,e=0){switch(Rt(r)){case 8:t[e++]=r&255|j,r/=128;case 7:t[e++]=r&255|j,r/=128;case 6:t[e++]=r&255|j,r/=128;case 5:t[e++]=r&255|j,r/=128;case 4:t[e++]=r&255|j,r>>>=7;case 3:t[e++]=r&255|j,r>>>=7;case 2:t[e++]=r&255|j,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function gd(r,t,e=0){switch(Rt(r)){case 8:t.set(e++,r&255|j),r/=128;case 7:t.set(e++,r&255|j),r/=128;case 6:t.set(e++,r&255|j),r/=128;case 5:t.set(e++,r&255|j),r/=128;case 4:t.set(e++,r&255|j),r>>>=7;case 3:t.set(e++,r&255|j),r>>>=7;case 2:t.set(e++,r&255|j),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function md(r,t){let e=r[t],n=0;if(n+=e&Bt,e<j||(e=r[t+1],n+=(e&Bt)<<7,e<j)||(e=r[t+2],n+=(e&Bt)<<14,e<j)||(e=r[t+3],n+=(e&Bt)<<21,e<j)||(e=r[t+4],n+=(e&Bt)*Yo,e<j)||(e=r[t+5],n+=(e&Bt)*Zo,e<j)||(e=r[t+6],n+=(e&Bt)*Jo,e<j)||(e=r[t+7],n+=(e&Bt)*Xo,e<j))return n;throw new RangeError("Could not decode varint")}function yd(r,t){let e=r.get(t),n=0;if(n+=e&Bt,e<j||(e=r.get(t+1),n+=(e&Bt)<<7,e<j)||(e=r.get(t+2),n+=(e&Bt)<<14,e<j)||(e=r.get(t+3),n+=(e&Bt)<<21,e<j)||(e=r.get(t+4),n+=(e&Bt)*Yo,e<j)||(e=r.get(t+5),n+=(e&Bt)*Zo,e<j)||(e=r.get(t+6),n+=(e&Bt)*Jo,e<j)||(e=r.get(t+7),n+=(e&Bt)*Xo,e<j))return n;throw new RangeError("Could not decode varint")}function Pe(r,t,e=0){return t==null&&(t=vt(Rt(r))),t instanceof Uint8Array?pd(r,t,e):gd(r,t,e)}function me(r,t=0){return r instanceof Uint8Array?md(r,t):yd(r,t)}var gs=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*s)-1;for(;;){let h=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let m=Number.parseInt(u,t);if(!Number.isNaN(m))return m});if(h===void 0)break;if(o*=t,o+=h,o>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let s=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],[s+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[s,!1];e[s]=o>>8,e[s+1]=o&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,s]=t(e);if(n===16)return e;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=t(o.subarray(0,i));return e.set(o.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var jc=45,bd=15,Ir=new gs;function Qo(r){if(!(r.length>bd))return Ir.new(r).parseWith(()=>Ir.readIPv4Addr())}function ti(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>jc))return Ir.new(r).parseWith(()=>Ir.readIPv6Addr())}function ms(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>jc))return Ir.new(r).parseWith(()=>Ir.readIPAddr())}var Xb=parseInt("0xFFFF",16),Qb=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Yc(r){return!!Qo(r)}function Zc(r){return!!ti(r)}function Sr(r){return!!ms(r)}var Jc=Yc,Ad=Zc,ei=function(r){let t=0;if(r=r.toString().trim(),Jc(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Ad(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=Jc(e[n]),i;o&&(i=ei(e[n]),e[n]=q(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,q(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);s[t++]=o>>8&255,s[t++]=o&255}return s}throw new Error("invalid ip address")},Xc=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let s=[];for(let o=0;o<e;o++)s.push(r[t+o]);return s.join(".")}if(e===16){let s=[];for(let o=0;o<e;o+=2)s.push(n.getUint16(t+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var kr={},ri={},Id=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];Id.forEach(r=>{let t=Sd(...r);ri[t.code]=t,kr[t.name]=t});function Sd(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function W(r){if(typeof r=="number"){if(ri[r]!=null)return ri[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(kr[r]!=null)return kr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var Dw=W("ip4"),Ow=W("ip6"),Vw=W("ipcidr");function si(r,t){switch(W(r).code){case 4:case 41:return Rd(t);case 42:return el(t);case 6:case 273:case 33:case 132:return nl(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return el(t);case 421:return _d(t);case 444:return rl(t);case 445:return rl(t);case 466:return Ld(t);default:return q(t,"base16")}}function oi(r,t){switch(W(r).code){case 4:return Qc(t);case 41:return Qc(t);case 42:return tl(t);case 6:case 273:case 33:case 132:return ii(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return tl(t);case 421:return Nd(t);case 444:return Cd(t);case 445:return Ud(t);case 466:return Td(t);default:return Z(t,"base16")}}var ni=Object.values(xe).map(r=>r.decoder),kd=function(){let r=ni[0].or(ni[1]);return ni.slice(2).forEach(t=>r=r.or(t)),r}();function Qc(r){if(!Sr(r))throw new Error("invalid ip address");return ei(r)}function Rd(r){let t=Xc(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Sr(t))throw new Error("invalid ip address");return t}function ii(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function nl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function tl(r){let t=Z(r),e=Uint8Array.from(Pe(t.length));return yt([e,t],e.length+t.length)}function el(r){let t=me(r);if(r=r.slice(Rt(t)),r.length!==t)throw new Error("inconsistent lengths");return q(r)}function Nd(r){let t;r[0]==="Q"||r[0]==="1"?t=Ve(ct.decode(`z${r}`)).bytes:t=Ut.parse(r).multihash.bytes;let e=Uint8Array.from(Pe(t.length));return yt([e,t],e.length+t.length)}function Td(r){let t=kd.decode(r),e=Uint8Array.from(Pe(t.length));return yt([e,t],e.length+t.length)}function Ld(r){let t=me(r),e=r.slice(Rt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+q(e,"base64url")}function _d(r){let t=me(r),e=r.slice(Rt(t));if(e.length!==t)throw new Error("inconsistent lengths");return q(e,"base58btc")}function Cd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Qt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ii(n);return yt([e,s],e.length+s.length)}function Ud(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Qt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ii(n);return yt([e,s],e.length+s.length)}function rl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=q(t,"base32"),s=nl(e);return`${n}:${s}`}function sl(r){r=ai(r);let t=[],e=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<s.length;o++){let i=s[o],a=W(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(o++,o>=s.length)throw il("invalid address: "+r);if(a.path===!0){n=ai(s.slice(o).join("/")),t.push([a.code,oi(a.code,n)]),e.push([a.code,n]);break}let c=oi(a.code,s[o]);t.push([a.code,c]),e.push([a.code,si(a.code,c)])}return{string:ol(e),bytes:li(t),tuples:t,stringTuples:e,path:n}}function ci(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=me(r,s),i=Rt(o),a=W(o),c=Pd(a,r.slice(s+i));if(c===0){t.push([o]),e.push([o]),s+=i;continue}let l=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw il("Invalid address Uint8Array: "+q(r,"base16"));t.push([o,l]);let h=si(o,l);if(e.push([o,h]),a.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:ol(e),tuples:t,stringTuples:e,path:n}}function ol(r){let t=[];return r.map(e=>{let n=W(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ai(t.join("/"))}function li(r){return yt(r.map(t=>{let e=W(t[0]),n=Uint8Array.from(Pe(e.code));return t.length>1&&t[1]!=null&&(n=yt([n,t[1]])),n}))}function Pd(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=me(t instanceof Uint8Array?t:Uint8Array.from(t));return e+Rt(e)}}function ai(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function il(r){return new Error("Error parsing address: "+r)}var Dd=Symbol.for("nodejs.util.inspect.custom"),ui=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Od=[W("dns").code,W("dns4").code,W("dns6").code,W("dnsaddr").code],ys=class r{bytes;#e;#t;#r;#n;[ui]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ci(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=sl(t)}else if(cl(t))e=ci(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,s,o="",i=W("tcp"),a=W("udp"),c=W("ip4"),l=W("ip6"),h=W("dns6"),u=W("ip6zone");for(let[f,p]of this.stringTuples())f===u.code&&(o=`%${p??""}`),Od.includes(f)&&(e=i.name,s=443,n=`${p??""}${o}`,t=f===h.code?6:4),(f===i.code||f===a.code)&&(e=W(f).name,s=parseInt(p??"")),(f===c.code||f===l.code)&&(e=W(f).name,n=`${p??""}${o}`,t=f===l.code?6:4);if(t==null||e==null||n==null||s==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:s}}protos(){return this.#t.map(([t])=>Object.assign({},W(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>W(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),s=n.lastIndexOf(e);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,s))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(li(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===kr.p2p.code&&t.push([n,s]),n===kr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?q(ct.decode(`z${n}`),"base58btc"):q(Ut.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return mt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=al.get(e.name);if(n==null)throw new _(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(o=>new r(o))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[Dd](){return`Multiaddr(${this.#e})`}};var al=new Map;function cl(r){return!!r?.[ui]}function bs(r){return new ys(r)}function Vd(r){return r[Symbol.asyncIterator]!=null}function Fd(r){if(Vd(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var fi=Fd;var ul=Symbol.for("@achingbrain/uint8arraylist");function ll(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let s=e+n.byteLength;if(t<s)return{buf:n,index:t-e};e=s}throw new RangeError("index is out of bounds")}function ws(r){return!!r?.[ul]}var Rr=class r{bufs;length;[ul]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ws(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ws(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=ll(this.bufs,t);return e.buf[e.index]}set(t,e){let n=ll(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ws(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:s}=this._subList(t,e);return yt(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:yt(n,s)}sublist(t,e){let{bufs:n,length:s}=this._subList(t,e),o=new r;return o.length=s,o.bufs=[...n],o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let o=0;o<this.bufs.length;o++){let i=this.bufs[o],a=s,c=a+i.byteLength;if(s=c,t>=c)continue;let l=t>=a&&t<c,h=e>a&&e<=c;if(l&&h){if(t===a&&e===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(h){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ws(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let s=n.byteLength;if(s===0)throw new TypeError("search must be at least 1 byte long");let o=256,i=new Int32Array(o);for(let u=0;u<o;u++)i[u]=-1;for(let u=0;u<s;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,h;for(let u=e;u<=c;u+=h){h=0;for(let m=l;m>=0;m--){let f=this.get(u+m);if(n[m]!==f){h=Math.max(1,m-a[f]);break}}if(h===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let s=te(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,e,n),this.write(s,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let s=te(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,e,n),this.write(s,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let s=te(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,e,n),this.write(s,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=vt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let s=te(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,e,n),this.write(s,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let s=te(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,e,n),this.write(s,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let s=te(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,e,n),this.write(s,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let s=te(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,e,n),this.write(s,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let s=te(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,e,n),this.write(s,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!mt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((s,o)=>s+o.byteLength,0)),n.length=e,n}};function xs(r){return r[Symbol.asyncIterator]!=null}var vs=r=>{let t=Rt(r),e=vt(t);return Pe(r,e),vs.bytes=t,e};vs.bytes=0;function Xr(r,t){t=t??{};let e=t.lengthEncoder??vs;function*n(s){let o=e(s.byteLength);o instanceof Uint8Array?yield o:yield*o,s instanceof Uint8Array?yield s:yield*s}return xs(r)?async function*(){for await(let s of r)yield*n(s)}():function*(){for(let s of r)yield*n(s)}()}Xr.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??vs;return new Rr(e(r.byteLength),r)};var Nr=rn(dl(),1);var Md=8,$d=1024*1024*4,Ye;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ye||(Ye={}));var hi=r=>{let t=me(r);return hi.bytes=Rt(t),t};hi.bytes=0;function Tr(r,t){let e=new Rr,n=Ye.LENGTH,s=-1,o=t?.lengthDecoder??hi,i=t?.maxLengthLength??Md,a=t?.maxDataLength??$d;function*c(){for(;e.byteLength>0;){if(n===Ye.LENGTH)try{if(s=o(e),s<0)throw(0,Nr.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>a)throw(0,Nr.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let l=o.bytes;e.consume(l),t?.onLength!=null&&t.onLength(s),n=Ye.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>i)throw(0,Nr.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw l}if(n===Ye.DATA){if(e.byteLength<s)break;let l=e.sublist(0,s);e.consume(s),t?.onData!=null&&t.onData(l),yield l,n=Ye.LENGTH}}}return xs(r)?async function*(){for await(let l of r)e.append(l),yield*c();if(e.byteLength>0)throw(0,Nr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let l of r)e.append(l),yield*c();if(e.byteLength>0)throw(0,Nr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Tr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:o,value:i}=await r.next(e);if(o===!0)return;i!=null&&(yield i)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{e=1}}();return Tr(n,{...t??{},onLength:o=>{e=o}})};function qd(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:s=>{n.push(s)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var pl=qd;function zd(r){return r[Symbol.asyncIterator]!=null}function jd(r,t){if(zd(r))return async function*(){for await(let a of r)yield t(a)}();let e=pl(r),{value:n,done:s}=e.next();if(s===!0)return function*(){}();let o=t(n);if(typeof o.then=="function")return async function*(){yield await o;for await(let a of e)yield t(a)}();let i=t;return function*(){yield o;for(let a of e)yield i(a)}()}var gl=jd;function ye(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Es=globalThis.CustomEvent??Event;async function*di(r,t={}){let e=t.concurrency??1/0;e<1&&(e=1/0);let n=t.ordered==null?!1:t.ordered,s=new EventTarget,o=[],i=ye(),a=ye(),c=!1,l,h=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of r){if(o.length===e&&(i=ye(),await i.promise),h)break;let d={done:!1};o.push(d),p().then(g=>{d.done=!0,d.ok=!0,d.value=g,s.dispatchEvent(new Es("task-complete"))},g=>{d.done=!0,d.err=g,s.dispatchEvent(new Es("task-complete"))})}c=!0,s.dispatchEvent(new Es("task-complete"))}catch(p){l=p,s.dispatchEvent(new Es("task-complete"))}});function u(){return n?o[0]?.done:!!o.find(p=>p.done)}function*m(){for(;o.length>0&&o[0].done;){let p=o[0];if(o.shift(),p.ok)yield p.value;else throw h=!0,i.resolve(),p.err;i.resolve()}}function*f(){for(;u();)for(let p=0;p<o.length;p++)if(o[p].done){let d=o[p];if(o.splice(p,1),p--,d.ok)yield d.value;else throw h=!0,i.resolve(),d.err;i.resolve()}}for(;;){if(u()||(a=ye(),await a.promise),l!=null)throw l;if(n?yield*m():yield*f(),c&&o.length===0)break}}var As=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Lr=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new As(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new As(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var pi=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function Bs(r={}){return Gd(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Gd(r,t){t=t??{};let e=t.onEnd,n=new Lr,s,o,i,a=ye(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((g,y)=>{o=b=>{o=null,n.push(b);try{g(r(n))}catch(w){y(w)}return s}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=ye()})}},l=g=>o!=null?o(g):(n.push(g),s),h=g=>(n=new Lr,o!=null?o({error:g}):(n.push({error:g}),s)),u=g=>{if(i)return s;if(t?.objectMode!==!0&&g?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:g})},m=g=>i?s:(i=!0,g!=null?h(g):l({done:!0})),f=()=>(n=new Lr,m(),{done:!0}),p=g=>(m(g),{done:!0});if(s={[Symbol.asyncIterator](){return this},next:c,return:f,throw:p,push:u,end:m,get readableLength(){return n.size},onEmpty:async g=>{let y=g?.signal;if(y?.throwIfAborted(),n.isEmpty())return;let b,w;y!=null&&(b=new Promise((k,v)=>{w=()=>{v(new pi)},y.addEventListener("abort",w)}));try{await Promise.race([a.promise,b])}finally{w!=null&&y!=null&&y?.removeEventListener("abort",w)}}},e==null)return s;let d=s;return s={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(g){return d.throw(g),e!=null&&(e(g),e=void 0),{done:!0}},return(){return d.return(),e!=null&&(e(),e=void 0),{done:!0}},push:u,end(g){return d.end(g),e!=null&&(e(g),e=void 0),s},get readableLength(){return d.readableLength},onEmpty:g=>d.onEmpty(g)},s}function Wd(r){return r[Symbol.asyncIterator]!=null}function Yd(...r){let t=[];for(let e of r)Wd(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=Bs({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let s of n)e.push(s)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var ml=Yd;function mi(r,...t){if(r==null)throw new Error("Empty pipeline");if(gi(r)){let n=r;r=()=>n.source}else if(bl(r)||yl(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&gi(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)gi(e[n])&&(e[n]=Jd(e[n]));return Zd(...e)}var Zd=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},yl=r=>r?.[Symbol.asyncIterator]!=null,bl=r=>r?.[Symbol.iterator]!=null,gi=r=>r==null?!1:r.sink!=null&&r.source!=null,Jd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=Bs({objectMode:!0});e.then(()=>{n.end()},i=>{n.end(i)});let s,o=r.source;if(yl(o))s=async function*(){yield*o,n.end()};else if(bl(o))s=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ml(n,s())}return r.source};var Il=rn(wl(),1);var xl="[a-fA-F\\d:]",De=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${xl})|(?<=${xl})(?=\\s|$))`:"",zt="(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]\\d|\\d)){3}",it="[a-fA-F\\d]{1,4}",Is=`
8
- (?:
9
- (?:${it}:){7}(?:${it}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
10
- (?:${it}:){6}(?:${zt}|:${it}|:)| // 1:2:3:4:5:6:: 1:2:3:4:5:6::8 1:2:3:4:5:6::8 1:2:3:4:5:6::1.2.3.4
11
- (?:${it}:){5}(?::${zt}|(?::${it}){1,2}|:)| // 1:2:3:4:5:: 1:2:3:4:5::7:8 1:2:3:4:5::8 1:2:3:4:5::7:1.2.3.4
12
- (?:${it}:){4}(?:(?::${it}){0,1}:${zt}|(?::${it}){1,3}|:)| // 1:2:3:4:: 1:2:3:4::6:7:8 1:2:3:4::8 1:2:3:4::6:7:1.2.3.4
13
- (?:${it}:){3}(?:(?::${it}){0,2}:${zt}|(?::${it}){1,4}|:)| // 1:2:3:: 1:2:3::5:6:7:8 1:2:3::8 1:2:3::5:6:7:1.2.3.4
14
- (?:${it}:){2}(?:(?::${it}){0,3}:${zt}|(?::${it}){1,5}|:)| // 1:2:: 1:2::4:5:6:7:8 1:2::8 1:2::4:5:6:7:1.2.3.4
15
- (?:${it}:){1}(?:(?::${it}){0,4}:${zt}|(?::${it}){1,6}|:)| // 1:: 1::3:4:5:6:7:8 1::8 1::3:4:5:6:7:1.2.3.4
16
- (?::(?:(?::${it}){0,5}:${zt}|(?::${it}){1,7}|:)) // ::2:3:4:5:6:7:8 ::2:3:4:5:6:7:8 ::8 ::1.2.3.4
17
- )(?:%[0-9a-zA-Z]{1,})? // %eth0 %1
18
- `.replace(/\s*\/\/.*$/gm,"").replace(/\n/g,"").trim(),Xd=new RegExp(`(?:^${zt}$)|(?:^${Is}$)`),Qd=new RegExp(`^${zt}$`),t0=new RegExp(`^${Is}$`),yi=r=>r&&r.exact?Xd:new RegExp(`(?:${De(r)}${zt}${De(r)})|(?:${De(r)}${Is}${De(r)})`,"g");yi.v4=r=>r&&r.exact?Qd:new RegExp(`${De(r)}${zt}${De(r)}`,"g");yi.v6=r=>r&&r.exact?t0:new RegExp(`${De(r)}${Is}${De(r)}`,"g");var vl=yi;var Sl=rn(Al(),1),{isValid:e0,parse:r0}=Sl.default,n0=["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"],s0=n0.map(r=>new Il.Netmask(r));function o0(r){for(let t of s0)if(t.contains(r))return!0;return!1}function Bl(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}var kl=r=>{if(e0(r)){let t=r0(r);if(t.kind()==="ipv4")return o0(t.toNormalizedString());if(t.kind()==="ipv6")return Bl(r)}else if(Sr(r)&&vl.v6().test(r))return Bl(r)};var bi=kl;var Rl="libp2p",Nl="autonat",Tl="1.0.0";var P;(function(r){let t;(function(l){l.DIAL="DIAL",l.DIAL_RESPONSE="DIAL_RESPONSE"})(t=r.MessageType||(r.MessageType={}));let e;(function(l){l[l.DIAL=0]="DIAL",l[l.DIAL_RESPONSE=1]="DIAL_RESPONSE"})(e||(e={})),function(l){l.codec=()=>pr(e)}(t=r.MessageType||(r.MessageType={}));let n;(function(l){l.OK="OK",l.E_DIAL_ERROR="E_DIAL_ERROR",l.E_DIAL_REFUSED="E_DIAL_REFUSED",l.E_BAD_REQUEST="E_BAD_REQUEST",l.E_INTERNAL_ERROR="E_INTERNAL_ERROR"})(n=r.ResponseStatus||(r.ResponseStatus={}));let s;(function(l){l[l.OK=0]="OK",l[l.E_DIAL_ERROR=100]="E_DIAL_ERROR",l[l.E_DIAL_REFUSED=101]="E_DIAL_REFUSED",l[l.E_BAD_REQUEST=200]="E_BAD_REQUEST",l[l.E_INTERNAL_ERROR=300]="E_INTERNAL_ERROR"})(s||(s={})),function(l){l.codec=()=>pr(s)}(n=r.ResponseStatus||(r.ResponseStatus={}));let o;(function(l){let h;l.codec=()=>(h==null&&(h=Mt((u,m,f={})=>{if(f.lengthDelimited!==!1&&m.fork(),u.id!=null&&(m.uint32(10),m.bytes(u.id)),u.addrs!=null)for(let p of u.addrs)m.uint32(18),m.bytes(p);f.lengthDelimited!==!1&&m.ldelim()},(u,m)=>{let f={addrs:[]},p=m==null?u.len:u.pos+m;for(;u.pos<p;){let d=u.uint32();switch(d>>>3){case 1:f.id=u.bytes();break;case 2:f.addrs.push(u.bytes());break;default:u.skipType(d&7);break}}return f})),h),l.encode=u=>Ht(u,l.codec()),l.decode=u=>Ft(u,l.codec())})(o=r.PeerInfo||(r.PeerInfo={}));let i;(function(l){let h;l.codec=()=>(h==null&&(h=Mt((u,m,f={})=>{f.lengthDelimited!==!1&&m.fork(),u.peer!=null&&(m.uint32(10),r.PeerInfo.codec().encode(u.peer,m)),f.lengthDelimited!==!1&&m.ldelim()},(u,m)=>{let f={},p=m==null?u.len:u.pos+m;for(;u.pos<p;){let d=u.uint32();switch(d>>>3){case 1:f.peer=r.PeerInfo.codec().decode(u,u.uint32());break;default:u.skipType(d&7);break}}return f})),h),l.encode=u=>Ht(u,l.codec()),l.decode=u=>Ft(u,l.codec())})(i=r.Dial||(r.Dial={}));let a;(function(l){let h;l.codec=()=>(h==null&&(h=Mt((u,m,f={})=>{f.lengthDelimited!==!1&&m.fork(),u.status!=null&&(m.uint32(8),r.ResponseStatus.codec().encode(u.status,m)),u.statusText!=null&&(m.uint32(18),m.string(u.statusText)),u.addr!=null&&(m.uint32(26),m.bytes(u.addr)),f.lengthDelimited!==!1&&m.ldelim()},(u,m)=>{let f={},p=m==null?u.len:u.pos+m;for(;u.pos<p;){let d=u.uint32();switch(d>>>3){case 1:f.status=r.ResponseStatus.codec().decode(u);break;case 2:f.statusText=u.string();break;case 3:f.addr=u.bytes();break;default:u.skipType(d&7);break}}return f})),h),l.encode=u=>Ht(u,l.codec()),l.decode=u=>Ft(u,l.codec())})(a=r.DialResponse||(r.DialResponse={}));let c;r.codec=()=>(c==null&&(c=Mt((l,h,u={})=>{u.lengthDelimited!==!1&&h.fork(),l.type!=null&&(h.uint32(8),r.MessageType.codec().encode(l.type,h)),l.dial!=null&&(h.uint32(18),r.Dial.codec().encode(l.dial,h)),l.dialResponse!=null&&(h.uint32(26),r.DialResponse.codec().encode(l.dialResponse,h)),u.lengthDelimited!==!1&&h.ldelim()},(l,h)=>{let u={},m=h==null?l.len:l.pos+h;for(;l.pos<m;){let f=l.uint32();switch(f>>>3){case 1:u.type=r.MessageType.codec().decode(l);break;case 2:u.dial=r.Dial.codec().decode(l,l.uint32());break;case 3:u.dialResponse=r.DialResponse.codec().decode(l,l.uint32());break;default:l.skipType(f&7);break}}return u})),c),r.encode=l=>Ht(l,r.codec()),r.decode=l=>Ft(l,r.codec())})(P||(P={}));var wi=4,ks=class{components;startupDelay;refreshInterval;protocol;timeout;maxInboundStreams;maxOutboundStreams;verifyAddressTimeout;started;log;constructor(t,e){this.components=t,this.log=t.logger.forComponent("libp2p:autonat"),this.started=!1,this.protocol=`/${e.protocolPrefix??Rl}/${Nl}/${Tl}`,this.timeout=e.timeout??3e4,this.maxInboundStreams=e.maxInboundStreams??1,this.maxOutboundStreams=e.maxOutboundStreams??1,this.startupDelay=e.startupDelay??5e3,this.refreshInterval=e.refreshInterval??6e4,this._verifyExternalAddresses=this._verifyExternalAddresses.bind(this)}isStarted(){return this.started}async start(){this.started||(await this.components.registrar.handle(this.protocol,t=>{this.handleIncomingAutonatStream(t).catch(e=>{this.log.error("error handling incoming autonat stream",e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams}),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.startupDelay),this.started=!0)}async stop(){await this.components.registrar.unhandle(this.protocol),clearTimeout(this.verifyAddressTimeout),this.started=!1}async handleIncomingAutonatStream(t){let e=AbortSignal.timeout(this.timeout),n=()=>{t.stream.abort(new _("handleIncomingAutonatStream timeout",Ns))};e.addEventListener("abort",n,{once:!0}),Ls(1/0,e);let s=this.components.addressManager.getAddresses().map(o=>o.toOptions().host);try{let o=this;await mi(t.stream,i=>Tr(i),async function*(i){let a=await fi(i);if(a==null){o.log("no message received"),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"No message was sent"}});return}let c;try{c=P.decode(a)}catch(d){o.log.error("could not decode message",d),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"Could not decode message"}});return}let l=c.dial;if(l==null){o.log.error("dial was missing from message"),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"No Dial message found in message"}});return}let h,u=l.peer;if(u==null||u.id==null){o.log.error("PeerId missing from message"),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"missing peer info"}});return}try{h=on(u.id)}catch(d){o.log.error("invalid PeerId",d),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"bad peer id"}});return}if(o.log("incoming request from %p",h),!t.connection.remotePeer.equals(h)){o.log("target peer %p did not equal sending peer %p",h,t.connection.remotePeer),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_BAD_REQUEST,statusText:"peer id mismatch"}});return}let m=u.addrs.map(d=>bs(d)).filter(d=>{let g=d.toOptions().host===t.connection.remoteAddr.toOptions().host;return o.log.trace("request to dial %a was sent from %a is same host %s",d,t.connection.remoteAddr,g),g}).filter(d=>{let g=d.toOptions().host,y=!(bi(g)??!1);return o.log.trace("host %s was public %s",g,y),y}).filter(d=>{let g=d.toOptions().host,y=!s.includes(g);return o.log.trace("host %s was not our host %s",g,y),y}).filter(d=>{let g=!!o.components.transportManager.transportForMultiaddr(d);return o.log.trace("transport for %a is supported %s",d,g),g}).map(d=>(d.getPeerId()==null&&(d=d.encapsulate(`/p2p/${h.toString()}`)),d));if(m.length===0){o.log("no valid multiaddrs for %p in message",h),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_DIAL_REFUSED,statusText:"no dialable addresses"}});return}o.log("dial multiaddrs %s for peer %p",m.map(d=>d.toString()).join(", "),h);let f="",p=m[0];for await(let d of m){let g;p=d;try{if(g=await o.components.connectionManager.openConnection(d,{signal:e}),!g.remoteAddr.equals(d))throw o.log.error("tried to dial %a but dialed %a",d,g.remoteAddr),new Error("Unexpected remote address");o.log("Success %p",h),yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.OK,addr:g.remoteAddr.decapsulateCode(W("p2p").code).bytes}});return}catch(y){o.log("could not dial %p",h,y),f=y.message}finally{g!=null&&await g.close()}}yield P.encode({type:P.MessageType.DIAL_RESPONSE,dialResponse:{status:P.ResponseStatus.E_DIAL_ERROR,statusText:f,addr:p.bytes}})},i=>Xr(i),t.stream)}catch(o){this.log.error("error handling incoming autonat stream",o)}finally{e.removeEventListener("abort",n)}}_verifyExternalAddresses(){this.verifyExternalAddresses().catch(t=>{this.log.error("error verifying external address",t)})}async verifyExternalAddresses(){if(clearTimeout(this.verifyAddressTimeout),!this.isStarted())return;let t=this.components.addressManager,e=t.getObservedAddrs().filter(o=>{let i=o.toOptions();return!(bi(i.host)??!1)});if(e.length===0){this.log("no public addresses found, not requesting verification"),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval);return}let n=AbortSignal.timeout(this.timeout);Ls(1/0,n);let s=this;try{this.log("verify multiaddrs %s",e.map(u=>u.toString()).join(", "));let o=P.encode({type:P.MessageType.DIAL,dial:{peer:{id:this.components.peerId.toBytes(),addrs:e.map(u=>u.bytes)}}}),a=(await zc()).toBytes(),c={},l=[],h=async u=>{let m=()=>{};try{this.log("asking %p to verify multiaddr",u.id);let f=await s.components.connectionManager.openConnection(u.id,{signal:n}),p=await f.newStream(this.protocol,{signal:n});m=()=>{p.abort(new _("verifyAddress timeout",Ns))},n.addEventListener("abort",m,{once:!0});let d=await mi([o],y=>Xr(y),p,y=>Tr(y),async y=>fi(y));if(d==null){this.log("no response received from %p",f.remotePeer);return}let g=P.decode(d);if(g.type!==P.MessageType.DIAL_RESPONSE||g.dialResponse==null){this.log("invalid autonat response from %p",f.remotePeer);return}if(g.dialResponse.status===P.ResponseStatus.OK){let y=f.remoteAddr.toOptions(),b;if(y.family===4)b=y.host.split(".")[0];else if(y.family===6)b=y.host.split(":")[0];else{this.log('remote address "%s" was not IP4 or IP6?',y.host);return}if(l.includes(b)){this.log("already have response from network segment %d - %s",b,y.host);return}l.push(b)}return g.dialResponse}catch(f){this.log.error("error asking remote to verify multiaddr",f)}finally{n.removeEventListener("abort",m)}};for await(let u of di(gl(this.components.peerRouting.getClosestPeers(a,{signal:n}),m=>async()=>h(m)),{concurrency:wi}))try{if(u==null)continue;let m=u.addr==null?e[0]:bs(u.addr);if(this.log("autonat response for %a is %s",m,u.status),u.status===P.ResponseStatus.E_BAD_REQUEST||u.status===P.ResponseStatus.E_DIAL_REFUSED||u.addr==null&&e.length>1)continue;if(!e.some(p=>p.equals(m))){this.log("peer reported %a as %s but it was not in our observed address list",m,u.status);continue}let f=m.toString();if(c[f]==null&&(c[f]={success:0,failure:0}),u.status===P.ResponseStatus.OK?c[f].success++:u.status===P.ResponseStatus.E_DIAL_ERROR&&c[f].failure++,c[f].success===wi){this.log("%a is externally dialable",m),t.confirmObservedAddr(m);return}if(c[f].failure===wi){this.log("%a is not externally dialable",m),t.removeObservedAddr(m);return}}catch(m){this.log.error("could not verify external address",m)}}finally{this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval)}}};function f0(r={}){return t=>new ks(t,r)}return ql(h0);})();
6
+ `)}`:`${e} :`}};Da=Ie;S.Constructed=Da;Ie.NAME="CONSTRUCTED";var kn=class extends xt{fromBER(t,e,n){return e}toBER(t){return Ft}};kn.override="EndOfContentValueBlock";var Pa,In=class extends gt{constructor(t={}){super(t,kn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Pa=In;S.EndOfContent=Pa;In.NAME=Or;var Oa,Re=class extends gt{constructor(t={}){super(t,xt),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(t,e,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,e+n>t.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):e+n}toBER(t,e){let n=new ArrayBuffer(2);if(!t){let s=new Uint8Array(n);s[0]=5,s[1]=0}return e&&e.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};Oa=Re;S.Null=Oa;Re.NAME="NULL";var Rn=class extends ue(xt){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=H.BufferSourceConverter.toUint8Array(e.valueHex):this.valueHexView=new Uint8Array(1),t&&(this.value=t)}get value(){for(let t of this.valueHexView)if(t>0)return!0;return!1}set value(t){this.valueHexView[0]=t?255:0}fromBER(t,e,n){let s=H.BufferSourceConverter.toUint8Array(t);return le(this,s,e,n)?(this.valueHexView=s.subarray(e,e+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,No.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Rn.NAME="BooleanValueBlock";var Va,Nn=class extends gt{constructor(t={}){super(t,Rn),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(t){this.valueBlock.value=t}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};Va=Nn;S.Boolean=Va;Nn.NAME="BOOLEAN";var Tn=class extends ue($t){constructor({isConstructed:t=!1,...e}={}){super(e),this.isConstructed=t}fromBER(t,e,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=$t.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===Or){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==La)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(t,e,n),this.blockLength=n;return s}toBER(t,e){return this.isConstructed?$t.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Tn.NAME="OctetStringValueBlock";var Fa,ae=class r extends gt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Tn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(t,e,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,n===0)return this.idBlock.error.length===0&&(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length===0&&(this.blockLength+=this.lenBlock.blockLength),e;if(!this.valueBlock.isConstructed){let o=(t instanceof ArrayBuffer?new Uint8Array(t):t).subarray(e,e+n);try{if(o.byteLength){let i=ss(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(t,e,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ie.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${H.Convert.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;let t=[];for(let e of this.valueBlock.value)e instanceof r&&t.push(e.valueBlock.valueHexView);return H.BufferSourceConverter.concat(t)}};Fa=ae;S.OctetString=Fa;ae.NAME=La;var Ln=class extends ue($t){constructor({unusedBits:t=0,isConstructed:e=!1,...n}={}){super(n),this.unusedBits=t,this.isConstructed=e,this.blockLength=this.valueHexView.byteLength}fromBER(t,e,n){if(!n)return e;let s=-1;if(this.isConstructed){if(s=$t.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Or){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==_a)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=a.valueBlock;if(this.unusedBits>0&&l.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=l.unusedBits}return s}let o=H.BufferSourceConverter.toUint8Array(t);if(!le(this,o,e,n))return-1;let i=o.subarray(e,e+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=ss(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,e+n}toBER(t,e){if(this.isConstructed)return $t.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ft;let n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}};Ln.NAME="BitStringValueBlock";var Ha,dr=class extends gt{constructor({idBlock:t={},lenBlock:e={},...n}={}){var s,o;(s=n.isConstructed)!==null&&s!==void 0||(n.isConstructed=!!(!((o=n.value)===null||o===void 0)&&o.length)),super({idBlock:{isConstructed:n.isConstructed,...t},lenBlock:{...e,isIndefiniteForm:!!n.isIndefiniteForm},...n},Ln),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(t,e,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(t,e,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ie.prototype.onAsciiEncoding.call(this);{let t=[],e=this.valueBlock.valueHexView;for(let s of e)t.push(s.toString(2).padStart(8,"0"));let n=t.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};Ha=dr;S.BitString=Ha;dr.NAME=_a;var Ma;function hh(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l=0,f=c<i?i:c,u=0;for(let h=f;h>=0;h--,u++){switch(!0){case u<a.length:l=o[i-u]+a[c-u]+e[0];break;default:l=o[i-u]+e[0]}switch(e[0]=l/10,!0){case u>=o.length:o=wn(new Uint8Array([l%10]),o);break;default:o[i-u]=l%10}}return e[0]>0&&(o=wn(e,o)),o}function Ta(r){if(r>=Dr.length)for(let t=Dr.length;t<=r;t++){let e=new Uint8Array([0]),n=Dr[t-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+e[0]]);e[0]=o[0]/10,n[s]=o[0]%10}e[0]>0&&(n=wn(e,n)),Dr.push(n)}return Dr[r]}function dh(r,t){let e=0,n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,l,f=0;for(let u=c;u>=0;u--,f++)switch(l=o[i-f]-a[c-f]-e,!0){case l<0:e=1,o[i-f]=l+10;break;default:e=0,o[i-f]=l}if(e>0)for(let u=i-c+1;u>=0;u--,f++)if(l=o[i-f]-e,l<0)e=1,o[i-f]=l+10;else{e=0,o[i-f]=l;break}return o.slice()}var Vr=class extends ue(xt){constructor({value:t,...e}={}){super(e),this._valueDec=0,e.valueHex&&this.setValueHex(),t!==void 0&&(this.valueDec=t)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=No.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Ia(t))}get valueDec(){return this._valueDec}fromDER(t,e,n,s=0){let o=this.fromBER(t,e,n);if(o===-1)return o;let i=this.valueHexView;return i[0]===0&&i[1]&128?this.valueHexView=i.subarray(1):s!==0&&i.length<s&&(s-i.length>1&&(s=i.length+1),this.valueHexView=i.subarray(s-i.length)),o}toDER(t=!1){let e=this.valueHexView;switch(!0){case(e[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(e,1),this.valueHexView=n}break;case(e[0]===0&&(e[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(t)}fromBER(t,e,n){let s=super.fromBER(t,e,n);return s===-1||this.setValueHex(),s}toBER(t){return t?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let t=this.valueHexView.length*8-1,e=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let l=0;l<8;l++){if((s&1)===1)switch(n){case t:e=dh(Ta(n),e),i="-";break;default:e=hh(e,Ta(n))}n++,s>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(i+=Na.charAt(e[c]));return a===!1&&(i+=Na.charAt(0)),i}};Ma=Vr;Vr.NAME="IntegerValueBlock";Object.defineProperty(Ma.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Ka,ot=class r extends gt{constructor(t={}){super(t,Vr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return xn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){xn();let e=BigInt(t),n=new Pr,s=e.toString(16).replace(/^-/,""),o=new Uint8Array(H.Convert.FromHex(s));if(e<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let l=BigInt(`0x${H.Convert.ToHex(a)}`)+e,f=H.BufferSourceConverter.toUint8Array(H.Convert.FromHex(l.toString(16)));f[0]|=128,n.write(f)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let t=new r({valueHex:this.valueBlock.valueHexView});return t.valueBlock.toDER(),t}convertFromDER(){return new r({valueHex:this.valueBlock.valueHexView[0]===0?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}};Ka=ot;S.Integer=Ka;ot.NAME="INTEGER";var $a,_n=class extends ot{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};$a=_n;S.Enumerated=$a;_n.NAME="ENUMERATED";var Fr=class extends ue(xt){constructor({valueDec:t=-1,isFirstSid:e=!1,...n}={}){super(n),this.valueDec=t,this.isFirstSid=e}fromBER(t,e,n){if(!n)return e;let s=H.BufferSourceConverter.toUint8Array(t);if(!le(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=$e(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){xn();let e=BigInt(t).toString(2);for(;e.length%7;)e="0"+e;let n=new Uint8Array(e.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(e.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=ke(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Ft;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let t="";if(this.isHexOnly)t=H.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let e=this.valueDec;this.valueDec<=39?t="0.":this.valueDec<=79?(t="1.",e-=40):(t="2.",e-=80),t+=e.toString()}else t=this.valueDec.toString();return t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Fr.NAME="sidBlock";var Un=class extends xt{constructor({value:t=pr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Fr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.value.length===0&&(o.isFirstSid=!0),this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t){let e=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(t);if(s.byteLength===0)return this.error=this.value[n].error,Ft;e.push(s)}return To(e)}fromString(t){this.value=[];let e=0,n=0,s="",o=!1;do if(n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1,o){let i=this.value[0],a=0;switch(i.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(s,10);if(isNaN(c))return;i.valueDec=c+a,o=!1}else{let i=new Fr;if(s>Number.MAX_SAFE_INTEGER){xn();let a=BigInt(s);i.valueBigInt=a}else if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,o=!0),this.value.push(i)}while(n!==-1)}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e?(s=`{${s}}`,this.value[n].isFirstSid?t=`2.{${s} - 80}`:t+=s):t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};Un.NAME="ObjectIdentifierValueBlock";var qa,Vt=class extends gt{constructor(t={}){super(t,Un),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};qa=Vt;S.ObjectIdentifier=qa;Vt.NAME="OBJECT IDENTIFIER";var Hr=class extends ue(ie){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let s=H.BufferSourceConverter.toUint8Array(t);if(!le(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=$e(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}toBER(t){if(this.isHexOnly){if(t)return new ArrayBuffer(this.valueHexView.byteLength);let s=this.valueHexView,o=new Uint8Array(this.blockLength);for(let i=0;i<this.blockLength-1;i++)o[i]=s[i]|128;return o[this.blockLength-1]=s[this.blockLength-1],o.buffer}let e=ke(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Ft;let n=new Uint8Array(e.byteLength);if(!t){let s=new Uint8Array(e),o=e.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let t="";return this.isHexOnly?t=H.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Hr.NAME="relativeSidBlock";var Cn=class extends xt{constructor({value:t=pr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Hr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.blockLength+=o.blockLength,n-=o.blockLength,this.value.push(o)}return s}toBER(t,e){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(t);if(o.byteLength===0)return this.error=this.value[s].error,Ft;n.push(o)}return To(n)}fromString(t){this.value=[];let e=0,n=0,s="";do{n=t.indexOf(".",e),n===-1?s=t.substring(e):s=t.substring(e,n),e=n+1;let o=new Hr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let t="",e=!1;for(let n=0;n<this.value.length;n++){e=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(t=`${t}.`),e&&(s=`{${s}}`),t+=s}return t}toJSON(){let t={...super.toJSON(),value:this.toString(),sidArray:[]};for(let e=0;e<this.value.length;e++)t.sidArray.push(this.value[e].toJSON());return t}};Cn.NAME="RelativeObjectIdentifierValueBlock";var Ga,Dn=class extends gt{constructor(t={}){super(t,Cn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(t){this.valueBlock.fromString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};Ga=Dn;S.RelativeObjectIdentifier=Ga;Dn.NAME="RelativeObjectIdentifier";var za,ut=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};za=ut;S.Sequence=za;ut.NAME="SEQUENCE";var ja,Pn=class extends Ie{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};ja=Pn;S.Set=ja;Pn.NAME="SET";var On=class extends ue(xt){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=pr}toJSON(){return{...super.toJSON(),value:this.value}}};On.NAME="StringValueBlock";var Vn=class extends On{};Vn.NAME="SimpleStringValueBlock";var At=class extends Bn{constructor({...t}={}){super(t,Vn)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,H.BufferSourceConverter.toUint8Array(t))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=t.charCodeAt(s);this.valueBlock.value=t}};At.NAME="SIMPLE STRING";var Fn=class extends At{fromBuffer(t){this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=H.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=H.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf8String(t)),this.valueBlock.value=t}};Fn.NAME="Utf8StringValueBlock";var Wa,ce=class extends Fn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Wa=ce;S.Utf8String=Wa;ce.NAME="UTF8String";var Hn=class extends At{fromBuffer(t){this.valueBlock.value=H.Convert.ToUtf16String(t),this.valueBlock.valueHexView=H.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(H.Convert.FromUtf16String(t))}};Hn.NAME="BmpStringValueBlock";var Ya,Mn=class extends Hn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ya=Mn;S.BmpString=Ya;Mn.NAME="BMPString";var Kn=class extends At{fromBuffer(t){let e=ArrayBuffer.isView(t)?t.slice().buffer:t.slice(0),n=new Uint8Array(e);for(let s=0;s<n.length;s+=4)n[s]=n[s+3],n[s+1]=n[s+2],n[s+2]=0,n[s+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(e))}fromString(t){let e=t.length,n=this.valueBlock.valueHexView=new Uint8Array(e*4);for(let s=0;s<e;s++){let o=ke(t.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[s*4+c+a]=i[c]}this.valueBlock.value=t}};Kn.NAME="UniversalStringValueBlock";var Za,$n=class extends Kn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Za=$n;S.UniversalString=Za;$n.NAME="UniversalString";var Ja,qn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Ja=qn;S.NumericString=Ja;qn.NAME="NumericString";var Xa,Gn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Xa=Gn;S.PrintableString=Xa;Gn.NAME="PrintableString";var Qa,zn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Qa=zn;S.TeletexString=Qa;zn.NAME="TeletexString";var tc,jn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};tc=jn;S.VideotexString=tc;jn.NAME="VideotexString";var ec,Wn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};ec=Wn;S.IA5String=ec;Wn.NAME="IA5String";var rc,Yn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};rc=Yn;S.GraphicString=rc;Yn.NAME="GraphicString";var nc,Mr=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};nc=Mr;S.VisibleString=nc;Mr.NAME="VisibleString";var sc,Zn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};sc=Zn;S.GeneralString=sc;Zn.NAME="GeneralString";var oc,Jn=class extends At{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};oc=Jn;S.CharacterString=oc;Jn.NAME="CharacterString";var ic,Kr=class extends Mr{constructor({value:t,valueDate:e,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,t){this.fromString(t),this.valueBlock.valueHexView=new Uint8Array(t.length);for(let s=0;s<t.length;s++)this.valueBlock.valueHexView[s]=t.charCodeAt(s)}e&&(this.fromDate(e),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(t){this.fromString(String.fromCharCode.apply(null,H.BufferSourceConverter.toUint8Array(t)))}toBuffer(){let t=this.toString(),e=new ArrayBuffer(t.length),n=new Uint8Array(e);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return e}fromDate(t){this.year=t.getUTCFullYear(),this.month=t.getUTCMonth()+1,this.day=t.getUTCDate(),this.hour=t.getUTCHours(),this.minute=t.getUTCMinutes(),this.second=t.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(t){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(t);if(n===null){this.error="Wrong input string for conversion";return}let s=parseInt(n[1],10);s>=50?this.year=1900+s:this.year=2e3+s,this.month=parseInt(n[2],10),this.day=parseInt(n[3],10),this.hour=parseInt(n[4],10),this.minute=parseInt(n[5],10),this.second=parseInt(n[6],10)}toString(t="iso"){if(t==="iso"){let e=new Array(7);return e[0]=kt(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=kt(this.month,2),e[2]=kt(this.day,2),e[3]=kt(this.hour,2),e[4]=kt(this.minute,2),e[5]=kt(this.second,2),e[6]="Z",e.join("")}return super.toString(t)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}};ic=Kr;S.UTCTime=ic;Kr.NAME="UTCTime";var ac,Xn=class extends Kr{constructor(t={}){var e;super(t),(e=this.millisecond)!==null&&e!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(t){super.fromDate(t),this.millisecond=t.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(t){let e=!1,n="",s="",o=0,i,a=0,c=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let u=new Number(t[t.length-1]);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");n=t}if(e){if(n.indexOf("+")!==-1)throw new Error("Wrong input string for conversion");if(n.indexOf("-")!==-1)throw new Error("Wrong input string for conversion")}else{let u=1,h=n.indexOf("+"),m="";if(h===-1&&(h=n.indexOf("-"),u=-1),h!==-1){if(m=n.substring(h+1),n=n.substring(0,h),m.length!==2&&m.length!==4)throw new Error("Wrong input string for conversion");let g=parseInt(m.substring(0,2),10);if(isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");if(a=u*g,m.length===4){if(g=parseInt(m.substring(2,4),10),isNaN(g.valueOf()))throw new Error("Wrong input string for conversion");c=u*g}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let u=new Number(`0${n.substring(l)}`);if(isNaN(u.valueOf()))throw new Error("Wrong input string for conversion");o=u.valueOf(),s=n.substring(0,l)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,l!==-1)throw new Error("Wrong input string for conversion");break;case s.length===10:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=60*o;this.minute=Math.floor(u),u=60*(u-this.minute),this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=60*o;this.second=Math.floor(u),u=1e3*(u-this.second),this.millisecond=Math.floor(u)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let u=1e3*o;this.millisecond=Math.floor(u)}break;default:throw new Error("Wrong input string for conversion")}let f=i.exec(s);if(f===null)throw new Error("Wrong input string for conversion");for(let u=1;u<f.length;u++)switch(u){case 1:this.year=parseInt(f[u],10);break;case 2:this.month=parseInt(f[u],10);break;case 3:this.day=parseInt(f[u],10);break;case 4:this.hour=parseInt(f[u],10)+a;break;case 5:this.minute=parseInt(f[u],10)+c;break;case 6:this.second=parseInt(f[u],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let u=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=u.getUTCFullYear(),this.month=u.getUTCMonth(),this.day=u.getUTCDay(),this.hour=u.getUTCHours(),this.minute=u.getUTCMinutes(),this.second=u.getUTCSeconds(),this.millisecond=u.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(kt(this.year,4)),e.push(kt(this.month,2)),e.push(kt(this.day,2)),e.push(kt(this.hour,2)),e.push(kt(this.minute,2)),e.push(kt(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(kt(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};ac=Xn;S.GeneralizedTime=ac;Xn.NAME="GeneralizedTime";var cc,Qn=class extends ce{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};cc=Qn;S.DATE=cc;Qn.NAME="DATE";var lc,ts=class extends ce{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};lc=ts;S.TimeOfDay=lc;ts.NAME="TimeOfDay";var uc,es=class extends ce{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};uc=es;S.DateTime=uc;es.NAME="DateTime";var fc,rs=class extends ce{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};fc=rs;S.Duration=fc;rs.NAME="Duration";var hc,ns=class extends ce{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};hc=ns;S.TIME=hc;ns.NAME="TIME";function gh(r){let{result:t}=gr(r),e=t.valueBlock.value;return{n:G(qt(e[1].toBigInt()),"base64url"),e:G(qt(e[2].toBigInt()),"base64url"),d:G(qt(e[3].toBigInt()),"base64url"),p:G(qt(e[4].toBigInt()),"base64url"),q:G(qt(e[5].toBigInt()),"base64url"),dp:G(qt(e[6].toBigInt()),"base64url"),dq:G(qt(e[7].toBigInt()),"base64url"),qi:G(qt(e[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function mh(r){if(r.n==null||r.e==null||r.d==null||r.p==null||r.q==null||r.dp==null||r.dq==null||r.qi==null)throw new U("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ut({value:[new ot({value:0}),ot.fromBigInt(Gt(Z(r.n,"base64url"))),ot.fromBigInt(Gt(Z(r.e,"base64url"))),ot.fromBigInt(Gt(Z(r.d,"base64url"))),ot.fromBigInt(Gt(Z(r.p,"base64url"))),ot.fromBigInt(Gt(Z(r.q,"base64url"))),ot.fromBigInt(Gt(Z(r.dp,"base64url"))),ot.fromBigInt(Gt(Z(r.dq,"base64url"))),ot.fromBigInt(Gt(Z(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function yh(r){let{result:t}=gr(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:G(qt(e[0].toBigInt()),"base64url"),e:G(qt(e[1].toBigInt()),"base64url")}}function bh(r){if(r.n==null||r.e==null)throw new U("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ut({value:[new ut({value:[new Vt({value:"1.2.840.113549.1.1.1"}),new Re]}),new dr({valueHex:new ut({value:[ot.fromBigInt(Gt(Z(r.n,"base64url"))),ot.fromBigInt(Gt(Z(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function qt(r){let t=r.toString(16);t.length%2>0&&(t=`0${t}`);let e=t.length/2,n=new Uint8Array(e),s=0,o=0;for(;s<e;)n[s]=parseInt(t.slice(o,o+2),16),s+=1,o+=2;return n}function Gt(r){let t=[];return r.forEach(function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)}),BigInt("0x"+t.join(""))}var wh=16,_o=32,Uo=1e4;async function xh(r,t){let e=Bt.get(),s=new ut({value:[new ot({value:0}),new ut({value:[new Vt({value:"1.2.840.113549.1.1.1"}),new Re]}),new ae({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=Ke(wh),a=await Io(or,t,i,{c:Uo,dkLen:_o}),c=Ke(16),l=await e.subtle.importKey("raw",a,"AES-CBC",!1,["encrypt"]),f=await e.subtle.encrypt({name:"AES-CBC",iv:c},l,o),u=new ut({value:[new ae({valueHex:i}),new ot({value:Uo}),new ot({value:_o}),new ut({value:[new Vt({value:"1.2.840.113549.2.11"}),new Re]})]}),h=new ut({value:[new Vt({value:"1.2.840.113549.1.5.13"}),new ut({value:[new ut({value:[new Vt({value:"1.2.840.113549.1.5.12"}),u]}),new ut({value:[new Vt({value:"2.16.840.1.101.3.4.1.42"}),new ae({valueHex:c})]})]})]}),g=new ut({value:[h,new ae({valueHex:f})]}).toBER(),d=new Uint8Array(g,0,g.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...G(d,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
7
+ `)}async function vh(r,t){let e=Bt.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=Z(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=gr(s),{iv:i,salt:a,iterations:c,keySize:l,cipherText:f}=Eh(o),u=await Io(or,t,a,{c,dkLen:l}),h=await e.subtle.importKey("raw",u,"AES-CBC",!1,["decrypt"]),m=$r(await e.subtle.decrypt({name:"AES-CBC",iv:i},h,f)),{result:g}=gr(m);n=dc(g)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=Z(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=gr(s);n=dc(o)}else throw new U("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Co(n)}function Eh(r){let t=r.valueBlock.value[0];if(t.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new U("Only pkcs5PBES2 encrypted private keys are supported","ERR_INVALID_PARAMS");let n=t.valueBlock.value[1].valueBlock.value[0];if(n.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.12")throw new U("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let o=n.valueBlock.value[1],i=$r(o.valueBlock.value[0].getValue()),a=Uo,c=_o;if(o.valueBlock.value.length===3)a=Number(o.valueBlock.value[1].toBigInt()),c=Number(o.valueBlock.value[2].toBigInt());else if(o.valueBlock.value.length===2)throw new U("Could not derive key size and iterations from PEM file - please use @libp2p/rsa to re-import your key","ERR_INVALID_PARAMS");let l=t.valueBlock.value[1].valueBlock.value[1],f=l.valueBlock.value[0].toString();if(f!=="OBJECT IDENTIFIER : 1.2.840.113549.3.7"){if(f!=="OBJECT IDENTIFIER : 1.3.14.3.2.7"){if(f!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.2"){if(f!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.22"){if(f!=="OBJECT IDENTIFIER : 2.16.840.1.101.3.4.1.42")throw new U("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let u=$r(l.valueBlock.value[1].getValue());return{cipherText:$r(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:u}}function dc(r){return $r(r.valueBlock.value[2].getValue())}function $r(r){return new Uint8Array(r,0,r.byteLength)}async function pc(r){let t=await Bt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),e=await yc(t);return{privateKey:e[0],publicKey:e[1]}}async function Do(r){let e=[await Bt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Bh(r)],n=await yc({privateKey:e[0],publicKey:e[1]});return{privateKey:n[0],publicKey:n[1]}}async function gc(r,t){let e=await Bt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Bt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function mc(r,t,e){let n=await Bt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Bt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function yc(r){if(r.privateKey==null||r.publicKey==null)throw new U("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Bt.get().subtle.exportKey("jwk",r.privateKey),Bt.get().subtle.exportKey("jwk",r.publicKey)])}async function Bh(r){return Bt.get().subtle.importKey("jwk",{kty:r.kty,n:r.n,e:r.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function os(r){if(r.kty!=="RSA")throw new U("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new U("invalid key modulus","ERR_INVALID_KEY_MODULUS");return Z(r.n,"base64url").length*8}var Gr=8192,qr=class{_key;constructor(t){this._key=t}verify(t,e){return mc(this._key,e,t)}marshal(){return Ne.jwkToPkix(this._key)}get bytes(){return Ae.encode({Type:pt.RSA,Data:this.marshal()}).subarray()}equals(t){return yt(this.bytes,t.bytes)}hash(){let t=dt.digest(this.bytes);return Tt(t)?t.then(({bytes:e})=>e):t.bytes}},mr=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e}genSecret(){return Ke(16)}sign(t){return gc(this._key,t)}get public(){if(this._publicKey==null)throw new U("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new qr(this._publicKey)}marshal(){return Ne.jwkToPkcs1(this._key)}get bytes(){return Se.encode({Type:pt.RSA,Data:this.marshal()}).subarray()}equals(t){return yt(this.bytes,t.bytes)}hash(){let t=dt.digest(this.bytes);return Tt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return G(t,"base58btc")}async export(t,e="pkcs-8"){if(e==="pkcs-8")return Ne.exportToPem(this,t);if(e==="libp2p-key")return cr(this.bytes,t);throw new U(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Co(r){let t=Ne.pkcs1ToJwk(r);if(os(t)>Gr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Do(t);return new mr(e.privateKey,e.publicKey)}function Sh(r){let t=Ne.pkixToJwk(r);if(os(t)>Gr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new qr(t)}async function kh(r){if(os(r)>Gr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Do(r);return new mr(t.privateKey,t.publicKey)}async function Ih(r){if(r>Gr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await pc(r);return new mr(t.privateKey,t.publicKey)}var Mo={};lt(Mo,{Secp256k1PrivateKey:()=>jr,Secp256k1PublicKey:()=>zr,generateKeyPair:()=>Kh,unmarshalSecp256k1PrivateKey:()=>Hh,unmarshalSecp256k1PublicKey:()=>Mh});var Rh=(r,t,e)=>r&t^~r&e,Nh=(r,t,e)=>r&t^r&e^t&e,Th=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Te=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Le=new Uint32Array(64),Oo=class extends sr{constructor(){super(64,32,8,!1),this.A=Te[0]|0,this.B=Te[1]|0,this.C=Te[2]|0,this.D=Te[3]|0,this.E=Te[4]|0,this.F=Te[5]|0,this.G=Te[6]|0,this.H=Te[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[t,e,n,s,o,i,a,c]}set(t,e,n,s,o,i,a,c){this.A=t|0,this.B=e|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(t,e){for(let u=0;u<16;u++,e+=4)Le[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let h=Le[u-15],m=Le[u-2],g=Ct(h,7)^Ct(h,18)^h>>>3,d=Ct(m,17)^Ct(m,19)^m>>>10;Le[u]=d+Le[u-7]+g+Le[u-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:l,H:f}=this;for(let u=0;u<64;u++){let h=Ct(a,6)^Ct(a,11)^Ct(a,25),m=f+h+Rh(a,c,l)+Th[u]+Le[u]|0,d=(Ct(n,2)^Ct(n,13)^Ct(n,22))+Nh(n,s,o)|0;f=l,l=c,c=a,a=i+m|0,i=o,o=s,s=n,n=m+d|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,f=f+this.H|0,this.set(n,s,o,i,a,c,l,f)}roundClean(){Le.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var bc=nn(()=>new Oo);function Lh(r){let t=Nr(r);Kt(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:e,Fp:n,a:s}=t;if(e){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof e!="object"||typeof e.beta!="bigint"||typeof e.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:_h,hexToBytes:Uh}=an,qe={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=qe;if(r.length<2||r[0]!==2)throw new t("Invalid signature integer tag");let e=r[1],n=r.subarray(2,e+2);if(!e||n.length!==e)throw new t("Invalid signature integer: wrong length");if(n[0]&128)throw new t("Invalid signature integer: negative");if(n[0]===0&&!(n[1]&128))throw new t("Invalid signature integer: unnecessary leading zero");return{d:_h(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=qe,e=typeof r=="string"?Uh(r):r;if(!Dt(e))throw new Error("ui8a expected");let n=e.length;if(n<2||e[0]!=48)throw new t("Invalid signature tag");if(e[1]!==n-2)throw new t("Invalid signature: incorrect length");let{d:s,l:o}=qe._parseInt(e.subarray(2)),{d:i,l:a}=qe._parseInt(o);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:s,s:i}},hexFromSig(r){let t=l=>Number.parseInt(l[0],16)&8?"00"+l:l,e=l=>{let f=l.toString(16);return f.length&1?`0${f}`:f},n=t(e(r.s)),s=t(e(r.r)),o=n.length/2,i=s.length/2,a=e(o),c=e(i);return`30${e(i+o+4)}02${c}${s}02${a}${n}`}},fe=BigInt(0),_t=BigInt(1),mm=BigInt(2),wc=BigInt(3),ym=BigInt(4);function Ch(r){let t=Lh(r),{Fp:e}=t,n=t.toBytes||((g,d,p)=>{let y=d.toAffine();return Qt(Uint8Array.from([4]),e.toBytes(y.x),e.toBytes(y.y))}),s=t.fromBytes||(g=>{let d=g.subarray(1),p=e.fromBytes(d.subarray(0,e.BYTES)),y=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:p,y}});function o(g){let{a:d,b:p}=t,y=e.sqr(g),v=e.mul(y,g);return e.add(e.add(v,e.mul(g,d)),p)}if(!e.eql(e.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function i(g){return typeof g=="bigint"&&fe<g&&g<t.n}function a(g){if(!i(g))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(g){let{allowedPrivateKeyLengths:d,nByteLength:p,wrapPrivateKey:y,n:v}=t;if(d&&typeof g!="bigint"){if(Dt(g)&&(g=Jt(g)),typeof g!="string"||!d.includes(g.length))throw new Error("Invalid key");g=g.padStart(p*2,"0")}let w;try{w=typeof g=="bigint"?g:Xt(et("private key",g,p))}catch{throw new Error(`private key must be ${p} bytes, hex or bigint, not ${typeof g}`)}return y&&(w=Y(w,v)),a(w),w}let l=new Map;function f(g){if(!(g instanceof u))throw new Error("ProjectivePoint expected")}class u{constructor(d,p,y){if(this.px=d,this.py=p,this.pz=y,d==null||!e.isValid(d))throw new Error("x required");if(p==null||!e.isValid(p))throw new Error("y required");if(y==null||!e.isValid(y))throw new Error("z required")}static fromAffine(d){let{x:p,y}=d||{};if(!d||!e.isValid(p)||!e.isValid(y))throw new Error("invalid affine point");if(d instanceof u)throw new Error("projective point not allowed");let v=w=>e.eql(w,e.ZERO);return v(p)&&v(y)?u.ZERO:new u(p,y,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let p=e.invertBatch(d.map(y=>y.pz));return d.map((y,v)=>y.toAffine(p[v])).map(u.fromAffine)}static fromHex(d){let p=u.fromAffine(s(et("pointHex",d)));return p.assertValidity(),p}static fromPrivateKey(d){return u.BASE.multiply(c(d))}_setWindowSize(d){this._WINDOW_SIZE=d,l.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!e.is0(this.py))return;throw new Error("bad point: ZERO")}let{x:d,y:p}=this.toAffine();if(!e.isValid(d)||!e.isValid(p))throw new Error("bad point: x or y not FE");let y=e.sqr(p),v=o(d);if(!e.eql(y,v))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){f(d);let{px:p,py:y,pz:v}=this,{px:w,py:T,pz:x}=d,A=e.eql(e.mul(p,x),e.mul(w,v)),R=e.eql(e.mul(y,x),e.mul(T,v));return A&&R}negate(){return new u(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:p}=t,y=e.mul(p,wc),{px:v,py:w,pz:T}=this,x=e.ZERO,A=e.ZERO,R=e.ZERO,N=e.mul(v,v),q=e.mul(w,w),K=e.mul(T,T),P=e.mul(v,w);return P=e.add(P,P),R=e.mul(v,T),R=e.add(R,R),x=e.mul(d,R),A=e.mul(y,K),A=e.add(x,A),x=e.sub(q,A),A=e.add(q,A),A=e.mul(x,A),x=e.mul(P,x),R=e.mul(y,R),K=e.mul(d,K),P=e.sub(N,K),P=e.mul(d,P),P=e.add(P,R),R=e.add(N,N),N=e.add(R,N),N=e.add(N,K),N=e.mul(N,P),A=e.add(A,N),K=e.mul(w,T),K=e.add(K,K),N=e.mul(K,P),x=e.sub(x,N),R=e.mul(K,q),R=e.add(R,R),R=e.add(R,R),new u(x,A,R)}add(d){f(d);let{px:p,py:y,pz:v}=this,{px:w,py:T,pz:x}=d,A=e.ZERO,R=e.ZERO,N=e.ZERO,q=t.a,K=e.mul(t.b,wc),P=e.mul(p,w),nt=e.mul(y,T),rt=e.mul(v,x),Nt=e.add(p,y),E=e.add(w,T);Nt=e.mul(Nt,E),E=e.add(P,nt),Nt=e.sub(Nt,E),E=e.add(p,v);let I=e.add(w,x);return E=e.mul(E,I),I=e.add(P,rt),E=e.sub(E,I),I=e.add(y,v),A=e.add(T,x),I=e.mul(I,A),A=e.add(nt,rt),I=e.sub(I,A),N=e.mul(q,E),A=e.mul(K,rt),N=e.add(A,N),A=e.sub(nt,N),N=e.add(nt,N),R=e.mul(A,N),nt=e.add(P,P),nt=e.add(nt,P),rt=e.mul(q,rt),E=e.mul(K,E),nt=e.add(nt,rt),rt=e.sub(P,rt),rt=e.mul(q,rt),E=e.add(E,rt),P=e.mul(nt,E),R=e.add(R,P),P=e.mul(I,E),A=e.mul(Nt,A),A=e.sub(A,P),P=e.mul(Nt,nt),N=e.mul(I,N),N=e.add(N,P),new u(A,R,N)}subtract(d){return this.add(d.negate())}is0(){return this.equals(u.ZERO)}wNAF(d){return m.wNAFCached(this,l,d,p=>{let y=e.invertBatch(p.map(v=>v.pz));return p.map((v,w)=>v.toAffine(y[w])).map(u.fromAffine)})}multiplyUnsafe(d){let p=u.ZERO;if(d===fe)return p;if(a(d),d===_t)return this;let{endo:y}=t;if(!y)return m.unsafeLadder(this,d);let{k1neg:v,k1:w,k2neg:T,k2:x}=y.splitScalar(d),A=p,R=p,N=this;for(;w>fe||x>fe;)w&_t&&(A=A.add(N)),x&_t&&(R=R.add(N)),N=N.double(),w>>=_t,x>>=_t;return v&&(A=A.negate()),T&&(R=R.negate()),R=new u(e.mul(R.px,y.beta),R.py,R.pz),A.add(R)}multiply(d){a(d);let p=d,y,v,{endo:w}=t;if(w){let{k1neg:T,k1:x,k2neg:A,k2:R}=w.splitScalar(p),{p:N,f:q}=this.wNAF(x),{p:K,f:P}=this.wNAF(R);N=m.constTimeNegate(T,N),K=m.constTimeNegate(A,K),K=new u(e.mul(K.px,w.beta),K.py,K.pz),y=N.add(K),v=q.add(P)}else{let{p:T,f:x}=this.wNAF(p);y=T,v=x}return u.normalizeZ([y,v])[0]}multiplyAndAddUnsafe(d,p,y){let v=u.BASE,w=(x,A)=>A===fe||A===_t||!x.equals(v)?x.multiplyUnsafe(A):x.multiply(A),T=w(this,p).add(w(d,y));return T.is0()?void 0:T}toAffine(d){let{px:p,py:y,pz:v}=this,w=this.is0();d==null&&(d=w?e.ONE:e.inv(v));let T=e.mul(p,d),x=e.mul(y,d),A=e.mul(v,d);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(A,e.ONE))throw new Error("invZ was invalid");return{x:T,y:x}}isTorsionFree(){let{h:d,isTorsionFree:p}=t;if(d===_t)return!0;if(p)return p(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:p}=t;return d===_t?this:p?p(u,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return this.assertValidity(),n(u,this,d)}toHex(d=!0){return Jt(this.toRawBytes(d))}}u.BASE=new u(t.Gx,t.Gy,e.ONE),u.ZERO=new u(e.ZERO,e.ONE,e.ZERO);let h=t.nBitLength,m=un(u,t.endo?Math.ceil(h/2):h);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function Dh(r){let t=Nr(r);return Kt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function xc(r){let t=Dh(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return fe<E&&E<e.ORDER}function a(E){return Y(E,n)}function c(E){return cn(E,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:h}=Ch({...t,toBytes(E,I,O){let B=I.toAffine(),b=e.toBytes(B.x),k=Qt;return O?k(Uint8Array.from([I.hasEvenY()?2:3]),b):k(Uint8Array.from([4]),b,e.toBytes(B.y))},fromBytes(E){let I=E.length,O=E[0],B=E.subarray(1);if(I===s&&(O===2||O===3)){let b=Xt(B);if(!i(b))throw new Error("Point is not on curve");let k=u(b),L=e.sqrt(k),_=(L&_t)===_t;return(O&1)===1!==_&&(L=e.neg(L)),{x:b,y:L}}else if(I===o&&O===4){let b=e.fromBytes(B.subarray(0,e.BYTES)),k=e.fromBytes(B.subarray(e.BYTES,2*e.BYTES));return{x:b,y:k}}else throw new Error(`Point of length ${I} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),m=E=>Jt(Ee(E,t.nByteLength));function g(E){let I=n>>_t;return E>I}function d(E){return g(E)?a(-E):E}let p=(E,I,O)=>Xt(E.slice(I,O));class y{constructor(I,O,B){this.r=I,this.s=O,this.recovery=B,this.assertValidity()}static fromCompact(I){let O=t.nByteLength;return I=et("compactSignature",I,O*2),new y(p(I,0,O),p(I,O,2*O))}static fromDER(I){let{r:O,s:B}=qe.toSig(et("DER",I));return new y(O,B)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(I){return new y(this.r,this.s,I)}recoverPublicKey(I){let{r:O,s:B,recovery:b}=this,k=R(et("msgHash",I));if(b==null||![0,1,2,3].includes(b))throw new Error("recovery id invalid");let L=b===2||b===3?O+t.n:O;if(L>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=b&1?"03":"02",V=l.fromHex(_+m(L)),F=c(L),j=a(-k*F),M=a(B*F),$=l.BASE.multiplyAndAddUnsafe(V,j,M);if(!$)throw new Error("point at infinify");return $.assertValidity(),$}hasHighS(){return g(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return Pe(this.toDERHex())}toDERHex(){return qe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Pe(this.toCompactHex())}toCompactHex(){return m(this.r)+m(this.s)}}let v={isValidPrivateKey(E){try{return f(E),!0}catch{return!1}},normPrivateKeyToScalar:f,randomPrivateKey:()=>{let E=io(t.n);return ia(t.randomBytes(E),t.n)},precompute(E=8,I=l.BASE){return I._setWindowSize(E),I.multiply(BigInt(3)),I}};function w(E,I=!0){return l.fromPrivateKey(E).toRawBytes(I)}function T(E){let I=Dt(E),O=typeof E=="string",B=(I||O)&&E.length;return I?B===s||B===o:O?B===2*s||B===2*o:E instanceof l}function x(E,I,O=!0){if(T(E))throw new Error("first arg must be private key");if(!T(I))throw new Error("second arg must be public key");return l.fromHex(I).multiply(f(E)).toRawBytes(O)}let A=t.bits2int||function(E){let I=Xt(E),O=E.length*8-t.nBitLength;return O>0?I>>BigInt(O):I},R=t.bits2int_modN||function(E){return a(A(E))},N=Rr(t.nBitLength);function q(E){if(typeof E!="bigint")throw new Error("bigint expected");if(!(fe<=E&&E<N))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Ee(E,t.nByteLength)}function K(E,I,O=P){if(["recovered","canonical"].some(Q=>Q in O))throw new Error("sign() legacy options not supported");let{hash:B,randomBytes:b}=t,{lowS:k,prehash:L,extraEntropy:_}=O;k==null&&(k=!0),E=et("msgHash",E),L&&(E=et("prehashed msgHash",B(E)));let V=R(E),F=f(I),j=[q(F),q(V)];if(_!=null){let Q=_===!0?b(e.BYTES):_;j.push(et("extraEntropy",Q))}let M=Qt(...j),$=V;function st(Q){let ft=A(Q);if(!h(ft))return;let ht=c(ft),it=l.BASE.multiply(ft).toAffine(),mt=a(it.x);if(mt===fe)return;let zt=a(ht*a($+mt*F));if(zt===fe)return;let Ue=(it.x===mt?0:2)|Number(it.y&_t),Br=zt;return k&&g(zt)&&(Br=d(zt),Ue^=1),new y(mt,Br,Ue)}return{seed:M,k2sig:st}}let P={lowS:t.lowS,prehash:!1},nt={lowS:t.lowS,prehash:!1};function rt(E,I,O=P){let{seed:B,k2sig:b}=K(E,I,O),k=t;return ro(k.hash.outputLen,k.nByteLength,k.hmac)(B,b)}l.BASE._setWindowSize(8);function Nt(E,I,O,B=nt){let b=E;if(I=et("msgHash",I),O=et("publicKey",O),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:k,prehash:L}=B,_,V;try{if(typeof b=="string"||Dt(b))try{_=y.fromDER(b)}catch(it){if(!(it instanceof qe.Err))throw it;_=y.fromCompact(b)}else if(typeof b=="object"&&typeof b.r=="bigint"&&typeof b.s=="bigint"){let{r:it,s:mt}=b;_=new y(it,mt)}else throw new Error("PARSE");V=l.fromHex(O)}catch(it){if(it.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(k&&_.hasHighS())return!1;L&&(I=t.hash(I));let{r:F,s:j}=_,M=R(I),$=c(j),st=a(M*$),Q=a(F*$),ft=l.BASE.multiplyAndAddUnsafe(V,st,Q)?.toAffine();return ft?a(ft.x)===F:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:x,sign:rt,verify:Nt,ProjectivePoint:l,Signature:y,utils:v}}function Ph(r){return{hash:r,hmac:(t,...e)=>Cr(r,t,rn(...e)),randomBytes:nr}}function vc(r,t){let e=n=>xc({...r,...Ph(n)});return Object.freeze({...e(t),create:e})}var Ac=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ec=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Oh=BigInt(1),Vo=BigInt(2),Bc=(r,t)=>(r+t/Vo)/t;function Vh(r){let t=Ac,e=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),l=r*r*r%t,f=l*l*r%t,u=X(f,e,t)*f%t,h=X(u,e,t)*f%t,m=X(h,Vo,t)*l%t,g=X(m,s,t)*m%t,d=X(g,o,t)*g%t,p=X(d,a,t)*d%t,y=X(p,c,t)*p%t,v=X(y,a,t)*d%t,w=X(v,e,t)*f%t,T=X(w,i,t)*g%t,x=X(T,n,t)*l%t,A=X(x,Vo,t);if(!Fo.eql(Fo.sqr(A),r))throw new Error("Cannot find square root");return A}var Fo=ln(Ac,void 0,void 0,{sqrt:Vh}),Ht=vc({a:BigInt(0),b:BigInt(7),Fp:Fo,n:Ec,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Ec,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Oh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),a=Bc(o*r,t),c=Bc(-n*r,t),l=Y(r-a*e-c*s,t),f=Y(-a*n-c*o,t),u=l>i,h=f>i;if(u&&(l=t-l),h&&(f=t-f),l>i||f>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:u,k1:l,k2neg:h,k2:f}}}},bc),km=BigInt(0);var Im=Ht.ProjectivePoint;function Sc(){return Ht.utils.randomPrivateKey()}function kc(r,t){let e=dt.digest(t instanceof Uint8Array?t:t.subarray());if(Tt(e))return e.then(({digest:n})=>Ht.sign(n,r).toDERRawBytes()).catch(n=>{throw new U(String(n),"ERR_INVALID_INPUT")});try{return Ht.sign(e.digest,r).toDERRawBytes()}catch(n){throw new U(String(n),"ERR_INVALID_INPUT")}}function Ic(r,t,e){let n=dt.digest(e instanceof Uint8Array?e:e.subarray());if(Tt(n))return n.then(({digest:s})=>Ht.verify(t,s,r)).catch(s=>{throw new U(String(s),"ERR_INVALID_INPUT")});try{return Ht.verify(t,n.digest,r)}catch(s){throw new U(String(s),"ERR_INVALID_INPUT")}}function Rc(r){return Ht.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Nc(r){try{Ht.getPublicKey(r,!0)}catch(t){throw new U(String(t),"ERR_INVALID_PRIVATE_KEY")}}function Ho(r){try{Ht.ProjectivePoint.fromHex(r)}catch(t){throw new U(String(t),"ERR_INVALID_PUBLIC_KEY")}}function Tc(r){try{return Ht.getPublicKey(r,!0)}catch(t){throw new U(String(t),"ERR_INVALID_PRIVATE_KEY")}}var zr=class{_key;constructor(t){Ho(t),this._key=t}verify(t,e){return Ic(this._key,e,t)}marshal(){return Rc(this._key)}get bytes(){return Ae.encode({Type:pt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return yt(this.bytes,t.bytes)}async hash(){let t=dt.digest(this.bytes),e;return Tt(t)?{bytes:e}=await t:e=t.bytes,e}},jr=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e??Tc(t),Nc(this._key),Ho(this._publicKey)}sign(t){return kc(this._key,t)}get public(){return new zr(this._publicKey)}marshal(){return this._key}get bytes(){return Se.encode({Type:pt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return yt(this.bytes,t.bytes)}hash(){let t=dt.digest(this.bytes);return Tt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return G(t,"base58btc")}async export(t,e="libp2p-key"){if(e==="libp2p-key")return cr(this.bytes,t);throw new U(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Hh(r){return new jr(r)}function Mh(r){return new zr(r)}async function Kh(){let r=Sc();return new jr(r)}var Lc={rsa:Po,ed25519:ko,secp256k1:Mo};function $h(r){let t=Object.keys(Lc).join(" / ");return new U(`invalid or unsupported key type ${r}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Ko(r){if(r=r.toLowerCase(),r==="rsa"||r==="ed25519"||r==="secp256k1")return Lc[r];throw $h(r)}async function _c(r,t){return Ko(r).generateKeyPair(t??2048)}function Uc(r,t){return t=(t??"rsa").toLowerCase(),Ko(t),r.bytes}function Cc(r,t){return t=(t??"rsa").toLowerCase(),Ko(t),r.bytes}var Dc=async()=>{let r=await _c("Ed25519"),t=await qh(r);if(t.type==="Ed25519")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function qh(r){return $i(Uc(r.public),Cc(r))}var is=class{index=0;input="";new(t){return this.index=0,this.input=t,this}readAtomically(t){let e=this.index,n=t();return n===void 0&&(this.index=e),n}parseWith(t){let e=t();if(this.index===this.input.length)return e}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(t){return this.readAtomically(()=>{let e=this.readChar();if(e===t)return e})}readSeparator(t,e,n){return this.readAtomically(()=>{if(!(e>0&&this.readGivenChar(t)===void 0))return n()})}readNumber(t,e,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",l=2**(8*s)-1;for(;;){let f=this.readAtomically(()=>{let u=this.readChar();if(u===void 0)return;let h=Number.parseInt(u,t);if(!Number.isNaN(h))return h});if(f===void 0)break;if(o*=t,o+=f,o>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let t=new Uint8Array(4);for(let e=0;e<t.length;e++){let n=this.readSeparator(".",e,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;t[e]=n}return t})}readIPv6Addr(){let t=e=>{for(let n=0;n<e.length/2;n++){let s=n*2;if(n<e.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return e[s]=i[0],e[s+1]=i[1],e[s+2]=i[2],e[s+3]=i[3],[s+4,!0]}let o=this.readSeparator(":",n,()=>this.readNumber(16,4,!0,2));if(o===void 0)return[s,!1];e[s]=o>>8,e[s+1]=o&255}return[e.length,!1]};return this.readAtomically(()=>{let e=new Uint8Array(16),[n,s]=t(e);if(n===16)return e;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=t(o.subarray(0,i));return e.set(o.subarray(0,a),16-a),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Pc=45,Gh=15,yr=new is;function $o(r){if(!(r.length>Gh))return yr.new(r).parseWith(()=>yr.readIPv4Addr())}function qo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Pc))return yr.new(r).parseWith(()=>yr.readIPv6Addr())}function as(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Pc))return yr.new(r).parseWith(()=>yr.readIPAddr())}function cs(r){return!!$o(r)}function ls(r){return!!qo(r)}function us(r){return!!as(r)}var Vc=Bs(Oc(),1),zh=["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"],jh=zh.map(r=>new Vc.Netmask(r));function Wh(r){for(let t of jh)if(t.contains(r))return!0;return!1}function Yh(r){return/^::$/.test(r)||/^::1$/.test(r)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function Go(r){return cs(r)?Wh(r):ls(r)?Yh(r):void 0}var Zh=Math.pow(2,7),Jh=Math.pow(2,14),Xh=Math.pow(2,21),zo=Math.pow(2,28),jo=Math.pow(2,35),Wo=Math.pow(2,42),Yo=Math.pow(2,49),z=128,vt=127;function It(r){if(r<Zh)return 1;if(r<Jh)return 2;if(r<Xh)return 3;if(r<zo)return 4;if(r<jo)return 5;if(r<Wo)return 6;if(r<Yo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Qh(r,t,e=0){switch(It(r)){case 8:t[e++]=r&255|z,r/=128;case 7:t[e++]=r&255|z,r/=128;case 6:t[e++]=r&255|z,r/=128;case 5:t[e++]=r&255|z,r/=128;case 4:t[e++]=r&255|z,r>>>=7;case 3:t[e++]=r&255|z,r>>>=7;case 2:t[e++]=r&255|z,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function td(r,t,e=0){switch(It(r)){case 8:t.set(e++,r&255|z),r/=128;case 7:t.set(e++,r&255|z),r/=128;case 6:t.set(e++,r&255|z),r/=128;case 5:t.set(e++,r&255|z),r/=128;case 4:t.set(e++,r&255|z),r>>>=7;case 3:t.set(e++,r&255|z),r>>>=7;case 2:t.set(e++,r&255|z),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function ed(r,t){let e=r[t],n=0;if(n+=e&vt,e<z||(e=r[t+1],n+=(e&vt)<<7,e<z)||(e=r[t+2],n+=(e&vt)<<14,e<z)||(e=r[t+3],n+=(e&vt)<<21,e<z)||(e=r[t+4],n+=(e&vt)*zo,e<z)||(e=r[t+5],n+=(e&vt)*jo,e<z)||(e=r[t+6],n+=(e&vt)*Wo,e<z)||(e=r[t+7],n+=(e&vt)*Yo,e<z))return n;throw new RangeError("Could not decode varint")}function rd(r,t){let e=r.get(t),n=0;if(n+=e&vt,e<z||(e=r.get(t+1),n+=(e&vt)<<7,e<z)||(e=r.get(t+2),n+=(e&vt)<<14,e<z)||(e=r.get(t+3),n+=(e&vt)<<21,e<z)||(e=r.get(t+4),n+=(e&vt)*zo,e<z)||(e=r.get(t+5),n+=(e&vt)*jo,e<z)||(e=r.get(t+6),n+=(e&vt)*Wo,e<z)||(e=r.get(t+7),n+=(e&vt)*Yo,e<z))return n;throw new RangeError("Could not decode varint")}function _e(r,t,e=0){return t==null&&(t=bt(It(r))),t instanceof Uint8Array?Qh(r,t,e):td(r,t,e)}function he(r,t=0){return r instanceof Uint8Array?ed(r,t):rd(r,t)}var cy=parseInt("0xFFFF",16),ly=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var Mc=cs,ad=ls,Zo=function(r){let t=0;if(r=r.toString().trim(),Mc(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(ad(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=Mc(e[n]),i;o&&(i=Zo(e[n]),e[n]=G(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,G(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);s[t++]=o>>8&255,s[t++]=o&255}return s}throw new Error("invalid ip address")},Kc=function(r,t=0,e){t=~~t,e=e??r.length-t;let n=new DataView(r.buffer);if(e===4){let s=[];for(let o=0;o<e;o++)s.push(r[t+o]);return s.join(".")}if(e===16){let s=[];for(let o=0;o<e;o+=2)s.push(n.getUint16(t+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var br={},Jo={},ld=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,-1,"memory"]];ld.forEach(r=>{let t=ud(...r);Jo[t.code]=t,br[t.name]=t});function ud(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function W(r){if(typeof r=="number"){if(Jo[r]!=null)return Jo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(br[r]!=null)return br[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var qy=W("ip4"),Gy=W("ip6"),zy=W("ipcidr");function Qo(r,t){switch(W(r).code){case 4:case 41:return hd(t);case 42:return Gc(t);case 6:case 273:case 33:case 132:return jc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Gc(t);case 421:return md(t);case 444:return zc(t);case 445:return zc(t);case 466:return gd(t);default:return G(t,"base16")}}function ti(r,t){switch(W(r).code){case 4:return $c(t);case 41:return $c(t);case 42:return qc(t);case 6:case 273:case 33:case 132:return ei(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return qc(t);case 421:return dd(t);case 444:return yd(t);case 445:return bd(t);case 466:return pd(t);default:return Z(t,"base16")}}var Xo=Object.values(me).map(r=>r.decoder),fd=function(){let r=Xo[0].or(Xo[1]);return Xo.slice(2).forEach(t=>r=r.or(t)),r}();function $c(r){if(!us(r))throw new Error("invalid ip address");return Zo(r)}function hd(r){let t=Kc(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!us(t))throw new Error("invalid ip address");return t}function ei(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function jc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function qc(r){let t=Z(r),e=Uint8Array.from(_e(t.length));return Et([e,t],e.length+t.length)}function Gc(r){let t=he(r);if(r=r.slice(It(t)),r.length!==t)throw new Error("inconsistent lengths");return G(r)}function dd(r){let t;r[0]==="Q"||r[0]==="1"?t=Ce(at.decode(`z${r}`)).bytes:t=Ut.parse(r).multihash.bytes;let e=Uint8Array.from(_e(t.length));return Et([e,t],e.length+t.length)}function pd(r){let t=fd.decode(r),e=Uint8Array.from(_e(t.length));return Et([e,t],e.length+t.length)}function gd(r){let t=he(r),e=r.slice(It(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+G(e,"base64url")}function md(r){let t=he(r),e=r.slice(It(t));if(e.length!==t)throw new Error("inconsistent lengths");return G(e,"base58btc")}function yd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==16)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);let e=Wt.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ei(n);return Et([e,s],e.length+s.length)}function bd(r){let t=r.split(":");if(t.length!==2)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(t[0].length!==56)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);let e=Wt.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=ei(n);return Et([e,s],e.length+s.length)}function zc(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=G(t,"base32"),s=jc(e);return`${n}:${s}`}function Wc(r){r=ri(r);let t=[],e=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<s.length;o++){let i=s[o],a=W(i);if(a.size===0){t.push([a.code]),e.push([a.code]);continue}if(o++,o>=s.length)throw Zc("invalid address: "+r);if(a.path===!0){n=ri(s.slice(o).join("/")),t.push([a.code,ti(a.code,n)]),e.push([a.code,n]);break}let c=ti(a.code,s[o]);t.push([a.code,c]),e.push([a.code,Qo(a.code,c)])}return{string:Yc(e),bytes:si(t),tuples:t,stringTuples:e,path:n}}function ni(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=he(r,s),i=It(o),a=W(o),c=wd(a,r.slice(s+i));if(c===0){t.push([o]),e.push([o]),s+=i;continue}let l=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw Zc("Invalid address Uint8Array: "+G(r,"base16"));t.push([o,l]);let f=Qo(o,l);if(e.push([o,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:Yc(e),tuples:t,stringTuples:e,path:n}}function Yc(r){let t=[];return r.map(e=>{let n=W(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),ri(t.join("/"))}function si(r){return Et(r.map(t=>{let e=W(t[0]),n=Uint8Array.from(_e(e.code));return t.length>1&&t[1]!=null&&(n=Et([n,t[1]])),n}))}function wd(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=he(t instanceof Uint8Array?t:Uint8Array.from(t));return e+It(e)}}function ri(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Zc(r){return new Error("Error parsing address: "+r)}var xd=Symbol.for("nodejs.util.inspect.custom"),oi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),vd=[W("dns").code,W("dns4").code,W("dns6").code,W("dnsaddr").code],hs=class r{bytes;#e;#t;#r;#n;[oi]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=ni(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Wc(t)}else if(Xc(t))e=ni(t.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=e.bytes,this.#e=e.string,this.#t=e.tuples,this.#r=e.stringTuples,this.#n=e.path}toString(){return this.#e}toJSON(){return this.toString()}toOptions(){let t,e,n,s,o="",i=W("tcp"),a=W("udp"),c=W("ip4"),l=W("ip6"),f=W("dns6"),u=W("ip6zone");for(let[m,g]of this.stringTuples())m===u.code&&(o=`%${g??""}`),vd.includes(m)&&(e=i.name,s=443,n=`${g??""}${o}`,t=m===f.code?6:4),(m===i.code||m===a.code)&&(e=W(m).name,s=parseInt(g??"")),(m===c.code||m===l.code)&&(e=W(m).name,n=`${g??""}${o}`,t=m===l.code?6:4);if(t==null||e==null||n==null||s==null)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:t,host:n,transport:e,port:s}}protos(){return this.#t.map(([t])=>Object.assign({},W(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>W(t).name)}tuples(){return this.#t}stringTuples(){return this.#r}encapsulate(t){return t=new r(t),new r(this.toString()+t.toString())}decapsulate(t){let e=t.toString(),n=this.toString(),s=n.lastIndexOf(e);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${t.toString()}`);return new r(n.slice(0,s))}decapsulateCode(t){let e=this.tuples();for(let n=e.length-1;n>=0;n--)if(e[n][0]===t)return new r(si(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===br.p2p.code&&t.push([n,s]),n===br["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?G(at.decode(`z${n}`),"base58btc"):G(Ut.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return yt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=Jc.get(e.name);if(n==null)throw new U(`no available resolver for ${e.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,t)).map(o=>new r(o))}nodeAddress(){let t=this.toOptions();if(t.transport!=="tcp"&&t.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${t.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:t.family,address:t.host,port:t.port}}isThinWaistAddress(t){let e=(t??this).protos();return!(e.length!==2||e[0].code!==4&&e[0].code!==41||e[1].code!==6&&e[1].code!==273)}[xd](){return`Multiaddr(${this.#e})`}};var Jc=new Map;function Xc(r){return!!r?.[oi]}function ds(r){return new hs(r)}function Ed(r){return r[Symbol.asyncIterator]!=null}function Bd(r){if(Ed(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var ii=Bd;var tl=Symbol.for("@achingbrain/uint8arraylist");function Qc(r,t){if(t==null||t<0)throw new RangeError("index is out of bounds");let e=0;for(let n of r){let s=e+n.byteLength;if(t<s)return{buf:n,index:t-e};e=s}throw new RangeError("index is out of bounds")}function ps(r){return!!r?.[tl]}var wr=class r{bufs;length;[tl]=!0;constructor(...t){this.bufs=[],this.length=0,t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...t){this.appendAll(t)}appendAll(t){let e=0;for(let n of t)if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.push(n);else if(ps(n))e+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}prepend(...t){this.prependAll(t)}prependAll(t){let e=0;for(let n of t.reverse())if(n instanceof Uint8Array)e+=n.byteLength,this.bufs.unshift(n);else if(ps(n))e+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=e}get(t){let e=Qc(this.bufs,t);return e.buf[e.index]}set(t,e){let n=Qc(this.bufs,t);n.buf[n.index]=e}write(t,e=0){if(t instanceof Uint8Array)for(let n=0;n<t.length;n++)this.set(e+n,t[n]);else if(ps(t))for(let n=0;n<t.length;n++)this.set(e+n,t.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(t){if(t=Math.trunc(t),!(Number.isNaN(t)||t<=0)){if(t===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(t>=this.bufs[0].byteLength)t-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(t),this.length-=t;break}}}slice(t,e){let{bufs:n,length:s}=this._subList(t,e);return Et(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Et(n,s)}sublist(t,e){let{bufs:n,length:s}=this._subList(t,e),o=new r;return o.length=s,o.bufs=[...n],o}_subList(t,e){if(t=t??0,e=e??this.length,t<0&&(t=this.length+t),e<0&&(e=this.length+e),t<0||e>this.length)throw new RangeError("index is out of bounds");if(t===e)return{bufs:[],length:0};if(t===0&&e===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let o=0;o<this.bufs.length;o++){let i=this.bufs[o],a=s,c=a+i.byteLength;if(s=c,t>=c)continue;let l=t>=a&&t<c,f=e>a&&e<=c;if(l&&f){if(t===a&&e===c){n.push(i);break}let u=t-a;n.push(i.subarray(u,u+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-a));continue}if(f){if(e===c){n.push(i);break}n.push(i.subarray(0,e-a));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!ps(t)&&!(t instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=t instanceof Uint8Array?t:t.subarray();if(e=Number(e??0),isNaN(e)&&(e=0),e<0&&(e=this.length+e),e<0&&(e=0),t.length===0)return e>this.length?this.length:e;let s=n.byteLength;if(s===0)throw new TypeError("search must be at least 1 byte long");let o=256,i=new Int32Array(o);for(let u=0;u<o;u++)i[u]=-1;for(let u=0;u<s;u++)i[n[u]]=u;let a=i,c=this.byteLength-n.byteLength,l=n.byteLength-1,f;for(let u=e;u<=c;u+=f){f=0;for(let h=l;h>=0;h--){let m=this.get(u+h);if(n[h]!==m){f=Math.max(1,h-a[m]);break}}if(f===0)return u}return-1}getInt8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getInt8(0)}setInt8(t,e){let n=bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,e),this.write(n,t)}getInt16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,e)}setInt16(t,e,n){let s=Yt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,e,n),this.write(s,t)}getInt32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,e)}setInt32(t,e,n){let s=Yt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,e,n),this.write(s,t)}getBigInt64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,e)}setBigInt64(t,e,n){let s=Yt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,e,n),this.write(s,t)}getUint8(t){let e=this.subarray(t,t+1);return new DataView(e.buffer,e.byteOffset,e.byteLength).getUint8(0)}setUint8(t,e){let n=bt(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,e),this.write(n,t)}getUint16(t,e){let n=this.subarray(t,t+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,e)}setUint16(t,e,n){let s=Yt(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,e,n),this.write(s,t)}getUint32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,e)}setUint32(t,e,n){let s=Yt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,e,n),this.write(s,t)}getBigUint64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,e)}setBigUint64(t,e,n){let s=Yt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,e,n),this.write(s,t)}getFloat32(t,e){let n=this.subarray(t,t+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,e)}setFloat32(t,e,n){let s=Yt(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,e,n),this.write(s,t)}getFloat64(t,e){let n=this.subarray(t,t+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,e)}setFloat64(t,e,n){let s=Yt(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,e,n),this.write(s,t)}equals(t){if(t==null||!(t instanceof r)||t.bufs.length!==this.bufs.length)return!1;for(let e=0;e<this.bufs.length;e++)if(!yt(this.bufs[e],t.bufs[e]))return!1;return!0}static fromUint8Arrays(t,e){let n=new r;return n.bufs=t,e==null&&(e=t.reduce((s,o)=>s+o.byteLength,0)),n.length=e,n}};function gs(r){return r[Symbol.asyncIterator]!=null}var ms=r=>{let t=It(r),e=bt(t);return _e(r,e),ms.bytes=t,e};ms.bytes=0;function Yr(r,t){t=t??{};let e=t.lengthEncoder??ms;function*n(s){let o=e(s.byteLength);o instanceof Uint8Array?yield o:yield*o,s instanceof Uint8Array?yield s:yield*s}return gs(r)?async function*(){for await(let s of r)yield*n(s)}():function*(){for(let s of r)yield*n(s)}()}Yr.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??ms;return new wr(e(r.byteLength),r)};var xr=Bs(nl(),1);var Sd=8,kd=1024*1024*4,Ge;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ge||(Ge={}));var ai=r=>{let t=he(r);return ai.bytes=It(t),t};ai.bytes=0;function vr(r,t){let e=new wr,n=Ge.LENGTH,s=-1,o=t?.lengthDecoder??ai,i=t?.maxLengthLength??Sd,a=t?.maxDataLength??kd;function*c(){for(;e.byteLength>0;){if(n===Ge.LENGTH)try{if(s=o(e),s<0)throw(0,xr.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>a)throw(0,xr.default)(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");let l=o.bytes;e.consume(l),t?.onLength!=null&&t.onLength(s),n=Ge.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>i)throw(0,xr.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw l}if(n===Ge.DATA){if(e.byteLength<s)break;let l=e.sublist(0,s);e.consume(s),t?.onData!=null&&t.onData(l),yield l,n=Ge.LENGTH}}}return gs(r)?async function*(){for await(let l of r)e.append(l),yield*c();if(e.byteLength>0)throw(0,xr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(let l of r)e.append(l),yield*c();if(e.byteLength>0)throw(0,xr.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}vr.fromReader=(r,t)=>{let e=1,n=async function*(){for(;;)try{let{done:o,value:i}=await r.next(e);if(o===!0)return;i!=null&&(yield i)}catch(o){if(o.code==="ERR_UNDER_READ")return{done:!0,value:null};throw o}finally{e=1}}();return vr(n,{...t??{},onLength:o=>{e=o}})};function Rd(r){let[t,e]=r[Symbol.asyncIterator]!=null?[r[Symbol.asyncIterator](),Symbol.asyncIterator]:[r[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:s=>{n.push(s)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[e](){return this}}}var sl=Rd;function Nd(r){return r[Symbol.asyncIterator]!=null}function Td(r,t){if(Nd(r))return async function*(){for await(let a of r)yield t(a)}();let e=sl(r),{value:n,done:s}=e.next();if(s===!0)return function*(){}();let o=t(n);if(typeof o.then=="function")return async function*(){yield await o;for await(let a of e)yield t(a)}();let i=t;return function*(){yield o;for(let a of e)yield i(a)}()}var ol=Td;function de(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var ys=globalThis.CustomEvent??Event;async function*ci(r,t={}){let e=t.concurrency??1/0;e<1&&(e=1/0);let n=t.ordered==null?!1:t.ordered,s=new EventTarget,o=[],i=de(),a=de(),c=!1,l,f=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let g of r){if(o.length===e&&(i=de(),await i.promise),f)break;let d={done:!1};o.push(d),g().then(p=>{d.done=!0,d.ok=!0,d.value=p,s.dispatchEvent(new ys("task-complete"))},p=>{d.done=!0,d.err=p,s.dispatchEvent(new ys("task-complete"))})}c=!0,s.dispatchEvent(new ys("task-complete"))}catch(g){l=g,s.dispatchEvent(new ys("task-complete"))}});function u(){return n?o[0]?.done:!!o.find(g=>g.done)}function*h(){for(;o.length>0&&o[0].done;){let g=o[0];if(o.shift(),g.ok)yield g.value;else throw f=!0,i.resolve(),g.err;i.resolve()}}function*m(){for(;u();)for(let g=0;g<o.length;g++)if(o[g].done){let d=o[g];if(o.splice(g,1),g--,d.ok)yield d.value;else throw f=!0,i.resolve(),d.err;i.resolve()}}for(;;){if(u()||(a=de(),await a.promise),l!=null)throw l;if(n?yield*h():yield*m(),c&&o.length===0)break}}var bs=class{buffer;mask;top;btm;next;constructor(t){if(!(t>0)||t-1&t)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(t),this.mask=t-1,this.top=0,this.btm=0,this.next=null}push(t){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=t,this.top=this.top+1&this.mask,!0)}shift(){let t=this.buffer[this.btm];if(t!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,t}isEmpty(){return this.buffer[this.btm]===void 0}},Er=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new bs(this.hwm),this.tail=this.head,this.size=0}calculateSize(t){return t?.byteLength!=null?t.byteLength:1}push(t){if(t?.value!=null&&(this.size+=this.calculateSize(t.value)),!this.head.push(t)){let e=this.head;this.head=e.next=new bs(2*this.head.buffer.length),this.head.push(t)}}shift(){let t=this.tail.shift();if(t===void 0&&this.tail.next!=null){let e=this.tail.next;this.tail.next=null,this.tail=e,t=this.tail.shift()}return t?.value!=null&&(this.size-=this.calculateSize(t.value)),t}isEmpty(){return this.head.isEmpty()}};var li=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function ws(r={}){return Ld(e=>{let n=e.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},r)}function Ld(r,t){t=t??{};let e=t.onEnd,n=new Er,s,o,i,a=de(),c=async()=>{try{return n.isEmpty()?i?{done:!0}:await new Promise((p,y)=>{o=v=>{o=null,n.push(v);try{p(r(n))}catch(w){y(w)}return s}}):r(n)}finally{n.isEmpty()&&queueMicrotask(()=>{a.resolve(),a=de()})}},l=p=>o!=null?o(p):(n.push(p),s),f=p=>(n=new Er,o!=null?o({error:p}):(n.push({error:p}),s)),u=p=>{if(i)return s;if(t?.objectMode!==!0&&p?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:p})},h=p=>i?s:(i=!0,p!=null?f(p):l({done:!0})),m=()=>(n=new Er,h(),{done:!0}),g=p=>(h(p),{done:!0});if(s={[Symbol.asyncIterator](){return this},next:c,return:m,throw:g,push:u,end:h,get readableLength(){return n.size},onEmpty:async p=>{let y=p?.signal;if(y?.throwIfAborted(),n.isEmpty())return;let v,w;y!=null&&(v=new Promise((T,x)=>{w=()=>{x(new li)},y.addEventListener("abort",w)}));try{await Promise.race([a.promise,v])}finally{w!=null&&y!=null&&y?.removeEventListener("abort",w)}}},e==null)return s;let d=s;return s={[Symbol.asyncIterator](){return this},next(){return d.next()},throw(p){return d.throw(p),e!=null&&(e(p),e=void 0),{done:!0}},return(){return d.return(),e!=null&&(e(),e=void 0),{done:!0}},push:u,end(p){return d.end(p),e!=null&&(e(p),e=void 0),s},get readableLength(){return d.readableLength},onEmpty:p=>d.onEmpty(p)},s}function _d(r){return r[Symbol.asyncIterator]!=null}function Ud(...r){let t=[];for(let e of r)_d(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=ws({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(r.map(async n=>{for await(let s of n)e.push(s)})),e.end()}catch(n){e.end(n)}}),yield*e}()}var il=Ud;function fi(r,...t){if(r==null)throw new Error("Empty pipeline");if(ui(r)){let n=r;r=()=>n.source}else if(cl(r)||al(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&ui(e[e.length-1])&&(e[e.length-1]=e[e.length-1].sink),e.length>2)for(let n=1;n<e.length-1;n++)ui(e[n])&&(e[n]=Dd(e[n]));return Cd(...e)}var Cd=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},al=r=>r?.[Symbol.asyncIterator]!=null,cl=r=>r?.[Symbol.iterator]!=null,ui=r=>r==null?!1:r.sink!=null&&r.source!=null,Dd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=ws({objectMode:!0});e.then(()=>{n.end()},i=>{n.end(i)});let s,o=r.source;if(al(o))s=async function*(){yield*o,n.end()};else if(cl(o))s=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return il(n,s())}return r.source};var ll="libp2p",ul="autonat",fl="1.0.0";var D;(function(r){let t;(function(l){l.DIAL="DIAL",l.DIAL_RESPONSE="DIAL_RESPONSE"})(t=r.MessageType||(r.MessageType={}));let e;(function(l){l[l.DIAL=0]="DIAL",l[l.DIAL_RESPONSE=1]="DIAL_RESPONSE"})(e||(e={})),function(l){l.codec=()=>ur(e)}(t=r.MessageType||(r.MessageType={}));let n;(function(l){l.OK="OK",l.E_DIAL_ERROR="E_DIAL_ERROR",l.E_DIAL_REFUSED="E_DIAL_REFUSED",l.E_BAD_REQUEST="E_BAD_REQUEST",l.E_INTERNAL_ERROR="E_INTERNAL_ERROR"})(n=r.ResponseStatus||(r.ResponseStatus={}));let s;(function(l){l[l.OK=0]="OK",l[l.E_DIAL_ERROR=100]="E_DIAL_ERROR",l[l.E_DIAL_REFUSED=101]="E_DIAL_REFUSED",l[l.E_BAD_REQUEST=200]="E_BAD_REQUEST",l[l.E_INTERNAL_ERROR=300]="E_INTERNAL_ERROR"})(s||(s={})),function(l){l.codec=()=>ur(s)}(n=r.ResponseStatus||(r.ResponseStatus={}));let o;(function(l){let f;l.codec=()=>(f==null&&(f=se((u,h,m={})=>{if(m.lengthDelimited!==!1&&h.fork(),u.id!=null&&(h.uint32(10),h.bytes(u.id)),u.addrs!=null)for(let g of u.addrs)h.uint32(18),h.bytes(g);m.lengthDelimited!==!1&&h.ldelim()},(u,h)=>{let m={addrs:[]},g=h==null?u.len:u.pos+h;for(;u.pos<g;){let d=u.uint32();switch(d>>>3){case 1:m.id=u.bytes();break;case 2:m.addrs.push(u.bytes());break;default:u.skipType(d&7);break}}return m})),f),l.encode=u=>ne(u,l.codec()),l.decode=u=>re(u,l.codec())})(o=r.PeerInfo||(r.PeerInfo={}));let i;(function(l){let f;l.codec=()=>(f==null&&(f=se((u,h,m={})=>{m.lengthDelimited!==!1&&h.fork(),u.peer!=null&&(h.uint32(10),r.PeerInfo.codec().encode(u.peer,h)),m.lengthDelimited!==!1&&h.ldelim()},(u,h)=>{let m={},g=h==null?u.len:u.pos+h;for(;u.pos<g;){let d=u.uint32();switch(d>>>3){case 1:m.peer=r.PeerInfo.codec().decode(u,u.uint32());break;default:u.skipType(d&7);break}}return m})),f),l.encode=u=>ne(u,l.codec()),l.decode=u=>re(u,l.codec())})(i=r.Dial||(r.Dial={}));let a;(function(l){let f;l.codec=()=>(f==null&&(f=se((u,h,m={})=>{m.lengthDelimited!==!1&&h.fork(),u.status!=null&&(h.uint32(8),r.ResponseStatus.codec().encode(u.status,h)),u.statusText!=null&&(h.uint32(18),h.string(u.statusText)),u.addr!=null&&(h.uint32(26),h.bytes(u.addr)),m.lengthDelimited!==!1&&h.ldelim()},(u,h)=>{let m={},g=h==null?u.len:u.pos+h;for(;u.pos<g;){let d=u.uint32();switch(d>>>3){case 1:m.status=r.ResponseStatus.codec().decode(u);break;case 2:m.statusText=u.string();break;case 3:m.addr=u.bytes();break;default:u.skipType(d&7);break}}return m})),f),l.encode=u=>ne(u,l.codec()),l.decode=u=>re(u,l.codec())})(a=r.DialResponse||(r.DialResponse={}));let c;r.codec=()=>(c==null&&(c=se((l,f,u={})=>{u.lengthDelimited!==!1&&f.fork(),l.type!=null&&(f.uint32(8),r.MessageType.codec().encode(l.type,f)),l.dial!=null&&(f.uint32(18),r.Dial.codec().encode(l.dial,f)),l.dialResponse!=null&&(f.uint32(26),r.DialResponse.codec().encode(l.dialResponse,f)),u.lengthDelimited!==!1&&f.ldelim()},(l,f)=>{let u={},h=f==null?l.len:l.pos+f;for(;l.pos<h;){let m=l.uint32();switch(m>>>3){case 1:u.type=r.MessageType.codec().decode(l);break;case 2:u.dial=r.Dial.codec().decode(l,l.uint32());break;case 3:u.dialResponse=r.DialResponse.codec().decode(l,l.uint32());break;default:l.skipType(m&7);break}}return u})),c),r.encode=l=>ne(l,r.codec()),r.decode=l=>re(l,r.codec())})(D||(D={}));var hi=4,xs=class{components;startupDelay;refreshInterval;protocol;timeout;maxInboundStreams;maxOutboundStreams;verifyAddressTimeout;started;log;constructor(t,e){this.components=t,this.log=t.logger.forComponent("libp2p:autonat"),this.started=!1,this.protocol=`/${e.protocolPrefix??ll}/${ul}/${fl}`,this.timeout=e.timeout??3e4,this.maxInboundStreams=e.maxInboundStreams??1,this.maxOutboundStreams=e.maxOutboundStreams??1,this.startupDelay=e.startupDelay??5e3,this.refreshInterval=e.refreshInterval??6e4,this._verifyExternalAddresses=this._verifyExternalAddresses.bind(this)}isStarted(){return this.started}async start(){this.started||(await this.components.registrar.handle(this.protocol,t=>{this.handleIncomingAutonatStream(t).catch(e=>{this.log.error("error handling incoming autonat stream",e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams}),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.startupDelay),this.started=!0)}async stop(){await this.components.registrar.unhandle(this.protocol),clearTimeout(this.verifyAddressTimeout),this.started=!1}async handleIncomingAutonatStream(t){let e=AbortSignal.timeout(this.timeout),n=()=>{t.stream.abort(new U("handleIncomingAutonatStream timeout",As))};e.addEventListener("abort",n,{once:!0}),Ss(1/0,e);let s=this.components.addressManager.getAddresses().map(o=>o.toOptions().host);try{let o=this;await fi(t.stream,i=>vr(i),async function*(i){let a=await ii(i);if(a==null){o.log("no message received"),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_BAD_REQUEST,statusText:"No message was sent"}});return}let c;try{c=D.decode(a)}catch(d){o.log.error("could not decode message",d),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_BAD_REQUEST,statusText:"Could not decode message"}});return}let l=c.dial;if(l==null){o.log.error("dial was missing from message"),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_BAD_REQUEST,statusText:"No Dial message found in message"}});return}let f,u=l.peer;if(u==null||u.id==null){o.log.error("PeerId missing from message"),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_BAD_REQUEST,statusText:"missing peer info"}});return}try{f=Xr(u.id)}catch(d){o.log.error("invalid PeerId",d),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_BAD_REQUEST,statusText:"bad peer id"}});return}if(o.log("incoming request from %p",f),!t.connection.remotePeer.equals(f)){o.log("target peer %p did not equal sending peer %p",f,t.connection.remotePeer),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_BAD_REQUEST,statusText:"peer id mismatch"}});return}let h=u.addrs.map(d=>ds(d)).filter(d=>{let p=d.toOptions().host===t.connection.remoteAddr.toOptions().host;return o.log.trace("request to dial %a was sent from %a is same host %s",d,t.connection.remoteAddr,p),p}).filter(d=>{let p=d.toOptions().host,y=!(Go(p)??!1);return o.log.trace("host %s was public %s",p,y),y}).filter(d=>{let p=d.toOptions().host,y=!s.includes(p);return o.log.trace("host %s was not our host %s",p,y),y}).filter(d=>{let p=!!o.components.transportManager.transportForMultiaddr(d);return o.log.trace("transport for %a is supported %s",d,p),p}).map(d=>(d.getPeerId()==null&&(d=d.encapsulate(`/p2p/${f.toString()}`)),d));if(h.length===0){o.log("no valid multiaddrs for %p in message",f),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_DIAL_REFUSED,statusText:"no dialable addresses"}});return}o.log("dial multiaddrs %s for peer %p",h.map(d=>d.toString()).join(", "),f);let m="",g=h[0];for await(let d of h){let p;g=d;try{if(p=await o.components.connectionManager.openConnection(d,{signal:e}),!p.remoteAddr.equals(d))throw o.log.error("tried to dial %a but dialed %a",d,p.remoteAddr),new Error("Unexpected remote address");o.log("Success %p",f),yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.OK,addr:p.remoteAddr.decapsulateCode(W("p2p").code).bytes}});return}catch(y){o.log("could not dial %p",f,y),m=y.message}finally{p!=null&&await p.close()}}yield D.encode({type:D.MessageType.DIAL_RESPONSE,dialResponse:{status:D.ResponseStatus.E_DIAL_ERROR,statusText:m,addr:g.bytes}})},i=>Yr(i),t.stream)}catch(o){this.log.error("error handling incoming autonat stream",o)}finally{e.removeEventListener("abort",n)}}_verifyExternalAddresses(){this.verifyExternalAddresses().catch(t=>{this.log.error("error verifying external address",t)})}async verifyExternalAddresses(){if(clearTimeout(this.verifyAddressTimeout),!this.isStarted())return;let t=this.components.addressManager,e=t.getObservedAddrs().filter(o=>{let i=o.toOptions();return!(Go(i.host)??!1)});if(e.length===0){this.log("no public addresses found, not requesting verification"),this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval);return}let n=AbortSignal.timeout(this.timeout);Ss(1/0,n);let s=this;try{this.log("verify multiaddrs %s",e.map(u=>u.toString()).join(", "));let o=D.encode({type:D.MessageType.DIAL,dial:{peer:{id:this.components.peerId.toBytes(),addrs:e.map(u=>u.bytes)}}}),a=(await Dc()).toBytes(),c={},l=[],f=async u=>{let h=()=>{};try{this.log("asking %p to verify multiaddr",u.id);let m=await s.components.connectionManager.openConnection(u.id,{signal:n}),g=await m.newStream(this.protocol,{signal:n});h=()=>{g.abort(new U("verifyAddress timeout",As))},n.addEventListener("abort",h,{once:!0});let d=await fi([o],y=>Yr(y),g,y=>vr(y),async y=>ii(y));if(d==null){this.log("no response received from %p",m.remotePeer);return}let p=D.decode(d);if(p.type!==D.MessageType.DIAL_RESPONSE||p.dialResponse==null){this.log("invalid autonat response from %p",m.remotePeer);return}if(p.dialResponse.status===D.ResponseStatus.OK){let y=m.remoteAddr.toOptions(),v;if(y.family===4)v=y.host.split(".")[0];else if(y.family===6)v=y.host.split(":")[0];else{this.log('remote address "%s" was not IP4 or IP6?',y.host);return}if(l.includes(v)){this.log("already have response from network segment %d - %s",v,y.host);return}l.push(v)}return p.dialResponse}catch(m){this.log.error("error asking remote to verify multiaddr",m)}finally{n.removeEventListener("abort",h)}};for await(let u of ci(ol(this.components.peerRouting.getClosestPeers(a,{signal:n}),h=>async()=>f(h)),{concurrency:hi}))try{if(u==null)continue;let h=u.addr==null?e[0]:ds(u.addr);if(this.log("autonat response for %a is %s",h,u.status),u.status===D.ResponseStatus.E_BAD_REQUEST||u.status===D.ResponseStatus.E_DIAL_REFUSED||u.addr==null&&e.length>1)continue;if(!e.some(g=>g.equals(h))){this.log("peer reported %a as %s but it was not in our observed address list",h,u.status);continue}let m=h.toString();if(c[m]==null&&(c[m]={success:0,failure:0}),u.status===D.ResponseStatus.OK?c[m].success++:u.status===D.ResponseStatus.E_DIAL_ERROR&&c[m].failure++,c[m].success===hi){this.log("%a is externally dialable",h),t.confirmObservedAddr(h);return}if(c[m].failure===hi){this.log("%a is not externally dialable",h),t.removeObservedAddr(h);return}}catch(h){this.log.error("could not verify external address",h)}}finally{this.verifyAddressTimeout=setTimeout(this._verifyExternalAddresses,this.refreshInterval)}}};function Md(r={}){return t=>new xs(t,r)}return Sl(Kd);})();
19
8
  /*! Bundled license information:
20
9
 
21
10
  pvtsutils/build/index.js:
@@ -1,13 +1,13 @@
1
1
  import { CodeError, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface';
2
2
  import { peerIdFromBytes } from '@libp2p/peer-id';
3
3
  import { createEd25519PeerId } from '@libp2p/peer-id-factory';
4
+ import { isPrivateIp } from '@libp2p/utils/private-ip';
4
5
  import { multiaddr, protocols } from '@multiformats/multiaddr';
5
6
  import first from 'it-first';
6
7
  import * as lp from 'it-length-prefixed';
7
8
  import map from 'it-map';
8
9
  import parallel from 'it-parallel';
9
10
  import { pipe } from 'it-pipe';
10
- import isPrivateIp from 'private-ip';
11
11
  import { MAX_INBOUND_STREAMS, MAX_OUTBOUND_STREAMS, PROTOCOL_NAME, PROTOCOL_PREFIX, PROTOCOL_VERSION, REFRESH_INTERVAL, STARTUP_DELAY, TIMEOUT } from './constants.js';
12
12
  import { Message } from './pb/index.js';
13
13
  // if more than 3 peers manage to dial us on what we believe to be our external
@@ -1 +1 @@
1
- {"version":3,"file":"autonat.js","sourceRoot":"","sources":["../../src/autonat.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAA;AAC7D,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC9D,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B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AE,IAAI,CAAC,eAAe,CAAC,CAAA;QAC7F,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/autonat",
3
- "version": "1.0.8",
3
+ "version": "1.0.9-2e464c099",
4
4
  "description": "Implementation of Autonat Protocol",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-autonat#readme",
@@ -51,27 +51,28 @@
51
51
  "dep-check": "aegir dep-check"
52
52
  },
53
53
  "dependencies": {
54
- "@libp2p/interface": "^1.1.1",
55
- "@libp2p/interface-internal": "^1.0.6",
56
- "@libp2p/peer-id": "^4.0.4",
57
- "@libp2p/peer-id-factory": "^4.0.4",
54
+ "@libp2p/interface": "1.1.2-2e464c099",
55
+ "@libp2p/interface-internal": "1.0.7-2e464c099",
56
+ "@libp2p/peer-id": "4.0.5-2e464c099",
57
+ "@libp2p/peer-id-factory": "4.0.5-2e464c099",
58
+ "@libp2p/utils": "5.2.2-2e464c099",
58
59
  "@multiformats/multiaddr": "^12.1.10",
59
60
  "it-first": "^3.0.3",
60
61
  "it-length-prefixed": "^9.0.3",
61
62
  "it-map": "^3.0.4",
62
- "it-parallel": "^3.0.0",
63
+ "it-parallel": "^3.0.6",
63
64
  "it-pipe": "^3.0.1",
64
- "private-ip": "^3.0.1",
65
65
  "protons-runtime": "^5.0.0",
66
- "uint8arraylist": "^2.4.3"
66
+ "uint8arraylist": "^2.4.7"
67
67
  },
68
68
  "devDependencies": {
69
- "@libp2p/logger": "^4.0.4",
69
+ "@libp2p/logger": "4.0.5-2e464c099",
70
70
  "aegir": "^42.0.0",
71
71
  "it-all": "^3.0.3",
72
72
  "it-pushable": "^3.2.1",
73
73
  "protons": "^7.3.0",
74
- "sinon": "^17.0.0",
74
+ "sinon": "^17.0.1",
75
75
  "sinon-ts": "^2.0.0"
76
- }
76
+ },
77
+ "sideEffects": false
77
78
  }
package/src/autonat.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { CodeError, ERR_TIMEOUT, setMaxListeners } from '@libp2p/interface'
2
2
  import { peerIdFromBytes } from '@libp2p/peer-id'
3
3
  import { createEd25519PeerId } from '@libp2p/peer-id-factory'
4
+ import { isPrivateIp } from '@libp2p/utils/private-ip'
4
5
  import { multiaddr, protocols } from '@multiformats/multiaddr'
5
6
  import first from 'it-first'
6
7
  import * as lp from 'it-length-prefixed'
7
8
  import map from 'it-map'
8
9
  import parallel from 'it-parallel'
9
10
  import { pipe } from 'it-pipe'
10
- import isPrivateIp from 'private-ip'
11
11
  import {
12
12
  MAX_INBOUND_STREAMS,
13
13
  MAX_OUTBOUND_STREAMS,
@@ -1,8 +0,0 @@
1
- {
2
- "AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_autonat.AutoNATComponents.html",
3
- ".:AutoNATComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_autonat.AutoNATComponents.html",
4
- "AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_autonat.AutoNATServiceInit.html",
5
- ".:AutoNATServiceInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_autonat.AutoNATServiceInit.html",
6
- "autoNAT": "https://libp2p.github.io/js-libp2p/functions/_libp2p_autonat.autoNAT.html",
7
- ".:autoNAT": "https://libp2p.github.io/js-libp2p/functions/_libp2p_autonat.autoNAT.html"
8
- }