@libp2p/identify 3.0.17-96f14e429 → 3.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,9 +1,9 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PIdentify = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PIdentify=(()=>{var wu=Object.create;var dn=Object.defineProperty;var xu=Object.getOwnPropertyDescriptor;var vu=Object.getOwnPropertyNames;var Eu=Object.getPrototypeOf,Bu=Object.prototype.hasOwnProperty;var oa=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),St=(r,t)=>{for(var e in t)dn(r,e,{get:t[e],enumerable:!0})},ia=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of vu(t))!Bu.call(r,s)&&s!==e&&dn(r,s,{get:()=>t[s],enumerable:!(n=xu(t,s))||n.enumerable});return r};var aa=(r,t,e)=>(e=r!=null?wu(Eu(r)):{},ia(t||!r||!r.__esModule?dn(e,"default",{value:r,enumerable:!0}):e,r)),Au=r=>ia(dn({},"__esModule",{value:!0}),r);var ac=oa(pr=>{"use strict";var jh="[object ArrayBuffer]",pe=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===jh}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 c=this.toUint8Array(i);s.set(c,o),o+=c.length}return t[t.length-1]instanceof Function?this.toView(s,t[t.length-1]):s.buffer}},fi="string",Zh=/^[0-9a-f\s]+$/i,Yh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Jh=/^[a-zA-Z0-9-_]+$/,Dn=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=pe.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return decodeURIComponent(escape(n))}},Vt=class{static toString(t,e=!1){let n=pe.toArrayBuffer(t),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let c=s.getUint16(i,e);o+=String.fromCharCode(c)}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}},Mn=class r{static isHex(t){return typeof t===fi&&Zh.test(t)}static isBase64(t){return typeof t===fi&&Yh.test(t)}static isBase64Url(t){return typeof t===fi&&Jh.test(t)}static ToString(t,e="utf8"){let n=pe.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 Vt.toString(n,!0);case"utf16":case"utf16be":return Vt.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 Vt.fromString(t,!0);case"utf16":case"utf16be":return Vt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=pe.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 Dn.fromString(t);case"utf16":case"utf16be":return Vt.fromString(t);case"utf16le":case"usc2":return Vt.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 Dn.toString(t);case"utf16":case"utf16be":return Vt.toString(t);case"utf16le":case"usc2":return Vt.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=pe.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=pe.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 Vt.toString(t,e)}static FromUtf16String(t,e=!1){return Vt.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,"")||""}};Mn.DEFAULT_UTF8_ENCODING="utf8";function Xh(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 Qh(...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 td(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}pr.BufferSourceConverter=pe;pr.Convert=Mn;pr.assign=Xh;pr.combine=Qh;pr.isEqual=td});var Ql=oa(ln=>{(function(){var r,t,e,n,s,o,i,c;c=function(a){var l,u,f,h;return l=(a&255<<24)>>>24,u=(a&255<<16)>>>16,f=(a&65280)>>>8,h=a&255,[l,u,f,h].join(".")},i=function(a){var l,u,f,h,m,p;for(l=[],f=h=0;h<=3&&a.length!==0;f=++h){if(f>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}p=t(a),m=p[0],u=p[1],a=a.substring(u),l.push(m)}if(a.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(a){return a.charCodeAt(0)},n=e("0"),o=e("a"),s=e("A"),t=function(a){var l,u,f,h,m;for(h=0,l=10,u="9",f=0,a.length>1&&a[f]==="0"&&(a[f+1]==="x"||a[f+1]==="X"?(f+=2,l=16):"0"<=a[f+1]&&a[f+1]<="9"&&(f++,l=8,u="7")),m=f;f<a.length;){if("0"<=a[f]&&a[f]<=u)h=h*l+(e(a[f])-n)>>>0;else if(l===16)if("a"<=a[f]&&a[f]<="f")h=h*l+(10+e(a[f])-o)>>>0;else if("A"<=a[f]&&a[f]<="F")h=h*l+(10+e(a[f])-s)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===m)throw new Error("empty octet");return[h,f]},r=function(){function a(l,u){var f,h,m,p;if(typeof l!="string")throw new Error("Missing `net' parameter");if(u||(p=l.split("/",2),l=p[0],u=p[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=i(u)}catch(b){throw f=b,new Error("Invalid mask: "+u)}for(h=m=32;m>=0;h=--m)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(u||u===0)this.bitmask=parseInt(u,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(b){throw f=b,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return a.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new a(l)),l instanceof a?this.contains(l.base)&&this.contains(l.broadcast||l.last):(i(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(l){return l==null&&(l=1),new a(c(this.netLong+this.size*l),this.mask)},a.prototype.forEach=function(l){var u,f,h;for(h=i(this.first),f=i(this.last),u=0;h<=f;)l(c(h),h,u),u++,h++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),ln.ip2long=i,ln.long2ip=c,ln.Netmask=r}).call(ln)});var p0={};St(p0,{identify:()=>h0,identifyPush:()=>d0});var eo=Symbol.for("@libp2p/peer-id");var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},rr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var pn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},mn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}},gn=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},Dt=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};var Me=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Tr=(r,...t)=>{try{[...t]}catch{}};var yn=Symbol.for("@libp2p/service-capabilities"),w0=Symbol.for("@libp2p/service-dependencies");var io={};St(io,{base58btc:()=>X,base58flickr:()=>Tu});var q0=new Uint8Array(0);function ca(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 ie(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 la(r){return new TextEncoder().encode(r)}function ua(r){return new TextDecoder().decode(r)}function Su(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 c=r.length,a=r.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(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 b=0,d=0,v=0,A=p.length;v!==A&&p[v]===0;)v++,b++;for(var y=(A-v)*u+1>>>0,I=new Uint8Array(y);v!==A;){for(var L=p[v],U=0,k=y-1;(L!==0||U<d)&&k!==-1;k--,U++)L+=256*I[k]>>>0,I[k]=L%c>>>0,L=L/c>>>0;if(L!==0)throw new Error("Non-zero carry");d=U,v++}for(var T=y-d;T!==y&&I[T]===0;)T++;for(var C=a.repeat(b);T<y;++T)C+=r.charAt(I[T]);return C}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var b=0;if(p[b]!==" "){for(var d=0,v=0;p[b]===a;)d++,b++;for(var A=(p.length-b)*l+1>>>0,y=new Uint8Array(A);p[b];){var I=e[p.charCodeAt(b)];if(I===255)return;for(var L=0,U=A-1;(I!==0||L<v)&&U!==-1;U--,L++)I+=c*y[U]>>>0,y[U]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=L,b++}if(p[b]!==" "){for(var k=A-v;k!==A&&y[k]===0;)k++;for(var T=new Uint8Array(d+(A-k)),C=d;k!==A;)T[C++]=y[k++];return T}}}function m(p){var b=h(p);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:m}}var Iu=Su,ku=Iu,ha=ku;var ro=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")}},no=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let s=e.codePointAt(0);if(s===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s,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 da(this,t)}},so=class{decoders;constructor(t){this.decoders=t}or(t){return da(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 da(r,t){return new so({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var oo=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 ro(t,e,n),this.decoder=new no(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function nr({name:r,prefix:t,encode:e,decode:n}){return new oo(r,t,e,n)}function Be({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=ha(e,r);return nr({prefix:t,name:r,encode:n,decode:o=>ie(s(o))})}function Cu(r,t,e,n){let s={};for(let u=0;u<t.length;++u)s[t[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*e/8|0),c=0,a=0,l=0;for(let u=0;u<o;++u){let f=s[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,i[l++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i}function Nu(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,o="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,o+=t[s&c>>i];if(i!==0&&(o+=t[s&c<<e-i]),n)for(;o.length*e&7;)o+="=";return o}function ot({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return nr({prefix:t,name:r,encode(s){return Nu(s,n,e)},decode(s){return Cu(s,n,e,r)}})}var X=Be({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Tu=Be({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ao={};St(ao,{base32:()=>ae,base32hex:()=>_u,base32hexpad:()=>Ou,base32hexpadupper:()=>Vu,base32hexupper:()=>Pu,base32pad:()=>Lu,base32padupper:()=>Ru,base32upper:()=>Uu,base32z:()=>Du});var ae=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Uu=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Lu=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ru=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_u=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pu=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ou=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vu=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Du=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var co={};St(co,{base36:()=>Ur,base36upper:()=>Mu});var Ur=Be({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Mu=Be({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fu=ga,pa=128,Hu=127,Ku=~Hu,qu=Math.pow(2,31);function ga(r,t,e){t=t||[],e=e||0;for(var n=e;r>=qu;)t[e++]=r&255|pa,r/=128;for(;r&Ku;)t[e++]=r&255|pa,r>>>=7;return t[e]=r|0,ga.bytes=e-n+1,t}var $u=lo,zu=128,ma=127;function lo(r,n){var e=0,n=n||0,s=0,o=n,i,c=r.length;do{if(o>=c)throw lo.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&ma)<<s:(i&ma)*Math.pow(2,s),s+=7}while(i>=zu);return lo.bytes=o-n,e}var Gu=Math.pow(2,7),Wu=Math.pow(2,14),ju=Math.pow(2,21),Zu=Math.pow(2,28),Yu=Math.pow(2,35),Ju=Math.pow(2,42),Xu=Math.pow(2,49),Qu=Math.pow(2,56),tf=Math.pow(2,63),ef=function(r){return r<Gu?1:r<Wu?2:r<ju?3:r<Zu?4:r<Yu?5:r<Ju?6:r<Xu?7:r<Qu?8:r<tf?9:10},rf={encode:Fu,decode:$u,encodingLength:ef},nf=rf,Lr=nf;function Rr(r,t=0){return[Lr.decode(r,t),Lr.decode.bytes]}function sr(r,t,e=0){return Lr.encode(r,t,e),t}function or(r){return Lr.encodingLength(r)}function Mt(r,t){let e=t.byteLength,n=or(r),s=n+or(e),o=new Uint8Array(s+e);return sr(r,o,0),sr(e,o,n),o.set(t,s),new ir(r,e,t,o)}function Fe(r){let t=ie(r),[e,n]=Rr(t),[s,o]=Rr(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new ir(e,s,i,t)}function ya(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&ca(r.bytes,e.bytes)}}var ir=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};function ba(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return of(e,uo(r),t??X.encoder);default:return af(e,uo(r),t??ae.encoder)}}var wa=new WeakMap;function uo(r){let t=wa.get(r);if(t==null){let e=new Map;return wa.set(r,e),e}return t}var dt=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!==_r)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==cf)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&&ya(t.multihash,n.multihash)}toString(t){return ba(this,t)}toJSON(){return{"/":ba(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??xa(n,s,o.bytes))}else if(e[lf]===!0){let{version:n,multihash:s,code:o}=e,i=Fe(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!==_r)throw new Error(`Version 0 CID must use dag-pb (code: ${_r}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=xa(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,_r,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=ie(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 ir(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[f,h]=Rr(t.subarray(e));return e+=h,f},s=n(),o=_r;if(s===18?(s=0,e=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=e,c=n(),a=n(),l=e+a,u=l-i;return{version:s,codec:o,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,e){let[n,s]=sf(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 uo(o).set(n,t),o}};function sf(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case ae.prefix:{let e=t??ae;return[ae.prefix,e.decode(r)]}case Ur.prefix:{let e=t??Ur;return[Ur.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function of(r,t,e){let{prefix:n}=e;if(n!==X.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 af(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 _r=112,cf=18;function xa(r,t,e){let n=or(r),s=n+or(t),o=new Uint8Array(s+e.byteLength);return sr(r,o,0),sr(t,o,n),o.set(e,s),o}var lf=Symbol.for("@ipld/js-cid/CID");var fo={};St(fo,{identity:()=>ce});var va=0,uf="identity",Ea=ie;function ff(r){return Mt(va,Ea(r))}var ce={code:va,name:uf,encode:Ea,digest:ff};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}function Ba(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function hf(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ar(r,...t){if(!hf(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Aa(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ba(r.outputLen),Ba(r.blockLen)}function cr(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 Sa(r,t){ar(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var He=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wn(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ft(r,t){return r<<32-t|r>>>t}function Ia(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Pr(r){return typeof r=="string"&&(r=Ia(r)),ar(r),r}function ho(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];ar(s),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 lr=class{clone(){return this._cloneInto()}};function xn(r){let t=n=>r().update(Pr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function vn(r=32){if(He&&typeof He.getRandomValues=="function")return He.getRandomValues(new Uint8Array(r));if(He&&typeof He.randomBytes=="function")return He.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function df(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),c=Number(e&o),a=n?4:0,l=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+l,c,n)}function ka(r,t,e){return r&t^~r&e}function Ca(r,t,e){return r&t^r&e^t&e}var ur=class extends lr{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=wn(this.buffer)}update(t){cr(this);let{view:e,buffer:n,blockLen:s}=this;t=Pr(t);let o=t.length;for(let i=0;i<o;){let c=Math.min(s-this.pos,o-i);if(c===s){let a=wn(t);for(;s<=o-i;i+=s)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){cr(this),Sa(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 f=i;f<s;f++)e[f]=0;df(n,s-8,BigInt(this.length*8),o),this.process(n,0);let c=wn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],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:c}=this;return t.length=s,t.pos=c,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var En=BigInt(4294967295),po=BigInt(32);function Na(r,t=!1){return t?{h:Number(r&En),l:Number(r>>po&En)}:{h:Number(r>>po&En)|0,l:Number(r&En)|0}}function pf(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}=Na(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var mf=(r,t)=>BigInt(r>>>0)<<po|BigInt(t>>>0),gf=(r,t,e)=>r>>>e,yf=(r,t,e)=>r<<32-e|t>>>e,bf=(r,t,e)=>r>>>e|t<<32-e,wf=(r,t,e)=>r<<32-e|t>>>e,xf=(r,t,e)=>r<<64-e|t>>>e-32,vf=(r,t,e)=>r>>>e-32|t<<64-e,Ef=(r,t)=>t,Bf=(r,t)=>r,Af=(r,t,e)=>r<<e|t>>>32-e,Sf=(r,t,e)=>t<<e|r>>>32-e,If=(r,t,e)=>t<<e-32|r>>>64-e,kf=(r,t,e)=>r<<e-32|t>>>64-e;function Cf(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var Nf=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Tf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Uf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),Lf=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,Rf=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),_f=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var Pf={fromBig:Na,split:pf,toBig:mf,shrSH:gf,shrSL:yf,rotrSH:bf,rotrSL:wf,rotrBH:xf,rotrBL:vf,rotr32H:Ef,rotr32L:Bf,rotlSH:Af,rotlSL:Sf,rotlBH:If,rotlBL:kf,add:Cf,add3L:Nf,add3H:Tf,add4L:Uf,add4H:Lf,add5H:_f,add5L:Rf},O=Pf;var[Of,Vf]=O.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))),Se=new Uint32Array(80),Ie=new Uint32Array(80),mo=class extends ur{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:c,Dl:a,Eh:l,El:u,Fh:f,Fl:h,Gh:m,Gl:p,Hh:b,Hl:d}=this;return[t,e,n,s,o,i,c,a,l,u,f,h,m,p,b,d]}set(t,e,n,s,o,i,c,a,l,u,f,h,m,p,b,d){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=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=m|0,this.Gl=p|0,this.Hh=b|0,this.Hl=d|0}process(t,e){for(let y=0;y<16;y++,e+=4)Se[y]=t.getUint32(e),Ie[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let I=Se[y-15]|0,L=Ie[y-15]|0,U=O.rotrSH(I,L,1)^O.rotrSH(I,L,8)^O.shrSH(I,L,7),k=O.rotrSL(I,L,1)^O.rotrSL(I,L,8)^O.shrSL(I,L,7),T=Se[y-2]|0,C=Ie[y-2]|0,tt=O.rotrSH(T,C,19)^O.rotrBH(T,C,61)^O.shrSH(T,C,6),q=O.rotrSL(T,C,19)^O.rotrBL(T,C,61)^O.shrSL(T,C,6),D=O.add4L(k,q,Ie[y-7],Ie[y-16]),it=O.add4H(D,U,tt,Se[y-7],Se[y-16]);Se[y]=it|0,Ie[y]=D|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:h,Fh:m,Fl:p,Gh:b,Gl:d,Hh:v,Hl:A}=this;for(let y=0;y<80;y++){let I=O.rotrSH(f,h,14)^O.rotrSH(f,h,18)^O.rotrBH(f,h,41),L=O.rotrSL(f,h,14)^O.rotrSL(f,h,18)^O.rotrBL(f,h,41),U=f&m^~f&b,k=h&p^~h&d,T=O.add5L(A,L,k,Vf[y],Ie[y]),C=O.add5H(T,v,I,U,Of[y],Se[y]),tt=T|0,q=O.rotrSH(n,s,28)^O.rotrBH(n,s,34)^O.rotrBH(n,s,39),D=O.rotrSL(n,s,28)^O.rotrBL(n,s,34)^O.rotrBL(n,s,39),it=n&o^n&c^o&c,E=s&i^s&a^i&a;v=b|0,A=d|0,b=m|0,d=p|0,m=f|0,p=h|0,{h:f,l:h}=O.add(l|0,u|0,C|0,tt|0),l=c|0,u=a|0,c=o|0,a=i|0,o=n|0,i=s|0;let N=O.add3L(tt,D,E);n=O.add3H(N,C,q,it),s=N|0}({h:n,l:s}=O.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=O.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=O.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=O.add(this.Eh|0,this.El|0,f|0,h|0),{h:m,l:p}=O.add(this.Fh|0,this.Fl|0,m|0,p|0),{h:b,l:d}=O.add(this.Gh|0,this.Gl|0,b|0,d|0),{h:v,l:A}=O.add(this.Hh|0,this.Hl|0,v|0,A|0),this.set(n,s,o,i,c,a,l,u,f,h,m,p,b,d,v,A)}roundClean(){Se.fill(0),Ie.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 Ta=xn(()=>new mo);var Sn={};St(Sn,{aInRange:()=>Nt,abool:()=>Ht,abytes:()=>fr,bitGet:()=>qf,bitLen:()=>wo,bitMask:()=>Vr,bitSet:()=>$f,bytesToHex:()=>ue,bytesToNumberBE:()=>fe,bytesToNumberLE:()=>Ce,concatBytes:()=>he,createHmacDrbg:()=>xo,ensureBytes:()=>nt,equalBytes:()=>Hf,hexToBytes:()=>qe,hexToNumber:()=>bo,inRange:()=>Or,isBytes:()=>ke,memoized:()=>ze,notImplemented:()=>Gf,numberToBytesBE:()=>Ne,numberToBytesLE:()=>$e,numberToHexUnpadded:()=>Ke,numberToVarBytesBE:()=>Ff,utf8ToBytes:()=>Kf,validateObject:()=>Xt});var Bn=BigInt(0),An=BigInt(1),Df=BigInt(2);function ke(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function fr(r){if(!ke(r))throw new Error("Uint8Array expected")}function Ht(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Mf=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function ue(r){fr(r);let t="";for(let e=0;e<r.length;e++)t+=Mf[r[e]];return t}function Ke(r){let t=r.toString(16);return t.length&1?"0"+t:t}function bo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Bn:BigInt("0x"+r)}var le={_0:48,_9:57,A:65,F:70,a:97,f:102};function Ua(r){if(r>=le._0&&r<=le._9)return r-le._0;if(r>=le.A&&r<=le.F)return r-(le.A-10);if(r>=le.a&&r<=le.f)return r-(le.a-10)}function qe(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("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=Ua(r.charCodeAt(o)),c=Ua(r.charCodeAt(o+1));if(i===void 0||c===void 0){let a=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}n[s]=i*16+c}return n}function fe(r){return bo(ue(r))}function Ce(r){return fr(r),bo(ue(Uint8Array.from(r).reverse()))}function Ne(r,t){return qe(r.toString(16).padStart(t*2,"0"))}function $e(r,t){return Ne(r,t).reverse()}function Ff(r){return qe(Ke(r))}function nt(r,t,e){let n;if(typeof t=="string")try{n=qe(t)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(ke(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+" of length "+e+" expected, got "+s);return n}function he(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];fr(s),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}function Hf(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("string expected");return new Uint8Array(new TextEncoder().encode(r))}var go=r=>typeof r=="bigint"&&Bn<=r;function Or(r,t,e){return go(r)&&go(t)&&go(e)&&t<=r&&r<e}function Nt(r,t,e,n){if(!Or(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function wo(r){let t;for(t=0;r>Bn;r>>=An,t+=1);return t}function qf(r,t){return r>>BigInt(t)&An}function $f(r,t,e){return r|(e?An:Bn)<<BigInt(t)}var Vr=r=>(Df<<BigInt(r-1))-An,yo=r=>new Uint8Array(r),La=r=>Uint8Array.from(r);function xo(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=yo(r),s=yo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},c=(...f)=>e(s,n,...f),a=(f=yo())=>{s=c(La([0]),f),n=c(),f.length!==0&&(s=c(La([1]),f),n=c())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<t;){n=c();let m=n.slice();h.push(m),f+=n.length}return he(...h)};return(f,h)=>{i(),a(f);let m;for(;!(m=h(l()));)a();return i(),m}}var zf={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"||ke(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 Xt(r,t,e={}){let n=(s,o,i)=>{let c=zf[o];if(typeof c!="function")throw new Error("invalid validator function");let a=r[s];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(s)+" is invalid. Expected "+o+", got "+a)};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 Gf=()=>{throw new Error("not implemented")};function ze(r){let t=new WeakMap;return(e,...n)=>{let s=t.get(e);if(s!==void 0)return s;let o=r(e,...n);return t.set(e,o),o}}var at=BigInt(0),et=BigInt(1),Ge=BigInt(2),Wf=BigInt(3),vo=BigInt(4),Ra=BigInt(5),_a=BigInt(8),jf=BigInt(9),Zf=BigInt(16);function Z(r,t){let e=r%t;return e>=at?e:t+e}function Yf(r,t,e){if(t<at)throw new Error("invalid exponent, negatives unsupported");if(e<=at)throw new Error("invalid modulus");if(e===et)return at;let n=et;for(;t>at;)t&et&&(n=n*r%e),r=r*r%e,t>>=et;return n}function rt(r,t,e){let n=r;for(;t-- >at;)n*=n,n%=e;return n}function In(r,t){if(r===at)throw new Error("invert: expected non-zero number");if(t<=at)throw new Error("invert: expected positive modulus, got "+t);let e=Z(r,t),n=t,s=at,o=et,i=et,c=at;for(;e!==at;){let l=n/e,u=n%e,f=s-i*l,h=o-c*l;n=e,e=u,s=i,o=c,i=f,c=h}if(n!==et)throw new Error("invert: does not exist");return Z(s,t)}function Jf(r){let t=(r-et)/Ge,e,n,s;for(e=r-et,n=0;e%Ge===at;e/=Ge,n++);for(s=Ge;s<r&&Yf(s,t,r)!==r-et;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+et)/vo;return function(a,l){let u=a.pow(l,i);if(!a.eql(a.sqr(u),l))throw new Error("Cannot find square root");return u}}let o=(e+et)/Ge;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,u=c.pow(c.mul(c.ONE,s),e),f=c.pow(a,o),h=c.pow(a,e);for(;!c.eql(h,c.ONE);){if(c.eql(h,c.ZERO))return c.ZERO;let m=1;for(let b=c.sqr(h);m<l&&!c.eql(b,c.ONE);m++)b=c.sqr(b);let p=c.pow(u,et<<BigInt(l-m-1));u=c.sqr(p),f=c.mul(f,p),h=c.mul(h,u),l=m}return f}}function Xf(r){if(r%vo===Wf){let t=(r+et)/vo;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%_a===Ra){let t=(r-Ra)/_a;return function(n,s){let o=n.mul(s,Ge),i=n.pow(o,t),c=n.mul(s,i),a=n.mul(n.mul(c,Ge),i),l=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%Zf,Jf(r)}var Pa=(r,t)=>(Z(r,t)&et)===et,Qf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Eo(r){let t={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},e=Qf.reduce((n,s)=>(n[s]="function",n),t);return Xt(r,e)}function th(r,t,e){if(e<at)throw new Error("invalid exponent, negatives unsupported");if(e===at)return r.ONE;if(e===et)return t;let n=r.ONE,s=t;for(;e>at;)e&et&&(n=r.mul(n,s)),s=r.sqr(s),e>>=et;return n}function eh(r,t){let e=new Array(t.length),n=t.reduce((o,i,c)=>r.is0(i)?o:(e[c]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return t.reduceRight((o,i,c)=>r.is0(i)?o:(e[c]=r.mul(o,e[c]),r.mul(o,i)),s),e}function Bo(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Te(r,t,e=!1,n={}){if(r<=at)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:s,nByteLength:o}=Bo(r,t);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:s,BYTES:o,MASK:Vr(s),ZERO:at,ONE:et,create:a=>Z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return at<=a&&a<r},is0:a=>a===at,isOdd:a=>(a&et)===et,neg:a=>Z(-a,r),eql:(a,l)=>a===l,sqr:a=>Z(a*a,r),add:(a,l)=>Z(a+l,r),sub:(a,l)=>Z(a-l,r),mul:(a,l)=>Z(a*l,r),pow:(a,l)=>th(c,a,l),div:(a,l)=>Z(a*In(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>In(a,r),sqrt:n.sqrt||(a=>(i||(i=Xf(r)),i(c,a))),invertBatch:a=>eh(c,a),cmov:(a,l,u)=>u?l:a,toBytes:a=>e?$e(a,o):Ne(a,o),fromBytes:a=>{if(a.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+a.length);return e?Ce(a):fe(a)}});return Object.freeze(c)}function Oa(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let t=r.toString(2).length;return Math.ceil(t/8)}function Ao(r){let t=Oa(r);return t+Math.ceil(t/2)}function Va(r,t,e=!1){let n=r.length,s=Oa(t),o=Ao(t);if(n<16||n<o||n>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+n);let i=e?Ce(r):fe(r),c=Z(i,t-et)+et;return e?$e(c,s):Ne(c,s)}var Da=BigInt(0),kn=BigInt(1);function So(r,t){let e=t.negate();return r?e:t}function Ma(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function Io(r,t){Ma(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function rh(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function nh(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var ko=new WeakMap,Fa=new WeakMap;function Co(r){return Fa.get(r)||1}function Cn(r,t){return{constTimeNegate:So,hasPrecomputes(e){return Co(e)!==1},unsafeLadder(e,n,s=r.ZERO){let o=e;for(;n>Da;)n&kn&&(s=s.add(o)),o=o.double(),n>>=kn;return s},precomputeWindow(e,n){let{windows:s,windowSize:o}=Io(n,t),i=[],c=e,a=c;for(let l=0;l<s;l++){a=c,i.push(a);for(let u=1;u<o;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,s){let{windows:o,windowSize:i}=Io(e,t),c=r.ZERO,a=r.BASE,l=BigInt(2**e-1),u=2**e,f=BigInt(e);for(let h=0;h<o;h++){let m=h*i,p=Number(s&l);s>>=f,p>i&&(p-=u,s+=kn);let b=m,d=m+Math.abs(p)-1,v=h%2!==0,A=p<0;p===0?a=a.add(So(v,n[b])):c=c.add(So(A,n[d]))}return{p:c,f:a}},wNAFUnsafe(e,n,s,o=r.ZERO){let{windows:i,windowSize:c}=Io(e,t),a=BigInt(2**e-1),l=2**e,u=BigInt(e);for(let f=0;f<i;f++){let h=f*c;if(s===Da)break;let m=Number(s&a);if(s>>=u,m>c&&(m-=l,s+=kn),m===0)continue;let p=n[h+Math.abs(m)-1];m<0&&(p=p.negate()),o=o.add(p)}return o},getPrecomputes(e,n,s){let o=ko.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&ko.set(n,s(o))),o},wNAFCached(e,n,s){let o=Co(e);return this.wNAF(o,this.getPrecomputes(o,e,s),n)},wNAFCachedUnsafe(e,n,s,o){let i=Co(e);return i===1?this.unsafeLadder(e,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,s),n,o)},setWindowSize(e,n){Ma(n,t),Fa.set(e,n),ko.delete(e)}}}function Nn(r,t,e,n){if(rh(e,r),nh(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,o=wo(BigInt(e.length)),i=o>12?o-3:o>4?o-2:o?2:1,c=(1<<i)-1,a=new Array(c+1).fill(s),l=Math.floor((t.BITS-1)/i)*i,u=s;for(let f=l;f>=0;f-=i){a.fill(s);for(let m=0;m<n.length;m++){let p=n[m],b=Number(p>>BigInt(f)&BigInt(c));a[b]=a[b].add(e[m])}let h=s;for(let m=a.length-1,p=s;m>0;m--)p=p.add(a[m]),h=h.add(p);if(u=u.add(h),f!==0)for(let m=0;m<i;m++)u=u.double()}return u}function Dr(r){return Eo(r.Fp),Xt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Bo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Kt=BigInt(0),Tt=BigInt(1),Tn=BigInt(2),sh=BigInt(8),oh={zip215:!0};function ih(r){let t=Dr(r);return Xt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Ha(r){let t=ih(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:c,h:a}=t,l=Tn<<BigInt(c*8)-Tt,u=e.create,f=Te(t.n,t.nBitLength),h=t.uvRatio||((w,g)=>{try{return{isValid:!0,value:e.sqrt(w*e.inv(g))}}catch{return{isValid:!1,value:Kt}}}),m=t.adjustScalarBytes||(w=>w),p=t.domain||((w,g,x)=>{if(Ht("phflag",x),g.length||x)throw new Error("Contexts/pre-hash are not supported");return w});function b(w,g){Nt("coordinate "+w,g,Kt,l)}function d(w){if(!(w instanceof y))throw new Error("ExtendedPoint expected")}let v=ze((w,g)=>{let{ex:x,ey:S,ez:R}=w,_=w.is0();g==null&&(g=_?sh:e.inv(R));let V=u(x*g),F=u(S*g),P=u(R*g);if(_)return{x:Kt,y:Tt};if(P!==Tt)throw new Error("invZ was invalid");return{x:V,y:F}}),A=ze(w=>{let{a:g,d:x}=t;if(w.is0())throw new Error("bad point: ZERO");let{ex:S,ey:R,ez:_,et:V}=w,F=u(S*S),P=u(R*R),j=u(_*_),J=u(j*j),lt=u(F*g),ut=u(j*u(lt+P)),ht=u(J+u(x*u(F*P)));if(ut!==ht)throw new Error("bad point: equation left != right (1)");let yt=u(S*R),Ct=u(_*V);if(yt!==Ct)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(g,x,S,R){this.ex=g,this.ey=x,this.ez=S,this.et=R,b("x",g),b("y",x),b("z",S),b("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof y)throw new Error("extended point not allowed");let{x,y:S}=g||{};return b("x",x),b("y",S),new y(x,S,Tt,u(x*S))}static normalizeZ(g){let x=e.invertBatch(g.map(S=>S.ez));return g.map((S,R)=>S.toAffine(x[R])).map(y.fromAffine)}static msm(g,x){return Nn(y,f,g,x)}_setWindowSize(g){U.setWindowSize(this,g)}assertValidity(){A(this)}equals(g){d(g);let{ex:x,ey:S,ez:R}=this,{ex:_,ey:V,ez:F}=g,P=u(x*F),j=u(_*R),J=u(S*F),lt=u(V*R);return P===j&&J===lt}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=t,{ex:x,ey:S,ez:R}=this,_=u(x*x),V=u(S*S),F=u(Tn*u(R*R)),P=u(g*_),j=x+S,J=u(u(j*j)-_-V),lt=P+V,ut=lt-F,ht=P-V,yt=u(J*ut),Ct=u(lt*ht),At=u(J*ht),Jt=u(ut*lt);return new y(yt,Ct,Jt,At)}add(g){d(g);let{a:x,d:S}=t,{ex:R,ey:_,ez:V,et:F}=this,{ex:P,ey:j,ez:J,et:lt}=g;if(x===BigInt(-1)){let Xi=u((_-R)*(j+P)),Qi=u((_+R)*(j-P)),to=u(Qi-Xi);if(to===Kt)return this.double();let ta=u(V*Tn*lt),ea=u(F*Tn*J),ra=ea+ta,na=Qi+Xi,sa=ea-ta,mu=u(ra*to),gu=u(na*sa),yu=u(ra*sa),bu=u(to*na);return new y(mu,gu,bu,yu)}let ut=u(R*P),ht=u(_*j),yt=u(F*S*lt),Ct=u(V*J),At=u((R+_)*(P+j)-ut-ht),Jt=Ct-yt,oe=Ct+yt,Nr=u(ht-x*ut),fu=u(At*Jt),hu=u(oe*Nr),du=u(At*Nr),pu=u(Jt*oe);return new y(fu,hu,pu,du)}subtract(g){return this.add(g.negate())}wNAF(g){return U.wNAFCached(this,g,y.normalizeZ)}multiply(g){let x=g;Nt("scalar",x,Tt,n);let{p:S,f:R}=this.wNAF(x);return y.normalizeZ([S,R])[0]}multiplyUnsafe(g,x=y.ZERO){let S=g;return Nt("scalar",S,Kt,n),S===Kt?L:this.is0()||S===Tt?this:U.wNAFCachedUnsafe(this,S,y.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(g){return v(this,g)}clearCofactor(){let{h:g}=t;return g===Tt?this:this.multiplyUnsafe(g)}static fromHex(g,x=!1){let{d:S,a:R}=t,_=e.BYTES;g=nt("pointHex",g,_),Ht("zip215",x);let V=g.slice(),F=g[_-1];V[_-1]=F&-129;let P=Ce(V),j=x?l:e.ORDER;Nt("pointHex.y",P,Kt,j);let J=u(P*P),lt=u(J-Tt),ut=u(S*J-R),{isValid:ht,value:yt}=h(lt,ut);if(!ht)throw new Error("Point.fromHex: invalid y coordinate");let Ct=(yt&Tt)===Tt,At=(F&128)!==0;if(!x&&yt===Kt&&At)throw new Error("Point.fromHex: x=0 and x_0=1");return At!==Ct&&(yt=u(-yt)),y.fromAffine({x:yt,y:P})}static fromPrivateKey(g){return C(g).point}toRawBytes(){let{x:g,y:x}=this.toAffine(),S=$e(x,e.BYTES);return S[S.length-1]|=g&Tt?128:0,S}toHex(){return ue(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Tt,u(t.Gx*t.Gy)),y.ZERO=new y(Kt,Tt,Tt,Kt);let{BASE:I,ZERO:L}=y,U=Cn(y,c*8);function k(w){return Z(w,n)}function T(w){return k(Ce(w))}function C(w){let g=e.BYTES;w=nt("private key",w,g);let x=nt("hashed private key",o(w),2*g),S=m(x.slice(0,g)),R=x.slice(g,2*g),_=T(S),V=I.multiply(_),F=V.toRawBytes();return{head:S,prefix:R,scalar:_,point:V,pointBytes:F}}function tt(w){return C(w).pointBytes}function q(w=new Uint8Array,...g){let x=he(...g);return T(o(p(x,nt("context",w),!!s)))}function D(w,g,x={}){w=nt("message",w),s&&(w=s(w));let{prefix:S,scalar:R,pointBytes:_}=C(g),V=q(x.context,S,w),F=I.multiply(V).toRawBytes(),P=q(x.context,F,_,w),j=k(V+P*R);Nt("signature.s",j,Kt,n);let J=he(F,$e(j,e.BYTES));return nt("result",J,e.BYTES*2)}let it=oh;function E(w,g,x,S=it){let{context:R,zip215:_}=S,V=e.BYTES;w=nt("signature",w,2*V),g=nt("message",g),x=nt("publicKey",x,V),_!==void 0&&Ht("zip215",_),s&&(g=s(g));let F=Ce(w.slice(V,2*V)),P,j,J;try{P=y.fromHex(x,_),j=y.fromHex(w.slice(0,V),_),J=I.multiplyUnsafe(F)}catch{return!1}if(!_&&P.isSmallOrder())return!1;let lt=q(R,j.toRawBytes(),P.toRawBytes(),g);return j.add(P.multiplyUnsafe(lt)).subtract(J).clearCofactor().equals(y.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:tt,sign:D,verify:E,ExtendedPoint:y,utils:{getExtendedPublicKey:C,randomPrivateKey:()=>i(e.BYTES),precompute(w=8,g=y.BASE){return g._setWindowSize(w),g.multiply(BigInt(3)),g}}}}var No=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ka=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Pp=BigInt(0),ah=BigInt(1),qa=BigInt(2),Op=BigInt(3),ch=BigInt(5),lh=BigInt(8);function uh(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),s=BigInt(80),o=No,c=r*r%o*r%o,a=rt(c,qa,o)*c%o,l=rt(a,ah,o)*r%o,u=rt(l,ch,o)*l%o,f=rt(u,t,o)*u%o,h=rt(f,e,o)*f%o,m=rt(h,n,o)*h%o,p=rt(m,s,o)*m%o,b=rt(p,s,o)*m%o,d=rt(b,t,o)*u%o;return{pow_p_5_8:rt(d,qa,o)*r%o,b2:c}}function fh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function hh(r,t){let e=No,n=Z(t*t*t,e),s=Z(n*n*t,e),o=uh(r*s).pow_p_5_8,i=Z(r*n*o,e),c=Z(t*i*i,e),a=i,l=Z(i*Ka,e),u=c===r,f=c===Z(-r,e),h=c===Z(-r*Ka,e);return u&&(i=a),(f||h)&&(i=l),Pa(i,e)&&(i=Z(-i,e)),{isValid:u||f,value:i}}var dh=Te(No,void 0,!0),ph={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:dh,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:lh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ta,randomBytes:vn,adjustScalarBytes:fh,uvRatio:hh},$a=Ha(ph);var Un=32;function za(r,t,e){return $a.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Ln=class{type="Ed25519";raw;constructor(t){this.raw=To(t,Un)}toMultihash(){return ce.digest(Ue(this))}toCID(){return dt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return za(this.raw,e,t)}};function Uo(r){return r=To(r,Un),new Ln(r)}function To(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new It(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function pt(r=0){return new Uint8Array(r)}function Ut(r=0){return new Uint8Array(r)}var gh=Math.pow(2,7),yh=Math.pow(2,14),bh=Math.pow(2,21),Lo=Math.pow(2,28),Ro=Math.pow(2,35),_o=Math.pow(2,42),Po=Math.pow(2,49),W=128,wt=127;function xt(r){if(r<gh)return 1;if(r<yh)return 2;if(r<bh)return 3;if(r<Lo)return 4;if(r<Ro)return 5;if(r<_o)return 6;if(r<Po)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Oo(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|W,r/=128;case 7:t[e++]=r&255|W,r/=128;case 6:t[e++]=r&255|W,r/=128;case 5:t[e++]=r&255|W,r/=128;case 4:t[e++]=r&255|W,r>>>=7;case 3:t[e++]=r&255|W,r>>>=7;case 2:t[e++]=r&255|W,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function wh(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|W),r/=128;case 7:t.set(e++,r&255|W),r/=128;case 6:t.set(e++,r&255|W),r/=128;case 5:t.set(e++,r&255|W),r/=128;case 4:t.set(e++,r&255|W),r>>>=7;case 3:t.set(e++,r&255|W),r>>>=7;case 2:t.set(e++,r&255|W),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Vo(r,t){let e=r[t],n=0;if(n+=e&wt,e<W||(e=r[t+1],n+=(e&wt)<<7,e<W)||(e=r[t+2],n+=(e&wt)<<14,e<W)||(e=r[t+3],n+=(e&wt)<<21,e<W)||(e=r[t+4],n+=(e&wt)*Lo,e<W)||(e=r[t+5],n+=(e&wt)*Ro,e<W)||(e=r[t+6],n+=(e&wt)*_o,e<W)||(e=r[t+7],n+=(e&wt)*Po,e<W))return n;throw new RangeError("Could not decode varint")}function xh(r,t){let e=r.get(t),n=0;if(n+=e&wt,e<W||(e=r.get(t+1),n+=(e&wt)<<7,e<W)||(e=r.get(t+2),n+=(e&wt)<<14,e<W)||(e=r.get(t+3),n+=(e&wt)<<21,e<W)||(e=r.get(t+4),n+=(e&wt)*Lo,e<W)||(e=r.get(t+5),n+=(e&wt)*Ro,e<W)||(e=r.get(t+6),n+=(e&wt)*_o,e<W)||(e=r.get(t+7),n+=(e&wt)*Po,e<W))return n;throw new RangeError("Could not decode varint")}function Ot(r,t,e=0){return t==null&&(t=Ut(xt(r))),t instanceof Uint8Array?Oo(r,t,e):wh(r,t,e)}function de(r,t=0){return r instanceof Uint8Array?Vo(r,t):xh(r,t)}var Do=new Float32Array([-0]),Le=new Uint8Array(Do.buffer);function Wa(r,t,e){Do[0]=r,t[e]=Le[0],t[e+1]=Le[1],t[e+2]=Le[2],t[e+3]=Le[3]}function ja(r,t){return Le[0]=r[t],Le[1]=r[t+1],Le[2]=r[t+2],Le[3]=r[t+3],Do[0]}var Mo=new Float64Array([-0]),vt=new Uint8Array(Mo.buffer);function Za(r,t,e){Mo[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 Ya(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],Mo[0]}var vh=BigInt(Number.MAX_SAFE_INTEGER),Eh=BigInt(Number.MIN_SAFE_INTEGER),_t=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 We;if(t<vh&&t>Eh)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>Ja&&(s=0n,++n>Ja&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return We;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):We}},We=new _t(0,0);We.toBigInt=function(){return 0n};We.zzEncode=We.zzDecode=function(){return this};We.length=function(){return 1};var Ja=4294967296n;function Xa(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 Qa(r,t,e){if(e-t<1)return"";let s,o=[],i=0,c;for(;t<e;)c=r[t++],c<128?o[i++]=c:c>191&&c<224?o[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[i++]=55296+(c>>10),o[i++]=56320+(c&1023)):o[i++]=(c&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 Fo(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 qt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function _n(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var Ho=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,qt(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 qt(this,4);return _n(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return _n(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=ja(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=Ya(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 qt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return Qa(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(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 _t(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 qt(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 qt(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 qt(this,8);let t=_n(this.buf,this.pos+=4),e=_n(this.buf,this.pos+=4);return new _t(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=Vo(this.buf,this.pos);return this.pos+=xt(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 Ko(r){return new Ho(r instanceof Uint8Array?r:r.subarray())}function $t(r,t,e){let n=Ko(r);return t.decode(n,void 0,e)}var qo={};St(qo,{base10:()=>Bh});var Bh=Be({prefix:"9",name:"base10",alphabet:"0123456789"});var $o={};St($o,{base16:()=>Ah,base16upper:()=>Sh});var Ah=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sh=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var zo={};St(zo,{base2:()=>Ih});var Ih=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Go={};St(Go,{base256emoji:()=>Uh});var ec=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}"),kh=ec.reduce((r,t,e)=>(r[e]=t,r),[]),Ch=ec.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Nh(r){return r.reduce((t,e)=>(t+=kh[e],t),"")}function Th(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let s=Ch[n];if(s==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(s)}return new Uint8Array(t)}var Uh=nr({prefix:"\u{1F680}",name:"base256emoji",encode:Nh,decode:Th});var jo={};St(jo,{base64:()=>Lh,base64pad:()=>Rh,base64url:()=>Wo,base64urlpad:()=>_h});var Lh=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Rh=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Wo=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_h=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Zo={};St(Zo,{base8:()=>Ph});var Ph=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Yo={};St(Yo,{identity:()=>Oh});var Oh=nr({prefix:"\0",name:"identity",encode:r=>ua(r),decode:r=>la(r)});var bm=new TextEncoder,wm=new TextDecoder;var Qo={};St(Qo,{sha256:()=>Mr,sha512:()=>Mh});function Xo({name:r,code:t,encode:e}){return new Jo(r,t,e)}var Jo=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 nc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Mr=Xo({name:"sha2-256",code:18,encode:nc("SHA-256")}),Mh=Xo({name:"sha2-512",code:19,encode:nc("SHA-512")});var Fr={...Yo,...zo,...Zo,...qo,...$o,...ao,...co,...io,...jo,...Go},Um={...Qo,...fo};function oc(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var sc=oc("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ti=oc("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=Ut(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Fh={utf8:sc,"utf-8":sc,hex:Fr.base16,latin1:ti,ascii:ti,binary:ti,...Fr},Pn=Fh;function $(r,t="utf8"){let e=Pn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function ei(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return Ut(i);s+i>t&&(n=Ut(t),s=0);let c=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),c}}var je=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function ri(){}var si=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Hh=ei();function Kh(r){return globalThis.Buffer!=null?Ut(r):Hh(r)}var Kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new je(ri,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new je(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new oi((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(On,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=_t.fromBigInt(t);return this._push(On,e.length(),e)}uint64Number(t){return this._push(Oo,xt(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=_t.fromBigInt(t).zzEncode();return this._push(On,e.length(),e)}sint64Number(t){let e=_t.fromNumber(t).zzEncode();return this._push(On,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(ni,1,t?1:0)}fixed32(t){return this._push(Hr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=_t.fromBigInt(t);return this._push(Hr,4,e.lo)._push(Hr,4,e.hi)}fixed64Number(t){let e=_t.fromNumber(t);return this._push(Hr,4,e.lo)._push(Hr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(Wa,4,t)}double(t){return this._push(Za,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(ni,1,0):this.uint32(e)._push($h,e,t)}string(t){let e=Xa(t);return e!==0?this.uint32(e)._push(Fo,e,t):this._push(ni,1,0)}fork(){return this.states=new si(this),this.head=this.tail=new je(ri,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 je(ri,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=Kh(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function ni(r,t,e){t[e]=r&255}function qh(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var oi=class extends je{next;constructor(t,e){super(qh,t,e),this.next=void 0}};function On(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Hr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function $h(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Kr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(zh,t,r),this},Kr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(Gh,t,r),this});function zh(r,t,e){t.set(r,e)}function Gh(r,t,e){r.length<40?Fo(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($(r),e)}function ii(){return new Kr}function zt(r,t){let e=ii();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 ai(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(o,i){let c=t(o);i.int32(c)},n=function(o){let i=o.int32();return t(i)};return Vn("enum",hr.VARINT,e,n)}function Gt(r,t){return Vn("message",hr.LENGTH_DELIMITED,r,t)}var Ze=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var ct;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ct||(ct={}));var ci;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(ci||(ci={}));(function(r){r.codec=()=>ai(ci)})(ct||(ct={}));var Qt;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ct.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{o.Type=ct.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(Qt||(Qt={}));var li;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ct.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{o.Type=ct.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(li||(li={}));var Xr={};St(Xr,{MAX_RSA_KEY_SIZE:()=>Cs,generateRSAKeyPair:()=>rl,jwkToJWKKeyPair:()=>nl,jwkToPkcs1:()=>cd,jwkToPkix:()=>bi,jwkToRSAPrivateKey:()=>el,pkcs1ToJwk:()=>Xc,pkcs1ToRSAPrivateKey:()=>tl,pkixToJwk:()=>Qc,pkixToRSAPublicKey:()=>wi});var Wh=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]),Re=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_e=new Uint32Array(64),ui=class extends ur{constructor(){super(64,32,8,!1),this.A=Re[0]|0,this.B=Re[1]|0,this.C=Re[2]|0,this.D=Re[3]|0,this.E=Re[4]|0,this.F=Re[5]|0,this.G=Re[6]|0,this.H=Re[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:c,H:a}=this;return[t,e,n,s,o,i,c,a]}set(t,e,n,s,o,i,c,a){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=c|0,this.H=a|0}process(t,e){for(let f=0;f<16;f++,e+=4)_e[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=_e[f-15],m=_e[f-2],p=Ft(h,7)^Ft(h,18)^h>>>3,b=Ft(m,17)^Ft(m,19)^m>>>10;_e[f]=b+_e[f-7]+p+_e[f-16]|0}let{A:n,B:s,C:o,D:i,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let h=Ft(c,6)^Ft(c,11)^Ft(c,25),m=u+h+ka(c,a,l)+Wh[f]+_e[f]|0,b=(Ft(n,2)^Ft(n,13)^Ft(n,22))+Ca(n,s,o)|0;u=l,l=a,a=c,c=i+m|0,i=o,o=s,s=n,n=m+b|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,o,i,c,a,l,u)}roundClean(){_e.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var dr=xn(()=>new ui);var M=aa(ac());function Ye(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 Pe(r,t,e=-1){let n=e,s=r,o=0,i=Math.pow(2,t);for(let c=1;c<8;c++){if(r<i){let a;if(n<0)a=new ArrayBuffer(c),o=c;else{if(n<c)return new ArrayBuffer(0);a=new ArrayBuffer(n),o=n}let l=new Uint8Array(a);for(let u=c-1;u>=0;u--){let f=Math.pow(2,u*t);l[o-u-1]=Math.floor(s/f),s-=l[o-u-1]*f}return a}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function Fn(...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 hi(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let c=r[0]===255&&r[1]&128,a=r[0]===0&&(r[1]&128)===0;(c||a)&&this.warnings.push("Needlessly long format")}let t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let c=0;c<this.valueHex.byteLength;c++)e[c]=0;e[0]=r[0]&128;let n=Ye(e,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let c=0;c<this.valueHex.byteLength;c++)o[c]=r[c];return o[0]&=127,Ye(o,8)-n}function cc(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,c=Pe(i,8,n),a=new Uint8Array(c);return a[0]|=128,c}let s=Pe(t,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),c=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let a=0;a<i.byteLength;a++)o[a+1]=c[a];o[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function lc(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 Lt(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 hg=Math.log(2);function Hn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function di(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 be(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 $r=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return di(this.items)}},qr=[new Uint8Array([1])],uc="0123456789";var br="",Wt=new ArrayBuffer(0),pi=new Uint8Array(0),zr="EndOfContent",hc="OCTET STRING",dc="BIT STRING";function we(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?M.BufferSourceConverter.toUint8Array(o.valueHex):pi}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(!be(this,i,s,o))return-1;let c=s+o;return this.valueHexView=i.subarray(s,c),this.valueHexView.length?(this.blockLength=o,c):(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",Wt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var me=class{constructor({blockLength:t=0,error:e=br,warnings:n=[],valueBeforeDecode:s=pi}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=M.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:M.Convert.ToHex(this.valueBeforeDecodeView)}}};me.NAME="baseBlock";var Et=class extends me{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 Kn=class extends we(me){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?M.BufferSourceConverter.toUint8Array(t.valueHex):pi,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",Wt}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=Pe(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,c=new Uint8Array(i+1);if(c[0]=e|31,!t){for(let a=0;a<i-1;a++)c[a+1]=o[a]|128;c[i]=o[i-1]}return c.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=M.BufferSourceConverter.toUint8Array(t);if(!be(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 c=o[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let a=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;o[a]&128;){if(l[a-1]=o[a]&127,a++,a>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(a===u){u+=255;let h=new Uint8Array(u);for(let m=0;m<l.length;m++)h[m]=l[m];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=a+1,l[a-1]=o[a]&127;let f=new Uint8Array(a);for(let h=0;h<a;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(a),l.set(f),this.blockLength<=9?this.tagNumber=Ye(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 qn=class extends me{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=M.BufferSourceConverter.toUint8Array(t);if(!be(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 c=e+1,a=s.subarray(c,c+i);return a[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ye(a,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=Pe(this.length,8);if(s.byteLength>127)return this.error="Too big length",Wt;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}}};qn.NAME="lengthBlock";var B={},mt=class extends me{constructor({name:t=br,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 qn(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 $r;e||pc(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?Wt: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():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.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 lc(e,n)}};mt.NAME="BaseBlock";function pc(r){if(r instanceof B.Constructed)for(let t of r.valueBlock.value)pc(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var $n=class extends mt{constructor({value:t=br,...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}'`}};$n.NAME="BaseStringBlock";var zn=class extends we(Et){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};zn.NAME="PrimitiveValueBlock";var mc,Gn=class extends mt{constructor(t={}){super(t,zn),this.idBlock.isConstructed=!1}};mc=Gn;B.Primitive=mc;Gn.NAME="PRIMITIVE";function rd(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 Is(r,t=0,e=r.length){let n=t,s=new mt({},Et),o=new me;if(!be(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 c=s.idBlock.fromBER(r,t,e);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),c===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=c,e-=s.idBlock.blockLength,c=s.lenBlock.fromBER(r,t,e),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),c===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=c,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 a=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};a=B.EndOfContent;break;case 1:a=B.Boolean;break;case 2:a=B.Integer;break;case 3:a=B.BitString;break;case 4:a=B.OctetString;break;case 5:a=B.Null;break;case 6:a=B.ObjectIdentifier;break;case 10:a=B.Enumerated;break;case 12:a=B.Utf8String;break;case 13:a=B.RelativeObjectIdentifier;break;case 14:a=B.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:a=B.Sequence;break;case 17:a=B.Set;break;case 18:a=B.NumericString;break;case 19:a=B.PrintableString;break;case 20:a=B.TeletexString;break;case 21:a=B.VideotexString;break;case 22:a=B.IA5String;break;case 23:a=B.UTCTime;break;case 24:a=B.GeneralizedTime;break;case 25:a=B.GraphicString;break;case 26:a=B.VisibleString;break;case 27:a=B.GeneralString;break;case 28:a=B.UniversalString;break;case 29:a=B.CharacterString;break;case 30:a=B.BmpString;break;case 31:a=B.DATE;break;case 32:a=B.TimeOfDay;break;case 33:a=B.DateTime;break;case 34:a=B.Duration;break;default:{let l=s.idBlock.isConstructed?new B.Constructed:new B.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:a=s.idBlock.isConstructed?B.Constructed:B.Primitive}return s=rd(s,a),c=s.fromBER(r,t,s.lenBlock.isIndefiniteForm?e:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:c,result:s}}function mi(r){if(!r.byteLength){let t=new mt({},Et);return t.error="Input buffer has zero length",{offset:-1,result:t}}return Is(M.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function nd(r,t){return r?1:t}var te=class extends Et{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!be(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(;nd(this.isIndefiniteForm,n)>0;){let i=Is(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===zr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===zr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new $r;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?Wt:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};te.NAME="ConstructedValueBlock";var gc,Oe=class extends mt{constructor(t={}){super(t,te),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 Libp2PIdentify=(()=>{var Tu=Object.create;var dn=Object.defineProperty;var Uu=Object.getOwnPropertyDescriptor;var Lu=Object.getOwnPropertyNames;var Ru=Object.getPrototypeOf,_u=Object.prototype.hasOwnProperty;var eo=(r,t)=>()=>(t||r((t={exports:{}}).exports,t),t.exports),St=(r,t)=>{for(var e in t)dn(r,e,{get:t[e],enumerable:!0})},ca=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Lu(t))!_u.call(r,s)&&s!==e&&dn(r,s,{get:()=>t[s],enumerable:!(n=Uu(t,s))||n.enumerable});return r};var ro=(r,t,e)=>(e=r!=null?Tu(Ru(r)):{},ca(t||!r||!r.__esModule?dn(e,"default",{value:r,enumerable:!0}):e,r)),Pu=r=>ca(dn({},"__esModule",{value:!0}),r);var cc=eo(pr=>{"use strict";var od="[object ArrayBuffer]",pe=class r{static isArrayBuffer(t){return Object.prototype.toString.call(t)===od}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 c=this.toUint8Array(i);s.set(c,o),o+=c.length}return t[t.length-1]instanceof Function?this.toView(s,t[t.length-1]):s.buffer}},di="string",id=/^[0-9a-f\s]+$/i,ad=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,cd=/^[a-zA-Z0-9-_]+$/,Dn=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=pe.toUint8Array(t),n="";for(let o=0;o<e.length;o++)n+=String.fromCharCode(e[o]);return decodeURIComponent(escape(n))}},Vt=class{static toString(t,e=!1){let n=pe.toArrayBuffer(t),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let c=s.getUint16(i,e);o+=String.fromCharCode(c)}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}},Mn=class r{static isHex(t){return typeof t===di&&id.test(t)}static isBase64(t){return typeof t===di&&ad.test(t)}static isBase64Url(t){return typeof t===di&&cd.test(t)}static ToString(t,e="utf8"){let n=pe.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 Vt.toString(n,!0);case"utf16":case"utf16be":return Vt.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 Vt.fromString(t,!0);case"utf16":case"utf16be":return Vt.fromString(t);default:throw new Error(`Unknown type of encoding '${e}'`)}}static ToBase64(t){let e=pe.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 Dn.fromString(t);case"utf16":case"utf16be":return Vt.fromString(t);case"utf16le":case"usc2":return Vt.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 Dn.toString(t);case"utf16":case"utf16be":return Vt.toString(t);case"utf16le":case"usc2":return Vt.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=pe.toUint8Array(t),n="";for(let s=0;s<e.length;s++)n+=String.fromCharCode(e[s]);return n}static ToHex(t){let e=pe.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 Vt.toString(t,e)}static FromUtf16String(t,e=!1){return Vt.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,"")||""}};Mn.DEFAULT_UTF8_ENCODING="utf8";function ld(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 ud(...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 fd(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}pr.BufferSourceConverter=pe;pr.Convert=Mn;pr.assign=ld;pr.combine=ud;pr.isEqual=fd});var tu=eo((Cx,Ql)=>{function Xd(){return!!(typeof window<"u"&&typeof window.process=="object"&&window.process.type==="renderer"||typeof process<"u"&&typeof process.versions=="object"&&process.versions.electron||typeof navigator=="object"&&typeof navigator.userAgent=="string"&&navigator.userAgent.indexOf("Electron")>=0)}Ql.exports=Xd});var uu=eo(ln=>{(function(){var r,t,e,n,s,o,i,c;c=function(a){var l,u,f,h;return l=(a&255<<24)>>>24,u=(a&255<<16)>>>16,f=(a&65280)>>>8,h=a&255,[l,u,f,h].join(".")},i=function(a){var l,u,f,h,m,p;for(l=[],f=h=0;h<=3&&a.length!==0;f=++h){if(f>0){if(a[0]!==".")throw new Error("Invalid IP");a=a.substring(1)}p=t(a),m=p[0],u=p[1],a=a.substring(u),l.push(m)}if(a.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(a){return a.charCodeAt(0)},n=e("0"),o=e("a"),s=e("A"),t=function(a){var l,u,f,h,m;for(h=0,l=10,u="9",f=0,a.length>1&&a[f]==="0"&&(a[f+1]==="x"||a[f+1]==="X"?(f+=2,l=16):"0"<=a[f+1]&&a[f+1]<="9"&&(f++,l=8,u="7")),m=f;f<a.length;){if("0"<=a[f]&&a[f]<=u)h=h*l+(e(a[f])-n)>>>0;else if(l===16)if("a"<=a[f]&&a[f]<="f")h=h*l+(10+e(a[f])-o)>>>0;else if("A"<=a[f]&&a[f]<="F")h=h*l+(10+e(a[f])-s)>>>0;else break;else break;if(h>4294967295)throw new Error("too large");f++}if(f===m)throw new Error("empty octet");return[h,f]},r=function(){function a(l,u){var f,h,m,p;if(typeof l!="string")throw new Error("Missing `net' parameter");if(u||(p=l.split("/",2),l=p[0],u=p[1]),u||(u=32),typeof u=="string"&&u.indexOf(".")>-1){try{this.maskLong=i(u)}catch(b){throw f=b,new Error("Invalid mask: "+u)}for(h=m=32;m>=0;h=--m)if(this.maskLong===4294967295<<32-h>>>0){this.bitmask=h;break}}else if(u||u===0)this.bitmask=parseInt(u,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(b){throw f=b,new Error("Invalid net address: "+l)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+u);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return a.prototype.contains=function(l){return typeof l=="string"&&(l.indexOf("/")>0||l.split(".").length!==4)&&(l=new a(l)),l instanceof a?this.contains(l.base)&&this.contains(l.broadcast||l.last):(i(l)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},a.prototype.next=function(l){return l==null&&(l=1),new a(c(this.netLong+this.size*l),this.mask)},a.prototype.forEach=function(l){var u,f,h;for(h=i(this.first),f=i(this.last),u=0;h<=f;)l(c(h),h,u),u++,h++},a.prototype.toString=function(){return this.base+"/"+this.bitmask},a}(),ln.ip2long=i,ln.long2ip=c,ln.Netmask=r}).call(ln)});var I0={};St(I0,{identify:()=>A0,identifyPush:()=>S0});var no=Symbol.for("@libp2p/peer-id");var It=class extends Error{static name="InvalidParametersError";constructor(t="Invalid parameters"){super(t),this.name="InvalidParametersError"}},rr=class extends Error{static name="InvalidPublicKeyError";constructor(t="Invalid public key"){super(t),this.name="InvalidPublicKeyError"}};var pn=class extends Error{static name="InvalidCIDError";constructor(t="Invalid CID"){super(t),this.name="InvalidCIDError"}},mn=class extends Error{static name="InvalidMultihashError";constructor(t="Invalid Multihash"){super(t),this.name="InvalidMultihashError"}},gn=class extends Error{static name="UnsupportedProtocolError";constructor(t="Unsupported protocol error"){super(t),this.name="UnsupportedProtocolError"}},Dt=class extends Error{static name="InvalidMessageError";constructor(t="Invalid message"){super(t),this.name="InvalidMessageError"}};var Me=class extends Error{static name="UnsupportedKeyTypeError";constructor(t="Unsupported key type"){super(t),this.name="UnsupportedKeyTypeError"}};var Tr=(r,...t)=>{try{[...t]}catch{}};var yn=Symbol.for("@libp2p/service-capabilities"),U0=Symbol.for("@libp2p/service-dependencies");var co={};St(co,{base58btc:()=>X,base58flickr:()=>Hu});var ep=new Uint8Array(0);function la(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 ie(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 ua(r){return new TextEncoder().encode(r)}function fa(r){return new TextDecoder().decode(r)}function Ou(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 c=r.length,a=r.charAt(0),l=Math.log(c)/Math.log(256),u=Math.log(256)/Math.log(c);function f(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 b=0,d=0,v=0,A=p.length;v!==A&&p[v]===0;)v++,b++;for(var y=(A-v)*u+1>>>0,I=new Uint8Array(y);v!==A;){for(var L=p[v],U=0,k=y-1;(L!==0||U<d)&&k!==-1;k--,U++)L+=256*I[k]>>>0,I[k]=L%c>>>0,L=L/c>>>0;if(L!==0)throw new Error("Non-zero carry");d=U,v++}for(var T=y-d;T!==y&&I[T]===0;)T++;for(var N=a.repeat(b);T<y;++T)N+=r.charAt(I[T]);return N}function h(p){if(typeof p!="string")throw new TypeError("Expected String");if(p.length===0)return new Uint8Array;var b=0;if(p[b]!==" "){for(var d=0,v=0;p[b]===a;)d++,b++;for(var A=(p.length-b)*l+1>>>0,y=new Uint8Array(A);p[b];){var I=e[p.charCodeAt(b)];if(I===255)return;for(var L=0,U=A-1;(I!==0||L<v)&&U!==-1;U--,L++)I+=c*y[U]>>>0,y[U]=I%256>>>0,I=I/256>>>0;if(I!==0)throw new Error("Non-zero carry");v=L,b++}if(p[b]!==" "){for(var k=A-v;k!==A&&y[k]===0;)k++;for(var T=new Uint8Array(d+(A-k)),N=d;k!==A;)T[N++]=y[k++];return T}}}function m(p){var b=h(p);if(b)return b;throw new Error(`Non-${t} character`)}return{encode:f,decodeUnsafe:h,decode:m}}var Vu=Ou,Du=Vu,da=Du;var so=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")}},oo=class{name;prefix;baseDecode;prefixCodePoint;constructor(t,e,n){this.name=t,this.prefix=e;let s=e.codePointAt(0);if(s===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s,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 pa(this,t)}},io=class{decoders;constructor(t){this.decoders=t}or(t){return pa(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 pa(r,t){return new io({...r.decoders??{[r.prefix]:r},...t.decoders??{[t.prefix]:t}})}var ao=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 so(t,e,n),this.decoder=new oo(t,e,s)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};function nr({name:r,prefix:t,encode:e,decode:n}){return new ao(r,t,e,n)}function Be({name:r,prefix:t,alphabet:e}){let{encode:n,decode:s}=da(e,r);return nr({prefix:t,name:r,encode:n,decode:o=>ie(s(o))})}function Mu(r,t,e,n){let s={};for(let u=0;u<t.length;++u)s[t[u]]=u;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*e/8|0),c=0,a=0,l=0;for(let u=0;u<o;++u){let f=s[r[u]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);a=a<<e|f,c+=e,c>=8&&(c-=8,i[l++]=255&a>>c)}if(c>=e||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i}function Fu(r,t,e){let n=t[t.length-1]==="=",s=(1<<e)-1,o="",i=0,c=0;for(let a=0;a<r.length;++a)for(c=c<<8|r[a],i+=8;i>e;)i-=e,o+=t[s&c>>i];if(i!==0&&(o+=t[s&c<<e-i]),n)for(;o.length*e&7;)o+="=";return o}function ot({name:r,prefix:t,bitsPerChar:e,alphabet:n}){return nr({prefix:t,name:r,encode(s){return Fu(s,n,e)},decode(s){return Mu(s,n,e,r)}})}var X=Be({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Hu=Be({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var lo={};St(lo,{base32:()=>ae,base32hex:()=>zu,base32hexpad:()=>Wu,base32hexpadupper:()=>ju,base32hexupper:()=>Gu,base32pad:()=>qu,base32padupper:()=>$u,base32upper:()=>Ku,base32z:()=>Zu});var ae=ot({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ku=ot({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),qu=ot({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$u=ot({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),zu=ot({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Gu=ot({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Wu=ot({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ju=ot({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Zu=ot({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var uo={};St(uo,{base36:()=>Ur,base36upper:()=>Yu});var Ur=Be({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Yu=Be({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ju=ya,ma=128,Xu=127,Qu=~Xu,tf=Math.pow(2,31);function ya(r,t,e){t=t||[],e=e||0;for(var n=e;r>=tf;)t[e++]=r&255|ma,r/=128;for(;r&Qu;)t[e++]=r&255|ma,r>>>=7;return t[e]=r|0,ya.bytes=e-n+1,t}var ef=fo,rf=128,ga=127;function fo(r,n){var e=0,n=n||0,s=0,o=n,i,c=r.length;do{if(o>=c)throw fo.bytes=0,new RangeError("Could not decode varint");i=r[o++],e+=s<28?(i&ga)<<s:(i&ga)*Math.pow(2,s),s+=7}while(i>=rf);return fo.bytes=o-n,e}var nf=Math.pow(2,7),sf=Math.pow(2,14),of=Math.pow(2,21),af=Math.pow(2,28),cf=Math.pow(2,35),lf=Math.pow(2,42),uf=Math.pow(2,49),ff=Math.pow(2,56),hf=Math.pow(2,63),df=function(r){return r<nf?1:r<sf?2:r<of?3:r<af?4:r<cf?5:r<lf?6:r<uf?7:r<ff?8:r<hf?9:10},pf={encode:Ju,decode:ef,encodingLength:df},mf=pf,Lr=mf;function Rr(r,t=0){return[Lr.decode(r,t),Lr.decode.bytes]}function sr(r,t,e=0){return Lr.encode(r,t,e),t}function or(r){return Lr.encodingLength(r)}function Mt(r,t){let e=t.byteLength,n=or(r),s=n+or(e),o=new Uint8Array(s+e);return sr(r,o,0),sr(e,o,n),o.set(t,s),new ir(r,e,t,o)}function Fe(r){let t=ie(r),[e,n]=Rr(t),[s,o]=Rr(t.subarray(n)),i=t.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new ir(e,s,i,t)}function ba(r,t){if(r===t)return!0;{let e=t;return r.code===e.code&&r.size===e.size&&e.bytes instanceof Uint8Array&&la(r.bytes,e.bytes)}}var ir=class{code;size;digest;bytes;constructor(t,e,n,s){this.code=t,this.size=e,this.digest=n,this.bytes=s}};function wa(r,t){let{bytes:e,version:n}=r;switch(n){case 0:return yf(e,ho(r),t??X.encoder);default:return bf(e,ho(r),t??ae.encoder)}}var xa=new WeakMap;function ho(r){let t=xa.get(r);if(t==null){let e=new Map;return xa.set(r,e),e}return t}var dt=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!==_r)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(e.code!==wf)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&&ba(t.multihash,n.multihash)}toString(t){return wa(this,t)}toJSON(){return{"/":wa(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??va(n,s,o.bytes))}else if(e[xf]===!0){let{version:n,multihash:s,code:o}=e,i=Fe(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!==_r)throw new Error(`Version 0 CID must use dag-pb (code: ${_r}) block encoding`);return new r(t,e,n,n.bytes)}case 1:{let s=va(t,e,n.bytes);return new r(t,e,n,s)}default:throw new Error("Invalid version")}}static createV0(t){return r.create(0,_r,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=ie(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 ir(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[f,h]=Rr(t.subarray(e));return e+=h,f},s=n(),o=_r;if(s===18?(s=0,e=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=e,c=n(),a=n(),l=e+a,u=l-i;return{version:s,codec:o,multihashCode:c,digestSize:a,multihashSize:u,size:l}}static parse(t,e){let[n,s]=gf(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 ho(o).set(n,t),o}};function gf(r,t){switch(r[0]){case"Q":{let e=t??X;return[X.prefix,e.decode(`${X.prefix}${r}`)]}case X.prefix:{let e=t??X;return[X.prefix,e.decode(r)]}case ae.prefix:{let e=t??ae;return[ae.prefix,e.decode(r)]}case Ur.prefix:{let e=t??Ur;return[Ur.prefix,e.decode(r)]}default:{if(t==null)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[r[0],t.decode(r)]}}}function yf(r,t,e){let{prefix:n}=e;if(n!==X.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 bf(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 _r=112,wf=18;function va(r,t,e){let n=or(r),s=n+or(t),o=new Uint8Array(s+e.byteLength);return sr(r,o,0),sr(t,o,n),o.set(e,s),o}var xf=Symbol.for("@ipld/js-cid/CID");var po={};St(po,{identity:()=>ce});var Ea=0,vf="identity",Ba=ie;function Ef(r){return Mt(Ea,Ba(r))}var ce={code:Ea,name:vf,encode:Ba,digest:Ef};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}function Aa(r){if(!Number.isSafeInteger(r)||r<0)throw new Error("positive integer expected, got "+r)}function Bf(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function ar(r,...t){if(!Bf(r))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(r.length))throw new Error("Uint8Array expected of length "+t+", got length="+r.length)}function Sa(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Aa(r.outputLen),Aa(r.blockLen)}function cr(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 Ia(r,t){ar(r);let e=t.outputLen;if(r.length<e)throw new Error("digestInto() expects output buffer of length at least "+e)}var He=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function wn(r){return new DataView(r.buffer,r.byteOffset,r.byteLength)}function Ft(r,t){return r<<32-t|r>>>t}function ka(r){if(typeof r!="string")throw new Error("utf8ToBytes expected string, got "+typeof r);return new Uint8Array(new TextEncoder().encode(r))}function Pr(r){return typeof r=="string"&&(r=ka(r)),ar(r),r}function mo(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];ar(s),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 lr=class{clone(){return this._cloneInto()}};function xn(r){let t=n=>r().update(Pr(n)).digest(),e=r();return t.outputLen=e.outputLen,t.blockLen=e.blockLen,t.create=()=>r(),t}function vn(r=32){if(He&&typeof He.getRandomValues=="function")return He.getRandomValues(new Uint8Array(r));if(He&&typeof He.randomBytes=="function")return He.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Af(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),c=Number(e&o),a=n?4:0,l=n?0:4;r.setUint32(t+a,i,n),r.setUint32(t+l,c,n)}function Na(r,t,e){return r&t^~r&e}function Ca(r,t,e){return r&t^r&e^t&e}var ur=class extends lr{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=wn(this.buffer)}update(t){cr(this);let{view:e,buffer:n,blockLen:s}=this;t=Pr(t);let o=t.length;for(let i=0;i<o;){let c=Math.min(s-this.pos,o-i);if(c===s){let a=wn(t);for(;s<=o-i;i+=s)this.process(a,i);continue}n.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===s&&(this.process(e,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){cr(this),Ia(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 f=i;f<s;f++)e[f]=0;Af(n,s-8,BigInt(this.length*8),o),this.process(n,0);let c=wn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let l=a/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<l;f++)c.setUint32(4*f,u[f],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:c}=this;return t.length=s,t.pos=c,t.finished=o,t.destroyed=i,s%e&&t.buffer.set(n),t}};var En=BigInt(4294967295),go=BigInt(32);function Ta(r,t=!1){return t?{h:Number(r&En),l:Number(r>>go&En)}:{h:Number(r>>go&En)|0,l:Number(r&En)|0}}function Sf(r,t=!1){let e=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=Ta(r[s],t);[e[s],n[s]]=[o,i]}return[e,n]}var If=(r,t)=>BigInt(r>>>0)<<go|BigInt(t>>>0),kf=(r,t,e)=>r>>>e,Nf=(r,t,e)=>r<<32-e|t>>>e,Cf=(r,t,e)=>r>>>e|t<<32-e,Tf=(r,t,e)=>r<<32-e|t>>>e,Uf=(r,t,e)=>r<<64-e|t>>>e-32,Lf=(r,t,e)=>r>>>e-32|t<<64-e,Rf=(r,t)=>t,_f=(r,t)=>r,Pf=(r,t,e)=>r<<e|t>>>32-e,Of=(r,t,e)=>t<<e|r>>>32-e,Vf=(r,t,e)=>t<<e-32|r>>>64-e,Df=(r,t,e)=>r<<e-32|t>>>64-e;function Mf(r,t,e,n){let s=(t>>>0)+(n>>>0);return{h:r+e+(s/2**32|0)|0,l:s|0}}var Ff=(r,t,e)=>(r>>>0)+(t>>>0)+(e>>>0),Hf=(r,t,e,n)=>t+e+n+(r/2**32|0)|0,Kf=(r,t,e,n)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0),qf=(r,t,e,n,s)=>t+e+n+s+(r/2**32|0)|0,$f=(r,t,e,n,s)=>(r>>>0)+(t>>>0)+(e>>>0)+(n>>>0)+(s>>>0),zf=(r,t,e,n,s,o)=>t+e+n+s+o+(r/2**32|0)|0;var Gf={fromBig:Ta,split:Sf,toBig:If,shrSH:kf,shrSL:Nf,rotrSH:Cf,rotrSL:Tf,rotrBH:Uf,rotrBL:Lf,rotr32H:Rf,rotr32L:_f,rotlSH:Pf,rotlSL:Of,rotlBH:Vf,rotlBL:Df,add:Mf,add3L:Ff,add3H:Hf,add4L:Kf,add4H:qf,add5H:zf,add5L:$f},O=Gf;var[Wf,jf]=O.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))),Se=new Uint32Array(80),Ie=new Uint32Array(80),yo=class extends ur{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:c,Dl:a,Eh:l,El:u,Fh:f,Fl:h,Gh:m,Gl:p,Hh:b,Hl:d}=this;return[t,e,n,s,o,i,c,a,l,u,f,h,m,p,b,d]}set(t,e,n,s,o,i,c,a,l,u,f,h,m,p,b,d){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=c|0,this.Dl=a|0,this.Eh=l|0,this.El=u|0,this.Fh=f|0,this.Fl=h|0,this.Gh=m|0,this.Gl=p|0,this.Hh=b|0,this.Hl=d|0}process(t,e){for(let y=0;y<16;y++,e+=4)Se[y]=t.getUint32(e),Ie[y]=t.getUint32(e+=4);for(let y=16;y<80;y++){let I=Se[y-15]|0,L=Ie[y-15]|0,U=O.rotrSH(I,L,1)^O.rotrSH(I,L,8)^O.shrSH(I,L,7),k=O.rotrSL(I,L,1)^O.rotrSL(I,L,8)^O.shrSL(I,L,7),T=Se[y-2]|0,N=Ie[y-2]|0,tt=O.rotrSH(T,N,19)^O.rotrBH(T,N,61)^O.shrSH(T,N,6),q=O.rotrSL(T,N,19)^O.rotrBL(T,N,61)^O.shrSL(T,N,6),D=O.add4L(k,q,Ie[y-7],Ie[y-16]),it=O.add4H(D,U,tt,Se[y-7],Se[y-16]);Se[y]=it|0,Ie[y]=D|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:c,Cl:a,Dh:l,Dl:u,Eh:f,El:h,Fh:m,Fl:p,Gh:b,Gl:d,Hh:v,Hl:A}=this;for(let y=0;y<80;y++){let I=O.rotrSH(f,h,14)^O.rotrSH(f,h,18)^O.rotrBH(f,h,41),L=O.rotrSL(f,h,14)^O.rotrSL(f,h,18)^O.rotrBL(f,h,41),U=f&m^~f&b,k=h&p^~h&d,T=O.add5L(A,L,k,jf[y],Ie[y]),N=O.add5H(T,v,I,U,Wf[y],Se[y]),tt=T|0,q=O.rotrSH(n,s,28)^O.rotrBH(n,s,34)^O.rotrBH(n,s,39),D=O.rotrSL(n,s,28)^O.rotrBL(n,s,34)^O.rotrBL(n,s,39),it=n&o^n&c^o&c,E=s&i^s&a^i&a;v=b|0,A=d|0,b=m|0,d=p|0,m=f|0,p=h|0,{h:f,l:h}=O.add(l|0,u|0,N|0,tt|0),l=c|0,u=a|0,c=o|0,a=i|0,o=n|0,i=s|0;let C=O.add3L(tt,D,E);n=O.add3H(C,N,q,it),s=C|0}({h:n,l:s}=O.add(this.Ah|0,this.Al|0,n|0,s|0)),{h:o,l:i}=O.add(this.Bh|0,this.Bl|0,o|0,i|0),{h:c,l:a}=O.add(this.Ch|0,this.Cl|0,c|0,a|0),{h:l,l:u}=O.add(this.Dh|0,this.Dl|0,l|0,u|0),{h:f,l:h}=O.add(this.Eh|0,this.El|0,f|0,h|0),{h:m,l:p}=O.add(this.Fh|0,this.Fl|0,m|0,p|0),{h:b,l:d}=O.add(this.Gh|0,this.Gl|0,b|0,d|0),{h:v,l:A}=O.add(this.Hh|0,this.Hl|0,v|0,A|0),this.set(n,s,o,i,c,a,l,u,f,h,m,p,b,d,v,A)}roundClean(){Se.fill(0),Ie.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 Ua=xn(()=>new yo);var Sn={};St(Sn,{aInRange:()=>Ct,abool:()=>Ht,abytes:()=>fr,bitGet:()=>th,bitLen:()=>vo,bitMask:()=>Vr,bitSet:()=>eh,bytesToHex:()=>ue,bytesToNumberBE:()=>fe,bytesToNumberLE:()=>Ne,concatBytes:()=>he,createHmacDrbg:()=>Eo,ensureBytes:()=>nt,equalBytes:()=>Xf,hexToBytes:()=>qe,hexToNumber:()=>xo,inRange:()=>Or,isBytes:()=>ke,memoized:()=>ze,notImplemented:()=>nh,numberToBytesBE:()=>Ce,numberToBytesLE:()=>$e,numberToHexUnpadded:()=>Ke,numberToVarBytesBE:()=>Jf,utf8ToBytes:()=>Qf,validateObject:()=>Xt});var Bn=BigInt(0),An=BigInt(1),Zf=BigInt(2);function ke(r){return r instanceof Uint8Array||ArrayBuffer.isView(r)&&r.constructor.name==="Uint8Array"}function fr(r){if(!ke(r))throw new Error("Uint8Array expected")}function Ht(r,t){if(typeof t!="boolean")throw new Error(r+" boolean expected, got "+t)}var Yf=Array.from({length:256},(r,t)=>t.toString(16).padStart(2,"0"));function ue(r){fr(r);let t="";for(let e=0;e<r.length;e++)t+=Yf[r[e]];return t}function Ke(r){let t=r.toString(16);return t.length&1?"0"+t:t}function xo(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return r===""?Bn:BigInt("0x"+r)}var le={_0:48,_9:57,A:65,F:70,a:97,f:102};function La(r){if(r>=le._0&&r<=le._9)return r-le._0;if(r>=le.A&&r<=le.F)return r-(le.A-10);if(r>=le.a&&r<=le.f)return r-(le.a-10)}function qe(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("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=La(r.charCodeAt(o)),c=La(r.charCodeAt(o+1));if(i===void 0||c===void 0){let a=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+o)}n[s]=i*16+c}return n}function fe(r){return xo(ue(r))}function Ne(r){return fr(r),xo(ue(Uint8Array.from(r).reverse()))}function Ce(r,t){return qe(r.toString(16).padStart(t*2,"0"))}function $e(r,t){return Ce(r,t).reverse()}function Jf(r){return qe(Ke(r))}function nt(r,t,e){let n;if(typeof t=="string")try{n=qe(t)}catch(o){throw new Error(r+" must be hex string or Uint8Array, cause: "+o)}else if(ke(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+" of length "+e+" expected, got "+s);return n}function he(...r){let t=0;for(let n=0;n<r.length;n++){let s=r[n];fr(s),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}function Xf(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 Qf(r){if(typeof r!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(r))}var bo=r=>typeof r=="bigint"&&Bn<=r;function Or(r,t,e){return bo(r)&&bo(t)&&bo(e)&&t<=r&&r<e}function Ct(r,t,e,n){if(!Or(t,e,n))throw new Error("expected valid "+r+": "+e+" <= n < "+n+", got "+t)}function vo(r){let t;for(t=0;r>Bn;r>>=An,t+=1);return t}function th(r,t){return r>>BigInt(t)&An}function eh(r,t,e){return r|(e?An:Bn)<<BigInt(t)}var Vr=r=>(Zf<<BigInt(r-1))-An,wo=r=>new Uint8Array(r),Ra=r=>Uint8Array.from(r);function Eo(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=wo(r),s=wo(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},c=(...f)=>e(s,n,...f),a=(f=wo())=>{s=c(Ra([0]),f),n=c(),f.length!==0&&(s=c(Ra([1]),f),n=c())},l=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<t;){n=c();let m=n.slice();h.push(m),f+=n.length}return he(...h)};return(f,h)=>{i(),a(f);let m;for(;!(m=h(l()));)a();return i(),m}}var rh={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"||ke(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 Xt(r,t,e={}){let n=(s,o,i)=>{let c=rh[o];if(typeof c!="function")throw new Error("invalid validator function");let a=r[s];if(!(i&&a===void 0)&&!c(a,r))throw new Error("param "+String(s)+" is invalid. Expected "+o+", got "+a)};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 nh=()=>{throw new Error("not implemented")};function ze(r){let t=new WeakMap;return(e,...n)=>{let s=t.get(e);if(s!==void 0)return s;let o=r(e,...n);return t.set(e,o),o}}var at=BigInt(0),et=BigInt(1),Ge=BigInt(2),sh=BigInt(3),Bo=BigInt(4),_a=BigInt(5),Pa=BigInt(8),oh=BigInt(9),ih=BigInt(16);function Z(r,t){let e=r%t;return e>=at?e:t+e}function ah(r,t,e){if(t<at)throw new Error("invalid exponent, negatives unsupported");if(e<=at)throw new Error("invalid modulus");if(e===et)return at;let n=et;for(;t>at;)t&et&&(n=n*r%e),r=r*r%e,t>>=et;return n}function rt(r,t,e){let n=r;for(;t-- >at;)n*=n,n%=e;return n}function In(r,t){if(r===at)throw new Error("invert: expected non-zero number");if(t<=at)throw new Error("invert: expected positive modulus, got "+t);let e=Z(r,t),n=t,s=at,o=et,i=et,c=at;for(;e!==at;){let l=n/e,u=n%e,f=s-i*l,h=o-c*l;n=e,e=u,s=i,o=c,i=f,c=h}if(n!==et)throw new Error("invert: does not exist");return Z(s,t)}function ch(r){let t=(r-et)/Ge,e,n,s;for(e=r-et,n=0;e%Ge===at;e/=Ge,n++);for(s=Ge;s<r&&ah(s,t,r)!==r-et;s++)if(s>1e3)throw new Error("Cannot find square root: likely non-prime P");if(n===1){let i=(r+et)/Bo;return function(a,l){let u=a.pow(l,i);if(!a.eql(a.sqr(u),l))throw new Error("Cannot find square root");return u}}let o=(e+et)/Ge;return function(c,a){if(c.pow(a,t)===c.neg(c.ONE))throw new Error("Cannot find square root");let l=n,u=c.pow(c.mul(c.ONE,s),e),f=c.pow(a,o),h=c.pow(a,e);for(;!c.eql(h,c.ONE);){if(c.eql(h,c.ZERO))return c.ZERO;let m=1;for(let b=c.sqr(h);m<l&&!c.eql(b,c.ONE);m++)b=c.sqr(b);let p=c.pow(u,et<<BigInt(l-m-1));u=c.sqr(p),f=c.mul(f,p),h=c.mul(h,u),l=m}return f}}function lh(r){if(r%Bo===sh){let t=(r+et)/Bo;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%Pa===_a){let t=(r-_a)/Pa;return function(n,s){let o=n.mul(s,Ge),i=n.pow(o,t),c=n.mul(s,i),a=n.mul(n.mul(c,Ge),i),l=n.mul(c,n.sub(a,n.ONE));if(!n.eql(n.sqr(l),s))throw new Error("Cannot find square root");return l}}return r%ih,ch(r)}var Oa=(r,t)=>(Z(r,t)&et)===et,uh=["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=uh.reduce((n,s)=>(n[s]="function",n),t);return Xt(r,e)}function fh(r,t,e){if(e<at)throw new Error("invalid exponent, negatives unsupported");if(e===at)return r.ONE;if(e===et)return t;let n=r.ONE,s=t;for(;e>at;)e&et&&(n=r.mul(n,s)),s=r.sqr(s),e>>=et;return n}function hh(r,t){let e=new Array(t.length),n=t.reduce((o,i,c)=>r.is0(i)?o:(e[c]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return t.reduceRight((o,i,c)=>r.is0(i)?o:(e[c]=r.mul(o,e[c]),r.mul(o,i)),s),e}function So(r,t){let e=t!==void 0?t:r.toString(2).length,n=Math.ceil(e/8);return{nBitLength:e,nByteLength:n}}function Te(r,t,e=!1,n={}){if(r<=at)throw new Error("invalid field: expected ORDER > 0, got "+r);let{nBitLength:s,nByteLength:o}=So(r,t);if(o>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let i,c=Object.freeze({ORDER:r,isLE:e,BITS:s,BYTES:o,MASK:Vr(s),ZERO:at,ONE:et,create:a=>Z(a,r),isValid:a=>{if(typeof a!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof a);return at<=a&&a<r},is0:a=>a===at,isOdd:a=>(a&et)===et,neg:a=>Z(-a,r),eql:(a,l)=>a===l,sqr:a=>Z(a*a,r),add:(a,l)=>Z(a+l,r),sub:(a,l)=>Z(a-l,r),mul:(a,l)=>Z(a*l,r),pow:(a,l)=>fh(c,a,l),div:(a,l)=>Z(a*In(l,r),r),sqrN:a=>a*a,addN:(a,l)=>a+l,subN:(a,l)=>a-l,mulN:(a,l)=>a*l,inv:a=>In(a,r),sqrt:n.sqrt||(a=>(i||(i=lh(r)),i(c,a))),invertBatch:a=>hh(c,a),cmov:(a,l,u)=>u?l:a,toBytes:a=>e?$e(a,o):Ce(a,o),fromBytes:a=>{if(a.length!==o)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+a.length);return e?Ne(a):fe(a)}});return Object.freeze(c)}function Va(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=Va(r);return t+Math.ceil(t/2)}function Da(r,t,e=!1){let n=r.length,s=Va(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?Ne(r):fe(r),c=Z(i,t-et)+et;return e?$e(c,s):Ce(c,s)}var Ma=BigInt(0),kn=BigInt(1);function ko(r,t){let e=t.negate();return r?e:t}function Fa(r,t){if(!Number.isSafeInteger(r)||r<=0||r>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+r)}function No(r,t){Fa(r,t);let e=Math.ceil(t/r)+1,n=2**(r-1);return{windows:e,windowSize:n}}function dh(r,t){if(!Array.isArray(r))throw new Error("array expected");r.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})}function ph(r,t){if(!Array.isArray(r))throw new Error("array of scalars expected");r.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}var Co=new WeakMap,Ha=new WeakMap;function To(r){return Ha.get(r)||1}function Nn(r,t){return{constTimeNegate:ko,hasPrecomputes(e){return To(e)!==1},unsafeLadder(e,n,s=r.ZERO){let o=e;for(;n>Ma;)n&kn&&(s=s.add(o)),o=o.double(),n>>=kn;return s},precomputeWindow(e,n){let{windows:s,windowSize:o}=No(n,t),i=[],c=e,a=c;for(let l=0;l<s;l++){a=c,i.push(a);for(let u=1;u<o;u++)a=a.add(c),i.push(a);c=a.double()}return i},wNAF(e,n,s){let{windows:o,windowSize:i}=No(e,t),c=r.ZERO,a=r.BASE,l=BigInt(2**e-1),u=2**e,f=BigInt(e);for(let h=0;h<o;h++){let m=h*i,p=Number(s&l);s>>=f,p>i&&(p-=u,s+=kn);let b=m,d=m+Math.abs(p)-1,v=h%2!==0,A=p<0;p===0?a=a.add(ko(v,n[b])):c=c.add(ko(A,n[d]))}return{p:c,f:a}},wNAFUnsafe(e,n,s,o=r.ZERO){let{windows:i,windowSize:c}=No(e,t),a=BigInt(2**e-1),l=2**e,u=BigInt(e);for(let f=0;f<i;f++){let h=f*c;if(s===Ma)break;let m=Number(s&a);if(s>>=u,m>c&&(m-=l,s+=kn),m===0)continue;let p=n[h+Math.abs(m)-1];m<0&&(p=p.negate()),o=o.add(p)}return o},getPrecomputes(e,n,s){let o=Co.get(n);return o||(o=this.precomputeWindow(n,e),e!==1&&Co.set(n,s(o))),o},wNAFCached(e,n,s){let o=To(e);return this.wNAF(o,this.getPrecomputes(o,e,s),n)},wNAFCachedUnsafe(e,n,s,o){let i=To(e);return i===1?this.unsafeLadder(e,n,o):this.wNAFUnsafe(i,this.getPrecomputes(i,e,s),n,o)},setWindowSize(e,n){Fa(n,t),Ha.set(e,n),Co.delete(e)}}}function Cn(r,t,e,n){if(dh(e,r),ph(n,t),e.length!==n.length)throw new Error("arrays of points and scalars must have equal length");let s=r.ZERO,o=vo(BigInt(e.length)),i=o>12?o-3:o>4?o-2:o?2:1,c=(1<<i)-1,a=new Array(c+1).fill(s),l=Math.floor((t.BITS-1)/i)*i,u=s;for(let f=l;f>=0;f-=i){a.fill(s);for(let m=0;m<n.length;m++){let p=n[m],b=Number(p>>BigInt(f)&BigInt(c));a[b]=a[b].add(e[m])}let h=s;for(let m=a.length-1,p=s;m>0;m--)p=p.add(a[m]),h=h.add(p);if(u=u.add(h),f!==0)for(let m=0;m<i;m++)u=u.double()}return u}function Dr(r){return Ao(r.Fp),Xt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...So(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Kt=BigInt(0),Tt=BigInt(1),Tn=BigInt(2),mh=BigInt(8),gh={zip215:!0};function yh(r){let t=Dr(r);return Xt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}function Ka(r){let t=yh(r),{Fp:e,n,prehash:s,hash:o,randomBytes:i,nByteLength:c,h:a}=t,l=Tn<<BigInt(c*8)-Tt,u=e.create,f=Te(t.n,t.nBitLength),h=t.uvRatio||((w,g)=>{try{return{isValid:!0,value:e.sqrt(w*e.inv(g))}}catch{return{isValid:!1,value:Kt}}}),m=t.adjustScalarBytes||(w=>w),p=t.domain||((w,g,x)=>{if(Ht("phflag",x),g.length||x)throw new Error("Contexts/pre-hash are not supported");return w});function b(w,g){Ct("coordinate "+w,g,Kt,l)}function d(w){if(!(w instanceof y))throw new Error("ExtendedPoint expected")}let v=ze((w,g)=>{let{ex:x,ey:S,ez:R}=w,_=w.is0();g==null&&(g=_?mh:e.inv(R));let V=u(x*g),F=u(S*g),P=u(R*g);if(_)return{x:Kt,y:Tt};if(P!==Tt)throw new Error("invZ was invalid");return{x:V,y:F}}),A=ze(w=>{let{a:g,d:x}=t;if(w.is0())throw new Error("bad point: ZERO");let{ex:S,ey:R,ez:_,et:V}=w,F=u(S*S),P=u(R*R),j=u(_*_),J=u(j*j),lt=u(F*g),ut=u(j*u(lt+P)),ht=u(J+u(x*u(F*P)));if(ut!==ht)throw new Error("bad point: equation left != right (1)");let yt=u(S*R),Nt=u(_*V);if(yt!==Nt)throw new Error("bad point: equation left != right (2)");return!0});class y{constructor(g,x,S,R){this.ex=g,this.ey=x,this.ez=S,this.et=R,b("x",g),b("y",x),b("z",S),b("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(g){if(g instanceof y)throw new Error("extended point not allowed");let{x,y:S}=g||{};return b("x",x),b("y",S),new y(x,S,Tt,u(x*S))}static normalizeZ(g){let x=e.invertBatch(g.map(S=>S.ez));return g.map((S,R)=>S.toAffine(x[R])).map(y.fromAffine)}static msm(g,x){return Cn(y,f,g,x)}_setWindowSize(g){U.setWindowSize(this,g)}assertValidity(){A(this)}equals(g){d(g);let{ex:x,ey:S,ez:R}=this,{ex:_,ey:V,ez:F}=g,P=u(x*F),j=u(_*R),J=u(S*F),lt=u(V*R);return P===j&&J===lt}is0(){return this.equals(y.ZERO)}negate(){return new y(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){let{a:g}=t,{ex:x,ey:S,ez:R}=this,_=u(x*x),V=u(S*S),F=u(Tn*u(R*R)),P=u(g*_),j=x+S,J=u(u(j*j)-_-V),lt=P+V,ut=lt-F,ht=P-V,yt=u(J*ut),Nt=u(lt*ht),At=u(J*ht),Jt=u(ut*lt);return new y(yt,Nt,Jt,At)}add(g){d(g);let{a:x,d:S}=t,{ex:R,ey:_,ez:V,et:F}=this,{ex:P,ey:j,ez:J,et:lt}=g;if(x===BigInt(-1)){let ea=u((_-R)*(j+P)),ra=u((_+R)*(j-P)),to=u(ra-ea);if(to===Kt)return this.double();let na=u(V*Tn*lt),sa=u(F*Tn*J),oa=sa+na,ia=ra+ea,aa=sa-na,Iu=u(oa*to),ku=u(ia*aa),Nu=u(oa*aa),Cu=u(to*ia);return new y(Iu,ku,Cu,Nu)}let ut=u(R*P),ht=u(_*j),yt=u(F*S*lt),Nt=u(V*J),At=u((R+_)*(P+j)-ut-ht),Jt=Nt-yt,oe=Nt+yt,Cr=u(ht-x*ut),Eu=u(At*Jt),Bu=u(oe*Cr),Au=u(At*Cr),Su=u(Jt*oe);return new y(Eu,Bu,Su,Au)}subtract(g){return this.add(g.negate())}wNAF(g){return U.wNAFCached(this,g,y.normalizeZ)}multiply(g){let x=g;Ct("scalar",x,Tt,n);let{p:S,f:R}=this.wNAF(x);return y.normalizeZ([S,R])[0]}multiplyUnsafe(g,x=y.ZERO){let S=g;return Ct("scalar",S,Kt,n),S===Kt?L:this.is0()||S===Tt?this:U.wNAFCachedUnsafe(this,S,y.normalizeZ,x)}isSmallOrder(){return this.multiplyUnsafe(a).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(g){return v(this,g)}clearCofactor(){let{h:g}=t;return g===Tt?this:this.multiplyUnsafe(g)}static fromHex(g,x=!1){let{d:S,a:R}=t,_=e.BYTES;g=nt("pointHex",g,_),Ht("zip215",x);let V=g.slice(),F=g[_-1];V[_-1]=F&-129;let P=Ne(V),j=x?l:e.ORDER;Ct("pointHex.y",P,Kt,j);let J=u(P*P),lt=u(J-Tt),ut=u(S*J-R),{isValid:ht,value:yt}=h(lt,ut);if(!ht)throw new Error("Point.fromHex: invalid y coordinate");let Nt=(yt&Tt)===Tt,At=(F&128)!==0;if(!x&&yt===Kt&&At)throw new Error("Point.fromHex: x=0 and x_0=1");return At!==Nt&&(yt=u(-yt)),y.fromAffine({x:yt,y:P})}static fromPrivateKey(g){return N(g).point}toRawBytes(){let{x:g,y:x}=this.toAffine(),S=$e(x,e.BYTES);return S[S.length-1]|=g&Tt?128:0,S}toHex(){return ue(this.toRawBytes())}}y.BASE=new y(t.Gx,t.Gy,Tt,u(t.Gx*t.Gy)),y.ZERO=new y(Kt,Tt,Tt,Kt);let{BASE:I,ZERO:L}=y,U=Nn(y,c*8);function k(w){return Z(w,n)}function T(w){return k(Ne(w))}function N(w){let g=e.BYTES;w=nt("private key",w,g);let x=nt("hashed private key",o(w),2*g),S=m(x.slice(0,g)),R=x.slice(g,2*g),_=T(S),V=I.multiply(_),F=V.toRawBytes();return{head:S,prefix:R,scalar:_,point:V,pointBytes:F}}function tt(w){return N(w).pointBytes}function q(w=new Uint8Array,...g){let x=he(...g);return T(o(p(x,nt("context",w),!!s)))}function D(w,g,x={}){w=nt("message",w),s&&(w=s(w));let{prefix:S,scalar:R,pointBytes:_}=N(g),V=q(x.context,S,w),F=I.multiply(V).toRawBytes(),P=q(x.context,F,_,w),j=k(V+P*R);Ct("signature.s",j,Kt,n);let J=he(F,$e(j,e.BYTES));return nt("result",J,e.BYTES*2)}let it=gh;function E(w,g,x,S=it){let{context:R,zip215:_}=S,V=e.BYTES;w=nt("signature",w,2*V),g=nt("message",g),x=nt("publicKey",x,V),_!==void 0&&Ht("zip215",_),s&&(g=s(g));let F=Ne(w.slice(V,2*V)),P,j,J;try{P=y.fromHex(x,_),j=y.fromHex(w.slice(0,V),_),J=I.multiplyUnsafe(F)}catch{return!1}if(!_&&P.isSmallOrder())return!1;let lt=q(R,j.toRawBytes(),P.toRawBytes(),g);return j.add(P.multiplyUnsafe(lt)).subtract(J).clearCofactor().equals(y.ZERO)}return I._setWindowSize(8),{CURVE:t,getPublicKey:tt,sign:D,verify:E,ExtendedPoint:y,utils:{getExtendedPublicKey:N,randomPrivateKey:()=>i(e.BYTES),precompute(w=8,g=y.BASE){return g._setWindowSize(w),g.multiply(BigInt(3)),g}}}}var Uo=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),qa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Wp=BigInt(0),bh=BigInt(1),$a=BigInt(2),jp=BigInt(3),wh=BigInt(5),xh=BigInt(8);function vh(r){let t=BigInt(10),e=BigInt(20),n=BigInt(40),s=BigInt(80),o=Uo,c=r*r%o*r%o,a=rt(c,$a,o)*c%o,l=rt(a,bh,o)*r%o,u=rt(l,wh,o)*l%o,f=rt(u,t,o)*u%o,h=rt(f,e,o)*f%o,m=rt(h,n,o)*h%o,p=rt(m,s,o)*m%o,b=rt(p,s,o)*m%o,d=rt(b,t,o)*u%o;return{pow_p_5_8:rt(d,$a,o)*r%o,b2:c}}function Eh(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Bh(r,t){let e=Uo,n=Z(t*t*t,e),s=Z(n*n*t,e),o=vh(r*s).pow_p_5_8,i=Z(r*n*o,e),c=Z(t*i*i,e),a=i,l=Z(i*qa,e),u=c===r,f=c===Z(-r,e),h=c===Z(-r*qa,e);return u&&(i=a),(f||h)&&(i=l),Oa(i,e)&&(i=Z(-i,e)),{isValid:u||f,value:i}}var Ah=Te(Uo,void 0,!0),Sh={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ah,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:xh,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ua,randomBytes:vn,adjustScalarBytes:Eh,uvRatio:Bh},za=Ka(Sh);var Un=32;function Ga(r,t,e){return za.verify(t,e instanceof Uint8Array?e:e.subarray(),r)}var Ln=class{type="Ed25519";raw;constructor(t){this.raw=Lo(t,Un)}toMultihash(){return ce.digest(Ue(this))}toCID(){return dt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return Ga(this.raw,e,t)}};function Ro(r){return r=Lo(r,Un),new Ln(r)}function Lo(r,t){if(r=Uint8Array.from(r??[]),r.length!==t)throw new It(`Key must be a Uint8Array of length ${t}, got ${r.length}`);return r}function pt(r=0){return new Uint8Array(r)}function Ut(r=0){return new Uint8Array(r)}var kh=Math.pow(2,7),Nh=Math.pow(2,14),Ch=Math.pow(2,21),_o=Math.pow(2,28),Po=Math.pow(2,35),Oo=Math.pow(2,42),Vo=Math.pow(2,49),W=128,wt=127;function xt(r){if(r<kh)return 1;if(r<Nh)return 2;if(r<Ch)return 3;if(r<_o)return 4;if(r<Po)return 5;if(r<Oo)return 6;if(r<Vo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function Do(r,t,e=0){switch(xt(r)){case 8:t[e++]=r&255|W,r/=128;case 7:t[e++]=r&255|W,r/=128;case 6:t[e++]=r&255|W,r/=128;case 5:t[e++]=r&255|W,r/=128;case 4:t[e++]=r&255|W,r>>>=7;case 3:t[e++]=r&255|W,r>>>=7;case 2:t[e++]=r&255|W,r>>>=7;case 1:{t[e++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return t}function Th(r,t,e=0){switch(xt(r)){case 8:t.set(e++,r&255|W),r/=128;case 7:t.set(e++,r&255|W),r/=128;case 6:t.set(e++,r&255|W),r/=128;case 5:t.set(e++,r&255|W),r/=128;case 4:t.set(e++,r&255|W),r>>>=7;case 3:t.set(e++,r&255|W),r>>>=7;case 2:t.set(e++,r&255|W),r>>>=7;case 1:{t.set(e++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return t}function Mo(r,t){let e=r[t],n=0;if(n+=e&wt,e<W||(e=r[t+1],n+=(e&wt)<<7,e<W)||(e=r[t+2],n+=(e&wt)<<14,e<W)||(e=r[t+3],n+=(e&wt)<<21,e<W)||(e=r[t+4],n+=(e&wt)*_o,e<W)||(e=r[t+5],n+=(e&wt)*Po,e<W)||(e=r[t+6],n+=(e&wt)*Oo,e<W)||(e=r[t+7],n+=(e&wt)*Vo,e<W))return n;throw new RangeError("Could not decode varint")}function Uh(r,t){let e=r.get(t),n=0;if(n+=e&wt,e<W||(e=r.get(t+1),n+=(e&wt)<<7,e<W)||(e=r.get(t+2),n+=(e&wt)<<14,e<W)||(e=r.get(t+3),n+=(e&wt)<<21,e<W)||(e=r.get(t+4),n+=(e&wt)*_o,e<W)||(e=r.get(t+5),n+=(e&wt)*Po,e<W)||(e=r.get(t+6),n+=(e&wt)*Oo,e<W)||(e=r.get(t+7),n+=(e&wt)*Vo,e<W))return n;throw new RangeError("Could not decode varint")}function Ot(r,t,e=0){return t==null&&(t=Ut(xt(r))),t instanceof Uint8Array?Do(r,t,e):Th(r,t,e)}function de(r,t=0){return r instanceof Uint8Array?Mo(r,t):Uh(r,t)}var Fo=new Float32Array([-0]),Le=new Uint8Array(Fo.buffer);function ja(r,t,e){Fo[0]=r,t[e]=Le[0],t[e+1]=Le[1],t[e+2]=Le[2],t[e+3]=Le[3]}function Za(r,t){return Le[0]=r[t],Le[1]=r[t+1],Le[2]=r[t+2],Le[3]=r[t+3],Fo[0]}var Ho=new Float64Array([-0]),vt=new Uint8Array(Ho.buffer);function Ya(r,t,e){Ho[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 Ja(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],Ho[0]}var Lh=BigInt(Number.MAX_SAFE_INTEGER),Rh=BigInt(Number.MIN_SAFE_INTEGER),_t=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 We;if(t<Lh&&t>Rh)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>Xa&&(s=0n,++n>Xa&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(t){if(t===0)return We;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):We}},We=new _t(0,0);We.toBigInt=function(){return 0n};We.zzEncode=We.zzDecode=function(){return this};We.length=function(){return 1};var Xa=4294967296n;function Qa(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 tc(r,t,e){if(e-t<1)return"";let s,o=[],i=0,c;for(;t<e;)c=r[t++],c<128?o[i++]=c:c>191&&c<224?o[i++]=(c&31)<<6|r[t++]&63:c>239&&c<365?(c=((c&7)<<18|(r[t++]&63)<<12|(r[t++]&63)<<6|r[t++]&63)-65536,o[i++]=55296+(c>>10),o[i++]=56320+(c&1023)):o[i++]=(c&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 Ko(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 qt(r,t){return RangeError(`index out of range: ${r.pos} + ${t??1} > ${r.len}`)}function _n(r,t){return(r[t-4]|r[t-3]<<8|r[t-2]<<16|r[t-1]<<24)>>>0}var qo=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,qt(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 qt(this,4);return _n(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qt(this,4);return _n(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qt(this,4);let t=Za(this.buf,this.pos);return this.pos+=4,t}double(){if(this.pos+8>this.len)throw qt(this,4);let t=Ja(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 qt(this,t);return this.pos+=t,e===n?new Uint8Array(0):this.buf.subarray(e,n)}string(){let t=this.bytes();return tc(t,0,t.length)}skip(t){if(typeof t=="number"){if(this.pos+t>this.len)throw qt(this,t);this.pos+=t}else do if(this.pos>=this.len)throw qt(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 _t(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 qt(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 qt(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 qt(this,8);let t=_n(this.buf,this.pos+=4),e=_n(this.buf,this.pos+=4);return new _t(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=Mo(this.buf,this.pos);return this.pos+=xt(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 $o(r){return new qo(r instanceof Uint8Array?r:r.subarray())}function $t(r,t,e){let n=$o(r);return t.decode(n,void 0,e)}var zo={};St(zo,{base10:()=>_h});var _h=Be({prefix:"9",name:"base10",alphabet:"0123456789"});var Go={};St(Go,{base16:()=>Ph,base16upper:()=>Oh});var Ph=ot({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Oh=ot({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Wo={};St(Wo,{base2:()=>Vh});var Vh=ot({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jo={};St(jo,{base256emoji:()=>Kh});var rc=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}"),Dh=rc.reduce((r,t,e)=>(r[e]=t,r),[]),Mh=rc.reduce((r,t,e)=>{let n=t.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${t}`);return r[n]=e,r},[]);function Fh(r){return r.reduce((t,e)=>(t+=Dh[e],t),"")}function Hh(r){let t=[];for(let e of r){let n=e.codePointAt(0);if(n==null)throw new Error(`Invalid character: ${e}`);let s=Mh[n];if(s==null)throw new Error(`Non-base256emoji character: ${e}`);t.push(s)}return new Uint8Array(t)}var Kh=nr({prefix:"\u{1F680}",name:"base256emoji",encode:Fh,decode:Hh});var Yo={};St(Yo,{base64:()=>qh,base64pad:()=>$h,base64url:()=>Zo,base64urlpad:()=>zh});var qh=ot({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$h=ot({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zo=ot({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),zh=ot({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Jo={};St(Jo,{base8:()=>Gh});var Gh=ot({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Xo={};St(Xo,{identity:()=>Wh});var Wh=nr({prefix:"\0",name:"identity",encode:r=>fa(r),decode:r=>ua(r)});var Tm=new TextEncoder,Um=new TextDecoder;var ei={};St(ei,{sha256:()=>Mr,sha512:()=>Yh});function ti({name:r,code:t,encode:e}){return new Qo(r,t,e)}var Qo=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 sc(r){return async t=>new Uint8Array(await crypto.subtle.digest(r,t))}var Mr=ti({name:"sha2-256",code:18,encode:sc("SHA-256")}),Yh=ti({name:"sha2-512",code:19,encode:sc("SHA-512")});var Fr={...Xo,...Wo,...Jo,...zo,...Go,...lo,...uo,...co,...Yo,...jo},qm={...ei,...po};function ic(r,t,e,n){return{name:r,prefix:t,encoder:{name:r,prefix:t,encode:e},decoder:{decode:n}}}var oc=ic("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),ri=ic("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=Ut(r.length);for(let e=0;e<r.length;e++)t[e]=r.charCodeAt(e);return t}),Jh={utf8:oc,"utf-8":oc,hex:Fr.base16,latin1:ri,ascii:ri,binary:ri,...Fr},Pn=Jh;function $(r,t="utf8"){let e=Pn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.decoder.decode(`${e.prefix}${r}`)}function ni(r){let t=r??8192,e=t>>>1,n,s=t;return function(i){if(i<1||i>e)return Ut(i);s+i>t&&(n=Ut(t),s=0);let c=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),c}}var je=class{fn;len;next;val;constructor(t,e,n){this.fn=t,this.len=e,this.next=void 0,this.val=n}};function si(){}var ii=class{head;tail;len;next;constructor(t){this.head=t.head,this.tail=t.tail,this.len=t.len,this.next=t.states}},Xh=ni();function Qh(r){return globalThis.Buffer!=null?Ut(r):Xh(r)}var Kr=class{len;head;tail;states;constructor(){this.len=0,this.head=new je(si,0,0),this.tail=this.head,this.states=null}_push(t,e,n){return this.tail=this.tail.next=new je(t,e,n),this.len+=e,this}uint32(t){return this.len+=(this.tail=this.tail.next=new ai((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(On,10,_t.fromNumber(t)):this.uint32(t)}sint32(t){return this.uint32((t<<1^t>>31)>>>0)}uint64(t){let e=_t.fromBigInt(t);return this._push(On,e.length(),e)}uint64Number(t){return this._push(Do,xt(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=_t.fromBigInt(t).zzEncode();return this._push(On,e.length(),e)}sint64Number(t){let e=_t.fromNumber(t).zzEncode();return this._push(On,e.length(),e)}sint64String(t){return this.sint64(BigInt(t))}bool(t){return this._push(oi,1,t?1:0)}fixed32(t){return this._push(Hr,4,t>>>0)}sfixed32(t){return this.fixed32(t)}fixed64(t){let e=_t.fromBigInt(t);return this._push(Hr,4,e.lo)._push(Hr,4,e.hi)}fixed64Number(t){let e=_t.fromNumber(t);return this._push(Hr,4,e.lo)._push(Hr,4,e.hi)}fixed64String(t){return this.fixed64(BigInt(t))}sfixed64(t){return this.fixed64(t)}sfixed64Number(t){return this.fixed64Number(t)}sfixed64String(t){return this.fixed64String(t)}float(t){return this._push(ja,4,t)}double(t){return this._push(Ya,8,t)}bytes(t){let e=t.length>>>0;return e===0?this._push(oi,1,0):this.uint32(e)._push(ed,e,t)}string(t){let e=Qa(t);return e!==0?this.uint32(e)._push(Ko,e,t):this._push(oi,1,0)}fork(){return this.states=new ii(this),this.head=this.tail=new je(si,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 je(si,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=Qh(this.len),n=0;for(;t!=null;)t.fn(t.val,e,n),n+=t.len,t=t.next;return e}};function oi(r,t,e){t[e]=r&255}function td(r,t,e){for(;r>127;)t[e++]=r&127|128,r>>>=7;t[e]=r}var ai=class extends je{next;constructor(t,e){super(td,t,e),this.next=void 0}};function On(r,t,e){for(;r.hi!==0;)t[e++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)t[e++]=r.lo&127|128,r.lo=r.lo>>>7;t[e++]=r.lo}function Hr(r,t,e){t[e]=r&255,t[e+1]=r>>>8&255,t[e+2]=r>>>16&255,t[e+3]=r>>>24}function ed(r,t,e){t.set(r,e)}globalThis.Buffer!=null&&(Kr.prototype.bytes=function(r){let t=r.length>>>0;return this.uint32(t),t>0&&this._push(rd,t,r),this},Kr.prototype.string=function(r){let t=globalThis.Buffer.byteLength(r);return this.uint32(t),t>0&&this._push(nd,t,r),this});function rd(r,t,e){t.set(r,e)}function nd(r,t,e){r.length<40?Ko(r,t,e):t.utf8Write!=null?t.utf8Write(r,e):t.set($(r),e)}function ci(){return new Kr}function zt(r,t){let e=ci();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 li(r){function t(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let e=function(o,i){let c=t(o);i.int32(c)},n=function(o){let i=o.int32();return t(i)};return Vn("enum",hr.VARINT,e,n)}function Gt(r,t){return Vn("message",hr.LENGTH_DELIMITED,r,t)}var Ze=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var ct;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ct||(ct={}));var ui;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(ui||(ui={}));(function(r){r.codec=()=>li(ui)})(ct||(ct={}));var Qt;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ct.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{o.Type=ct.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(Qt||(Qt={}));var fi;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.Type!=null&&(n.uint32(8),ct.codec().encode(e.Type,n)),e.Data!=null&&(n.uint32(18),n.bytes(e.Data)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{o.Type=ct.codec().decode(e);break}case 2:{o.Data=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(fi||(fi={}));var Xr={};St(Xr,{MAX_RSA_KEY_SIZE:()=>Ns,generateRSAKeyPair:()=>nl,jwkToJWKKeyPair:()=>sl,jwkToPkcs1:()=>wd,jwkToPkix:()=>xi,jwkToRSAPrivateKey:()=>rl,pkcs1ToJwk:()=>Qc,pkcs1ToRSAPrivateKey:()=>el,pkixToJwk:()=>tl,pkixToRSAPublicKey:()=>vi});var sd=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]),Re=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_e=new Uint32Array(64),hi=class extends ur{constructor(){super(64,32,8,!1),this.A=Re[0]|0,this.B=Re[1]|0,this.C=Re[2]|0,this.D=Re[3]|0,this.E=Re[4]|0,this.F=Re[5]|0,this.G=Re[6]|0,this.H=Re[7]|0}get(){let{A:t,B:e,C:n,D:s,E:o,F:i,G:c,H:a}=this;return[t,e,n,s,o,i,c,a]}set(t,e,n,s,o,i,c,a){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=c|0,this.H=a|0}process(t,e){for(let f=0;f<16;f++,e+=4)_e[f]=t.getUint32(e,!1);for(let f=16;f<64;f++){let h=_e[f-15],m=_e[f-2],p=Ft(h,7)^Ft(h,18)^h>>>3,b=Ft(m,17)^Ft(m,19)^m>>>10;_e[f]=b+_e[f-7]+p+_e[f-16]|0}let{A:n,B:s,C:o,D:i,E:c,F:a,G:l,H:u}=this;for(let f=0;f<64;f++){let h=Ft(c,6)^Ft(c,11)^Ft(c,25),m=u+h+Na(c,a,l)+sd[f]+_e[f]|0,b=(Ft(n,2)^Ft(n,13)^Ft(n,22))+Ca(n,s,o)|0;u=l,l=a,a=c,c=i+m|0,i=o,o=s,s=n,n=m+b|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,s,o,i,c,a,l,u)}roundClean(){_e.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var dr=xn(()=>new hi);var M=ro(cc());function Ye(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 Pe(r,t,e=-1){let n=e,s=r,o=0,i=Math.pow(2,t);for(let c=1;c<8;c++){if(r<i){let a;if(n<0)a=new ArrayBuffer(c),o=c;else{if(n<c)return new ArrayBuffer(0);a=new ArrayBuffer(n),o=n}let l=new Uint8Array(a);for(let u=c-1;u>=0;u--){let f=Math.pow(2,u*t);l[o-u-1]=Math.floor(s/f),s-=l[o-u-1]*f}return a}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function Fn(...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 pi(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let c=r[0]===255&&r[1]&128,a=r[0]===0&&(r[1]&128)===0;(c||a)&&this.warnings.push("Needlessly long format")}let t=new ArrayBuffer(this.valueHex.byteLength),e=new Uint8Array(t);for(let c=0;c<this.valueHex.byteLength;c++)e[c]=0;e[0]=r[0]&128;let n=Ye(e,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let c=0;c<this.valueHex.byteLength;c++)o[c]=r[c];return o[0]&=127,Ye(o,8)-n}function lc(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,c=Pe(i,8,n),a=new Uint8Array(c);return a[0]|=128,c}let s=Pe(t,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),c=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let a=0;a<i.byteLength;a++)o[a+1]=c[a];o[0]=0}return s}e*=Math.pow(2,8)}return new ArrayBuffer(0)}function uc(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 Lt(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 Ag=Math.log(2);function Hn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function mi(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 be(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 $r=class{constructor(){this.items=[]}write(t){this.items.push(t)}final(){return mi(this.items)}},qr=[new Uint8Array([1])],fc="0123456789";var br="",Wt=new ArrayBuffer(0),gi=new Uint8Array(0),zr="EndOfContent",dc="OCTET STRING",pc="BIT STRING";function we(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?M.BufferSourceConverter.toUint8Array(o.valueHex):gi}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(!be(this,i,s,o))return-1;let c=s+o;return this.valueHexView=i.subarray(s,c),this.valueHexView.length?(this.blockLength=o,c):(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",Wt)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}var me=class{constructor({blockLength:t=0,error:e=br,warnings:n=[],valueBeforeDecode:s=gi}={}){this.blockLength=t,this.error=e,this.warnings=n,this.valueBeforeDecodeView=M.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:M.Convert.ToHex(this.valueBeforeDecodeView)}}};me.NAME="baseBlock";var Et=class extends me{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 Kn=class extends we(me){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?M.BufferSourceConverter.toUint8Array(t.valueHex):gi,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",Wt}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=Pe(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,c=new Uint8Array(i+1);if(c[0]=e|31,!t){for(let a=0;a<i-1;a++)c[a+1]=o[a]|128;c[i]=o[i-1]}return c.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=M.BufferSourceConverter.toUint8Array(t);if(!be(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 c=o[0]&31;if(c!==31)this.tagNumber=c,this.blockLength=1;else{let a=1,l=this.valueHexView=new Uint8Array(255),u=255;for(;o[a]&128;){if(l[a-1]=o[a]&127,a++,a>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(a===u){u+=255;let h=new Uint8Array(u);for(let m=0;m<l.length;m++)h[m]=l[m];l=this.valueHexView=new Uint8Array(u)}}this.blockLength=a+1,l[a-1]=o[a]&127;let f=new Uint8Array(a);for(let h=0;h<a;h++)f[h]=l[h];l=this.valueHexView=new Uint8Array(a),l.set(f),this.blockLength<=9?this.tagNumber=Ye(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 qn=class extends me{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=M.BufferSourceConverter.toUint8Array(t);if(!be(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 c=e+1,a=s.subarray(c,c+i);return a[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Ye(a,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=Pe(this.length,8);if(s.byteLength>127)return this.error="Too big length",Wt;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}}};qn.NAME="lengthBlock";var B={},mt=class extends me{constructor({name:t=br,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 qn(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 $r;e||mc(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?Wt: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():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.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 uc(e,n)}};mt.NAME="BaseBlock";function mc(r){if(r instanceof B.Constructed)for(let t of r.valueBlock.value)mc(t)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var $n=class extends mt{constructor({value:t=br,...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}'`}};$n.NAME="BaseStringBlock";var zn=class extends we(Et){constructor({isHexOnly:t=!0,...e}={}){super(e),this.isHexOnly=t}};zn.NAME="PrimitiveValueBlock";var gc,Gn=class extends mt{constructor(t={}){super(t,zn),this.idBlock.isConstructed=!1}};gc=Gn;B.Primitive=gc;Gn.NAME="PRIMITIVE";function dd(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 Is(r,t=0,e=r.length){let n=t,s=new mt({},Et),o=new me;if(!be(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 c=s.idBlock.fromBER(r,t,e);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),c===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(t=c,e-=s.idBlock.blockLength,c=s.lenBlock.fromBER(r,t,e),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),c===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(t=c,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 a=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};a=B.EndOfContent;break;case 1:a=B.Boolean;break;case 2:a=B.Integer;break;case 3:a=B.BitString;break;case 4:a=B.OctetString;break;case 5:a=B.Null;break;case 6:a=B.ObjectIdentifier;break;case 10:a=B.Enumerated;break;case 12:a=B.Utf8String;break;case 13:a=B.RelativeObjectIdentifier;break;case 14:a=B.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:a=B.Sequence;break;case 17:a=B.Set;break;case 18:a=B.NumericString;break;case 19:a=B.PrintableString;break;case 20:a=B.TeletexString;break;case 21:a=B.VideotexString;break;case 22:a=B.IA5String;break;case 23:a=B.UTCTime;break;case 24:a=B.GeneralizedTime;break;case 25:a=B.GraphicString;break;case 26:a=B.VisibleString;break;case 27:a=B.GeneralString;break;case 28:a=B.UniversalString;break;case 29:a=B.CharacterString;break;case 30:a=B.BmpString;break;case 31:a=B.DATE;break;case 32:a=B.TimeOfDay;break;case 33:a=B.DateTime;break;case 34:a=B.Duration;break;default:{let l=s.idBlock.isConstructed?new B.Constructed:new B.Primitive;l.idBlock=s.idBlock,l.lenBlock=s.lenBlock,l.warnings=s.warnings,s=l}}break;case 2:case 3:case 4:default:a=s.idBlock.isConstructed?B.Constructed:B.Primitive}return s=dd(s,a),c=s.fromBER(r,t,s.lenBlock.isIndefiniteForm?e:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:c,result:s}}function yi(r){if(!r.byteLength){let t=new mt({},Et);return t.error="Input buffer has zero length",{offset:-1,result:t}}return Is(M.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function pd(r,t){return r?1:t}var te=class extends Et{constructor({value:t=[],isIndefiniteForm:e=!1,...n}={}){super(n),this.value=t,this.isIndefiniteForm=e}fromBER(t,e,n){let s=M.BufferSourceConverter.toUint8Array(t);if(!be(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(;pd(this.isIndefiniteForm,n)>0;){let i=Is(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===zr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===zr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(t,e){let n=e||new $r;for(let s=0;s<this.value.length;s++)this.value[s].toBER(t,n);return e?Wt:n.final()}toJSON(){let t={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let e of this.value)t.value.push(e.toJSON());return t}};te.NAME="ConstructedValueBlock";var yc,Oe=class extends mt{constructor(t={}){super(t,te),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} :`}};gc=Oe;B.Constructed=gc;Oe.NAME="CONSTRUCTED";var Wn=class extends Et{fromBER(t,e,n){return e}toBER(t){return Wt}};Wn.override="EndOfContentValueBlock";var yc,jn=class extends mt{constructor(t={}){super(t,Wn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};yc=jn;B.EndOfContent=yc;jn.NAME=zr;var bc,mr=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}`}};bc=mr;B.Null=bc;mr.NAME="NULL";var Zn=class extends we(Et){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=M.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=M.BufferSourceConverter.toUint8Array(t);return be(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,hi.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Zn.NAME="BooleanValueBlock";var wc,Yn=class extends mt{constructor(t={}){super(t,Zn),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}`}};wc=Yn;B.Boolean=wc;Yn.NAME="BOOLEAN";var Jn=class extends we(te){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=te.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==hc)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?te.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Jn.NAME="OctetStringValueBlock";var xc,Xn=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},Jn),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=Is(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?Oe.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${M.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 M.BufferSourceConverter.concat(t)}};xc=Xn;B.OctetString=xc;Xn.NAME=hc;var Qn=class extends we(te){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=te.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let c of this.value){let a=c.constructor.NAME;if(a===zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(a!==dc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=c.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=M.BufferSourceConverter.toUint8Array(t);if(!be(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 c=i.subarray(1);try{if(c.byteLength){let a=Is(c,0,c.byteLength);a.offset!==-1&&a.offset===n-1&&(this.value=[a.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,e+n}toBER(t,e){if(this.isConstructed)return te.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Wt;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}}};Qn.NAME="BitStringValueBlock";var vc,gr=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},Qn),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 Oe.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)}`}}};vc=gr;B.BitString=vc;gr.NAME=dc;var Ec;function sd(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,c=s.slice(0),a=c.length-1,l=0,u=a<i?i:a,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<c.length:l=o[i-f]+c[a-f]+e[0];break;default:l=o[i-f]+e[0]}switch(e[0]=l/10,!0){case f>=o.length:o=Fn(new Uint8Array([l%10]),o);break;default:o[i-f]=l%10}}return e[0]>0&&(o=Fn(e,o)),o}function fc(r){if(r>=qr.length)for(let t=qr.length;t<=r;t++){let e=new Uint8Array([0]),n=qr[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=Fn(e,n)),qr.push(n)}return qr[r]}function od(r,t){let e=0,n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,c=s.slice(0),a=c.length-1,l,u=0;for(let f=a;f>=0;f--,u++)switch(l=o[i-u]-c[a-u]-e,!0){case l<0:e=1,o[i-u]=l+10;break;default:e=0,o[i-u]=l}if(e>0)for(let f=i-a+1;f>=0;f--,u++)if(l=o[i-u]-e,l<0)e=1,o[i-u]=l+10;else{e=0,o[i-u]=l;break}return o.slice()}var Gr=class extends we(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=hi.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(cc(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="",c=!1;for(let a=o.byteLength-1;a>=0;a--){s=o[a];for(let l=0;l<8;l++){if((s&1)===1)switch(n){case t:e=od(fc(n),e),i="-";break;default:e=sd(e,fc(n))}n++,s>>=1}}for(let a=0;a<e.length;a++)e[a]&&(c=!0),c&&(i+=uc.charAt(e[a]));return c===!1&&(i+=uc.charAt(0)),i}};Ec=Gr;Gr.NAME="IntegerValueBlock";Object.defineProperty(Ec.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Bc,gt=class r extends mt{constructor(t={}){super(t,Gr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Hn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){Hn();let e=BigInt(t),n=new $r,s=e.toString(16).replace(/^-/,""),o=new Uint8Array(M.Convert.FromHex(s));if(e<0){let c=new Uint8Array(o.length+(o[0]&128?1:0));c[0]|=128;let l=BigInt(`0x${M.Convert.ToHex(c)}`)+e,u=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}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()}`}};Bc=gt;B.Integer=Bc;gt.NAME="INTEGER";var Ac,ts=class extends gt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Ac=ts;B.Enumerated=Ac;ts.NAME="ENUMERATED";var Wr=class extends we(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=M.BufferSourceConverter.toUint8Array(t);if(!be(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=o[c]&127,this.blockLength++,!!(o[c]&128));c++);let i=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)i[c]=this.valueHexView[c];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=Ye(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){Hn();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=Pe(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Wt;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=M.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}}};Wr.NAME="sidBlock";var es=class extends Et{constructor({value:t=br,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Wr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.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,Wt;e.push(s)}return di(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],c=0;switch(i.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}let a=parseInt(s,10);if(isNaN(a))return;i.valueDec=a+c,o=!1}else{let i=new Wr;if(s>Number.MAX_SAFE_INTEGER){Hn();let c=BigInt(s);i.valueBigInt=c}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}};es.NAME="ObjectIdentifierValueBlock";var Sc,yr=class extends mt{constructor(t={}){super(t,es),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()}}};Sc=yr;B.ObjectIdentifier=Sc;yr.NAME="OBJECT IDENTIFIER";var jr=class extends we(me){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let s=M.BufferSourceConverter.toUint8Array(t);if(!be(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=o[c]&127,this.blockLength++,!!(o[c]&128));c++);let i=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)i[c]=this.valueHexView[c];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=Ye(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=Pe(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Wt;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=M.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};jr.NAME="relativeSidBlock";var rs=class extends Et{constructor({value:t=br,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new jr;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,Wt;n.push(o)}return di(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 jr;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}};rs.NAME="RelativeObjectIdentifierValueBlock";var Ic,ns=class extends mt{constructor(t={}){super(t,rs),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()}}};Ic=ns;B.RelativeObjectIdentifier=Ic;ns.NAME="RelativeObjectIdentifier";var kc,ge=class extends Oe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};kc=ge;B.Sequence=kc;ge.NAME="SEQUENCE";var Cc,ss=class extends Oe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Cc=ss;B.Set=Cc;ss.NAME="SET";var os=class extends we(Et){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=br}toJSON(){return{...super.toJSON(),value:this.value}}};os.NAME="StringValueBlock";var is=class extends os{};is.NAME="SimpleStringValueBlock";var kt=class extends $n{constructor({...t}={}){super(t,is)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,M.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}};kt.NAME="SIMPLE STRING";var as=class extends kt{fromBuffer(t){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=M.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(t)),this.valueBlock.value=t}};as.NAME="Utf8StringValueBlock";var Nc,ye=class extends as{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Nc=ye;B.Utf8String=Nc;ye.NAME="UTF8String";var cs=class extends kt{fromBuffer(t){this.valueBlock.value=M.Convert.ToUtf16String(t),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(t))}};cs.NAME="BmpStringValueBlock";var Tc,ls=class extends cs{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Tc=ls;B.BmpString=Tc;ls.NAME="BMPString";var us=class extends kt{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=Pe(t.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let c=4-i.length;for(let a=i.length-1;a>=0;a--)n[s*4+a+c]=i[a]}this.valueBlock.value=t}};us.NAME="UniversalStringValueBlock";var Uc,fs=class extends us{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Uc=fs;B.UniversalString=Uc;fs.NAME="UniversalString";var Lc,hs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Lc=hs;B.NumericString=Lc;hs.NAME="NumericString";var Rc,ds=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};Rc=ds;B.PrintableString=Rc;ds.NAME="PrintableString";var _c,ps=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};_c=ps;B.TeletexString=_c;ps.NAME="TeletexString";var Pc,ms=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Pc=ms;B.VideotexString=Pc;ms.NAME="VideotexString";var Oc,gs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Oc=gs;B.IA5String=Oc;gs.NAME="IA5String";var Vc,ys=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Vc=ys;B.GraphicString=Vc;ys.NAME="GraphicString";var Dc,Zr=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Dc=Zr;B.VisibleString=Dc;Zr.NAME="VisibleString";var Mc,bs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Mc=bs;B.GeneralString=Mc;bs.NAME="GeneralString";var Fc,ws=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Fc=ws;B.CharacterString=Fc;ws.NAME="CharacterString";var Hc,Yr=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,M.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]=Lt(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Lt(this.month,2),e[2]=Lt(this.day,2),e[3]=Lt(this.hour,2),e[4]=Lt(this.minute,2),e[5]=Lt(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}}};Hc=Yr;B.UTCTime=Hc;Yr.NAME="UTCTime";var Kc,xs=class extends Yr{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,c=0,a=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let f=new Number(t[t.length-1]);if(isNaN(f.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 f=1,h=n.indexOf("+"),m="";if(h===-1&&(h=n.indexOf("-"),f=-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 p=parseInt(m.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(c=f*p,m.length===4){if(p=parseInt(m.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");a=f*p}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");o=f.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 f=60*o;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*o;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*o;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=i.exec(s);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+c;break;case 5:this.minute=parseInt(u[f],10)+a;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(Lt(this.year,4)),e.push(Lt(this.month,2)),e.push(Lt(this.day,2)),e.push(Lt(this.hour,2)),e.push(Lt(this.minute,2)),e.push(Lt(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Lt(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Kc=xs;B.GeneralizedTime=Kc;xs.NAME="GeneralizedTime";var qc,vs=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};qc=vs;B.DATE=qc;vs.NAME="DATE";var $c,Es=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};$c=Es;B.TimeOfDay=$c;Es.NAME="TimeOfDay";var zc,Bs=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};zc=Bs;B.DateTime=zc;Bs.NAME="DateTime";var Gc,As=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Gc=As;B.Duration=Gc;As.NAME="Duration";var Wc,Ss=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Wc=Ss;B.TIME=Wc;Ss.NAME="TIME";function Q(r,t="utf8"){let e=Pn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Jr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},ks=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var jc={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new ks("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");return t}};var Ve=jc;async function Zc(r){let t=await Ve.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 ad(t);return{privateKey:e[0],publicKey:e[1]}}async function Yc(r,t){let e=await Ve.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ve.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},e,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}async function Jc(r,t,e){let n=await Ve.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ve.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function ad(r){if(r.privateKey==null||r.publicKey==null)throw new It("Private and public key are required");return Promise.all([Ve.get().subtle.exportKey("jwk",r.privateKey),Ve.get().subtle.exportKey("jwk",r.publicKey)])}function gi(r){if(r.kty!=="RSA")throw new It("invalid key type");if(r.n==null)throw new It("invalid key modulus");return $(r.n,"base64url").length*8}var wr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=Xr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return dt.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return Jc(this._key,e,t)}},Qr=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=Xr.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}sign(t){return Yc(this._key,t)}};var Cs=8192,yi=18;function Xc(r){let{result:t}=mi(r),e=t.valueBlock.value;return{n:ee(e[1]),e:ee(e[2]),d:ee(e[3]),p:ee(e[4]),q:ee(e[5]),dp:ee(e[6]),dq:ee(e[7]),qi:ee(e[8]),kty:"RSA",alg:"RS256"}}function cd(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 It("JWK was missing components");let e=new ge({value:[new gt({value:0}),gt.fromBigInt(re($(r.n,"base64url"))),gt.fromBigInt(re($(r.e,"base64url"))),gt.fromBigInt(re($(r.d,"base64url"))),gt.fromBigInt(re($(r.p,"base64url"))),gt.fromBigInt(re($(r.q,"base64url"))),gt.fromBigInt(re($(r.dp,"base64url"))),gt.fromBigInt(re($(r.dq,"base64url"))),gt.fromBigInt(re($(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function Qc(r){let{result:t}=mi(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ee(e[0]),e:ee(e[1])}}function bi(r){if(r.n==null||r.e==null)throw new It("JWK was missing components");let e=new ge({value:[new ge({value:[new yr({value:"1.2.840.113549.1.1.1"}),new mr]}),new gr({valueHex:new ge({value:[gt.fromBigInt(re($(r.n,"base64url"))),gt.fromBigInt(re($(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function ee(r){let t=r.valueBlock.valueHexView;for(;t[0]===0;)t=t.subarray(1);return Q(t,"base64url")}function re(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(""))}function tl(r){let t=Xc(r);return el(t)}function wi(r){let t=Qc(r);if(gi(t)>Cs)throw new rr("Key size is too large");let e=dr(Qt.encode({Type:ct.RSA,Data:r})),n=Mt(yi,e);return new wr(t,n)}function el(r){if(gi(r)>Cs)throw new It("Key size is too large");let t=nl(r),e=dr(Qt.encode({Type:ct.RSA,Data:bi(t.publicKey)})),n=Mt(yi,e);return new Qr(t.privateKey,new wr(t.publicKey,n))}async function rl(r){if(r>Cs)throw new It("Key size is too large");let t=await Zc(r),e=dr(Qt.encode({Type:ct.RSA,Data:bi(t.publicKey)})),n=Mt(yi,e);return new Qr(t.privateKey,new wr(t.publicKey,n))}function nl(r){if(r==null)throw new It("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Ns=class extends lr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Aa(t);let n=Pr(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 cr(this),this.iHash.update(t),this}digestInto(t){cr(this),ar(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:c}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},xi=(r,t,e)=>new Ns(r,t).update(e).digest();xi.create=(r,t)=>new Ns(r,t);function sl(r){r.lowS!==void 0&&Ht("lowS",r.lowS),r.prehash!==void 0&&Ht("prehash",r.prehash)}function ld(r){let t=Dr(r);Xt(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("invalid 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("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:ud,hexToBytes:fd}=Sn,vi=class extends Error{constructor(t=""){super(t)}},xe={Err:vi,_tlv:{encode:(r,t)=>{let{Err:e}=xe;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,s=Ke(n);if(s.length/2&128)throw new e("tlv.encode: long form length too big");let o=n>127?Ke(s.length/2|128):"";return Ke(r)+o+s+t},decode(r,t){let{Err:e}=xe,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let s=t[n++],o=!!(s&128),i=0;if(!o)i=s;else{let a=s&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+a);if(l.length!==a)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=xe;if(r<ve)throw new t("integer: negative integers are not allowed");let e=Ke(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=xe;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return ud(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=xe,s=typeof r=="string"?fd(r):r;fr(s);let{v:o,l:i}=n.decode(48,s);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,o),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=xe,n=t.encode(2,e.encode(r.r)),s=t.encode(2,e.encode(r.s)),o=n+s;return t.encode(48,o)}},ve=BigInt(0),ft=BigInt(1),$g=BigInt(2),ol=BigInt(3),zg=BigInt(4);function hd(r){let t=ld(r),{Fp:e}=t,n=Te(t.n,t.nBitLength),s=t.toBytes||((b,d,v)=>{let A=d.toAffine();return he(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),o=t.fromBytes||(b=>{let d=b.subarray(1),v=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:v,y:A}});function i(b){let{a:d,b:v}=t,A=e.sqr(b),y=e.mul(A,b);return e.add(e.add(y,e.mul(b,d)),v)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(b){return Or(b,ft,t.n)}function a(b){let{allowedPrivateKeyLengths:d,nByteLength:v,wrapPrivateKey:A,n:y}=t;if(d&&typeof b!="bigint"){if(ke(b)&&(b=ue(b)),typeof b!="string"||!d.includes(b.length))throw new Error("invalid private key");b=b.padStart(v*2,"0")}let I;try{I=typeof b=="bigint"?b:fe(nt("private key",b,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof b)}return A&&(I=Z(I,y)),Nt("private key",I,ft,y),I}function l(b){if(!(b instanceof h))throw new Error("ProjectivePoint expected")}let u=ze((b,d)=>{let{px:v,py:A,pz:y}=b;if(e.eql(y,e.ONE))return{x:v,y:A};let I=b.is0();d==null&&(d=I?e.ONE:e.inv(y));let L=e.mul(v,d),U=e.mul(A,d),k=e.mul(y,d);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(k,e.ONE))throw new Error("invZ was invalid");return{x:L,y:U}}),f=ze(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:d,y:v}=b.toAffine();if(!e.isValid(d)||!e.isValid(v))throw new Error("bad point: x or y not FE");let A=e.sqr(v),y=i(d);if(!e.eql(A,y))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,v,A){if(this.px=d,this.py=v,this.pz=A,d==null||!e.isValid(d))throw new Error("x required");if(v==null||!e.isValid(v))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:v,y:A}=d||{};if(!d||!e.isValid(v)||!e.isValid(A))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=I=>e.eql(I,e.ZERO);return y(v)&&y(A)?h.ZERO:new h(v,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let v=e.invertBatch(d.map(A=>A.pz));return d.map((A,y)=>A.toAffine(v[y])).map(h.fromAffine)}static fromHex(d){let v=h.fromAffine(o(nt("pointHex",d)));return v.assertValidity(),v}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,v){return Nn(h,n,d,v)}_setWindowSize(d){p.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:v,py:A,pz:y}=this,{px:I,py:L,pz:U}=d,k=e.eql(e.mul(v,U),e.mul(I,y)),T=e.eql(e.mul(A,U),e.mul(L,y));return k&&T}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:v}=t,A=e.mul(v,ol),{px:y,py:I,pz:L}=this,U=e.ZERO,k=e.ZERO,T=e.ZERO,C=e.mul(y,y),tt=e.mul(I,I),q=e.mul(L,L),D=e.mul(y,I);return D=e.add(D,D),T=e.mul(y,L),T=e.add(T,T),U=e.mul(d,T),k=e.mul(A,q),k=e.add(U,k),U=e.sub(tt,k),k=e.add(tt,k),k=e.mul(U,k),U=e.mul(D,U),T=e.mul(A,T),q=e.mul(d,q),D=e.sub(C,q),D=e.mul(d,D),D=e.add(D,T),T=e.add(C,C),C=e.add(T,C),C=e.add(C,q),C=e.mul(C,D),k=e.add(k,C),q=e.mul(I,L),q=e.add(q,q),C=e.mul(q,D),U=e.sub(U,C),T=e.mul(q,tt),T=e.add(T,T),T=e.add(T,T),new h(U,k,T)}add(d){l(d);let{px:v,py:A,pz:y}=this,{px:I,py:L,pz:U}=d,k=e.ZERO,T=e.ZERO,C=e.ZERO,tt=t.a,q=e.mul(t.b,ol),D=e.mul(v,I),it=e.mul(A,L),E=e.mul(y,U),N=e.add(v,A),w=e.add(I,L);N=e.mul(N,w),w=e.add(D,it),N=e.sub(N,w),w=e.add(v,y);let g=e.add(I,U);return w=e.mul(w,g),g=e.add(D,E),w=e.sub(w,g),g=e.add(A,y),k=e.add(L,U),g=e.mul(g,k),k=e.add(it,E),g=e.sub(g,k),C=e.mul(tt,w),k=e.mul(q,E),C=e.add(k,C),k=e.sub(it,C),C=e.add(it,C),T=e.mul(k,C),it=e.add(D,D),it=e.add(it,D),E=e.mul(tt,E),w=e.mul(q,w),it=e.add(it,E),E=e.sub(D,E),E=e.mul(tt,E),w=e.add(w,E),D=e.mul(it,w),T=e.add(T,D),D=e.mul(g,w),k=e.mul(N,k),k=e.sub(k,D),D=e.mul(N,it),C=e.mul(g,C),C=e.add(C,D),new h(k,T,C)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return p.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:v,n:A}=t;Nt("scalar",d,ve,A);let y=h.ZERO;if(d===ve)return y;if(this.is0()||d===ft)return this;if(!v||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:I,k1:L,k2neg:U,k2:k}=v.splitScalar(d),T=y,C=y,tt=this;for(;L>ve||k>ve;)L&ft&&(T=T.add(tt)),k&ft&&(C=C.add(tt)),tt=tt.double(),L>>=ft,k>>=ft;return I&&(T=T.negate()),U&&(C=C.negate()),C=new h(e.mul(C.px,v.beta),C.py,C.pz),T.add(C)}multiply(d){let{endo:v,n:A}=t;Nt("scalar",d,ft,A);let y,I;if(v){let{k1neg:L,k1:U,k2neg:k,k2:T}=v.splitScalar(d),{p:C,f:tt}=this.wNAF(U),{p:q,f:D}=this.wNAF(T);C=p.constTimeNegate(L,C),q=p.constTimeNegate(k,q),q=new h(e.mul(q.px,v.beta),q.py,q.pz),y=C.add(q),I=tt.add(D)}else{let{p:L,f:U}=this.wNAF(d);y=L,I=U}return h.normalizeZ([y,I])[0]}multiplyAndAddUnsafe(d,v,A){let y=h.BASE,I=(U,k)=>k===ve||k===ft||!U.equals(y)?U.multiplyUnsafe(k):U.multiply(k),L=I(this,v).add(I(d,A));return L.is0()?void 0:L}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:v}=t;if(d===ft)return!0;if(v)return v(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:v}=t;return d===ft?this:v?v(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Ht("isCompressed",d),this.assertValidity(),s(h,this,d)}toHex(d=!0){return Ht("isCompressed",d),ue(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let m=t.nBitLength,p=Cn(h,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function dd(r){let t=Dr(r);return Xt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function il(r){let t=dd(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return Z(E,n)}function c(E){return In(E,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=hd({...t,toBytes(E,N,w){let g=N.toAffine(),x=e.toBytes(g.x),S=he;return Ht("isCompressed",w),w?S(Uint8Array.from([N.hasEvenY()?2:3]),x):S(Uint8Array.from([4]),x,e.toBytes(g.y))},fromBytes(E){let N=E.length,w=E[0],g=E.subarray(1);if(N===s&&(w===2||w===3)){let x=fe(g);if(!Or(x,ft,e.ORDER))throw new Error("Point is not on curve");let S=u(x),R;try{R=e.sqrt(S)}catch(F){let P=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+P)}let _=(R&ft)===ft;return(w&1)===1!==_&&(R=e.neg(R)),{x,y:R}}else if(N===o&&w===4){let x=e.fromBytes(g.subarray(0,e.BYTES)),S=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x,y:S}}else{let x=s,S=o;throw new Error("invalid Point, expected length of "+x+", or uncompressed "+S+", got "+N)}}}),h=E=>ue(Ne(E,t.nByteLength));function m(E){let N=n>>ft;return E>N}function p(E){return m(E)?i(-E):E}let b=(E,N,w)=>fe(E.slice(N,w));class d{constructor(N,w,g){this.r=N,this.s=w,this.recovery=g,this.assertValidity()}static fromCompact(N){let w=t.nByteLength;return N=nt("compactSignature",N,w*2),new d(b(N,0,w),b(N,w,2*w))}static fromDER(N){let{r:w,s:g}=xe.toSig(nt("DER",N));return new d(w,g)}assertValidity(){Nt("r",this.r,ft,n),Nt("s",this.s,ft,n)}addRecoveryBit(N){return new d(this.r,this.s,N)}recoverPublicKey(N){let{r:w,s:g,recovery:x}=this,S=U(nt("msgHash",N));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let R=x===2||x===3?w+t.n:w;if(R>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=x&1?"03":"02",V=a.fromHex(_+h(R)),F=c(R),P=i(-S*F),j=i(g*F),J=a.BASE.multiplyAndAddUnsafe(V,P,j);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return qe(this.toDERHex())}toDERHex(){return xe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return qe(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let v={isValidPrivateKey(E){try{return l(E),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let E=Ao(t.n);return Va(t.randomBytes(E),t.n)},precompute(E=8,N=a.BASE){return N._setWindowSize(E),N.multiply(BigInt(3)),N}};function A(E,N=!0){return a.fromPrivateKey(E).toRawBytes(N)}function y(E){let N=ke(E),w=typeof E=="string",g=(N||w)&&E.length;return N?g===s||g===o:w?g===2*s||g===2*o:E instanceof a}function I(E,N,w=!0){if(y(E))throw new Error("first arg must be private key");if(!y(N))throw new Error("second arg must be public key");return a.fromHex(N).multiply(l(E)).toRawBytes(w)}let L=t.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");let N=fe(E),w=E.length*8-t.nBitLength;return w>0?N>>BigInt(w):N},U=t.bits2int_modN||function(E){return i(L(E))},k=Vr(t.nBitLength);function T(E){return Nt("num < 2^"+t.nBitLength,E,ve,k),Ne(E,t.nByteLength)}function C(E,N,w=tt){if(["recovered","canonical"].some(ut=>ut in w))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:x}=t,{lowS:S,prehash:R,extraEntropy:_}=w;S==null&&(S=!0),E=nt("msgHash",E),sl(w),R&&(E=nt("prehashed msgHash",g(E)));let V=U(E),F=l(N),P=[T(F),T(V)];if(_!=null&&_!==!1){let ut=_===!0?x(e.BYTES):_;P.push(nt("extraEntropy",ut))}let j=he(...P),J=V;function lt(ut){let ht=L(ut);if(!f(ht))return;let yt=c(ht),Ct=a.BASE.multiply(ht).toAffine(),At=i(Ct.x);if(At===ve)return;let Jt=i(yt*i(J+At*F));if(Jt===ve)return;let oe=(Ct.x===At?0:2)|Number(Ct.y&ft),Nr=Jt;return S&&m(Jt)&&(Nr=p(Jt),oe^=1),new d(At,Nr,oe)}return{seed:j,k2sig:lt}}let tt={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function D(E,N,w=tt){let{seed:g,k2sig:x}=C(E,N,w),S=t;return xo(S.hash.outputLen,S.nByteLength,S.hmac)(g,x)}a.BASE._setWindowSize(8);function it(E,N,w,g=q){let x=E;N=nt("msgHash",N),w=nt("publicKey",w);let{lowS:S,prehash:R,format:_}=g;if(sl(g),"strict"in g)throw new Error("options.strict was renamed to lowS");if(_!==void 0&&_!=="compact"&&_!=="der")throw new Error("format must be compact or der");let V=typeof x=="string"||ke(x),F=!V&&!_&&typeof x=="object"&&x!==null&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!V&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let P,j;try{if(F&&(P=new d(x.r,x.s)),V){try{_!=="compact"&&(P=d.fromDER(x))}catch(oe){if(!(oe instanceof xe.Err))throw oe}!P&&_!=="der"&&(P=d.fromCompact(x))}j=a.fromHex(w)}catch{return!1}if(!P||S&&P.hasHighS())return!1;R&&(N=t.hash(N));let{r:J,s:lt}=P,ut=U(N),ht=c(lt),yt=i(ut*ht),Ct=i(J*ht),At=a.BASE.multiplyAndAddUnsafe(j,yt,Ct)?.toAffine();return At?i(At.x)===J:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:I,sign:D,verify:it,ProjectivePoint:a,Signature:d,utils:v}}function pd(r){return{hash:r,hmac:(t,...e)=>xi(r,t,ho(...e)),randomBytes:vn}}function al(r,t){let e=n=>il({...r,...pd(n)});return{...e(t),create:e}}var ul=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),cl=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),md=BigInt(1),Ei=BigInt(2),ll=(r,t)=>(r+t/Ei)/t;function gd(r){let t=ul,e=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=rt(u,e,t)*u%t,h=rt(f,e,t)*u%t,m=rt(h,Ei,t)*l%t,p=rt(m,s,t)*m%t,b=rt(p,o,t)*p%t,d=rt(b,c,t)*b%t,v=rt(d,a,t)*d%t,A=rt(v,c,t)*b%t,y=rt(A,e,t)*u%t,I=rt(y,i,t)*p%t,L=rt(I,n,t)*l%t,U=rt(L,Ei,t);if(!Bi.eql(Bi.sqr(U),r))throw new Error("Cannot find square root");return U}var Bi=Te(ul,void 0,void 0,{sqrt:gd}),Je=al({a:BigInt(0),b:BigInt(7),Fp:Bi,n:cl,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=cl,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-md*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),c=ll(o*r,t),a=ll(-n*r,t),l=Z(r-c*e-a*s,t),u=Z(-c*n-a*o,t),f=l>i,h=u>i;if(f&&(l=t-l),h&&(u=t-u),l>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},dr),ty=BigInt(0);var ey=Je.ProjectivePoint;function Pt(r,t){t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=Ut(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return e}function fl(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function hl(r,t,e){let n=Mr.digest(e instanceof Uint8Array?e:e.subarray());if(fl(n))return n.then(({digest:s})=>Je.verify(t,s,r)).catch(s=>{throw new Jr(String(s))});try{return Je.verify(t,n.digest,r)}catch(s){throw new Jr(String(s))}}var Ts=class{type="secp256k1";raw;_key;constructor(t){this._key=pl(t),this.raw=dl(this._key)}toMultihash(){return ce.digest(Ue(this))}toCID(){return dt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return hl(this._key,e,t)}};function Ai(r){return new Ts(r)}function dl(r){return Je.ProjectivePoint.fromHex(r).toRawBytes(!0)}function pl(r){try{return Je.ProjectivePoint.fromHex(r),r}catch(t){throw new rr(String(t))}}function xr(r){let{Type:t,Data:e}=Qt.decode(r),n=e??new Uint8Array;switch(t){case ct.RSA:return wi(n);case ct.Ed25519:return Uo(n);case ct.secp256k1:return Ai(n);default:throw new Me}}function ml(r){let{Type:t,Data:e}=Qt.decode(r.digest),n=e??new Uint8Array;switch(t){case ct.Ed25519:return Uo(n);case ct.secp256k1:return Ai(n);default:throw new Me}}function Ue(r){return Qt.encode({Type:ct[r.type],Data:r.raw})}var yl=Symbol.for("@achingbrain/uint8arraylist");function gl(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 Us(r){return!!r?.[yl]}var jt=class r{bufs;length;[yl]=!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(Us(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(Us(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=gl(this.bufs,t);return e.buf[e.index]}set(t,e){let n=gl(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(Us(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 Pt(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Pt(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],c=s,a=c+i.byteLength;if(s=a,t>=a)continue;let l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(i);break}let f=t-c;n.push(i.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Us(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 f=0;f<o;f++)i[f]=-1;for(let f=0;f<s;f++)i[n[f]]=f;let c=i,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=a;f+=u){u=0;for(let h=l;h>=0;h--){let m=this.get(f+h);if(n[h]!==m){u=Math.max(1,h-c[m]);break}}if(u===0)return f}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=Ut(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=pt(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=pt(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=pt(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=Ut(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=pt(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=pt(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=pt(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=pt(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=pt(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}};var tn;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.publicKey!=null&&e.publicKey.byteLength>0&&(n.uint32(10),n.bytes(e.publicKey)),e.payloadType!=null&&e.payloadType.byteLength>0&&(n.uint32(18),n.bytes(e.payloadType)),e.payload!=null&&e.payload.byteLength>0&&(n.uint32(26),n.bytes(e.payload)),e.signature!=null&&e.signature.byteLength>0&&(n.uint32(42),n.bytes(e.signature)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={publicKey:pt(0),payloadType:pt(0),payload:pt(0),signature:pt(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{o.publicKey=e.bytes();break}case 2:{o.payloadType=e.bytes();break}case 3:{o.payload=e.bytes();break}case 5:{o.signature=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(tn||(tn={}));var Ls=class extends Error{constructor(t="Invalid signature"){super(t),this.name="InvalidSignatureError"}};var ne=class r{static createFromProtobuf=async t=>{let e=tn.decode(t),n=xr(e.publicKey);return new r({publicKey:n,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};static seal=async(t,e)=>{if(e==null)throw new Error("Missing private key");let n=t.domain,s=t.codec,o=t.marshal(),i=bl(n,s,o),c=await e.sign(i.subarray());return new r({publicKey:e.publicKey,payloadType:s,payload:o,signature:c})};static openAndCertify=async(t,e)=>{let n=await r.createFromProtobuf(t);if(!await n.validate(e))throw new Ls("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(t){let{publicKey:e,payloadType:n,payload:s,signature:o}=t;this.publicKey=e,this.payloadType=n,this.payload=s,this.signature=o}marshal(){return this.marshaled==null&&(this.marshaled=tn.encode({publicKey:Ue(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return bt(this.marshal(),t.marshal())}async validate(t){let e=bl(t,this.payloadType,this.payload);return this.publicKey.verify(e.subarray(),this.signature)}},bl=(r,t,e)=>{let n=$(r),s=Ot(n.byteLength),o=Ot(t.length),i=Ot(e.length);return new jt(s,n,o,t,i,e)};var wl=Symbol.for("nodejs.util.inspect.custom"),yd=114,en=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[eo]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return dt.createV1(yd,this.multihash)}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 this.toString()===t;if(t?.toMultihash()?.bytes!=null)return bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[wl](){return`PeerId(${this.toString()})`}},rn=class extends en{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},nn=class extends en{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},sn=class extends en{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},bd=2336,on=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=ce.digest($(this.url))}[wl](){return`PeerId(${this.url})`}[eo]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return dt.createV1(bd,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=Q(t)),t.toString()===this.toString())}};var wd=114,xl=2336;function vl(r){if(r.type==="Ed25519")return new nn({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new sn({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new rn({multihash:r.toCID().multihash,publicKey:r});throw new Me}function Si(r){if(vd(r))return new rn({multihash:r});if(xd(r))try{let t=ml(r);if(t.type==="Ed25519")return new nn({multihash:r,publicKey:t});if(t.type==="secp256k1")return new sn({multihash:r,publicKey:t})}catch{let e=Q(r.digest);return new on(new URL(e))}throw new mn("Supplied PeerID Multihash is invalid")}function Rs(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==wd&&r.code!==xl)throw new pn("Supplied PeerID CID is invalid");if(r.code===xl){let t=Q(r.multihash.digest);return new on(new URL(t))}return Si(r.multihash)}function xd(r){return r.code===ce.code}function vd(r){return r.code===Mr.code}function El(r,t){let e=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==t.length?!1:(t.sort(e),r.sort(e).every((n,s)=>t[s].equals(n)))}var _s=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,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*s)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(o*=t,o+=u,o>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&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),[c]=t(o.subarray(0,i));return e.set(o.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Bl=45,Ed=15,vr=new _s;function Ps(r){if(!(r.length>Ed))return vr.new(r).parseWith(()=>vr.readIPv4Addr())}function Os(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Bl))return vr.new(r).parseWith(()=>vr.readIPv6Addr())}function Xe(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Bl)return;let e=vr.new(r).parseWith(()=>vr.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function Al(r,t,e){let n=0;for(let s of r)if(!(n<t)){if(n>e)break;if(s!==255)return!1;n++}return!0}function Sl(r,t,e,n){let s=0;for(let o of r)if(!(s<e)){if(s>n)break;if(o!==t[s])return!1;s++}return!0}function Ii(r){switch(r.length){case Qe:return r.join(".");case tr:{let t=[];for(let e=0;e<r.length;e++)e%2===0&&t.push(r[e].toString(16).padStart(2,"0")+r[e+1].toString(16).padStart(2,"0"));return t.join(":")}default:throw new Error("Invalid ip length")}}function Il(r){let t=0;for(let[e,n]of r.entries()){if(n===255){t+=8;continue}for(;n&128;)t++,n=n<<1;if(n&128)return-1;for(let s=e+1;s<r.length;s++)if(r[s]!=0)return-1;break}return t}function kl(r){let t="0x";for(let e of r)t+=(e>>4).toString(16)+(e&15).toString(16);return t}var Qe=4,tr=16,Tb=parseInt("0xFFFF",16),Bd=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function an(r,t){t.length===tr&&r.length===Qe&&Al(t,0,11)&&(t=t.slice(12)),t.length===Qe&&r.length===tr&&Sl(r,Bd,0,11)&&(r=r.slice(12));let e=r.length;if(e!=t.length)throw new Error("Failed to mask ip");let n=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=r[s]&t[s];return n}function Cl(r,t){if(typeof t=="string"&&(t=Xe(t)),t==null)throw new Error("Invalid ip");if(t.length!==r.network.length)return!1;for(let e=0;e<t.length;e++)if((r.network[e]&r.mask[e])!==(t[e]&r.mask[e]))return!1;return!0}function ki(r){let[t,e]=r.split("/");if(!t||!e)throw new Error("Failed to parse given CIDR: "+r);let n=Qe,s=Ps(t);if(s==null&&(n=tr,s=Os(t),s==null))throw new Error("Failed to parse given CIDR: "+r);let o=parseInt(e,10);if(Number.isNaN(o)||String(o).length!==e.length||o<0||o>n*8)throw new Error("Failed to parse given CIDR: "+r);let i=Ci(o,8*n);return{network:an(s,i),mask:i}}function Ci(r,t){if(t!==8*Qe&&t!==8*tr)throw new Error("Invalid CIDR mask");if(r<0||r>t)throw new Error("Invalid CIDR mask");let e=t/8,n=new Uint8Array(e);for(let s=0;s<e;s++){if(r>=8){n[s]=255,r-=8;continue}n[s]=255-(255>>r),r=0}return n}var Er=class{constructor(t,e){if(e==null)({network:this.network,mask:this.mask}=ki(t));else{let n=Xe(t);if(n==null)throw new Error("Failed to parse network");e=String(e);let s=parseInt(e,10);if(Number.isNaN(s)||String(s).length!==e.length||s<0||s>n.length*8){let o=Xe(e);if(o==null)throw new Error("Failed to parse mask");this.mask=o}else this.mask=Ci(s,8*n.length);this.network=an(n,this.mask)}}contains(t){return Cl({network:this.network,mask:this.mask},t)}toString(){let t=Il(this.mask),e=t!==-1?String(t):kl(this.mask);return Ii(this.network)+"/"+e}};function Nl(r,t){return new Er(r).contains(t)}function Br(r){return!!Ps(r)}function Ar(r){return!!Os(r)}function Vs(r){return!!Xe(r)}var Tl=Br,Ad=Ar,Ni=function(r){let t=0;if(r=r.toString().trim(),Tl(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=Tl(e[n]),i;o&&(i=Ni(e[n]),e[n]=Q(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,Q(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);s[t++]=o>>8&255,s[t++]=o&255}return s}throw new Error("invalid ip address")},Ul=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 Sr={},Ti={},Id=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Id.forEach(r=>{let t=kd(...r);Ti[t.code]=t,Sr[t.name]=t});function kd(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function z(r){if(typeof r=="number"){if(Ti[r]!=null)return Ti[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Sr[r]!=null)return Sr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var lw=z("ip4"),uw=z("ip6"),fw=z("ipcidr");function _i(r,t){switch(z(r).code){case 4:case 41:return Nd(t);case 42:return Ri(t);case 43:return Q(t,"base10");case 6:case 273:case 33:case 132:return _l(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Ri(t);case 421:return Rd(t);case 444:return Rl(t);case 445:return Rl(t);case 466:return Ld(t);case 481:return globalThis.encodeURIComponent(Ri(t));default:return Q(t,"base16")}}function Pi(r,t){switch(z(r).code){case 4:return Ll(t);case 41:return Ll(t);case 42:return Li(t);case 43:return $(t,"base10");case 6:case 273:case 33:case 132:return Oi(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Li(t);case 421:return Td(t);case 444:return _d(t);case 445:return Pd(t);case 466:return Ud(t);case 481:return Li(globalThis.decodeURIComponent(t));default:return $(t,"base16")}}var Ui=Object.values(Fr).map(r=>r.decoder),Cd=function(){let r=Ui[0].or(Ui[1]);return Ui.slice(2).forEach(t=>r=r.or(t)),r}();function Ll(r){if(!Vs(r))throw new Error("invalid ip address");return Ni(r)}function Nd(r){let t=Ul(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Vs(t))throw new Error("invalid ip address");return t}function Oi(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function _l(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function Li(r){let t=$(r),e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Ri(r){let t=de(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return Q(r)}function Td(r){let t;r[0]==="Q"||r[0]==="1"?t=Fe(X.decode(`z${r}`)).bytes:t=dt.parse(r).multihash.bytes;let e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Ud(r){let t=Cd.decode(r),e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Ld(r){let t=de(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+Q(e,"base64url")}function Rd(r){let t=de(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return Q(e,"base58btc")}function _d(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=ae.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=Oi(n);return Pt([e,s],e.length+s.length)}function Pd(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=ae.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=Oi(n);return Pt([e,s],e.length+s.length)}function Rl(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=Q(t,"base32"),s=_l(e);return`${n}:${s}`}function Pl(r){r=Vi(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],c=z(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(o++,o>=s.length)throw new Ds("invalid address: "+r);if(c.path===!0){n=Vi(s.slice(o).join("/")),t.push([c.code,Pi(c.code,n)]),e.push([c.code,n]);break}let a=Pi(c.code,s[o]);t.push([c.code,a]),e.push([c.code,_i(c.code,a)])}return{string:Ol(e),bytes:Mi(t),tuples:t,stringTuples:e,path:n}}function Di(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=de(r,s),i=xt(o),c=z(o),a=Od(c,r.slice(s+i));if(a===0){t.push([o]),e.push([o]),s+=i;continue}let l=r.slice(s+i,s+i+a);if(s+=a+i,s>r.length)throw new Ds("Invalid address Uint8Array: "+Q(r,"base16"));t.push([o,l]);let u=_i(o,l);if(e.push([o,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Ol(e),tuples:t,stringTuples:e,path:n}}function Ol(r){let t=[];return r.map(e=>{let n=z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Vi(t.join("/"))}function Mi(r){return Pt(r.map(t=>{let e=z(t[0]),n=Uint8Array.from(Ot(e.code));return t.length>1&&t[1]!=null&&(n=Pt([n,t[1]])),n}))}function Od(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=de(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function Vi(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}var Ds=class extends Error{static name="ParseError";name="ParseError";constructor(t){super(`Error parsing address: ${t}`)}};var Vd=Symbol.for("nodejs.util.inspect.custom"),Hi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Dd=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],Fi=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Ms=class r{bytes;#e;#t;#r;#n;[Hi]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Di(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Pl(t)}else if(Dl(t))e=Di(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=z("tcp"),c=z("udp"),a=z("ip4"),l=z("ip6"),u=z("dns6"),f=z("ip6zone");for(let[m,p]of this.stringTuples())m===f.code&&(o=`%${p??""}`),Dd.includes(m)&&(e=i.name==="tcp"?"tcp":"udp",s=443,n=`${p??""}${o}`,t=m===u.code?6:4),(m===i.code||m===c.code)&&(e=z(m).name==="tcp"?"tcp":"udp",s=parseInt(p??"")),(m===a.code||m===l.code)&&(e=z(m).name==="tcp"?"tcp":"udp",n=`${p??""}${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({},z(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>z(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}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(Mi(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===Sr.p2p.code&&t.push([n,s]),n===Sr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?Q(X.decode(`z${n}`),"base58btc"):Q(dt.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=Vl.get(e.name);if(n==null)throw new Fi(`no available resolver for ${e.name}`);return(await n(this,t)).map(o=>se(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)}[Vd](){return`Multiaddr(${this.#e})`}};var Vl=new Map;function Dl(r){return!!r?.[Hi]}function se(r){return new Ms(r)}var Ml="libp2p-peer-record",Fl=Uint8Array.from([3,1]);var cn;(function(r){let t;(function(n){let s;n.codec=()=>(s==null&&(s=Gt((o,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(o.multiaddr)),c.lengthDelimited!==!1&&i.ldelim()},(o,i,c={})=>{let a={multiaddr:pt(0)},l=i==null?o.len:o.pos+i;for(;o.pos<l;){let u=o.uint32();switch(u>>>3){case 1:{a.multiaddr=o.bytes();break}default:{o.skipType(u&7);break}}}return a})),s),n.encode=o=>zt(o,n.codec()),n.decode=(o,i)=>$t(o,n.codec(),i)})(t=r.AddressInfo||(r.AddressInfo={}));let e;r.codec=()=>(e==null&&(e=Gt((n,s,o={})=>{if(o.lengthDelimited!==!1&&s.fork(),n.peerId!=null&&n.peerId.byteLength>0&&(s.uint32(10),s.bytes(n.peerId)),n.seq!=null&&n.seq!==0n&&(s.uint32(16),s.uint64(n.seq)),n.addresses!=null)for(let i of n.addresses)s.uint32(26),r.AddressInfo.codec().encode(i,s);o.lengthDelimited!==!1&&s.ldelim()},(n,s,o={})=>{let i={peerId:pt(0),seq:0n,addresses:[]},c=s==null?n.len:n.pos+s;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:{i.peerId=n.bytes();break}case 2:{i.seq=n.uint64();break}case 3:{if(o.limits?.addresses!=null&&i.addresses.length===o.limits.addresses)throw new Ze('Decode error - map field "addresses" had too many elements');i.addresses.push(r.AddressInfo.codec().decode(n,n.uint32(),{limits:o.limits?.addresses$}));break}default:{n.skipType(a&7);break}}}return i})),e),r.encode=n=>zt(n,r.codec()),r.decode=(n,s)=>$t(n,r.codec(),s)})(cn||(cn={}));var Zt=class r{static createFromProtobuf=t=>{let e=cn.decode(t),n=Si(Fe(e.peerId)),s=(e.addresses??[]).map(i=>se(i.multiaddr)),o=e.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=Ml;static CODEC=Fl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(t){let{peerId:e,multiaddrs:n,seqNumber:s}=t;this.peerId=e,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=cn.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof r)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!El(this.multiaddrs,t.multiaddrs))}};function Md(r){return r[Symbol.asyncIterator]!=null}function Fd(r){if(Md(r))return(async()=>{for await(let t of r);})();for(let t of r);}var Hl=Fd;function Yt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Fs=globalThis.CustomEvent??Event;async function*Ki(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=Yt(),c=Yt(),a=!1,l,u=!1;s.addEventListener("task-complete",()=>{c.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of r){if(o.length===e&&(i=Yt(),await i.promise),u)break;let b={done:!1};o.push(b),p().then(d=>{b.done=!0,b.ok=!0,b.value=d,s.dispatchEvent(new Fs("task-complete"))},d=>{b.done=!0,b.err=d,s.dispatchEvent(new Fs("task-complete"))})}a=!0,s.dispatchEvent(new Fs("task-complete"))}catch(p){l=p,s.dispatchEvent(new Fs("task-complete"))}});function f(){return n?o[0]?.done:!!o.find(p=>p.done)}function*h(){for(;o.length>0&&o[0].done;){let p=o[0];if(o.shift(),p.ok)yield p.value;else throw u=!0,i.resolve(),p.err;i.resolve()}}function*m(){for(;f();)for(let p=0;p<o.length;p++)if(o[p].done){let b=o[p];if(o.splice(p,1),p--,b.ok)yield b.value;else throw u=!0,i.resolve(),b.err;i.resolve()}}for(;;){if(f()||(c=Yt(),await c.promise),l!=null)throw l;if(n?yield*h():yield*m(),a&&o.length===0)break}}var Hs=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function Kl(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Hs(e?.errorMessage,e?.errorCode,e?.errorName));let n,s=new Hs(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var qi=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Yt(),this.haveNext=Yt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Yt(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Yt(),await Kl(this.readNext.promise,e?.signal,e)}};function ql(){return new qi}var Ks=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var $i=class extends Error{code;constructor(t,e){super(t),this.code=e}},zi=class extends $i{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function $l(r,t){let e=ql();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let c of i)await e.push(c);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let s=new jt;return{read:async(i,c)=>{c?.signal?.throwIfAborted();let a,l=new Promise((u,f)=>{a=()=>{f(new zi("Read aborted"))},c?.signal?.addEventListener("abort",a)});try{if(i==null){let{done:f,value:h}=await Promise.race([n.next(),l]);return f===!0?new jt:h}for(;s.byteLength<i;){let{value:f,done:h}=await Promise.race([n.next(),l]);if(h===!0)throw new Ks("unexpected end of input");s.append(f)}let u=s.sublist(0,i);return s.consume(i),u}finally{a!=null&&c?.signal?.removeEventListener("abort",a)}},write:async(i,c)=>{c?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,c):await e.push(i.subarray(),c)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var qs=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},$s=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},zs=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function zl(r,t={}){let e=$l(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=xt(t.maxDataLength));let n=t?.lengthDecoder??de,s=t?.lengthEncoder??Ot;return{read:async i=>{let c=-1,a=new jt;for(;;){a.append(await e.read(1,i));try{c=n(a)}catch(l){if(l instanceof RangeError)continue;throw l}if(c<0)throw new qs("Invalid message length");if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new zs("message length length too long");if(c>-1)break}if(t?.maxDataLength!=null&&c>t.maxDataLength)throw new $s("message length too long");return e.read(c,i)},write:async(i,c)=>{await e.write(new jt(s(i.byteLength),i),c)},writeV:async(i,c)=>{let a=new jt(...i.flatMap(l=>[s(l.byteLength),l]));await e.write(a,c)},unwrap:()=>e.unwrap()}}function Ir(r,t){let e=zl(r,t),n={read:async(s,o)=>{let i=await e.read(o);return s.decode(i)},write:async(s,o,i)=>{await e.write(o.encode(s),i)},writeV:async(s,o,i)=>{await e.writeV(s.map(c=>o.encode(c)),i)},pb:s=>({read:async o=>n.read(s,o),write:async(o,i)=>n.write(o,s,i),writeV:async(o,i)=>n.writeV(o,s,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var Gl="0.1.0",Wl="id",jl="id/push",Zl="1.0.0",Yl="1.0.0";var De;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),e.protocolVersion!=null&&(n.uint32(42),n.string(e.protocolVersion)),e.agentVersion!=null&&(n.uint32(50),n.string(e.agentVersion)),e.publicKey!=null&&(n.uint32(10),n.bytes(e.publicKey)),e.listenAddrs!=null)for(let o of e.listenAddrs)n.uint32(18),n.bytes(o);if(e.observedAddr!=null&&(n.uint32(34),n.bytes(e.observedAddr)),e.protocols!=null)for(let o of e.protocols)n.uint32(26),n.string(o);e.signedPeerRecord!=null&&(n.uint32(66),n.bytes(e.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={listenAddrs:[],protocols:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 5:{o.protocolVersion=e.string();break}case 6:{o.agentVersion=e.string();break}case 1:{o.publicKey=e.bytes();break}case 2:{if(s.limits?.listenAddrs!=null&&o.listenAddrs.length===s.limits.listenAddrs)throw new Ze('Decode error - map field "listenAddrs" had too many elements');o.listenAddrs.push(e.bytes());break}case 4:{o.observedAddr=e.bytes();break}case 3:{if(s.limits?.protocols!=null&&o.protocols.length===s.limits.protocols)throw new Ze('Decode error - map field "protocols" had too many elements');o.protocols.push(e.string());break}case 8:{o.signedPeerRecord=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(De||(De={}));var Rt={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function Jl(r){if(r!=null&&r.length>0)try{return se(r)}catch{}}function qd(r,t){return t??r.userAgent}async function Gs(r,t,e,n,s){if(e("received identify from %p",n.remotePeer),s==null)throw new Dt("message was null or undefined");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(a=>({isCertified:!1,multiaddr:se(a)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null){let a=xr(s.publicKey);if(!vl(a).equals(n.remotePeer))throw new Dt("public key did not match remote PeerId");o.publicKey=a}let i;if(s.signedPeerRecord!=null){e.trace("received signedPeerRecord from %p",n.remotePeer);let a=s.signedPeerRecord,l=await ne.openAndCertify(a,Zt.DOMAIN),u=Zt.createFromProtobuf(l.payload),f=Rs(l.publicKey.toCID());if(!u.peerId.equals(f))throw new Dt("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(u.peerId))throw new Dt("signing key does not match remote PeerId");let h;try{h=await r.get(u.peerId)}catch(m){if(m.name!=="NotFoundError")throw m}if(h!=null&&(o.metadata=h.metadata,h.peerRecordEnvelope!=null)){let m=await ne.createFromProtobuf(h.peerRecordEnvelope),p=Zt.createFromProtobuf(m.payload);p.seqNumber>=u.seqNumber&&(e("sequence number was lower or equal to existing sequence number - stored: %d received: %d",p.seqNumber,u.seqNumber),u=p,a=h.peerRecordEnvelope)}o.peerRecordEnvelope=a,o.addresses=u.multiaddrs.map(m=>({isCertified:!0,multiaddr:m})),i={seq:u.seqNumber,addresses:u.multiaddrs}}else e("%p did not send a signed peer record",n.remotePeer);if(e.trace("patching %p with",n.remotePeer,o),await r.patch(n.remotePeer,o),s.agentVersion!=null||s.protocolVersion!=null){let a={};s.agentVersion!=null&&(a.AgentVersion=$(s.agentVersion)),s.protocolVersion!=null&&(a.ProtocolVersion=$(s.protocolVersion)),e.trace("merging %p metadata",n.remotePeer,a),await r.merge(n.remotePeer,{metadata:a})}let c={peerId:n.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map(a=>se(a)),observedAddr:s.observedAddr==null?void 0:se(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return t.safeDispatchEvent("peer:identify",{detail:c}),c}var kr=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(t,e){this.protocol=e.protocol,this.started=!1,this.peerId=t.peerId,this.privateKey=t.privateKey,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.events=t.events,this.log=e.log,this.timeout=e.timeout??Rt.timeout,this.maxInboundStreams=e.maxInboundStreams??Rt.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Rt.maxOutboundStreams,this.maxMessageSize=e.maxMessageSize??Rt.maxMessageSize,this.maxObservedAddresses=e.maxObservedAddresses??Rt.maxObservedAddresses,this.runOnLimitedConnection=e.runOnLimitedConnection??Rt.runOnLimitedConnection,this.host={protocolVersion:`${e.protocolPrefix??Rt.protocolPrefix}/${Gl}`,agentVersion:qd(t.nodeInfo,e.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:$(this.host.agentVersion),ProtocolVersion:$(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,t=>{this.handleProtocol(t).catch(e=>{this.log.error(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Ws=class extends kr{connectionManager;concurrency;constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${jl}/${Yl}`,log:t.logger.forComponent("libp2p:identify-push")}),this.connectionManager=t.connectionManager,this.concurrency=e.concurrency??Rt.concurrency,(e.runOnSelfUpdate??Rt.runOnSelfUpdate)&&t.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[yn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let t=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),e=new Zt({peerId:this.peerId,multiaddrs:t}),n=await ne.seal(e,this.privateKey),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=Q(o.metadata.get("AgentVersion")??$(this.host.agentVersion)),c=Q(o.metadata.get("ProtocolVersion")??$(this.host.protocolVersion)),a=this;async function*l(){for(let u of a.connectionManager.getConnections())(await a.peerStore.get(u.remotePeer)).protocols.includes(a.protocol)&&(yield async()=>{let h,m=AbortSignal.timeout(a.timeout);Tr(1/0,m);try{h=await u.newStream(a.protocol,{signal:m,runOnLimitedConnection:a.runOnLimitedConnection}),await Ir(h,{maxDataLength:a.maxMessageSize}).pb(De).write({listenAddrs:t.map(b=>b.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:c},{signal:m}),await h.close({signal:m})}catch(p){a.log.error("could not push identify update to peer",p),h?.abort(p)}})}await Hl(Ki(l(),{concurrency:this.concurrency}))}async handleProtocol(t){let{connection:e,stream:n}=t;try{if(this.peerId.equals(e.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await Ir(n,{maxDataLength:this.maxMessageSize}).pb(De).read(s);await n.close(s),await Gs(this.peerStore,this.events,this.log,e,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log.trace("handled push from %p",e.remotePeer)}};var $d=41;function Xl(r){try{let[[t,e]]=r.stringTuples();if(e==null)return!1;if(t===$d)return Nl("2000::/3",e)}catch{}return!1}var tu=aa(Ql(),1),zd=["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"],Gd=zd.map(r=>new tu.Netmask(r));function Gi(r){for(let t of Gd)if(t.contains(r))return!0;return!1}function Wd(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function jd(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),s=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return Gi(s)}function Zd(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function Yd(r){let t=r.split(":"),e=t[t.length-1];return Gi(e)}function Jd(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function eu(r){return Br(r)?Gi(r):Wd(r)?jd(r):Zd(r)?Yd(r):Ar(r)?Jd(r):void 0}var Xd=4,Qd=41,t0=53,e0=54,r0=55,n0=56;function ru(r){try{let[[t,e]]=r.stringTuples();if(e==null)return!0;if(t===t0||t===e0||t===r0||t===n0)return!1;if(t===Xd||t===Qd)return eu(e)??!1}catch{}return!0}var s0=r=>r.toString().split("/").slice(1),Cr=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),H=r=>({match:t=>Cr(e=>e===r).match(t),pattern:r}),er=()=>({match:r=>Cr(t=>typeof t=="string").match(r),pattern:"{string}"}),un=()=>({match:r=>Cr(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),Y=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{X.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),fn=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Wo.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),G=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),Bt=(...r)=>({match:t=>{let e;for(let n of r){let s=n.match(t);s!==!1&&(e==null||s.length<e.length)&&(e=s)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),K=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function st(...r){function t(s){let o=s0(s);for(let i of r){let c=i.match(o);if(c===!1)return!1;o=c}return o}function e(s){return t(s)!==!1}function n(s){let o=t(s);return o===!1?!1:o.length===0}return{matchers:r,matches:e,exactMatch:n}}var Zs=K(H("dns4"),er()),Ys=K(H("dns6"),er()),Js=K(H("dnsaddr"),er()),ji=K(H("dns"),er()),Zx=st(Zs,G(Y())),Yx=st(Ys,G(Y())),Jx=st(Js,G(Y())),Xx=st(Bt(ji,Js,Zs,Ys),G(Y())),nu=K(H("ip4"),Cr(Br)),su=K(H("ip6"),Cr(Ar)),Zi=Bt(nu,su),Ee=Bt(Zi,ji,Zs,Ys,Js),ou=st(Bt(Zi,K(Bt(ji,Js,Zs,Ys),G(Y())))),Qx=st(nu),t1=st(su),e1=st(Zi),Yi=K(Ee,H("tcp"),un()),hn=K(Ee,H("udp"),un()),iu=st(K(Yi,G(Y()))),r1=st(hn),Ji=K(hn,H("quic"),G(Y())),Xs=K(hn,H("quic-v1"),G(Y())),o0=Bt(Ji,Xs),n1=st(Ji),s1=st(Xs),Wi=Bt(Ee,Yi,hn,Ji,Xs),au=Bt(K(Wi,H("ws"),G(Y()))),o1=st(au),cu=Bt(K(Wi,H("wss"),G(Y())),K(Wi,H("tls"),G(K(H("sni"),er())),H("ws"),G(Y()))),i1=st(cu),lu=K(hn,H("webrtc-direct"),G(fn()),G(fn()),G(Y())),a1=st(lu),uu=K(Xs,H("webtransport"),G(fn()),G(fn()),G(Y())),c1=st(uu),js=Bt(au,cu,K(Yi,G(Y())),K(o0,G(Y())),K(Ee,G(Y())),lu,uu,Y()),l1=st(js),i0=K(js,H("p2p-circuit"),Y()),u1=st(i0),a0=Bt(K(js,H("p2p-circuit"),H("webrtc"),G(Y())),K(js,H("webrtc"),G(Y())),K(H("webrtc"),G(Y()))),f1=st(a0),c0=Bt(K(Ee,H("tcp"),un(),H("http"),G(Y())),K(Ee,H("http"),G(Y()))),h1=st(c0),l0=Bt(K(Ee,H("tcp"),Bt(K(H("443"),H("http")),K(un(),H("https"))),G(Y())),K(Ee,H("tls"),H("http"),G(Y())),K(Ee,H("https"),G(Y()))),d1=st(l0),u0=Bt(K(H("memory"),er(),G(Y()))),p1=st(u0);var f0=41,Qs=class extends kr{constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${Wl}/${Zl}`,log:t.logger.forComponent("libp2p:identify")}),(e.runOnConnectionOpen??Rt.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{o.name!==gn.name&&this.log.error("error during identify trigged by connection:open",o)})})}[yn]=["@libp2p/identify"];async _identify(t,e={}){let n;if(e.signal==null){let s=AbortSignal.timeout(this.timeout);Tr(1/0,s),e={...e,signal:s}}try{n=await t.newStream(this.protocol,{...e,runOnLimitedConnection:this.runOnLimitedConnection});let o=await Ir(n,{maxDataLength:this.maxMessageSize}).pb(De).read(e);return await n.close(e),o}catch(s){throw n?.abort(s),s}}async identify(t,e={}){let n=await this._identify(t,e),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new Dt("public key was missing from identify message");let c=xr(s),a=Rs(c.toCID());if(!t.remotePeer.equals(a))throw new Dt("identified peer does not match the expected peer");if(this.peerId.equals(a))throw new Dt("identified peer is our own peer id?");return this.maybeAddObservedAddress(i),this.log("identify completed for peer %p and protocols %o",a,o),Gs(this.peerStore,this.events,this.log,t,n)}maybeAddObservedAddress(t){let e=Jl(t);if(e==null)return;if(this.log.trace("our observed address was %a",e),ru(e)){this.log.trace("our observed address was private");return}if(e.stringTuples()[0][0]===f0&&!Xl(e)){this.log.trace("our observed address was IPv6 but not a global unicast address");return}iu.exactMatch(e)||(this.log.trace("storing the observed address"),this.addressManager.addObservedAddr(e))}async handleProtocol(t){let{connection:e,stream:n}=t,s=AbortSignal.timeout(this.timeout);Tr(1/0,s);try{let o=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),c=o.peerRecordEnvelope;if(i.length>0&&c==null){let u=new Zt({peerId:this.peerId,multiaddrs:i});c=(await ne.seal(u,this.privateKey)).marshal().subarray()}let a=e.remoteAddr.bytes;ou.matches(e.remoteAddr)||(a=void 0),await Ir(n).pb(De).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:Ue(this.privateKey.publicKey),listenAddrs:i.map(u=>u.bytes),signedPeerRecord:c,observedAddr:a,protocols:o.protocols},{signal:s}),await n.close({signal:s})}catch(o){this.log.error("could not respond to identify request",o),n.abort(o)}}};function h0(r={}){return t=>new Qs(t,r)}function d0(r={}){return t=>new Ws(t,r)}return Au(p0);})();
6
+ `)}`:`${e} :`}};yc=Oe;B.Constructed=yc;Oe.NAME="CONSTRUCTED";var Wn=class extends Et{fromBER(t,e,n){return e}toBER(t){return Wt}};Wn.override="EndOfContentValueBlock";var bc,jn=class extends mt{constructor(t={}){super(t,Wn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};bc=jn;B.EndOfContent=bc;jn.NAME=zr;var wc,mr=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}`}};wc=mr;B.Null=wc;mr.NAME="NULL";var Zn=class extends we(Et){constructor({value:t,...e}={}){super(e),e.valueHex?this.valueHexView=M.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=M.BufferSourceConverter.toUint8Array(t);return be(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,pi.call(this),this.blockLength=n,e+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};Zn.NAME="BooleanValueBlock";var xc,Yn=class extends mt{constructor(t={}){super(t,Zn),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}`}};xc=Yn;B.Boolean=xc;Yn.NAME="BOOLEAN";var Jn=class extends we(te){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=te.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==dc)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?te.prototype.toBER.call(this,t,e):t?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Jn.NAME="OctetStringValueBlock";var vc,Xn=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},Jn),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=Is(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?Oe.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${M.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 M.BufferSourceConverter.concat(t)}};vc=Xn;B.OctetString=vc;Xn.NAME=dc;var Qn=class extends we(te){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=te.prototype.fromBER.call(this,t,e,n),s===-1)return s;for(let c of this.value){let a=c.constructor.NAME;if(a===zr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(a!==pc)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let l=c.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=M.BufferSourceConverter.toUint8Array(t);if(!be(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 c=i.subarray(1);try{if(c.byteLength){let a=Is(c,0,c.byteLength);a.offset!==-1&&a.offset===n-1&&(this.value=[a.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,e+n}toBER(t,e){if(this.isConstructed)return te.prototype.toBER.call(this,t,e);if(t)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Wt;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}}};Qn.NAME="BitStringValueBlock";var Ec,gr=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},Qn),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 Oe.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)}`}}};Ec=gr;B.BitString=Ec;gr.NAME=pc;var Bc;function md(r,t){let e=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,c=s.slice(0),a=c.length-1,l=0,u=a<i?i:a,f=0;for(let h=u;h>=0;h--,f++){switch(!0){case f<c.length:l=o[i-f]+c[a-f]+e[0];break;default:l=o[i-f]+e[0]}switch(e[0]=l/10,!0){case f>=o.length:o=Fn(new Uint8Array([l%10]),o);break;default:o[i-f]=l%10}}return e[0]>0&&(o=Fn(e,o)),o}function hc(r){if(r>=qr.length)for(let t=qr.length;t<=r;t++){let e=new Uint8Array([0]),n=qr[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=Fn(e,n)),qr.push(n)}return qr[r]}function gd(r,t){let e=0,n=new Uint8Array(r),s=new Uint8Array(t),o=n.slice(0),i=o.length-1,c=s.slice(0),a=c.length-1,l,u=0;for(let f=a;f>=0;f--,u++)switch(l=o[i-u]-c[a-u]-e,!0){case l<0:e=1,o[i-u]=l+10;break;default:e=0,o[i-u]=l}if(e>0)for(let f=i-a+1;f>=0;f--,u++)if(l=o[i-u]-e,l<0)e=1,o[i-u]=l+10;else{e=0,o[i-u]=l;break}return o.slice()}var Gr=class extends we(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=pi.call(this)))}set valueDec(t){this._valueDec=t,this.isHexOnly=!1,this.valueHexView=new Uint8Array(lc(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="",c=!1;for(let a=o.byteLength-1;a>=0;a--){s=o[a];for(let l=0;l<8;l++){if((s&1)===1)switch(n){case t:e=gd(hc(n),e),i="-";break;default:e=md(e,hc(n))}n++,s>>=1}}for(let a=0;a<e.length;a++)e[a]&&(c=!0),c&&(i+=fc.charAt(e[a]));return c===!1&&(i+=fc.charAt(0)),i}};Bc=Gr;Gr.NAME="IntegerValueBlock";Object.defineProperty(Bc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var Ac,gt=class r extends mt{constructor(t={}){super(t,Gr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Hn(),BigInt(this.valueBlock.toString())}static fromBigInt(t){Hn();let e=BigInt(t),n=new $r,s=e.toString(16).replace(/^-/,""),o=new Uint8Array(M.Convert.FromHex(s));if(e<0){let c=new Uint8Array(o.length+(o[0]&128?1:0));c[0]|=128;let l=BigInt(`0x${M.Convert.ToHex(c)}`)+e,u=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(l.toString(16)));u[0]|=128,n.write(u)}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()}`}};Ac=gt;B.Integer=Ac;gt.NAME="INTEGER";var Sc,ts=class extends gt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};Sc=ts;B.Enumerated=Sc;ts.NAME="ENUMERATED";var Wr=class extends we(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=M.BufferSourceConverter.toUint8Array(t);if(!be(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=o[c]&127,this.blockLength++,!!(o[c]&128));c++);let i=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)i[c]=this.valueHexView[c];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=Ye(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),e+this.blockLength)}set valueBigInt(t){Hn();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=Pe(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Wt;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=M.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}}};Wr.NAME="sidBlock";var es=class extends Et{constructor({value:t=br,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new Wr;if(s=o.fromBER(t,s,n),s===-1)return this.blockLength=0,this.error=o.error,s;this.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,Wt;e.push(s)}return mi(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],c=0;switch(i.valueDec){case 0:break;case 1:c=40;break;case 2:c=80;break;default:this.value=[];return}let a=parseInt(s,10);if(isNaN(a))return;i.valueDec=a+c,o=!1}else{let i=new Wr;if(s>Number.MAX_SAFE_INTEGER){Hn();let c=BigInt(s);i.valueBigInt=c}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}};es.NAME="ObjectIdentifierValueBlock";var Ic,yr=class extends mt{constructor(t={}){super(t,es),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()}}};Ic=yr;B.ObjectIdentifier=Ic;yr.NAME="OBJECT IDENTIFIER";var jr=class extends we(me){constructor({valueDec:t=0,...e}={}){super(e),this.valueDec=t}fromBER(t,e,n){if(n===0)return e;let s=M.BufferSourceConverter.toUint8Array(t);if(!be(this,s,e,n))return-1;let o=s.subarray(e,e+n);this.valueHexView=new Uint8Array(n);for(let c=0;c<n&&(this.valueHexView[c]=o[c]&127,this.blockLength++,!!(o[c]&128));c++);let i=new Uint8Array(this.blockLength);for(let c=0;c<this.blockLength;c++)i[c]=this.valueHexView[c];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=Ye(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=Pe(this.valueDec,7);if(e.byteLength===0)return this.error="Error during encoding SID value",Wt;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=M.Convert.ToHex(this.valueHexView):t=this.valueDec.toString(),t}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};jr.NAME="relativeSidBlock";var rs=class extends Et{constructor({value:t=br,...e}={}){super(e),this.value=[],t&&this.fromString(t)}fromBER(t,e,n){let s=e;for(;n>0;){let o=new jr;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,Wt;n.push(o)}return mi(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 jr;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}};rs.NAME="RelativeObjectIdentifierValueBlock";var kc,ns=class extends mt{constructor(t={}){super(t,rs),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()}}};kc=ns;B.RelativeObjectIdentifier=kc;ns.NAME="RelativeObjectIdentifier";var Nc,ge=class extends Oe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};Nc=ge;B.Sequence=Nc;ge.NAME="SEQUENCE";var Cc,ss=class extends Oe{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};Cc=ss;B.Set=Cc;ss.NAME="SET";var os=class extends we(Et){constructor({...t}={}){super(t),this.isHexOnly=!0,this.value=br}toJSON(){return{...super.toJSON(),value:this.value}}};os.NAME="StringValueBlock";var is=class extends os{};is.NAME="SimpleStringValueBlock";var kt=class extends $n{constructor({...t}={}){super(t,is)}fromBuffer(t){this.valueBlock.value=String.fromCharCode.apply(null,M.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}};kt.NAME="SIMPLE STRING";var as=class extends kt{fromBuffer(t){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t);try{this.valueBlock.value=M.Convert.ToUtf8String(t)}catch(e){this.warnings.push(`Error during "decodeURIComponent": ${e}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(t)}}fromString(t){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(t)),this.valueBlock.value=t}};as.NAME="Utf8StringValueBlock";var Tc,ye=class extends as{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};Tc=ye;B.Utf8String=Tc;ye.NAME="UTF8String";var cs=class extends kt{fromBuffer(t){this.valueBlock.value=M.Convert.ToUtf16String(t),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(t)}fromString(t){this.valueBlock.value=t,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(t))}};cs.NAME="BmpStringValueBlock";var Uc,ls=class extends cs{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};Uc=ls;B.BmpString=Uc;ls.NAME="BMPString";var us=class extends kt{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=Pe(t.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let c=4-i.length;for(let a=i.length-1;a>=0;a--)n[s*4+a+c]=i[a]}this.valueBlock.value=t}};us.NAME="UniversalStringValueBlock";var Lc,fs=class extends us{constructor({...t}={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};Lc=fs;B.UniversalString=Lc;fs.NAME="UniversalString";var Rc,hs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};Rc=hs;B.NumericString=Rc;hs.NAME="NumericString";var _c,ds=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};_c=ds;B.PrintableString=_c;ds.NAME="PrintableString";var Pc,ps=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};Pc=ps;B.TeletexString=Pc;ps.NAME="TeletexString";var Oc,ms=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};Oc=ms;B.VideotexString=Oc;ms.NAME="VideotexString";var Vc,gs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};Vc=gs;B.IA5String=Vc;gs.NAME="IA5String";var Dc,ys=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};Dc=ys;B.GraphicString=Dc;ys.NAME="GraphicString";var Mc,Zr=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};Mc=Zr;B.VisibleString=Mc;Zr.NAME="VisibleString";var Fc,bs=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};Fc=bs;B.GeneralString=Fc;bs.NAME="GeneralString";var Hc,ws=class extends kt{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Hc=ws;B.CharacterString=Hc;ws.NAME="CharacterString";var Kc,Yr=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,M.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]=Lt(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Lt(this.month,2),e[2]=Lt(this.day,2),e[3]=Lt(this.hour,2),e[4]=Lt(this.minute,2),e[5]=Lt(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}}};Kc=Yr;B.UTCTime=Kc;Yr.NAME="UTCTime";var qc,xs=class extends Yr{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,c=0,a=0;if(t[t.length-1]==="Z")n=t.substring(0,t.length-1),e=!0;else{let f=new Number(t[t.length-1]);if(isNaN(f.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 f=1,h=n.indexOf("+"),m="";if(h===-1&&(h=n.indexOf("-"),f=-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 p=parseInt(m.substring(0,2),10);if(isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");if(c=f*p,m.length===4){if(p=parseInt(m.substring(2,4),10),isNaN(p.valueOf()))throw new Error("Wrong input string for conversion");a=f*p}}}let l=n.indexOf(".");if(l===-1&&(l=n.indexOf(",")),l!==-1){let f=new Number(`0${n.substring(l)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");o=f.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 f=60*o;this.minute=Math.floor(f),f=60*(f-this.minute),this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===12:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=60*o;this.second=Math.floor(f),f=1e3*(f-this.second),this.millisecond=Math.floor(f)}break;case s.length===14:if(i=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/ig,l!==-1){let f=1e3*o;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let u=i.exec(s);if(u===null)throw new Error("Wrong input string for conversion");for(let f=1;f<u.length;f++)switch(f){case 1:this.year=parseInt(u[f],10);break;case 2:this.month=parseInt(u[f],10);break;case 3:this.day=parseInt(u[f],10);break;case 4:this.hour=parseInt(u[f],10)+c;break;case 5:this.minute=parseInt(u[f],10)+a;break;case 6:this.second=parseInt(u[f],10);break;default:throw new Error("Wrong input string for conversion")}if(e===!1){let f=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=f.getUTCFullYear(),this.month=f.getUTCMonth(),this.day=f.getUTCDay(),this.hour=f.getUTCHours(),this.minute=f.getUTCMinutes(),this.second=f.getUTCSeconds(),this.millisecond=f.getUTCMilliseconds()}}toString(t="iso"){if(t==="iso"){let e=[];return e.push(Lt(this.year,4)),e.push(Lt(this.month,2)),e.push(Lt(this.day,2)),e.push(Lt(this.hour,2)),e.push(Lt(this.minute,2)),e.push(Lt(this.second,2)),this.millisecond!==0&&(e.push("."),e.push(Lt(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(t)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};qc=xs;B.GeneralizedTime=qc;xs.NAME="GeneralizedTime";var $c,vs=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};$c=vs;B.DATE=$c;vs.NAME="DATE";var zc,Es=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};zc=Es;B.TimeOfDay=zc;Es.NAME="TimeOfDay";var Gc,Bs=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};Gc=Bs;B.DateTime=Gc;Bs.NAME="DateTime";var Wc,As=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Wc=As;B.Duration=Wc;As.NAME="Duration";var jc,Ss=class extends ye{constructor(t={}){super(t),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};jc=Ss;B.TIME=jc;Ss.NAME="TIME";function Q(r,t="utf8"){let e=Pn[t];if(e==null)throw new Error(`Unsupported encoding "${t}"`);return e.encoder.encode(r).substring(1)}var Jr=class extends Error{constructor(t="An error occurred while verifying a message"){super(t),this.name="VerificationError"}},ks=class extends Error{constructor(t="Missing Web Crypto API"){super(t),this.name="WebCryptoMissingError"}};var Zc={get(r=globalThis){let t=r.crypto;if(t?.subtle==null)throw new ks("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");return t}};var Ve=Zc;async function Yc(r){let t=await Ve.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 bd(t);return{privateKey:e[0],publicKey:e[1]}}async function Jc(r,t){let e=await Ve.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ve.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 Ve.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ve.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,e instanceof Uint8Array?e:e.subarray())}async function bd(r){if(r.privateKey==null||r.publicKey==null)throw new It("Private and public key are required");return Promise.all([Ve.get().subtle.exportKey("jwk",r.privateKey),Ve.get().subtle.exportKey("jwk",r.publicKey)])}function bi(r){if(r.kty!=="RSA")throw new It("invalid key type");if(r.n==null)throw new It("invalid key modulus");return $(r.n,"base64url").length*8}var wr=class{type="RSA";_key;_raw;_multihash;constructor(t,e){this._key=t,this._multihash=e}get raw(){return this._raw==null&&(this._raw=Xr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return dt.createV1(114,this._multihash)}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return Xc(this._key,e,t)}},Qr=class{type="RSA";_key;_raw;publicKey;constructor(t,e){this._key=t,this.publicKey=e}get raw(){return this._raw==null&&(this._raw=Xr.jwkToPkcs1(this._key)),this._raw}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}sign(t){return Jc(this._key,t)}};var Ns=8192,wi=18;function Qc(r){let{result:t}=yi(r),e=t.valueBlock.value;return{n:ee(e[1]),e:ee(e[2]),d:ee(e[3]),p:ee(e[4]),q:ee(e[5]),dp:ee(e[6]),dq:ee(e[7]),qi:ee(e[8]),kty:"RSA",alg:"RS256"}}function wd(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 It("JWK was missing components");let e=new ge({value:[new gt({value:0}),gt.fromBigInt(re($(r.n,"base64url"))),gt.fromBigInt(re($(r.e,"base64url"))),gt.fromBigInt(re($(r.d,"base64url"))),gt.fromBigInt(re($(r.p,"base64url"))),gt.fromBigInt(re($(r.q,"base64url"))),gt.fromBigInt(re($(r.dp,"base64url"))),gt.fromBigInt(re($(r.dq,"base64url"))),gt.fromBigInt(re($(r.qi,"base64url")))]}).toBER();return new Uint8Array(e,0,e.byteLength)}function tl(r){let{result:t}=yi(r),e=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:ee(e[0]),e:ee(e[1])}}function xi(r){if(r.n==null||r.e==null)throw new It("JWK was missing components");let e=new ge({value:[new ge({value:[new yr({value:"1.2.840.113549.1.1.1"}),new mr]}),new gr({valueHex:new ge({value:[gt.fromBigInt(re($(r.n,"base64url"))),gt.fromBigInt(re($(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(e,0,e.byteLength)}function ee(r){let t=r.valueBlock.valueHexView;for(;t[0]===0;)t=t.subarray(1);return Q(t,"base64url")}function re(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(""))}function el(r){let t=Qc(r);return rl(t)}function vi(r){let t=tl(r);if(bi(t)>Ns)throw new rr("Key size is too large");let e=dr(Qt.encode({Type:ct.RSA,Data:r})),n=Mt(wi,e);return new wr(t,n)}function rl(r){if(bi(r)>Ns)throw new It("Key size is too large");let t=sl(r),e=dr(Qt.encode({Type:ct.RSA,Data:xi(t.publicKey)})),n=Mt(wi,e);return new Qr(t.privateKey,new wr(t.publicKey,n))}async function nl(r){if(r>Ns)throw new It("Key size is too large");let t=await Yc(r),e=dr(Qt.encode({Type:ct.RSA,Data:xi(t.publicKey)})),n=Mt(wi,e);return new Qr(t.privateKey,new wr(t.publicKey,n))}function sl(r){if(r==null)throw new It("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var Cs=class extends lr{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,Sa(t);let n=Pr(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 cr(this),this.iHash.update(t),this}digestInto(t){cr(this),ar(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:c}=this;return t=t,t.finished=s,t.destroyed=o,t.blockLen=i,t.outputLen=c,t.oHash=e._cloneInto(t.oHash),t.iHash=n._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},Ei=(r,t,e)=>new Cs(r,t).update(e).digest();Ei.create=(r,t)=>new Cs(r,t);function ol(r){r.lowS!==void 0&&Ht("lowS",r.lowS),r.prehash!==void 0&&Ht("prehash",r.prehash)}function xd(r){let t=Dr(r);Xt(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("invalid 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("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}var{bytesToNumberBE:vd,hexToBytes:Ed}=Sn,Bi=class extends Error{constructor(t=""){super(t)}},xe={Err:Bi,_tlv:{encode:(r,t)=>{let{Err:e}=xe;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length&1)throw new e("tlv.encode: unpadded data");let n=t.length/2,s=Ke(n);if(s.length/2&128)throw new e("tlv.encode: long form length too big");let o=n>127?Ke(s.length/2|128):"";return Ke(r)+o+s+t},decode(r,t){let{Err:e}=xe,n=0;if(r<0||r>256)throw new e("tlv.encode: wrong tag");if(t.length<2||t[n++]!==r)throw new e("tlv.decode: wrong tlv");let s=t[n++],o=!!(s&128),i=0;if(!o)i=s;else{let a=s&127;if(!a)throw new e("tlv.decode(long): indefinite length not supported");if(a>4)throw new e("tlv.decode(long): byte length is too big");let l=t.subarray(n,n+a);if(l.length!==a)throw new e("tlv.decode: length bytes not complete");if(l[0]===0)throw new e("tlv.decode(long): zero leftmost byte");for(let u of l)i=i<<8|u;if(n+=a,i<128)throw new e("tlv.decode(long): not minimal encoding")}let c=t.subarray(n,n+i);if(c.length!==i)throw new e("tlv.decode: wrong value length");return{v:c,l:t.subarray(n+i)}}},_int:{encode(r){let{Err:t}=xe;if(r<ve)throw new t("integer: negative integers are not allowed");let e=Ke(r);if(Number.parseInt(e[0],16)&8&&(e="00"+e),e.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return e},decode(r){let{Err:t}=xe;if(r[0]&128)throw new t("invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return vd(r)}},toSig(r){let{Err:t,_int:e,_tlv:n}=xe,s=typeof r=="string"?Ed(r):r;fr(s);let{v:o,l:i}=n.decode(48,s);if(i.length)throw new t("invalid signature: left bytes after parsing");let{v:c,l:a}=n.decode(2,o),{v:l,l:u}=n.decode(2,a);if(u.length)throw new t("invalid signature: left bytes after parsing");return{r:e.decode(c),s:e.decode(l)}},hexFromSig(r){let{_tlv:t,_int:e}=xe,n=t.encode(2,e.encode(r.r)),s=t.encode(2,e.encode(r.s)),o=n+s;return t.encode(48,o)}},ve=BigInt(0),ft=BigInt(1),ry=BigInt(2),il=BigInt(3),ny=BigInt(4);function Bd(r){let t=xd(r),{Fp:e}=t,n=Te(t.n,t.nBitLength),s=t.toBytes||((b,d,v)=>{let A=d.toAffine();return he(Uint8Array.from([4]),e.toBytes(A.x),e.toBytes(A.y))}),o=t.fromBytes||(b=>{let d=b.subarray(1),v=e.fromBytes(d.subarray(0,e.BYTES)),A=e.fromBytes(d.subarray(e.BYTES,2*e.BYTES));return{x:v,y:A}});function i(b){let{a:d,b:v}=t,A=e.sqr(b),y=e.mul(A,b);return e.add(e.add(y,e.mul(b,d)),v)}if(!e.eql(e.sqr(t.Gy),i(t.Gx)))throw new Error("bad generator point: equation left != right");function c(b){return Or(b,ft,t.n)}function a(b){let{allowedPrivateKeyLengths:d,nByteLength:v,wrapPrivateKey:A,n:y}=t;if(d&&typeof b!="bigint"){if(ke(b)&&(b=ue(b)),typeof b!="string"||!d.includes(b.length))throw new Error("invalid private key");b=b.padStart(v*2,"0")}let I;try{I=typeof b=="bigint"?b:fe(nt("private key",b,v))}catch{throw new Error("invalid private key, expected hex or "+v+" bytes, got "+typeof b)}return A&&(I=Z(I,y)),Ct("private key",I,ft,y),I}function l(b){if(!(b instanceof h))throw new Error("ProjectivePoint expected")}let u=ze((b,d)=>{let{px:v,py:A,pz:y}=b;if(e.eql(y,e.ONE))return{x:v,y:A};let I=b.is0();d==null&&(d=I?e.ONE:e.inv(y));let L=e.mul(v,d),U=e.mul(A,d),k=e.mul(y,d);if(I)return{x:e.ZERO,y:e.ZERO};if(!e.eql(k,e.ONE))throw new Error("invZ was invalid");return{x:L,y:U}}),f=ze(b=>{if(b.is0()){if(t.allowInfinityPoint&&!e.is0(b.py))return;throw new Error("bad point: ZERO")}let{x:d,y:v}=b.toAffine();if(!e.isValid(d)||!e.isValid(v))throw new Error("bad point: x or y not FE");let A=e.sqr(v),y=i(d);if(!e.eql(A,y))throw new Error("bad point: equation left != right");if(!b.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,v,A){if(this.px=d,this.py=v,this.pz=A,d==null||!e.isValid(d))throw new Error("x required");if(v==null||!e.isValid(v))throw new Error("y required");if(A==null||!e.isValid(A))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x:v,y:A}=d||{};if(!d||!e.isValid(v)||!e.isValid(A))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let y=I=>e.eql(I,e.ZERO);return y(v)&&y(A)?h.ZERO:new h(v,A,e.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let v=e.invertBatch(d.map(A=>A.pz));return d.map((A,y)=>A.toAffine(v[y])).map(h.fromAffine)}static fromHex(d){let v=h.fromAffine(o(nt("pointHex",d)));return v.assertValidity(),v}static fromPrivateKey(d){return h.BASE.multiply(a(d))}static msm(d,v){return Cn(h,n,d,v)}_setWindowSize(d){p.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(e.isOdd)return!e.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){l(d);let{px:v,py:A,pz:y}=this,{px:I,py:L,pz:U}=d,k=e.eql(e.mul(v,U),e.mul(I,y)),T=e.eql(e.mul(A,U),e.mul(L,y));return k&&T}negate(){return new h(this.px,e.neg(this.py),this.pz)}double(){let{a:d,b:v}=t,A=e.mul(v,il),{px:y,py:I,pz:L}=this,U=e.ZERO,k=e.ZERO,T=e.ZERO,N=e.mul(y,y),tt=e.mul(I,I),q=e.mul(L,L),D=e.mul(y,I);return D=e.add(D,D),T=e.mul(y,L),T=e.add(T,T),U=e.mul(d,T),k=e.mul(A,q),k=e.add(U,k),U=e.sub(tt,k),k=e.add(tt,k),k=e.mul(U,k),U=e.mul(D,U),T=e.mul(A,T),q=e.mul(d,q),D=e.sub(N,q),D=e.mul(d,D),D=e.add(D,T),T=e.add(N,N),N=e.add(T,N),N=e.add(N,q),N=e.mul(N,D),k=e.add(k,N),q=e.mul(I,L),q=e.add(q,q),N=e.mul(q,D),U=e.sub(U,N),T=e.mul(q,tt),T=e.add(T,T),T=e.add(T,T),new h(U,k,T)}add(d){l(d);let{px:v,py:A,pz:y}=this,{px:I,py:L,pz:U}=d,k=e.ZERO,T=e.ZERO,N=e.ZERO,tt=t.a,q=e.mul(t.b,il),D=e.mul(v,I),it=e.mul(A,L),E=e.mul(y,U),C=e.add(v,A),w=e.add(I,L);C=e.mul(C,w),w=e.add(D,it),C=e.sub(C,w),w=e.add(v,y);let g=e.add(I,U);return w=e.mul(w,g),g=e.add(D,E),w=e.sub(w,g),g=e.add(A,y),k=e.add(L,U),g=e.mul(g,k),k=e.add(it,E),g=e.sub(g,k),N=e.mul(tt,w),k=e.mul(q,E),N=e.add(k,N),k=e.sub(it,N),N=e.add(it,N),T=e.mul(k,N),it=e.add(D,D),it=e.add(it,D),E=e.mul(tt,E),w=e.mul(q,w),it=e.add(it,E),E=e.sub(D,E),E=e.mul(tt,E),w=e.add(w,E),D=e.mul(it,w),T=e.add(T,D),D=e.mul(g,w),k=e.mul(C,k),k=e.sub(k,D),D=e.mul(C,it),N=e.mul(g,N),N=e.add(N,D),new h(k,T,N)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return p.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){let{endo:v,n:A}=t;Ct("scalar",d,ve,A);let y=h.ZERO;if(d===ve)return y;if(this.is0()||d===ft)return this;if(!v||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,d,h.normalizeZ);let{k1neg:I,k1:L,k2neg:U,k2:k}=v.splitScalar(d),T=y,N=y,tt=this;for(;L>ve||k>ve;)L&ft&&(T=T.add(tt)),k&ft&&(N=N.add(tt)),tt=tt.double(),L>>=ft,k>>=ft;return I&&(T=T.negate()),U&&(N=N.negate()),N=new h(e.mul(N.px,v.beta),N.py,N.pz),T.add(N)}multiply(d){let{endo:v,n:A}=t;Ct("scalar",d,ft,A);let y,I;if(v){let{k1neg:L,k1:U,k2neg:k,k2:T}=v.splitScalar(d),{p:N,f:tt}=this.wNAF(U),{p:q,f:D}=this.wNAF(T);N=p.constTimeNegate(L,N),q=p.constTimeNegate(k,q),q=new h(e.mul(q.px,v.beta),q.py,q.pz),y=N.add(q),I=tt.add(D)}else{let{p:L,f:U}=this.wNAF(d);y=L,I=U}return h.normalizeZ([y,I])[0]}multiplyAndAddUnsafe(d,v,A){let y=h.BASE,I=(U,k)=>k===ve||k===ft||!U.equals(y)?U.multiplyUnsafe(k):U.multiply(k),L=I(this,v).add(I(d,A));return L.is0()?void 0:L}toAffine(d){return u(this,d)}isTorsionFree(){let{h:d,isTorsionFree:v}=t;if(d===ft)return!0;if(v)return v(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:v}=t;return d===ft?this:v?v(h,this):this.multiplyUnsafe(t.h)}toRawBytes(d=!0){return Ht("isCompressed",d),this.assertValidity(),s(h,this,d)}toHex(d=!0){return Ht("isCompressed",d),ue(this.toRawBytes(d))}}h.BASE=new h(t.Gx,t.Gy,e.ONE),h.ZERO=new h(e.ZERO,e.ONE,e.ZERO);let m=t.nBitLength,p=Nn(h,t.endo?Math.ceil(m/2):m);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:a,weierstrassEquation:i,isWithinCurveOrder:c}}function Ad(r){let t=Dr(r);return Xt(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}function al(r){let t=Ad(r),{Fp:e,n}=t,s=e.BYTES+1,o=2*e.BYTES+1;function i(E){return Z(E,n)}function c(E){return In(E,n)}let{ProjectivePoint:a,normPrivateKeyToScalar:l,weierstrassEquation:u,isWithinCurveOrder:f}=Bd({...t,toBytes(E,C,w){let g=C.toAffine(),x=e.toBytes(g.x),S=he;return Ht("isCompressed",w),w?S(Uint8Array.from([C.hasEvenY()?2:3]),x):S(Uint8Array.from([4]),x,e.toBytes(g.y))},fromBytes(E){let C=E.length,w=E[0],g=E.subarray(1);if(C===s&&(w===2||w===3)){let x=fe(g);if(!Or(x,ft,e.ORDER))throw new Error("Point is not on curve");let S=u(x),R;try{R=e.sqrt(S)}catch(F){let P=F instanceof Error?": "+F.message:"";throw new Error("Point is not on curve"+P)}let _=(R&ft)===ft;return(w&1)===1!==_&&(R=e.neg(R)),{x,y:R}}else if(C===o&&w===4){let x=e.fromBytes(g.subarray(0,e.BYTES)),S=e.fromBytes(g.subarray(e.BYTES,2*e.BYTES));return{x,y:S}}else{let x=s,S=o;throw new Error("invalid Point, expected length of "+x+", or uncompressed "+S+", got "+C)}}}),h=E=>ue(Ce(E,t.nByteLength));function m(E){let C=n>>ft;return E>C}function p(E){return m(E)?i(-E):E}let b=(E,C,w)=>fe(E.slice(C,w));class d{constructor(C,w,g){this.r=C,this.s=w,this.recovery=g,this.assertValidity()}static fromCompact(C){let w=t.nByteLength;return C=nt("compactSignature",C,w*2),new d(b(C,0,w),b(C,w,2*w))}static fromDER(C){let{r:w,s:g}=xe.toSig(nt("DER",C));return new d(w,g)}assertValidity(){Ct("r",this.r,ft,n),Ct("s",this.s,ft,n)}addRecoveryBit(C){return new d(this.r,this.s,C)}recoverPublicKey(C){let{r:w,s:g,recovery:x}=this,S=U(nt("msgHash",C));if(x==null||![0,1,2,3].includes(x))throw new Error("recovery id invalid");let R=x===2||x===3?w+t.n:w;if(R>=e.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=x&1?"03":"02",V=a.fromHex(_+h(R)),F=c(R),P=i(-S*F),j=i(g*F),J=a.BASE.multiplyAndAddUnsafe(V,P,j);if(!J)throw new Error("point at infinify");return J.assertValidity(),J}hasHighS(){return m(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return qe(this.toDERHex())}toDERHex(){return xe.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return qe(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let v={isValidPrivateKey(E){try{return l(E),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{let E=Io(t.n);return Da(t.randomBytes(E),t.n)},precompute(E=8,C=a.BASE){return C._setWindowSize(E),C.multiply(BigInt(3)),C}};function A(E,C=!0){return a.fromPrivateKey(E).toRawBytes(C)}function y(E){let C=ke(E),w=typeof E=="string",g=(C||w)&&E.length;return C?g===s||g===o:w?g===2*s||g===2*o:E instanceof a}function I(E,C,w=!0){if(y(E))throw new Error("first arg must be private key");if(!y(C))throw new Error("second arg must be public key");return a.fromHex(C).multiply(l(E)).toRawBytes(w)}let L=t.bits2int||function(E){if(E.length>8192)throw new Error("input is too large");let C=fe(E),w=E.length*8-t.nBitLength;return w>0?C>>BigInt(w):C},U=t.bits2int_modN||function(E){return i(L(E))},k=Vr(t.nBitLength);function T(E){return Ct("num < 2^"+t.nBitLength,E,ve,k),Ce(E,t.nByteLength)}function N(E,C,w=tt){if(["recovered","canonical"].some(ut=>ut in w))throw new Error("sign() legacy options not supported");let{hash:g,randomBytes:x}=t,{lowS:S,prehash:R,extraEntropy:_}=w;S==null&&(S=!0),E=nt("msgHash",E),ol(w),R&&(E=nt("prehashed msgHash",g(E)));let V=U(E),F=l(C),P=[T(F),T(V)];if(_!=null&&_!==!1){let ut=_===!0?x(e.BYTES):_;P.push(nt("extraEntropy",ut))}let j=he(...P),J=V;function lt(ut){let ht=L(ut);if(!f(ht))return;let yt=c(ht),Nt=a.BASE.multiply(ht).toAffine(),At=i(Nt.x);if(At===ve)return;let Jt=i(yt*i(J+At*F));if(Jt===ve)return;let oe=(Nt.x===At?0:2)|Number(Nt.y&ft),Cr=Jt;return S&&m(Jt)&&(Cr=p(Jt),oe^=1),new d(At,Cr,oe)}return{seed:j,k2sig:lt}}let tt={lowS:t.lowS,prehash:!1},q={lowS:t.lowS,prehash:!1};function D(E,C,w=tt){let{seed:g,k2sig:x}=N(E,C,w),S=t;return Eo(S.hash.outputLen,S.nByteLength,S.hmac)(g,x)}a.BASE._setWindowSize(8);function it(E,C,w,g=q){let x=E;C=nt("msgHash",C),w=nt("publicKey",w);let{lowS:S,prehash:R,format:_}=g;if(ol(g),"strict"in g)throw new Error("options.strict was renamed to lowS");if(_!==void 0&&_!=="compact"&&_!=="der")throw new Error("format must be compact or der");let V=typeof x=="string"||ke(x),F=!V&&!_&&typeof x=="object"&&x!==null&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!V&&!F)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let P,j;try{if(F&&(P=new d(x.r,x.s)),V){try{_!=="compact"&&(P=d.fromDER(x))}catch(oe){if(!(oe instanceof xe.Err))throw oe}!P&&_!=="der"&&(P=d.fromCompact(x))}j=a.fromHex(w)}catch{return!1}if(!P||S&&P.hasHighS())return!1;R&&(C=t.hash(C));let{r:J,s:lt}=P,ut=U(C),ht=c(lt),yt=i(ut*ht),Nt=i(J*ht),At=a.BASE.multiplyAndAddUnsafe(j,yt,Nt)?.toAffine();return At?i(At.x)===J:!1}return{CURVE:t,getPublicKey:A,getSharedSecret:I,sign:D,verify:it,ProjectivePoint:a,Signature:d,utils:v}}function Sd(r){return{hash:r,hmac:(t,...e)=>Ei(r,t,mo(...e)),randomBytes:vn}}function cl(r,t){let e=n=>al({...r,...Sd(n)});return{...e(t),create:e}}var fl=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),ll=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Id=BigInt(1),Ai=BigInt(2),ul=(r,t)=>(r+t/Ai)/t;function kd(r){let t=fl,e=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),l=r*r*r%t,u=l*l*r%t,f=rt(u,e,t)*u%t,h=rt(f,e,t)*u%t,m=rt(h,Ai,t)*l%t,p=rt(m,s,t)*m%t,b=rt(p,o,t)*p%t,d=rt(b,c,t)*b%t,v=rt(d,a,t)*d%t,A=rt(v,c,t)*b%t,y=rt(A,e,t)*u%t,I=rt(y,i,t)*p%t,L=rt(I,n,t)*l%t,U=rt(L,Ai,t);if(!Si.eql(Si.sqr(U),r))throw new Error("Cannot find square root");return U}var Si=Te(fl,void 0,void 0,{sqrt:kd}),Je=cl({a:BigInt(0),b:BigInt(7),Fp:Si,n:ll,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let t=ll,e=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Id*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=e,i=BigInt("0x100000000000000000000000000000000"),c=ul(o*r,t),a=ul(-n*r,t),l=Z(r-c*e-a*s,t),u=Z(-c*n-a*o,t),f=l>i,h=u>i;if(f&&(l=t-l),h&&(u=t-u),l>i||u>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:l,k2neg:h,k2:u}}}},dr),hy=BigInt(0);var dy=Je.ProjectivePoint;function Pt(r,t){t==null&&(t=r.reduce((s,o)=>s+o.length,0));let e=Ut(t),n=0;for(let s of r)e.set(s,n),n+=s.length;return e}function hl(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function dl(r,t,e){let n=Mr.digest(e instanceof Uint8Array?e:e.subarray());if(hl(n))return n.then(({digest:s})=>Je.verify(t,s,r)).catch(s=>{throw new Jr(String(s))});try{return Je.verify(t,n.digest,r)}catch(s){throw new Jr(String(s))}}var Ts=class{type="secp256k1";raw;_key;constructor(t){this._key=ml(t),this.raw=pl(this._key)}toMultihash(){return ce.digest(Ue(this))}toCID(){return dt.createV1(114,this.toMultihash())}toString(){return X.encode(this.toMultihash().bytes).substring(1)}equals(t){return t==null||!(t.raw instanceof Uint8Array)?!1:bt(this.raw,t.raw)}verify(t,e){return dl(this._key,e,t)}};function Ii(r){return new Ts(r)}function pl(r){return Je.ProjectivePoint.fromHex(r).toRawBytes(!0)}function ml(r){try{return Je.ProjectivePoint.fromHex(r),r}catch(t){throw new rr(String(t))}}function xr(r){let{Type:t,Data:e}=Qt.decode(r),n=e??new Uint8Array;switch(t){case ct.RSA:return vi(n);case ct.Ed25519:return Ro(n);case ct.secp256k1:return Ii(n);default:throw new Me}}function gl(r){let{Type:t,Data:e}=Qt.decode(r.digest),n=e??new Uint8Array;switch(t){case ct.Ed25519:return Ro(n);case ct.secp256k1:return Ii(n);default:throw new Me}}function Ue(r){return Qt.encode({Type:ct[r.type],Data:r.raw})}var bl=Symbol.for("@achingbrain/uint8arraylist");function yl(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 Us(r){return!!r?.[bl]}var jt=class r{bufs;length;[bl]=!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(Us(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(Us(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=yl(this.bufs,t);return e.buf[e.index]}set(t,e){let n=yl(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(Us(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 Pt(n,s)}subarray(t,e){let{bufs:n,length:s}=this._subList(t,e);return n.length===1?n[0]:Pt(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],c=s,a=c+i.byteLength;if(s=a,t>=a)continue;let l=t>=c&&t<a,u=e>c&&e<=a;if(l&&u){if(t===c&&e===a){n.push(i);break}let f=t-c;n.push(i.subarray(f,f+(e-t)));break}if(l){if(t===0){n.push(i);continue}n.push(i.subarray(t-c));continue}if(u){if(e===a){n.push(i);break}n.push(i.subarray(0,e-c));break}n.push(i)}return{bufs:n,length:e-t}}indexOf(t,e=0){if(!Us(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 f=0;f<o;f++)i[f]=-1;for(let f=0;f<s;f++)i[n[f]]=f;let c=i,a=this.byteLength-n.byteLength,l=n.byteLength-1,u;for(let f=e;f<=a;f+=u){u=0;for(let h=l;h>=0;h--){let m=this.get(f+h);if(n[h]!==m){u=Math.max(1,h-c[m]);break}}if(u===0)return f}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=Ut(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=pt(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=pt(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=pt(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=Ut(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=pt(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=pt(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=pt(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=pt(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=pt(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}};var tn;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),e.publicKey!=null&&e.publicKey.byteLength>0&&(n.uint32(10),n.bytes(e.publicKey)),e.payloadType!=null&&e.payloadType.byteLength>0&&(n.uint32(18),n.bytes(e.payloadType)),e.payload!=null&&e.payload.byteLength>0&&(n.uint32(26),n.bytes(e.payload)),e.signature!=null&&e.signature.byteLength>0&&(n.uint32(42),n.bytes(e.signature)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={publicKey:pt(0),payloadType:pt(0),payload:pt(0),signature:pt(0)},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 1:{o.publicKey=e.bytes();break}case 2:{o.payloadType=e.bytes();break}case 3:{o.payload=e.bytes();break}case 5:{o.signature=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(tn||(tn={}));var Ls=class extends Error{constructor(t="Invalid signature"){super(t),this.name="InvalidSignatureError"}};var ne=class r{static createFromProtobuf=async t=>{let e=tn.decode(t),n=xr(e.publicKey);return new r({publicKey:n,payloadType:e.payloadType,payload:e.payload,signature:e.signature})};static seal=async(t,e)=>{if(e==null)throw new Error("Missing private key");let n=t.domain,s=t.codec,o=t.marshal(),i=wl(n,s,o),c=await e.sign(i.subarray());return new r({publicKey:e.publicKey,payloadType:s,payload:o,signature:c})};static openAndCertify=async(t,e)=>{let n=await r.createFromProtobuf(t);if(!await n.validate(e))throw new Ls("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(t){let{publicKey:e,payloadType:n,payload:s,signature:o}=t;this.publicKey=e,this.payloadType=n,this.payload=s,this.signature=o}marshal(){return this.marshaled==null&&(this.marshaled=tn.encode({publicKey:Ue(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(t){return bt(this.marshal(),t.marshal())}async validate(t){let e=wl(t,this.payloadType,this.payload);return this.publicKey.verify(e.subarray(),this.signature)}},wl=(r,t,e)=>{let n=$(r),s=Ot(n.byteLength),o=Ot(t.length),i=Ot(e.length);return new jt(s,n,o,t,i,e)};var xl=Symbol.for("nodejs.util.inspect.custom"),Nd=114,en=class{type;multihash;publicKey;string;constructor(t){this.type=t.type,this.multihash=t.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[no]=!0;toString(){return this.string==null&&(this.string=X.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return dt.createV1(Nd,this.multihash)}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 this.toString()===t;if(t?.toMultihash()?.bytes!=null)return bt(this.multihash.bytes,t.toMultihash().bytes);throw new Error("not valid Id")}[xl](){return`PeerId(${this.toString()})`}},rn=class extends en{type="RSA";publicKey;constructor(t){super({...t,type:"RSA"}),this.publicKey=t.publicKey}},nn=class extends en{type="Ed25519";publicKey;constructor(t){super({...t,type:"Ed25519"}),this.publicKey=t.publicKey}},sn=class extends en{type="secp256k1";publicKey;constructor(t){super({...t,type:"secp256k1"}),this.publicKey=t.publicKey}},Cd=2336,on=class{type="url";multihash;publicKey;url;constructor(t){this.url=t.toString(),this.multihash=ce.digest($(this.url))}[xl](){return`PeerId(${this.url})`}[no]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return dt.createV1(Cd,this.toMultihash())}toJSON(){return this.toString()}equals(t){return t==null?!1:(t instanceof Uint8Array&&(t=Q(t)),t.toString()===this.toString())}};var Td=114,vl=2336;function El(r){if(r.type==="Ed25519")return new nn({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new sn({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new rn({multihash:r.toCID().multihash,publicKey:r});throw new Me}function ki(r){if(Ld(r))return new rn({multihash:r});if(Ud(r))try{let t=gl(r);if(t.type==="Ed25519")return new nn({multihash:r,publicKey:t});if(t.type==="secp256k1")return new sn({multihash:r,publicKey:t})}catch{let e=Q(r.digest);return new on(new URL(e))}throw new mn("Supplied PeerID Multihash is invalid")}function Rs(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==Td&&r.code!==vl)throw new pn("Supplied PeerID CID is invalid");if(r.code===vl){let t=Q(r.multihash.digest);return new on(new URL(t))}return ki(r.multihash)}function Ud(r){return r.code===ce.code}function Ld(r){return r.code===Mr.code}function Bl(r,t){let e=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==t.length?!1:(t.sort(e),r.sort(e).every((n,s)=>t[s].equals(n)))}var _s=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,c=this.peekChar();if(c===void 0)return;let a=c==="0",l=2**(8*s)-1;for(;;){let u=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,t);if(!Number.isNaN(h))return h});if(u===void 0)break;if(o*=t,o+=u,o>l||(i+=1,e!==void 0&&i>e))return}if(i!==0)return!n&&a&&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),[c]=t(o.subarray(0,i));return e.set(o.subarray(0,c),16-c),e})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var Al=45,Rd=15,vr=new _s;function Ps(r){if(!(r.length>Rd))return vr.new(r).parseWith(()=>vr.readIPv4Addr())}function Os(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>Al))return vr.new(r).parseWith(()=>vr.readIPv6Addr())}function Xe(r,t=!1){if(r.includes("%")&&(r=r.split("%")[0]),r.length>Al)return;let e=vr.new(r).parseWith(()=>vr.readIPAddr());if(e)return t&&e.length===4?Uint8Array.from([0,0,0,0,0,0,0,0,0,0,255,255,e[0],e[1],e[2],e[3]]):e}function Sl(r,t,e){let n=0;for(let s of r)if(!(n<t)){if(n>e)break;if(s!==255)return!1;n++}return!0}function Il(r,t,e,n){let s=0;for(let o of r)if(!(s<e)){if(s>n)break;if(o!==t[s])return!1;s++}return!0}function Ni(r){switch(r.length){case Qe:return r.join(".");case tr:{let t=[];for(let e=0;e<r.length;e++)e%2===0&&t.push(r[e].toString(16).padStart(2,"0")+r[e+1].toString(16).padStart(2,"0"));return t.join(":")}default:throw new Error("Invalid ip length")}}function kl(r){let t=0;for(let[e,n]of r.entries()){if(n===255){t+=8;continue}for(;n&128;)t++,n=n<<1;if(n&128)return-1;for(let s=e+1;s<r.length;s++)if(r[s]!=0)return-1;break}return t}function Nl(r){let t="0x";for(let e of r)t+=(e>>4).toString(16)+(e&15).toString(16);return t}var Qe=4,tr=16,Kb=parseInt("0xFFFF",16),_d=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function an(r,t){t.length===tr&&r.length===Qe&&Sl(t,0,11)&&(t=t.slice(12)),t.length===Qe&&r.length===tr&&Il(r,_d,0,11)&&(r=r.slice(12));let e=r.length;if(e!=t.length)throw new Error("Failed to mask ip");let n=new Uint8Array(e);for(let s=0;s<e;s++)n[s]=r[s]&t[s];return n}function Cl(r,t){if(typeof t=="string"&&(t=Xe(t)),t==null)throw new Error("Invalid ip");if(t.length!==r.network.length)return!1;for(let e=0;e<t.length;e++)if((r.network[e]&r.mask[e])!==(t[e]&r.mask[e]))return!1;return!0}function Ci(r){let[t,e]=r.split("/");if(!t||!e)throw new Error("Failed to parse given CIDR: "+r);let n=Qe,s=Ps(t);if(s==null&&(n=tr,s=Os(t),s==null))throw new Error("Failed to parse given CIDR: "+r);let o=parseInt(e,10);if(Number.isNaN(o)||String(o).length!==e.length||o<0||o>n*8)throw new Error("Failed to parse given CIDR: "+r);let i=Ti(o,8*n);return{network:an(s,i),mask:i}}function Ti(r,t){if(t!==8*Qe&&t!==8*tr)throw new Error("Invalid CIDR mask");if(r<0||r>t)throw new Error("Invalid CIDR mask");let e=t/8,n=new Uint8Array(e);for(let s=0;s<e;s++){if(r>=8){n[s]=255,r-=8;continue}n[s]=255-(255>>r),r=0}return n}var Er=class{constructor(t,e){if(e==null)({network:this.network,mask:this.mask}=Ci(t));else{let n=Xe(t);if(n==null)throw new Error("Failed to parse network");e=String(e);let s=parseInt(e,10);if(Number.isNaN(s)||String(s).length!==e.length||s<0||s>n.length*8){let o=Xe(e);if(o==null)throw new Error("Failed to parse mask");this.mask=o}else this.mask=Ti(s,8*n.length);this.network=an(n,this.mask)}}contains(t){return Cl({network:this.network,mask:this.mask},t)}toString(){let t=kl(this.mask),e=t!==-1?String(t):Nl(this.mask);return Ni(this.network)+"/"+e}};function Tl(r,t){return new Er(r).contains(t)}function Br(r){return!!Ps(r)}function Ar(r){return!!Os(r)}function Vs(r){return!!Xe(r)}var Ul=Br,Pd=Ar,Ui=function(r){let t=0;if(r=r.toString().trim(),Ul(r)){let e=new Uint8Array(t+4);return r.split(/\./g).forEach(n=>{e[t++]=parseInt(n,10)&255}),e}if(Pd(r)){let e=r.split(":",8),n;for(n=0;n<e.length;n++){let o=Ul(e[n]),i;o&&(i=Ui(e[n]),e[n]=Q(i.slice(0,2),"base16")),i!=null&&++n<8&&e.splice(n,0,Q(i.slice(2,4),"base16"))}if(e[0]==="")for(;e.length<8;)e.unshift("0");else if(e[e.length-1]==="")for(;e.length<8;)e.push("0");else if(e.length<8){for(n=0;n<e.length&&e[n]!=="";n++);let o=[n,1];for(n=9-e.length;n>0;n--)o.push("0");e.splice.apply(e,o)}let s=new Uint8Array(t+16);for(n=0;n<e.length;n++){let o=parseInt(e[n],16);s[t++]=o>>8&255,s[t++]=o&255}return s}throw new Error("invalid ip address")},Ll=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 Sr={},Li={},Vd=[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,-1,"ip6zone"],[43,8,"ipcidr"],[53,-1,"dns",!0],[54,-1,"dns4",!0],[55,-1,"dns6",!0],[56,-1,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,-1,"unix",!1,!0],[421,-1,"ipfs"],[421,-1,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,-1,"garlic64"],[448,0,"tls"],[449,-1,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,-1,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,-1,"http-path"],[777,-1,"memory"]];Vd.forEach(r=>{let t=Dd(...r);Li[t.code]=t,Sr[t.name]=t});function Dd(r,t,e,n,s){return{code:r,size:t,name:e,resolvable:!!n,path:!!s}}function z(r){if(typeof r=="number"){if(Li[r]!=null)return Li[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(Sr[r]!=null)return Sr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var vw=z("ip4"),Ew=z("ip6"),Bw=z("ipcidr");function Oi(r,t){switch(z(r).code){case 4:case 41:return Fd(t);case 42:return Pi(t);case 43:return Q(t,"base10");case 6:case 273:case 33:case 132:return Pl(t).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Pi(t);case 421:return $d(t);case 444:return _l(t);case 445:return _l(t);case 466:return qd(t);case 481:return globalThis.encodeURIComponent(Pi(t));default:return Q(t,"base16")}}function Vi(r,t){switch(z(r).code){case 4:return Rl(t);case 41:return Rl(t);case 42:return _i(t);case 43:return $(t,"base10");case 6:case 273:case 33:case 132:return Di(parseInt(t,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return _i(t);case 421:return Hd(t);case 444:return zd(t);case 445:return Gd(t);case 466:return Kd(t);case 481:return _i(globalThis.decodeURIComponent(t));default:return $(t,"base16")}}var Ri=Object.values(Fr).map(r=>r.decoder),Md=function(){let r=Ri[0].or(Ri[1]);return Ri.slice(2).forEach(t=>r=r.or(t)),r}();function Rl(r){if(!Vs(r))throw new Error("invalid ip address");return Ui(r)}function Fd(r){let t=Ll(r,0,r.length);if(t==null)throw new Error("ipBuff is required");if(!Vs(t))throw new Error("invalid ip address");return t}function Di(r){let t=new ArrayBuffer(2);return new DataView(t).setUint16(0,r),new Uint8Array(t)}function Pl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function _i(r){let t=$(r),e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Pi(r){let t=de(r);if(r=r.slice(xt(t)),r.length!==t)throw new Error("inconsistent lengths");return Q(r)}function Hd(r){let t;r[0]==="Q"||r[0]==="1"?t=Fe(X.decode(`z${r}`)).bytes:t=dt.parse(r).multihash.bytes;let e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function Kd(r){let t=Md.decode(r),e=Uint8Array.from(Ot(t.length));return Pt([e,t],e.length+t.length)}function qd(r){let t=de(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return"u"+Q(e,"base64url")}function $d(r){let t=de(r),e=r.slice(xt(t));if(e.length!==t)throw new Error("inconsistent lengths");return Q(e,"base58btc")}function zd(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=ae.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=Di(n);return Pt([e,s],e.length+s.length)}function Gd(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=ae.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=Di(n);return Pt([e,s],e.length+s.length)}function _l(r){let t=r.slice(0,r.length-2),e=r.slice(r.length-2),n=Q(t,"base32"),s=Pl(e);return`${n}:${s}`}function Ol(r){r=Mi(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],c=z(i);if(c.size===0){t.push([c.code]),e.push([c.code]);continue}if(o++,o>=s.length)throw Dl("invalid address: "+r);if(c.path===!0){n=Mi(s.slice(o).join("/")),t.push([c.code,Vi(c.code,n)]),e.push([c.code,n]);break}let a=Vi(c.code,s[o]);t.push([c.code,a]),e.push([c.code,Oi(c.code,a)])}return{string:Vl(e),bytes:Hi(t),tuples:t,stringTuples:e,path:n}}function Fi(r){let t=[],e=[],n=null,s=0;for(;s<r.length;){let o=de(r,s),i=xt(o),c=z(o),a=Wd(c,r.slice(s+i));if(a===0){t.push([o]),e.push([o]),s+=i;continue}let l=r.slice(s+i,s+i+a);if(s+=a+i,s>r.length)throw Dl("Invalid address Uint8Array: "+Q(r,"base16"));t.push([o,l]);let u=Oi(o,l);if(e.push([o,u]),c.path===!0){n=u;break}}return{bytes:Uint8Array.from(r),string:Vl(e),tuples:t,stringTuples:e,path:n}}function Vl(r){let t=[];return r.map(e=>{let n=z(e[0]);return t.push(n.name),e.length>1&&e[1]!=null&&t.push(e[1]),null}),Mi(t.join("/"))}function Hi(r){return Pt(r.map(t=>{let e=z(t[0]),n=Uint8Array.from(Ot(e.code));return t.length>1&&t[1]!=null&&(n=Pt([n,t[1]])),n}))}function Wd(r,t){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let e=de(t instanceof Uint8Array?t:Uint8Array.from(t));return e+xt(e)}}function Mi(r){return"/"+r.trim().split("/").filter(t=>t).join("/")}function Dl(r){return new Error("Error parsing address: "+r)}var jd=Symbol.for("nodejs.util.inspect.custom"),qi=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Zd=[z("dns").code,z("dns4").code,z("dns6").code,z("dnsaddr").code],Ki=class extends Error{constructor(t="No available resolver"){super(t),this.name="NoAvailableResolverError"}},Ds=class r{bytes;#e;#t;#r;#n;[qi]=!0;constructor(t){t==null&&(t="");let e;if(t instanceof Uint8Array)e=Fi(t);else if(typeof t=="string"){if(t.length>0&&t.charAt(0)!=="/")throw new Error(`multiaddr "${t}" must start with a "/"`);e=Ol(t)}else if(Fl(t))e=Fi(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=z("tcp"),c=z("udp"),a=z("ip4"),l=z("ip6"),u=z("dns6"),f=z("ip6zone");for(let[m,p]of this.stringTuples())m===f.code&&(o=`%${p??""}`),Zd.includes(m)&&(e=i.name,s=443,n=`${p??""}${o}`,t=m===u.code?6:4),(m===i.code||m===c.code)&&(e=z(m).name,s=parseInt(p??"")),(m===a.code||m===l.code)&&(e=z(m).name,n=`${p??""}${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({},z(t)))}protoCodes(){return this.#t.map(([t])=>t)}protoNames(){return this.#t.map(([t])=>z(t).name)}tuples(){return this.#t.map(([t,e])=>e==null?[t]:[t,e])}stringTuples(){return this.#r.map(([t,e])=>e==null?[t]:[t,e])}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(Hi(e.slice(0,n)));return this}getPeerId(){try{let t=[];this.stringTuples().forEach(([n,s])=>{n===Sr.p2p.code&&t.push([n,s]),n===Sr["p2p-circuit"].code&&(t=[])});let e=t.pop();if(e?.[1]!=null){let n=e[1];return n[0]==="Q"||n[0]==="1"?Q(X.decode(`z${n}`),"base58btc"):Q(dt.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=Ml.get(e.name);if(n==null)throw new Ki(`no available resolver for ${e.name}`);return(await n(this,t)).map(o=>se(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)}[jd](){return`Multiaddr(${this.#e})`}};var Ml=new Map;function Fl(r){return!!r?.[qi]}function se(r){return new Ds(r)}var Hl="libp2p-peer-record",Kl=Uint8Array.from([3,1]);var cn;(function(r){let t;(function(n){let s;n.codec=()=>(s==null&&(s=Gt((o,i,c={})=>{c.lengthDelimited!==!1&&i.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(o.multiaddr)),c.lengthDelimited!==!1&&i.ldelim()},(o,i,c={})=>{let a={multiaddr:pt(0)},l=i==null?o.len:o.pos+i;for(;o.pos<l;){let u=o.uint32();switch(u>>>3){case 1:{a.multiaddr=o.bytes();break}default:{o.skipType(u&7);break}}}return a})),s),n.encode=o=>zt(o,n.codec()),n.decode=(o,i)=>$t(o,n.codec(),i)})(t=r.AddressInfo||(r.AddressInfo={}));let e;r.codec=()=>(e==null&&(e=Gt((n,s,o={})=>{if(o.lengthDelimited!==!1&&s.fork(),n.peerId!=null&&n.peerId.byteLength>0&&(s.uint32(10),s.bytes(n.peerId)),n.seq!=null&&n.seq!==0n&&(s.uint32(16),s.uint64(n.seq)),n.addresses!=null)for(let i of n.addresses)s.uint32(26),r.AddressInfo.codec().encode(i,s);o.lengthDelimited!==!1&&s.ldelim()},(n,s,o={})=>{let i={peerId:pt(0),seq:0n,addresses:[]},c=s==null?n.len:n.pos+s;for(;n.pos<c;){let a=n.uint32();switch(a>>>3){case 1:{i.peerId=n.bytes();break}case 2:{i.seq=n.uint64();break}case 3:{if(o.limits?.addresses!=null&&i.addresses.length===o.limits.addresses)throw new Ze('Decode error - map field "addresses" had too many elements');i.addresses.push(r.AddressInfo.codec().decode(n,n.uint32(),{limits:o.limits?.addresses$}));break}default:{n.skipType(a&7);break}}}return i})),e),r.encode=n=>zt(n,r.codec()),r.decode=(n,s)=>$t(n,r.codec(),s)})(cn||(cn={}));var Zt=class r{static createFromProtobuf=t=>{let e=cn.decode(t),n=ki(Fe(e.peerId)),s=(e.addresses??[]).map(i=>se(i.multiaddr)),o=e.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=Hl;static CODEC=Kl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(t){let{peerId:e,multiaddrs:n,seqNumber:s}=t;this.peerId=e,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=cn.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(t=>({multiaddr:t.bytes}))})),this.marshaled}equals(t){return!(!(t instanceof r)||!this.peerId.equals(t.peerId)||this.seqNumber!==t.seqNumber||!Bl(this.multiaddrs,t.multiaddrs))}};function Yd(r){return r[Symbol.asyncIterator]!=null}function Jd(r){if(Yd(r))return(async()=>{for await(let t of r);})();for(let t of r);}var ql=Jd;function Yt(){let r={};return r.promise=new Promise((t,e)=>{r.resolve=t,r.reject=e}),r}var Ms=globalThis.CustomEvent??Event;async function*$i(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=Yt(),c=Yt(),a=!1,l,u=!1;s.addEventListener("task-complete",()=>{c.resolve()}),Promise.resolve().then(async()=>{try{for await(let p of r){if(o.length===e&&(i=Yt(),await i.promise),u)break;let b={done:!1};o.push(b),p().then(d=>{b.done=!0,b.ok=!0,b.value=d,s.dispatchEvent(new Ms("task-complete"))},d=>{b.done=!0,b.err=d,s.dispatchEvent(new Ms("task-complete"))})}a=!0,s.dispatchEvent(new Ms("task-complete"))}catch(p){l=p,s.dispatchEvent(new Ms("task-complete"))}});function f(){return n?o[0]?.done:!!o.find(p=>p.done)}function*h(){for(;o.length>0&&o[0].done;){let p=o[0];if(o.shift(),p.ok)yield p.value;else throw u=!0,i.resolve(),p.err;i.resolve()}}function*m(){for(;f();)for(let p=0;p<o.length;p++)if(o[p].done){let b=o[p];if(o.splice(p,1),p--,b.ok)yield b.value;else throw u=!0,i.resolve(),b.err;i.resolve()}}for(;;){if(f()||(c=Yt(),await c.promise),l!=null)throw l;if(n?yield*h():yield*m(),a&&o.length===0)break}}var Fs=class extends Error{type;code;constructor(t,e,n){super(t??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=e??"ABORT_ERR"}};async function $l(r,t,e){if(t==null)return r;if(t.aborted)return Promise.reject(new Fs(e?.errorMessage,e?.errorCode,e?.errorName));let n,s=new Fs(e?.errorMessage,e?.errorCode,e?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},t.addEventListener("abort",n)})])}finally{n!=null&&t.removeEventListener("abort",n)}}var zi=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Yt(),this.haveNext=Yt()}[Symbol.asyncIterator](){return this}async next(){if(this.nextResult==null&&await this.haveNext.promise,this.nextResult==null)throw new Error("HaveNext promise resolved but nextResult was undefined");let t=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Yt(),t}async throw(t){return this.ended=!0,t!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(t)),{done:!0,value:void 0}}async return(){let t={done:!0,value:void 0};return await this._push(void 0),t}async push(t,e){await this._push(t,e)}async end(t,e){t!=null?await this.throw(t):await this._push(void 0,e)}async _push(t,e){if(t!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;t!=null?this.nextResult={done:!1,value:t}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Yt(),await $l(this.readNext.promise,e?.signal,e)}};function zl(){return new zi}var Hs=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var Gi=class extends Error{code;constructor(t,e){super(t),this.code=e}},Wi=class extends Gi{type;constructor(t){super(t,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Gl(r,t){let e=zl();r.sink(e).catch(async i=>{await e.end(i)}),r.sink=async i=>{for await(let c of i)await e.push(c);await e.end()};let n=r.source;r.source[Symbol.iterator]!=null?n=r.source[Symbol.iterator]():r.source[Symbol.asyncIterator]!=null&&(n=r.source[Symbol.asyncIterator]());let s=new jt;return{read:async(i,c)=>{c?.signal?.throwIfAborted();let a,l=new Promise((u,f)=>{a=()=>{f(new Wi("Read aborted"))},c?.signal?.addEventListener("abort",a)});try{if(i==null){let{done:f,value:h}=await Promise.race([n.next(),l]);return f===!0?new jt:h}for(;s.byteLength<i;){let{value:f,done:h}=await Promise.race([n.next(),l]);if(h===!0)throw new Hs("unexpected end of input");s.append(f)}let u=s.sublist(0,i);return s.consume(i),u}finally{a!=null&&c?.signal?.removeEventListener("abort",a)}},write:async(i,c)=>{c?.signal?.throwIfAborted(),i instanceof Uint8Array?await e.push(i,c):await e.push(i.subarray(),c)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){t?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var Ks=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},qs=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},$s=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Wl(r,t={}){let e=Gl(r,t);t.maxDataLength!=null&&t.maxLengthLength==null&&(t.maxLengthLength=xt(t.maxDataLength));let n=t?.lengthDecoder??de,s=t?.lengthEncoder??Ot;return{read:async i=>{let c=-1,a=new jt;for(;;){a.append(await e.read(1,i));try{c=n(a)}catch(l){if(l instanceof RangeError)continue;throw l}if(c<0)throw new Ks("Invalid message length");if(t?.maxLengthLength!=null&&a.byteLength>t.maxLengthLength)throw new $s("message length length too long");if(c>-1)break}if(t?.maxDataLength!=null&&c>t.maxDataLength)throw new qs("message length too long");return e.read(c,i)},write:async(i,c)=>{await e.write(new jt(s(i.byteLength),i),c)},writeV:async(i,c)=>{let a=new jt(...i.flatMap(l=>[s(l.byteLength),l]));await e.write(a,c)},unwrap:()=>e.unwrap()}}function Ir(r,t){let e=Wl(r,t),n={read:async(s,o)=>{let i=await e.read(o);return s.decode(i)},write:async(s,o,i)=>{await e.write(o.encode(s),i)},writeV:async(s,o,i)=>{await e.writeV(s.map(c=>o.encode(c)),i)},pb:s=>({read:async o=>n.read(s,o),write:async(o,i)=>n.write(o,s,i),writeV:async(o,i)=>n.writeV(o,s,i),unwrap:()=>n}),unwrap:()=>e.unwrap()};return n}var jl="0.1.0",Zl="id",Yl="id/push",Jl="1.0.0",Xl="1.0.0";var De;(function(r){let t;r.codec=()=>(t==null&&(t=Gt((e,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),e.protocolVersion!=null&&(n.uint32(42),n.string(e.protocolVersion)),e.agentVersion!=null&&(n.uint32(50),n.string(e.agentVersion)),e.publicKey!=null&&(n.uint32(10),n.bytes(e.publicKey)),e.listenAddrs!=null)for(let o of e.listenAddrs)n.uint32(18),n.bytes(o);if(e.observedAddr!=null&&(n.uint32(34),n.bytes(e.observedAddr)),e.protocols!=null)for(let o of e.protocols)n.uint32(26),n.string(o);e.signedPeerRecord!=null&&(n.uint32(66),n.bytes(e.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(e,n,s={})=>{let o={listenAddrs:[],protocols:[]},i=n==null?e.len:e.pos+n;for(;e.pos<i;){let c=e.uint32();switch(c>>>3){case 5:{o.protocolVersion=e.string();break}case 6:{o.agentVersion=e.string();break}case 1:{o.publicKey=e.bytes();break}case 2:{if(s.limits?.listenAddrs!=null&&o.listenAddrs.length===s.limits.listenAddrs)throw new Ze('Decode error - map field "listenAddrs" had too many elements');o.listenAddrs.push(e.bytes());break}case 4:{o.observedAddr=e.bytes();break}case 3:{if(s.limits?.protocols!=null&&o.protocols.length===s.limits.protocols)throw new Ze('Decode error - map field "protocols" had too many elements');o.protocols.push(e.string());break}case 8:{o.signedPeerRecord=e.bytes();break}default:{e.skipType(c&7);break}}}return o})),t),r.encode=e=>zt(e,r.codec()),r.decode=(e,n)=>$t(e,r.codec(),n)})(De||(De={}));var eu=ro(tu(),1),ji=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,zs=(0,eu.default)(),ru=ji&&!zs,nu=zs&&!ji,su=zs&&ji,ou=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!zs,iu=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Tx=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",au=typeof navigator<"u"&&navigator.product==="ReactNative";var Rt={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function cu(r){if(r!=null&&r.length>0)try{return se(r)}catch{}}function e0(r,t){return t!=null||(t=`${r.name}/${r.version}`,ou||nu?t+=` UserAgent=${globalThis.process.version}`:(ru||iu||su||au)&&(t+=` UserAgent=${globalThis.navigator.userAgent}`)),t}async function Gs(r,t,e,n,s){if(e("received identify from %p",n.remotePeer),s==null)throw new Dt("message was null or undefined");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(a=>({isCertified:!1,multiaddr:se(a)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null){let a=xr(s.publicKey);if(!El(a).equals(n.remotePeer))throw new Dt("public key did not match remote PeerId");o.publicKey=a}let i;if(s.signedPeerRecord!=null){e.trace("received signedPeerRecord from %p",n.remotePeer);let a=s.signedPeerRecord,l=await ne.openAndCertify(a,Zt.DOMAIN),u=Zt.createFromProtobuf(l.payload),f=Rs(l.publicKey.toCID());if(!u.peerId.equals(f))throw new Dt("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(u.peerId))throw new Dt("signing key does not match remote PeerId");let h;try{h=await r.get(u.peerId)}catch(m){if(m.name!=="NotFoundError")throw m}if(h!=null&&(o.metadata=h.metadata,h.peerRecordEnvelope!=null)){let m=await ne.createFromProtobuf(h.peerRecordEnvelope),p=Zt.createFromProtobuf(m.payload);p.seqNumber>=u.seqNumber&&(e("sequence number was lower or equal to existing sequence number - stored: %d received: %d",p.seqNumber,u.seqNumber),u=p,a=h.peerRecordEnvelope)}o.peerRecordEnvelope=a,o.addresses=u.multiaddrs.map(m=>({isCertified:!0,multiaddr:m})),i={seq:u.seqNumber,addresses:u.multiaddrs}}else e("%p did not send a signed peer record",n.remotePeer);if(e.trace("patching %p with",n.remotePeer,o),await r.patch(n.remotePeer,o),s.agentVersion!=null||s.protocolVersion!=null){let a={};s.agentVersion!=null&&(a.AgentVersion=$(s.agentVersion)),s.protocolVersion!=null&&(a.ProtocolVersion=$(s.protocolVersion)),e.trace("merging %p metadata",n.remotePeer,a),await r.merge(n.remotePeer,{metadata:a})}let c={peerId:n.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map(a=>se(a)),observedAddr:s.observedAddr==null?void 0:se(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return t.safeDispatchEvent("peer:identify",{detail:c}),c}var kr=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(t,e){this.protocol=e.protocol,this.started=!1,this.peerId=t.peerId,this.privateKey=t.privateKey,this.peerStore=t.peerStore,this.registrar=t.registrar,this.addressManager=t.addressManager,this.events=t.events,this.log=e.log,this.timeout=e.timeout??Rt.timeout,this.maxInboundStreams=e.maxInboundStreams??Rt.maxInboundStreams,this.maxOutboundStreams=e.maxOutboundStreams??Rt.maxOutboundStreams,this.maxMessageSize=e.maxMessageSize??Rt.maxMessageSize,this.maxObservedAddresses=e.maxObservedAddresses??Rt.maxObservedAddresses,this.runOnLimitedConnection=e.runOnLimitedConnection??Rt.runOnLimitedConnection,this.host={protocolVersion:`${e.protocolPrefix??Rt.protocolPrefix}/${jl}`,agentVersion:e0(t.nodeInfo,e.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:$(this.host.agentVersion),ProtocolVersion:$(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,t=>{this.handleProtocol(t).catch(e=>{this.log.error(e)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Ws=class extends kr{connectionManager;concurrency;constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${Yl}/${Xl}`,log:t.logger.forComponent("libp2p:identify-push")}),this.connectionManager=t.connectionManager,this.concurrency=e.concurrency??Rt.concurrency,(e.runOnSelfUpdate??Rt.runOnSelfUpdate)&&t.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[yn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let t=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),e=new Zt({peerId:this.peerId,multiaddrs:t}),n=await ne.seal(e,this.privateKey),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=Q(o.metadata.get("AgentVersion")??$(this.host.agentVersion)),c=Q(o.metadata.get("ProtocolVersion")??$(this.host.protocolVersion)),a=this;async function*l(){for(let u of a.connectionManager.getConnections())(await a.peerStore.get(u.remotePeer)).protocols.includes(a.protocol)&&(yield async()=>{let h,m=AbortSignal.timeout(a.timeout);Tr(1/0,m);try{h=await u.newStream(a.protocol,{signal:m,runOnLimitedConnection:a.runOnLimitedConnection}),await Ir(h,{maxDataLength:a.maxMessageSize}).pb(De).write({listenAddrs:t.map(b=>b.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:c},{signal:m}),await h.close({signal:m})}catch(p){a.log.error("could not push identify update to peer",p),h?.abort(p)}})}await ql($i(l(),{concurrency:this.concurrency}))}async handleProtocol(t){let{connection:e,stream:n}=t;try{if(this.peerId.equals(e.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await Ir(n,{maxDataLength:this.maxMessageSize}).pb(De).read(s);await n.close(s),await Gs(this.peerStore,this.events,this.log,e,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log.trace("handled push from %p",e.remotePeer)}};var r0=41;function lu(r){try{let[[t,e]]=r.stringTuples();if(e==null)return!1;if(t===r0)return Tl("2000::/3",e)}catch{}return!1}var fu=ro(uu(),1),n0=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"],s0=n0.map(r=>new fu.Netmask(r));function Zi(r){for(let t of s0)if(t.contains(r))return!0;return!1}function o0(r){return/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(r)}function i0(r){let t=r.split(":");if(t.length<2)return!1;let e=t[t.length-1].padStart(4,"0"),n=t[t.length-2].padStart(4,"0"),s=`${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}.${parseInt(e.substring(0,2),16)}.${parseInt(e.substring(2),16)}`;return Zi(s)}function a0(r){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)}function c0(r){let t=r.split(":"),e=t[t.length-1];return Zi(e)}function l0(r){return/^::$/.test(r)||/^::1$/.test(r)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(r)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(r)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(r)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(r)||/^ff([0-9a-fA-F]{2,2}):/i.test(r)}function hu(r){return Br(r)?Zi(r):o0(r)?i0(r):a0(r)?c0(r):Ar(r)?l0(r):void 0}var u0=4,f0=41,h0=53,d0=54,p0=55,m0=56;function du(r){try{let[[t,e]]=r.stringTuples();if(e==null)return!0;if(t===h0||t===d0||t===p0||t===m0)return!1;if(t===u0||t===f0)return hu(e)??!1}catch{}return!0}var g0=r=>r.toString().split("/").slice(1),Nr=r=>({match:t=>t.length<1?!1:r(t[0])?t.slice(1):!1,pattern:"fn"}),H=r=>({match:t=>Nr(e=>e===r).match(t),pattern:r}),er=()=>({match:r=>Nr(t=>typeof t=="string").match(r),pattern:"{string}"}),un=()=>({match:r=>Nr(t=>!isNaN(parseInt(t))).match(r),pattern:"{number}"}),Y=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{X.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),fn=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Zo.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),G=r=>({match:t=>{let e=r.match(t);return e===!1?t:e},pattern:`optional(${r.pattern})`}),Bt=(...r)=>({match:t=>{let e;for(let n of r){let s=n.match(t);s!==!1&&(e==null||s.length<e.length)&&(e=s)}return e??!1},pattern:`or(${r.map(t=>t.pattern).join(", ")})`}),K=(...r)=>({match:t=>{for(let e of r){let n=e.match(t);if(n===!1)return!1;t=n}return t},pattern:`and(${r.map(t=>t.pattern).join(", ")})`});function st(...r){function t(s){let o=g0(s);for(let i of r){let c=i.match(o);if(c===!1)return!1;o=c}return o}function e(s){return t(s)!==!1}function n(s){let o=t(s);return o===!1?!1:o.length===0}return{matchers:r,matches:e,exactMatch:n}}var Zs=K(H("dns4"),er()),Ys=K(H("dns6"),er()),Js=K(H("dnsaddr"),er()),Ji=K(H("dns"),er()),f1=st(Zs,G(Y())),h1=st(Ys,G(Y())),d1=st(Js,G(Y())),p1=st(Bt(Ji,Js,Zs,Ys),G(Y())),pu=K(H("ip4"),Nr(Br)),mu=K(H("ip6"),Nr(Ar)),Xi=Bt(pu,mu),Ee=Bt(Xi,Ji,Zs,Ys,Js),gu=st(Bt(Xi,K(Bt(Ji,Js,Zs,Ys),G(Y())))),m1=st(pu),g1=st(mu),y1=st(Xi),Qi=K(Ee,H("tcp"),un()),hn=K(Ee,H("udp"),un()),yu=st(K(Qi,G(Y()))),b1=st(hn),ta=K(hn,H("quic"),G(Y())),Xs=K(hn,H("quic-v1"),G(Y())),y0=Bt(ta,Xs),w1=st(ta),x1=st(Xs),Yi=Bt(Ee,Qi,hn,ta,Xs),bu=Bt(K(Yi,H("ws"),G(Y()))),v1=st(bu),wu=Bt(K(Yi,H("wss"),G(Y())),K(Yi,H("tls"),G(K(H("sni"),er())),H("ws"),G(Y()))),E1=st(wu),xu=K(hn,H("webrtc-direct"),G(fn()),G(fn()),G(Y())),B1=st(xu),vu=K(Xs,H("webtransport"),G(fn()),G(fn()),G(Y())),A1=st(vu),js=Bt(bu,wu,K(Qi,G(Y())),K(y0,G(Y())),K(Ee,G(Y())),xu,vu,Y()),S1=st(js),b0=K(js,H("p2p-circuit"),Y()),I1=st(b0),w0=Bt(K(js,H("p2p-circuit"),H("webrtc"),G(Y())),K(js,H("webrtc"),G(Y())),K(H("webrtc"),G(Y()))),k1=st(w0),x0=Bt(K(Ee,H("tcp"),un(),H("http"),G(Y())),K(Ee,H("http"),G(Y()))),N1=st(x0),v0=Bt(K(Ee,H("tcp"),Bt(K(H("443"),H("http")),K(un(),H("https"))),G(Y())),K(Ee,H("tls"),H("http"),G(Y())),K(Ee,H("https"),G(Y()))),C1=st(v0),E0=Bt(K(H("memory"),er(),G(Y()))),T1=st(E0);var B0=41,Qs=class extends kr{constructor(t,e={}){super(t,{...e,protocol:`/${e.protocolPrefix??Rt.protocolPrefix}/${Zl}/${Jl}`,log:t.logger.forComponent("libp2p:identify")}),(e.runOnConnectionOpen??Rt.runOnConnectionOpen)&&t.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{o.name!==gn.name&&this.log.error("error during identify trigged by connection:open",o)})})}[yn]=["@libp2p/identify"];async _identify(t,e={}){let n;if(e.signal==null){let s=AbortSignal.timeout(this.timeout);Tr(1/0,s),e={...e,signal:s}}try{n=await t.newStream(this.protocol,{...e,runOnLimitedConnection:this.runOnLimitedConnection});let o=await Ir(n,{maxDataLength:this.maxMessageSize}).pb(De).read(e);return await n.close(e),o}catch(s){throw n?.abort(s),s}}async identify(t,e={}){let n=await this._identify(t,e),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new Dt("public key was missing from identify message");let c=xr(s),a=Rs(c.toCID());if(!t.remotePeer.equals(a))throw new Dt("identified peer does not match the expected peer");if(this.peerId.equals(a))throw new Dt("identified peer is our own peer id?");return this.maybeAddObservedAddress(i),this.log("identify completed for peer %p and protocols %o",a,o),Gs(this.peerStore,this.events,this.log,t,n)}maybeAddObservedAddress(t){let e=cu(t);if(e==null)return;if(this.log.trace("our observed address was %a",e),du(e)){this.log.trace("our observed address was private");return}if(e.stringTuples()[0][0]===B0&&!lu(e)){this.log.trace("our observed address was IPv6 but not a global unicast address");return}yu.exactMatch(e)||(this.log.trace("storing the observed address"),this.addressManager.addObservedAddr(e))}async handleProtocol(t){let{connection:e,stream:n}=t,s=AbortSignal.timeout(this.timeout);Tr(1/0,s);try{let o=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(u=>u.decapsulateCode(z("p2p").code)),c=o.peerRecordEnvelope;if(i.length>0&&c==null){let u=new Zt({peerId:this.peerId,multiaddrs:i});c=(await ne.seal(u,this.privateKey)).marshal().subarray()}let a=e.remoteAddr.bytes;gu.matches(e.remoteAddr)||(a=void 0),await Ir(n).pb(De).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:Ue(this.privateKey.publicKey),listenAddrs:i.map(u=>u.bytes),signedPeerRecord:c,observedAddr:a,protocols:o.protocols},{signal:s}),await n.close({signal:s})}catch(o){this.log.error("could not respond to identify request",o),n.abort(o)}}};function A0(r={}){return t=>new Qs(t,r)}function S0(r={}){return t=>new Ws(t,r)}return Pu(I0);})();
7
7
  /*! Bundled license information:
8
8
 
9
9
  pvtsutils/build/index.js:
@@ -51,8 +51,6 @@ export interface IdentifyInit {
51
51
  protocolPrefix?: string;
52
52
  /**
53
53
  * What details we should send as part of an identify message
54
- *
55
- * @deprecated Use `nodeInfo.userAgent` in the main libp2p config instead
56
54
  */
57
55
  agentVersion?: string;
58
56
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC3K,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE9F,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAEhC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,YAAY,EAAE,qBAAqB,CAAC;IACjF;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,EAAE,SAAS,CAAA;IACpB,cAAc,EAAE,cAAc,CAAA;IAC9B,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;IACtC,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,iBAAiB,EAAE,iBAAiB,CAAA;CACrC;AAED,MAAM,WAAW,QAAQ;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CAClF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED,wBAAgB,QAAQ,CAAE,IAAI,GAAE,YAAiB,GAAG,CAAC,UAAU,EAAE,kBAAkB,KAAK,QAAQ,CAE/F;AAED,wBAAgB,YAAY,CAAE,IAAI,GAAE,gBAAqB,GAAG,CAAC,UAAU,EAAE,sBAAsB,KAAK,YAAY,CAE/G"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC3K,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE9F,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAEhC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,MAAM,WAAW,gBAAiB,SAAQ,IAAI,CAAC,YAAY,EAAE,qBAAqB,CAAC;IACjF;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IAEzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,UAAU,CAAA;IACtB,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,EAAE,SAAS,CAAA;IACpB,cAAc,EAAE,cAAc,CAAA;IAC9B,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;IACtC,MAAM,EAAE,eAAe,CAAA;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB;AAED,MAAM,WAAW,sBAAuB,SAAQ,kBAAkB;IAChE,iBAAiB,EAAE,iBAAiB,CAAA;CACrC;AAED,MAAM,WAAW,QAAQ;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;CAClF;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACtB;AAED,wBAAgB,QAAQ,CAAE,IAAI,GAAE,YAAiB,GAAG,CAAC,UAAU,EAAE,kBAAkB,KAAK,QAAQ,CAE/F;AAED,wBAAgB,YAAY,CAAE,IAAI,GAAE,gBAAqB,GAAG,CAAC,UAAU,EAAE,sBAAsB,KAAK,YAAY,CAE/G"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AAmHzD,MAAM,UAAU,QAAQ,CAAE,OAAqB,EAAE;IAC/C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAE,OAAyB,EAAE;IACvD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAChE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,YAAY,IAAI,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,eAAe,CAAA;AAiHzD,MAAM,UAAU,QAAQ,CAAE,OAAqB,EAAE;IAC/C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAC5D,CAAC;AAED,MAAM,UAAU,YAAY,CAAE,OAAyB,EAAE;IACvD,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AAChE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAA;AAGnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAoB,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAkB,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACrN,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3E,eAAO,MAAM,aAAa;;;;;;;;;;;CAWzB,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAQtG;AAED,wBAAgB,eAAe,CAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAMlF;AAED,wBAAsB,sBAAsB,CAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAoIlM;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,8BAAsB,gBAAiB,YAAW,SAAS;IACzD,SAAgB,IAAI,EAAE;QACpB,eAAe,EAAE,MAAM,CAAA;QACvB,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IAED,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,OAAO,EAAE,OAAO,CAAA;IAC1B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAClC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACjC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IACzC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IACvC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IACvC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;IACjD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAC3C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IACzC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IAC/C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;IACzD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAA;IAClD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;gBAEjB,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,oBAAoB;IAyBvE,SAAS,IAAK,OAAO;IAIf,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAyBvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAM5B,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAC5E"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,SAAS,EAAa,MAAM,yBAAyB,CAAA;AAInE,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAClE,OAAO,KAAK,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAoB,MAAM,EAAE,UAAU,EAAE,gBAAgB,EAAkB,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACrN,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAE3E,eAAO,MAAM,aAAa;;;;;;;;;;;CAWzB,CAAA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAQtG;AAED,wBAAgB,eAAe,CAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAclF;AAED,wBAAsB,sBAAsB,CAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,cAAc,CAAC,CAoIlM;AAED,MAAM,WAAW,oBAAqB,SAAQ,YAAY;IACxD,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,8BAAsB,gBAAiB,YAAW,SAAS;IACzD,SAAgB,IAAI,EAAE;QACpB,eAAe,EAAE,MAAM,CAAA;QACvB,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IAED,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAA;IAC1B,SAAS,CAAC,OAAO,EAAE,OAAO,CAAA;IAC1B,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IAClC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACjC,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;IACzC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IACvC,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IACvC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,cAAc,CAAA;IACjD,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAQ;IAC1C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAQ;IAC3C,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IACzC,SAAS,CAAC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IAC/C,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAA;IACzD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,OAAO,CAAA;IAClD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;gBAEjB,UAAU,EAAE,kBAAkB,EAAE,IAAI,EAAE,oBAAoB;IAyBvE,SAAS,IAAK,OAAO;IAIf,KAAK,IAAK,OAAO,CAAC,IAAI,CAAC;IAyBvB,IAAI,IAAK,OAAO,CAAC,IAAI,CAAC;IAM5B,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAE,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAC5E"}
package/dist/src/utils.js CHANGED
@@ -4,6 +4,7 @@ import { peerIdFromCID, peerIdFromPublicKey } from '@libp2p/peer-id';
4
4
  import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record';
5
5
  import { multiaddr } from '@multiformats/multiaddr';
6
6
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
7
+ import { isNode, isBrowser, isWebWorker, isElectronMain, isElectronRenderer, isReactNative } from 'wherearewe';
7
8
  import { IDENTIFY_PROTOCOL_VERSION, MAX_IDENTIFY_MESSAGE_SIZE, MAX_PUSH_CONCURRENCY } from './consts.js';
8
9
  export const defaultValues = {
9
10
  protocolPrefix: 'ipfs',
@@ -33,7 +34,15 @@ export function getAgentVersion(nodeInfo, agentVersion) {
33
34
  if (agentVersion != null) {
34
35
  return agentVersion;
35
36
  }
36
- return nodeInfo.userAgent;
37
+ agentVersion = `${nodeInfo.name}/${nodeInfo.version}`;
38
+ // Append user agent version to default AGENT_VERSION depending on the environment
39
+ if (isNode || isElectronMain) {
40
+ agentVersion += ` UserAgent=${globalThis.process.version}`;
41
+ }
42
+ else if (isBrowser || isWebWorker || isElectronRenderer || isReactNative) {
43
+ agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`;
44
+ }
45
+ return agentVersion;
37
46
  }
38
47
  export async function consumeIdentifyMessage(peerStore, events, log, connection, message) {
39
48
  log('received identify from %p', connection.remotePeer);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAkB,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMxG,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,cAAc,EAAE,MAAM;IACtB,OAAO,EAAE,IAAI;IACb,iBAAiB,EAAE,CAAC;IACpB,kBAAkB,EAAE,CAAC;IACrB,oBAAoB,EAAE,EAAE;IACxB,cAAc,EAAE,yBAAyB;IACzC,mBAAmB,EAAE,IAAI;IACzB,eAAe,EAAE,IAAI;IACrB,sBAAsB,EAAE,IAAI;IAC5B,WAAW,EAAE,oBAAoB;CAClC,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAE,IAA4C;IAC7E,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC;YACH,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;QAAC,MAAM,CAAC;QAET,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAE,QAAkB,EAAE,YAAqB;IACxE,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,OAAO,QAAQ,CAAC,SAAS,CAAA;AAC3B,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAE,SAAoB,EAAE,MAAsC,EAAE,GAAW,EAAE,UAAsB,EAAE,OAAwB;IACvK,GAAG,CAAC,2BAA2B,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IAEvD,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,mBAAmB,CAAC,+BAA+B,CAAC,CAAA;IAChE,CAAC;IAED,MAAM,IAAI,GAAa,EAAE,CAAA;IAEzB,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC;SAC1B,CAAC,CAAC,CAAA;IACL,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;IACpC,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAC1D,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAA;QAE7C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,mBAAmB,CAAC,wCAAwC,CAAC,CAAA;QACzE,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,IAAI,MAAoC,CAAA;IAExC,6GAA6G;IAC7G,IAAI,OAAO,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;QACrC,GAAG,CAAC,KAAK,CAAC,mCAAmC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;QAErE,IAAI,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAA;QACjD,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,kBAAkB,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QAC3F,IAAI,UAAU,GAAG,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAChE,MAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;QAE9D,gBAAgB;QAChB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAAC,qDAAqD,CAAC,CAAA;QACtF,CAAC;QAED,sDAAsD;QACtD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,mBAAmB,CAAC,0CAA0C,CAAC,CAAA;QAC3E,CAAC;QAED,IAAI,YAA8B,CAAA;QAElC,IAAI,CAAC;YACH,YAAY,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACvD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;gBACjC,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;QAED,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;YACzB,mCAAmC;YACnC,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAA;YAErC,+FAA+F;YAC/F,IAAI,YAAY,CAAC,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAC5C,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAA;gBAC/F,MAAM,YAAY,GAAG,UAAU,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;gBAE1E,6DAA6D;gBAC7D,IAAI,YAAY,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;oBACnD,GAAG,CAAC,0FAA0F,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;oBAC7I,UAAU,GAAG,YAAY,CAAA;oBACzB,kBAAkB,GAAG,YAAY,CAAC,kBAAkB,CAAA;gBACtD,CAAC;YACH,CAAC;QACH,CAAC;QAED,wCAAwC;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAE5C,2DAA2D;QAC3D,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YACvD,WAAW,EAAE,IAAI;YACjB,SAAS;SACV,CAAC,CAAC,CAAA;QAEH,MAAM,GAAG;YACP,GAAG,EAAE,UAAU,CAAC,SAAS;YACzB,SAAS,EAAE,UAAU,CAAC,UAAU;SACjC,CAAA;IACH,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IACpE,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,kBAAkB,EAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAC1D,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAElD,IAAI,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;QACpE,MAAM,QAAQ,GAA+B,EAAE,CAAA;QAE/C,IAAI,OAAO,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC;YACjC,QAAQ,CAAC,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;QACpE,CAAC;QAED,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;YACpC,QAAQ,CAAC,eAAe,GAAG,oBAAoB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QAC1E,CAAC;QAED,GAAG,CAAC,KAAK,CAAC,qBAAqB,EAAE,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QACjE,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE;YAC3C,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,MAAM,GAAmB;QAC7B,MAAM,EAAE,UAAU,CAAC,UAAU;QAC7B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC3D,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC;QACxF,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,gBAAgB,EAAE,MAAM;QACxB,UAAU;KACX,CAAA;IAED,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAE7D,OAAO,MAAM,CAAA;AACf,CAAC;AAOD,MAAM,OAAgB,gBAAgB;IACpB,IAAI,CAGnB;IAES,QAAQ,CAAQ;IAChB,OAAO,CAAS;IACP,OAAO,CAAQ;IACf,MAAM,CAAQ;IACd,UAAU,CAAY;IACtB,SAAS,CAAW;IACpB,SAAS,CAAW;IACpB,cAAc,CAAgB;IAChC,iBAAiB,CAAQ;IACzB,kBAAkB,CAAQ;IACxB,cAAc,CAAQ;IACtB,oBAAoB,CAAQ;IAC5B,MAAM,CAAgC;IACtC,sBAAsB,CAAS;IAC/B,GAAG,CAAQ;IAE9B,YAAa,UAA8B,EAAE,IAA0B;QACrE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAA;QACvC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;QACrC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAA;QAC/C,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;QAC/B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QAEnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAA;QACpD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,IAAI,aAAa,CAAC,iBAAiB,CAAA;QAClF,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,IAAI,aAAa,CAAC,kBAAkB,CAAA;QACrF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,CAAA;QACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,IAAI,aAAa,CAAC,oBAAoB,CAAA;QAC3F,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,IAAI,aAAa,CAAC,sBAAsB,CAAA;QAEjG,2BAA2B;QAC3B,IAAI,CAAC,IAAI,GAAG;YACV,eAAe,EAAE,GAAG,IAAI,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,IAAI,yBAAyB,EAAE;YACtG,YAAY,EAAE,eAAe,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC;SACtE,CAAA;IACH,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAM;QACR,CAAC;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;YACtC,QAAQ,EAAE;gBACR,YAAY,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1D,eAAe,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;aACjE;SACF,CAAC,CAAA;QAEF,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;YAClD,KAAK,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;gBACzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACrB,CAAC,CAAC,CAAA;QACJ,CAAC,EAAE;YACD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;SACpD,CAAC,CAAA;QAEF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAE5C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;CAGF"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACpE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAkB,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC9G,OAAO,EAAE,yBAAyB,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAMxG,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,cAAc,EAAE,MAAM;IACtB,OAAO,EAAE,IAAI;IACb,iBAAiB,EAAE,CAAC;IACpB,kBAAkB,EAAE,CAAC;IACrB,oBAAoB,EAAE,EAAE;IACxB,cAAc,EAAE,yBAAyB;IACzC,mBAAmB,EAAE,IAAI;IACzB,eAAe,EAAE,IAAI;IACrB,sBAAsB,EAAE,IAAI;IAC5B,WAAW,EAAE,oBAAoB;CAClC,CAAA;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAE,IAA4C;IAC7E,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,IAAI,CAAC;YACH,OAAO,SAAS,CAAC,IAAI,CAAC,CAAA;QACxB,CAAC;QAAC,MAAM,CAAC;QAET,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,eAAe,CAAE,QAAkB,EAAE,YAAqB;IACxE,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,YAAY,CAAA;IACrB,CAAC;IAED,YAAY,GAAG,GAAG,QAAQ,CAAC,IAAI,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAA;IACrD,kFAAkF;IAClF,IAAI,MAAM,IAAI,cAAc,EAAE,CAAC;QAC7B,YAAY,IAAI,cAAc,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IAC5D,CAAC;SAAM,IAAI,SAAS,IAAI,WAAW,IAAI,kBAAkB,IAAI,aAAa,EAAE,CAAC;QAC3E,YAAY,IAAI,cAAc,UAAU,CAAC,SAAS,CAAC,SAAS,EAAE,CAAA;IAChE,CAAC;IAED,OAAO,YAAY,CAAA;AACrB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAE,SAAoB,EAAE,MAAsC,EAAE,GAAW,EAAE,UAAsB,EAAE,OAAwB;IACvK,GAAG,CAAC,2BAA2B,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IAEvD,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,mBAAmB,CAAC,+BAA+B,CAAC,CAAA;IAChE,CAAC;IAED,MAAM,IAAI,GAAa,EAAE,CAAA;IAEzB,IAAI,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC/C,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,SAAS,CAAC,GAAG,CAAC;SAC1B,CAAC,CAAC,CAAA;IACL,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;IACpC,CAAC;IAED,IAAI,OAAO,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,qBAAqB,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAC1D,MAAM,MAAM,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAA;QAE7C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YAC1C,MAAM,IAAI,mBAAmB,CAAC,wCAAwC,CAAC,CAAA;QACzE,CAAC;QAED,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;IAC5B,CAAC;IAED,IAAI,MAAoC,CAAA;IAExC,6GAA6G;IAC7G,IAAI,OAAO,CAAC,gBAAgB,IAAI,IAAI,EAAE,CAAC;QACrC,GAAG,CAAC,KAAK,CAAC,mCAAmC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;QAErE,IAAI,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAA;QACjD,MAAM,QAAQ,GAAG,MAAM,cAAc,CAAC,cAAc,CAAC,kBAAkB,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QAC3F,IAAI,UAAU,GAAG,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAChE,MAAM,YAAY,GAAG,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;QAE9D,gBAAgB;QAChB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAAC,qDAAqD,CAAC,CAAA;QACtF,CAAC;QAED,sDAAsD;QACtD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,mBAAmB,CAAC,0CAA0C,CAAC,CAAA;QAC3E,CAAC;QAED,IAAI,YAA8B,CAAA;QAElC,IAAI,CAAC;YACH,YAAY,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;QACvD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE,CAAC;gBACjC,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;QAED,IAAI,YAAY,IAAI,IAAI,EAAE,CAAC;YACzB,mCAAmC;YACnC,IAAI,CAAC,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAA;YAErC,+FAA+F;YAC/F,IAAI,YAAY,CAAC,kBAAkB,IAAI,IAAI,EAAE,CAAC;gBAC5C,MAAM,cAAc,GAAG,MAAM,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAA;gBAC/F,MAAM,YAAY,GAAG,UAAU,CAAC,kBAAkB,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;gBAE1E,6DAA6D;gBAC7D,IAAI,YAAY,CAAC,SAAS,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC;oBACnD,GAAG,CAAC,0FAA0F,EAAE,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;oBAC7I,UAAU,GAAG,YAAY,CAAA;oBACzB,kBAAkB,GAAG,YAAY,CAAC,kBAAkB,CAAA;gBACtD,CAAC;YACH,CAAC;QACH,CAAC;QAED,wCAAwC;QACxC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;QAE5C,2DAA2D;QAC3D,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;YACvD,WAAW,EAAE,IAAI;YACjB,SAAS;SACV,CAAC,CAAC,CAAA;QAEH,MAAM,GAAG;YACP,GAAG,EAAE,UAAU,CAAC,SAAS;YACzB,SAAS,EAAE,UAAU,CAAC,UAAU;SACjC,CAAA;IACH,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,sCAAsC,EAAE,UAAU,CAAC,UAAU,CAAC,CAAA;IACpE,CAAC;IAED,GAAG,CAAC,KAAK,CAAC,kBAAkB,EAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAC1D,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;IAElD,IAAI,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;QACpE,MAAM,QAAQ,GAA+B,EAAE,CAAA;QAE/C,IAAI,OAAO,CAAC,YAAY,IAAI,IAAI,EAAE,CAAC;YACjC,QAAQ,CAAC,YAAY,GAAG,oBAAoB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;QACpE,CAAC;QAED,IAAI,OAAO,CAAC,eAAe,IAAI,IAAI,EAAE,CAAC;YACpC,QAAQ,CAAC,eAAe,GAAG,oBAAoB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QAC1E,CAAC;QAED,GAAG,CAAC,KAAK,CAAC,qBAAqB,EAAE,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA;QACjE,MAAM,SAAS,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,EAAE;YAC3C,QAAQ;SACT,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,MAAM,GAAmB;QAC7B,MAAM,EAAE,UAAU,CAAC,UAAU;QAC7B,eAAe,EAAE,OAAO,CAAC,eAAe;QACxC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC3D,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC;QACxF,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,gBAAgB,EAAE,MAAM;QACxB,UAAU;KACX,CAAA;IAED,MAAM,CAAC,iBAAiB,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;IAE7D,OAAO,MAAM,CAAA;AACf,CAAC;AAOD,MAAM,OAAgB,gBAAgB;IACpB,IAAI,CAGnB;IAES,QAAQ,CAAQ;IAChB,OAAO,CAAS;IACP,OAAO,CAAQ;IACf,MAAM,CAAQ;IACd,UAAU,CAAY;IACtB,SAAS,CAAW;IACpB,SAAS,CAAW;IACpB,cAAc,CAAgB;IAChC,iBAAiB,CAAQ;IACzB,kBAAkB,CAAQ;IACxB,cAAc,CAAQ;IACtB,oBAAoB,CAAQ;IAC5B,MAAM,CAAgC;IACtC,sBAAsB,CAAS;IAC/B,GAAG,CAAQ;IAE9B,YAAa,UAA8B,EAAE,IAA0B;QACrE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC7B,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,CAAA;QACvC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;QACrC,IAAI,CAAC,SAAS,GAAG,UAAU,CAAC,SAAS,CAAA;QACrC,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,cAAc,CAAA;QAC/C,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;QAC/B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAA;QAEnB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAA;QACpD,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,IAAI,aAAa,CAAC,iBAAiB,CAAA;QAClF,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,IAAI,aAAa,CAAC,kBAAkB,CAAA;QACrF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,CAAA;QACzE,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC,oBAAoB,IAAI,aAAa,CAAC,oBAAoB,CAAA;QAC3F,IAAI,CAAC,sBAAsB,GAAG,IAAI,CAAC,sBAAsB,IAAI,aAAa,CAAC,sBAAsB,CAAA;QAEjG,2BAA2B;QAC3B,IAAI,CAAC,IAAI,GAAG;YACV,eAAe,EAAE,GAAG,IAAI,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,IAAI,yBAAyB,EAAE;YACtG,YAAY,EAAE,eAAe,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,CAAC;SACtE,CAAA;IACH,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,OAAM;QACR,CAAC;QAED,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE;YACtC,QAAQ,EAAE;gBACR,YAAY,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC;gBAC1D,eAAe,EAAE,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC;aACjE;SACF,CAAC,CAAA;QAEF,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE;YAClD,KAAK,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;gBACzC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACrB,CAAC,CAAC,CAAA;QACJ,CAAC,EAAE;YACD,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,sBAAsB,EAAE,IAAI,CAAC,sBAAsB;SACpD,CAAC,CAAA;QAEF,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;IACrB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAE5C,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;IACtB,CAAC;CAGF"}
@@ -0,0 +1,18 @@
1
+ {
2
+ "Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
3
+ ".:Identify": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.Identify.html",
4
+ "IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
5
+ ".:IdentifyComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyComponents.html",
6
+ "IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
7
+ ".:IdentifyInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyInit.html",
8
+ "IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
9
+ ".:IdentifyPush": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPush.html",
10
+ "IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
11
+ ".:IdentifyPushComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushComponents.html",
12
+ "IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
13
+ ".:IdentifyPushInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_identify.IdentifyPushInit.html",
14
+ "identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
15
+ ".:identify": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identify-1.html",
16
+ "identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush-1.html",
17
+ ".:identifyPush": "https://libp2p.github.io/js-libp2p/functions/_libp2p_identify.identifyPush-1.html"
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/identify",
3
- "version": "3.0.17-96f14e429",
3
+ "version": "3.0.17",
4
4
  "description": "Implementation of the Identify Protocol",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/protocol-identify#readme",
@@ -52,12 +52,12 @@
52
52
  "doc-check": "aegir doc-check"
53
53
  },
54
54
  "dependencies": {
55
- "@libp2p/crypto": "5.0.10-96f14e429",
56
- "@libp2p/interface": "2.4.1-96f14e429",
57
- "@libp2p/interface-internal": "2.2.4-96f14e429",
58
- "@libp2p/peer-id": "5.0.11-96f14e429",
59
- "@libp2p/peer-record": "8.0.16-96f14e429",
60
- "@libp2p/utils": "6.5.0-96f14e429",
55
+ "@libp2p/crypto": "^5.0.10",
56
+ "@libp2p/interface": "^2.4.1",
57
+ "@libp2p/interface-internal": "^2.2.4",
58
+ "@libp2p/peer-id": "^5.0.11",
59
+ "@libp2p/peer-record": "^8.0.16",
60
+ "@libp2p/utils": "^6.5.0",
61
61
  "@multiformats/multiaddr": "^12.3.3",
62
62
  "@multiformats/multiaddr-matcher": "^1.6.0",
63
63
  "it-drain": "^3.0.7",
@@ -65,10 +65,11 @@
65
65
  "it-protobuf-stream": "^1.1.5",
66
66
  "protons-runtime": "^5.5.0",
67
67
  "uint8arraylist": "^2.4.8",
68
- "uint8arrays": "^5.1.0"
68
+ "uint8arrays": "^5.1.0",
69
+ "wherearewe": "^2.0.1"
69
70
  },
70
71
  "devDependencies": {
71
- "@libp2p/logger": "5.1.7-96f14e429",
72
+ "@libp2p/logger": "^5.1.7",
72
73
  "aegir": "^45.0.5",
73
74
  "delay": "^6.0.0",
74
75
  "it-length-prefixed": "^9.1.0",
package/src/index.ts CHANGED
@@ -56,8 +56,6 @@ export interface IdentifyInit {
56
56
 
57
57
  /**
58
58
  * What details we should send as part of an identify message
59
- *
60
- * @deprecated Use `nodeInfo.userAgent` in the main libp2p config instead
61
59
  */
62
60
  agentVersion?: string
63
61
 
package/src/utils.ts CHANGED
@@ -4,6 +4,7 @@ import { peerIdFromCID, peerIdFromPublicKey } from '@libp2p/peer-id'
4
4
  import { RecordEnvelope, PeerRecord } from '@libp2p/peer-record'
5
5
  import { type Multiaddr, multiaddr } from '@multiformats/multiaddr'
6
6
  import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string'
7
+ import { isNode, isBrowser, isWebWorker, isElectronMain, isElectronRenderer, isReactNative } from 'wherearewe'
7
8
  import { IDENTIFY_PROTOCOL_VERSION, MAX_IDENTIFY_MESSAGE_SIZE, MAX_PUSH_CONCURRENCY } from './consts.js'
8
9
  import type { IdentifyComponents, IdentifyInit } from './index.js'
9
10
  import type { Identify as IdentifyMessage } from './pb/message.js'
@@ -41,7 +42,15 @@ export function getAgentVersion (nodeInfo: NodeInfo, agentVersion?: string): str
41
42
  return agentVersion
42
43
  }
43
44
 
44
- return nodeInfo.userAgent
45
+ agentVersion = `${nodeInfo.name}/${nodeInfo.version}`
46
+ // Append user agent version to default AGENT_VERSION depending on the environment
47
+ if (isNode || isElectronMain) {
48
+ agentVersion += ` UserAgent=${globalThis.process.version}`
49
+ } else if (isBrowser || isWebWorker || isElectronRenderer || isReactNative) {
50
+ agentVersion += ` UserAgent=${globalThis.navigator.userAgent}`
51
+ }
52
+
53
+ return agentVersion
45
54
  }
46
55
 
47
56
  export async function consumeIdentifyMessage (peerStore: PeerStore, events: TypedEventTarget<Libp2pEvents>, log: Logger, connection: Connection, message: IdentifyMessage): Promise<IdentifyResult> {