@libp2p/autonat 1.0.9 → 1.0.10-0321812e7
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 +3 -14
- package/dist/src/autonat.js +1 -1
- package/dist/src/autonat.js.map +1 -1
- package/package.json +17 -17
- package/src/autonat.ts +1 -1
- package/dist/typedoc-urls.json +0 -8
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 Cl=Object.create;var tn=Object.defineProperty;var Ul=Object.getOwnPropertyDescriptor;var Pl=Object.getOwnPropertyNames;var Dl=Object.getPrototypeOf,Ol=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})},Ii=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Pl(t))!Ol.call(r,s)&&s!==e&&tn(r,s,{get:()=>t[s],enumerable:!(n=Ul(t,s))||n.enumerable});return r};var rn=(r,t,e)=>(e=r!=null?Cl(Dl(r)):{},Ii(t||!r||!r.__esModule?tn(e,"default",{value:r,enumerable:!0}):e,r)),Vl=r=>Ii(tn({},"__esModule",{value:!0}),r);var Ta=en(gr=>{"use strict";var gh="[object ArrayBuffer]",ae=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===gh}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}},Lo="string",mh=/^[0-9a-f]+$/i,yh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,bh=/^[a-zA-Z0-9-_]+$/,Bn=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=ae.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=ae.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}},An=class r{static isHex(t){return typeof t===Lo&&mh.test(t)}static isBase64(t){return typeof t===Lo&&yh.test(t)}static isBase64Url(t){return typeof t===Lo&&bh.test(t)}static ToString(t,e="utf8"){let n=ae.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=ae.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 Bn.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 Bn.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=ae.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=ae.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,"")||""}};An.DEFAULT_UTF8_ENCODING="utf8";function wh(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 xh(...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 vh(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}gr.BufferSourceConverter=ae;gr.Convert=An;gr.assign=wh;gr.combine=xh;gr.isEqual=vh});var al=en((Mb,il)=>{"use strict";function ol(r,t){for(let e in t)Object.defineProperty(r,e,{value:t[e],enumerable:!0,configurable:!0});return r}function Cd(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 ol(r,e)}catch{e.message=r.message,e.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),ol(new s,e)}}il.exports=Cd});var dl=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 yl=en((ml,As)=>{(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 A=0;A<k.length;A++)v.push(parseInt(k[A],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 As<"u"&&As.exports?As.exports=m:r.ipaddr=m})(ml)});var o0={};ut(o0,{autoNAT:()=>s0});var Si=Symbol.for("@libp2p/peer-id");var C=class extends Error{code;props;constructor(t,e,n){super(t),this.code=e,this.name=n?.name??"CodeError",this.props=n??{}}};var ks="ERR_TIMEOUT";var Rs=(r,...t)=>{try{[...t]}catch{}};var Cs={};ut(Cs,{base58btc:()=>ct,base58flickr:()=>ql});var u0=new Uint8Array(0);function ki(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 Zt(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 Ri(r){return new TextEncoder().encode(r)}function Ni(r){return new TextDecoder().decode(r)}function Fl(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],A=0,N=w-1;(v!==0||A<g)&&N!==-1;N--,A++)v+=256*k[N]>>>0,k[N]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");g=A,y++}for(var T=w-g;T!==w&&k[T]===0;)T++;for(var q=c.repeat(d);T<w;++T)q+=r.charAt(k[T]);return q}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,A=b-1;(k!==0||v<y)&&A!==-1;A--,v++)k+=a*w[A]>>>0,w[A]=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)),q=g;N!==b;)T[q++]=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 Hl=Fl,Ml=Hl,Li=Ml;var Ns=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")}},Ts=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 _i(this,t)}},Ls=class{decoders;constructor(t){this.decoders=t}or(t){return _i(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 _i(r,t){return new Ls({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var _s=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 Ns(t,e,n),this.decoder=new Ts(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 _s(r,t,e,n)}function me({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=Li(e,r);return Ze({prefix:t,name:r,encode:n,decode:o=>Zt(s(o))})}function $l(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 Kl(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 Kl(s,n,e)},decode(s){return $l(s,n,e,r)}})}var ct=me({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ql=me({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Us={};ut(Us,{base10:()=>zl});var zl=me({prefix:"9",name:"base10",alphabet:"0123456789"});var Ps={};ut(Ps,{base16:()=>jl,base16upper:()=>Gl});var jl=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Gl=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ds={};ut(Ds,{base2:()=>Wl});var Wl=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Os={};ut(Os,{base256emoji:()=>Ql});var Ci=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}"),Zl=Ci.reduce((r,t,e)=>(r[e]=t,r),[]),Yl=Ci.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Jl(r){return r.reduce((t,e)=>(t+=Zl[e],t),"")}function Xl(r){let t=[];for(let e of r){let n=Yl[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Ql=Ze({prefix:"\u{1F680}",name:"base256emoji",encode:Jl,decode:Xl});var Vs={};ut(Vs,{base32:()=>Yt,base32hex:()=>nu,base32hexpad:()=>ou,base32hexpadupper:()=>iu,base32hexupper:()=>su,base32pad:()=>eu,base32padupper:()=>ru,base32upper:()=>tu,base32z:()=>au});var Yt=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),eu=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ru=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),su=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ou=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iu=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),au=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Fs={};ut(Fs,{base36:()=>cu,base36upper:()=>lu});var cu=me({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),lu=me({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ms={};ut(Ms,{base64:()=>Hs,base64pad:()=>uu,base64url:()=>fu,base64urlpad:()=>hu});var Hs=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),uu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fu=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),hu=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $s={};ut($s,{base8:()=>du});var du=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Ks={};ut(Ks,{identity:()=>pu});var pu=Ze({prefix:"\0",name:"identity",encode:r=>Ni(r),decode:r=>Ri(r)});var S0=new TextEncoder,k0=new TextDecoder;var zs={};ut(zs,{identity:()=>ye});var yu=Di,Ui=128,bu=127,wu=~bu,xu=Math.pow(2,31);function Di(r,t,e){t=t||[],e=e||0;for(var n=e;r>=xu;)t[e++]=r&255|Ui,r/=128;for(;r&wu;)t[e++]=r&255|Ui,r>>>=7;return t[e]=r|0,Di.bytes=e-n+1,t}var vu=qs,Eu=128,Pi=127;function qs(r,n){var e=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw qs.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&Pi)<<s:(i&Pi)*Math.pow(2,s),s+=7}while(i>=Eu);return qs.bytes=o-n,e}var Bu=Math.pow(2,7),Au=Math.pow(2,14),Iu=Math.pow(2,21),Su=Math.pow(2,28),ku=Math.pow(2,35),Ru=Math.pow(2,42),Nu=Math.pow(2,49),Tu=Math.pow(2,56),Lu=Math.pow(2,63),_u=function(r){return r<Bu?1:r<Au?2:r<Iu?3:r<Su?4:r<ku?5:r<Ru?6:r<Nu?7:r<Tu?8:r<Lu?9:10},Cu={encode:yu,decode:vu,encodingLength:_u},Uu=Cu,Rr=Uu;function Nr(r,t=0){return[Rr.decode(r,t),Rr.decode.bytes]}function Ye(r,t,e=0){return Rr.encode(r,t,e),t}function Je(r){return Rr.encodingLength(r)}function Kt(r,t){let e=t.byteLength,n=Je(r),s=n+Je(e),o=new Uint8Array(s+e);return Ye(r,o,0),Ye(e,o,n),o.set(t,s),new Xe(r,e,t,o)}function Oe(r){let t=Zt(r),[e,n]=Nr(t),[s,o]=Nr(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new Xe(e,s,i,t)}function Oi(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ki(r.bytes,e.bytes)}}var Xe=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};var Vi=0,Pu="identity",Fi=Zt;function Du(r){return Kt(Vi,Fi(r))}var ye={code:Vi,name:Pu,encode:Fi,digest:Du};var Ws={};ut(Ws,{sha256:()=>pt,sha512:()=>Ou});function Gs({name:r,code:t,encode:e}){return new js(r,t,e)}var js=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?Kt(this.code,e):e.then(n=>Kt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Mi(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var pt=Gs({name:"sha2-256",code:18,encode:Mi("SHA-256")}),Ou=Gs({name:"sha2-512",code:19,encode:Mi("SHA-512")});function $i(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Fu(e,Zs(r),t??ct.encoder);default:return Hu(e,Zs(r),t??Yt.encoder)}}var Ki=new WeakMap;function Zs(r){let t=Ki.get(r);if(t==null){let e=new Map;return Ki.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!==Tr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==Mu)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=Kt(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&&Oi(t.multihash,n.multihash)}toString(t){return $i(this,t)}toJSON(){return{"/":$i(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??qi(n,s,o.bytes))}else if(e[$u]===!0){let{version:n,multihash:s,code:o}=e,i=Oe(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!==Tr)throw new Error(`Version 0 CID must use dag-pb (code: ${Tr}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=qi(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,Tr,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=Zt(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 Xe(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]=Nr(t.subarray(e));return e+=m,u},s=n(),o=Tr;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]=Vu(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 Vu(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 Yt.prefix:{let e=t??Yt;return[Yt.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 Fu(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 Hu(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 Tr=112,Mu=18;function qi(r,t,e){let n=Je(r),s=n+Je(t),o=new Uint8Array(s+e.byteLength);return Ye(r,o,0),Ye(t,o,n),o.set(e,s),o}var $u=Symbol.for("@ipld/js-cid/CID");var be={...Ks,...Ds,...$s,...Us,...Ps,...Vs,...Fs,...Cs,...Ms,...Os},W0={...Ws,...zs};function bt(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 Ku=Symbol.for("nodejs.util.inspect.custom"),zi=Object.values(be).map(r=>r.decoder).reduce((r,t)=>r.or(t),be.identity.decoder),ji=114,Ys=36,Js=37,Lr=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()})`}[Si]=!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 bt(this.multihash.bytes,t);if(typeof t=="string")return qu(t).equals(this);if(t?.multihash?.bytes!=null)return bt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[Ku](){return`PeerId(${this.toString()})`}},Qe=class extends Lr{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},tr=class extends Lr{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.multihash.digest}},er=class extends Lr{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.multihash.digest}};function qu(r,t){if(t=t??zi,r.charAt(0)==="1"||r.charAt(0)==="Q"){let e=Oe(ct.decode(`z${r}`));return r.startsWith("12D")?new tr({multihash:e}):r.startsWith("16U")?new er({multihash:e}):new Qe({multihash:e})}return sn(zi.decode(r))}function sn(r){try{let t=Oe(r);if(t.code===ye.code){if(t.digest.length===Ys)return new tr({multihash:t});if(t.digest.length===Js)return new er({multihash:t})}if(t.code===pt.code)return new Qe({multihash:t})}catch{return zu(Ut.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function zu(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===pt.code)return new Qe({multihash:r.multihash});if(t.code===ye.code){if(t.digest.length===Ys)return new tr({multihash:r.multihash});if(t.digest.length===Js)return new er({multihash:r.multihash})}throw new Error("Supplied PeerID CID is invalid")}async function Gi(r,t){return r.length===Ys?new tr({multihash:Kt(ye.code,r),privateKey:t}):r.length===Js?new er({multihash:Kt(ye.code,r),privateKey:t}):new Qe({multihash:await pt.digest(r),publicKey:r,privateKey:t})}var No={};ut(No,{Ed25519PrivateKey:()=>qe,Ed25519PublicKey:()=>Or,generateKeyPair:()=>hh,generateKeyPairFromSeed:()=>Na,unmarshalEd25519PrivateKey:()=>uh,unmarshalEd25519PublicKey:()=>fh});function we(r){return globalThis.Buffer!=null?new Uint8Array(r.buffer,r.byteOffset,r.byteLength):r}function Jt(r=0){return globalThis.Buffer?.alloc!=null?we(globalThis.Buffer.alloc(r)):new Uint8Array(r)}function wt(r=0){return globalThis.Buffer?.allocUnsafe!=null?we(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Bt(r,t){if(globalThis.Buffer!=null)return we(globalThis.Buffer.concat(r,t));t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=wt(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return we(e)}function Zi(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var Wi=Zi("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Xs=Zi("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=wt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),ju={utf8:Wi,"utf-8":Wi,hex:be.base16,latin1:Xs,ascii:Xs,binary:Xs,...be},on=ju;function Y(r,t="utf8"){let e=on[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?we(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 rr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`Wrong positive integer: ${r}`)}function Gu(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Qs(r,...t){if(!Gu(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 an(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");rr(r.outputLen),rr(r.blockLen)}function nr(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 Yi(r,t){Qs(r);let e=t.outputLen;if(r.length<e)throw new Error(`digestInto() expects output buffer of length at least ${e}`)}var cn=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 or=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),Pt=(r,t)=>r<<32-t|r>>>t,Wu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Wu)throw new Error("Non little-endian hardware is not supported");var Zu=async()=>{};async function Xi(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 Zu(),n+=o)}}function to(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function xe(r){if(typeof r=="string"&&(r=to(r)),!Ji(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function ln(...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 sr=class{clone(){return this._cloneInto()}},Yu={}.toString;function Qi(r,t){if(t!==void 0&&Yu.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,t)}function un(r){let t=n=>r().update(xe(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function ir(r=32){if(cn&&typeof cn.getRandomValues=="function")return cn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Ju(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 ar=class extends sr{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=or(this.buffer)}update(t){nr(this);let{view:e,buffer:n,blockLen:s}=this;t=xe(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=or(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){nr(this),Yi(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;Ju(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=or(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 fn=BigInt(4294967295),eo=BigInt(32);function ta(r,t=!1){return t?{h:Number(r&fn),l:Number(r>>eo&fn)}:{h:Number(r>>eo&fn)|0,l:Number(r&fn)|0}}function Xu(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}=ta(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var Qu=(r,t)=>BigInt(r>>>0)<<eo|BigInt(t>>>0),tf=(r,t,e)=>r>>>e,ef=(r,t,e)=>r<<32-e|t>>>e,rf=(r,t,e)=>r>>>e|t<<32-e,nf=(r,t,e)=>r<<32-e|t>>>e,sf=(r,t,e)=>r<<64-e|t>>>e-32,of=(r,t,e)=>r>>>e-32|t<<64-e,af=(r,t)=>t,cf=(r,t)=>r,lf=(r,t,e)=>r<<e|t>>>32-e,uf=(r,t,e)=>t<<e|r>>>32-e,ff=(r,t,e)=>t<<e-32|r>>>64-e,hf=(r,t,e)=>r<<e-32|t>>>64-e;function df(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var pf=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),gf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,mf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),yf=(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),wf=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var xf={fromBig:ta,split:Xu,toBig:Qu,shrSH:tf,shrSL:ef,rotrSH:rf,rotrSL:nf,rotrBH:sf,rotrBL:of,rotr32H:af,rotr32L:cf,rotlSH:lf,rotlSL:uf,rotlBH:ff,rotlBL:hf,add:df,add3L:pf,add3H:gf,add4L:mf,add4H:yf,add5H:wf,add5L:bf},U=xf;var[vf,Ef]=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))),ve=new Uint32Array(80),Ee=new Uint32Array(80),ro=class extends ar{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)ve[w]=t.getUint32(e),Ee[w]=t.getUint32(e+=4);for(let w=16;w<80;w++){let k=ve[w-15]|0,v=Ee[w-15]|0,A=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=ve[w-2]|0,q=Ee[w-2]|0,$=U.rotrSH(T,q,19)^U.rotrBH(T,q,61)^U.shrSH(T,q,6),D=U.rotrSL(T,q,19)^U.rotrBL(T,q,61)^U.shrSL(T,q,6),nt=U.add4L(N,D,Ee[w-7],Ee[w-16]),rt=U.add4H(nt,A,$,ve[w-7],ve[w-16]);ve[w]=rt|0,Ee[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),A=u&f^~u&d,N=m&p^~m&g,T=U.add5L(b,v,N,Ef[w],Ee[w]),q=U.add5H(T,y,k,A,vf[w],ve[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,q|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,q,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(){ve.fill(0),Ee.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 cr=un(()=>new ro);var dn={};ut(dn,{bitGet:()=>Nf,bitLen:()=>Rf,bitMask:()=>_r,bitSet:()=>Tf,bytesToHex:()=>Qt,bytesToNumberBE:()=>te,bytesToNumberLE:()=>Be,concatBytes:()=>ee,createHmacDrbg:()=>oo,ensureBytes:()=>et,equalBytes:()=>Sf,hexToBytes:()=>Fe,hexToNumber:()=>so,isBytes:()=>Dt,numberToBytesBE:()=>Ae,numberToBytesLE:()=>He,numberToHexUnpadded:()=>sa,numberToVarBytesBE:()=>If,utf8ToBytes:()=>kf,validateObject:()=>qt});var na=BigInt(0),hn=BigInt(1),Bf=BigInt(2);function Dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var Af=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function Qt(r){if(!Dt(r))throw new Error("Uint8Array expected");let t="";for(let e=0;e<r.length;e++)t+=Af[r[e]];return t}function sa(r){let t=r.toString(16);return t.length&1?`0${t}`:t}function so(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Xt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ea(r){if(r>=Xt._0&&r<=Xt._9)return r-Xt._0;if(r>=Xt._A&&r<=Xt._F)return r-(Xt._A-10);if(r>=Xt._a&&r<=Xt._f)return r-(Xt._a-10)}function Fe(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=ea(r.charCodeAt(o)),a=ea(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 te(r){return so(Qt(r))}function Be(r){if(!Dt(r))throw new Error("Uint8Array expected");return so(Qt(Uint8Array.from(r).reverse()))}function Ae(r,t){return Fe(r.toString(16).padStart(t*2,"0"))}function He(r,t){return Ae(r,t).reverse()}function If(r){return Fe(sa(r))}function et(r,t,e){let n;if(typeof t=="string")try{n=Fe(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 ee(...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 Sf(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 kf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Rf(r){let t;for(t=0;r>na;r>>=hn,t+=1);return t}function Nf(r,t){return r>>BigInt(t)&hn}var Tf=(r,t,e)=>r|(e?hn:na)<<BigInt(t),_r=r=>(Bf<<BigInt(r-1))-hn,no=r=>new Uint8Array(r),ra=r=>Uint8Array.from(r);function oo(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=no(r),s=no(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...u)=>e(s,n,...u),c=(u=no())=>{s=a(ra([0]),u),n=a(),u.length!==0&&(s=a(ra([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 ee(...m)};return(u,m)=>{i(),c(u);let f;for(;!(f=m(l()));)c();return i(),f}}var Lf={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 qt(r,t,e={}){let n=(s,o,i)=>{let a=Lf[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),Me=BigInt(2),_f=BigInt(3),io=BigInt(4),oa=BigInt(5),ia=BigInt(8),Cf=BigInt(9),Uf=BigInt(16);function Z(r,t){let e=r%t;return e>=lt?e:t+e}function Pf(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 pn(r,t){if(r===lt||t<=lt)throw new Error(`invert: expected positive integers, got n=${r} mod=${t}`);let e=Z(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 Z(s,t)}function Df(r){let t=(r-J)/Me,e,n,s;for(e=r-J,n=0;e%Me===lt;e/=Me,n++);for(s=Me;s<r&&Pf(s,t,r)!==r-J;s++);if(n===1){let i=(r+J)/io;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)/Me;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 Of(r){if(r%io===_f){let t=(r+J)/io;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%ia===oa){let t=(r-oa)/ia;return function(n,s){let o=n.mul(s,Me),i=n.pow(o,t),a=n.mul(s,i),c=n.mul(n.mul(a,Me),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%Uf,Df(r)}var aa=(r,t)=>(Z(r,t)&J)===J,Vf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ao(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Vf.reduce((n,s)=>(n[s]="function",n),t);return qt(r,e)}function Ff(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 Hf(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 co(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function gn(r,t,e=!1,n={}){if(r<=lt)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=co(r,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Of(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:_r(s),ZERO:lt,ONE:J,create:c=>Z(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=>Z(-c,r),eql:(c,l)=>c===l,sqr:c=>Z(c*c,r),add:(c,l)=>Z(c+l,r),sub:(c,l)=>Z(c-l,r),mul:(c,l)=>Z(c*l,r),pow:(c,l)=>Ff(a,c,l),div:(c,l)=>Z(c*pn(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>pn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>Hf(a,c),cmov:(c,l,h)=>h?l:c,toBytes:c=>e?He(c,o):Ae(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return e?Be(c):te(c)}});return Object.freeze(a)}function ca(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 la(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 lo(r){let t=la(r);return t+Math.ceil(t/2)}function ua(r,t,e=!1){let n=r.length,s=la(t),o=lo(t);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=e?te(r):Be(r),a=Z(i,t-J)+J;return e?He(a,s):Ae(a,s)}var $f=BigInt(0),uo=BigInt(1);function mn(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>$f;)o&uo&&(i=i.add(a)),a=a.double(),o>>=uo;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+=uo);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 Cr(r){return ao(r.Fp),qt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...co(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ot=BigInt(0),Nt=BigInt(1),yn=BigInt(2),Kf=BigInt(8),qf={zip215:!0};function zf(r){let t=Cr(r);return qt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function bn(r){let t=zf(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=t,l=yn<<BigInt(a*8)-Nt,h=e.create,u=t.uvRatio||((B,x)=>{try{return{isValid:!0,value:e.sqrt(B*e.inv(x))}}catch{return{isValid:!1,value:Ot}}}),m=t.adjustScalarBytes||(B=>B),f=t.domain||((B,x,S)=>{if(x.length||S)throw new Error("Contexts/pre-hash are not supported");return B}),p=B=>typeof B=="bigint"&&Ot<B,d=(B,x)=>p(B)&&p(x)&&B<x,g=B=>B===Ot||d(B,l);function y(B,x){if(d(B,x))return B;throw new Error(`Expected valid scalar < ${x}, got ${typeof B} ${B}`)}function b(B){return B===Ot?B:y(B,n)}let w=new Map;function k(B){if(!(B instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(x,S,L,_){if(this.ex=x,this.ey=S,this.ez=L,this.et=_,!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(_))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,_)=>L.toAffine(S[_])).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:_,ez:V,et:F}=this,G=h(L*L),M=h(_*_),K=h(V*V),st=h(K*K),Q=h(G*x),ht=h(K*h(Q+M)),dt=h(st+h(S*h(G*M)));if(ht!==dt)throw new Error("bad point: equation left != right (1)");let at=h(L*_),yt=h(V*F);if(at!==yt)throw new Error("bad point: equation left != right (2)")}equals(x){k(x);let{ex:S,ey:L,ez:_}=this,{ex:V,ey:F,ez:G}=x,M=h(S*G),K=h(V*_),st=h(L*G),Q=h(F*_);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:_}=this,V=h(S*S),F=h(L*L),G=h(yn*h(_*_)),M=h(x*V),K=S+L,st=h(h(K*K)-V-F),Q=M+F,ht=Q-G,dt=M-F,at=h(st*ht),yt=h(Q*dt),Wt=h(st*dt),De=h(ht*Q);return new v(at,yt,De,Wt)}add(x){k(x);let{a:S,d:L}=t,{ex:_,ey:V,ez:F,et:G}=this,{ex:M,ey:K,ez:st,et:Q}=x;if(S===BigInt(-1)){let bi=h((V-_)*(K+M)),wi=h((V+_)*(K-M)),Ss=h(wi-bi);if(Ss===Ot)return this.double();let xi=h(F*yn*Q),vi=h(G*yn*st),Ei=vi+xi,Bi=wi+bi,Ai=vi-xi,Nl=h(Ei*Ss),Tl=h(Bi*Ai),Ll=h(Ei*Ai),_l=h(Ss*Bi);return new v(Nl,Tl,_l,Ll)}let ht=h(_*M),dt=h(V*K),at=h(G*L*Q),yt=h(F*st),Wt=h((_+V)*(M+K)-ht-dt),De=yt-at,kr=yt+at,yi=h(dt-S*ht),Il=h(Wt*De),Sl=h(kr*yi),kl=h(Wt*yi),Rl=h(De*kr);return new v(Il,Sl,Rl,kl)}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(A)?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:_}=this,V=this.is0();x==null&&(x=V?Kf:e.inv(_));let F=h(S*x),G=h(L*x),M=h(_*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:_}=t,V=e.BYTES;x=et("pointHex",x,V);let F=x.slice(),G=x[V-1];F[V-1]=G&-129;let M=Be(F);M===Ot||(S?y(M,l):y(M,e.ORDER));let K=h(M*M),st=h(K-Nt),Q=h(L*K-_),{isValid:ht,value:dt}=u(st,Q);if(!ht)throw new Error("Point.fromHex: invalid y coordinate");let at=(dt&Nt)===Nt,yt=(G&128)!==0;if(!S&&dt===Ot&&yt)throw new Error("Point.fromHex: x=0 and x_0=1");return yt!==at&&(dt=h(-dt)),v.fromAffine({x:dt,y:M})}static fromPrivateKey(x){return D(x).point}toRawBytes(){let{x,y:S}=this.toAffine(),L=He(S,e.BYTES);return L[L.length-1]|=x&Nt?128:0,L}toHex(){return Qt(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:A,ZERO:N}=v,T=mn(v,a*8);function q(B){return Z(B,n)}function $(B){return q(Be(B))}function D(B){let x=a;B=et("private key",B,x);let S=et("hashed private key",o(B),2*x),L=m(S.slice(0,x)),_=S.slice(x,2*x),V=$(L),F=A.multiply(V),G=F.toRawBytes();return{head:L,prefix:_,scalar:V,point:F,pointBytes:G}}function nt(B){return D(B).pointBytes}function rt(B=new Uint8Array,...x){let S=ee(...x);return $(o(f(S,et("context",B),!!s)))}function Tt(B,x,S={}){B=et("message",B),s&&(B=s(B));let{prefix:L,scalar:_,pointBytes:V}=D(x),F=rt(S.context,L,B),G=A.multiply(F).toRawBytes(),M=rt(S.context,G,V,B),K=q(F+M*_);b(K);let st=ee(G,He(K,e.BYTES));return et("result",st,a*2)}let E=qf;function R(B,x,S,L=E){let{context:_,zip215:V}=L,F=e.BYTES;B=et("signature",B,2*F),x=et("message",x),s&&(x=s(x));let G=Be(B.slice(F,2*F)),M,K,st;try{M=v.fromHex(S,V),K=v.fromHex(B.slice(0,F),V),st=A.multiplyUnsafe(G)}catch{return!1}if(!V&&M.isSmallOrder())return!1;let Q=rt(_,K.toRawBytes(),M.toRawBytes(),x);return K.add(M.multiplyUnsafe(Q)).subtract(st).clearCofactor().equals(v.ZERO)}return A._setWindowSize(8),{CURVE:t,getPublicKey:nt,sign:Tt,verify:R,ExtendedPoint:v,utils:{getExtendedPublicKey:D,randomPrivateKey:()=>i(e.BYTES),precompute(B=8,x=v.BASE){return x._setWindowSize(B),x.multiply(BigInt(3)),x}}}}var ho=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),fa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),qp=BigInt(0),jf=BigInt(1),fo=BigInt(2),Gf=BigInt(5),ha=BigInt(10),Wf=BigInt(20),Zf=BigInt(40),da=BigInt(80);function Yf(r){let t=ho,n=r*r%t*r%t,s=X(n,fo,t)*n%t,o=X(s,jf,t)*r%t,i=X(o,Gf,t)*o%t,a=X(i,ha,t)*i%t,c=X(a,Wf,t)*a%t,l=X(c,Zf,t)*c%t,h=X(l,da,t)*l%t,u=X(h,da,t)*l%t,m=X(u,ha,t)*i%t;return{pow_p_5_8:X(m,fo,t)*r%t,b2:n}}function Jf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Xf(r,t){let e=ho,n=Z(t*t*t,e),s=Z(n*n*t,e),o=Yf(r*s).pow_p_5_8,i=Z(r*n*o,e),a=Z(t*i*i,e),c=i,l=Z(i*fa,e),h=a===r,u=a===Z(-r,e),m=a===Z(-r*fa,e);return h&&(i=c),(u||m)&&(i=l),aa(i,e)&&(i=Z(-i,e)),{isValid:h||u,value:i}}var re=gn(ho,void 0,!0),po={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:re,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:cr,randomBytes:ir,adjustScalarBytes:Jf,uvRatio:Xf},lr=bn(po);function pa(r,t,e){if(t.length>255)throw new Error("Context is too big");return ln(to("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var zp=bn({...po,domain:pa}),jp=bn({...po,domain:pa,prehash:cr});var Qf=(re.ORDER+BigInt(3))/BigInt(8),Gp=re.pow(fo,Qf),Wp=re.sqrt(re.neg(re.ONE)),Zp=(re.ORDER-BigInt(5))/BigInt(8),Yp=BigInt(486662);var Jp=ca(re,re.neg(BigInt(486664)));var Xp=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),Qp=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),tg=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),eg=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");var rg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");var ur=32,ne=64,wn=32;function ga(){let r=lr.utils.randomPrivateKey(),t=lr.getPublicKey(r);return{privateKey:wa(r,t),publicKey:t}}function ma(r){if(r.length!==wn)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=lr.getPublicKey(t);return{privateKey:wa(t,e),publicKey:e}}function ya(r,t){let e=r.subarray(0,wn);return lr.sign(t instanceof Uint8Array?t:t.subarray(),e)}function ba(r,t,e){return lr.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}function wa(r,t){let e=new Uint8Array(ne);for(let n=0;n<wn;n++)e[n]=r[n],e[wn+n]=t[n];return e}var At={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 go={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function xa(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=At.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=Y(m));let g;if(m.length===0){g=await a.subtle.importKey("jwk",go,{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",go,{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 Bt([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=Y(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",go,{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 fr(r,t){let n=await xa().encrypt(r,t);return Hs.encode(n)}var mo=new Float32Array([-0]),Ie=new Uint8Array(mo.buffer);function va(r,t,e){mo[0]=r,t[e]=Ie[0],t[e+1]=Ie[1],t[e+2]=Ie[2],t[e+3]=Ie[3]}function Ea(r,t){return Ie[0]=r[t],Ie[1]=r[t+1],Ie[2]=r[t+2],Ie[3]=r[t+3],mo[0]}var yo=new Float64Array([-0]),xt=new Uint8Array(yo.buffer);function Ba(r,t,e){yo[0]=r,t[e]=xt[0],t[e+1]=xt[1],t[e+2]=xt[2],t[e+3]=xt[3],t[e+4]=xt[4],t[e+5]=xt[5],t[e+6]=xt[6],t[e+7]=xt[7]}function Aa(r,t){return xt[0]=r[t],xt[1]=r[t+1],xt[2]=r[t+2],xt[3]=r[t+3],xt[4]=r[t+4],xt[5]=r[t+5],xt[6]=r[t+6],xt[7]=r[t+7],yo[0]}var rh=BigInt(Number.MAX_SAFE_INTEGER),nh=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 $e;if(t<rh&&t>nh)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>Ia&&(s=0n,++n>Ia&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return $e;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):$e}},$e=new St(0,0);$e.toBigInt=function(){return 0n};$e.zzEncode=$e.zzDecode=function(){return this};$e.length=function(){return 1};var Ia=4294967296n;function Sa(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 ka(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 bo(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 xn(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var wo=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 xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Vt(this,4);return xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw Vt(this,4);let t=Ea(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Vt(this,4);let t=Aa(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 ka(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=xn(this.buf,this.pos+=4),e=xn(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 xo(r){return new wo(r instanceof Uint8Array?r:r.subarray())}function se(r,t){let e=xo(r);return t.decode(e)}function vo(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return wt(i);s+i>t&&(n=wt(t),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Ke=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function Eo(){}var Ao=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},sh=vo();function oh(r){return globalThis.Buffer!=null?wt(r):sh(r)}var Dr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Ke(Eo,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new Ke(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new Io((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(Ur,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(Ur,e.length(),e)}uint64Number(t){let e=St.fromNumber(t);return this._push(Ur,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(Ur,e.length(),e)}sint64Number(t){let e=St.fromNumber(t).zzEncode();return this._push(Ur,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(Bo,1,t?1:0)}fixed32(t){return this._push(Pr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=St.fromBigInt(t);return this._push(Pr,4,e.lo)._push(Pr,4,e.hi)}fixed64Number(t){let e=St.fromNumber(t);return this._push(Pr,4,e.lo)._push(Pr,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(va,4,t)}double(t){return this._push(Ba,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(Bo,1,0):this.uint32(e)._push(ah,e,t)}string(t){let e=Sa(t);return e!==0?this.uint32(e)._push(bo,e,t):this._push(Bo,1,0)}fork(){return this.states=new Ao(this),this.head=this.tail=new Ke(Eo,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 Ke(Eo,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=oh(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function Bo(r,t,e){t[e]=r&255}function ih(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Io=class extends Ke{next;constructor(t,e){super(ih,t,e),this.next=void 0}};function Ur(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 Pr(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 ah(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Dr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(ch,t,r),this},Dr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(lh,t,r),this});function ch(r,t,e){t.set(r,e)}function lh(r,t,e){r.length<40?bo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set(Y(r),e)}function So(){return new Dr}function oe(r,t){let e=So();return t.encode(r,e,{lengthDelimited:!1}),e.finish()}var hr;(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"})(hr||(hr={}));function vn(r,t,e,n){return{name:r,type:t,encode:e,decode:n}}function dr(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 vn("enum",hr.VARINT,e,n)}function ie(r,t){return vn("message",hr.LENGTH_DELIMITED,r,t)}var gt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(gt||(gt={}));var ko;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(ko||(ko={}));(function(r){r.codec=()=>dr(ko)})(gt||(gt={}));var Se;(function(r){let t;r.codec=()=>(t==null&&(t=ie((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),gt.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=gt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>oe(e,r.codec()),r.decode=e=>se(e,r.codec())})(Se||(Se={}));var ke;(function(r){let t;r.codec=()=>(t==null&&(t=ie((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),gt.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=gt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>oe(e,r.codec()),r.decode=e=>se(e,r.codec())})(ke||(ke={}));var Or=class{_key;constructor(t){this._key=pr(t,ur)}verify(t,e){return ba(this._key,e,t)}marshal(){return this._key}get bytes(){return Se.encode({Type:gt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}},qe=class{_key;_publicKey;constructor(t,e){this._key=pr(t,ne),this._publicKey=pr(e,ur)}sign(t){return ya(this._key,t)}get public(){return new Or(this._publicKey)}marshal(){return this._key}get bytes(){return ke.encode({Type:gt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}async hash(){let t=pt.digest(this.bytes),e;return Lt(t)?{bytes:e}=await t:e=t.bytes,e}async id(){let t=ye.digest(this.public.bytes);return ct.encode(t.bytes).substring(1)}async export(t,e="libp2p-key"){if(e==="libp2p-key")return fr(this.bytes,t);throw new C(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function uh(r){if(r.length>ne){r=pr(r,ne+ur);let n=r.subarray(0,ne),s=r.subarray(ne,r.length);return new qe(n,s)}r=pr(r,ne);let t=r.subarray(0,ne),e=r.subarray(ur);return new qe(t,e)}function fh(r){return r=pr(r,ur),new Or(r)}async function hh(){let{privateKey:r,publicKey:t}=ga();return new qe(r,t)}async function Na(r){let{privateKey:t,publicKey:e}=ma(r);return new qe(t,e)}function pr(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new C(`Key must be a Uint8Array of length ${t}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function z(r,t="utf8"){let e=on[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 Fo={};ut(Fo,{MAX_RSA_KEY_SIZE:()=>Zr,RsaPrivateKey:()=>wr,RsaPublicKey:()=>Wr,fromJwk:()=>Fh,generateKeyPair:()=>Hh,unmarshalRsaPrivateKey:()=>Oo,unmarshalRsaPublicKey:()=>Vh});function ze(r){if(isNaN(r)||r<=0)throw new C("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return ir(r)}var Le={};ut(Le,{exportToPem:()=>Ch,importFromPem:()=>Uh,jwkToPkcs1:()=>Nh,jwkToPkix:()=>Lh,pkcs1ToJwk:()=>Rh,pkixToJwk:()=>Th});var En=class extends sr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,an(t);let n=xe(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 nr(this),this.iHash.update(t),this}digestInto(t){nr(this),Qs(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()}},Vr=(r,t,e)=>new En(r,t).update(e).digest();Vr.create=(r,t)=>new En(r,t);function dh(r,t,e,n){an(r);let s=Qi({dkLen:32,asyncTick:10},n),{c:o,dkLen:i,asyncTick:a}=s;if(rr(o),rr(i),rr(a),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=xe(t),l=xe(e),h=new Uint8Array(i),u=Vr.create(r,c),m=u._cloneInto().update(l);return{c:o,dkLen:i,asyncTick:a,DK:h,PRF:u,PRFSalt:m}}function ph(r,t,e,n,s){return r.destroy(),t.destroy(),n&&n.destroy(),s.fill(0),e}async function To(r,t,e,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:l}=dh(r,t,e,n),h,u=new Uint8Array(4),m=or(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 Xi(s-1,i,()=>{c._cloneInto(h).update(f).digestInto(f);for(let y=0;y<g.length;y++)g[y]^=f[y]})}return ph(c,l,a,h,f)}var H=rn(Ta());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 Re(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 In(...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 _o(){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 La(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=Re(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Re(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 _a(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 am=Math.log(2);function Sn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Co(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 fe(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 Hr=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return Co(this.items)}},Fr=[new Uint8Array([1])],Ca="0123456789";var yr="",Ht=new ArrayBuffer(0),Uo=new Uint8Array(0),Mr="EndOfContent",Pa="OCTET STRING",Da="BIT STRING";function he(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):Uo}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(!fe(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",Ht)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:H.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var ce=class{constructor({blockLength:t=0,error:e=yr,warnings:n=[],valueBeforeDecode:s=Uo}={}){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)}}};ce.NAME="baseBlock";var vt=class extends ce{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'")}};vt.NAME="valueBlock";var kn=class extends he(ce){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):Uo,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",Ht}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=Re(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(!fe(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}}};kn.NAME="identificationBlock";var Rn=class extends ce{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(!fe(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=Re(this.length,8);if(s.byteLength>127)return this.error="Too big length",Ht;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}}};Rn.NAME="lengthBlock";var I={},mt=class extends ce{constructor({name:t=yr,optional:e=!1,primitiveSchema:n,...s}={},o){super(s),this.name=t,this.optional=e,n&&(this.primitiveSchema=n),this.idBlock=new kn(s),this.lenBlock=new Rn(s),this.valueBlock=o?new o(s):new vt(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 Hr;e||Oa(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?Ht: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 _a(e,n)}};mt.NAME="BaseBlock";function Oa(r){if(r instanceof I.Constructed)for(let t of r.valueBlock.value)Oa(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Nn=class extends mt{constructor({value:t=yr,...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}'`}};Nn.NAME="BaseStringBlock";var Tn=class extends he(vt){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};Tn.NAME="PrimitiveValueBlock";var Va,Ln=class extends mt{constructor(t={}){super(t,Tn),this.idBlock.isConstructed=!1}};Va=Ln;I.Primitive=Va;Ln.NAME="PRIMITIVE";function Bh(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 us(r,t=0,e=r.length){let n=t,s=new mt({},vt),o=new ce;if(!fe(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=mt;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=Bh(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 br(r){if(!r.byteLength){let t=new mt({},vt);return t.error="Input buffer has zero length",{offset:-1,result:t}}return us(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Ah(r,t){return r?1:t}var zt=class extends vt{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(!fe(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(;Ah(this.isIndefiniteForm,n)>0;){let i=us(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===Mr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Mr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new Hr;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?Ht:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};zt.NAME="ConstructedValueBlock";var Fa,Ne=class extends mt{constructor(t={}){super(t,zt),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 El=Object.create;var Yr=Object.defineProperty;var Bl=Object.getOwnPropertyDescriptor;var Al=Object.getOwnPropertyNames;var Sl=Object.getPrototypeOf,kl=Object.prototype.hasOwnProperty;var Es=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),lt=(r,t)=>{for(var e in t)Yr(r,e,{get:t[e],enumerable:!0})},Bi=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Al(t))!kl.call(r,s)&&s!==e&&Yr(r,s,{get:()=>t[s],enumerable:!(n=Bl(t,s))||n.enumerable});return r};var Bs=(r,t,e)=>(e=r!=null?El(Sl(r)):{},Bi(t||!r||!r.__esModule?Yr(e,"default",{value:r,enumerable:!0}):e,r)),Il=r=>Bi(Yr({},"__esModule",{value:!0}),r);var Ra=Es(hr=>{"use strict";var lh="[object ArrayBuffer]",ie=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===lh}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",uh=/^[0-9a-f]+$/i,fh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,hh=/^[a-zA-Z0-9-_]+$/,bn=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=ie.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=ie.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}},wn=class r{static isHex(t){return typeof t===Co&&uh.test(t)}static isBase64(t){return typeof t===Co&&fh.test(t)}static isBase64Url(t){return typeof t===Co&&hh.test(t)}static ToString(t,e="utf8"){let n=ie.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=ie.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 bn.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 bn.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=ie.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=ie.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,"")||""}};wn.DEFAULT_UTF8_ENCODING="utf8";function dh(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 ph(...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 gh(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=ie;hr.Convert=wn;hr.assign=dh;hr.combine=ph;hr.isEqual=gh});var Fc=Es(jr=>{(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}(),jr.ip2long=i,jr.long2ip=a,jr.Netmask=r}).call(jr)});var ol=Es((Nb,sl)=>{"use strict";function nl(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 nl(r,e)}catch{e.message=r.message,e.stack=r.stack;let s=function(){};return s.prototype=Object.create(Object.getPrototypeOf(r)),nl(new s,e)}}sl.exports=Ad});var Kd={};lt(Kd,{autoNAT:()=>Md});var Ai=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:()=>Ul});var jd=new Uint8Array(0);function Si(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 ki(r){return new TextEncoder().encode(r)}function Ii(r){return new TextDecoder().decode(r)}function Rl(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 Nl=Rl,Tl=Nl,Ni=Tl;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 Ti(this,t)}},Rs=class{decoders;constructor(t){this.decoders=t}or(t){return Ti(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 Ti(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}=Ni(e,r);return ze({prefix:t,name:r,encode:n,decode:o=>jt(s(o))})}function Ll(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 _l(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 _l(s,n,e)},decode(s){return Ll(s,n,e,r)}})}var at=pe({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ul=pe({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ls={};lt(Ls,{base10:()=>Cl});var Cl=pe({prefix:"9",name:"base10",alphabet:"0123456789"});var _s={};lt(_s,{base16:()=>Dl,base16upper:()=>Pl});var Dl=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Pl=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Us={};lt(Us,{base2:()=>Ol});var Ol=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cs={};lt(Cs,{base256emoji:()=>Kl});var Li=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}"),Vl=Li.reduce((r,t,e)=>(r[e]=t,r),[]),Fl=Li.reduce((r,t,e)=>(r[t.codePointAt(0)]=e,r),[]);function Hl(r){return r.reduce((t,e)=>(t+=Vl[e],t),"")}function Ml(r){let t=[];for(let e of r){let n=Fl[e.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${e}`);t.push(n)}return new Uint8Array(t)}var Kl=ze({prefix:"\u{1F680}",name:"base256emoji",encode:Hl,decode:Ml});var Ds={};lt(Ds,{base32:()=>Wt,base32hex:()=>zl,base32hexpad:()=>Wl,base32hexpadupper:()=>Yl,base32hexupper:()=>jl,base32pad:()=>ql,base32padupper:()=>Gl,base32upper:()=>$l,base32z:()=>Zl});var Wt=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$l=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ql=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Gl=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zl=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jl=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wl=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yl=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zl=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ps={};lt(Ps,{base36:()=>Jl,base36upper:()=>Xl});var Jl=pe({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xl=pe({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Vs={};lt(Vs,{base64:()=>Os,base64pad:()=>Ql,base64url:()=>tu,base64urlpad:()=>eu});var Os=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ql=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tu=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),eu=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fs={};lt(Fs,{base8:()=>ru});var ru=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Hs={};lt(Hs,{identity:()=>nu});var nu=ze({prefix:"\0",name:"identity",encode:r=>Ii(r),decode:r=>ki(r)});var l0=new TextEncoder,u0=new TextDecoder;var Ks={};lt(Ks,{identity:()=>ge});var iu=Ci,_i=128,au=127,cu=~au,lu=Math.pow(2,31);function Ci(r,t,e){t=t||[],e=e||0;for(var n=e;r>=lu;)t[e++]=r&255|_i,r/=128;for(;r&cu;)t[e++]=r&255|_i,r>>>=7;return t[e]=r|0,Ci.bytes=e-n+1,t}var uu=Ms,fu=128,Ui=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&Ui)<<s:(i&Ui)*Math.pow(2,s),s+=7}while(i>=fu);return Ms.bytes=o-n,e}var hu=Math.pow(2,7),du=Math.pow(2,14),pu=Math.pow(2,21),gu=Math.pow(2,28),mu=Math.pow(2,35),yu=Math.pow(2,42),bu=Math.pow(2,49),wu=Math.pow(2,56),xu=Math.pow(2,63),vu=function(r){return r<hu?1:r<du?2:r<pu?3:r<gu?4:r<mu?5:r<yu?6:r<bu?7:r<wu?8:r<xu?9:10},Eu={encode:iu,decode:uu,encodingLength:vu},Bu=Eu,Ar=Bu;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 Di(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&Si(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 Pi=0,Au="identity",Oi=jt;function Su(r){return Mt(Pi,Oi(r))}var ge={code:Pi,name:Au,encode:Oi,digest:Su};var Gs={};lt(Gs,{sha256:()=>pt,sha512:()=>ku});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 Fi(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var pt=qs({name:"sha2-256",code:18,encode:Fi("SHA-256")}),ku=qs({name:"sha2-512",code:19,encode:Fi("SHA-512")});function Hi(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return Ru(e,zs(r),t??at.encoder);default:return Nu(e,zs(r),t??Wt.encoder)}}var Mi=new WeakMap;function zs(r){let t=Mi.get(r);if(t==null){let e=new Map;return Mi.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!==Tu)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&&Di(t.multihash,n.multihash)}toString(t){return Hi(this,t)}toJSON(){return{"/":Hi(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??Ki(n,s,o.bytes))}else if(e[Lu]===!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=Ki(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]=Iu(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 Iu(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 Ru(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 Nu(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,Tu=18;function Ki(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 Lu=Symbol.for("@ipld/js-cid/CID");var me={...Hs,...Us,...Fs,...Ls,..._s,...Ds,...Ps,...Ts,...Vs,...Cs},L0={...Gs,...Ks};function bt(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 _u=Symbol.for("nodejs.util.inspect.custom"),$i=Object.values(me).map(r=>r.decoder).reduce((r,t)=>r.or(t),me.identity.decoder),qi=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()})`}[Ai]=!0;toString(){return this.string==null&&(this.string=at.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Ut.createV1(qi,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(t){if(t==null)return!1;if(t instanceof Uint8Array)return bt(this.multihash.bytes,t);if(typeof t=="string")return Uu(t).equals(this);if(t?.multihash?.bytes!=null)return bt(this.multihash.bytes,t.multihash.bytes);throw new Error("not valid Id")}[_u](){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 Uu(r,t){if(t=t??$i,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 Jr($i.decode(r))}function Jr(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===pt.code)return new Ze({multihash:t})}catch{return Cu(Ut.decode(r))}throw new Error("Supplied PeerID CID is invalid")}function Cu(r){if(r==null||r.multihash==null||r.version==null||r.version===1&&r.code!==qi)throw new Error("Supplied PeerID CID is invalid");let t=r.multihash;if(t.code===pt.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 Gi(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 pt.digest(r),publicKey:r,privateKey:t})}var _o={};lt(_o,{Ed25519PrivateKey:()=>Me,Ed25519PublicKey:()=>_r,generateKeyPair:()=>ih,generateKeyPairFromSeed:()=>Ia,unmarshalEd25519PrivateKey:()=>sh,unmarshalEd25519PublicKey:()=>oh});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 wt(r=0){return globalThis.Buffer?.allocUnsafe!=null?ye(globalThis.Buffer.allocUnsafe(r)):new Uint8Array(r)}function Bt(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=wt(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return ye(e)}function ji(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var zi=ji("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ys=ji("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=wt(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Du={utf8:zi,"utf-8":zi,hex:me.base16,latin1:Ys,ascii:Ys,binary:Ys,...me},Xr=Du;function Z(r,t="utf8"){let e=Xr[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 Pu(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Zs(r,...t){if(!Pu(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 Qr(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 Wi(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 tn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Yi(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,Ou=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Ou)throw new Error("Non little-endian hardware is not supported");var Vu=async()=>{};async function Zi(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 Vu(),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)),!Yi(r))throw new Error(`expected Uint8Array, got ${typeof r}`);return r}function en(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];if(!Yi(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()}},Fu={}.toString;function Ji(r,t){if(t!==void 0&&Fu.call(t)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,t)}function rn(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(tn&&typeof tn.getRandomValues=="function")return tn.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function Hu(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),Wi(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;Hu(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 nn=BigInt(4294967295),Xs=BigInt(32);function Xi(r,t=!1){return t?{h:Number(r&nn),l:Number(r>>Xs&nn)}:{h:Number(r>>Xs&nn)|0,l:Number(r&nn)|0}}function Mu(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}=Xi(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var Ku=(r,t)=>BigInt(r>>>0)<<Xs|BigInt(t>>>0),$u=(r,t,e)=>r>>>e,qu=(r,t,e)=>r<<32-e|t>>>e,Gu=(r,t,e)=>r>>>e|t<<32-e,zu=(r,t,e)=>r<<32-e|t>>>e,ju=(r,t,e)=>r<<64-e|t>>>e-32,Wu=(r,t,e)=>r>>>e-32|t<<64-e,Yu=(r,t)=>t,Zu=(r,t)=>r,Ju=(r,t,e)=>r<<e|t>>>32-e,Xu=(r,t,e)=>t<<e|r>>>32-e,Qu=(r,t,e)=>t<<e-32|r>>>64-e,tf=(r,t,e)=>r<<e-32|t>>>64-e;function ef(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var rf=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),nf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,sf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),of=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,af=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),cf=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var lf={fromBig:Xi,split:Mu,toBig:Ku,shrSH:$u,shrSL:qu,rotrSH:Gu,rotrSL:zu,rotrBH:ju,rotrBL:Wu,rotr32H:Yu,rotr32L:Zu,rotlSH:Ju,rotlSL:Xu,rotlBH:Qu,rotlBL:tf,add:ef,add3L:rf,add3H:nf,add4L:sf,add4H:of,add5H:cf,add5L:af},C=lf;var[uf,ff]=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,ff[w],xe[w]),q=C.add5H(N,y,T,A,uf[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=rn(()=>new Qs);var on={};lt(on,{bitGet:()=>bf,bitLen:()=>yf,bitMask:()=>Rr,bitSet:()=>wf,bytesToHex:()=>Jt,bytesToNumberBE:()=>Xt,bytesToNumberLE:()=>ve,concatBytes:()=>Qt,createHmacDrbg:()=>ro,ensureBytes:()=>et,equalBytes:()=>gf,hexToBytes:()=>Pe,hexToNumber:()=>eo,isBytes:()=>Dt,numberToBytesBE:()=>Ee,numberToBytesLE:()=>Oe,numberToHexUnpadded:()=>ra,numberToVarBytesBE:()=>pf,utf8ToBytes:()=>mf,validateObject:()=>Kt});var ea=BigInt(0),sn=BigInt(1),hf=BigInt(2);function Dt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}var df=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+=df[r[e]];return t}function ra(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 Qi(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=Qi(r.charCodeAt(o)),a=Qi(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 pf(r){return Pe(ra(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 gf(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 mf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function yf(r){let t;for(t=0;r>ea;r>>=sn,t+=1);return t}function bf(r,t){return r>>BigInt(t)&sn}var wf=(r,t,e)=>r|(e?sn:ea)<<BigInt(t),Rr=r=>(hf<<BigInt(r-1))-sn,to=r=>new Uint8Array(r),ta=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(ta([0]),u),n=a(),u.length!==0&&(s=a(ta([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 xf={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=xf[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),vf=BigInt(3),no=BigInt(4),na=BigInt(5),sa=BigInt(8),Ef=BigInt(9),Bf=BigInt(16);function Y(r,t){let e=r%t;return e>=ct?e:t+e}function Af(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 an(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 Sf(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&&Af(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 kf(r){if(r%no===vf){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%sa===na){let t=(r-na)/sa;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%Bf,Sf(r)}var oa=(r,t)=>(Y(r,t)&J)===J,If=["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=If.reduce((n,s)=>(n[s]="function",n),t);return Kt(r,e)}function Rf(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 Nf(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 cn(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=kf(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)=>Rf(a,c,l),div:(c,l)=>Y(c*an(l,r),r),sqrN:c=>c*c,addN:(c,l)=>c+l,subN:(c,l)=>c-l,mulN:(c,l)=>c*l,inv:c=>an(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>Nf(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 ia(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 aa(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=aa(r);return t+Math.ceil(t/2)}function ca(r,t,e=!1){let n=r.length,s=aa(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 Lf=BigInt(0),ao=BigInt(1);function ln(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>Lf;)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),It=BigInt(1),un=BigInt(2),_f=BigInt(8),Uf={zip215:!0};function Cf(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 fn(r){let t=Cf(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=t,l=un<<BigInt(a*8)-It,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,It,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),ht=f($*f(Q+M)),dt=f(st+f(k*f(j*M)));if(ht!==dt)throw new Error("bad point: equation left != right (1)");let it=f(L*_),yt=f(V*F);if(it!==yt)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(un*f(_*_)),M=f(b*V),$=k+L,st=f(f($*$)-V-F),Q=M+F,ht=Q-j,dt=M-F,it=f(st*ht),yt=f(Q*dt),zt=f(st*dt),Ue=f(ht*Q);return new x(it,yt,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 mi=f((V-_)*($+M)),yi=f((V+_)*($-M)),vs=f(yi-mi);if(vs===Pt)return this.double();let bi=f(F*un*Q),wi=f(j*un*st),xi=wi+bi,vi=yi+mi,Ei=wi-bi,bl=f(xi*vs),wl=f(vi*Ei),xl=f(xi*Ei),vl=f(vs*vi);return new x(bl,wl,vl,xl)}let ht=f(_*M),dt=f(V*$),it=f(j*L*Q),yt=f(F*st),zt=f((_+V)*(M+$)-ht-dt),Ue=yt-it,Br=yt+it,gi=f(dt-k*ht),pl=f(zt*Ue),gl=f(Br*gi),ml=f(zt*gi),yl=f(Ue*Br);return new x(pl,gl,yl,ml)}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===It?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?_f:e.inv(_));let F=f(k*b),j=f(L*b),M=f(_*b);if(V)return{x:Pt,y:It};if(M!==It)throw new Error("invZ was invalid");return{x:F,y:j}}clearCofactor(){let{h:b}=t;return b===It?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($-It),Q=f(L*$-_),{isValid:ht,value:dt}=u(st,Q);if(!ht)throw new Error("Point.fromHex: invalid y coordinate");let it=(dt&It)===It,yt=(j&128)!==0;if(!k&&dt===Pt&&yt)throw new Error("Point.fromHex: x=0 and x_0=1");return yt!==it&&(dt=f(-dt)),x.fromAffine({x:dt,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&It?128:0,L}toHex(){return Jt(this.toRawBytes())}}x.BASE=new x(t.Gx,t.Gy,It,f(t.Gx*t.Gy)),x.ZERO=new x(Pt,It,It,Pt);let{BASE:A,ZERO:R}=x,N=ln(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=Uf;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"),la=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ip=BigInt(0),Df=BigInt(1),co=BigInt(2),Pf=BigInt(5),ua=BigInt(10),Of=BigInt(20),Vf=BigInt(40),fa=BigInt(80);function Ff(r){let t=lo,n=r*r%t*r%t,s=X(n,co,t)*n%t,o=X(s,Df,t)*r%t,i=X(o,Pf,t)*o%t,a=X(i,ua,t)*i%t,c=X(a,Of,t)*a%t,l=X(c,Vf,t)*c%t,f=X(l,fa,t)*l%t,u=X(f,fa,t)*l%t,h=X(u,ua,t)*i%t;return{pow_p_5_8:X(h,co,t)*r%t,b2:n}}function Hf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Mf(r,t){let e=lo,n=Y(t*t*t,e),s=Y(n*n*t,e),o=Ff(r*s).pow_p_5_8,i=Y(r*n*o,e),a=Y(t*i*i,e),c=i,l=Y(i*la,e),f=a===r,u=a===Y(-r,e),h=a===Y(-r*la,e);return f&&(i=c),(u||h)&&(i=l),oa(i,e)&&(i=Y(-i,e)),{isValid:f||u,value:i}}var te=cn(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:Hf,uvRatio:Mf},ir=fn(uo);function ha(r,t,e){if(t.length>255)throw new Error("Context is too big");return en(Js("SigEd25519 no Ed25519 collisions"),new Uint8Array([e?1:0,t.length]),t,r)}var Rp=fn({...uo,domain:ha}),Np=fn({...uo,domain:ha,prehash:or});var Kf=(te.ORDER+BigInt(3))/BigInt(8),Tp=te.pow(co,Kf),Lp=te.sqrt(te.neg(te.ONE)),_p=(te.ORDER-BigInt(5))/BigInt(8),Up=BigInt(486662);var Cp=ia(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,hn=32;function da(){let r=ir.utils.randomPrivateKey(),t=ir.getPublicKey(r);return{privateKey:ya(r,t),publicKey:t}}function pa(r){if(r.length!==hn)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:ya(t,e),publicKey:e}}function ga(r,t){let e=r.subarray(0,hn);return ir.sign(t instanceof Uint8Array?t:t.subarray(),e)}function ma(r,t,e){return ir.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}function ya(r,t){let e=new Uint8Array(ee);for(let n=0;n<hn;n++)e[n]=r[n],e[hn+n]=t[n];return e}var At={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 ba(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=At.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 Bt([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 ba().encrypt(r,t);return Os.encode(n)}var Gf=Math.pow(2,7),zf=Math.pow(2,14),jf=Math.pow(2,21),ho=Math.pow(2,28),po=Math.pow(2,35),go=Math.pow(2,42),mo=Math.pow(2,49),G=128,xt=127;function ut(r){if(r<Gf)return 1;if(r<zf)return 2;if(r<jf)return 3;if(r<ho)return 4;if(r<po)return 5;if(r<go)return 6;if(r<mo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function yo(r,t,e=0){switch(ut(r)){case 8:t[e++]=r&255|G,r/=128;case 7:t[e++]=r&255|G,r/=128;case 6:t[e++]=r&255|G,r/=128;case 5:t[e++]=r&255|G,r/=128;case 4:t[e++]=r&255|G,r>>>=7;case 3:t[e++]=r&255|G,r>>>=7;case 2:t[e++]=r&255|G,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Wf(r,t,e=0){switch(ut(r)){case 8:t.set(e++,r&255|G),r/=128;case 7:t.set(e++,r&255|G),r/=128;case 6:t.set(e++,r&255|G),r/=128;case 5:t.set(e++,r&255|G),r/=128;case 4:t.set(e++,r&255|G),r>>>=7;case 3:t.set(e++,r&255|G),r>>>=7;case 2:t.set(e++,r&255|G),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function bo(r,t){let e=r[t],n=0;if(n+=e&xt,e<G||(e=r[t+1],n+=(e&xt)<<7,e<G)||(e=r[t+2],n+=(e&xt)<<14,e<G)||(e=r[t+3],n+=(e&xt)<<21,e<G)||(e=r[t+4],n+=(e&xt)*ho,e<G)||(e=r[t+5],n+=(e&xt)*po,e<G)||(e=r[t+6],n+=(e&xt)*go,e<G)||(e=r[t+7],n+=(e&xt)*mo,e<G))return n;throw new RangeError("Could not decode varint")}function Yf(r,t){let e=r.get(t),n=0;if(n+=e&xt,e<G||(e=r.get(t+1),n+=(e&xt)<<7,e<G)||(e=r.get(t+2),n+=(e&xt)<<14,e<G)||(e=r.get(t+3),n+=(e&xt)<<21,e<G)||(e=r.get(t+4),n+=(e&xt)*ho,e<G)||(e=r.get(t+5),n+=(e&xt)*po,e<G)||(e=r.get(t+6),n+=(e&xt)*go,e<G)||(e=r.get(t+7),n+=(e&xt)*mo,e<G))return n;throw new RangeError("Could not decode varint")}function Be(r,t,e=0){return t==null&&(t=wt(ut(r))),t instanceof Uint8Array?yo(r,t,e):Wf(r,t,e)}function re(r,t=0){return r instanceof Uint8Array?bo(r,t):Yf(r,t)}var wo=new Float32Array([-0]),Ae=new Uint8Array(wo.buffer);function wa(r,t,e){wo[0]=r,t[e]=Ae[0],t[e+1]=Ae[1],t[e+2]=Ae[2],t[e+3]=Ae[3]}function xa(r,t){return Ae[0]=r[t],Ae[1]=r[t+1],Ae[2]=r[t+2],Ae[3]=r[t+3],wo[0]}var xo=new Float64Array([-0]),vt=new Uint8Array(xo.buffer);function va(r,t,e){xo[0]=r,t[e]=vt[0],t[e+1]=vt[1],t[e+2]=vt[2],t[e+3]=vt[3],t[e+4]=vt[4],t[e+5]=vt[5],t[e+6]=vt[6],t[e+7]=vt[7]}function Ea(r,t){return vt[0]=r[t],vt[1]=r[t+1],vt[2]=r[t+2],vt[3]=r[t+3],vt[4]=r[t+4],vt[5]=r[t+5],vt[6]=r[t+6],vt[7]=r[t+7],xo[0]}var Zf=BigInt(Number.MAX_SAFE_INTEGER),Jf=BigInt(Number.MIN_SAFE_INTEGER),Rt=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<Zf&&t>Jf)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>Ba&&(s=0n,++n>Ba&&(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 Rt(0,0);Fe.toBigInt=function(){return 0n};Fe.zzEncode=Fe.zzDecode=function(){return this};Fe.length=function(){return 1};var Ba=4294967296n;function Aa(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 Sa(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 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 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,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=xa(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw Ot(this,4);let t=Ea(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 Sa(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 Rt(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 Rt(t,e)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let t=bo(this.buf,this.pos);return this.pos+=ut(t),t}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 Bo(r){return new Eo(r instanceof Uint8Array?r:r.subarray())}function ne(r,t,e){let n=Bo(r);return t.decode(n,void 0,e)}function Ao(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return wt(i);s+i>t&&(n=wt(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 So(){}var Io=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Xf=Ao();function Qf(r){return globalThis.Buffer!=null?wt(r):Xf(r)}var Lr=class{len;head;tail;states;constructor(){this.len=0,this.head=new He(So,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 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(gn,10,Rt.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=Rt.fromBigInt(t);return this._push(gn,e.length(),e)}uint64Number(t){return this._push(yo,ut(t),t)}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=Rt.fromBigInt(t).zzEncode();return this._push(gn,e.length(),e)}sint64Number(t){let e=Rt.fromNumber(t).zzEncode();return this._push(gn,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ko,1,t?1:0)}fixed32(t){return this._push(Tr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=Rt.fromBigInt(t);return this._push(Tr,4,e.lo)._push(Tr,4,e.hi)}fixed64Number(t){let e=Rt.fromNumber(t);return this._push(Tr,4,e.lo)._push(Tr,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(wa,4,t)}double(t){return this._push(va,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(ko,1,0):this.uint32(e)._push(eh,e,t)}string(t){let e=Aa(t);return e!==0?this.uint32(e)._push(vo,e,t):this._push(ko,1,0)}fork(){return this.states=new Io(this),this.head=this.tail=new He(So,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(So,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=Qf(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function ko(r,t,e){t[e]=r&255}function th(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var Ro=class extends He{next;constructor(t,e){super(th,t,e),this.next=void 0}};function gn(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 Tr(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 eh(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Lr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(rh,t,r),this},Lr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(nh,t,r),this});function rh(r,t,e){t.set(r,e)}function nh(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 Lr}function se(r,t){let e=No();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 mn(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 mn("enum",lr.VARINT,e,n)}function oe(r,t){return mn("message",lr.LENGTH_DELIMITED,r,t)}var gt;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(gt||(gt={}));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=()=>ur(To)})(gt||(gt={}));var Se;(function(r){let t;r.codec=()=>(t==null&&(t=oe((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),gt.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=gt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>se(e,r.codec()),r.decode=e=>ne(e,r.codec())})(Se||(Se={}));var ke;(function(r){let t;r.codec=()=>(t==null&&(t=oe((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),gt.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=gt.codec().decode(e);break;case 2:s.Data=e.bytes();break;default:e.skipType(i&7);break}}return s})),t),r.encode=e=>se(e,r.codec()),r.decode=e=>ne(e,r.codec())})(ke||(ke={}));var _r=class{_key;constructor(t){this._key=fr(t,ar)}verify(t,e){return ma(this._key,e,t)}marshal(){return this._key}get bytes(){return Se.encode({Type:gt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.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 ga(this._key,t)}get public(){return new _r(this._publicKey)}marshal(){return this._key}get bytes(){return ke.encode({Type:gt.Ed25519,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}async hash(){let t=pt.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 sh(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 oh(r){return r=fr(r,ar),new _r(r)}async function ih(){let{privateKey:r,publicKey:t}=da();return new Me(r,t)}async function Ia(r){let{privateKey:t,publicKey:e}=pa(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 z(r,t="utf8"){let e=Xr[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 Ko={};lt(Ko,{MAX_RSA_KEY_SIZE:()=>qr,RsaPrivateKey:()=>mr,RsaPublicKey:()=>$r,fromJwk:()=>Uh,generateKeyPair:()=>Ch,unmarshalRsaPrivateKey:()=>Ho,unmarshalRsaPublicKey:()=>_h});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 Te={};lt(Te,{exportToPem:()=>Ih,importFromPem:()=>Rh,jwkToPkcs1:()=>Bh,jwkToPkix:()=>Sh,pkcs1ToJwk:()=>Eh,pkixToJwk:()=>Ah});var yn=class extends er{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Qr(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()}},Ur=(r,t,e)=>new yn(r,t).update(e).digest();Ur.create=(r,t)=>new yn(r,t);function ah(r,t,e,n){Qr(r);let s=Ji({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=Ur.create(r,c),h=u._cloneInto().update(l);return{c:o,dkLen:i,asyncTick:a,DK:f,PRF:u,PRFSalt:h}}function ch(r,t,e,n,s){return r.destroy(),t.destroy(),n&&n.destroy(),s.fill(0),e}async function Uo(r,t,e,n){let{c:s,dkLen:o,asyncTick:i,DK:a,PRF:c,PRFSalt:l}=ah(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 Zi(s-1,i,()=>{c._cloneInto(f).update(m).digestInto(m);for(let y=0;y<p.length;y++)p[y]^=m[y]})}return ch(c,l,a,f,m)}var H=Bs(Ra());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 Ie(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 xn(...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 Do(){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 Na(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=Ie(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=Ie(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 Ta(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 jg=Math.log(2);function vn(){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 ue(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 Dr=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return Po(this.items)}},Cr=[new Uint8Array([1])],La="0123456789";var pr="",Ft=new ArrayBuffer(0),Oo=new Uint8Array(0),Pr="EndOfContent",Ua="OCTET STRING",Ca="BIT STRING";function fe(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):Oo}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(!ue(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 ae=class{constructor({blockLength:t=0,error:e=pr,warnings:n=[],valueBeforeDecode:s=Oo}={}){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)}}};ae.NAME="baseBlock";var Et=class extends ae{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'")}};Et.NAME="valueBlock";var En=class extends fe(ae){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):Oo,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=Ie(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(!ue(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}}};En.NAME="identificationBlock";var Bn=class extends ae{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(!ue(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=Ie(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}}};Bn.NAME="lengthBlock";var S={},mt=class extends ae{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 En(s),this.lenBlock=new Bn(s),this.valueBlock=o?new o(s):new Et(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 Dr;e||Da(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 Ta(e,n)}};mt.NAME="BaseBlock";function Da(r){if(r instanceof S.Constructed)for(let t of r.valueBlock.value)Da(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var An=class extends mt{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}'`}};An.NAME="BaseStringBlock";var Sn=class extends fe(Et){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};Sn.NAME="PrimitiveValueBlock";var Pa,kn=class extends mt{constructor(t={}){super(t,Sn),this.idBlock.isConstructed=!1}};Pa=kn;S.Primitive=Pa;kn.NAME="PRIMITIVE";function yh(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 os(r,t=0,e=r.length){let n=t,s=new mt({},Et),o=new ae;if(!ue(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=mt;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=yh(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 mt({},Et);return t.error="Input buffer has zero length",{offset:-1,result:t}}return os(H.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function bh(r,t){return r?1:t}var $t=class extends Et{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(!ue(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(;bh(this.isIndefiniteForm,n)>0;){let i=os(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===Pr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Pr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new Dr;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 Oa,Re=class extends mt{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} :`}};Fa=Ne;I.Constructed=Fa;Ne.NAME="CONSTRUCTED";var _n=class extends vt{fromBER(t,e,n){return e}toBER(t){return Ht}};_n.override="EndOfContentValueBlock";var Ha,Cn=class extends mt{constructor(t={}){super(t,_n),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Ha=Cn;I.EndOfContent=Ha;Cn.NAME=Mr;var Ma,Te=class extends mt{constructor(t={}){super(t,vt),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}`}};Ma=Te;I.Null=Ma;Te.NAME="NULL";var Un=class extends he(vt){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 fe(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,_o.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Un.NAME="BooleanValueBlock";var $a,Pn=class extends mt{constructor(t={}){super(t,Un),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}`}};$a=Pn;I.Boolean=$a;Pn.NAME="BOOLEAN";var Dn=class extends he(zt){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=zt.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===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==Pa)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?zt.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Dn.NAME="OctetStringValueBlock";var Ka,le=class r extends mt{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},Dn),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=us(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?Ne.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)}};Ka=le;I.OctetString=Ka;le.NAME=Pa;var On=class extends he(zt){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=zt.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Mr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Da)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(!fe(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=us(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 zt.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ht;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}}};On.NAME="BitStringValueBlock";var qa,mr=class extends mt{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},On),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 Ne.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)}`}}};qa=mr;I.BitString=qa;mr.NAME=Da;var za;function Ih(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=In(new Uint8Array([l%10]),o);break;default:o[i-u]=l%10}}return e[0]>0&&(o=In(e,o)),o}function Ua(r){if(r>=Fr.length)for(let t=Fr.length;t<=r;t++){let e=new Uint8Array([0]),n=Fr[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=In(e,n)),Fr.push(n)}return Fr[r]}function Sh(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 $r=class extends he(vt){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=_o.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(La(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=Sh(Ua(n),e),i="-";break;default:e=Ih(e,Ua(n))}n++,s>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(i+=Ca.charAt(e[c]));return a===!1&&(i+=Ca.charAt(0)),i}};za=$r;$r.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 mt{constructor(t={}){super(t,$r),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Sn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){Sn();let e=BigInt(t),n=new Hr,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 Ga,Vn=class extends ot{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ga=Vn;I.Enumerated=Ga;Vn.NAME="ENUMERATED";var Kr=class extends he(vt){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(!fe(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){Sn();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=Re(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Ht;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}}};Kr.NAME="sidBlock";var Fn=class extends vt{constructor({value:t=yr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Kr;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,Ht;e.push(s)}return Co(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 Kr;if(s>Number.MAX_SAFE_INTEGER){Sn();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}};Fn.NAME="ObjectIdentifierValueBlock";var Wa,Ft=class extends mt{constructor(t={}){super(t,Fn),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()}}};Wa=Ft;I.ObjectIdentifier=Wa;Ft.NAME="OBJECT IDENTIFIER";var qr=class extends he(ce){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(!fe(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=Re(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Ht;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}}};qr.NAME="relativeSidBlock";var Hn=class extends vt{constructor({value:t=yr,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new qr;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,Ht;n.push(o)}return Co(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 qr;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}};Hn.NAME="RelativeObjectIdentifierValueBlock";var Za,Mn=class extends mt{constructor(t={}){super(t,Hn),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()}}};Za=Mn;I.RelativeObjectIdentifier=Za;Mn.NAME="RelativeObjectIdentifier";var Ya,ft=class extends Ne{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Ya=ft;I.Sequence=Ya;ft.NAME="SEQUENCE";var Ja,$n=class extends Ne{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Ja=$n;I.Set=Ja;$n.NAME="SET";var Kn=class extends he(vt){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=yr}toJSON(){return{...super.toJSON(),value:this.value}}};Kn.NAME="StringValueBlock";var qn=class extends Kn{};qn.NAME="SimpleStringValueBlock";var It=class extends Nn{constructor({...t}={}){super(t,qn)}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 zn=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}};zn.NAME="Utf8StringValueBlock";var Xa,ue=class extends zn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Xa=ue;I.Utf8String=Xa;ue.NAME="UTF8String";var jn=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))}};jn.NAME="BmpStringValueBlock";var Qa,Gn=class extends jn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Qa=Gn;I.BmpString=Qa;Gn.NAME="BMPString";var Wn=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=Re(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}};Wn.NAME="UniversalStringValueBlock";var tc,Zn=class extends Wn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};tc=Zn;I.UniversalString=tc;Zn.NAME="UniversalString";var ec,Yn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};ec=Yn;I.NumericString=ec;Yn.NAME="NumericString";var rc,Jn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};rc=Jn;I.PrintableString=rc;Jn.NAME="PrintableString";var nc,Xn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};nc=Xn;I.TeletexString=nc;Xn.NAME="TeletexString";var sc,Qn=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};sc=Qn;I.VideotexString=sc;Qn.NAME="VideotexString";var oc,ts=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};oc=ts;I.IA5String=oc;ts.NAME="IA5String";var ic,es=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};ic=es;I.GraphicString=ic;es.NAME="GraphicString";var ac,zr=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};ac=zr;I.VisibleString=ac;zr.NAME="VisibleString";var cc,rs=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};cc=rs;I.GeneralString=cc;rs.NAME="GeneralString";var lc,ns=class extends It{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};lc=ns;I.CharacterString=lc;ns.NAME="CharacterString";var uc,jr=class extends zr{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}}};uc=jr;I.UTCTime=uc;jr.NAME="UTCTime";var fc,ss=class extends jr{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}}};fc=ss;I.GeneralizedTime=fc;ss.NAME="GeneralizedTime";var hc,os=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};hc=os;I.DATE=hc;os.NAME="DATE";var dc,is=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};dc=is;I.TimeOfDay=dc;is.NAME="TimeOfDay";var pc,as=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};pc=as;I.DateTime=pc;as.NAME="DateTime";var gc,cs=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};gc=cs;I.Duration=gc;cs.NAME="Duration";var mc,ls=class extends ue{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};mc=ls;I.TIME=mc;ls.NAME="TIME";function Rh(r){let{result:t}=br(r),e=t.valueBlock.value;return{n:z(jt(e[1].toBigInt()),"base64url"),e:z(jt(e[2].toBigInt()),"base64url"),d:z(jt(e[3].toBigInt()),"base64url"),p:z(jt(e[4].toBigInt()),"base64url"),q:z(jt(e[5].toBigInt()),"base64url"),dp:z(jt(e[6].toBigInt()),"base64url"),dq:z(jt(e[7].toBigInt()),"base64url"),qi:z(jt(e[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Nh(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 C("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ft({value:[new ot({value:0}),ot.fromBigInt(Gt(Y(r.n,"base64url"))),ot.fromBigInt(Gt(Y(r.e,"base64url"))),ot.fromBigInt(Gt(Y(r.d,"base64url"))),ot.fromBigInt(Gt(Y(r.p,"base64url"))),ot.fromBigInt(Gt(Y(r.q,"base64url"))),ot.fromBigInt(Gt(Y(r.dp,"base64url"))),ot.fromBigInt(Gt(Y(r.dq,"base64url"))),ot.fromBigInt(Gt(Y(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Th(r){let{result:t}=br(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:z(jt(e[0].toBigInt()),"base64url"),e:z(jt(e[1].toBigInt()),"base64url")}}function Lh(r){if(r.n==null||r.e==null)throw new C("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ft({value:[new ft({value:[new Ft({value:"1.2.840.113549.1.1.1"}),new Te]}),new mr({valueHex:new ft({value:[ot.fromBigInt(Gt(Y(r.n,"base64url"))),ot.fromBigInt(Gt(Y(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function jt(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 _h=16,Po=32,Do=1e4;async function Ch(r,t){let e=At.get(),s=new ft({value:[new ot({value:0}),new ft({value:[new Ft({value:"1.2.840.113549.1.1.1"}),new Te]}),new le({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=ze(_h),a=await To(cr,t,i,{c:Do,dkLen:Po}),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 ft({value:[new le({valueHex:i}),new ot({value:Do}),new ot({value:Po}),new ft({value:[new Ft({value:"1.2.840.113549.2.11"}),new Te]})]}),m=new ft({value:[new Ft({value:"1.2.840.113549.1.5.13"}),new ft({value:[new ft({value:[new Ft({value:"1.2.840.113549.1.5.12"}),u]}),new ft({value:[new Ft({value:"2.16.840.1.101.3.4.1.42"}),new le({valueHex:c})]})]})]}),p=new ft({value:[m,new le({valueHex:h})]}).toBER(),d=new Uint8Array(p,0,p.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...z(d,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
|
|
7
|
-
`)}async function Uh(r,t){let e=At.get(),n;if(r.includes("-----BEGIN ENCRYPTED PRIVATE KEY-----")){let s=Y(r.replace("-----BEGIN ENCRYPTED PRIVATE KEY-----","").replace("-----END ENCRYPTED PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=br(s),{iv:i,salt:a,iterations:c,keySize:l,cipherText:h}=Ph(o),u=await To(cr,t,a,{c,dkLen:l}),m=await e.subtle.importKey("raw",u,"AES-CBC",!1,["decrypt"]),f=Gr(await e.subtle.decrypt({name:"AES-CBC",iv:i},m,h)),{result:p}=br(f);n=yc(p)}else if(r.includes("-----BEGIN PRIVATE KEY-----")){let s=Y(r.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","").replace(/\n/g,"").trim(),"base64pad"),{result:o}=br(s);n=yc(o)}else throw new C("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Oo(n)}function Ph(r){let t=r.valueBlock.value[0];if(t.valueBlock.value[0].toString()!=="OBJECT IDENTIFIER : 1.2.840.113549.1.5.13")throw new C("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 C("Only pkcs5PBKDF2 key derivation functions are supported","ERR_INVALID_PARAMS");let o=n.valueBlock.value[1],i=Gr(o.valueBlock.value[0].getValue()),a=Do,c=Po;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 C("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 C("Only AES-CBC encryption schemes are supported","ERR_INVALID_PARAMS")}}}}let u=Gr(l.valueBlock.value[1].getValue());return{cipherText:Gr(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:u}}function yc(r){return Gr(r.valueBlock.value[2].getValue())}function Gr(r){return new Uint8Array(r,0,r.byteLength)}async function bc(r){let t=await At.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 vc(t);return{privateKey:e[0],publicKey:e[1]}}async function Vo(r){let e=[await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Dh(r)],n=await vc({privateKey:e[0],publicKey:e[1]});return{privateKey:n[0],publicKey:n[1]}}async function wc(r,t){let e=await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await At.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function xc(r,t,e){let n=await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return At.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function vc(r){if(r.privateKey==null||r.publicKey==null)throw new C("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([At.get().subtle.exportKey("jwk",r.privateKey),At.get().subtle.exportKey("jwk",r.publicKey)])}async function Dh(r){return At.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 fs(r){if(r.kty!=="RSA")throw new C("invalid key type","ERR_INVALID_KEY_TYPE");if(r.n==null)throw new C("invalid key modulus","ERR_INVALID_KEY_MODULUS");return Y(r.n,"base64url").length*8}var Zr=8192,Wr=class{_key;constructor(t){this._key=t}verify(t,e){return xc(this._key,e,t)}marshal(){return Le.jwkToPkix(this._key)}get bytes(){return Se.encode({Type:gt.RSA,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}},wr=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e}genSecret(){return ze(16)}sign(t){return wc(this._key,t)}get public(){if(this._publicKey==null)throw new C("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Wr(this._publicKey)}marshal(){return Le.jwkToPkcs1(this._key)}get bytes(){return ke.encode({Type:gt.RSA,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return z(t,"base58btc")}async export(t,e="pkcs-8"){if(e==="pkcs-8")return Le.exportToPem(this,t);if(e==="libp2p-key")return fr(this.bytes,t);throw new C(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};async function Oo(r){let t=Le.pkcs1ToJwk(r);if(fs(t)>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Vo(t);return new wr(e.privateKey,e.publicKey)}function Vh(r){let t=Le.pkixToJwk(r);if(fs(t)>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Wr(t)}async function Fh(r){if(fs(r)>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Vo(r);return new wr(t.privateKey,t.publicKey)}async function Hh(r){if(r>Zr)throw new C("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await bc(r);return new wr(t.privateKey,t.publicKey)}var qo={};ut(qo,{Secp256k1PrivateKey:()=>Jr,Secp256k1PublicKey:()=>Yr,generateKeyPair:()=>ed,unmarshalSecp256k1PrivateKey:()=>Qh,unmarshalSecp256k1PublicKey:()=>td});var Mh=(r,t,e)=>r&t^~r&e,$h=(r,t,e)=>r&t^r&e^t&e,Kh=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]),_e=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Ce=new Uint32Array(64),Ho=class extends ar{constructor(){super(64,32,8,!1),this.A=_e[0]|0,this.B=_e[1]|0,this.C=_e[2]|0,this.D=_e[3]|0,this.E=_e[4]|0,this.F=_e[5]|0,this.G=_e[6]|0,this.H=_e[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)Ce[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let m=Ce[u-15],f=Ce[u-2],p=Pt(m,7)^Pt(m,18)^m>>>3,d=Pt(f,17)^Pt(f,19)^f>>>10;Ce[u]=d+Ce[u-7]+p+Ce[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+Mh(a,c,l)+Kh[u]+Ce[u]|0,d=(Pt(n,2)^Pt(n,13)^Pt(n,22))+$h(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(){Ce.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var Ec=un(()=>new Ho);function qh(r){let t=Cr(r);qt(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:zh,hexToBytes:jh}=dn,Ge={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(r){let{Err:t}=Ge;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:zh(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=Ge,e=typeof r=="string"?jh(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}=Ge._parseInt(e.subarray(2)),{d:i,l:a}=Ge._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}`}},de=BigInt(0),Ct=BigInt(1),Cm=BigInt(2),Bc=BigInt(3),Um=BigInt(4);function Gh(r){let t=qh(r),{Fp:e}=t,n=t.toBytes||((p,d,g)=>{let y=d.toAffine();return ee(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"&&de<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=Qt(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:te(et("private key",p,g))}catch{throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof p}`)}return y&&(w=Z(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,A=e.eql(e.mul(g,v),e.mul(w,b)),N=e.eql(e.mul(y,v),e.mul(k,b));return A&&N}negate(){return new u(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:g}=t,y=e.mul(g,Bc),{px:b,py:w,pz:k}=this,v=e.ZERO,A=e.ZERO,N=e.ZERO,T=e.mul(b,b),q=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),A=e.mul(y,$),A=e.add(v,A),v=e.sub(q,A),A=e.add(q,A),A=e.mul(v,A),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),A=e.add(A,T),$=e.mul(w,k),$=e.add($,$),T=e.mul($,D),v=e.sub(v,T),N=e.mul($,q),N=e.add(N,N),N=e.add(N,N),new u(v,A,N)}add(d){h(d);let{px:g,py:y,pz:b}=this,{px:w,py:k,pz:v}=d,A=e.ZERO,N=e.ZERO,T=e.ZERO,q=t.a,$=e.mul(t.b,Bc),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),A=e.add(k,v),R=e.mul(R,A),A=e.add(nt,rt),R=e.sub(R,A),T=e.mul(q,E),A=e.mul($,rt),T=e.add(A,T),A=e.sub(nt,T),T=e.add(nt,T),N=e.mul(A,T),nt=e.add(D,D),nt=e.add(nt,D),rt=e.mul(q,rt),E=e.mul($,E),nt=e.add(nt,rt),rt=e.sub(D,rt),rt=e.mul(q,rt),E=e.add(E,rt),D=e.mul(nt,E),N=e.add(N,D),D=e.mul(R,E),A=e.mul(Tt,A),A=e.sub(A,D),D=e.mul(Tt,nt),T=e.mul(R,T),T=e.add(T,D),new u(A,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===de)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),A=g,N=g,T=this;for(;w>de||v>de;)w&Ct&&(A=A.add(T)),v&Ct&&(N=N.add(T)),T=T.double(),w>>=Ct,v>>=Ct;return b&&(A=A.negate()),k&&(N=N.negate()),N=new u(e.mul(N.px,y.beta),N.py,N.pz),A.add(N)}multiply(d){a(d);let g=d,y,b,{endo:w}=t;if(w){let{k1neg:k,k1:v,k2neg:A,k2:N}=w.splitScalar(g),{p:T,f:q}=this.wNAF(v),{p:$,f:D}=this.wNAF(N);T=f.constTimeNegate(k,T),$=f.constTimeNegate(A,$),$=new u(e.mul($.px,w.beta),$.py,$.pz),y=T.add($),b=q.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,A)=>A===de||A===Ct||!v.equals(b)?v.multiplyUnsafe(A):v.multiply(A),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),A=e.mul(b,d);if(w)return{x:e.ZERO,y:e.ZERO};if(!e.eql(A,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 Qt(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=mn(u,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function Wh(r){let t=Cr(r);return qt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function Ac(r){let t=Wh(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return de<E&&E<e.ORDER}function a(E){return Z(E,n)}function c(E){return pn(E,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:h,weierstrassEquation:u,isWithinCurveOrder:m}=Gh({...t,toBytes(E,R,O){let B=R.toAffine(),x=e.toBytes(B.x),S=ee;return O?S(Uint8Array.from([R.hasEvenY()?2:3]),x):S(Uint8Array.from([4]),x,e.toBytes(B.y))},fromBytes(E){let R=E.length,O=E[0],B=E.subarray(1);if(R===s&&(O===2||O===3)){let x=te(B);if(!i(x))throw new Error("Point is not on curve");let S=u(x),L=e.sqrt(S),_=(L&Ct)===Ct;return(O&1)===1!==_&&(L=e.neg(L)),{x,y:L}}else if(R===o&&O===4){let x=e.fromBytes(B.subarray(0,e.BYTES)),S=e.fromBytes(B.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=>Qt(Ae(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)=>te(E.slice(R,O));class y{constructor(R,O,B){this.r=R,this.s=O,this.recovery=B,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:B}=Ge.toSig(et("DER",R));return new y(O,B)}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:B,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 _=x&1?"03":"02",V=l.fromHex(_+f(L)),F=c(L),G=a(-S*F),M=a(B*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 Fe(this.toDERHex())}toDERHex(){return Ge.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Fe(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=lo(t.n);return ua(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",B=(R||O)&&E.length;return R?B===s||B===o:O?B===2*s||B===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 A=t.bits2int||function(E){let R=te(E),O=E.length*8-t.nBitLength;return O>0?R>>BigInt(O):R},N=t.bits2int_modN||function(E){return a(A(E))},T=_r(t.nBitLength);function q(E){if(typeof E!="bigint")throw new Error("bigint expected");if(!(de<=E&&E<T))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Ae(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:B,randomBytes:x}=t,{lowS:S,prehash:L,extraEntropy:_}=O;S==null&&(S=!0),E=et("msgHash",E),L&&(E=et("prehashed msgHash",B(E)));let V=N(E),F=h(R),G=[q(F),q(V)];if(_!=null){let Q=_===!0?x(e.BYTES):_;G.push(et("extraEntropy",Q))}let M=ee(...G),K=V;function st(Q){let ht=A(Q);if(!m(ht))return;let dt=c(ht),at=l.BASE.multiply(ht).toAffine(),yt=a(at.x);if(yt===de)return;let Wt=a(dt*a(K+yt*F));if(Wt===de)return;let De=(at.x===yt?0:2)|Number(at.y&Ct),kr=Wt;return S&&p(Wt)&&(kr=d(Wt),De^=1),new y(yt,kr,De)}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:B,k2sig:x}=$(E,R,O),S=t;return oo(S.hash.outputLen,S.nByteLength,S.hmac)(B,x)}l.BASE._setWindowSize(8);function Tt(E,R,O,B=nt){let x=E;if(R=et("msgHash",R),O=et("publicKey",O),"strict"in B)throw new Error("options.strict was renamed to lowS");let{lowS:S,prehash:L}=B,_,V;try{if(typeof x=="string"||Dt(x))try{_=y.fromDER(x)}catch(at){if(!(at instanceof Ge.Err))throw at;_=y.fromCompact(x)}else if(typeof x=="object"&&typeof x.r=="bigint"&&typeof x.s=="bigint"){let{r:at,s:yt}=x;_=new y(at,yt)}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&&_.hasHighS())return!1;L&&(R=t.hash(R));let{r:F,s:G}=_,M=N(R),K=c(G),st=a(M*K),Q=a(F*K),ht=l.BASE.multiplyAndAddUnsafe(V,st,Q)?.toAffine();return ht?a(ht.x)===F:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:v,sign:rt,verify:Tt,ProjectivePoint:l,Signature:y,utils:b}}function Zh(r){return{hash:r,hmac:(t,...e)=>Vr(r,t,ln(...e)),randomBytes:ir}}function Ic(r,t){let e=n=>Ac({...r,...Zh(n)});return Object.freeze({...e(t),create:e})}var Rc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Sc=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Yh=BigInt(1),Mo=BigInt(2),kc=(r,t)=>(r+t/Mo)/t;function Jh(r){let t=Rc,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,Mo,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,A=X(v,Mo,t);if(!$o.eql($o.sqr(A),r))throw new Error("Cannot find square root");return A}var $o=gn(Rc,void 0,void 0,{sqrt:Jh}),Mt=Ic({a:BigInt(0),b:BigInt(7),Fp:$o,n:Sc,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Sc,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Yh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),a=kc(o*r,t),c=kc(-n*r,t),l=Z(r-a*e-c*s,t),h=Z(-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}}}},Ec),Km=BigInt(0);var qm=Mt.ProjectivePoint;function Nc(){return Mt.utils.randomPrivateKey()}function Tc(r,t){let e=pt.digest(t instanceof Uint8Array?t:t.subarray());if(Lt(e))return e.then(({digest:n})=>Mt.sign(n,r).toDERRawBytes()).catch(n=>{throw new C(String(n),"ERR_INVALID_INPUT")});try{return Mt.sign(e.digest,r).toDERRawBytes()}catch(n){throw new C(String(n),"ERR_INVALID_INPUT")}}function Lc(r,t,e){let n=pt.digest(e instanceof Uint8Array?e:e.subarray());if(Lt(n))return n.then(({digest:s})=>Mt.verify(t,s,r)).catch(s=>{throw new C(String(s),"ERR_INVALID_INPUT")});try{return Mt.verify(t,n.digest,r)}catch(s){throw new C(String(s),"ERR_INVALID_INPUT")}}function _c(r){return Mt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Cc(r){try{Mt.getPublicKey(r,!0)}catch(t){throw new C(String(t),"ERR_INVALID_PRIVATE_KEY")}}function Ko(r){try{Mt.ProjectivePoint.fromHex(r)}catch(t){throw new C(String(t),"ERR_INVALID_PUBLIC_KEY")}}function Uc(r){try{return Mt.getPublicKey(r,!0)}catch(t){throw new C(String(t),"ERR_INVALID_PRIVATE_KEY")}}var Yr=class{_key;constructor(t){Ko(t),this._key=t}verify(t,e){return Lc(this._key,e,t)}marshal(){return _c(this._key)}get bytes(){return Se.encode({Type:gt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}async hash(){let t=pt.digest(this.bytes),e;return Lt(t)?{bytes:e}=await t:e=t.bytes,e}},Jr=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e??Uc(t),Cc(this._key),Ko(this._publicKey)}sign(t){return Tc(this._key,t)}get public(){return new Yr(this._publicKey)}marshal(){return this._key}get bytes(){return ke.encode({Type:gt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Lt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return z(t,"base58btc")}async export(t,e="libp2p-key"){if(e==="libp2p-key")return fr(this.bytes,t);throw new C(`export format '${e}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Qh(r){return new Jr(r)}function td(r){return new Yr(r)}async function ed(){let r=Nc();return new Jr(r)}var Pc={rsa:Fo,ed25519:No,secp256k1:qo};function rd(r){let t=Object.keys(Pc).join(" / ");return new C(`invalid or unsupported key type ${r}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function zo(r){if(r=r.toLowerCase(),r==="rsa"||r==="ed25519"||r==="secp256k1")return Pc[r];throw rd(r)}async function Dc(r,t){return zo(r).generateKeyPair(t??2048)}function Oc(r,t){return t=(t??"rsa").toLowerCase(),zo(t),r.bytes}function Vc(r,t){return t=(t??"rsa").toLowerCase(),zo(t),r.bytes}var Fc=async()=>{let r=await Dc("Ed25519"),t=await nd(r);if(t.type==="Ed25519")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function nd(r){return Gi(Oc(r.public),Vc(r))}var sd=Math.pow(2,7),od=Math.pow(2,14),id=Math.pow(2,21),jo=Math.pow(2,28),Go=Math.pow(2,35),Wo=Math.pow(2,42),Zo=Math.pow(2,49),j=128,Et=127;function Rt(r){if(r<sd)return 1;if(r<od)return 2;if(r<id)return 3;if(r<jo)return 4;if(r<Go)return 5;if(r<Wo)return 6;if(r<Zo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function ad(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 cd(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 ld(r,t){let e=r[t],n=0;if(n+=e&Et,e<j||(e=r[t+1],n+=(e&Et)<<7,e<j)||(e=r[t+2],n+=(e&Et)<<14,e<j)||(e=r[t+3],n+=(e&Et)<<21,e<j)||(e=r[t+4],n+=(e&Et)*jo,e<j)||(e=r[t+5],n+=(e&Et)*Go,e<j)||(e=r[t+6],n+=(e&Et)*Wo,e<j)||(e=r[t+7],n+=(e&Et)*Zo,e<j))return n;throw new RangeError("Could not decode varint")}function ud(r,t){let e=r.get(t),n=0;if(n+=e&Et,e<j||(e=r.get(t+1),n+=(e&Et)<<7,e<j)||(e=r.get(t+2),n+=(e&Et)<<14,e<j)||(e=r.get(t+3),n+=(e&Et)<<21,e<j)||(e=r.get(t+4),n+=(e&Et)*jo,e<j)||(e=r.get(t+5),n+=(e&Et)*Go,e<j)||(e=r.get(t+6),n+=(e&Et)*Wo,e<j)||(e=r.get(t+7),n+=(e&Et)*Zo,e<j))return n;throw new RangeError("Could not decode varint")}function Ue(r,t,e=0){return t==null&&(t=wt(Rt(r))),t instanceof Uint8Array?ad(r,t,e):cd(r,t,e)}function pe(r,t=0){return r instanceof Uint8Array?ld(r,t):ud(r,t)}var ds=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 Hc=45,fd=15,xr=new ds;function Yo(r){if(!(r.length>fd))return xr.new(r).parseWith(()=>xr.readIPv4Addr())}function Jo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hc))return xr.new(r).parseWith(()=>xr.readIPv6Addr())}function ps(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Hc))return xr.new(r).parseWith(()=>xr.readIPAddr())}var xy=parseInt("0xFFFF",16),vy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Kc(r){return!!Yo(r)}function qc(r){return!!Jo(r)}function vr(r){return!!ps(r)}var zc=Kc,md=qc,Xo=function(r){let t=0;if(r=r.toString().trim(),zc(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(md(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=zc(e[n]),i;o&&(i=Xo(e[n]),e[n]=z(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,z(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")},jc=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 Er={},Qo={},bd=[[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"]];bd.forEach(r=>{let t=wd(...r);Qo[t.code]=t,Er[t.name]=t});function wd(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function W(r){if(typeof r=="number"){if(Qo[r]!=null)return Qo[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Er[r]!=null)return Er[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var sb=W("ip4"),ob=W("ip6"),ib=W("ipcidr");function ei(r,t){switch(W(r).code){case 4:case 41:return vd(t);case 42:return Zc(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 Zc(t);case 421:return Id(t);case 444:return Yc(t);case 445:return Yc(t);case 466:return Ad(t);default:return z(t,"base16")}}function ri(r,t){switch(W(r).code){case 4:return Gc(t);case 41:return Gc(t);case 42:return Wc(t);case 6:case 273:case 33:case 132:return ni(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Wc(t);case 421:return Ed(t);case 444:return Sd(t);case 445:return kd(t);case 466:return Bd(t);default:return Y(t,"base16")}}var ti=Object.values(be).map(r=>r.decoder),xd=function(){let r=ti[0].or(ti[1]);return ti.slice(2).forEach(t=>r=r.or(t)),r}();function Gc(r){if(!vr(r))throw new Error("invalid ip address");return Xo(r)}function vd(r){let t=jc(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!vr(t))throw new Error("invalid ip address");return t}function ni(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 Wc(r){let t=Y(r),e=Uint8Array.from(Ue(t.length));return Bt([e,t],e.length+t.length)}function Zc(r){let t=pe(r);if(r=r.slice(Rt(t)),r.length!==t)throw new Error("inconsistent lengths");return z(r)}function Ed(r){let t;r[0]==="Q"||r[0]==="1"?t=Oe(ct.decode(`z${r}`)).bytes:t=Ut.parse(r).multihash.bytes;let e=Uint8Array.from(Ue(t.length));return Bt([e,t],e.length+t.length)}function Bd(r){let t=xd.decode(r),e=Uint8Array.from(Ue(t.length));return Bt([e,t],e.length+t.length)}function Ad(r){let t=pe(r),e=r.slice(Rt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+z(e,"base64url")}function Id(r){let t=pe(r),e=r.slice(Rt(t));if(e.length!==t)throw new Error("inconsistent lengths");return z(e,"base58btc")}function Sd(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=Yt.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=ni(n);return Bt([e,s],e.length+s.length)}function kd(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=Yt.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=ni(n);return Bt([e,s],e.length+s.length)}function Yc(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=z(t,"base32"),s=Jc(e);return`${n}:${s}`}function Xc(r){r=si(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 tl("invalid address: "+r);if(a.path===!0){n=si(s.slice(o).join("/")),t.push([a.code,ri(a.code,n)]),e.push([a.code,n]);break}let c=ri(a.code,s[o]);t.push([a.code,c]),e.push([a.code,ei(a.code,c)])}return{string:Qc(e),bytes:ii(t),tuples:t,stringTuples:e,path:n}}function oi(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=pe(r,s),i=Rt(o),a=W(o),c=Rd(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 tl("Invalid address Uint8Array: "+z(r,"base16"));t.push([o,l]);let h=ei(o,l);if(e.push([o,h]),a.path===!0){n=h;break}}return{bytes:Uint8Array.from(r),string:Qc(e),tuples:t,stringTuples:e,path:n}}function Qc(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}),si(t.join("/"))}function ii(r){return Bt(r.map(t=>{let e=W(t[0]),n=Uint8Array.from(Ue(e.code));return t.length>1&&t[1]!=null&&(n=Bt([n,t[1]])),n}))}function Rd(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=pe(t instanceof Uint8Array?t:Uint8Array.from(t));return e+Rt(e)}}function si(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function tl(r){return new Error("Error parsing address: "+r)}var Nd=Symbol.for("nodejs.util.inspect.custom"),ai=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Td=[W("dns").code,W("dns4").code,W("dns6").code,W("dnsaddr").code],gs=class r{bytes;#e;#t;#r;#n;[ai]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=oi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Xc(t)}else if(rl(t))e=oi(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??""}`),Td.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(ii(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===Er.p2p.code&&t.push([n,s]),n===Er["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?z(ct.decode(`z${n}`),"base58btc"):z(Ut.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return bt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=el.get(e.name);if(n==null)throw new C(`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)}[Nd](){return`Multiaddr(${this.#e})`}};var el=new Map;function rl(r){return!!r?.[ai]}function ms(r){return new gs(r)}function Ld(r){return r[Symbol.asyncIterator]!=null}function _d(r){if(Ld(r))return(async()=>{for await(let t of r)return t})();for(let t of r)return t}var ci=_d;var sl=Symbol.for("@achingbrain/uint8arraylist");function nl(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 ys(r){return!!r?.[sl]}var Br=class r{bufs;length;[sl]=!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(ys(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(ys(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=nl(this.bufs,t);return e.buf[e.index]}set(t,e){let n=nl(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(ys(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 Bt(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Bt(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(!ys(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=wt(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=Jt(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=Jt(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=Jt(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=wt(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=Jt(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=Jt(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=Jt(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=Jt(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=Jt(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(!bt(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 bs(r){return r[Symbol.asyncIterator]!=null}var ws=r=>{let t=Rt(r),e=wt(t);return Ue(r,e),ws.bytes=t,e};ws.bytes=0;function Xr(r,t){t=t??{};let e=t.lengthEncoder??ws;function*n(s){let o=e(s.byteLength);o instanceof Uint8Array?yield o:yield*o,s instanceof Uint8Array?yield s:yield*s}return bs(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??ws;return new Br(e(r.byteLength),r)};var Ar=rn(al(),1);var Ud=8,Pd=1024*1024*4,We;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(We||(We={}));var li=r=>{let t=pe(r);return li.bytes=Rt(t),t};li.bytes=0;function Ir(r,t){let e=new Br,n=We.LENGTH,s=-1,o=t?.lengthDecoder??li,i=t?.maxLengthLength??Ud,a=t?.maxDataLength??Pd;function*c(){for(;e.byteLength>0;){if(n===We.LENGTH)try{if(s=o(e),s<0)throw(0,Ar.default)(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(s>a)throw(0,Ar.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=We.DATA}catch(l){if(l instanceof RangeError){if(e.byteLength>i)throw(0,Ar.default)(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw l}if(n===We.DATA){if(e.byteLength<s)break;let l=e.sublist(0,s);e.consume(s),t?.onData!=null&&t.onData(l),yield l,n=We.LENGTH}}}return bs(r)?async function*(){for await(let l of r)e.append(l),yield*c();if(e.byteLength>0)throw(0,Ar.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,Ar.default)(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}Ir.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 Ir(n,{...t??{},onLength:o=>{e=o}})};function Od(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 cl=Od;function Vd(r){return r[Symbol.asyncIterator]!=null}function Fd(r,t){if(Vd(r))return async function*(){for await(let a of r)yield t(a)}();let e=cl(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 ll=Fd;function ge(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var xs=globalThis.CustomEvent??Event;async function*ui(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=ge(),a=ge(),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=ge(),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 xs("task-complete"))},g=>{d.done=!0,d.err=g,s.dispatchEvent(new xs("task-complete"))})}c=!0,s.dispatchEvent(new xs("task-complete"))}catch(p){l=p,s.dispatchEvent(new xs("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=ge(),await a.promise),l!=null)throw l;if(n?yield*m():yield*f(),c&&o.length===0)break}}var vs=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}},Sr=class{size;hwm;head;tail;constructor(t={}){this.hwm=t.splitLimit??16,this.head=new vs(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 vs(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 fi=class extends Error{type;code;constructor(t,e){super(t??"The operation was aborted"),this.type="aborted",this.code=e??"ABORT_ERR"}};function Es(r={}){return Hd(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 Hd(r,t){t=t??{};let e=t.onEnd,n=new Sr,s,o,i,a=ge(),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=ge()})}},l=g=>o!=null?o(g):(n.push(g),s),h=g=>(n=new Sr,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 Sr,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 fi)},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 Md(r){return r[Symbol.asyncIterator]!=null}function $d(...r){let t=[];for(let e of r)Md(e)||t.push(e);return t.length===r.length?function*(){for(let e of t)yield*e}():async function*(){let e=Es({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 ul=$d;function di(r,...t){if(r==null)throw new Error("Empty pipeline");if(hi(r)){let n=r;r=()=>n.source}else if(hl(r)||fl(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&hi(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++)hi(e[n])&&(e[n]=qd(e[n]));return Kd(...e)}var Kd=(...r)=>{let t;for(;r.length>0;)t=r.shift()(t);return t},fl=r=>r?.[Symbol.asyncIterator]!=null,hl=r=>r?.[Symbol.iterator]!=null,hi=r=>r==null?!1:r.sink!=null&&r.source!=null,qd=r=>t=>{let e=r.sink(t);if(e?.then!=null){let n=Es({objectMode:!0});e.then(()=>{n.end()},i=>{n.end(i)});let s,o=r.source;if(fl(o))s=async function*(){yield*o,n.end()};else if(hl(o))s=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return ul(n,s())}return r.source};var wl=rn(dl(),1);var pl="[a-fA-F\\d:]",Pe=r=>r&&r.includeBoundaries?`(?:(?<=\\s|^)(?=${pl})|(?<=${pl})(?=\\s|$))`:"",$t="(?: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}",Bs=`
|
|
8
|
-
(?:
|
|
9
|
-
(?:${it}:){7}(?:${it}|:)| // 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:8
|
|
10
|
-
(?:${it}:){6}(?:${$t}|:${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}(?::${$t}|(?::${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}:${$t}|(?::${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}:${$t}|(?::${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}:${$t}|(?::${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}:${$t}|(?::${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}:${$t}|(?::${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(),zd=new RegExp(`(?:^${$t}$)|(?:^${Bs}$)`),jd=new RegExp(`^${$t}$`),Gd=new RegExp(`^${Bs}$`),pi=r=>r&&r.exact?zd:new RegExp(`(?:${Pe(r)}${$t}${Pe(r)})|(?:${Pe(r)}${Bs}${Pe(r)})`,"g");pi.v4=r=>r&&r.exact?jd:new RegExp(`${Pe(r)}${$t}${Pe(r)}`,"g");pi.v6=r=>r&&r.exact?Gd:new RegExp(`${Pe(r)}${Bs}${Pe(r)}`,"g");var gl=pi;var xl=rn(yl(),1),{isValid:Wd,parse:Zd}=xl.default,Yd=["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"],Jd=Yd.map(r=>new wl.Netmask(r));function Xd(r){for(let t of Jd)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 vl=r=>{if(Wd(r)){let t=Zd(r);if(t.kind()==="ipv4")return Xd(t.toNormalizedString());if(t.kind()==="ipv6")return bl(r)}else if(vr(r)&&gl.v6().test(r))return bl(r)};var gi=vl;var El="libp2p",Bl="autonat",Al="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=()=>dr(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=()=>dr(s)}(n=r.ResponseStatus||(r.ResponseStatus={}));let o;(function(l){let h;l.codec=()=>(h==null&&(h=ie((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=>oe(u,l.codec()),l.decode=u=>se(u,l.codec())})(o=r.PeerInfo||(r.PeerInfo={}));let i;(function(l){let h;l.codec=()=>(h==null&&(h=ie((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=>oe(u,l.codec()),l.decode=u=>se(u,l.codec())})(i=r.Dial||(r.Dial={}));let a;(function(l){let h;l.codec=()=>(h==null&&(h=ie((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=>oe(u,l.codec()),l.decode=u=>se(u,l.codec())})(a=r.DialResponse||(r.DialResponse={}));let c;r.codec=()=>(c==null&&(c=ie((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=>oe(l,r.codec()),r.decode=l=>se(l,r.codec())})(P||(P={}));var mi=4,Is=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??El}/${Bl}/${Al}`,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 C("handleIncomingAutonatStream timeout",ks))};e.addEventListener("abort",n,{once:!0}),Rs(1/0,e);let s=this.components.addressManager.getAddresses().map(o=>o.toOptions().host);try{let o=this;await di(t.stream,i=>Ir(i),async function*(i){let a=await ci(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=sn(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=>ms(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=!(gi(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!(gi(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);Rs(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 Fc()).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 C("verifyAddress timeout",ks))},n.addEventListener("abort",m,{once:!0});let d=await di([o],y=>Xr(y),p,y=>Ir(y),async y=>ci(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 ui(ll(this.components.peerRouting.getClosestPeers(a,{signal:n}),m=>async()=>h(m)),{concurrency:mi}))try{if(u==null)continue;let m=u.addr==null?e[0]:ms(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===mi){this.log("%a is externally dialable",m),t.confirmObservedAddr(m);return}if(c[f].failure===mi){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 s0(r={}){return t=>new Is(t,r)}return Vl(o0);})();
|
|
6
|
+
`)}`:`${e} :`}};Oa=Re;S.Constructed=Oa;Re.NAME="CONSTRUCTED";var In=class extends Et{fromBER(t,e,n){return e}toBER(t){return Ft}};In.override="EndOfContentValueBlock";var Va,Rn=class extends mt{constructor(t={}){super(t,In),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Va=Rn;S.EndOfContent=Va;Rn.NAME=Pr;var Fa,Ne=class extends mt{constructor(t={}){super(t,Et),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}`}};Fa=Ne;S.Null=Fa;Ne.NAME="NULL";var Nn=class extends fe(Et){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 ue(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,Do.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Nn.NAME="BooleanValueBlock";var Ha,Tn=class extends mt{constructor(t={}){super(t,Nn),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}`}};Ha=Tn;S.Boolean=Ha;Tn.NAME="BOOLEAN";var Ln=class extends fe($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===Pr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==Ua)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}}};Ln.NAME="OctetStringValueBlock";var Ma,ce=class r extends mt{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=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=os(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?Re.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)}};Ma=ce;S.OctetString=Ma;ce.NAME=Ua;var _n=class extends fe($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===Pr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Ca)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(!ue(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=os(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}}};_n.NAME="BitStringValueBlock";var Ka,dr=class extends mt{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},_n),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 Re.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)}`}}};Ka=dr;S.BitString=Ka;dr.NAME=Ca;var $a;function wh(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=xn(new Uint8Array([l%10]),o);break;default:o[i-u]=l%10}}return e[0]>0&&(o=xn(e,o)),o}function _a(r){if(r>=Cr.length)for(let t=Cr.length;t<=r;t++){let e=new Uint8Array([0]),n=Cr[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=xn(e,n)),Cr.push(n)}return Cr[r]}function xh(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 Or=class extends fe(Et){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=Do.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(Na(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=xh(_a(n),e),i="-";break;default:e=wh(e,_a(n))}n++,s>>=1}}for(let c=0;c<e.length;c++)e[c]&&(a=!0),a&&(i+=La.charAt(e[c]));return a===!1&&(i+=La.charAt(0)),i}};$a=Or;Or.NAME="IntegerValueBlock";Object.defineProperty($a.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var qa,ot=class r extends mt{constructor(t={}){super(t,Or),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return vn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){vn();let e=BigInt(t),n=new Dr,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()}`}};qa=ot;S.Integer=qa;ot.NAME="INTEGER";var Ga,Un=class extends ot{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ga=Un;S.Enumerated=Ga;Un.NAME="ENUMERATED";var Vr=class extends fe(Et){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(!ue(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){vn();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=Ie(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}}};Vr.NAME="sidBlock";var Cn=class extends Et{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 Vr;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 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 Vr;if(s>Number.MAX_SAFE_INTEGER){vn();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}};Cn.NAME="ObjectIdentifierValueBlock";var za,Vt=class extends mt{constructor(t={}){super(t,Cn),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()}}};za=Vt;S.ObjectIdentifier=za;Vt.NAME="OBJECT IDENTIFIER";var Fr=class extends fe(ae){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(!ue(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=Ie(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}}};Fr.NAME="relativeSidBlock";var Dn=class extends Et{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.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 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 Fr;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}};Dn.NAME="RelativeObjectIdentifierValueBlock";var ja,Pn=class extends mt{constructor(t={}){super(t,Dn),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()}}};ja=Pn;S.RelativeObjectIdentifier=ja;Pn.NAME="RelativeObjectIdentifier";var Wa,ft=class extends Re{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Wa=ft;S.Sequence=Wa;ft.NAME="SEQUENCE";var Ya,On=class extends Re{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Ya=On;S.Set=Ya;On.NAME="SET";var Vn=class extends fe(Et){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=pr}toJSON(){return{...super.toJSON(),value:this.value}}};Vn.NAME="StringValueBlock";var Fn=class extends Vn{};Fn.NAME="SimpleStringValueBlock";var St=class extends An{constructor({...t}={}){super(t,Fn)}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}};St.NAME="SIMPLE STRING";var Hn=class extends St{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}};Hn.NAME="Utf8StringValueBlock";var Za,le=class extends Hn{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Za=le;S.Utf8String=Za;le.NAME="UTF8String";var Mn=class extends St{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))}};Mn.NAME="BmpStringValueBlock";var Ja,Kn=class extends Mn{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Ja=Kn;S.BmpString=Ja;Kn.NAME="BMPString";var $n=class extends St{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=Ie(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}};$n.NAME="UniversalStringValueBlock";var Xa,qn=class extends $n{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Xa=qn;S.UniversalString=Xa;qn.NAME="UniversalString";var Qa,Gn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Qa=Gn;S.NumericString=Qa;Gn.NAME="NumericString";var tc,zn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};tc=zn;S.PrintableString=tc;zn.NAME="PrintableString";var ec,jn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};ec=jn;S.TeletexString=ec;jn.NAME="TeletexString";var rc,Wn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};rc=Wn;S.VideotexString=rc;Wn.NAME="VideotexString";var nc,Yn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};nc=Yn;S.IA5String=nc;Yn.NAME="IA5String";var sc,Zn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};sc=Zn;S.GraphicString=sc;Zn.NAME="GraphicString";var oc,Hr=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};oc=Hr;S.VisibleString=oc;Hr.NAME="VisibleString";var ic,Jn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};ic=Jn;S.GeneralString=ic;Jn.NAME="GeneralString";var ac,Xn=class extends St{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};ac=Xn;S.CharacterString=ac;Xn.NAME="CharacterString";var cc,Mr=class extends Hr{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}}};cc=Mr;S.UTCTime=cc;Mr.NAME="UTCTime";var lc,Qn=class extends Mr{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}}};lc=Qn;S.GeneralizedTime=lc;Qn.NAME="GeneralizedTime";var uc,ts=class extends le{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};uc=ts;S.DATE=uc;ts.NAME="DATE";var fc,es=class extends le{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};fc=es;S.TimeOfDay=fc;es.NAME="TimeOfDay";var hc,rs=class extends le{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};hc=rs;S.DateTime=hc;rs.NAME="DateTime";var dc,ns=class extends le{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};dc=ns;S.Duration=dc;ns.NAME="Duration";var pc,ss=class extends le{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};pc=ss;S.TIME=pc;ss.NAME="TIME";function Eh(r){let{result:t}=gr(r),e=t.valueBlock.value;return{n:z(qt(e[1].toBigInt()),"base64url"),e:z(qt(e[2].toBigInt()),"base64url"),d:z(qt(e[3].toBigInt()),"base64url"),p:z(qt(e[4].toBigInt()),"base64url"),q:z(qt(e[5].toBigInt()),"base64url"),dp:z(qt(e[6].toBigInt()),"base64url"),dq:z(qt(e[7].toBigInt()),"base64url"),qi:z(qt(e[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Bh(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 ft({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 Ah(r){let{result:t}=gr(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:z(qt(e[0].toBigInt()),"base64url"),e:z(qt(e[1].toBigInt()),"base64url")}}function Sh(r){if(r.n==null||r.e==null)throw new U("JWK was missing components","ERR_INVALID_PARAMETERS");let e=new ft({value:[new ft({value:[new Vt({value:"1.2.840.113549.1.1.1"}),new Ne]}),new dr({valueHex:new ft({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 kh=16,Vo=32,Fo=1e4;async function Ih(r,t){let e=At.get(),s=new ft({value:[new ot({value:0}),new ft({value:[new Vt({value:"1.2.840.113549.1.1.1"}),new Ne]}),new ce({valueHex:r.marshal()})]}).toBER(),o=new Uint8Array(s,0,s.byteLength),i=Ke(kh),a=await Uo(or,t,i,{c:Fo,dkLen:Vo}),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 ft({value:[new ce({valueHex:i}),new ot({value:Fo}),new ot({value:Vo}),new ft({value:[new Vt({value:"1.2.840.113549.2.11"}),new Ne]})]}),h=new ft({value:[new Vt({value:"1.2.840.113549.1.5.13"}),new ft({value:[new ft({value:[new Vt({value:"1.2.840.113549.1.5.12"}),u]}),new ft({value:[new Vt({value:"2.16.840.1.101.3.4.1.42"}),new ce({valueHex:c})]})]})]}),g=new ft({value:[h,new ce({valueHex:f})]}).toBER(),d=new Uint8Array(g,0,g.byteLength);return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...z(d,"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join(`
|
|
7
|
+
`)}async function Rh(r,t){let e=At.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}=Nh(o),u=await Uo(or,t,a,{c,dkLen:l}),h=await e.subtle.importKey("raw",u,"AES-CBC",!1,["decrypt"]),m=Kr(await e.subtle.decrypt({name:"AES-CBC",iv:i},h,f)),{result:g}=gr(m);n=gc(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=gc(o)}else throw new U("Could not parse private key from PEM data","ERR_INVALID_PARAMETERS");return Ho(n)}function Nh(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=Kr(o.valueBlock.value[0].getValue()),a=Fo,c=Vo;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=Kr(l.valueBlock.value[1].getValue());return{cipherText:Kr(r.valueBlock.value[1].getValue()),salt:i,iterations:a,keySize:c,iv:u}}function gc(r){return Kr(r.valueBlock.value[2].getValue())}function Kr(r){return new Uint8Array(r,0,r.byteLength)}async function mc(r){let t=await At.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 wc(t);return{privateKey:e[0],publicKey:e[1]}}async function Mo(r){let e=[await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Th(r)],n=await wc({privateKey:e[0],publicKey:e[1]});return{privateKey:n[0],publicKey:n[1]}}async function yc(r,t){let e=await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await At.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function bc(r,t,e){let n=await At.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return At.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function wc(r){if(r.privateKey==null||r.publicKey==null)throw new U("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([At.get().subtle.exportKey("jwk",r.privateKey),At.get().subtle.exportKey("jwk",r.publicKey)])}async function Th(r){return At.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 is(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 qr=8192,$r=class{_key;constructor(t){this._key=t}verify(t,e){return bc(this._key,e,t)}marshal(){return Te.jwkToPkix(this._key)}get bytes(){return Se.encode({Type:gt.RSA,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.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 yc(this._key,t)}get public(){if(this._publicKey==null)throw new U("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new $r(this._publicKey)}marshal(){return Te.jwkToPkcs1(this._key)}get bytes(){return ke.encode({Type:gt.RSA,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Tt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return z(t,"base58btc")}async export(t,e="pkcs-8"){if(e==="pkcs-8")return Te.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 Ho(r){let t=Te.pkcs1ToJwk(r);if(is(t)>qr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let e=await Mo(t);return new mr(e.privateKey,e.publicKey)}function _h(r){let t=Te.pkixToJwk(r);if(is(t)>qr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new $r(t)}async function Uh(r){if(is(r)>qr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await Mo(r);return new mr(t.privateKey,t.publicKey)}async function Ch(r){if(r>qr)throw new U("key size is too large","ERR_KEY_SIZE_TOO_LARGE");let t=await mc(r);return new mr(t.privateKey,t.publicKey)}var jo={};lt(jo,{Secp256k1PrivateKey:()=>zr,Secp256k1PublicKey:()=>Gr,generateKeyPair:()=>Yh,unmarshalSecp256k1PrivateKey:()=>jh,unmarshalSecp256k1PublicKey:()=>Wh});var Dh=(r,t,e)=>r&t^~r&e,Ph=(r,t,e)=>r&t^r&e^t&e,Oh=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]),Le=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_e=new Uint32Array(64),$o=class extends sr{constructor(){super(64,32,8,!1),this.A=Le[0]|0,this.B=Le[1]|0,this.C=Le[2]|0,this.D=Le[3]|0,this.E=Le[4]|0,this.F=Le[5]|0,this.G=Le[6]|0,this.H=Le[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)_e[u]=t.getUint32(e,!1);for(let u=16;u<64;u++){let h=_e[u-15],m=_e[u-2],g=Ct(h,7)^Ct(h,18)^h>>>3,d=Ct(m,17)^Ct(m,19)^m>>>10;_e[u]=d+_e[u-7]+g+_e[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+Dh(a,c,l)+Oh[u]+_e[u]|0,d=(Ct(n,2)^Ct(n,13)^Ct(n,22))+Ph(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(){_e.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var xc=rn(()=>new $o);function Vh(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:Fh,hexToBytes:Hh}=on,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:Fh(n),l:r.subarray(e+2)}},toSig(r){let{Err:t}=qe,e=typeof r=="string"?Hh(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}`}},he=BigInt(0),_t=BigInt(1),wm=BigInt(2),vc=BigInt(3),xm=BigInt(4);function Mh(r){let t=Vh(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"&&he<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,vc),{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,vc),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===he)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>he||x>he;)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===he||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=ln(u,t.endo?Math.ceil(h/2):h);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:o,isWithinCurveOrder:i}}function Kh(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 Ec(r){let t=Kh(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return he<E&&E<e.ORDER}function a(E){return Y(E,n)}function c(E){return an(E,n)}let{ProjectivePoint:l,normPrivateKeyToScalar:f,weierstrassEquation:u,isWithinCurveOrder:h}=Mh({...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 ca(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(!(he<=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 ht=A(Q);if(!h(ht))return;let dt=c(ht),it=l.BASE.multiply(ht).toAffine(),yt=a(it.x);if(yt===he)return;let zt=a(dt*a($+yt*F));if(zt===he)return;let Ue=(it.x===yt?0:2)|Number(it.y&_t),Br=zt;return k&&g(zt)&&(Br=d(zt),Ue^=1),new y(yt,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:yt}=b;_=new y(it,yt)}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*$),ht=l.BASE.multiplyAndAddUnsafe(V,st,Q)?.toAffine();return ht?a(ht.x)===F:!1}return{CURVE:t,getPublicKey:w,getSharedSecret:x,sign:rt,verify:Nt,ProjectivePoint:l,Signature:y,utils:v}}function $h(r){return{hash:r,hmac:(t,...e)=>Ur(r,t,en(...e)),randomBytes:nr}}function Bc(r,t){let e=n=>Ec({...r,...$h(n)});return Object.freeze({...e(t),create:e})}var kc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Ac=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),qh=BigInt(1),qo=BigInt(2),Sc=(r,t)=>(r+t/qo)/t;function Gh(r){let t=kc,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,qo,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,qo,t);if(!Go.eql(Go.sqr(A),r))throw new Error("Cannot find square root");return A}var Go=cn(kc,void 0,void 0,{sqrt:Gh}),Ht=Bc({a:BigInt(0),b:BigInt(7),Fp:Go,n:Ac,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=Ac,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-qh*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),a=Sc(o*r,t),c=Sc(-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}}}},xc),Nm=BigInt(0);var Tm=Ht.ProjectivePoint;function Ic(){return Ht.utils.randomPrivateKey()}function Rc(r,t){let e=pt.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 Nc(r,t,e){let n=pt.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 Tc(r){return Ht.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Lc(r){try{Ht.getPublicKey(r,!0)}catch(t){throw new U(String(t),"ERR_INVALID_PRIVATE_KEY")}}function zo(r){try{Ht.ProjectivePoint.fromHex(r)}catch(t){throw new U(String(t),"ERR_INVALID_PUBLIC_KEY")}}function _c(r){try{return Ht.getPublicKey(r,!0)}catch(t){throw new U(String(t),"ERR_INVALID_PRIVATE_KEY")}}var Gr=class{_key;constructor(t){zo(t),this._key=t}verify(t,e){return Nc(this._key,e,t)}marshal(){return Tc(this._key)}get bytes(){return Se.encode({Type:gt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}async hash(){let t=pt.digest(this.bytes),e;return Tt(t)?{bytes:e}=await t:e=t.bytes,e}},zr=class{_key;_publicKey;constructor(t,e){this._key=t,this._publicKey=e??_c(t),Lc(this._key),zo(this._publicKey)}sign(t){return Rc(this._key,t)}get public(){return new Gr(this._publicKey)}marshal(){return this._key}get bytes(){return ke.encode({Type:gt.Secp256k1,Data:this.marshal()}).subarray()}equals(t){return bt(this.bytes,t.bytes)}hash(){let t=pt.digest(this.bytes);return Tt(t)?t.then(({bytes:e})=>e):t.bytes}async id(){let t=await this.public.hash();return z(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 jh(r){return new zr(r)}function Wh(r){return new Gr(r)}async function Yh(){let r=Ic();return new zr(r)}var Uc={rsa:Ko,ed25519:_o,secp256k1:jo};function Zh(r){let t=Object.keys(Uc).join(" / ");return new U(`invalid or unsupported key type ${r}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function Wo(r){if(r=r.toLowerCase(),r==="rsa"||r==="ed25519"||r==="secp256k1")return Uc[r];throw Zh(r)}async function Cc(r,t){return Wo(r).generateKeyPair(t??2048)}function Dc(r,t){return t=(t??"rsa").toLowerCase(),Wo(t),r.bytes}function Pc(r,t){return t=(t??"rsa").toLowerCase(),Wo(t),r.bytes}var Oc=async()=>{let r=await Cc("Ed25519"),t=await Jh(r);if(t.type==="Ed25519")return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function Jh(r){return Gi(Dc(r.public),Pc(r))}var as=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 Vc=45,Xh=15,yr=new as;function Yo(r){if(!(r.length>Xh))return yr.new(r).parseWith(()=>yr.readIPv4Addr())}function Zo(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Vc))return yr.new(r).parseWith(()=>yr.readIPv6Addr())}function cs(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Vc))return yr.new(r).parseWith(()=>yr.readIPAddr())}function ls(r){return!!Yo(r)}function us(r){return!!Zo(r)}function fs(r){return!!cs(r)}var Hc=Bs(Fc(),1),Qh=["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"],td=Qh.map(r=>new Hc.Netmask(r));function ed(r){for(let t of td)if(t.contains(r))return!0;return!1}function rd(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 Jo(r){return ls(r)?ed(r):us(r)?rd(r):void 0}var uy=parseInt("0xFFFF",16),fy=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);var $c=ls,ad=us,Xo=function(r){let t=0;if(r=r.toString().trim(),$c(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=$c(e[n]),i;o&&(i=Xo(e[n]),e[n]=z(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,z(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")},qc=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={},Qo={},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);Qo[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(Qo[r]!=null)return Qo[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 zy=W("ip4"),jy=W("ip6"),Wy=W("ipcidr");function ei(r,t){switch(W(r).code){case 4:case 41:return hd(t);case 42:return jc(t);case 6:case 273:case 33:case 132:return Yc(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return jc(t);case 421:return md(t);case 444:return Wc(t);case 445:return Wc(t);case 466:return gd(t);default:return z(t,"base16")}}function ri(r,t){switch(W(r).code){case 4:return Gc(t);case 41:return Gc(t);case 42:return zc(t);case 6:case 273:case 33:case 132:return ni(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return zc(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 ti=Object.values(me).map(r=>r.decoder),fd=function(){let r=ti[0].or(ti[1]);return ti.slice(2).forEach(t=>r=r.or(t)),r}();function Gc(r){if(!fs(r))throw new Error("invalid ip address");return Xo(r)}function hd(r){let t=qc(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!fs(t))throw new Error("invalid ip address");return t}function ni(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Yc(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function zc(r){let t=Z(r),e=Uint8Array.from(Be(t.length));return Bt([e,t],e.length+t.length)}function jc(r){let t=re(r);if(r=r.slice(ut(t)),r.length!==t)throw new Error("inconsistent lengths");return z(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(Be(t.length));return Bt([e,t],e.length+t.length)}function pd(r){let t=fd.decode(r),e=Uint8Array.from(Be(t.length));return Bt([e,t],e.length+t.length)}function gd(r){let t=re(r),e=r.slice(ut(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+z(e,"base64url")}function md(r){let t=re(r),e=r.slice(ut(t));if(e.length!==t)throw new Error("inconsistent lengths");return z(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=ni(n);return Bt([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=ni(n);return Bt([e,s],e.length+s.length)}function Wc(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=z(t,"base32"),s=Yc(e);return`${n}:${s}`}function Zc(r){r=si(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 Xc("invalid address: "+r);if(a.path===!0){n=si(s.slice(o).join("/")),t.push([a.code,ri(a.code,n)]),e.push([a.code,n]);break}let c=ri(a.code,s[o]);t.push([a.code,c]),e.push([a.code,ei(a.code,c)])}return{string:Jc(e),bytes:ii(t),tuples:t,stringTuples:e,path:n}}function oi(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=re(r,s),i=ut(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 Xc("Invalid address Uint8Array: "+z(r,"base16"));t.push([o,l]);let f=ei(o,l);if(e.push([o,f]),a.path===!0){n=f;break}}return{bytes:Uint8Array.from(r),string:Jc(e),tuples:t,stringTuples:e,path:n}}function Jc(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}),si(t.join("/"))}function ii(r){return Bt(r.map(t=>{let e=W(t[0]),n=Uint8Array.from(Be(e.code));return t.length>1&&t[1]!=null&&(n=Bt([n,t[1]])),n}))}function wd(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=re(t instanceof Uint8Array?t:Uint8Array.from(t));return e+ut(e)}}function si(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Xc(r){return new Error("Error parsing address: "+r)}var xd=Symbol.for("nodejs.util.inspect.custom"),ai=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;[ai]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=oi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Zc(t)}else if(tl(t))e=oi(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(ii(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"?z(at.decode(`z${n}`),"base58btc"):z(Ut.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(t){return bt(this.bytes,t.bytes)}async resolve(t){let e=this.protos().find(o=>o.resolvable);if(e==null)return[this];let n=Qc.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 Qc=new Map;function tl(r){return!!r?.[ai]}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 ci=Bd;var rl=Symbol.for("@achingbrain/uint8arraylist");function el(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?.[rl]}var wr=class r{bufs;length;[rl]=!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=el(this.bufs,t);return e.buf[e.index]}set(t,e){let n=el(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 Bt(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Bt(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=wt(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=wt(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(!bt(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=ut(r),e=wt(t);return Be(r,e),ms.bytes=t,e};ms.bytes=0;function Wr(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)}()}Wr.single=(r,t)=>{t=t??{};let e=t.lengthEncoder??ms;return new wr(e(r.byteLength),r)};var xr=Bs(ol(),1);var Sd=8,kd=1024*1024*4,Ge;(function(r){r[r.LENGTH=0]="LENGTH",r[r.DATA=1]="DATA"})(Ge||(Ge={}));var li=r=>{let t=re(r);return li.bytes=ut(t),t};li.bytes=0;function vr(r,t){let e=new wr,n=Ge.LENGTH,s=-1,o=t?.lengthDecoder??li,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 il=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=il(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 al=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*ui(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 fi=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 fi)},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 cl=Ud;function di(r,...t){if(r==null)throw new Error("Empty pipeline");if(hi(r)){let n=r;r=()=>n.source}else if(ul(r)||ll(r)){let n=r;r=()=>n}let e=[r,...t];if(e.length>1&&hi(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++)hi(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},ll=r=>r?.[Symbol.asyncIterator]!=null,ul=r=>r?.[Symbol.iterator]!=null,hi=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(ll(o))s=async function*(){yield*o,n.end()};else if(ul(o))s=function*(){yield*o,n.end()};else throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");return cl(n,s())}return r.source};var fl="libp2p",hl="autonat",dl="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=oe((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=>se(u,l.codec()),l.decode=u=>ne(u,l.codec())})(o=r.PeerInfo||(r.PeerInfo={}));let i;(function(l){let f;l.codec=()=>(f==null&&(f=oe((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=>se(u,l.codec()),l.decode=u=>ne(u,l.codec())})(i=r.Dial||(r.Dial={}));let a;(function(l){let f;l.codec=()=>(f==null&&(f=oe((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=>se(u,l.codec()),l.decode=u=>ne(u,l.codec())})(a=r.DialResponse||(r.DialResponse={}));let c;r.codec=()=>(c==null&&(c=oe((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=>se(l,r.codec()),r.decode=l=>ne(l,r.codec())})(D||(D={}));var pi=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??fl}/${hl}/${dl}`,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 di(t.stream,i=>vr(i),async function*(i){let a=await ci(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=Jr(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=!(Jo(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=>Wr(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!(Jo(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 Oc()).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 di([o],y=>Wr(y),g,y=>vr(y),async y=>ci(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 ui(al(this.components.peerRouting.getClosestPeers(a,{signal:n}),h=>async()=>f(h)),{concurrency:pi}))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===pi){this.log("%a is externally dialable",h),t.confirmObservedAddr(h);return}if(c[m].failure===pi){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 Il(Kd);})();
|
|
19
8
|
/*! Bundled license information:
|
|
20
9
|
|
|
21
10
|
pvtsutils/build/index.js:
|
package/dist/src/autonat.js
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 { 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
|
package/dist/src/autonat.js.map
CHANGED
|
@@ -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,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAA;AACxC,OAAO,GAAG,MAAM,QAAQ,CAAA;AACxB,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,WAAW,MAAM,YAAY,CAAA;AACpC,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,aAAa,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,OAAO,EAC3F,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAKvC,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AI,YAAY,CAAC,MAAM,KAAK,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;wBACvE,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAA;oBAC5B,CAAC;oBAED,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,yBAAyB,EAAE,CAAC;wBAC3D,uBAAuB;wBACvB,IAAI,CAAC,GAAG,CAAC,2BAA2B,EAAE,IAAI,CAAC,CAAA;wBAC3C,cAAc,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAA;wBACxC,OAAM;oBACR,CAAC;oBAED,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,KAAK,yBAAyB,EAAE,CAAC;wBAC3D,yBAAyB;wBACzB,IAAI,CAAC,GAAG,CAAC,+BAA+B,EAAE,IAAI,CAAC,CAAA;wBAC/C,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAA;wBACvC,OAAM;oBACR,CAAC;gBACH,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,mCAAmC,EAAE,GAAG,CAAC,CAAA;gBAC1D,CAAC;YACH,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,oBAAoB,GAAG,UAAU,CAAC,IAAI,CAAC,wBAAwB,EAAE,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.
|
|
3
|
+
"version": "1.0.10-0321812e7",
|
|
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,26 +51,26 @@
|
|
|
51
51
|
"dep-check": "aegir dep-check"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@libp2p/interface": "
|
|
55
|
-
"@libp2p/interface-internal": "
|
|
56
|
-
"@libp2p/peer-id": "
|
|
57
|
-
"@libp2p/peer-id-factory": "
|
|
58
|
-
"@
|
|
59
|
-
"
|
|
60
|
-
"it-
|
|
61
|
-
"it-
|
|
54
|
+
"@libp2p/interface": "1.1.2-0321812e7",
|
|
55
|
+
"@libp2p/interface-internal": "1.0.7-0321812e7",
|
|
56
|
+
"@libp2p/peer-id": "4.0.5-0321812e7",
|
|
57
|
+
"@libp2p/peer-id-factory": "4.0.5-0321812e7",
|
|
58
|
+
"@libp2p/utils": "5.2.3-0321812e7",
|
|
59
|
+
"@multiformats/multiaddr": "^12.1.14",
|
|
60
|
+
"it-first": "^3.0.4",
|
|
61
|
+
"it-length-prefixed": "^9.0.4",
|
|
62
|
+
"it-map": "^3.0.5",
|
|
62
63
|
"it-parallel": "^3.0.6",
|
|
63
64
|
"it-pipe": "^3.0.1",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"uint8arraylist": "^2.4.7"
|
|
65
|
+
"protons-runtime": "^5.4.0",
|
|
66
|
+
"uint8arraylist": "^2.4.8"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@libp2p/logger": "
|
|
70
|
-
"aegir": "^42.
|
|
71
|
-
"it-all": "^3.0.
|
|
72
|
-
"it-pushable": "^3.2.
|
|
73
|
-
"protons": "^7.
|
|
69
|
+
"@libp2p/logger": "4.0.5-0321812e7",
|
|
70
|
+
"aegir": "^42.2.3",
|
|
71
|
+
"it-all": "^3.0.4",
|
|
72
|
+
"it-pushable": "^3.2.3",
|
|
73
|
+
"protons": "^7.5.0",
|
|
74
74
|
"sinon": "^17.0.1",
|
|
75
75
|
"sinon-ts": "^2.0.0"
|
|
76
76
|
},
|
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,
|
package/dist/typedoc-urls.json
DELETED
|
@@ -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
|
-
}
|