@libp2p/identify 2.1.5-df330695a → 2.1.5-e1ca9cced
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 +2 -2
- package/package.json +8 -8
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 nu=Object.create;var en=Object.defineProperty;var su=Object.getOwnPropertyDescriptor;var ou=Object.getOwnPropertyNames;var iu=Object.getPrototypeOf,au=Object.prototype.hasOwnProperty;var qi=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ae=(r,e)=>{for(var t in e)en(r,t,{get:e[t],enumerable:!0})},$i=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ou(e))!au.call(r,s)&&s!==t&&en(r,s,{get:()=>e[s],enumerable:!(n=su(e,s))||n.enumerable});return r};var zi=(r,e,t)=>(t=r!=null?nu(iu(r)):{},$i(e||!r||!r.__esModule?en(t,"default",{value:r,enumerable:!0}):t,r)),cu=r=>$i(en({},"__esModule",{value:!0}),r);var qa=qi(lr=>{"use strict";var Rh="[object ArrayBuffer]",pt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Rh}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),s=r.toUint8Array(t);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(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let i of t)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of t){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},Jo="string",_h=/^[0-9a-f]+$/i,Oh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Vh=/^[a-zA-Z0-9-_]+$/,An=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=pt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return decodeURIComponent(escape(n))}},Ve=class{static toString(e,t=!1){let n=pt.toArrayBuffer(e),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,t);o+=String.fromCharCode(a)}return o}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let o=0;o<e.length;o++)s.setUint16(o*2,e.charCodeAt(o),t);return n}},Sn=class r{static isHex(e){return typeof e===Jo&&_h.test(e)}static isBase64(e){return typeof e===Jo&&Oh.test(e)}static isBase64Url(e){return typeof e===Jo&&Vh.test(e)}static ToString(e,t="utf8"){let n=pt.toUint8Array(e);switch(t.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 Ve.toString(n,!0);case"utf16":case"utf16be":return Ve.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Ve.fromString(e,!0);case"utf16":case"utf16be":return Ve.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=pt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return An.fromString(e);case"utf16":case"utf16be":return Ve.fromString(e);case"utf16le":case"usc2":return Ve.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return An.toString(e);case"utf16":case"utf16be":return Ve.toString(e);case"utf16le":case"usc2":return Ve.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=pt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=pt.toUint8Array(e),n="",s=t.length;for(let o=0;o<s;o++){let i=t[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let o=t.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(e,t=!1){return Ve.toString(e,t)}static FromUtf16String(e,t=!1){return Ve.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};Sn.DEFAULT_UTF8_ENCODING="utf8";function Ph(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)t[o]=s[o]}return t}function Dh(...r){let e=r.map(s=>s.byteLength).reduce((s,o)=>s+o),t=new Uint8Array(e),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)t[n++]=o}),t.buffer}function Mh(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}lr.BufferSourceConverter=pt;lr.Convert=Sn;lr.assign=Ph;lr.combine=Dh;lr.isEqual=Mh});var Ul=qi((Xw,Tl)=>{function Cd(){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)}Tl.exports=Cd});var Fd={};Ae(Fd,{identify:()=>Md,identifyPush:()=>Hd});var Ks=Symbol.for("@libp2p/peer-id");var tn=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}};var Se=class extends Error{constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Jt=class extends Error{constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var rn=class extends Error{constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},nn=class extends Error{constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var De=class extends Error{constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var Dt=class extends Error{constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Er=(r,...e)=>{try{[...e]}catch{}};var sn=Symbol.for("@libp2p/service-capabilities"),Gd=Symbol.for("@libp2p/service-dependencies");var Ws={};Ae(Ws,{base58btc:()=>J,base58flickr:()=>pu});var mp=new Uint8Array(0);function Gi(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function it(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 Wi(r){return new TextEncoder().encode(r)}function ji(r){return new TextDecoder().decode(r)}function lu(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(t[i]!==255)throw new TypeError(o+" is ambiguous");t[i]=s}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var y=0,d=0,x=0,B=m.length;x!==B&&m[x]===0;)x++,y++;for(var g=(B-x)*l+1>>>0,S=new Uint8Array(g);x!==B;){for(var L=m[x],U=0,I=g-1;(L!==0||U<d)&&I!==-1;I--,U++)L+=256*S[I]>>>0,S[I]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");d=U,x++}for(var k=g-d;k!==g&&S[k]===0;)k++;for(var T=c.repeat(y);k<g;++k)T+=r.charAt(S[k]);return T}function h(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var y=0;if(m[y]!==" "){for(var d=0,x=0;m[y]===c;)d++,y++;for(var B=(m.length-y)*u+1>>>0,g=new Uint8Array(B);m[y];){var S=t[m.charCodeAt(y)];if(S===255)return;for(var L=0,U=B-1;(S!==0||L<x)&&U!==-1;U--,L++)S+=a*g[U]>>>0,g[U]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");x=L,y++}if(m[y]!==" "){for(var I=B-x;I!==B&&g[I]===0;)I++;for(var k=new Uint8Array(d+(B-I)),T=d;I!==B;)k[T++]=g[I++];return k}}}function w(m){var y=h(m);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:w}}var uu=lu,fu=uu,Yi=fu;var qs=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},$s=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ji(this,e)}},zs=class{decoders;constructor(e){this.decoders=e}or(e){return Ji(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ji(r,e){return new zs({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var Gs=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,s){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=s,this.encoder=new qs(e,t,n),this.decoder=new $s(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Xt({name:r,prefix:e,encode:t,decode:n}){return new Gs(r,e,t,n)}function Et({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=Yi(t,r);return Xt({prefix:e,name:r,encode:n,decode:o=>it(s(o))})}function hu(r,e,t,n){let s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),a=0,c=0,u=0;for(let l=0;l<o;++l){let f=s[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|f,a+=t,a>=8&&(a-=8,i[u++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function du(r,e,t){let n=e[e.length-1]==="=",s=(1<<t)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,o+=e[s&a>>i];if(i!==0&&(o+=e[s&a<<t-i]),n)for(;o.length*t&7;)o+="=";return o}function ee({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Xt({prefix:e,name:r,encode(s){return du(s,n,t)},decode(s){return hu(s,n,t,r)}})}var J=Et({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pu=Et({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var js={};Ae(js,{base32:()=>at,base32hex:()=>bu,base32hexpad:()=>xu,base32hexpadupper:()=>vu,base32hexupper:()=>wu,base32pad:()=>mu,base32padupper:()=>yu,base32upper:()=>gu,base32z:()=>Eu});var at=ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gu=ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mu=ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yu=ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bu=ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wu=ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xu=ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vu=ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Eu=ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bu=ea,Xi=128,Au=127,Su=~Au,Iu=Math.pow(2,31);function ea(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Iu;)e[t++]=r&255|Xi,r/=128;for(;r&Su;)e[t++]=r&255|Xi,r>>>=7;return e[t]=r|0,ea.bytes=t-n+1,e}var ku=Zs,Nu=128,Qi=127;function Zs(r,n){var t=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw Zs.bytes=0,new RangeError("Could not decode varint");i=r[o++],t+=s<28?(i&Qi)<<s:(i&Qi)*Math.pow(2,s),s+=7}while(i>=Nu);return Zs.bytes=o-n,t}var Cu=Math.pow(2,7),Tu=Math.pow(2,14),Uu=Math.pow(2,21),Lu=Math.pow(2,28),Ru=Math.pow(2,35),_u=Math.pow(2,42),Ou=Math.pow(2,49),Vu=Math.pow(2,56),Pu=Math.pow(2,63),Du=function(r){return r<Cu?1:r<Tu?2:r<Uu?3:r<Lu?4:r<Ru?5:r<_u?6:r<Ou?7:r<Vu?8:r<Pu?9:10},Mu={encode:Bu,decode:ku,encodingLength:Du},Hu=Mu,Br=Hu;function Ar(r,e=0){return[Br.decode(r,e),Br.decode.bytes]}function Qt(r,e,t=0){return Br.encode(r,e,t),e}function er(r){return Br.encodingLength(r)}function Me(r,e){let t=e.byteLength,n=er(r),s=n+er(t),o=new Uint8Array(s+t);return Qt(r,o,0),Qt(t,o,n),o.set(e,s),new tr(r,t,e,o)}function Mt(r){let e=it(r),[t,n]=Ar(e),[s,o]=Ar(e.subarray(n)),i=e.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new tr(t,s,i,e)}function ta(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Gi(r.bytes,t.bytes)}}var tr=class{code;size;digest;bytes;constructor(e,t,n,s){this.code=e,this.size=t,this.digest=n,this.bytes=s}};function ra(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Ku(t,Ys(r),e??J.encoder);default:return qu(t,Ys(r),e??at.encoder)}}var na=new WeakMap;function Ys(r){let e=na.get(r);if(e==null){let t=new Map;return na.set(r,t),t}return e}var de=class r{code;version;multihash;bytes;"/";constructor(e,t,n,s){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==Sr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$u)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Me(e,t);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(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&ta(e.multihash,n.multihash)}toString(e){return ra(this,e)}toJSON(){return{"/":ra(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:s,multihash:o,bytes:i}=t;return new r(n,s,o,i??sa(n,s,o.bytes))}else if(t[zu]===!0){let{version:n,multihash:s,code:o}=t,i=Mt(s);return r.create(n,o,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Sr)throw new Error(`Version 0 CID must use dag-pb (code: ${Sr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let s=sa(e,t,n.bytes);return new r(e,t,n,s)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Sr,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,s=it(e.subarray(n,n+t.multihashSize));if(s.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=s.subarray(t.multihashSize-t.digestSize),i=new tr(t.multihashCode,t.digestSize,o,s);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,h]=Ar(e.subarray(t));return t+=h,f},s=n(),o=Sr;if(s===18?(s=0,t=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=t,a=n(),c=n(),u=t+c,l=u-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,t){let[n,s]=Fu(e,t),o=r.decode(s);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Ys(o).set(n,e),o}};function Fu(r,e){switch(r[0]){case"Q":{let t=e??J;return[J.prefix,t.decode(`${J.prefix}${r}`)]}case J.prefix:{let t=e??J;return[J.prefix,t.decode(r)]}case at.prefix:{let t=e??at;return[at.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ku(r,e,t){let{prefix:n}=t;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let s=e.get(n);if(s==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return s}function qu(r,e,t){let{prefix:n}=t,s=e.get(n);if(s==null){let o=t.encode(r);return e.set(n,o),o}else return s}var Sr=112,$u=18;function sa(r,e,t){let n=er(r),s=n+er(e),o=new Uint8Array(s+t.byteLength);return Qt(r,o,0),Qt(e,o,n),o.set(t,s),o}var zu=Symbol.for("@ipld/js-cid/CID");var Js={};Ae(Js,{identity:()=>ct});var oa=0,Gu="identity",ia=it;function Wu(r){return Me(oa,ia(r))}var ct={code:oa,name:Gu,encode:ia,digest:Wu};function be(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function aa(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function ju(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function rr(r,...e){if(!ju(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function ca(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 nr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function la(r,e){rr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Ht=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var an=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),He=(r,e)=>r<<32-e|r>>>e;var Pp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ua(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ir(r){return typeof r=="string"&&(r=ua(r)),rr(r),r}function Xs(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];rr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}var sr=class{clone(){return this._cloneInto()}},Dp={}.toString;function cn(r){let e=n=>r().update(Ir(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function ln(r=32){if(Ht&&typeof Ht.getRandomValues=="function")return Ht.getRandomValues(new Uint8Array(r));if(Ht&&typeof Ht.randomBytes=="function")return Ht.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Zu(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(t>>s&o),a=Number(t&o),c=n?4:0,u=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+u,a,n)}var fa=(r,e,t)=>r&e^~r&t,ha=(r,e,t)=>r&e^r&t^e&t,or=class extends sr{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=an(this.buffer)}update(e){nr(this);let{view:t,buffer:n,blockLen:s}=this;e=Ir(e);let o=e.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=an(e);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){nr(this),la(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;t[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++)t[f]=0;Zu(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=an(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,l[f],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return e.length=s,e.pos=a,e.finished=o,e.destroyed=i,s%t&&e.buffer.set(n),e}};var un=BigInt(4294967295),Qs=BigInt(32);function da(r,e=!1){return e?{h:Number(r&un),l:Number(r>>Qs&un)}:{h:Number(r>>Qs&un)|0,l:Number(r&un)|0}}function Yu(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=da(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}var Ju=(r,e)=>BigInt(r>>>0)<<Qs|BigInt(e>>>0),Xu=(r,e,t)=>r>>>t,Qu=(r,e,t)=>r<<32-t|e>>>t,ef=(r,e,t)=>r>>>t|e<<32-t,tf=(r,e,t)=>r<<32-t|e>>>t,rf=(r,e,t)=>r<<64-t|e>>>t-32,nf=(r,e,t)=>r>>>t-32|e<<64-t,sf=(r,e)=>e,of=(r,e)=>r,af=(r,e,t)=>r<<t|e>>>32-t,cf=(r,e,t)=>e<<t|r>>>32-t,lf=(r,e,t)=>e<<t-32|r>>>64-t,uf=(r,e,t)=>r<<t-32|e>>>64-t;function ff(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var hf=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),df=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,pf=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),gf=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,mf=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),yf=(r,e,t,n,s,o)=>e+t+n+s+o+(r/2**32|0)|0;var bf={fromBig:da,split:Yu,toBig:Ju,shrSH:Xu,shrSL:Qu,rotrSH:ef,rotrSL:tf,rotrBH:rf,rotrBL:nf,rotr32H:sf,rotr32L:of,rotlSH:af,rotlSL:cf,rotlBH:lf,rotlBL:uf,add:ff,add3L:hf,add3H:df,add4L:pf,add4H:gf,add5H:yf,add5L:mf},O=bf;var[wf,xf]=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))),At=new Uint32Array(80),St=new Uint32Array(80),eo=class extends or{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:e,Al:t,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:h,Gh:w,Gl:m,Hh:y,Hl:d}=this;return[e,t,n,s,o,i,a,c,u,l,f,h,w,m,y,d]}set(e,t,n,s,o,i,a,c,u,l,f,h,w,m,y,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=h|0,this.Gh=w|0,this.Gl=m|0,this.Hh=y|0,this.Hl=d|0}process(e,t){for(let g=0;g<16;g++,t+=4)At[g]=e.getUint32(t),St[g]=e.getUint32(t+=4);for(let g=16;g<80;g++){let S=At[g-15]|0,L=St[g-15]|0,U=O.rotrSH(S,L,1)^O.rotrSH(S,L,8)^O.shrSH(S,L,7),I=O.rotrSL(S,L,1)^O.rotrSL(S,L,8)^O.shrSL(S,L,7),k=At[g-2]|0,T=St[g-2]|0,ne=O.rotrSH(k,T,19)^O.rotrBH(k,T,61)^O.shrSH(k,T,6),K=O.rotrSL(k,T,19)^O.rotrBL(k,T,61)^O.shrSL(k,T,6),V=O.add4L(I,K,St[g-7],St[g-16]),se=O.add4H(V,U,ne,At[g-7],At[g-16]);At[g]=se|0,St[g]=V|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:h,Fh:w,Fl:m,Gh:y,Gl:d,Hh:x,Hl:B}=this;for(let g=0;g<80;g++){let S=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&w^~f&y,I=h&m^~h&d,k=O.add5L(B,L,I,xf[g],St[g]),T=O.add5H(k,x,S,U,wf[g],At[g]),ne=k|0,K=O.rotrSH(n,s,28)^O.rotrBH(n,s,34)^O.rotrBH(n,s,39),V=O.rotrSL(n,s,28)^O.rotrBL(n,s,34)^O.rotrBL(n,s,39),se=n&o^n&a^o&a,E=s&i^s&c^i&c;x=y|0,B=d|0,y=w|0,d=m|0,w=f|0,m=h|0,{h:f,l:h}=O.add(u|0,l|0,T|0,ne|0),u=a|0,l=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let N=O.add3L(ne,V,E);n=O.add3H(N,T,K,se),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:a,l:c}=O.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=O.add(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:h}=O.add(this.Eh|0,this.El|0,f|0,h|0),{h:w,l:m}=O.add(this.Fh|0,this.Fl|0,w|0,m|0),{h:y,l:d}=O.add(this.Gh|0,this.Gl|0,y|0,d|0),{h:x,l:B}=O.add(this.Hh|0,this.Hl|0,x|0,B|0),this.set(n,s,o,i,a,c,u,l,f,h,w,m,y,d,x,B)}roundClean(){At.fill(0),St.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 pa=cn(()=>new eo);var hn={};Ae(hn,{aInRange:()=>Ne,abool:()=>Fe,abytes:()=>ir,bitGet:()=>If,bitLen:()=>oo,bitMask:()=>Nr,bitSet:()=>kf,bytesToHex:()=>ut,bytesToNumberBE:()=>ft,bytesToNumberLE:()=>kt,concatBytes:()=>ht,createHmacDrbg:()=>io,ensureBytes:()=>te,equalBytes:()=>Af,hexToBytes:()=>Kt,hexToNumber:()=>so,inRange:()=>kr,isBytes:()=>It,memoized:()=>$t,notImplemented:()=>Cf,numberToBytesBE:()=>Nt,numberToBytesLE:()=>qt,numberToHexUnpadded:()=>Ft,numberToVarBytesBE:()=>Bf,utf8ToBytes:()=>Sf,validateObject:()=>Je});var no=BigInt(0),fn=BigInt(1),vf=BigInt(2);function It(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ir(r){if(!It(r))throw new Error("Uint8Array expected")}function Fe(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Ef=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ut(r){ir(r);let e="";for(let t=0;t<r.length;t++)e+=Ef[r[t]];return e}function Ft(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function so(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var lt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ga(r){if(r>=lt._0&&r<=lt._9)return r-lt._0;if(r>=lt._A&&r<=lt._F)return r-(lt._A-10);if(r>=lt._a&&r<=lt._f)return r-(lt._a-10)}function Kt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let s=0,o=0;s<t;s++,o+=2){let i=ga(r.charCodeAt(o)),a=ga(r.charCodeAt(o+1));if(i===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[s]=i*16+a}return n}function ft(r){return so(ut(r))}function kt(r){return ir(r),so(ut(Uint8Array.from(r).reverse()))}function Nt(r,e){return Kt(r.toString(16).padStart(e*2,"0"))}function qt(r,e){return Nt(r,e).reverse()}function Bf(r){return Kt(Ft(r))}function te(r,e,t){let n;if(typeof e=="string")try{n=Kt(e)}catch(o){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${o}`)}else if(It(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function ht(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];ir(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}function Af(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Sf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var to=r=>typeof r=="bigint"&&no<=r;function kr(r,e,t){return to(r)&&to(e)&&to(t)&&e<=r&&r<t}function Ne(r,e,t,n){if(!kr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function oo(r){let e;for(e=0;r>no;r>>=fn,e+=1);return e}function If(r,e){return r>>BigInt(e)&fn}function kf(r,e,t){return r|(t?fn:no)<<BigInt(e)}var Nr=r=>(vf<<BigInt(r-1))-fn,ro=r=>new Uint8Array(r),ma=r=>Uint8Array.from(r);function io(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=ro(r),s=ro(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...f)=>t(s,n,...f),c=(f=ro())=>{s=a(ma([0]),f),n=a(),f.length!==0&&(s=a(ma([1]),f),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<e;){n=a();let w=n.slice();h.push(w),f+=n.length}return ht(...h)};return(f,h)=>{i(),c(f);let w;for(;!(w=h(u()));)c();return i(),w}}var Nf={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"||It(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Je(r,e,t={}){let n=(s,o,i)=>{let a=Nf[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=r[s];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(let[s,o]of Object.entries(e))n(s,o,!1);for(let[s,o]of Object.entries(t))n(s,o,!0);return r}var Cf=()=>{throw new Error("not implemented")};function $t(r){let e=new WeakMap;return(t,...n)=>{let s=e.get(t);if(s!==void 0)return s;let o=r(t,...n);return e.set(t,o),o}}var ie=BigInt(0),X=BigInt(1),zt=BigInt(2),Tf=BigInt(3),ao=BigInt(4),ya=BigInt(5),ba=BigInt(8),Uf=BigInt(9),Lf=BigInt(16);function j(r,e){let t=r%e;return t>=ie?t:e+t}function Rf(r,e,t){if(t<=ie||e<ie)throw new Error("Expected power/modulo > 0");if(t===X)return ie;let n=X;for(;e>ie;)e&X&&(n=n*r%t),r=r*r%t,e>>=X;return n}function Q(r,e,t){let n=r;for(;e-- >ie;)n*=n,n%=t;return n}function dn(r,e){if(r===ie||e<=ie)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=j(r,e),n=e,s=ie,o=X,i=X,a=ie;for(;t!==ie;){let u=n/t,l=n%t,f=s-i*u,h=o-a*u;n=t,t=l,s=i,o=a,i=f,a=h}if(n!==X)throw new Error("invert: does not exist");return j(s,e)}function _f(r){let e=(r-X)/zt,t,n,s;for(t=r-X,n=0;t%zt===ie;t/=zt,n++);for(s=zt;s<r&&Rf(s,e,r)!==r-X;s++);if(n===1){let i=(r+X)/ao;return function(c,u){let l=c.pow(u,i);if(!c.eql(c.sqr(l),u))throw new Error("Cannot find square root");return l}}let o=(t+X)/zt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,l=a.pow(a.mul(a.ONE,s),t),f=a.pow(c,o),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let w=1;for(let y=a.sqr(h);w<u&&!a.eql(y,a.ONE);w++)y=a.sqr(y);let m=a.pow(l,X<<BigInt(u-w-1));l=a.sqr(m),f=a.mul(f,m),h=a.mul(h,l),u=w}return f}}function Of(r){if(r%ao===Tf){let e=(r+X)/ao;return function(n,s){let o=n.pow(s,e);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%ba===ya){let e=(r-ya)/ba;return function(n,s){let o=n.mul(s,zt),i=n.pow(o,e),a=n.mul(s,i),c=n.mul(n.mul(a,zt),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),s))throw new Error("Cannot find square root");return u}}return r%Lf,_f(r)}var wa=(r,e)=>(j(r,e)&X)===X,Vf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function co(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Vf.reduce((n,s)=>(n[s]="function",n),e);return Je(r,t)}function Pf(r,e,t){if(t<ie)throw new Error("Expected power > 0");if(t===ie)return r.ONE;if(t===X)return e;let n=r.ONE,s=e;for(;t>ie;)t&X&&(n=r.mul(n,s)),s=r.sqr(s),t>>=X;return n}function Df(r,e){let t=new Array(e.length),n=e.reduce((o,i,a)=>r.is0(i)?o:(t[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return e.reduceRight((o,i,a)=>r.is0(i)?o:(t[a]=r.mul(o,t[a]),r.mul(o,i)),s),t}function lo(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ct(r,e,t=!1,n={}){if(r<=ie)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=lo(r,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Of(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Nr(s),ZERO:ie,ONE:X,create:c=>j(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ie<=c&&c<r},is0:c=>c===ie,isOdd:c=>(c&X)===X,neg:c=>j(-c,r),eql:(c,u)=>c===u,sqr:c=>j(c*c,r),add:(c,u)=>j(c+u,r),sub:(c,u)=>j(c-u,r),mul:(c,u)=>j(c*u,r),pow:(c,u)=>Pf(a,c,u),div:(c,u)=>j(c*dn(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>dn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>Df(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>t?qt(c,o):Nt(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return t?kt(c):ft(c)}});return Object.freeze(a)}function xa(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function uo(r){let e=xa(r);return e+Math.ceil(e/2)}function va(r,e,t=!1){let n=r.length,s=xa(e),o=uo(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=t?ft(r):kt(r),a=j(i,e-X)+X;return t?qt(a,s):Nt(a,s)}var Hf=BigInt(0),fo=BigInt(1),ho=new WeakMap,Ea=new WeakMap;function pn(r,e){let t=(o,i)=>{let a=i.negate();return o?a:i},n=o=>{if(!Number.isSafeInteger(o)||o<=0||o>e)throw new Error(`Wrong window size=${o}, should be [1..${e}]`)},s=o=>{n(o);let i=Math.ceil(e/o)+1,a=2**(o-1);return{windows:i,windowSize:a}};return{constTimeNegate:t,unsafeLadder(o,i){let a=r.ZERO,c=o;for(;i>Hf;)i&fo&&(a=a.add(c)),c=c.double(),i>>=fo;return a},precomputeWindow(o,i){let{windows:a,windowSize:c}=s(i),u=[],l=o,f=l;for(let h=0;h<a;h++){f=l,u.push(f);for(let w=1;w<c;w++)f=f.add(l),u.push(f);l=f.double()}return u},wNAF(o,i,a){let{windows:c,windowSize:u}=s(o),l=r.ZERO,f=r.BASE,h=BigInt(2**o-1),w=2**o,m=BigInt(o);for(let y=0;y<c;y++){let d=y*u,x=Number(a&h);a>>=m,x>u&&(x-=w,a+=fo);let B=d,g=d+Math.abs(x)-1,S=y%2!==0,L=x<0;x===0?f=f.add(t(S,i[B])):l=l.add(t(L,i[g]))}return{p:l,f}},wNAFCached(o,i,a){let c=Ea.get(o)||1,u=ho.get(o);return u||(u=this.precomputeWindow(o,c),c!==1&&ho.set(o,a(u))),this.wNAF(c,u,i)},setWindowSize(o,i){n(i),Ea.set(o,i),ho.delete(o)}}}function gn(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((l,f)=>{if(!e.isValid(l))throw new Error(`wrong scalar at index ${f}`)}),t.forEach((l,f)=>{if(!(l instanceof r))throw new Error(`wrong point at index ${f}`)});let s=oo(BigInt(t.length)),o=s>12?s-3:s>4?s-2:s?2:1,i=(1<<o)-1,a=new Array(i+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/o)*o,u=r.ZERO;for(let l=c;l>=0;l-=o){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let w=n[h],m=Number(w>>BigInt(l)&BigInt(i));a[m]=a[m].add(t[h])}let f=r.ZERO;for(let h=a.length-1,w=r.ZERO;h>0;h--)w=w.add(a[h]),f=f.add(w);if(u=u.add(f),l!==0)for(let h=0;h<o;h++)u=u.double()}return u}function Cr(r){return co(r.Fp),Je(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...lo(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ke=BigInt(0),Ce=BigInt(1),mn=BigInt(2),Ff=BigInt(8),Kf={zip215:!0};function qf(r){let e=Cr(r);return Je(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ba(r){let e=qf(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=e,u=mn<<BigInt(a*8)-Ce,l=t.create,f=Ct(e.n,e.nBitLength),h=e.uvRatio||((b,p)=>{try{return{isValid:!0,value:t.sqrt(b*t.inv(p))}}catch{return{isValid:!1,value:Ke}}}),w=e.adjustScalarBytes||(b=>b),m=e.domain||((b,p,v)=>{if(Fe("phflag",v),p.length||v)throw new Error("Contexts/pre-hash are not supported");return b});function y(b,p){Ne("coordinate "+b,p,Ke,u)}function d(b){if(!(b instanceof g))throw new Error("ExtendedPoint expected")}let x=$t((b,p)=>{let{ex:v,ey:C,ez:R}=b,_=b.is0();p==null&&(p=_?Ff:t.inv(R));let P=l(v*p),H=l(C*p),D=l(R*p);if(_)return{x:Ke,y:Ce};if(D!==Ce)throw new Error("invZ was invalid");return{x:P,y:H}}),B=$t(b=>{let{a:p,d:v}=e;if(b.is0())throw new Error("bad point: ZERO");let{ex:C,ey:R,ez:_,et:P}=b,H=l(C*C),D=l(R*R),W=l(_*_),Y=l(W*W),le=l(H*p),ue=l(W*l(le+D)),he=l(Y+l(v*l(H*D)));if(ue!==he)throw new Error("bad point: equation left != right (1)");let Be=l(C*R),oe=l(_*P);if(Be!==oe)throw new Error("bad point: equation left != right (2)");return!0});class g{constructor(p,v,C,R){this.ex=p,this.ey=v,this.ez=C,this.et=R,y("x",p),y("y",v),y("z",C),y("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof g)throw new Error("extended point not allowed");let{x:v,y:C}=p||{};return y("x",v),y("y",C),new g(v,C,Ce,l(v*C))}static normalizeZ(p){let v=t.invertBatch(p.map(C=>C.ez));return p.map((C,R)=>C.toAffine(v[R])).map(g.fromAffine)}static msm(p,v){return gn(g,f,p,v)}_setWindowSize(p){U.setWindowSize(this,p)}assertValidity(){B(this)}equals(p){d(p);let{ex:v,ey:C,ez:R}=this,{ex:_,ey:P,ez:H}=p,D=l(v*H),W=l(_*R),Y=l(C*H),le=l(P*R);return D===W&&Y===le}is0(){return this.equals(g.ZERO)}negate(){return new g(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:p}=e,{ex:v,ey:C,ez:R}=this,_=l(v*v),P=l(C*C),H=l(mn*l(R*R)),D=l(p*_),W=v+C,Y=l(l(W*W)-_-P),le=D+P,ue=le-H,he=D-P,Be=l(Y*ue),oe=l(le*he),ke=l(Y*he),ot=l(ue*le);return new g(Be,oe,ot,ke)}add(p){d(p);let{a:v,d:C}=e,{ex:R,ey:_,ez:P,et:H}=this,{ex:D,ey:W,ez:Y,et:le}=p;if(v===BigInt(-1)){let Vi=l((_-R)*(W+D)),Pi=l((_+R)*(W-D)),Fs=l(Pi-Vi);if(Fs===Ke)return this.double();let Di=l(P*mn*le),Mi=l(H*mn*Y),Hi=Mi+Di,Fi=Pi+Vi,Ki=Mi-Di,Ql=l(Hi*Fs),eu=l(Fi*Ki),tu=l(Hi*Ki),ru=l(Fs*Fi);return new g(Ql,eu,ru,tu)}let ue=l(R*D),he=l(_*W),Be=l(H*C*le),oe=l(P*Y),ke=l((R+_)*(D+W)-ue-he),ot=oe-Be,xr=oe+Be,vr=l(he-v*ue),Zl=l(ke*ot),Yl=l(xr*vr),Jl=l(ke*vr),Xl=l(ot*xr);return new g(Zl,Yl,Xl,Jl)}subtract(p){return this.add(p.negate())}wNAF(p){return U.wNAFCached(this,p,g.normalizeZ)}multiply(p){let v=p;Ne("scalar",v,Ce,n);let{p:C,f:R}=this.wNAF(v);return g.normalizeZ([C,R])[0]}multiplyUnsafe(p){let v=p;return Ne("scalar",v,Ke,n),v===Ke?L:this.equals(L)||v===Ce?this:this.equals(S)?this.wNAF(v).p:U.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(p){return x(this,p)}clearCofactor(){let{h:p}=e;return p===Ce?this:this.multiplyUnsafe(p)}static fromHex(p,v=!1){let{d:C,a:R}=e,_=t.BYTES;p=te("pointHex",p,_),Fe("zip215",v);let P=p.slice(),H=p[_-1];P[_-1]=H&-129;let D=kt(P),W=v?u:t.ORDER;Ne("pointHex.y",D,Ke,W);let Y=l(D*D),le=l(Y-Ce),ue=l(C*Y-R),{isValid:he,value:Be}=h(le,ue);if(!he)throw new Error("Point.fromHex: invalid y coordinate");let oe=(Be&Ce)===Ce,ke=(H&128)!==0;if(!v&&Be===Ke&&ke)throw new Error("Point.fromHex: x=0 and x_0=1");return ke!==oe&&(Be=l(-Be)),g.fromAffine({x:Be,y:D})}static fromPrivateKey(p){return T(p).point}toRawBytes(){let{x:p,y:v}=this.toAffine(),C=qt(v,t.BYTES);return C[C.length-1]|=p&Ce?128:0,C}toHex(){return ut(this.toRawBytes())}}g.BASE=new g(e.Gx,e.Gy,Ce,l(e.Gx*e.Gy)),g.ZERO=new g(Ke,Ce,Ce,Ke);let{BASE:S,ZERO:L}=g,U=pn(g,a*8);function I(b){return j(b,n)}function k(b){return I(kt(b))}function T(b){let p=a;b=te("private key",b,p);let v=te("hashed private key",o(b),2*p),C=w(v.slice(0,p)),R=v.slice(p,2*p),_=k(C),P=S.multiply(_),H=P.toRawBytes();return{head:C,prefix:R,scalar:_,point:P,pointBytes:H}}function ne(b){return T(b).pointBytes}function K(b=new Uint8Array,...p){let v=ht(...p);return k(o(m(v,te("context",b),!!s)))}function V(b,p,v={}){b=te("message",b),s&&(b=s(b));let{prefix:C,scalar:R,pointBytes:_}=T(p),P=K(v.context,C,b),H=S.multiply(P).toRawBytes(),D=K(v.context,H,_,b),W=I(P+D*R);Ne("signature.s",W,Ke,n);let Y=ht(H,qt(W,t.BYTES));return te("result",Y,a*2)}let se=Kf;function E(b,p,v,C=se){let{context:R,zip215:_}=C,P=t.BYTES;b=te("signature",b,2*P),p=te("message",p),_!==void 0&&Fe("zip215",_),s&&(p=s(p));let H=kt(b.slice(P,2*P)),D,W,Y;try{D=g.fromHex(v,_),W=g.fromHex(b.slice(0,P),_),Y=S.multiplyUnsafe(H)}catch{return!1}if(!_&&D.isSmallOrder())return!1;let le=K(R,W.toRawBytes(),D.toRawBytes(),p);return W.add(D.multiplyUnsafe(le)).subtract(Y).clearCofactor().equals(g.ZERO)}return S._setWindowSize(8),{CURVE:e,getPublicKey:ne,sign:V,verify:E,ExtendedPoint:g,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>i(t.BYTES),precompute(b=8,p=g.BASE){return p._setWindowSize(b),p.multiply(BigInt(3)),p}}}}var po=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Aa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),a0=BigInt(0),$f=BigInt(1),Sa=BigInt(2),c0=BigInt(3),zf=BigInt(5),Gf=BigInt(8);function Wf(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),s=BigInt(80),o=po,a=r*r%o*r%o,c=Q(a,Sa,o)*a%o,u=Q(c,$f,o)*r%o,l=Q(u,zf,o)*u%o,f=Q(l,e,o)*l%o,h=Q(f,t,o)*f%o,w=Q(h,n,o)*h%o,m=Q(w,s,o)*w%o,y=Q(m,s,o)*w%o,d=Q(y,e,o)*l%o;return{pow_p_5_8:Q(d,Sa,o)*r%o,b2:a}}function jf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Zf(r,e){let t=po,n=j(e*e*e,t),s=j(n*n*e,t),o=Wf(r*s).pow_p_5_8,i=j(r*n*o,t),a=j(e*i*i,t),c=i,u=j(i*Aa,t),l=a===r,f=a===j(-r,t),h=a===j(-r*Aa,t);return l&&(i=c),(f||h)&&(i=u),wa(i,t)&&(i=j(-i,t)),{isValid:l||f,value:i}}var Yf=Ct(po,void 0,!0),Jf={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Yf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Gf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:pa,randomBytes:ln,adjustScalarBytes:jf,uvRatio:Zf},Ia=Ba(Jf);var yn=32;function ka(r,e,t){return Ia.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var bn=class{type="Ed25519";raw;constructor(e){this.raw=go(e,yn)}toMultihash(){return ct.digest(Tt(this))}toCID(){return de.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}verify(e,t){return ka(this.raw,t,e)}};function mo(r){return r=go(r,yn),new bn(r)}function go(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Se(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}function pe(r=0){return new Uint8Array(r)}function Te(r=0){return new Uint8Array(r)}var Qf=Math.pow(2,7),eh=Math.pow(2,14),th=Math.pow(2,21),yo=Math.pow(2,28),bo=Math.pow(2,35),wo=Math.pow(2,42),xo=Math.pow(2,49),G=128,we=127;function xe(r){if(r<Qf)return 1;if(r<eh)return 2;if(r<th)return 3;if(r<yo)return 4;if(r<bo)return 5;if(r<wo)return 6;if(r<xo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function vo(r,e,t=0){switch(xe(r)){case 8:e[t++]=r&255|G,r/=128;case 7:e[t++]=r&255|G,r/=128;case 6:e[t++]=r&255|G,r/=128;case 5:e[t++]=r&255|G,r/=128;case 4:e[t++]=r&255|G,r>>>=7;case 3:e[t++]=r&255|G,r>>>=7;case 2:e[t++]=r&255|G,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function rh(r,e,t=0){switch(xe(r)){case 8:e.set(t++,r&255|G),r/=128;case 7:e.set(t++,r&255|G),r/=128;case 6:e.set(t++,r&255|G),r/=128;case 5:e.set(t++,r&255|G),r/=128;case 4:e.set(t++,r&255|G),r>>>=7;case 3:e.set(t++,r&255|G),r>>>=7;case 2:e.set(t++,r&255|G),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function Eo(r,e){let t=r[e],n=0;if(n+=t&we,t<G||(t=r[e+1],n+=(t&we)<<7,t<G)||(t=r[e+2],n+=(t&we)<<14,t<G)||(t=r[e+3],n+=(t&we)<<21,t<G)||(t=r[e+4],n+=(t&we)*yo,t<G)||(t=r[e+5],n+=(t&we)*bo,t<G)||(t=r[e+6],n+=(t&we)*wo,t<G)||(t=r[e+7],n+=(t&we)*xo,t<G))return n;throw new RangeError("Could not decode varint")}function nh(r,e){let t=r.get(e),n=0;if(n+=t&we,t<G||(t=r.get(e+1),n+=(t&we)<<7,t<G)||(t=r.get(e+2),n+=(t&we)<<14,t<G)||(t=r.get(e+3),n+=(t&we)<<21,t<G)||(t=r.get(e+4),n+=(t&we)*yo,t<G)||(t=r.get(e+5),n+=(t&we)*bo,t<G)||(t=r.get(e+6),n+=(t&we)*wo,t<G)||(t=r.get(e+7),n+=(t&we)*xo,t<G))return n;throw new RangeError("Could not decode varint")}function Oe(r,e,t=0){return e==null&&(e=Te(xe(r))),e instanceof Uint8Array?vo(r,e,t):rh(r,e,t)}function dt(r,e=0){return r instanceof Uint8Array?Eo(r,e):nh(r,e)}var Bo=new Float32Array([-0]),Ut=new Uint8Array(Bo.buffer);function Ca(r,e,t){Bo[0]=r,e[t]=Ut[0],e[t+1]=Ut[1],e[t+2]=Ut[2],e[t+3]=Ut[3]}function Ta(r,e){return Ut[0]=r[e],Ut[1]=r[e+1],Ut[2]=r[e+2],Ut[3]=r[e+3],Bo[0]}var Ao=new Float64Array([-0]),ve=new Uint8Array(Ao.buffer);function Ua(r,e,t){Ao[0]=r,e[t]=ve[0],e[t+1]=ve[1],e[t+2]=ve[2],e[t+3]=ve[3],e[t+4]=ve[4],e[t+5]=ve[5],e[t+6]=ve[6],e[t+7]=ve[7]}function La(r,e){return ve[0]=r[e],ve[1]=r[e+1],ve[2]=r[e+2],ve[3]=r[e+3],ve[4]=r[e+4],ve[5]=r[e+5],ve[6]=r[e+6],ve[7]=r[e+7],Ao[0]}var sh=BigInt(Number.MAX_SAFE_INTEGER),oh=BigInt(Number.MIN_SAFE_INTEGER),Re=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Gt;if(e<sh&&e>oh)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,s=e-(n<<32n);return t&&(n=~n|0n,s=~s|0n,++s>Ra&&(s=0n,++n>Ra&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(e){if(e===0)return Gt;let t=e<0;t&&(e=-e);let n=e>>>0,s=(e-n)/4294967296>>>0;return t&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Gt}},Gt=new Re(0,0);Gt.toBigInt=function(){return 0n};Gt.zzEncode=Gt.zzDecode=function(){return this};Gt.length=function(){return 1};var Ra=4294967296n;function _a(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Oa(r,e,t){if(t-e<1)return"";let s,o=[],i=0,a;for(;e<t;)a=r[e++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&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 So(r,e,t){let n=t,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128);return t-n}function qe(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function xn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Io=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,qe(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw qe(this,4);return xn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qe(this,4);return xn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qe(this,4);let e=Ta(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw qe(this,4);let e=La(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw qe(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Oa(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw qe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw qe(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Re(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw qe(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw qe(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw qe(this,8);let e=xn(this.buf,this.pos+=4),t=xn(this.buf,this.pos+=4);return new Re(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=Eo(this.buf,this.pos);return this.pos+=xe(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function ko(r){return new Io(r instanceof Uint8Array?r:r.subarray())}function $e(r,e,t){let n=ko(r);return e.decode(n,void 0,t)}var No={};Ae(No,{base10:()=>ih});var ih=Et({prefix:"9",name:"base10",alphabet:"0123456789"});var Co={};Ae(Co,{base16:()=>ah,base16upper:()=>ch});var ah=ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ch=ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var To={};Ae(To,{base2:()=>lh});var lh=ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Uo={};Ae(Uo,{base256emoji:()=>ph});var Pa=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}"),uh=Pa.reduce((r,e,t)=>(r[t]=e,r),[]),fh=Pa.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function hh(r){return r.reduce((e,t)=>(e+=uh[t],e),"")}function dh(r){let e=[];for(let t of r){let n=fh[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ph=Xt({prefix:"\u{1F680}",name:"base256emoji",encode:hh,decode:dh});var Lo={};Ae(Lo,{base36:()=>gh,base36upper:()=>mh});var gh=Et({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mh=Et({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var _o={};Ae(_o,{base64:()=>yh,base64pad:()=>bh,base64url:()=>Ro,base64urlpad:()=>wh});var yh=ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bh=ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ro=ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wh=ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Oo={};Ae(Oo,{base8:()=>xh});var xh=ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Vo={};Ae(Vo,{identity:()=>vh});var vh=Xt({prefix:"\0",name:"identity",encode:r=>ji(r),decode:r=>Wi(r)});var z0=new TextEncoder,G0=new TextDecoder;var Mo={};Ae(Mo,{sha256:()=>Tr,sha512:()=>Ah});function Do({name:r,code:e,encode:t}){return new Po(r,e,t)}var Po=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Me(this.code,t):t.then(n=>Me(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ma(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Tr=Do({name:"sha2-256",code:18,encode:Ma("SHA-256")}),Ah=Do({name:"sha2-512",code:19,encode:Ma("SHA-512")});var Ur={...Vo,...To,...Oo,...No,...Co,...js,...Lo,...Ws,..._o,...Uo},sg={...Mo,...Js};function Fa(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ha=Fa("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Ho=Fa("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Te(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Sh={utf8:Ha,"utf-8":Ha,hex:Ur.base16,latin1:Ho,ascii:Ho,binary:Ho,...Ur},vn=Sh;function q(r,e="utf8"){let t=vn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Fo(r){let e=r??8192,t=e>>>1,n,s=e;return function(i){if(i<1||i>t)return Te(i);s+i>e&&(n=Te(e),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Wt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Ko(){}var $o=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Ih=Fo();function kh(r){return globalThis.Buffer!=null?Te(r):Ih(r)}var Rr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Wt(Ko,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Wt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new zo((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(En,10,Re.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Re.fromBigInt(e);return this._push(En,t.length(),t)}uint64Number(e){return this._push(vo,xe(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Re.fromBigInt(e).zzEncode();return this._push(En,t.length(),t)}sint64Number(e){let t=Re.fromNumber(e).zzEncode();return this._push(En,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(qo,1,e?1:0)}fixed32(e){return this._push(Lr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Re.fromBigInt(e);return this._push(Lr,4,t.lo)._push(Lr,4,t.hi)}fixed64Number(e){let t=Re.fromNumber(e);return this._push(Lr,4,t.lo)._push(Lr,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Ca,4,e)}double(e){return this._push(Ua,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(qo,1,0):this.uint32(t)._push(Ch,t,e)}string(e){let t=_a(e);return t!==0?this.uint32(t)._push(So,t,e):this._push(qo,1,0)}fork(){return this.states=new $o(this),this.head=this.tail=new Wt(Ko,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 Wt(Ko,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=kh(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function qo(r,e,t){e[t]=r&255}function Nh(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var zo=class extends Wt{next;constructor(e,t){super(Nh,e,t),this.next=void 0}};function En(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Lr(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Ch(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Rr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Th,e,r),this},Rr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Uh,e,r),this});function Th(r,e,t){e.set(r,t)}function Uh(r,e,t){r.length<40?So(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(q(r),t)}function Go(){return new Rr}function ze(r,e){let t=Go();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var ar;(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"})(ar||(ar={}));function Bn(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Wo(r){function e(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let t=function(o,i){let a=e(o);i.int32(a)},n=function(o){let i=o.int32();return e(i)};return Bn("enum",ar.VARINT,t,n)}function Ge(r,e){return Bn("message",ar.LENGTH_DELIMITED,r,e)}var jt=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var ae;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ae||(ae={}));var jo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(jo||(jo={}));(function(r){r.codec=()=>Wo(jo)})(ae||(ae={}));var Xe;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ae.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=ae.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(Xe||(Xe={}));var Zo;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ae.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=ae.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(Zo||(Zo={}));var qr={};Ae(qr,{MAX_RSA_KEY_SIZE:()=>ps,generateRSAKeyPair:()=>Dc,jwkToJWKKeyPair:()=>Mc,jwkToPkcs1:()=>Wh,jwkToPkix:()=>si,jwkToRSAPrivateKey:()=>Pc,pkcs1ToJwk:()=>_c,pkcs1ToRSAPrivateKey:()=>Vc,pkixToJwk:()=>Oc,pkixToRSAPublicKey:()=>oi});var Lh=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]),Lt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Rt=new Uint32Array(64),Yo=class extends or{constructor(){super(64,32,8,!1),this.A=Lt[0]|0,this.B=Lt[1]|0,this.C=Lt[2]|0,this.D=Lt[3]|0,this.E=Lt[4]|0,this.F=Lt[5]|0,this.G=Lt[6]|0,this.H=Lt[7]|0}get(){let{A:e,B:t,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[e,t,n,s,o,i,a,c]}set(e,t,n,s,o,i,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,t){for(let f=0;f<16;f++,t+=4)Rt[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){let h=Rt[f-15],w=Rt[f-2],m=He(h,7)^He(h,18)^h>>>3,y=He(w,17)^He(w,19)^w>>>10;Rt[f]=y+Rt[f-7]+m+Rt[f-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){let h=He(a,6)^He(a,11)^He(a,25),w=l+h+fa(a,c,u)+Lh[f]+Rt[f]|0,y=(He(n,2)^He(n,13)^He(n,22))+ha(n,s,o)|0;l=u,u=c,c=a,a=i+w|0,i=o,o=s,s=n,n=w+y|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,s,o,i,a,c,u,l)}roundClean(){Rt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var cr=cn(()=>new Yo);var M=zi(qa());function Zt(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function _t(r,e,t=-1){let n=t,s=r,o=0,i=Math.pow(2,e);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let u=new Uint8Array(c);for(let l=a-1;l>=0;l--){let f=Math.pow(2,l*e);u[o-l-1]=Math.floor(s/f),s-=u[o-l-1]*f}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function In(...r){let e=0,t=0;for(let o of r)e+=o.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let o of r)s.set(o,t),t+=o.length;return s}function Xo(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=Zt(t,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)o[a]=r[a];return o[0]&=127,Zt(o,8)-n}function $a(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let i=t-e,a=_t(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=_t(e,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),a=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<i.byteLength;c++)o[c+1]=a[c];o[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function za(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Ue(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(t)}var Mg=Math.log(2);function kn(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Qo(r){let e=0,t=0;for(let s=0;s<r.length;s++){let o=r[s];e+=o.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),t),t+=o.byteLength}return n.buffer}function bt(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-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 Or=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Qo(this.items)}},_r=[new Uint8Array([1])],Ga="0123456789";var dr="",We=new ArrayBuffer(0),ei=new Uint8Array(0),Vr="EndOfContent",ja="OCTET STRING",Za="BIT STRING";function wt(r){var e;return e=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):ei}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(!bt(this,i,s,o))return-1;let a=s+o;return this.valueHexView=i.subarray(s,a),this.valueHexView.length?(this.blockLength=o,a):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var gt=class{constructor({blockLength:e=0,error:t=dr,warnings:n=[],valueBeforeDecode:s=ei}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=M.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:M.Convert.ToHex(this.valueBeforeDecodeView)}}};gt.NAME="baseBlock";var Ee=class extends gt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Ee.NAME="valueBlock";var Nn=class extends wt(gt){constructor({idBlock:e={}}={}){var t,n,s,o;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?M.BufferSourceConverter.toUint8Array(e.valueHex):ei,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=e.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",We}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let o=this.tagNumber;o&=31,t|=o,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=_t(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let c=0;c<i-1;c++)a[c+1]=o[c]|128;a[i]=o[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){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(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+n);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(o[0]&32)===32,this.isHexOnly=!1;let a=o[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),l=255;for(;o[c]&128;){if(u[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===l){l+=255;let h=new Uint8Array(l);for(let w=0;w<u.length;w++)h[w]=u[w];u=this.valueHexView=new Uint8Array(l)}}this.blockLength=c+1,u[c-1]=o[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=u[h];u=this.valueHexView=new Uint8Array(c),u.set(f),this.blockLength<=9?this.tagNumber=Zt(u,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 t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};Nn.NAME="identificationBlock";var Cn=class extends gt{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+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,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;let i=o[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Zt(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=_t(this.length,8);if(s.byteLength>127)return this.error="Too big length",We;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let o=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Cn.NAME="lengthBlock";var A={},ge=class extends gt{constructor({name:e=dr,optional:t=!1,primitiveSchema:n,...s}={},o){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Nn(s),this.lenBlock=new Cn(s),this.valueBlock=o?new o(s):new Ee(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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(e,t){let n=t||new Or;t||Ya(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(e);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(o)}return t?We:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return za(t,n)}};ge.NAME="BaseBlock";function Ya(r){if(r instanceof A.Constructed)for(let e of r.valueBlock.value)Ya(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Tn=class extends ge{constructor({value:e=dr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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}'`}};Tn.NAME="BaseStringBlock";var Un=class extends wt(Ee){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Un.NAME="PrimitiveValueBlock";var Ja,Ln=class extends ge{constructor(e={}){super(e,Un),this.idBlock.isConstructed=!1}};Ja=Ln;A.Primitive=Ja;Ln.NAME="PRIMITIVE";function Fh(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function hs(r,e=0,t=r.length){let n=e,s=new ge({},Ee),o=new gt;if(!bt(o,r,e,t))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=a,t-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=a,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=ge;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=A.EndOfContent;break;case 1:c=A.Boolean;break;case 2:c=A.Integer;break;case 3:c=A.BitString;break;case 4:c=A.OctetString;break;case 5:c=A.Null;break;case 6:c=A.ObjectIdentifier;break;case 10:c=A.Enumerated;break;case 12:c=A.Utf8String;break;case 13:c=A.RelativeObjectIdentifier;break;case 14:c=A.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=A.Sequence;break;case 17:c=A.Set;break;case 18:c=A.NumericString;break;case 19:c=A.PrintableString;break;case 20:c=A.TeletexString;break;case 21:c=A.VideotexString;break;case 22:c=A.IA5String;break;case 23:c=A.UTCTime;break;case 24:c=A.GeneralizedTime;break;case 25:c=A.GraphicString;break;case 26:c=A.VisibleString;break;case 27:c=A.GeneralString;break;case 28:c=A.UniversalString;break;case 29:c=A.CharacterString;break;case 30:c=A.BmpString;break;case 31:c=A.DATE;break;case 32:c=A.TimeOfDay;break;case 33:c=A.DateTime;break;case 34:c=A.Duration;break;default:{let u=s.idBlock.isConstructed?new A.Constructed:new A.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?A.Constructed:A.Primitive}return s=Fh(s,c),a=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function ti(r){if(!r.byteLength){let e=new ge({},Ee);return e.error="Input buffer has zero length",{offset:-1,result:e}}return hs(M.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Kh(r,e){return r?1:e}var Qe=class extends Ee{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let o=t;for(;Kh(this.isIndefiniteForm,n)>0;){let i=hs(s,o,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(o=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Vr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Vr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){let n=t||new Or;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Qe.NAME="ConstructedValueBlock";var Xa,Ot=class extends ge{constructor(e={}){super(e,Qe),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,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 e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
2
|
+
"use strict";var Libp2PIdentify=(()=>{var nu=Object.create;var en=Object.defineProperty;var su=Object.getOwnPropertyDescriptor;var ou=Object.getOwnPropertyNames;var iu=Object.getPrototypeOf,au=Object.prototype.hasOwnProperty;var qi=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Ae=(r,e)=>{for(var t in e)en(r,t,{get:e[t],enumerable:!0})},$i=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ou(e))!au.call(r,s)&&s!==t&&en(r,s,{get:()=>e[s],enumerable:!(n=su(e,s))||n.enumerable});return r};var zi=(r,e,t)=>(t=r!=null?nu(iu(r)):{},$i(e||!r||!r.__esModule?en(t,"default",{value:r,enumerable:!0}):t,r)),cu=r=>$i(en({},"__esModule",{value:!0}),r);var qa=qi(lr=>{"use strict";var Rh="[object ArrayBuffer]",pt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===Rh}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:this.toUint8Array(e.buffer).slice(e.byteOffset,e.byteOffset+e.byteLength).buffer}static toUint8Array(e){return this.toView(e,Uint8Array)}static toView(e,t){if(e.constructor===t)return e;if(this.isArrayBuffer(e))return new t(e);if(this.isArrayBufferView(e))return new t(e.buffer,e.byteOffset,e.byteLength);throw new TypeError("The provided value is not of type '(ArrayBuffer or ArrayBufferView)'")}static isBufferSource(e){return this.isArrayBufferView(e)||this.isArrayBuffer(e)}static isArrayBufferView(e){return ArrayBuffer.isView(e)||e&&this.isArrayBuffer(e.buffer)}static isEqual(e,t){let n=r.toUint8Array(e),s=r.toUint8Array(t);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(...e){let t;Array.isArray(e[0])&&!(e[1]instanceof Function)||Array.isArray(e[0])&&e[1]instanceof Function?t=e[0]:e[e.length-1]instanceof Function?t=e.slice(0,e.length-1):t=e;let n=0;for(let i of t)n+=i.byteLength;let s=new Uint8Array(n),o=0;for(let i of t){let a=this.toUint8Array(i);s.set(a,o),o+=a.length}return e[e.length-1]instanceof Function?this.toView(s,e[e.length-1]):s.buffer}},Yo="string",_h=/^[0-9a-f]+$/i,Oh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Vh=/^[a-zA-Z0-9-_]+$/,Bn=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n.buffer}static toString(e){let t=pt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return decodeURIComponent(escape(n))}},Ve=class{static toString(e,t=!1){let n=pt.toArrayBuffer(e),s=new DataView(n),o="";for(let i=0;i<n.byteLength;i+=2){let a=s.getUint16(i,t);o+=String.fromCharCode(a)}return o}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),s=new DataView(n);for(let o=0;o<e.length;o++)s.setUint16(o*2,e.charCodeAt(o),t);return n}},An=class r{static isHex(e){return typeof e===Yo&&_h.test(e)}static isBase64(e){return typeof e===Yo&&Oh.test(e)}static isBase64Url(e){return typeof e===Yo&&Vh.test(e)}static ToString(e,t="utf8"){let n=pt.toUint8Array(e);switch(t.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 Ve.toString(n,!0);case"utf16":case"utf16be":return Ve.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e,t="utf8"){if(!e)return new ArrayBuffer(0);switch(t.toLowerCase()){case"utf8":return this.FromUtf8String(e);case"binary":return this.FromBinary(e);case"hex":return this.FromHex(e);case"base64":return this.FromBase64(e);case"base64url":return this.FromBase64Url(e);case"utf16le":return Ve.fromString(e,!0);case"utf16":case"utf16be":return Ve.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=pt.toUint8Array(e);if(typeof btoa<"u"){let n=this.ToString(t,"binary");return btoa(n)}else return Buffer.from(t).toString("base64")}static FromBase64(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return typeof atob<"u"?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isBase64Url(t))throw new TypeError("Argument 'base64url' is not Base64Url encoded");return this.FromBase64(this.Base64Padding(t.replace(/\-/g,"+").replace(/\_/g,"/")))}static ToBase64Url(e){return this.ToBase64(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/\=/g,"")}static FromUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.FromBinary(e);case"utf8":return Bn.fromString(e);case"utf16":case"utf16be":return Ve.fromString(e);case"utf16le":case"usc2":return Ve.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e,t=r.DEFAULT_UTF8_ENCODING){switch(t){case"ascii":return this.ToBinary(e);case"utf8":return Bn.toString(e);case"utf16":case"utf16be":return Ve.toString(e);case"utf16le":case"usc2":return Ve.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){let t=e.length,n=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);return n.buffer}static ToBinary(e){let t=pt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return n}static ToHex(e){let t=pt.toUint8Array(e),n="",s=t.length;for(let o=0;o<s;o++){let i=t[o];i<16&&(n+="0"),n+=i.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!r.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);let n=new Uint8Array(t.length/2);for(let s=0;s<t.length;s=s+2){let o=t.slice(s,s+2);n[s/2]=parseInt(o,16)}return n.buffer}static ToUtf16String(e,t=!1){return Ve.toString(e,t)}static FromUtf16String(e,t=!1){return Ve.fromString(e,t)}static Base64Padding(e){let t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return e?.replace(/[\n\r\t ]/g,"")||""}};An.DEFAULT_UTF8_ENCODING="utf8";function Ph(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let s=arguments[n];for(let o in s)t[o]=s[o]}return t}function Dh(...r){let e=r.map(s=>s.byteLength).reduce((s,o)=>s+o),t=new Uint8Array(e),n=0;return r.map(s=>new Uint8Array(s)).forEach(s=>{for(let o of s)t[n++]=o}),t.buffer}function Mh(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<r.byteLength;s++)if(t[s]!==n[s])return!1;return!0}lr.BufferSourceConverter=pt;lr.Convert=An;lr.assign=Ph;lr.combine=Dh;lr.isEqual=Mh});var Ul=qi((Jw,Tl)=>{function Cd(){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)}Tl.exports=Cd});var Fd={};Ae(Fd,{identify:()=>Md,identifyPush:()=>Hd});var Fs=Symbol.for("@libp2p/peer-id");var Se=class extends Error{static name="InvalidParametersError";constructor(e="Invalid parameters"){super(e),this.name="InvalidParametersError"}},Jt=class extends Error{static name="InvalidPublicKeyError";constructor(e="Invalid public key"){super(e),this.name="InvalidPublicKeyError"}};var tn=class extends Error{static name="InvalidCIDError";constructor(e="Invalid CID"){super(e),this.name="InvalidCIDError"}},rn=class extends Error{static name="InvalidMultihashError";constructor(e="Invalid Multihash"){super(e),this.name="InvalidMultihashError"}};var De=class extends Error{static name="InvalidMessageError";constructor(e="Invalid message"){super(e),this.name="InvalidMessageError"}};var Dt=class extends Error{static name="UnsupportedKeyTypeError";constructor(e="Unsupported key type"){super(e),this.name="UnsupportedKeyTypeError"}};var Er=(r,...e)=>{try{[...e]}catch{}};var nn=Symbol.for("@libp2p/service-capabilities"),Gd=Symbol.for("@libp2p/service-dependencies");var Gs={};Ae(Gs,{base58btc:()=>J,base58flickr:()=>pu});var mp=new Uint8Array(0);function Gi(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function it(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 Wi(r){return new TextEncoder().encode(r)}function ji(r){return new TextDecoder().decode(r)}function lu(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var s=0;s<r.length;s++){var o=r.charAt(s),i=o.charCodeAt(0);if(t[i]!==255)throw new TypeError(o+" is ambiguous");t[i]=s}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(m){if(m instanceof Uint8Array||(ArrayBuffer.isView(m)?m=new Uint8Array(m.buffer,m.byteOffset,m.byteLength):Array.isArray(m)&&(m=Uint8Array.from(m))),!(m instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(m.length===0)return"";for(var y=0,d=0,x=0,B=m.length;x!==B&&m[x]===0;)x++,y++;for(var g=(B-x)*l+1>>>0,S=new Uint8Array(g);x!==B;){for(var L=m[x],U=0,I=g-1;(L!==0||U<d)&&I!==-1;I--,U++)L+=256*S[I]>>>0,S[I]=L%a>>>0,L=L/a>>>0;if(L!==0)throw new Error("Non-zero carry");d=U,x++}for(var k=g-d;k!==g&&S[k]===0;)k++;for(var T=c.repeat(y);k<g;++k)T+=r.charAt(S[k]);return T}function h(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return new Uint8Array;var y=0;if(m[y]!==" "){for(var d=0,x=0;m[y]===c;)d++,y++;for(var B=(m.length-y)*u+1>>>0,g=new Uint8Array(B);m[y];){var S=t[m.charCodeAt(y)];if(S===255)return;for(var L=0,U=B-1;(S!==0||L<x)&&U!==-1;U--,L++)S+=a*g[U]>>>0,g[U]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");x=L,y++}if(m[y]!==" "){for(var I=B-x;I!==B&&g[I]===0;)I++;for(var k=new Uint8Array(d+(B-I)),T=d;I!==B;)k[T++]=g[I++];return k}}}function w(m){var y=h(m);if(y)return y;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:w}}var uu=lu,fu=uu,Yi=fu;var Ks=class{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},qs=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Ji(this,e)}},$s=class{decoders;constructor(e){this.decoders=e}or(e){return Ji(this,e)}decode(e){let t=e[0],n=this.decoders[t];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Ji(r,e){return new $s({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var zs=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,s){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=s,this.encoder=new Ks(e,t,n),this.decoder=new qs(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Xt({name:r,prefix:e,encode:t,decode:n}){return new zs(r,e,t,n)}function Et({name:r,prefix:e,alphabet:t}){let{encode:n,decode:s}=Yi(t,r);return Xt({prefix:e,name:r,encode:n,decode:o=>it(s(o))})}function hu(r,e,t,n){let s={};for(let l=0;l<e.length;++l)s[e[l]]=l;let o=r.length;for(;r[o-1]==="=";)--o;let i=new Uint8Array(o*t/8|0),a=0,c=0,u=0;for(let l=0;l<o;++l){let f=s[r[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|f,a+=t,a>=8&&(a-=8,i[u++]=255&c>>a)}if(a>=t||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return i}function du(r,e,t){let n=e[e.length-1]==="=",s=(1<<t)-1,o="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,o+=e[s&a>>i];if(i!==0&&(o+=e[s&a<<t-i]),n)for(;o.length*t&7;)o+="=";return o}function ee({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Xt({prefix:e,name:r,encode(s){return du(s,n,t)},decode(s){return hu(s,n,t,r)}})}var J=Et({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pu=Et({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ws={};Ae(Ws,{base32:()=>at,base32hex:()=>bu,base32hexpad:()=>xu,base32hexpadupper:()=>vu,base32hexupper:()=>wu,base32pad:()=>mu,base32padupper:()=>yu,base32upper:()=>gu,base32z:()=>Eu});var at=ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),gu=ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mu=ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yu=ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bu=ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wu=ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xu=ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),vu=ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Eu=ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bu=ea,Xi=128,Au=127,Su=~Au,Iu=Math.pow(2,31);function ea(r,e,t){e=e||[],t=t||0;for(var n=t;r>=Iu;)e[t++]=r&255|Xi,r/=128;for(;r&Su;)e[t++]=r&255|Xi,r>>>=7;return e[t]=r|0,ea.bytes=t-n+1,e}var ku=js,Nu=128,Qi=127;function js(r,n){var t=0,n=n||0,s=0,o=n,i,a=r.length;do{if(o>=a)throw js.bytes=0,new RangeError("Could not decode varint");i=r[o++],t+=s<28?(i&Qi)<<s:(i&Qi)*Math.pow(2,s),s+=7}while(i>=Nu);return js.bytes=o-n,t}var Cu=Math.pow(2,7),Tu=Math.pow(2,14),Uu=Math.pow(2,21),Lu=Math.pow(2,28),Ru=Math.pow(2,35),_u=Math.pow(2,42),Ou=Math.pow(2,49),Vu=Math.pow(2,56),Pu=Math.pow(2,63),Du=function(r){return r<Cu?1:r<Tu?2:r<Uu?3:r<Lu?4:r<Ru?5:r<_u?6:r<Ou?7:r<Vu?8:r<Pu?9:10},Mu={encode:Bu,decode:ku,encodingLength:Du},Hu=Mu,Br=Hu;function Ar(r,e=0){return[Br.decode(r,e),Br.decode.bytes]}function Qt(r,e,t=0){return Br.encode(r,e,t),e}function er(r){return Br.encodingLength(r)}function Me(r,e){let t=e.byteLength,n=er(r),s=n+er(t),o=new Uint8Array(s+t);return Qt(r,o,0),Qt(t,o,n),o.set(e,s),new tr(r,t,e,o)}function Mt(r){let e=it(r),[t,n]=Ar(e),[s,o]=Ar(e.subarray(n)),i=e.subarray(n+o);if(i.byteLength!==s)throw new Error("Incorrect length");return new tr(t,s,i,e)}function ta(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&Gi(r.bytes,t.bytes)}}var tr=class{code;size;digest;bytes;constructor(e,t,n,s){this.code=e,this.size=t,this.digest=n,this.bytes=s}};function ra(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return Ku(t,Zs(r),e??J.encoder);default:return qu(t,Zs(r),e??at.encoder)}}var na=new WeakMap;function Zs(r){let e=na.get(r);if(e==null){let t=new Map;return na.set(r,t),t}return e}var de=class r{code;version;multihash;bytes;"/";constructor(e,t,n,s){this.code=t,this.version=e,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:e,multihash:t}=this;if(e!==Sr)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$u)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,n=Me(e,t);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(e){return r.equals(this,e)}static equals(e,t){let n=t;return n!=null&&e.code===n.code&&e.version===n.version&&ta(e.multihash,n.multihash)}toString(e){return ra(this,e)}toJSON(){return{"/":ra(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let t=e;if(t instanceof r)return t;if(t["/"]!=null&&t["/"]===t.bytes||t.asCID===t){let{version:n,code:s,multihash:o,bytes:i}=t;return new r(n,s,o,i??sa(n,s,o.bytes))}else if(t[zu]===!0){let{version:n,multihash:s,code:o}=t,i=Mt(s);return r.create(n,o,i)}else return null}static create(e,t,n){if(typeof t!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(t!==Sr)throw new Error(`Version 0 CID must use dag-pb (code: ${Sr}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let s=sa(e,t,n.bytes);return new r(e,t,n,s)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Sr,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,n]=r.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),n=t.size-t.multihashSize,s=it(e.subarray(n,n+t.multihashSize));if(s.byteLength!==t.multihashSize)throw new Error("Incorrect length");let o=s.subarray(t.multihashSize-t.digestSize),i=new tr(t.multihashCode,t.digestSize,o,s);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[f,h]=Ar(e.subarray(t));return t+=h,f},s=n(),o=Sr;if(s===18?(s=0,t=0):o=n(),s!==0&&s!==1)throw new RangeError(`Invalid CID version ${s}`);let i=t,a=n(),c=n(),u=t+c,l=u-i;return{version:s,codec:o,multihashCode:a,digestSize:c,multihashSize:l,size:u}}static parse(e,t){let[n,s]=Fu(e,t),o=r.decode(s);if(o.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Zs(o).set(n,e),o}};function Fu(r,e){switch(r[0]){case"Q":{let t=e??J;return[J.prefix,t.decode(`${J.prefix}${r}`)]}case J.prefix:{let t=e??J;return[J.prefix,t.decode(r)]}case at.prefix:{let t=e??at;return[at.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}}function Ku(r,e,t){let{prefix:n}=t;if(n!==J.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let s=e.get(n);if(s==null){let o=t.encode(r).slice(1);return e.set(n,o),o}else return s}function qu(r,e,t){let{prefix:n}=t,s=e.get(n);if(s==null){let o=t.encode(r);return e.set(n,o),o}else return s}var Sr=112,$u=18;function sa(r,e,t){let n=er(r),s=n+er(e),o=new Uint8Array(s+t.byteLength);return Qt(r,o,0),Qt(e,o,n),o.set(t,s),o}var zu=Symbol.for("@ipld/js-cid/CID");var Ys={};Ae(Ys,{identity:()=>ct});var oa=0,Gu="identity",ia=it;function Wu(r){return Me(oa,ia(r))}var ct={code:oa,name:Gu,encode:ia,digest:Wu};function be(r,e){if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t<r.byteLength;t++)if(r[t]!==e[t])return!1;return!0}function aa(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function ju(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function rr(r,...e){if(!ju(r))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(r.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${r.length}`)}function ca(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 nr(r,e=!0){if(r.destroyed)throw new Error("Hash instance has been destroyed");if(e&&r.finished)throw new Error("Hash#digest() has already been called")}function la(r,e){rr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Ht=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var on=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),He=(r,e)=>r<<32-e|r>>>e;var Pp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ua(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Ir(r){return typeof r=="string"&&(r=ua(r)),rr(r),r}function Js(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];rr(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}var sr=class{clone(){return this._cloneInto()}},Dp={}.toString;function an(r){let e=n=>r().update(Ir(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function cn(r=32){if(Ht&&typeof Ht.getRandomValues=="function")return Ht.getRandomValues(new Uint8Array(r));if(Ht&&typeof Ht.randomBytes=="function")return Ht.randomBytes(r);throw new Error("crypto.getRandomValues must be defined")}function Zu(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let s=BigInt(32),o=BigInt(4294967295),i=Number(t>>s&o),a=Number(t&o),c=n?4:0,u=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+u,a,n)}var fa=(r,e,t)=>r&e^~r&t,ha=(r,e,t)=>r&e^r&t^e&t,or=class extends sr{constructor(e,t,n,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=on(this.buffer)}update(e){nr(this);let{view:t,buffer:n,blockLen:s}=this;e=Ir(e);let o=e.length;for(let i=0;i<o;){let a=Math.min(s-this.pos,o-i);if(a===s){let c=on(e);for(;s<=o-i;i+=s)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){nr(this),la(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:s,isLE:o}=this,{pos:i}=this;t[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++)t[f]=0;Zu(n,s-8,BigInt(this.length*8),o),this.process(n,0);let a=on(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,l=this.get();if(u>l.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<u;f++)a.setUint32(4*f,l[f],o)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:n,length:s,finished:o,destroyed:i,pos:a}=this;return e.length=s,e.pos=a,e.finished=o,e.destroyed=i,s%t&&e.buffer.set(n),e}};var ln=BigInt(4294967295),Xs=BigInt(32);function da(r,e=!1){return e?{h:Number(r&ln),l:Number(r>>Xs&ln)}:{h:Number(r>>Xs&ln)|0,l:Number(r&ln)|0}}function Yu(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let s=0;s<r.length;s++){let{h:o,l:i}=da(r[s],e);[t[s],n[s]]=[o,i]}return[t,n]}var Ju=(r,e)=>BigInt(r>>>0)<<Xs|BigInt(e>>>0),Xu=(r,e,t)=>r>>>t,Qu=(r,e,t)=>r<<32-t|e>>>t,ef=(r,e,t)=>r>>>t|e<<32-t,tf=(r,e,t)=>r<<32-t|e>>>t,rf=(r,e,t)=>r<<64-t|e>>>t-32,nf=(r,e,t)=>r>>>t-32|e<<64-t,sf=(r,e)=>e,of=(r,e)=>r,af=(r,e,t)=>r<<t|e>>>32-t,cf=(r,e,t)=>e<<t|r>>>32-t,lf=(r,e,t)=>e<<t-32|r>>>64-t,uf=(r,e,t)=>r<<t-32|e>>>64-t;function ff(r,e,t,n){let s=(e>>>0)+(n>>>0);return{h:r+t+(s/2**32|0)|0,l:s|0}}var hf=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),df=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,pf=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),gf=(r,e,t,n,s)=>e+t+n+s+(r/2**32|0)|0,mf=(r,e,t,n,s)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(s>>>0),yf=(r,e,t,n,s,o)=>e+t+n+s+o+(r/2**32|0)|0;var bf={fromBig:da,split:Yu,toBig:Ju,shrSH:Xu,shrSL:Qu,rotrSH:ef,rotrSL:tf,rotrBH:rf,rotrBL:nf,rotr32H:sf,rotr32L:of,rotlSH:af,rotlSL:cf,rotlBH:lf,rotlBL:uf,add:ff,add3L:hf,add3H:df,add4L:pf,add4H:gf,add5H:yf,add5L:mf},O=bf;var[wf,xf]=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))),At=new Uint32Array(80),St=new Uint32Array(80),Qs=class extends or{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:e,Al:t,Bh:n,Bl:s,Ch:o,Cl:i,Dh:a,Dl:c,Eh:u,El:l,Fh:f,Fl:h,Gh:w,Gl:m,Hh:y,Hl:d}=this;return[e,t,n,s,o,i,a,c,u,l,f,h,w,m,y,d]}set(e,t,n,s,o,i,a,c,u,l,f,h,w,m,y,d){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=s|0,this.Ch=o|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=l|0,this.Fh=f|0,this.Fl=h|0,this.Gh=w|0,this.Gl=m|0,this.Hh=y|0,this.Hl=d|0}process(e,t){for(let g=0;g<16;g++,t+=4)At[g]=e.getUint32(t),St[g]=e.getUint32(t+=4);for(let g=16;g<80;g++){let S=At[g-15]|0,L=St[g-15]|0,U=O.rotrSH(S,L,1)^O.rotrSH(S,L,8)^O.shrSH(S,L,7),I=O.rotrSL(S,L,1)^O.rotrSL(S,L,8)^O.shrSL(S,L,7),k=At[g-2]|0,T=St[g-2]|0,ne=O.rotrSH(k,T,19)^O.rotrBH(k,T,61)^O.shrSH(k,T,6),K=O.rotrSL(k,T,19)^O.rotrBL(k,T,61)^O.shrSL(k,T,6),V=O.add4L(I,K,St[g-7],St[g-16]),se=O.add4H(V,U,ne,At[g-7],At[g-16]);At[g]=se|0,St[g]=V|0}let{Ah:n,Al:s,Bh:o,Bl:i,Ch:a,Cl:c,Dh:u,Dl:l,Eh:f,El:h,Fh:w,Fl:m,Gh:y,Gl:d,Hh:x,Hl:B}=this;for(let g=0;g<80;g++){let S=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&w^~f&y,I=h&m^~h&d,k=O.add5L(B,L,I,xf[g],St[g]),T=O.add5H(k,x,S,U,wf[g],At[g]),ne=k|0,K=O.rotrSH(n,s,28)^O.rotrBH(n,s,34)^O.rotrBH(n,s,39),V=O.rotrSL(n,s,28)^O.rotrBL(n,s,34)^O.rotrBL(n,s,39),se=n&o^n&a^o&a,E=s&i^s&c^i&c;x=y|0,B=d|0,y=w|0,d=m|0,w=f|0,m=h|0,{h:f,l:h}=O.add(u|0,l|0,T|0,ne|0),u=a|0,l=c|0,a=o|0,c=i|0,o=n|0,i=s|0;let N=O.add3L(ne,V,E);n=O.add3H(N,T,K,se),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:a,l:c}=O.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l}=O.add(this.Dh|0,this.Dl|0,u|0,l|0),{h:f,l:h}=O.add(this.Eh|0,this.El|0,f|0,h|0),{h:w,l:m}=O.add(this.Fh|0,this.Fl|0,w|0,m|0),{h:y,l:d}=O.add(this.Gh|0,this.Gl|0,y|0,d|0),{h:x,l:B}=O.add(this.Hh|0,this.Hl|0,x|0,B|0),this.set(n,s,o,i,a,c,u,l,f,h,w,m,y,d,x,B)}roundClean(){At.fill(0),St.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 pa=an(()=>new Qs);var fn={};Ae(fn,{aInRange:()=>Ne,abool:()=>Fe,abytes:()=>ir,bitGet:()=>If,bitLen:()=>so,bitMask:()=>Nr,bitSet:()=>kf,bytesToHex:()=>ut,bytesToNumberBE:()=>ft,bytesToNumberLE:()=>kt,concatBytes:()=>ht,createHmacDrbg:()=>oo,ensureBytes:()=>te,equalBytes:()=>Af,hexToBytes:()=>Kt,hexToNumber:()=>no,inRange:()=>kr,isBytes:()=>It,memoized:()=>$t,notImplemented:()=>Cf,numberToBytesBE:()=>Nt,numberToBytesLE:()=>qt,numberToHexUnpadded:()=>Ft,numberToVarBytesBE:()=>Bf,utf8ToBytes:()=>Sf,validateObject:()=>Je});var ro=BigInt(0),un=BigInt(1),vf=BigInt(2);function It(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function ir(r){if(!It(r))throw new Error("Uint8Array expected")}function Fe(r,e){if(typeof e!="boolean")throw new Error(`${r} must be valid boolean, got "${e}".`)}var Ef=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function ut(r){ir(r);let e="";for(let t=0;t<r.length;t++)e+=Ef[r[t]];return e}function Ft(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function no(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var lt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function ga(r){if(r>=lt._0&&r<=lt._9)return r-lt._0;if(r>=lt._A&&r<=lt._F)return r-(lt._A-10);if(r>=lt._a&&r<=lt._f)return r-(lt._a-10)}function Kt(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);let e=r.length,t=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);let n=new Uint8Array(t);for(let s=0,o=0;s<t;s++,o+=2){let i=ga(r.charCodeAt(o)),a=ga(r.charCodeAt(o+1));if(i===void 0||a===void 0){let c=r[o]+r[o+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+o)}n[s]=i*16+a}return n}function ft(r){return no(ut(r))}function kt(r){return ir(r),no(ut(Uint8Array.from(r).reverse()))}function Nt(r,e){return Kt(r.toString(16).padStart(e*2,"0"))}function qt(r,e){return Nt(r,e).reverse()}function Bf(r){return Kt(Ft(r))}function te(r,e,t){let n;if(typeof e=="string")try{n=Kt(e)}catch(o){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${o}`)}else if(It(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let s=n.length;if(typeof t=="number"&&s!==t)throw new Error(`${r} expected ${t} bytes, got ${s}`);return n}function ht(...r){let e=0;for(let n=0;n<r.length;n++){let s=r[n];ir(s),e+=s.length}let t=new Uint8Array(e);for(let n=0,s=0;n<r.length;n++){let o=r[n];t.set(o,s),s+=o.length}return t}function Af(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r[n]^e[n];return t===0}function Sf(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}var eo=r=>typeof r=="bigint"&&ro<=r;function kr(r,e,t){return eo(r)&&eo(e)&&eo(t)&&e<=r&&r<t}function Ne(r,e,t,n){if(!kr(e,t,n))throw new Error(`expected valid ${r}: ${t} <= n < ${n}, got ${typeof e} ${e}`)}function so(r){let e;for(e=0;r>ro;r>>=un,e+=1);return e}function If(r,e){return r>>BigInt(e)&un}function kf(r,e,t){return r|(t?un:ro)<<BigInt(e)}var Nr=r=>(vf<<BigInt(r-1))-un,to=r=>new Uint8Array(r),ma=r=>Uint8Array.from(r);function oo(r,e,t){if(typeof r!="number"||r<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let n=to(r),s=to(r),o=0,i=()=>{n.fill(1),s.fill(0),o=0},a=(...f)=>t(s,n,...f),c=(f=to())=>{s=a(ma([0]),f),n=a(),f.length!==0&&(s=a(ma([1]),f),n=a())},u=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let f=0,h=[];for(;f<e;){n=a();let w=n.slice();h.push(w),f+=n.length}return ht(...h)};return(f,h)=>{i(),c(f);let w;for(;!(w=h(u()));)c();return i(),w}}var Nf={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"||It(r),isSafeInteger:r=>Number.isSafeInteger(r),array:r=>Array.isArray(r),field:(r,e)=>e.Fp.isValid(r),hash:r=>typeof r=="function"&&Number.isSafeInteger(r.outputLen)};function Je(r,e,t={}){let n=(s,o,i)=>{let a=Nf[o];if(typeof a!="function")throw new Error(`Invalid validator "${o}", expected function`);let c=r[s];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(s)}=${c} (${typeof c}), expected ${o}`)};for(let[s,o]of Object.entries(e))n(s,o,!1);for(let[s,o]of Object.entries(t))n(s,o,!0);return r}var Cf=()=>{throw new Error("not implemented")};function $t(r){let e=new WeakMap;return(t,...n)=>{let s=e.get(t);if(s!==void 0)return s;let o=r(t,...n);return e.set(t,o),o}}var ie=BigInt(0),X=BigInt(1),zt=BigInt(2),Tf=BigInt(3),io=BigInt(4),ya=BigInt(5),ba=BigInt(8),Uf=BigInt(9),Lf=BigInt(16);function j(r,e){let t=r%e;return t>=ie?t:e+t}function Rf(r,e,t){if(t<=ie||e<ie)throw new Error("Expected power/modulo > 0");if(t===X)return ie;let n=X;for(;e>ie;)e&X&&(n=n*r%t),r=r*r%t,e>>=X;return n}function Q(r,e,t){let n=r;for(;e-- >ie;)n*=n,n%=t;return n}function hn(r,e){if(r===ie||e<=ie)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=j(r,e),n=e,s=ie,o=X,i=X,a=ie;for(;t!==ie;){let u=n/t,l=n%t,f=s-i*u,h=o-a*u;n=t,t=l,s=i,o=a,i=f,a=h}if(n!==X)throw new Error("invert: does not exist");return j(s,e)}function _f(r){let e=(r-X)/zt,t,n,s;for(t=r-X,n=0;t%zt===ie;t/=zt,n++);for(s=zt;s<r&&Rf(s,e,r)!==r-X;s++);if(n===1){let i=(r+X)/io;return function(c,u){let l=c.pow(u,i);if(!c.eql(c.sqr(l),u))throw new Error("Cannot find square root");return l}}let o=(t+X)/zt;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,l=a.pow(a.mul(a.ONE,s),t),f=a.pow(c,o),h=a.pow(c,t);for(;!a.eql(h,a.ONE);){if(a.eql(h,a.ZERO))return a.ZERO;let w=1;for(let y=a.sqr(h);w<u&&!a.eql(y,a.ONE);w++)y=a.sqr(y);let m=a.pow(l,X<<BigInt(u-w-1));l=a.sqr(m),f=a.mul(f,m),h=a.mul(h,l),u=w}return f}}function Of(r){if(r%io===Tf){let e=(r+X)/io;return function(n,s){let o=n.pow(s,e);if(!n.eql(n.sqr(o),s))throw new Error("Cannot find square root");return o}}if(r%ba===ya){let e=(r-ya)/ba;return function(n,s){let o=n.mul(s,zt),i=n.pow(o,e),a=n.mul(s,i),c=n.mul(n.mul(a,zt),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),s))throw new Error("Cannot find square root");return u}}return r%Lf,_f(r)}var wa=(r,e)=>(j(r,e)&X)===X,Vf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ao(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=Vf.reduce((n,s)=>(n[s]="function",n),e);return Je(r,t)}function Pf(r,e,t){if(t<ie)throw new Error("Expected power > 0");if(t===ie)return r.ONE;if(t===X)return e;let n=r.ONE,s=e;for(;t>ie;)t&X&&(n=r.mul(n,s)),s=r.sqr(s),t>>=X;return n}function Df(r,e){let t=new Array(e.length),n=e.reduce((o,i,a)=>r.is0(i)?o:(t[a]=o,r.mul(o,i)),r.ONE),s=r.inv(n);return e.reduceRight((o,i,a)=>r.is0(i)?o:(t[a]=r.mul(o,t[a]),r.mul(o,i)),s),t}function co(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ct(r,e,t=!1,n={}){if(r<=ie)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:s,nByteLength:o}=co(r,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=Of(r),a=Object.freeze({ORDER:r,BITS:s,BYTES:o,MASK:Nr(s),ZERO:ie,ONE:X,create:c=>j(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return ie<=c&&c<r},is0:c=>c===ie,isOdd:c=>(c&X)===X,neg:c=>j(-c,r),eql:(c,u)=>c===u,sqr:c=>j(c*c,r),add:(c,u)=>j(c+u,r),sub:(c,u)=>j(c-u,r),mul:(c,u)=>j(c*u,r),pow:(c,u)=>Pf(a,c,u),div:(c,u)=>j(c*hn(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>hn(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>Df(a,c),cmov:(c,u,l)=>l?u:c,toBytes:c=>t?qt(c,o):Nt(c,o),fromBytes:c=>{if(c.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);return t?kt(c):ft(c)}});return Object.freeze(a)}function xa(r){if(typeof r!="bigint")throw new Error("field order must be bigint");let e=r.toString(2).length;return Math.ceil(e/8)}function lo(r){let e=xa(r);return e+Math.ceil(e/2)}function va(r,e,t=!1){let n=r.length,s=xa(e),o=lo(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);let i=t?ft(r):kt(r),a=j(i,e-X)+X;return t?qt(a,s):Nt(a,s)}var Hf=BigInt(0),uo=BigInt(1),fo=new WeakMap,Ea=new WeakMap;function dn(r,e){let t=(o,i)=>{let a=i.negate();return o?a:i},n=o=>{if(!Number.isSafeInteger(o)||o<=0||o>e)throw new Error(`Wrong window size=${o}, should be [1..${e}]`)},s=o=>{n(o);let i=Math.ceil(e/o)+1,a=2**(o-1);return{windows:i,windowSize:a}};return{constTimeNegate:t,unsafeLadder(o,i){let a=r.ZERO,c=o;for(;i>Hf;)i&uo&&(a=a.add(c)),c=c.double(),i>>=uo;return a},precomputeWindow(o,i){let{windows:a,windowSize:c}=s(i),u=[],l=o,f=l;for(let h=0;h<a;h++){f=l,u.push(f);for(let w=1;w<c;w++)f=f.add(l),u.push(f);l=f.double()}return u},wNAF(o,i,a){let{windows:c,windowSize:u}=s(o),l=r.ZERO,f=r.BASE,h=BigInt(2**o-1),w=2**o,m=BigInt(o);for(let y=0;y<c;y++){let d=y*u,x=Number(a&h);a>>=m,x>u&&(x-=w,a+=uo);let B=d,g=d+Math.abs(x)-1,S=y%2!==0,L=x<0;x===0?f=f.add(t(S,i[B])):l=l.add(t(L,i[g]))}return{p:l,f}},wNAFCached(o,i,a){let c=Ea.get(o)||1,u=fo.get(o);return u||(u=this.precomputeWindow(o,c),c!==1&&fo.set(o,a(u))),this.wNAF(c,u,i)},setWindowSize(o,i){n(i),Ea.set(o,i),fo.delete(o)}}}function pn(r,e,t,n){if(!Array.isArray(t)||!Array.isArray(n)||n.length!==t.length)throw new Error("arrays of points and scalars must have equal length");n.forEach((l,f)=>{if(!e.isValid(l))throw new Error(`wrong scalar at index ${f}`)}),t.forEach((l,f)=>{if(!(l instanceof r))throw new Error(`wrong point at index ${f}`)});let s=so(BigInt(t.length)),o=s>12?s-3:s>4?s-2:s?2:1,i=(1<<o)-1,a=new Array(i+1).fill(r.ZERO),c=Math.floor((e.BITS-1)/o)*o,u=r.ZERO;for(let l=c;l>=0;l-=o){a.fill(r.ZERO);for(let h=0;h<n.length;h++){let w=n[h],m=Number(w>>BigInt(l)&BigInt(i));a[m]=a[m].add(t[h])}let f=r.ZERO;for(let h=a.length-1,w=r.ZERO;h>0;h--)w=w.add(a[h]),f=f.add(w);if(u=u.add(f),l!==0)for(let h=0;h<o;h++)u=u.double()}return u}function Cr(r){return ao(r.Fp),Je(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...co(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var Ke=BigInt(0),Ce=BigInt(1),gn=BigInt(2),Ff=BigInt(8),Kf={zip215:!0};function qf(r){let e=Cr(r);return Je(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Ba(r){let e=qf(r),{Fp:t,n,prehash:s,hash:o,randomBytes:i,nByteLength:a,h:c}=e,u=gn<<BigInt(a*8)-Ce,l=t.create,f=Ct(e.n,e.nBitLength),h=e.uvRatio||((b,p)=>{try{return{isValid:!0,value:t.sqrt(b*t.inv(p))}}catch{return{isValid:!1,value:Ke}}}),w=e.adjustScalarBytes||(b=>b),m=e.domain||((b,p,v)=>{if(Fe("phflag",v),p.length||v)throw new Error("Contexts/pre-hash are not supported");return b});function y(b,p){Ne("coordinate "+b,p,Ke,u)}function d(b){if(!(b instanceof g))throw new Error("ExtendedPoint expected")}let x=$t((b,p)=>{let{ex:v,ey:C,ez:R}=b,_=b.is0();p==null&&(p=_?Ff:t.inv(R));let P=l(v*p),H=l(C*p),D=l(R*p);if(_)return{x:Ke,y:Ce};if(D!==Ce)throw new Error("invZ was invalid");return{x:P,y:H}}),B=$t(b=>{let{a:p,d:v}=e;if(b.is0())throw new Error("bad point: ZERO");let{ex:C,ey:R,ez:_,et:P}=b,H=l(C*C),D=l(R*R),W=l(_*_),Y=l(W*W),le=l(H*p),ue=l(W*l(le+D)),he=l(Y+l(v*l(H*D)));if(ue!==he)throw new Error("bad point: equation left != right (1)");let Be=l(C*R),oe=l(_*P);if(Be!==oe)throw new Error("bad point: equation left != right (2)");return!0});class g{constructor(p,v,C,R){this.ex=p,this.ey=v,this.ez=C,this.et=R,y("x",p),y("y",v),y("z",C),y("t",R),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(p){if(p instanceof g)throw new Error("extended point not allowed");let{x:v,y:C}=p||{};return y("x",v),y("y",C),new g(v,C,Ce,l(v*C))}static normalizeZ(p){let v=t.invertBatch(p.map(C=>C.ez));return p.map((C,R)=>C.toAffine(v[R])).map(g.fromAffine)}static msm(p,v){return pn(g,f,p,v)}_setWindowSize(p){U.setWindowSize(this,p)}assertValidity(){B(this)}equals(p){d(p);let{ex:v,ey:C,ez:R}=this,{ex:_,ey:P,ez:H}=p,D=l(v*H),W=l(_*R),Y=l(C*H),le=l(P*R);return D===W&&Y===le}is0(){return this.equals(g.ZERO)}negate(){return new g(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){let{a:p}=e,{ex:v,ey:C,ez:R}=this,_=l(v*v),P=l(C*C),H=l(gn*l(R*R)),D=l(p*_),W=v+C,Y=l(l(W*W)-_-P),le=D+P,ue=le-H,he=D-P,Be=l(Y*ue),oe=l(le*he),ke=l(Y*he),ot=l(ue*le);return new g(Be,oe,ot,ke)}add(p){d(p);let{a:v,d:C}=e,{ex:R,ey:_,ez:P,et:H}=this,{ex:D,ey:W,ez:Y,et:le}=p;if(v===BigInt(-1)){let Vi=l((_-R)*(W+D)),Pi=l((_+R)*(W-D)),Hs=l(Pi-Vi);if(Hs===Ke)return this.double();let Di=l(P*gn*le),Mi=l(H*gn*Y),Hi=Mi+Di,Fi=Pi+Vi,Ki=Mi-Di,Ql=l(Hi*Hs),eu=l(Fi*Ki),tu=l(Hi*Ki),ru=l(Hs*Fi);return new g(Ql,eu,ru,tu)}let ue=l(R*D),he=l(_*W),Be=l(H*C*le),oe=l(P*Y),ke=l((R+_)*(D+W)-ue-he),ot=oe-Be,xr=oe+Be,vr=l(he-v*ue),Zl=l(ke*ot),Yl=l(xr*vr),Jl=l(ke*vr),Xl=l(ot*xr);return new g(Zl,Yl,Xl,Jl)}subtract(p){return this.add(p.negate())}wNAF(p){return U.wNAFCached(this,p,g.normalizeZ)}multiply(p){let v=p;Ne("scalar",v,Ce,n);let{p:C,f:R}=this.wNAF(v);return g.normalizeZ([C,R])[0]}multiplyUnsafe(p){let v=p;return Ne("scalar",v,Ke,n),v===Ke?L:this.equals(L)||v===Ce?this:this.equals(S)?this.wNAF(v).p:U.unsafeLadder(this,v)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return U.unsafeLadder(this,n).is0()}toAffine(p){return x(this,p)}clearCofactor(){let{h:p}=e;return p===Ce?this:this.multiplyUnsafe(p)}static fromHex(p,v=!1){let{d:C,a:R}=e,_=t.BYTES;p=te("pointHex",p,_),Fe("zip215",v);let P=p.slice(),H=p[_-1];P[_-1]=H&-129;let D=kt(P),W=v?u:t.ORDER;Ne("pointHex.y",D,Ke,W);let Y=l(D*D),le=l(Y-Ce),ue=l(C*Y-R),{isValid:he,value:Be}=h(le,ue);if(!he)throw new Error("Point.fromHex: invalid y coordinate");let oe=(Be&Ce)===Ce,ke=(H&128)!==0;if(!v&&Be===Ke&&ke)throw new Error("Point.fromHex: x=0 and x_0=1");return ke!==oe&&(Be=l(-Be)),g.fromAffine({x:Be,y:D})}static fromPrivateKey(p){return T(p).point}toRawBytes(){let{x:p,y:v}=this.toAffine(),C=qt(v,t.BYTES);return C[C.length-1]|=p&Ce?128:0,C}toHex(){return ut(this.toRawBytes())}}g.BASE=new g(e.Gx,e.Gy,Ce,l(e.Gx*e.Gy)),g.ZERO=new g(Ke,Ce,Ce,Ke);let{BASE:S,ZERO:L}=g,U=dn(g,a*8);function I(b){return j(b,n)}function k(b){return I(kt(b))}function T(b){let p=a;b=te("private key",b,p);let v=te("hashed private key",o(b),2*p),C=w(v.slice(0,p)),R=v.slice(p,2*p),_=k(C),P=S.multiply(_),H=P.toRawBytes();return{head:C,prefix:R,scalar:_,point:P,pointBytes:H}}function ne(b){return T(b).pointBytes}function K(b=new Uint8Array,...p){let v=ht(...p);return k(o(m(v,te("context",b),!!s)))}function V(b,p,v={}){b=te("message",b),s&&(b=s(b));let{prefix:C,scalar:R,pointBytes:_}=T(p),P=K(v.context,C,b),H=S.multiply(P).toRawBytes(),D=K(v.context,H,_,b),W=I(P+D*R);Ne("signature.s",W,Ke,n);let Y=ht(H,qt(W,t.BYTES));return te("result",Y,a*2)}let se=Kf;function E(b,p,v,C=se){let{context:R,zip215:_}=C,P=t.BYTES;b=te("signature",b,2*P),p=te("message",p),_!==void 0&&Fe("zip215",_),s&&(p=s(p));let H=kt(b.slice(P,2*P)),D,W,Y;try{D=g.fromHex(v,_),W=g.fromHex(b.slice(0,P),_),Y=S.multiplyUnsafe(H)}catch{return!1}if(!_&&D.isSmallOrder())return!1;let le=K(R,W.toRawBytes(),D.toRawBytes(),p);return W.add(D.multiplyUnsafe(le)).subtract(Y).clearCofactor().equals(g.ZERO)}return S._setWindowSize(8),{CURVE:e,getPublicKey:ne,sign:V,verify:E,ExtendedPoint:g,utils:{getExtendedPublicKey:T,randomPrivateKey:()=>i(t.BYTES),precompute(b=8,p=g.BASE){return p._setWindowSize(b),p.multiply(BigInt(3)),p}}}}var ho=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Aa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),a0=BigInt(0),$f=BigInt(1),Sa=BigInt(2),c0=BigInt(3),zf=BigInt(5),Gf=BigInt(8);function Wf(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),s=BigInt(80),o=ho,a=r*r%o*r%o,c=Q(a,Sa,o)*a%o,u=Q(c,$f,o)*r%o,l=Q(u,zf,o)*u%o,f=Q(l,e,o)*l%o,h=Q(f,t,o)*f%o,w=Q(h,n,o)*h%o,m=Q(w,s,o)*w%o,y=Q(m,s,o)*w%o,d=Q(y,e,o)*l%o;return{pow_p_5_8:Q(d,Sa,o)*r%o,b2:a}}function jf(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Zf(r,e){let t=ho,n=j(e*e*e,t),s=j(n*n*e,t),o=Wf(r*s).pow_p_5_8,i=j(r*n*o,t),a=j(e*i*i,t),c=i,u=j(i*Aa,t),l=a===r,f=a===j(-r,t),h=a===j(-r*Aa,t);return l&&(i=c),(f||h)&&(i=u),wa(i,t)&&(i=j(-i,t)),{isValid:l||f,value:i}}var Yf=Ct(ho,void 0,!0),Jf={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Yf,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Gf,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:pa,randomBytes:cn,adjustScalarBytes:jf,uvRatio:Zf},Ia=Ba(Jf);var mn=32;function ka(r,e,t){return Ia.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}var yn=class{type="Ed25519";raw;constructor(e){this.raw=po(e,mn)}toMultihash(){return ct.digest(Tt(this))}toCID(){return de.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}verify(e,t){return ka(this.raw,t,e)}};function go(r){return r=po(r,mn),new yn(r)}function po(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new Se(`Key must be a Uint8Array of length ${e}, got ${r.length}`);return r}function pe(r=0){return new Uint8Array(r)}function Te(r=0){return new Uint8Array(r)}var Qf=Math.pow(2,7),eh=Math.pow(2,14),th=Math.pow(2,21),mo=Math.pow(2,28),yo=Math.pow(2,35),bo=Math.pow(2,42),wo=Math.pow(2,49),G=128,we=127;function xe(r){if(r<Qf)return 1;if(r<eh)return 2;if(r<th)return 3;if(r<mo)return 4;if(r<yo)return 5;if(r<bo)return 6;if(r<wo)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function xo(r,e,t=0){switch(xe(r)){case 8:e[t++]=r&255|G,r/=128;case 7:e[t++]=r&255|G,r/=128;case 6:e[t++]=r&255|G,r/=128;case 5:e[t++]=r&255|G,r/=128;case 4:e[t++]=r&255|G,r>>>=7;case 3:e[t++]=r&255|G,r>>>=7;case 2:e[t++]=r&255|G,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function rh(r,e,t=0){switch(xe(r)){case 8:e.set(t++,r&255|G),r/=128;case 7:e.set(t++,r&255|G),r/=128;case 6:e.set(t++,r&255|G),r/=128;case 5:e.set(t++,r&255|G),r/=128;case 4:e.set(t++,r&255|G),r>>>=7;case 3:e.set(t++,r&255|G),r>>>=7;case 2:e.set(t++,r&255|G),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function vo(r,e){let t=r[e],n=0;if(n+=t&we,t<G||(t=r[e+1],n+=(t&we)<<7,t<G)||(t=r[e+2],n+=(t&we)<<14,t<G)||(t=r[e+3],n+=(t&we)<<21,t<G)||(t=r[e+4],n+=(t&we)*mo,t<G)||(t=r[e+5],n+=(t&we)*yo,t<G)||(t=r[e+6],n+=(t&we)*bo,t<G)||(t=r[e+7],n+=(t&we)*wo,t<G))return n;throw new RangeError("Could not decode varint")}function nh(r,e){let t=r.get(e),n=0;if(n+=t&we,t<G||(t=r.get(e+1),n+=(t&we)<<7,t<G)||(t=r.get(e+2),n+=(t&we)<<14,t<G)||(t=r.get(e+3),n+=(t&we)<<21,t<G)||(t=r.get(e+4),n+=(t&we)*mo,t<G)||(t=r.get(e+5),n+=(t&we)*yo,t<G)||(t=r.get(e+6),n+=(t&we)*bo,t<G)||(t=r.get(e+7),n+=(t&we)*wo,t<G))return n;throw new RangeError("Could not decode varint")}function Oe(r,e,t=0){return e==null&&(e=Te(xe(r))),e instanceof Uint8Array?xo(r,e,t):rh(r,e,t)}function dt(r,e=0){return r instanceof Uint8Array?vo(r,e):nh(r,e)}var Eo=new Float32Array([-0]),Ut=new Uint8Array(Eo.buffer);function Ca(r,e,t){Eo[0]=r,e[t]=Ut[0],e[t+1]=Ut[1],e[t+2]=Ut[2],e[t+3]=Ut[3]}function Ta(r,e){return Ut[0]=r[e],Ut[1]=r[e+1],Ut[2]=r[e+2],Ut[3]=r[e+3],Eo[0]}var Bo=new Float64Array([-0]),ve=new Uint8Array(Bo.buffer);function Ua(r,e,t){Bo[0]=r,e[t]=ve[0],e[t+1]=ve[1],e[t+2]=ve[2],e[t+3]=ve[3],e[t+4]=ve[4],e[t+5]=ve[5],e[t+6]=ve[6],e[t+7]=ve[7]}function La(r,e){return ve[0]=r[e],ve[1]=r[e+1],ve[2]=r[e+2],ve[3]=r[e+3],ve[4]=r[e+4],ve[5]=r[e+5],ve[6]=r[e+6],ve[7]=r[e+7],Bo[0]}var sh=BigInt(Number.MAX_SAFE_INTEGER),oh=BigInt(Number.MIN_SAFE_INTEGER),Re=class r{lo;hi;constructor(e,t){this.lo=e|0,this.hi=t|0}toNumber(e=!1){if(!e&&this.hi>>>31>0){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(t+n*4294967296)}return this.lo+this.hi*4294967296}toBigInt(e=!1){if(e)return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31){let t=~this.lo+1>>>0,n=~this.hi>>>0;return t===0&&(n=n+1>>>0),-(BigInt(t)+(BigInt(n)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(e=!1){return this.toBigInt(e).toString()}zzEncode(){let e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){let e=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){let e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return n===0?t===0?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(e===0n)return Gt;if(e<sh&&e>oh)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,s=e-(n<<32n);return t&&(n=~n|0n,s=~s|0n,++s>Ra&&(s=0n,++n>Ra&&(n=0n))),new r(Number(s),Number(n))}static fromNumber(e){if(e===0)return Gt;let t=e<0;t&&(e=-e);let n=e>>>0,s=(e-n)/4294967296>>>0;return t&&(s=~s>>>0,n=~n>>>0,++n>4294967295&&(n=0,++s>4294967295&&(s=0))),new r(n,s)}static from(e){return typeof e=="number"?r.fromNumber(e):typeof e=="bigint"?r.fromBigInt(e):typeof e=="string"?r.fromBigInt(BigInt(e)):e.low!=null||e.high!=null?new r(e.low>>>0,e.high>>>0):Gt}},Gt=new Re(0,0);Gt.toBigInt=function(){return 0n};Gt.zzEncode=Gt.zzDecode=function(){return this};Gt.length=function(){return 1};var Ra=4294967296n;function _a(r){let e=0,t=0;for(let n=0;n<r.length;++n)t=r.charCodeAt(n),t<128?e+=1:t<2048?e+=2:(t&64512)===55296&&(r.charCodeAt(n+1)&64512)===56320?(++n,e+=4):e+=3;return e}function Oa(r,e,t){if(t-e<1)return"";let s,o=[],i=0,a;for(;e<t;)a=r[e++],a<128?o[i++]=a:a>191&&a<224?o[i++]=(a&31)<<6|r[e++]&63:a>239&&a<365?(a=((a&7)<<18|(r[e++]&63)<<12|(r[e++]&63)<<6|r[e++]&63)-65536,o[i++]=55296+(a>>10),o[i++]=56320+(a&1023)):o[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&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 Ao(r,e,t){let n=t,s,o;for(let i=0;i<r.length;++i)s=r.charCodeAt(i),s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&((o=r.charCodeAt(i+1))&64512)===56320?(s=65536+((s&1023)<<10)+(o&1023),++i,e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128);return t-n}function qe(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function wn(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var So=class{buf;pos;len;_slice=Uint8Array.prototype.subarray;constructor(e){this.buf=e,this.pos=0,this.len=e.length}uint32(){let e=4294967295;if(e=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||(e=(e|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||(e=(e|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return e;if((this.pos+=5)>this.len)throw this.pos=this.len,qe(this,10);return e}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)|0}bool(){return this.uint32()!==0}fixed32(){if(this.pos+4>this.len)throw qe(this,4);return wn(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw qe(this,4);return wn(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw qe(this,4);let e=Ta(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw qe(this,4);let e=La(this.buf,this.pos);return this.pos+=8,e}bytes(){let e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw qe(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Oa(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw qe(this,e);this.pos+=e}else do if(this.pos>=this.len)throw qe(this);while(this.buf[this.pos++]&128);return this}skipType(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(e=this.uint32()&7)!==4;)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){let e=new Re(0,0),t=0;if(this.len-this.pos>4){for(;t<4;++t)if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(this.buf[this.pos]&127)<<28)>>>0,e.hi=(e.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return e;t=0}else{for(;t<3;++t){if(this.pos>=this.len)throw qe(this);if(e.lo=(e.lo|(this.buf[this.pos]&127)<<t*7)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(this.buf[this.pos++]&127)<<t*7)>>>0,e}if(this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw qe(this);if(e.hi=(e.hi|(this.buf[this.pos]&127)<<t*7+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw qe(this,8);let e=wn(this.buf,this.pos+=4),t=wn(this.buf,this.pos+=4);return new Re(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){let e=vo(this.buf,this.pos);return this.pos+=xe(e),e}uint64String(){return this.readLongVarint().toString(!0)}sint64(){return this.readLongVarint().zzDecode().toBigInt()}sint64Number(){return this.readLongVarint().zzDecode().toNumber()}sint64String(){return this.readLongVarint().zzDecode().toString()}fixed64(){return this.readFixed64().toBigInt()}fixed64Number(){return this.readFixed64().toNumber()}fixed64String(){return this.readFixed64().toString()}sfixed64(){return this.readFixed64().toBigInt()}sfixed64Number(){return this.readFixed64().toNumber()}sfixed64String(){return this.readFixed64().toString()}};function Io(r){return new So(r instanceof Uint8Array?r:r.subarray())}function $e(r,e,t){let n=Io(r);return e.decode(n,void 0,t)}var ko={};Ae(ko,{base10:()=>ih});var ih=Et({prefix:"9",name:"base10",alphabet:"0123456789"});var No={};Ae(No,{base16:()=>ah,base16upper:()=>ch});var ah=ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ch=ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Co={};Ae(Co,{base2:()=>lh});var lh=ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var To={};Ae(To,{base256emoji:()=>ph});var Pa=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}"),uh=Pa.reduce((r,e,t)=>(r[t]=e,r),[]),fh=Pa.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function hh(r){return r.reduce((e,t)=>(e+=uh[t],e),"")}function dh(r){let e=[];for(let t of r){let n=fh[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var ph=Xt({prefix:"\u{1F680}",name:"base256emoji",encode:hh,decode:dh});var Uo={};Ae(Uo,{base36:()=>gh,base36upper:()=>mh});var gh=Et({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),mh=Et({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ro={};Ae(Ro,{base64:()=>yh,base64pad:()=>bh,base64url:()=>Lo,base64urlpad:()=>wh});var yh=ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bh=ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lo=ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wh=ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var _o={};Ae(_o,{base8:()=>xh});var xh=ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Oo={};Ae(Oo,{identity:()=>vh});var vh=Xt({prefix:"\0",name:"identity",encode:r=>ji(r),decode:r=>Wi(r)});var z0=new TextEncoder,G0=new TextDecoder;var Do={};Ae(Do,{sha256:()=>Tr,sha512:()=>Ah});function Po({name:r,code:e,encode:t}){return new Vo(r,e,t)}var Vo=class{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Me(this.code,t):t.then(n=>Me(this.code,n))}else throw Error("Unknown type, must be binary type")}};function Ma(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Tr=Po({name:"sha2-256",code:18,encode:Ma("SHA-256")}),Ah=Po({name:"sha2-512",code:19,encode:Ma("SHA-512")});var Ur={...Oo,...Co,..._o,...ko,...No,...Ws,...Uo,...Gs,...Ro,...To},sg={...Do,...Ys};function Fa(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Ha=Fa("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Mo=Fa("ascii","a",r=>{let e="a";for(let t=0;t<r.length;t++)e+=String.fromCharCode(r[t]);return e},r=>{r=r.substring(1);let e=Te(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),Sh={utf8:Ha,"utf-8":Ha,hex:Ur.base16,latin1:Mo,ascii:Mo,binary:Mo,...Ur},xn=Sh;function q(r,e="utf8"){let t=xn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function Ho(r){let e=r??8192,t=e>>>1,n,s=e;return function(i){if(i<1||i>t)return Te(i);s+i>e&&(n=Te(e),s=0);let a=n.subarray(s,s+=i);return s&7&&(s=(s|7)+1),a}}var Wt=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Fo(){}var qo=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Ih=Ho();function kh(r){return globalThis.Buffer!=null?Te(r):Ih(r)}var Rr=class{len;head;tail;states;constructor(){this.len=0,this.head=new Wt(Fo,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Wt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new $o((e=e>>>0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(vn,10,Re.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=Re.fromBigInt(e);return this._push(vn,t.length(),t)}uint64Number(e){return this._push(xo,xe(e),e)}uint64String(e){return this.uint64(BigInt(e))}int64(e){return this.uint64(e)}int64Number(e){return this.uint64Number(e)}int64String(e){return this.uint64String(e)}sint64(e){let t=Re.fromBigInt(e).zzEncode();return this._push(vn,t.length(),t)}sint64Number(e){let t=Re.fromNumber(e).zzEncode();return this._push(vn,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ko,1,e?1:0)}fixed32(e){return this._push(Lr,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=Re.fromBigInt(e);return this._push(Lr,4,t.lo)._push(Lr,4,t.hi)}fixed64Number(e){let t=Re.fromNumber(e);return this._push(Lr,4,t.lo)._push(Lr,4,t.hi)}fixed64String(e){return this.fixed64(BigInt(e))}sfixed64(e){return this.fixed64(e)}sfixed64Number(e){return this.fixed64Number(e)}sfixed64String(e){return this.fixed64String(e)}float(e){return this._push(Ca,4,e)}double(e){return this._push(Ua,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Ko,1,0):this.uint32(t)._push(Ch,t,e)}string(e){let t=_a(e);return t!==0?this.uint32(t)._push(Ao,t,e):this._push(Ko,1,0)}fork(){return this.states=new qo(this),this.head=this.tail=new Wt(Fo,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 Wt(Fo,0,0),this.len=0),this}ldelim(){let e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n!==0&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next,t=kh(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Ko(r,e,t){e[t]=r&255}function Nh(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var $o=class extends Wt{next;constructor(e,t){super(Nh,e,t),this.next=void 0}};function vn(r,e,t){for(;r.hi!==0;)e[t++]=r.lo&127|128,r.lo=(r.lo>>>7|r.hi<<25)>>>0,r.hi>>>=7;for(;r.lo>127;)e[t++]=r.lo&127|128,r.lo=r.lo>>>7;e[t++]=r.lo}function Lr(r,e,t){e[t]=r&255,e[t+1]=r>>>8&255,e[t+2]=r>>>16&255,e[t+3]=r>>>24}function Ch(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Rr.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Th,e,r),this},Rr.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Uh,e,r),this});function Th(r,e,t){e.set(r,t)}function Uh(r,e,t){r.length<40?Ao(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(q(r),t)}function zo(){return new Rr}function ze(r,e){let t=zo();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var ar;(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"})(ar||(ar={}));function En(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function Go(r){function e(s){if(r[s.toString()]==null)throw new Error("Invalid enum value");return r[s]}let t=function(o,i){let a=e(o);i.int32(a)},n=function(o){let i=o.int32();return e(i)};return En("enum",ar.VARINT,t,n)}function Ge(r,e){return En("message",ar.LENGTH_DELIMITED,r,e)}var jt=class extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"};var ae;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.secp256k1="secp256k1"})(ae||(ae={}));var Wo;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.secp256k1=2]="secp256k1"})(Wo||(Wo={}));(function(r){r.codec=()=>Go(Wo)})(ae||(ae={}));var Xe;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ae.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=ae.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(Xe||(Xe={}));var jo;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),ae.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 1:{o.Type=ae.codec().decode(t);break}case 2:{o.Data=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(jo||(jo={}));var qr={};Ae(qr,{MAX_RSA_KEY_SIZE:()=>ds,generateRSAKeyPair:()=>Dc,jwkToJWKKeyPair:()=>Mc,jwkToPkcs1:()=>Wh,jwkToPkix:()=>ni,jwkToRSAPrivateKey:()=>Pc,pkcs1ToJwk:()=>_c,pkcs1ToRSAPrivateKey:()=>Vc,pkixToJwk:()=>Oc,pkixToRSAPublicKey:()=>si});var Lh=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]),Lt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Rt=new Uint32Array(64),Zo=class extends or{constructor(){super(64,32,8,!1),this.A=Lt[0]|0,this.B=Lt[1]|0,this.C=Lt[2]|0,this.D=Lt[3]|0,this.E=Lt[4]|0,this.F=Lt[5]|0,this.G=Lt[6]|0,this.H=Lt[7]|0}get(){let{A:e,B:t,C:n,D:s,E:o,F:i,G:a,H:c}=this;return[e,t,n,s,o,i,a,c]}set(e,t,n,s,o,i,a,c){this.A=e|0,this.B=t|0,this.C=n|0,this.D=s|0,this.E=o|0,this.F=i|0,this.G=a|0,this.H=c|0}process(e,t){for(let f=0;f<16;f++,t+=4)Rt[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){let h=Rt[f-15],w=Rt[f-2],m=He(h,7)^He(h,18)^h>>>3,y=He(w,17)^He(w,19)^w>>>10;Rt[f]=y+Rt[f-7]+m+Rt[f-16]|0}let{A:n,B:s,C:o,D:i,E:a,F:c,G:u,H:l}=this;for(let f=0;f<64;f++){let h=He(a,6)^He(a,11)^He(a,25),w=l+h+fa(a,c,u)+Lh[f]+Rt[f]|0,y=(He(n,2)^He(n,13)^He(n,22))+ha(n,s,o)|0;l=u,u=c,c=a,a=i+w|0,i=o,o=s,s=n,n=w+y|0}n=n+this.A|0,s=s+this.B|0,o=o+this.C|0,i=i+this.D|0,a=a+this.E|0,c=c+this.F|0,u=u+this.G|0,l=l+this.H|0,this.set(n,s,o,i,a,c,u,l)}roundClean(){Rt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};var cr=an(()=>new Zo);var M=zi(qa());function Zt(r,e){let t=0;if(r.length===1)return r[0];for(let n=r.length-1;n>=0;n--)t+=r[r.length-1-n]*Math.pow(2,e*n);return t}function _t(r,e,t=-1){let n=t,s=r,o=0,i=Math.pow(2,e);for(let a=1;a<8;a++){if(r<i){let c;if(n<0)c=new ArrayBuffer(a),o=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),o=n}let u=new Uint8Array(c);for(let l=a-1;l>=0;l--){let f=Math.pow(2,l*e);u[o-l-1]=Math.floor(s/f),s-=u[o-l-1]*f}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Sn(...r){let e=0,t=0;for(let o of r)e+=o.length;let n=new ArrayBuffer(e),s=new Uint8Array(n);for(let o of r)s.set(o,t),t+=o.length;return s}function Jo(){let r=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){let a=r[0]===255&&r[1]&128,c=r[0]===0&&(r[1]&128)===0;(a||c)&&this.warnings.push("Needlessly long format")}let e=new ArrayBuffer(this.valueHex.byteLength),t=new Uint8Array(e);for(let a=0;a<this.valueHex.byteLength;a++)t[a]=0;t[0]=r[0]&128;let n=Zt(t,8),s=new ArrayBuffer(this.valueHex.byteLength),o=new Uint8Array(s);for(let a=0;a<this.valueHex.byteLength;a++)o[a]=r[a];return o[0]&=127,Zt(o,8)-n}function $a(r){let e=r<0?r*-1:r,t=128;for(let n=1;n<8;n++){if(e<=t){if(r<0){let i=t-e,a=_t(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let s=_t(e,8,n),o=new Uint8Array(s);if(o[0]&128){let i=s.slice(0),a=new Uint8Array(i);s=new ArrayBuffer(s.byteLength+1),o=new Uint8Array(s);for(let c=0;c<i.byteLength;c++)o[c+1]=a[c];o[0]=0}return s}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function za(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let s=0;s<t.length;s++)if(t[s]!==n[s])return!1;return!0}function Ue(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,s=new Array(n);for(let i=0;i<n;i++)s[i]="0";return s.join("").concat(t)}var Mg=Math.log(2);function In(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Xo(r){let e=0,t=0;for(let s=0;s<r.length;s++){let o=r[s];e+=o.byteLength}let n=new Uint8Array(e);for(let s=0;s<r.length;s++){let o=r[s];n.set(new Uint8Array(o),t),t+=o.byteLength}return n.buffer}function bt(r,e,t,n){return e instanceof Uint8Array?e.byteLength?t<0?(r.error="Wrong parameter: inputOffset less than zero",!1):n<0?(r.error="Wrong parameter: inputLength less than zero",!1):e.byteLength-t-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 Or=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Xo(this.items)}},_r=[new Uint8Array([1])],Ga="0123456789";var dr="",We=new ArrayBuffer(0),Qo=new Uint8Array(0),Vr="EndOfContent",ja="OCTET STRING",Za="BIT STRING";function wt(r){var e;return e=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):Qo}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(!bt(this,i,s,o))return-1;let a=s+o;return this.valueHexView=i.subarray(s,a),this.valueHexView.length?(this.blockLength=o,a):(this.warnings.push("Zero buffer length"),s)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",We)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:M.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var gt=class{constructor({blockLength:e=0,error:t=dr,warnings:n=[],valueBeforeDecode:s=Qo}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=M.BufferSourceConverter.toUint8Array(s)}static blockName(){return this.NAME}get valueBeforeDecode(){return this.valueBeforeDecodeView.slice().buffer}set valueBeforeDecode(e){this.valueBeforeDecodeView=new Uint8Array(e)}toJSON(){return{blockName:this.constructor.NAME,blockLength:this.blockLength,error:this.error,warnings:this.warnings,valueBeforeDecode:M.Convert.ToHex(this.valueBeforeDecodeView)}}};gt.NAME="baseBlock";var Ee=class extends gt{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}};Ee.NAME="valueBlock";var kn=class extends wt(gt){constructor({idBlock:e={}}={}){var t,n,s,o;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?M.BufferSourceConverter.toUint8Array(e.valueHex):Qo,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(s=e.tagNumber)!==null&&s!==void 0?s:-1,this.isConstructed=(o=e.isConstructed)!==null&&o!==void 0?o:!1):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(e=!1){let t=0;switch(this.tagClass){case 1:t|=0;break;case 2:t|=64;break;case 3:t|=128;break;case 4:t|=192;break;default:return this.error="Unknown tag class",We}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let s=new Uint8Array(1);if(!e){let o=this.tagNumber;o&=31,t|=o,s[0]=t}return s.buffer}if(!this.isHexOnly){let s=_t(this.tagNumber,7),o=new Uint8Array(s),i=s.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let c=0;c<i-1;c++)a[c+1]=o[c]|128;a[i]=o[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){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(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+n);if(o.length===0)return this.error="Zero buffer length",-1;switch(o[0]&192){case 0:this.tagClass=1;break;case 64:this.tagClass=2;break;case 128:this.tagClass=3;break;case 192:this.tagClass=4;break;default:return this.error="Unknown tag class",-1}this.isConstructed=(o[0]&32)===32,this.isHexOnly=!1;let a=o[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),l=255;for(;o[c]&128;){if(u[c-1]=o[c]&127,c++,c>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(c===l){l+=255;let h=new Uint8Array(l);for(let w=0;w<u.length;w++)h[w]=u[w];u=this.valueHexView=new Uint8Array(l)}}this.blockLength=c+1,u[c-1]=o[c]&127;let f=new Uint8Array(c);for(let h=0;h<c;h++)f[h]=u[h];u=this.valueHexView=new Uint8Array(c),u.set(f),this.blockLength<=9?this.tagNumber=Zt(u,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 t+this.blockLength}toJSON(){return{...super.toJSON(),tagClass:this.tagClass,tagNumber:this.tagNumber,isConstructed:this.isConstructed}}};kn.NAME="identificationBlock";var Nn=class extends gt{constructor({lenBlock:e={}}={}){var t,n,s;super(),this.isIndefiniteForm=(t=e.isIndefiniteForm)!==null&&t!==void 0?t:!1,this.longFormUsed=(n=e.longFormUsed)!==null&&n!==void 0?n:!1,this.length=(s=e.length)!==null&&s!==void 0?s:0}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+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,t+this.blockLength;if(this.longFormUsed=!!(o[0]&128),this.longFormUsed===!1)return this.length=o[0],this.blockLength=1,t+this.blockLength;let i=o[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=s.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Zt(c,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,t+this.blockLength}toBER(e=!1){let t,n;if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=128),t;if(this.longFormUsed){let s=_t(this.length,8);if(s.byteLength>127)return this.error="Too big length",We;if(t=new ArrayBuffer(s.byteLength+1),e)return t;let o=new Uint8Array(s);n=new Uint8Array(t),n[0]=s.byteLength|128;for(let i=0;i<s.byteLength;i++)n[i+1]=o[i];return t}return t=new ArrayBuffer(1),e===!1&&(n=new Uint8Array(t),n[0]=this.length),t}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}};Nn.NAME="lengthBlock";var A={},ge=class extends gt{constructor({name:e=dr,optional:t=!1,primitiveSchema:n,...s}={},o){super(s),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new kn(s),this.lenBlock=new Nn(s),this.valueBlock=o?new o(s):new Ee(s)}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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(e,t){let n=t||new Or;t||Ya(this);let s=this.idBlock.toBER(e);if(n.write(s),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let o=this.valueBlock.toBER(e);this.lenBlock.length=o.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(o)}return t?We:n.final()}toJSON(){let e={...super.toJSON(),idBlock:this.idBlock.toJSON(),lenBlock:this.lenBlock.toJSON(),valueBlock:this.valueBlock.toJSON(),name:this.name,optional:this.optional};return this.primitiveSchema&&(e.primitiveSchema=this.primitiveSchema.toJSON()),e}toString(e="ascii"){return e==="ascii"?this.onAsciiEncoding():M.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${M.Convert.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;let t=this.toBER(),n=e.toBER();return za(t,n)}};ge.NAME="BaseBlock";function Ya(r){if(r instanceof A.Constructed)for(let e of r.valueBlock.value)Ya(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var Cn=class extends ge{constructor({value:e=dr,...t}={},n){super(t,n),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,n){let s=this.valueBlock.fromBER(e,t,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}'`}};Cn.NAME="BaseStringBlock";var Tn=class extends wt(Ee){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};Tn.NAME="PrimitiveValueBlock";var Ja,Un=class extends ge{constructor(e={}){super(e,Tn),this.idBlock.isConstructed=!1}};Ja=Un;A.Primitive=Ja;Un.NAME="PRIMITIVE";function Fh(r,e){if(r instanceof e)return r;let t=new e;return t.idBlock=r.idBlock,t.lenBlock=r.lenBlock,t.warnings=r.warnings,t.valueBeforeDecodeView=r.valueBeforeDecodeView,t}function fs(r,e=0,t=r.length){let n=e,s=new ge({},Ee),o=new gt;if(!bt(o,r,e,t))return s.error=o.error,{offset:-1,result:s};if(!r.subarray(e,e+t).length)return s.error="Zero buffer length",{offset:-1,result:s};let a=s.idBlock.fromBER(r,e,t);if(s.idBlock.warnings.length&&s.warnings.concat(s.idBlock.warnings),a===-1)return s.error=s.idBlock.error,{offset:-1,result:s};if(e=a,t-=s.idBlock.blockLength,a=s.lenBlock.fromBER(r,e,t),s.lenBlock.warnings.length&&s.warnings.concat(s.lenBlock.warnings),a===-1)return s.error=s.lenBlock.error,{offset:-1,result:s};if(e=a,t-=s.lenBlock.blockLength,!s.idBlock.isConstructed&&s.lenBlock.isIndefiniteForm)return s.error="Indefinite length form used for primitive encoding form",{offset:-1,result:s};let c=ge;switch(s.idBlock.tagClass){case 1:if(s.idBlock.tagNumber>=37&&s.idBlock.isHexOnly===!1)return s.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:s};switch(s.idBlock.tagNumber){case 0:if(s.idBlock.isConstructed&&s.lenBlock.length>0)return s.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:s};c=A.EndOfContent;break;case 1:c=A.Boolean;break;case 2:c=A.Integer;break;case 3:c=A.BitString;break;case 4:c=A.OctetString;break;case 5:c=A.Null;break;case 6:c=A.ObjectIdentifier;break;case 10:c=A.Enumerated;break;case 12:c=A.Utf8String;break;case 13:c=A.RelativeObjectIdentifier;break;case 14:c=A.TIME;break;case 15:return s.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:s};case 16:c=A.Sequence;break;case 17:c=A.Set;break;case 18:c=A.NumericString;break;case 19:c=A.PrintableString;break;case 20:c=A.TeletexString;break;case 21:c=A.VideotexString;break;case 22:c=A.IA5String;break;case 23:c=A.UTCTime;break;case 24:c=A.GeneralizedTime;break;case 25:c=A.GraphicString;break;case 26:c=A.VisibleString;break;case 27:c=A.GeneralString;break;case 28:c=A.UniversalString;break;case 29:c=A.CharacterString;break;case 30:c=A.BmpString;break;case 31:c=A.DATE;break;case 32:c=A.TimeOfDay;break;case 33:c=A.DateTime;break;case 34:c=A.Duration;break;default:{let u=s.idBlock.isConstructed?new A.Constructed:new A.Primitive;u.idBlock=s.idBlock,u.lenBlock=s.lenBlock,u.warnings=s.warnings,s=u}}break;case 2:case 3:case 4:default:c=s.idBlock.isConstructed?A.Constructed:A.Primitive}return s=Fh(s,c),a=s.fromBER(r,e,s.lenBlock.isIndefiniteForm?t:s.lenBlock.length),s.valueBeforeDecodeView=r.subarray(n,n+s.blockLength),{offset:a,result:s}}function ei(r){if(!r.byteLength){let e=new ge({},Ee);return e.error="Input buffer has zero length",{offset:-1,result:e}}return fs(M.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Kh(r,e){return r?1:e}var Qe=class extends Ee{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;if(this.valueBeforeDecodeView=s.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let o=t;for(;Kh(this.isIndefiniteForm,n)>0;){let i=fs(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===Vr)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Vr?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){let n=t||new Or;for(let s=0;s<this.value.length;s++)this.value[s].toBER(e,n);return t?We:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Qe.NAME="ConstructedValueBlock";var Xa,Ot=class extends ge{constructor(e={}){super(e,Qe),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let s=this.valueBlock.fromBER(e,t,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 e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
|
|
3
3
|
`).map(s=>` ${s}`).join(`
|
|
4
4
|
`));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
|
|
5
5
|
${e.join(`
|
|
6
|
-
`)}`:`${t} :`}};Xa=Ot;A.Constructed=Xa;Ot.NAME="CONSTRUCTED";var Rn=class extends Ee{fromBER(e,t,n){return t}toBER(e){return We}};Rn.override="EndOfContentValueBlock";var Qa,_n=class extends ge{constructor(e={}){super(e,Rn),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Qa=_n;A.EndOfContent=Qa;_n.NAME=Vr;var ec,ur=class extends ge{constructor(e={}){super(e,Ee),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,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,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};ec=ur;A.Null=ec;ur.NAME="NULL";var On=class extends wt(Ee){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=M.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);return bt(this,s,t,n)?(this.valueHexView=s.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Xo.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};On.NAME="BooleanValueBlock";var tc,Vn=class extends ge{constructor(e={}){super(e,On),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};tc=Vn;A.Boolean=tc;Vn.NAME="BOOLEAN";var Pn=class extends wt(Qe){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=Qe.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===Vr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==ja)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,t,n),this.blockLength=n;return s}toBER(e,t){return this.isConstructed?Qe.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Pn.NAME="OctetStringValueBlock";var rc,Dn=class r extends ge{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Pn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,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),t;if(!this.valueBlock.isConstructed){let o=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(o.byteLength){let i=hs(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ot.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 e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return M.BufferSourceConverter.concat(e)}};rc=Dn;A.OctetString=rc;Dn.NAME=ja;var Mn=class extends wt(Qe){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let s=-1;if(this.isConstructed){if(s=Qe.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Vr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Za)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let u=a.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return s}let o=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=hs(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,t+n}toBER(e,t){if(this.isConstructed)return Qe.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;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}}};Mn.NAME="BitStringValueBlock";var nc,fr=class extends ge{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Mn),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ot.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let s of t)e.push(s.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};nc=fr;A.BitString=nc;fr.NAME=Za;var sc;function qh(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,u=0,l=c<i?i:c,f=0;for(let h=l;h>=0;h--,f++){switch(!0){case f<a.length:u=o[i-f]+a[c-f]+t[0];break;default:u=o[i-f]+t[0]}switch(t[0]=u/10,!0){case f>=o.length:o=In(new Uint8Array([u%10]),o);break;default:o[i-f]=u%10}}return t[0]>0&&(o=In(t,o)),o}function Wa(r){if(r>=_r.length)for(let e=_r.length;e<=r;e++){let t=new Uint8Array([0]),n=_r[e-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+t[0]]);t[0]=o[0]/10,n[s]=o[0]%10}t[0]>0&&(n=In(t,n)),_r.push(n)}return _r[r]}function $h(r,e){let t=0,n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,u,l=0;for(let f=c;f>=0;f--,l++)switch(u=o[i-l]-a[c-l]-t,!0){case u<0:t=1,o[i-l]=u+10;break;default:t=0,o[i-l]=u}if(t>0)for(let f=i-c+1;f>=0;f--,l++)if(u=o[i-l]-t,u<0)t=1,o[i-l]=u+10;else{t=0,o[i-l]=u;break}return o.slice()}var Pr=class extends wt(Ee){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}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=Xo.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array($a(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,s=0){let o=this.fromBER(e,t,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(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let s=super.fromBER(e,t,n);return s===-1||this.setValueHex(),s}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let u=0;u<8;u++){if((s&1)===1)switch(n){case e:t=$h(Wa(n),t),i="-";break;default:t=qh(t,Wa(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=Ga.charAt(t[c]));return a===!1&&(i+=Ga.charAt(0)),i}};sc=Pr;Pr.NAME="IntegerValueBlock";Object.defineProperty(sc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var oc,me=class r extends ge{constructor(e={}){super(e,Pr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return kn(),BigInt(this.valueBlock.toString())}static fromBigInt(e){kn();let t=BigInt(e),n=new Or,s=t.toString(16).replace(/^-/,""),o=new Uint8Array(M.Convert.FromHex(s));if(t<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let u=BigInt(`0x${M.Convert.ToHex(a)}`)+t,l=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(u.toString(16)));l[0]|=128,n.write(l)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}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()}`}};oc=me;A.Integer=oc;me.NAME="INTEGER";var ic,Hn=class extends me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};ic=Hn;A.Enumerated=ic;Hn.NAME="ENUMERATED";var Dr=class extends wt(Ee){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zt(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){kn();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(t.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)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 t=_t(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let e="";if(this.isHexOnly)e=M.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Dr.NAME="sidBlock";var Fn=class extends Ee{constructor({value:e=dr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new Dr;if(s=o.fromBER(e,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(e){let t=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(e);if(s.byteLength===0)return this.error=this.value[n].error,We;t.push(s)}return Qo(t)}fromString(e){this.value=[];let t=0,n=0,s="",o=!1;do if(n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1,o){let i=this.value[0],a=0;switch(i.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(s,10);if(isNaN(c))return;i.valueDec=c+a,o=!1}else{let i=new Dr;if(s>Number.MAX_SAFE_INTEGER){kn();let a=BigInt(s);i.valueBigInt=a}else if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,o=!0),this.value.push(i)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t?(s=`{${s}}`,this.value[n].isFirstSid?e=`2.{${s} - 80}`:e+=s):e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Fn.NAME="ObjectIdentifierValueBlock";var ac,hr=class extends ge{constructor(e={}){super(e,Fn),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};ac=hr;A.ObjectIdentifier=ac;hr.NAME="OBJECT IDENTIFIER";var Mr=class extends wt(gt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zt(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)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 t=_t(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let e="";return this.isHexOnly?e=M.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Mr.NAME="relativeSidBlock";var Kn=class extends Ee{constructor({value:e=dr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new Mr;if(s=o.fromBER(e,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(e,t){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(e);if(o.byteLength===0)return this.error=this.value[s].error,We;n.push(o)}return Qo(n)}fromString(e){this.value=[];let t=0,n=0,s="";do{n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1;let o=new Mr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(s=`{${s}}`),e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Kn.NAME="RelativeObjectIdentifierValueBlock";var cc,qn=class extends ge{constructor(e={}){super(e,Kn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};cc=qn;A.RelativeObjectIdentifier=cc;qn.NAME="RelativeObjectIdentifier";var lc,mt=class extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};lc=mt;A.Sequence=lc;mt.NAME="SEQUENCE";var uc,$n=class extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};uc=$n;A.Set=uc;$n.NAME="SET";var zn=class extends wt(Ee){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=dr}toJSON(){return{...super.toJSON(),value:this.value}}};zn.NAME="StringValueBlock";var Gn=class extends zn{};Gn.NAME="SimpleStringValueBlock";var Ie=class extends Tn{constructor({...e}={}){super(e,Gn)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}};Ie.NAME="SIMPLE STRING";var Wn=class extends Ie{fromBuffer(e){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=M.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Wn.NAME="Utf8StringValueBlock";var fc,yt=class extends Wn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};fc=yt;A.Utf8String=fc;yt.NAME="UTF8String";var jn=class extends Ie{fromBuffer(e){this.valueBlock.value=M.Convert.ToUtf16String(e),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(e))}};jn.NAME="BmpStringValueBlock";var hc,Zn=class extends jn{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};hc=Zn;A.BmpString=hc;Zn.NAME="BMPString";var Yn=class extends Ie{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);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(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let s=0;s<t;s++){let o=_t(e.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[s*4+c+a]=i[c]}this.valueBlock.value=e}};Yn.NAME="UniversalStringValueBlock";var dc,Jn=class extends Yn{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};dc=Jn;A.UniversalString=dc;Jn.NAME="UniversalString";var pc,Xn=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};pc=Xn;A.NumericString=pc;Xn.NAME="NumericString";var gc,Qn=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};gc=Qn;A.PrintableString=gc;Qn.NAME="PrintableString";var mc,es=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};mc=es;A.TeletexString=mc;es.NAME="TeletexString";var yc,ts=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};yc=ts;A.VideotexString=yc;ts.NAME="VideotexString";var bc,rs=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};bc=rs;A.IA5String=bc;rs.NAME="IA5String";var wc,ns=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};wc=ns;A.GraphicString=wc;ns.NAME="GraphicString";var xc,Hr=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};xc=Hr;A.VisibleString=xc;Hr.NAME="VisibleString";var vc,ss=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};vc=ss;A.GeneralString=vc;ss.NAME="GeneralString";var Ec,os=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Ec=os;A.CharacterString=Ec;os.NAME="CharacterString";var Bc,Fr=class extends Hr{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);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(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Ue(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ue(this.month,2),t[2]=Ue(this.day,2),t[3]=Ue(this.hour,2),t[4]=Ue(this.minute,2),t[5]=Ue(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}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}}};Bc=Fr;A.UTCTime=Bc;Fr.NAME="UTCTime";var Ac,is=class extends Fr{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",s="",o=0,i,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let f=new Number(e[e.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){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("+"),w="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(w=n.substring(h+1),n=n.substring(0,h),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(w.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*m,w.length===4){if(m=parseInt(w.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");c=f*m}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){let f=new Number(`0${n.substring(u)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");o=f.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,u!==-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,u!==-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,u!==-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,u!==-1){let f=1e3*o;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let l=i.exec(s);if(l===null)throw new Error("Wrong input string for conversion");for(let f=1;f<l.length;f++)switch(f){case 1:this.year=parseInt(l[f],10);break;case 2:this.month=parseInt(l[f],10);break;case 3:this.day=parseInt(l[f],10);break;case 4:this.hour=parseInt(l[f],10)+a;break;case 5:this.minute=parseInt(l[f],10)+c;break;case 6:this.second=parseInt(l[f],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!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(e="iso"){if(e==="iso"){let t=[];return t.push(Ue(this.year,4)),t.push(Ue(this.month,2)),t.push(Ue(this.day,2)),t.push(Ue(this.hour,2)),t.push(Ue(this.minute,2)),t.push(Ue(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ue(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Ac=is;A.GeneralizedTime=Ac;is.NAME="GeneralizedTime";var Sc,as=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Sc=as;A.DATE=Sc;as.NAME="DATE";var Ic,cs=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Ic=cs;A.TimeOfDay=Ic;cs.NAME="TimeOfDay";var kc,ls=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};kc=ls;A.DateTime=kc;ls.NAME="DateTime";var Nc,us=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Nc=us;A.Duration=Nc;us.NAME="Duration";var Cc,fs=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Cc=fs;A.TIME=Cc;fs.NAME="TIME";function F(r,e="utf8"){let t=vn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Kr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},ds=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Tc={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new ds("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 e}};var Vt=Tc;async function Uc(r){let e=await Vt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await Gh(e);return{privateKey:t[0],publicKey:t[1]}}async function Lc(r,e){let t=await Vt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Vt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Rc(r,e,t){let n=await Vt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Vt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function Gh(r){if(r.privateKey==null||r.publicKey==null)throw new Se("Private and public key are required");return Promise.all([Vt.get().subtle.exportKey("jwk",r.privateKey),Vt.get().subtle.exportKey("jwk",r.publicKey)])}function ri(r){if(r.kty!=="RSA")throw new Se("invalid key type");if(r.n==null)throw new Se("invalid key modulus");return q(r.n,"base64url").length*8}var pr=class{type="RSA";_key;_raw;_multihash;constructor(e,t){this._key=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return de.createV1(114,this._multihash)}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}verify(e,t){return Rc(this._key,t,e)}},$r=class{type="RSA";_key;_raw;publicKey;constructor(e,t){this._key=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}sign(e){return Lc(this._key,e)}};var ps=8192,ni=18;function _c(r){let{result:e}=ti(r),t=e.valueBlock.value;return{n:F(et(t[1].toBigInt()),"base64url"),e:F(et(t[2].toBigInt()),"base64url"),d:F(et(t[3].toBigInt()),"base64url"),p:F(et(t[4].toBigInt()),"base64url"),q:F(et(t[5].toBigInt()),"base64url"),dp:F(et(t[6].toBigInt()),"base64url"),dq:F(et(t[7].toBigInt()),"base64url"),qi:F(et(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Wh(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 Se("JWK was missing components");let t=new mt({value:[new me({value:0}),me.fromBigInt(tt(q(r.n,"base64url"))),me.fromBigInt(tt(q(r.e,"base64url"))),me.fromBigInt(tt(q(r.d,"base64url"))),me.fromBigInt(tt(q(r.p,"base64url"))),me.fromBigInt(tt(q(r.q,"base64url"))),me.fromBigInt(tt(q(r.dp,"base64url"))),me.fromBigInt(tt(q(r.dq,"base64url"))),me.fromBigInt(tt(q(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Oc(r){let{result:e}=ti(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:F(et(t[0].toBigInt()),"base64url"),e:F(et(t[1].toBigInt()),"base64url")}}function si(r){if(r.n==null||r.e==null)throw new Se("JWK was missing components");let t=new mt({value:[new mt({value:[new hr({value:"1.2.840.113549.1.1.1"}),new ur]}),new fr({valueHex:new mt({value:[me.fromBigInt(tt(q(r.n,"base64url"))),me.fromBigInt(tt(q(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function et(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),s=0,o=0;for(;s<t;)n[s]=parseInt(e.slice(o,o+2),16),s+=1,o+=2;return n}function tt(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function Vc(r){let e=_c(r);return Pc(e)}function oi(r){let e=Oc(r);if(ri(e)>ps)throw new Jt("Key size is too large");let t=cr(Xe.encode({Type:ae.RSA,Data:r})),n=Me(ni,t);return new pr(e,n)}function Pc(r){if(ri(r)>ps)throw new Se("Key size is too large");let e=Mc(r),t=cr(Xe.encode({Type:ae.RSA,Data:si(e.publicKey)})),n=Me(ni,t);return new $r(e.privateKey,new pr(e.publicKey,n))}async function Dc(r){if(r>ps)throw new Se("Key size is too large");let e=await Uc(r),t=cr(Xe.encode({Type:ae.RSA,Data:si(e.publicKey)})),n=Me(ni,t);return new $r(e.privateKey,new pr(e.publicKey,n))}function Mc(r){if(r==null)throw new Se("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var gs=class extends sr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ca(e);let n=Ir(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(e){return nr(this),this.iHash.update(e),this}digestInto(e){nr(this),rr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=o,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},ii=(r,e,t)=>new gs(r,e).update(t).digest();ii.create=(r,e)=>new gs(r,e);function Hc(r){r.lowS!==void 0&&Fe("lowS",r.lowS),r.prehash!==void 0&&Fe("prehash",r.prehash)}function jh(r){let e=Cr(r);Je(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Zh,hexToBytes:Yh}=hn,xt={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=xt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,s=Ft(n);if(s.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?Ft(s.length/2|128):"";return`${Ft(r)}${o}${s}${e}`},decode(r,e){let{Err:t}=xt,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let s=e[n++],o=!!(s&128),i=0;if(!o)i=s;else{let c=s&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+c);if(u.length!==c)throw new t("tlv.decode: length bytes not complete");if(u[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let l of u)i=i<<8|l;if(n+=c,i<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+i);if(a.length!==i)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+i)}}},_int:{encode(r){let{Err:e}=xt;if(r<vt)throw new e("integer: negative integers are not allowed");let t=Ft(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected assertion");return t},decode(r){let{Err:e}=xt;if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return Zh(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=xt,s=typeof r=="string"?Yh(r):r;ir(s);let{v:o,l:i}=n.decode(48,s);if(i.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:u,l}=n.decode(2,c);if(l.length)throw new e("Invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(u)}},hexFromSig(r){let{_tlv:e,_int:t}=xt,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},vt=BigInt(0),fe=BigInt(1),ym=BigInt(2),Fc=BigInt(3),bm=BigInt(4);function Jh(r){let e=jh(r),{Fp:t}=e,n=Ct(e.n,e.nBitLength),s=e.toBytes||((y,d,x)=>{let B=d.toAffine();return ht(Uint8Array.from([4]),t.toBytes(B.x),t.toBytes(B.y))}),o=e.fromBytes||(y=>{let d=y.subarray(1),x=t.fromBytes(d.subarray(0,t.BYTES)),B=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x,y:B}});function i(y){let{a:d,b:x}=e,B=t.sqr(y),g=t.mul(B,y);return t.add(t.add(g,t.mul(y,d)),x)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return kr(y,fe,e.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:x,wrapPrivateKey:B,n:g}=e;if(d&&typeof y!="bigint"){if(It(y)&&(y=ut(y)),typeof y!="string"||!d.includes(y.length))throw new Error("Invalid key");y=y.padStart(x*2,"0")}let S;try{S=typeof y=="bigint"?y:ft(te("private key",y,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof y}`)}return B&&(S=j(S,g)),Ne("private key",S,fe,g),S}function u(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let l=$t((y,d)=>{let{px:x,py:B,pz:g}=y;if(t.eql(g,t.ONE))return{x,y:B};let S=y.is0();d==null&&(d=S?t.ONE:t.inv(g));let L=t.mul(x,d),U=t.mul(B,d),I=t.mul(g,d);if(S)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:L,y:U}}),f=$t(y=>{if(y.is0()){if(e.allowInfinityPoint&&!t.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=y.toAffine();if(!t.isValid(d)||!t.isValid(x))throw new Error("bad point: x or y not FE");let B=t.sqr(x),g=i(d);if(!t.eql(B,g))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,x,B){if(this.px=d,this.py=x,this.pz=B,d==null||!t.isValid(d))throw new Error("x required");if(x==null||!t.isValid(x))throw new Error("y required");if(B==null||!t.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x,y:B}=d||{};if(!d||!t.isValid(x)||!t.isValid(B))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let g=S=>t.eql(S,t.ZERO);return g(x)&&g(B)?h.ZERO:new h(x,B,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let x=t.invertBatch(d.map(B=>B.pz));return d.map((B,g)=>B.toAffine(x[g])).map(h.fromAffine)}static fromHex(d){let x=h.fromAffine(o(te("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,x){return gn(h,n,d,x)}_setWindowSize(d){m.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){u(d);let{px:x,py:B,pz:g}=this,{px:S,py:L,pz:U}=d,I=t.eql(t.mul(x,U),t.mul(S,g)),k=t.eql(t.mul(B,U),t.mul(L,g));return I&&k}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:x}=e,B=t.mul(x,Fc),{px:g,py:S,pz:L}=this,U=t.ZERO,I=t.ZERO,k=t.ZERO,T=t.mul(g,g),ne=t.mul(S,S),K=t.mul(L,L),V=t.mul(g,S);return V=t.add(V,V),k=t.mul(g,L),k=t.add(k,k),U=t.mul(d,k),I=t.mul(B,K),I=t.add(U,I),U=t.sub(ne,I),I=t.add(ne,I),I=t.mul(U,I),U=t.mul(V,U),k=t.mul(B,k),K=t.mul(d,K),V=t.sub(T,K),V=t.mul(d,V),V=t.add(V,k),k=t.add(T,T),T=t.add(k,T),T=t.add(T,K),T=t.mul(T,V),I=t.add(I,T),K=t.mul(S,L),K=t.add(K,K),T=t.mul(K,V),U=t.sub(U,T),k=t.mul(K,ne),k=t.add(k,k),k=t.add(k,k),new h(U,I,k)}add(d){u(d);let{px:x,py:B,pz:g}=this,{px:S,py:L,pz:U}=d,I=t.ZERO,k=t.ZERO,T=t.ZERO,ne=e.a,K=t.mul(e.b,Fc),V=t.mul(x,S),se=t.mul(B,L),E=t.mul(g,U),N=t.add(x,B),b=t.add(S,L);N=t.mul(N,b),b=t.add(V,se),N=t.sub(N,b),b=t.add(x,g);let p=t.add(S,U);return b=t.mul(b,p),p=t.add(V,E),b=t.sub(b,p),p=t.add(B,g),I=t.add(L,U),p=t.mul(p,I),I=t.add(se,E),p=t.sub(p,I),T=t.mul(ne,b),I=t.mul(K,E),T=t.add(I,T),I=t.sub(se,T),T=t.add(se,T),k=t.mul(I,T),se=t.add(V,V),se=t.add(se,V),E=t.mul(ne,E),b=t.mul(K,b),se=t.add(se,E),E=t.sub(V,E),E=t.mul(ne,E),b=t.add(b,E),V=t.mul(se,b),k=t.add(k,V),V=t.mul(p,b),I=t.mul(N,I),I=t.sub(I,V),V=t.mul(N,se),T=t.mul(p,T),T=t.add(T,V),new h(I,k,T)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return m.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Ne("scalar",d,vt,e.n);let x=h.ZERO;if(d===vt)return x;if(d===fe)return this;let{endo:B}=e;if(!B)return m.unsafeLadder(this,d);let{k1neg:g,k1:S,k2neg:L,k2:U}=B.splitScalar(d),I=x,k=x,T=this;for(;S>vt||U>vt;)S&fe&&(I=I.add(T)),U&fe&&(k=k.add(T)),T=T.double(),S>>=fe,U>>=fe;return g&&(I=I.negate()),L&&(k=k.negate()),k=new h(t.mul(k.px,B.beta),k.py,k.pz),I.add(k)}multiply(d){let{endo:x,n:B}=e;Ne("scalar",d,fe,B);let g,S;if(x){let{k1neg:L,k1:U,k2neg:I,k2:k}=x.splitScalar(d),{p:T,f:ne}=this.wNAF(U),{p:K,f:V}=this.wNAF(k);T=m.constTimeNegate(L,T),K=m.constTimeNegate(I,K),K=new h(t.mul(K.px,x.beta),K.py,K.pz),g=T.add(K),S=ne.add(V)}else{let{p:L,f:U}=this.wNAF(d);g=L,S=U}return h.normalizeZ([g,S])[0]}multiplyAndAddUnsafe(d,x,B){let g=h.BASE,S=(U,I)=>I===vt||I===fe||!U.equals(g)?U.multiplyUnsafe(I):U.multiply(I),L=S(this,x).add(S(d,B));return L.is0()?void 0:L}toAffine(d){return l(this,d)}isTorsionFree(){let{h:d,isTorsionFree:x}=e;if(d===fe)return!0;if(x)return x(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:x}=e;return d===fe?this:x?x(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Fe("isCompressed",d),this.assertValidity(),s(h,this,d)}toHex(d=!0){return Fe("isCompressed",d),ut(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let w=e.nBitLength,m=pn(h,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:a}}function Xh(r){let e=Cr(r);return Je(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Kc(r){let e=Xh(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(E){return j(E,n)}function a(E){return dn(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:f}=Jh({...e,toBytes(E,N,b){let p=N.toAffine(),v=t.toBytes(p.x),C=ht;return Fe("isCompressed",b),b?C(Uint8Array.from([N.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,t.toBytes(p.y))},fromBytes(E){let N=E.length,b=E[0],p=E.subarray(1);if(N===s&&(b===2||b===3)){let v=ft(p);if(!kr(v,fe,t.ORDER))throw new Error("Point is not on curve");let C=l(v),R;try{R=t.sqrt(C)}catch(H){let D=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+D)}let _=(R&fe)===fe;return(b&1)===1!==_&&(R=t.neg(R)),{x:v,y:R}}else if(N===o&&b===4){let v=t.fromBytes(p.subarray(0,t.BYTES)),C=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:v,y:C}}else throw new Error(`Point of length ${N} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),h=E=>ut(Nt(E,e.nByteLength));function w(E){let N=n>>fe;return E>N}function m(E){return w(E)?i(-E):E}let y=(E,N,b)=>ft(E.slice(N,b));class d{constructor(N,b,p){this.r=N,this.s=b,this.recovery=p,this.assertValidity()}static fromCompact(N){let b=e.nByteLength;return N=te("compactSignature",N,b*2),new d(y(N,0,b),y(N,b,2*b))}static fromDER(N){let{r:b,s:p}=xt.toSig(te("DER",N));return new d(b,p)}assertValidity(){Ne("r",this.r,fe,n),Ne("s",this.s,fe,n)}addRecoveryBit(N){return new d(this.r,this.s,N)}recoverPublicKey(N){let{r:b,s:p,recovery:v}=this,C=U(te("msgHash",N));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let R=v===2||v===3?b+e.n:b;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=v&1?"03":"02",P=c.fromHex(_+h(R)),H=a(R),D=i(-C*H),W=i(p*H),Y=c.BASE.multiplyAndAddUnsafe(P,D,W);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Kt(this.toDERHex())}toDERHex(){return xt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Kt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let x={isValidPrivateKey(E){try{return u(E),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let E=uo(e.n);return va(e.randomBytes(E),e.n)},precompute(E=8,N=c.BASE){return N._setWindowSize(E),N.multiply(BigInt(3)),N}};function B(E,N=!0){return c.fromPrivateKey(E).toRawBytes(N)}function g(E){let N=It(E),b=typeof E=="string",p=(N||b)&&E.length;return N?p===s||p===o:b?p===2*s||p===2*o:E instanceof c}function S(E,N,b=!0){if(g(E))throw new Error("first arg must be private key");if(!g(N))throw new Error("second arg must be public key");return c.fromHex(N).multiply(u(E)).toRawBytes(b)}let L=e.bits2int||function(E){let N=ft(E),b=E.length*8-e.nBitLength;return b>0?N>>BigInt(b):N},U=e.bits2int_modN||function(E){return i(L(E))},I=Nr(e.nBitLength);function k(E){return Ne(`num < 2^${e.nBitLength}`,E,vt,I),Nt(E,e.nByteLength)}function T(E,N,b=ne){if(["recovered","canonical"].some(ue=>ue in b))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:v}=e,{lowS:C,prehash:R,extraEntropy:_}=b;C==null&&(C=!0),E=te("msgHash",E),Hc(b),R&&(E=te("prehashed msgHash",p(E)));let P=U(E),H=u(N),D=[k(H),k(P)];if(_!=null&&_!==!1){let ue=_===!0?v(t.BYTES):_;D.push(te("extraEntropy",ue))}let W=ht(...D),Y=P;function le(ue){let he=L(ue);if(!f(he))return;let Be=a(he),oe=c.BASE.multiply(he).toAffine(),ke=i(oe.x);if(ke===vt)return;let ot=i(Be*i(Y+ke*H));if(ot===vt)return;let xr=(oe.x===ke?0:2)|Number(oe.y&fe),vr=ot;return C&&w(ot)&&(vr=m(ot),xr^=1),new d(ke,vr,xr)}return{seed:W,k2sig:le}}let ne={lowS:e.lowS,prehash:!1},K={lowS:e.lowS,prehash:!1};function V(E,N,b=ne){let{seed:p,k2sig:v}=T(E,N,b),C=e;return io(C.hash.outputLen,C.nByteLength,C.hmac)(p,v)}c.BASE._setWindowSize(8);function se(E,N,b,p=K){let v=E;if(N=te("msgHash",N),b=te("publicKey",b),"strict"in p)throw new Error("options.strict was renamed to lowS");Hc(p);let{lowS:C,prehash:R}=p,_,P;try{if(typeof v=="string"||It(v))try{_=d.fromDER(v)}catch(oe){if(!(oe instanceof xt.Err))throw oe;_=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:oe,s:ke}=v;_=new d(oe,ke)}else throw new Error("PARSE");P=c.fromHex(b)}catch(oe){if(oe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&_.hasHighS())return!1;R&&(N=e.hash(N));let{r:H,s:D}=_,W=U(N),Y=a(D),le=i(W*Y),ue=i(H*Y),he=c.BASE.multiplyAndAddUnsafe(P,le,ue)?.toAffine();return he?i(he.x)===H:!1}return{CURVE:e,getPublicKey:B,getSharedSecret:S,sign:V,verify:se,ProjectivePoint:c,Signature:d,utils:x}}function Qh(r){return{hash:r,hmac:(e,...t)=>ii(r,e,Xs(...t)),randomBytes:ln}}function qc(r,e){let t=n=>Kc({...r,...Qh(n)});return Object.freeze({...t(e),create:t})}var Gc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$c=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ed=BigInt(1),ai=BigInt(2),zc=(r,e)=>(r+e/ai)/e;function td(r){let e=Gc,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=r*r*r%e,l=u*u*r%e,f=Q(l,t,e)*l%e,h=Q(f,t,e)*l%e,w=Q(h,ai,e)*u%e,m=Q(w,s,e)*w%e,y=Q(m,o,e)*m%e,d=Q(y,a,e)*y%e,x=Q(d,c,e)*d%e,B=Q(x,a,e)*y%e,g=Q(B,t,e)*l%e,S=Q(g,i,e)*m%e,L=Q(S,n,e)*u%e,U=Q(L,ai,e);if(!ci.eql(ci.sqr(U),r))throw new Error("Cannot find square root");return U}var ci=Ct(Gc,void 0,void 0,{sqrt:td}),Yt=qc({a:BigInt(0),b:BigInt(7),Fp:ci,n:$c,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=$c,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ed*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=zc(o*r,e),c=zc(-n*r,e),u=j(r-a*t-c*s,e),l=j(-a*n-c*o,e),f=u>i,h=l>i;if(f&&(u=e-u),h&&(l=e-l),u>i||l>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:u,k2neg:h,k2:l}}}},cr),km=BigInt(0);var Nm=Yt.ProjectivePoint;function _e(r,e){e==null&&(e=r.reduce((s,o)=>s+o.length,0));let t=Te(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return t}function Wc(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function jc(r,e,t){let n=Tr.digest(t instanceof Uint8Array?t:t.subarray());if(Wc(n))return n.then(({digest:s})=>Yt.verify(e,s,r)).catch(s=>{throw new Kr(String(s))});try{return Yt.verify(e,n.digest,r)}catch(s){throw new Kr(String(s))}}var ms=class{type="secp256k1";raw;_key;constructor(e){this._key=Yc(e),this.raw=Zc(this._key)}toMultihash(){return ct.digest(Tt(this))}toCID(){return de.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}verify(e,t){return jc(this._key,t,e)}};function li(r){return new ms(r)}function Zc(r){return Yt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Yc(r){try{return Yt.ProjectivePoint.fromHex(r),r}catch(e){throw new Jt(String(e))}}function gr(r){let{Type:e,Data:t}=Xe.decode(r),n=t??new Uint8Array;switch(e){case ae.RSA:return oi(n);case ae.Ed25519:return mo(n);case ae.secp256k1:return li(n);default:throw new Dt}}function Jc(r){let{Type:e,Data:t}=Xe.decode(r.digest),n=t??new Uint8Array;switch(e){case ae.Ed25519:return mo(n);case ae.secp256k1:return li(n);default:throw new Dt}}function Tt(r){return Xe.encode({Type:ae[r.type],Data:r.raw})}var Qc=Symbol.for("@achingbrain/uint8arraylist");function Xc(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let s=t+n.byteLength;if(e<s)return{buf:n,index:e-t};t=s}throw new RangeError("index is out of bounds")}function ys(r){return!!r?.[Qc]}var je=class r{bufs;length;[Qc]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(ys(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(ys(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=Xc(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Xc(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(ys(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:s}=this._subList(e,t);return _e(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:_e(n,s)}sublist(e,t){let{bufs:n,length:s}=this._subList(e,t),o=new r;return o.length=s,o.bufs=[...n],o}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let o=0;o<this.bufs.length;o++){let i=this.bufs[o],a=s,c=a+i.byteLength;if(s=c,e>=c)continue;let u=e>=a&&e<c,l=t>a&&t<=c;if(u&&l){if(e===a&&t===c){n.push(i);break}let f=e-a;n.push(i.subarray(f,f+(t-e)));break}if(u){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(l){if(t===c){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!ys(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;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 a=i,c=this.byteLength-n.byteLength,u=n.byteLength-1,l;for(let f=t;f<=c;f+=l){l=0;for(let h=u;h>=0;h--){let w=this.get(f+h);if(n[h]!==w){l=Math.max(1,h-a[w]);break}}if(l===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Te(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let s=pe(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,t,n),this.write(s,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let s=pe(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,t,n),this.write(s,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let s=pe(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,t,n),this.write(s,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Te(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let s=pe(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,t,n),this.write(s,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let s=pe(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,t,n),this.write(s,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let s=pe(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,t,n),this.write(s,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let s=pe(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,t,n),this.write(s,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let s=pe(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,t,n),this.write(s,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!be(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((s,o)=>s+o.byteLength,0)),n.length=t,n}};var zr;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.publicKey!=null&&t.publicKey.byteLength>0&&(n.uint32(10),n.bytes(t.publicKey)),t.payloadType!=null&&t.payloadType.byteLength>0&&(n.uint32(18),n.bytes(t.payloadType)),t.payload!=null&&t.payload.byteLength>0&&(n.uint32(26),n.bytes(t.payload)),t.signature!=null&&t.signature.byteLength>0&&(n.uint32(42),n.bytes(t.signature)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={publicKey:pe(0),payloadType:pe(0),payload:pe(0),signature:pe(0)},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 1:{o.publicKey=t.bytes();break}case 2:{o.payloadType=t.bytes();break}case 3:{o.payload=t.bytes();break}case 5:{o.signature=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(zr||(zr={}));var bs=class extends Error{constructor(e="Invalid signature"){super(e),this.name="InvalidSignatureError"}};var rt=class r{static createFromProtobuf=async e=>{let t=zr.decode(e),n=gr(t.publicKey);return new r({publicKey:n,payloadType:t.payloadType,payload:t.payload,signature:t.signature})};static seal=async(e,t)=>{if(t==null)throw new Error("Missing private key");let n=e.domain,s=e.codec,o=e.marshal(),i=el(n,s,o),a=await t.sign(i.subarray());return new r({publicKey:t.publicKey,payloadType:s,payload:o,signature:a})};static openAndCertify=async(e,t)=>{let n=await r.createFromProtobuf(e);if(!await n.validate(t))throw new bs("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(e){let{publicKey:t,payloadType:n,payload:s,signature:o}=e;this.publicKey=t,this.payloadType=n,this.payload=s,this.signature=o}marshal(){return this.marshaled==null&&(this.marshaled=zr.encode({publicKey:Tt(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return be(this.marshal(),e.marshal())}async validate(e){let t=el(e,this.payloadType,this.payload);return this.publicKey.verify(t.subarray(),this.signature)}},el=(r,e,t)=>{let n=q(r),s=Oe(n.byteLength),o=Oe(e.length),i=Oe(t.length);return new je(s,n,o,e,i,t)};var tl=Symbol.for("nodejs.util.inspect.custom"),rd=114,Gr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Ks]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return de.createV1(rd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return be(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return be(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[tl](){return`PeerId(${this.toString()})`}},Wr=class extends Gr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},jr=class extends Gr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Zr=class extends Gr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},nd=2336,Yr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ct.digest(q(this.url))}[tl](){return`PeerId(${this.url})`}[Ks]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return de.createV1(nd,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=F(e)),e.toString()===this.toString())}};var sd=114,rl=2336;function nl(r){if(r.type==="Ed25519")return new jr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Zr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Wr({multihash:r.toCID().multihash,publicKey:r});throw new Dt}function ui(r){if(id(r))return new Wr({multihash:r});if(od(r))try{let e=Jc(r);if(e.type==="Ed25519")return new jr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Zr({multihash:r,publicKey:e})}catch{let t=F(r.digest);return new Yr(new URL(t))}throw new nn("Supplied PeerID Multihash is invalid")}function ws(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==sd&&r.code!==rl)throw new rn("Supplied PeerID CID is invalid");if(r.code===rl){let e=F(r.multihash.digest);return new Yr(new URL(e))}return ui(r.multihash)}function od(r){return r.code===ct.code}function id(r){return r.code===Tr.code}function sl(r,e){let t=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==e.length?!1:(e.sort(t),r.sort(t).every((n,s)=>e[s].equals(n)))}var xs=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*s)-1;for(;;){let l=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,e);if(!Number.isNaN(h))return h});if(l===void 0)break;if(o*=e,o+=l,o>u||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let s=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[s]=i[0],t[s+1]=i[1],t[s+2]=i[2],t[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];t[s]=o>>8,t[s+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,s]=e(t);if(n===16)return t;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=e(o.subarray(0,i));return t.set(o.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ol=45,ad=15,mr=new xs;function fi(r){if(!(r.length>ad))return mr.new(r).parseWith(()=>mr.readIPv4Addr())}function hi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ol))return mr.new(r).parseWith(()=>mr.readIPv6Addr())}function vs(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ol))return mr.new(r).parseWith(()=>mr.readIPAddr())}var ob=parseInt("0xFFFF",16),ib=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function Es(r){return!!fi(r)}function Bs(r){return!!hi(r)}function As(r){return!!vs(r)}var cl=Es,hd=Bs,di=function(r){let e=0;if(r=r.toString().trim(),cl(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(hd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=cl(t[n]),i;o&&(i=di(t[n]),t[n]=F(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,F(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let s=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);s[e++]=o>>8&255,s[e++]=o&255}return s}throw new Error("invalid ip address")},ll=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let s=[];for(let o=0;o<t;o++)s.push(r[e+o]);return s.join(".")}if(t===16){let s=[];for(let o=0;o<t;o+=2)s.push(n.getUint16(e+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var yr={},pi={},pd=[[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"]];pd.forEach(r=>{let e=gd(...r);pi[e.code]=e,yr[e.name]=e});function gd(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function $(r){if(typeof r=="number"){if(pi[r]!=null)return pi[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(yr[r]!=null)return yr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var qb=$("ip4"),$b=$("ip6"),zb=$("ipcidr");function bi(r,e){switch($(r).code){case 4:case 41:return yd(e);case 42:return yi(e);case 6:case 273:case 33:case 132:return hl(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return yi(e);case 421:return vd(e);case 444:return fl(e);case 445:return fl(e);case 466:return xd(e);case 481:return globalThis.encodeURIComponent(yi(e));default:return F(e,"base16")}}function wi(r,e){switch($(r).code){case 4:return ul(e);case 41:return ul(e);case 42:return mi(e);case 6:case 273:case 33:case 132:return xi(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return mi(e);case 421:return bd(e);case 444:return Ed(e);case 445:return Bd(e);case 466:return wd(e);case 481:return mi(globalThis.decodeURIComponent(e));default:return q(e,"base16")}}var gi=Object.values(Ur).map(r=>r.decoder),md=function(){let r=gi[0].or(gi[1]);return gi.slice(2).forEach(e=>r=r.or(e)),r}();function ul(r){if(!As(r))throw new Error("invalid ip address");return di(r)}function yd(r){let e=ll(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!As(e))throw new Error("invalid ip address");return e}function xi(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function hl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function mi(r){let e=q(r),t=Uint8Array.from(Oe(e.length));return _e([t,e],t.length+e.length)}function yi(r){let e=dt(r);if(r=r.slice(xe(e)),r.length!==e)throw new Error("inconsistent lengths");return F(r)}function bd(r){let e;r[0]==="Q"||r[0]==="1"?e=Mt(J.decode(`z${r}`)).bytes:e=de.parse(r).multihash.bytes;let t=Uint8Array.from(Oe(e.length));return _e([t,e],t.length+e.length)}function wd(r){let e=md.decode(r),t=Uint8Array.from(Oe(e.length));return _e([t,e],t.length+e.length)}function xd(r){let e=dt(r),t=r.slice(xe(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+F(t,"base64url")}function vd(r){let e=dt(r),t=r.slice(xe(e));if(t.length!==e)throw new Error("inconsistent lengths");return F(t,"base58btc")}function Ed(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=at.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=xi(n);return _e([t,s],t.length+s.length)}function Bd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=at.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=xi(n);return _e([t,s],t.length+s.length)}function fl(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=F(e,"base32"),s=hl(t);return`${n}:${s}`}function dl(r){r=vi(r);let e=[],t=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<s.length;o++){let i=s[o],a=$(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=s.length)throw gl("invalid address: "+r);if(a.path===!0){n=vi(s.slice(o).join("/")),e.push([a.code,wi(a.code,n)]),t.push([a.code,n]);break}let c=wi(a.code,s[o]);e.push([a.code,c]),t.push([a.code,bi(a.code,c)])}return{string:pl(t),bytes:Bi(e),tuples:e,stringTuples:t,path:n}}function Ei(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let o=dt(r,s),i=xe(o),a=$(o),c=Ad(a,r.slice(s+i));if(c===0){e.push([o]),t.push([o]),s+=i;continue}let u=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw gl("Invalid address Uint8Array: "+F(r,"base16"));e.push([o,u]);let l=bi(o,u);if(t.push([o,l]),a.path===!0){n=l;break}}return{bytes:Uint8Array.from(r),string:pl(t),tuples:e,stringTuples:t,path:n}}function pl(r){let e=[];return r.map(t=>{let n=$(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),vi(e.join("/"))}function Bi(r){return _e(r.map(e=>{let t=$(e[0]),n=Uint8Array.from(Oe(t.code));return e.length>1&&e[1]!=null&&(n=_e([n,e[1]])),n}))}function Ad(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=dt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+xe(t)}}function vi(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function gl(r){return new Error("Error parsing address: "+r)}var Sd=Symbol.for("nodejs.util.inspect.custom"),Ai=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Id=[$("dns").code,$("dns4").code,$("dns6").code,$("dnsaddr").code],Ss=class r{bytes;#t;#e;#r;#n;[Ai]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=Ei(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=dl(e)}else if(yl(e))t=Ei(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#t=t.string,this.#e=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,s,o="",i=$("tcp"),a=$("udp"),c=$("ip4"),u=$("ip6"),l=$("dns6"),f=$("ip6zone");for(let[w,m]of this.stringTuples())w===f.code&&(o=`%${m??""}`),Id.includes(w)&&(t=i.name,s=443,n=`${m??""}${o}`,e=w===l.code?6:4),(w===i.code||w===a.code)&&(t=$(w).name,s=parseInt(m??"")),(w===c.code||w===u.code)&&(t=$(w).name,n=`${m??""}${o}`,e=w===u.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:s}}protos(){return this.#e.map(([e])=>Object.assign({},$(e)))}protoCodes(){return this.#e.map(([e])=>e)}protoNames(){return this.#e.map(([e])=>$(e).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),s=n.lastIndexOf(t);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,s))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Bi(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,s])=>{n===yr.p2p.code&&e.push([n,s]),n===yr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?F(J.decode(`z${n}`),"base58btc"):F(de.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return be(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=ml.get(t.name);if(n==null)throw new tn(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await n(this,e)).map(o=>nt(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[Sd](){return`Multiaddr(${this.#t})`}};var ml=new Map;function yl(r){return!!r?.[Ai]}function nt(r){return new Ss(r)}var bl="libp2p-peer-record",wl=Uint8Array.from([3,1]);var Jr;(function(r){let e;(function(n){let s;n.codec=()=>(s==null&&(s=Ge((o,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(o.multiaddr)),a.lengthDelimited!==!1&&i.ldelim()},(o,i,a={})=>{let c={multiaddr:pe(0)},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:{c.multiaddr=o.bytes();break}default:{o.skipType(l&7);break}}}return c})),s),n.encode=o=>ze(o,n.codec()),n.decode=(o,i)=>$e(o,n.codec(),i)})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=Ge((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:pe(0),seq:0n,addresses:[]},a=s==null?n.len:n.pos+s;for(;n.pos<a;){let c=n.uint32();switch(c>>>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 jt('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(c&7);break}}}return i})),t),r.encode=n=>ze(n,r.codec()),r.decode=(n,s)=>$e(n,r.codec(),s)})(Jr||(Jr={}));var Ze=class r{static createFromProtobuf=e=>{let t=Jr.decode(e),n=ui(Mt(t.peerId)),s=(t.addresses??[]).map(i=>nt(i.multiaddr)),o=t.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=bl;static CODEC=wl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(e){let{peerId:t,multiaddrs:n,seqNumber:s}=e;this.peerId=t,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=Jr.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))})),this.marshaled}equals(e){return!(!(e instanceof r)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!sl(this.multiaddrs,e.multiaddrs))}};function kd(r){return r[Symbol.asyncIterator]!=null}function Nd(r){if(kd(r))return(async()=>{for await(let e of r);})();for(let e of r);}var xl=Nd;function Ye(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Is=globalThis.CustomEvent??Event;async function*Si(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,s=new EventTarget,o=[],i=Ye(),a=Ye(),c=!1,u,l=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(o.length===t&&(i=Ye(),await i.promise),l)break;let y={done:!1};o.push(y),m().then(d=>{y.done=!0,y.ok=!0,y.value=d,s.dispatchEvent(new Is("task-complete"))},d=>{y.done=!0,y.err=d,s.dispatchEvent(new Is("task-complete"))})}c=!0,s.dispatchEvent(new Is("task-complete"))}catch(m){u=m,s.dispatchEvent(new Is("task-complete"))}});function f(){return n?o[0]?.done:!!o.find(m=>m.done)}function*h(){for(;o.length>0&&o[0].done;){let m=o[0];if(o.shift(),m.ok)yield m.value;else throw l=!0,i.resolve(),m.err;i.resolve()}}function*w(){for(;f();)for(let m=0;m<o.length;m++)if(o[m].done){let y=o[m];if(o.splice(m,1),m--,y.ok)yield y.value;else throw l=!0,i.resolve(),y.err;i.resolve()}}for(;;){if(f()||(a=Ye(),await a.promise),u!=null)throw u;if(n?yield*h():yield*w(),c&&o.length===0)break}}var ks=class extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}};async function vl(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new ks(t?.errorMessage,t?.errorCode,t?.errorName));let n,s=new ks(t?.errorMessage,t?.errorCode,t?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var Ii=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Ye(),this.haveNext=Ye()}[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 e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Ye(),e}async throw(e){return this.ended=!0,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Ye(),await vl(this.readNext.promise,t?.signal,t)}};function El(){return new Ii}var Ns=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var ki=class extends Error{code;constructor(e,t){super(e),this.code=t}},Ni=class extends ki{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Bl(r,e){let t=El();r.sink(t).catch(async i=>{await t.end(i)}),r.sink=async i=>{for await(let a of i)await t.push(a);await t.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 je;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,u=new Promise((l,f)=>{c=()=>{f(new Ni("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:f,value:h}=await Promise.race([n.next(),u]);return f===!0?new je:h}for(;s.byteLength<i;){let{value:f,done:h}=await Promise.race([n.next(),u]);if(h===!0)throw new Ns("unexpected end of input");s.append(f)}let l=s.sublist(0,i);return s.consume(i),l}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await t.push(i,a):await t.push(i.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){e?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var Cs=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Ts=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Us=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Al(r,e={}){let t=Bl(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=xe(e.maxDataLength));let n=e?.lengthDecoder??dt,s=e?.lengthEncoder??Oe;return{read:async i=>{let a=-1,c=new je;for(;;){c.append(await t.read(1,i));try{a=n(c)}catch(u){if(u instanceof RangeError)continue;throw u}if(a<0)throw new Cs("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new Us("message length length too long");if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Ts("message length too long");return t.read(a,i)},write:async(i,a)=>{await t.write(new je(s(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new je(...i.flatMap(u=>[s(u.byteLength),u]));await t.write(c,a)},unwrap:()=>t.unwrap()}}function br(r,e){let t=Al(r,e),n={read:async(s,o)=>{let i=await t.read(o);return s.decode(i)},write:async(s,o,i)=>{await t.write(o.encode(s),i)},writeV:async(s,o,i)=>{await t.writeV(s.map(a=>o.encode(a)),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:()=>t.unwrap()};return n}var Sl="0.1.0",Il="id",kl="id/push",Nl="1.0.0",Cl="1.0.0";var Pt;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.protocolVersion!=null&&(n.uint32(42),n.string(t.protocolVersion)),t.agentVersion!=null&&(n.uint32(50),n.string(t.agentVersion)),t.publicKey!=null&&(n.uint32(10),n.bytes(t.publicKey)),t.listenAddrs!=null)for(let o of t.listenAddrs)n.uint32(18),n.bytes(o);if(t.observedAddr!=null&&(n.uint32(34),n.bytes(t.observedAddr)),t.protocols!=null)for(let o of t.protocols)n.uint32(26),n.string(o);t.signedPeerRecord!=null&&(n.uint32(66),n.bytes(t.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={listenAddrs:[],protocols:[]},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 5:{o.protocolVersion=t.string();break}case 6:{o.agentVersion=t.string();break}case 1:{o.publicKey=t.bytes();break}case 2:{if(s.limits?.listenAddrs!=null&&o.listenAddrs.length===s.limits.listenAddrs)throw new jt('Decode error - map field "listenAddrs" had too many elements');o.listenAddrs.push(t.bytes());break}case 4:{o.observedAddr=t.bytes();break}case 3:{if(s.limits?.protocols!=null&&o.protocols.length===s.limits.protocols)throw new jt('Decode error - map field "protocols" had too many elements');o.protocols.push(t.string());break}case 8:{o.signedPeerRecord=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(Pt||(Pt={}));var Ll=zi(Ul(),1),Ci=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Ls=(0,Ll.default)(),Rl=Ci&&!Ls,_l=Ls&&!Ci,Ol=Ls&&Ci,Vl=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Ls,Pl=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Qw=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",Dl=typeof navigator<"u"&&navigator.product==="ReactNative";var Le={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function Ml(r){if(r!=null&&r.length>0)try{return nt(r)}catch{}}function Ld(r,e){return e!=null||(e=`${r.name}/${r.version}`,Vl||_l?e+=` UserAgent=${globalThis.process.version}`:(Rl||Pl||Ol||Dl)&&(e+=` UserAgent=${globalThis.navigator.userAgent}`)),e}async function Rs(r,e,t,n,s){if(t("received identify from %p",n.remotePeer),s==null)throw new De("message was null or undefined");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(c=>({isCertified:!1,multiaddr:nt(c)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null){let c=gr(s.publicKey);if(!nl(c).equals(n.remotePeer))throw new De("public key did not match remote PeerId");o.publicKey=c}let i;if(s.signedPeerRecord!=null){t("received signedPeerRecord from %p",n.remotePeer);let c=s.signedPeerRecord,u=await rt.openAndCertify(c,Ze.DOMAIN),l=Ze.createFromProtobuf(u.payload),f=ws(u.publicKey.toCID());if(!l.peerId.equals(f))throw new De("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(l.peerId))throw new De("signing key does not match remote PeerId");let h;try{h=await r.get(l.peerId)}catch(w){if(w.name!=="NotFoundError")throw w}if(h!=null&&(o.metadata=h.metadata,h.peerRecordEnvelope!=null)){let w=await rt.createFromProtobuf(h.peerRecordEnvelope),m=Ze.createFromProtobuf(w.payload);m.seqNumber>=l.seqNumber&&(t("sequence number was lower or equal to existing sequence number - stored: %d received: %d",m.seqNumber,l.seqNumber),l=m,c=h.peerRecordEnvelope)}o.peerRecordEnvelope=c,o.addresses=l.multiaddrs.map(w=>({isCertified:!0,multiaddr:w})),i={seq:l.seqNumber,addresses:l.multiaddrs}}else t("%p did not send a signed peer record",n.remotePeer);if(t("patching %p with",n.remotePeer,o),await r.patch(n.remotePeer,o),s.agentVersion!=null||s.protocolVersion!=null){let c={};s.agentVersion!=null&&(c.AgentVersion=q(s.agentVersion)),s.protocolVersion!=null&&(c.ProtocolVersion=q(s.protocolVersion)),t("merging %p metadata",n.remotePeer,c),await r.merge(n.remotePeer,{metadata:c})}let a={peerId:n.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map(c=>nt(c)),observedAddr:s.observedAddr==null?void 0:nt(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return e.safeDispatchEvent("peer:identify",{detail:a}),a}var wr=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(e,t){this.protocol=t.protocol,this.started=!1,this.peerId=e.peerId,this.privateKey=e.privateKey,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.events=e.events,this.log=t.log,this.timeout=t.timeout??Le.timeout,this.maxInboundStreams=t.maxInboundStreams??Le.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Le.maxOutboundStreams,this.maxMessageSize=t.maxMessageSize??Le.maxMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Le.maxObservedAddresses,this.runOnLimitedConnection=t.runOnLimitedConnection??Le.runOnLimitedConnection,this.host={protocolVersion:`${t.protocolPrefix??Le.protocolPrefix}/${Sl}`,agentVersion:Ld(e.nodeInfo,t.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:q(this.host.agentVersion),ProtocolVersion:q(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,e=>{this.handleProtocol(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var _s=class extends wr{connectionManager;concurrency;constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Le.protocolPrefix}/${kl}/${Cl}`,log:e.logger.forComponent("libp2p:identify-push")}),this.connectionManager=e.connectionManager,this.concurrency=t.concurrency??Le.concurrency,(t.runOnSelfUpdate??Le.runOnSelfUpdate)&&e.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[sn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let e=this.addressManager.getAddresses().map(l=>l.decapsulateCode($("p2p").code)),t=new Ze({peerId:this.peerId,multiaddrs:e}),n=await rt.seal(t,this.privateKey),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=F(o.metadata.get("AgentVersion")??q(this.host.agentVersion)),a=F(o.metadata.get("ProtocolVersion")??q(this.host.protocolVersion)),c=this;async function*u(){for(let l of c.connectionManager.getConnections())(await c.peerStore.get(l.remotePeer)).protocols.includes(c.protocol)&&(yield async()=>{let h,w=AbortSignal.timeout(c.timeout);Er(1/0,w);try{h=await l.newStream(c.protocol,{signal:w,runOnLimitedConnection:c.runOnLimitedConnection}),await br(h,{maxDataLength:c.maxMessageSize}).pb(Pt).write({listenAddrs:e.map(y=>y.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:a},{signal:w}),await h.close({signal:w})}catch(m){c.log.error("could not push identify update to peer",m),h?.abort(m)}})}await xl(Si(u(),{concurrency:this.concurrency}))}async handleProtocol(e){let{connection:t,stream:n}=e;try{if(this.peerId.equals(t.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await br(n,{maxDataLength:this.maxMessageSize}).pb(Pt).read(s);await n.close(s),await Rs(this.peerStore,this.events,this.log,t,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log("handled push from %p",t.remotePeer)}};var Rd=r=>r.toString().split("/").slice(1),Xr=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),z=r=>({match:e=>Xr(t=>t===r).match(e),pattern:r}),Ps=()=>({match:r=>Xr(e=>typeof e=="string").match(r),pattern:"{string}"}),Ds=()=>({match:r=>Xr(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),ye=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{J.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),Os=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Ro.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),ce=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),Pe=(...r)=>({match:e=>{let t;for(let n of r){let s=n.match(e);s!==!1&&(t==null||s.length<t.length)&&(t=s)}return t??!1},pattern:`or(${r.map(e=>e.pattern).join(", ")})`}),Z=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e},pattern:`and(${r.map(e=>e.pattern).join(", ")})`});function re(...r){function e(s){let o=Rd(s);for(let i of r){let a=i.match(o);if(a===!1)return!1;o=a}return o}function t(s){return e(s)!==!1}function n(s){let o=e(s);return o===!1?!1:o.length===0}return{matches:t,exactMatch:n}}var Ui=Z(z("dns4"),Ps()),Li=Z(z("dns6"),Ps()),Ri=Z(z("dnsaddr"),Ps()),Hl=Z(z("dns"),Ps()),Ix=re(Ui),kx=re(Li),Nx=re(Ri),Cx=re(Pe(Hl,Ri,Ui,Li)),Fl=Z(z("ip4"),Xr(Es)),Kl=Z(z("ip6"),Xr(Bs)),ql=Pe(Fl,Kl),st=Pe(ql,Hl,Ui,Li,Ri),$l=re(st),Tx=re(Fl),Ux=re(Kl),Lx=re(ql),_i=Z(st,z("tcp"),Ds()),Qr=Z(st,z("udp"),Ds()),Rx=re(_i),_x=re(Qr),Oi=Z(Qr,z("quic")),Ms=Z(Qr,z("quic-v1")),_d=Pe(Oi,Ms),Ox=re(Oi),Vx=re(Ms),Ti=Pe(st,_i,Qr,Oi,Ms),zl=Pe(Z(Ti,z("ws"),ce(ye()))),Px=re(zl),Gl=Pe(Z(Ti,z("wss"),ce(ye())),Z(Ti,z("tls"),z("ws"),ce(ye()))),Dx=re(Gl),Wl=Z(Qr,z("webrtc-direct"),ce(Os()),ce(Os()),ce(ye())),Mx=re(Wl),jl=Z(Ms,z("webtransport"),ce(Os()),ce(Os()),ce(ye())),Hx=re(jl),Vs=Pe(zl,Gl,Z(_i,ce(ye())),Z(_d,ce(ye())),Z(st,ce(ye())),Wl,jl,ye()),Fx=re(Vs),Od=Z(Vs,z("p2p-circuit"),ye()),Kx=re(Od),Vd=Pe(Z(Vs,z("p2p-circuit"),z("webrtc"),ce(ye())),Z(Vs,z("webrtc"),ce(ye())),z("webrtc")),qx=re(Vd),Pd=Pe(Z(st,z("tcp"),Ds(),z("http"),ce(ye())),Z(st,z("http"),ce(ye()))),$x=re(Pd),Dd=Pe(Z(st,z("tcp"),Pe(Z(z("443"),z("http")),Z(Ds(),z("https"))),ce(ye())),Z(st,z("tls"),z("http"),ce(ye())),Z(st,z("https"),ce(ye()))),zx=re(Dd);var Hs=class extends wr{constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Le.protocolPrefix}/${Il}/${Nl}`,log:e.logger.forComponent("libp2p:identify")}),(t.runOnConnectionOpen??Le.runOnConnectionOpen)&&e.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{this.log.error("error during identify trigged by connection:open",o)})})}[sn]=["@libp2p/identify"];async _identify(e,t={}){let n;if(t.signal==null){let s=AbortSignal.timeout(this.timeout);Er(1/0,s),t={...t,signal:s}}try{n=await e.newStream(this.protocol,{...t,runOnLimitedConnection:this.runOnLimitedConnection});let o=await br(n,{maxDataLength:this.maxMessageSize}).pb(Pt).read(t);return await n.close(t),o}catch(s){throw this.log.error("error while reading identify message",s),n?.abort(s),s}}async identify(e,t={}){let n=await this._identify(e,t),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new De("public key was missing from identify message");let a=gr(s),c=ws(a.toCID());if(!e.remotePeer.equals(c))throw new De("identified peer does not match the expected peer");if(this.peerId.equals(c))throw new De("identified peer is our own peer id?");let u=Ml(i);return this.log("identify completed for peer %p and protocols %o",c,o),this.log("our observed address is %a",u),u!=null&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address %a",u),this.addressManager.addObservedAddr(u)),Rs(this.peerStore,this.events,this.log,e,n)}async handleProtocol(e){let{connection:t,stream:n}=e,s=AbortSignal.timeout(this.timeout);Er(1/0,s);try{let o=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(l=>l.decapsulateCode($("p2p").code)),a=o.peerRecordEnvelope;if(i.length>0&&a==null){let l=new Ze({peerId:this.peerId,multiaddrs:i});a=(await rt.seal(l,this.privateKey)).marshal().subarray()}let c=t.remoteAddr.bytes;$l.matches(t.remoteAddr)||(c=void 0),await br(n).pb(Pt).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:Tt(this.privateKey.publicKey),listenAddrs:i.map(l=>l.bytes),signedPeerRecord:a,observedAddr:c,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 Md(r={}){return e=>new Hs(e,r)}function Hd(r={}){return e=>new _s(e,r)}return cu(Fd);})();
|
|
6
|
+
`)}`:`${t} :`}};Xa=Ot;A.Constructed=Xa;Ot.NAME="CONSTRUCTED";var Ln=class extends Ee{fromBER(e,t,n){return t}toBER(e){return We}};Ln.override="EndOfContentValueBlock";var Qa,Rn=class extends ge{constructor(e={}){super(e,Ln),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}};Qa=Rn;A.EndOfContent=Qa;Rn.NAME=Vr;var ec,ur=class extends ge{constructor(e={}){super(e,Ee),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,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,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){let n=new ArrayBuffer(2);if(!e){let s=new Uint8Array(n);s[0]=5,s[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}};ec=ur;A.Null=ec;ur.NAME="NULL";var _n=class extends wt(Ee){constructor({value:e,...t}={}){super(t),t.valueHex?this.valueHexView=M.BufferSourceConverter.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(let e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,n){let s=M.BufferSourceConverter.toUint8Array(e);return bt(this,s,t,n)?(this.valueHexView=s.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Jo.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}};_n.NAME="BooleanValueBlock";var tc,On=class extends ge{constructor(e={}){super(e,_n),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}};tc=On;A.Boolean=tc;On.NAME="BOOLEAN";var Vn=class extends wt(Qe){constructor({isConstructed:e=!1,...t}={}){super(t),this.isConstructed=e}fromBER(e,t,n){let s=0;if(this.isConstructed){if(this.isHexOnly=!1,s=Qe.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let o=0;o<this.value.length;o++){let i=this.value[o].constructor.NAME;if(i===Vr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(i!==ja)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,s=super.fromBER(e,t,n),this.blockLength=n;return s}toBER(e,t){return this.isConstructed?Qe.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}};Vn.NAME="OctetStringValueBlock";var rc,Pn=class r extends ge{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Vn),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,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),t;if(!this.valueBlock.isConstructed){let o=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(o.byteLength){let i=fs(o,0,o.byteLength);i.offset!==-1&&i.offset===n&&(this.valueBlock.value=[i.result])}}catch{}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Ot.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 e=[];for(let t of this.valueBlock.value)t instanceof r&&e.push(t.valueBlock.valueHexView);return M.BufferSourceConverter.concat(e)}};rc=Pn;A.OctetString=rc;Pn.NAME=ja;var Dn=class extends wt(Qe){constructor({unusedBits:e=0,isConstructed:t=!1,...n}={}){super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let s=-1;if(this.isConstructed){if(s=Qe.prototype.fromBER.call(this,e,t,n),s===-1)return s;for(let a of this.value){let c=a.constructor.NAME;if(c===Vr){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(c!==Za)return this.error="BIT STRING may consists of BIT STRINGs only",-1;let u=a.valueBlock;if(this.unusedBits>0&&u.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=u.unusedBits}return s}let o=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,o,t,n))return-1;let i=o.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){let a=i.subarray(1);try{if(a.byteLength){let c=fs(a,0,a.byteLength);c.offset!==-1&&c.offset===n-1&&(this.value=[c.result])}}catch{}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,t+n}toBER(e,t){if(this.isConstructed)return Qe.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return We;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}}};Dn.NAME="BitStringValueBlock";var nc,fr=class extends ge{constructor({idBlock:e={},lenBlock:t={},...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,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Dn),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Ot.prototype.onAsciiEncoding.call(this);{let e=[],t=this.valueBlock.valueHexView;for(let s of t)e.push(s.toString(2).padStart(8,"0"));let n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}};nc=fr;A.BitString=nc;fr.NAME=Za;var sc;function qh(r,e){let t=new Uint8Array([0]),n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,u=0,l=c<i?i:c,f=0;for(let h=l;h>=0;h--,f++){switch(!0){case f<a.length:u=o[i-f]+a[c-f]+t[0];break;default:u=o[i-f]+t[0]}switch(t[0]=u/10,!0){case f>=o.length:o=Sn(new Uint8Array([u%10]),o);break;default:o[i-f]=u%10}}return t[0]>0&&(o=Sn(t,o)),o}function Wa(r){if(r>=_r.length)for(let e=_r.length;e<=r;e++){let t=new Uint8Array([0]),n=_r[e-1].slice(0);for(let s=n.length-1;s>=0;s--){let o=new Uint8Array([(n[s]<<1)+t[0]]);t[0]=o[0]/10,n[s]=o[0]%10}t[0]>0&&(n=Sn(t,n)),_r.push(n)}return _r[r]}function $h(r,e){let t=0,n=new Uint8Array(r),s=new Uint8Array(e),o=n.slice(0),i=o.length-1,a=s.slice(0),c=a.length-1,u,l=0;for(let f=c;f>=0;f--,l++)switch(u=o[i-l]-a[c-l]-t,!0){case u<0:t=1,o[i-l]=u+10;break;default:t=0,o[i-l]=u}if(t>0)for(let f=i-c+1;f>=0;f--,l++)if(u=o[i-l]-t,u<0)t=1,o[i-l]=u+10;else{t=0,o[i-l]=u;break}return o.slice()}var Pr=class extends wt(Ee){constructor({value:e,...t}={}){super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),e!==void 0&&(this.valueDec=e)}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=Jo.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array($a(e))}get valueDec(){return this._valueDec}fromDER(e,t,n,s=0){let o=this.fromBER(e,t,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(e=!1){let t=this.valueHexView;switch(!0){case(t[0]&128)!==0:{let n=new Uint8Array(this.valueHexView.length+1);n[0]=0,n.set(t,1),this.valueHexView=n}break;case(t[0]===0&&(t[1]&128)===0):this.valueHexView=this.valueHexView.subarray(1);break}return this.toBER(e)}fromBER(e,t,n){let s=super.fromBER(e,t,n);return s===-1||this.setValueHex(),s}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){let e=this.valueHexView.length*8-1,t=new Uint8Array(this.valueHexView.length*8/3),n=0,s,o=this.valueHexView,i="",a=!1;for(let c=o.byteLength-1;c>=0;c--){s=o[c];for(let u=0;u<8;u++){if((s&1)===1)switch(n){case e:t=$h(Wa(n),t),i="-";break;default:t=qh(t,Wa(n))}n++,s>>=1}}for(let c=0;c<t.length;c++)t[c]&&(a=!0),a&&(i+=Ga.charAt(t[c]));return a===!1&&(i+=Ga.charAt(0)),i}};sc=Pr;Pr.NAME="IntegerValueBlock";Object.defineProperty(sc.prototype,"valueHex",{set:function(r){this.valueHexView=new Uint8Array(r),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});var oc,me=class r extends ge{constructor(e={}){super(e,Pr),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return In(),BigInt(this.valueBlock.toString())}static fromBigInt(e){In();let t=BigInt(e),n=new Or,s=t.toString(16).replace(/^-/,""),o=new Uint8Array(M.Convert.FromHex(s));if(t<0){let a=new Uint8Array(o.length+(o[0]&128?1:0));a[0]|=128;let u=BigInt(`0x${M.Convert.ToHex(a)}`)+t,l=M.BufferSourceConverter.toUint8Array(M.Convert.FromHex(u.toString(16)));l[0]|=128,n.write(l)}else o[0]&128&&n.write(new Uint8Array([0])),n.write(o);return new r({valueHex:n.final()})}convertToDER(){let e=new r({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}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()}`}};oc=me;A.Integer=oc;me.NAME="INTEGER";var ic,Mn=class extends me{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}};ic=Mn;A.Enumerated=ic;Mn.NAME="ENUMERATED";var Dr=class extends wt(Ee){constructor({valueDec:e=-1,isFirstSid:t=!1,...n}={}){super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zt(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){In();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;let n=new Uint8Array(t.length/7);for(let s=0;s<n.length;s++)n[s]=parseInt(t.slice(s*7,s*7+7),2)+(s+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)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 t=_t(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n}toString(){let e="";if(this.isHexOnly)e=M.Convert.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}};Dr.NAME="sidBlock";var Hn=class extends Ee{constructor({value:e=dr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new Dr;if(s=o.fromBER(e,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(e){let t=[];for(let n=0;n<this.value.length;n++){let s=this.value[n].toBER(e);if(s.byteLength===0)return this.error=this.value[n].error,We;t.push(s)}return Xo(t)}fromString(e){this.value=[];let t=0,n=0,s="",o=!1;do if(n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1,o){let i=this.value[0],a=0;switch(i.valueDec){case 0:break;case 1:a=40;break;case 2:a=80;break;default:this.value=[];return}let c=parseInt(s,10);if(isNaN(c))return;i.valueDec=c+a,o=!1}else{let i=new Dr;if(s>Number.MAX_SAFE_INTEGER){In();let a=BigInt(s);i.valueBigInt=a}else if(i.valueDec=parseInt(s,10),isNaN(i.valueDec))return;this.value.length||(i.isFirstSid=!0,o=!0),this.value.push(i)}while(n!==-1)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t?(s=`{${s}}`,this.value[n].isFirstSid?e=`2.{${s} - 80}`:e+=s):e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Hn.NAME="ObjectIdentifierValueBlock";var ac,hr=class extends ge{constructor(e={}){super(e,Hn),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};ac=hr;A.ObjectIdentifier=ac;hr.NAME="OBJECT IDENTIFIER";var Mr=class extends wt(gt){constructor({valueDec:e=0,...t}={}){super(t),this.valueDec=e}fromBER(e,t,n){if(n===0)return t;let s=M.BufferSourceConverter.toUint8Array(e);if(!bt(this,s,t,n))return-1;let o=s.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let a=0;a<n&&(this.valueHexView[a]=o[a]&127,this.blockLength++,!!(o[a]&128));a++);let i=new Uint8Array(this.blockLength);for(let a=0;a<this.blockLength;a++)i[a]=this.valueHexView[a];return this.valueHexView=i,o[this.blockLength-1]&128?(this.error="End of input reached before message was fully decoded",-1):(this.valueHexView[0]===0&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=Zt(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)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 t=_t(this.valueDec,7);if(t.byteLength===0)return this.error="Error during encoding SID value",We;let n=new Uint8Array(t.byteLength);if(!e){let s=new Uint8Array(t),o=t.byteLength-1;for(let i=0;i<o;i++)n[i]=s[i]|128;n[o]=s[o]}return n.buffer}toString(){let e="";return this.isHexOnly?e=M.Convert.ToHex(this.valueHexView):e=this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}};Mr.NAME="relativeSidBlock";var Fn=class extends Ee{constructor({value:e=dr,...t}={}){super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let s=t;for(;n>0;){let o=new Mr;if(s=o.fromBER(e,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(e,t){let n=[];for(let s=0;s<this.value.length;s++){let o=this.value[s].toBER(e);if(o.byteLength===0)return this.error=this.value[s].error,We;n.push(o)}return Xo(n)}fromString(e){this.value=[];let t=0,n=0,s="";do{n=e.indexOf(".",t),n===-1?s=e.substring(t):s=e.substring(t,n),t=n+1;let o=new Mr;if(o.valueDec=parseInt(s,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(n!==-1);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let s=this.value[n].toString();n!==0&&(e=`${e}.`),t&&(s=`{${s}}`),e+=s}return e}toJSON(){let e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}};Fn.NAME="RelativeObjectIdentifierValueBlock";var cc,Kn=class extends ge{constructor(e={}){super(e,Fn),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}};cc=Kn;A.RelativeObjectIdentifier=cc;Kn.NAME="RelativeObjectIdentifier";var lc,mt=class extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}};lc=mt;A.Sequence=lc;mt.NAME="SEQUENCE";var uc,qn=class extends Ot{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}};uc=qn;A.Set=uc;qn.NAME="SET";var $n=class extends wt(Ee){constructor({...e}={}){super(e),this.isHexOnly=!0,this.value=dr}toJSON(){return{...super.toJSON(),value:this.value}}};$n.NAME="StringValueBlock";var zn=class extends $n{};zn.NAME="SimpleStringValueBlock";var Ie=class extends Cn{constructor({...e}={}){super(e,zn)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let s=0;s<t;s++)n[s]=e.charCodeAt(s);this.valueBlock.value=e}};Ie.NAME="SIMPLE STRING";var Gn=class extends Ie{fromBuffer(e){this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e);try{this.valueBlock.value=M.Convert.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=M.Convert.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf8String(e)),this.valueBlock.value=e}};Gn.NAME="Utf8StringValueBlock";var fc,yt=class extends Gn{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}};fc=yt;A.Utf8String=fc;yt.NAME="UTF8String";var Wn=class extends Ie{fromBuffer(e){this.valueBlock.value=M.Convert.ToUtf16String(e),this.valueBlock.valueHexView=M.BufferSourceConverter.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(M.Convert.FromUtf16String(e))}};Wn.NAME="BmpStringValueBlock";var hc,jn=class extends Wn{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}};hc=jn;A.BmpString=hc;jn.NAME="BMPString";var Zn=class extends Ie{fromBuffer(e){let t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);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(t))}fromString(e){let t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t*4);for(let s=0;s<t;s++){let o=_t(e.charCodeAt(s),8),i=new Uint8Array(o);if(i.length>4)continue;let a=4-i.length;for(let c=i.length-1;c>=0;c--)n[s*4+c+a]=i[c]}this.valueBlock.value=e}};Zn.NAME="UniversalStringValueBlock";var dc,Yn=class extends Zn{constructor({...e}={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}};dc=Yn;A.UniversalString=dc;Yn.NAME="UniversalString";var pc,Jn=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}};pc=Jn;A.NumericString=pc;Jn.NAME="NumericString";var gc,Xn=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}};gc=Xn;A.PrintableString=gc;Xn.NAME="PrintableString";var mc,Qn=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}};mc=Qn;A.TeletexString=mc;Qn.NAME="TeletexString";var yc,es=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}};yc=es;A.VideotexString=yc;es.NAME="VideotexString";var bc,ts=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}};bc=ts;A.IA5String=bc;ts.NAME="IA5String";var wc,rs=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}};wc=rs;A.GraphicString=wc;rs.NAME="GraphicString";var xc,Hr=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}};xc=Hr;A.VisibleString=xc;Hr.NAME="VisibleString";var vc,ns=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}};vc=ns;A.GeneralString=vc;ns.NAME="GeneralString";var Ec,ss=class extends Ie{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}};Ec=ss;A.CharacterString=Ec;ss.NAME="CharacterString";var Bc,Fr=class extends Hr{constructor({value:e,valueDate:t,...n}={}){if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let s=0;s<e.length;s++)this.valueBlock.valueHexView[s]=e.charCodeAt(s)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,M.BufferSourceConverter.toUint8Array(e)))}toBuffer(){let e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let s=0;s<e.length;s++)n[s]=e.charCodeAt(s);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){let n=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/ig.exec(e);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(e="iso"){if(e==="iso"){let t=new Array(7);return t[0]=Ue(this.year<2e3?this.year-1900:this.year-2e3,2),t[1]=Ue(this.month,2),t[2]=Ue(this.day,2),t[3]=Ue(this.hour,2),t[4]=Ue(this.minute,2),t[5]=Ue(this.second,2),t[6]="Z",t.join("")}return super.toString(e)}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}}};Bc=Fr;A.UTCTime=Bc;Fr.NAME="UTCTime";var Ac,os=class extends Fr{constructor(e={}){var t;super(e),(t=this.millisecond)!==null&&t!==void 0||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t=!1,n="",s="",o=0,i,a=0,c=0;if(e[e.length-1]==="Z")n=e.substring(0,e.length-1),t=!0;else{let f=new Number(e[e.length-1]);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(t){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("+"),w="";if(h===-1&&(h=n.indexOf("-"),f=-1),h!==-1){if(w=n.substring(h+1),n=n.substring(0,h),w.length!==2&&w.length!==4)throw new Error("Wrong input string for conversion");let m=parseInt(w.substring(0,2),10);if(isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");if(a=f*m,w.length===4){if(m=parseInt(w.substring(2,4),10),isNaN(m.valueOf()))throw new Error("Wrong input string for conversion");c=f*m}}}let u=n.indexOf(".");if(u===-1&&(u=n.indexOf(",")),u!==-1){let f=new Number(`0${n.substring(u)}`);if(isNaN(f.valueOf()))throw new Error("Wrong input string for conversion");o=f.valueOf(),s=n.substring(0,u)}else s=n;switch(!0){case s.length===8:if(i=/(\d{4})(\d{2})(\d{2})/ig,u!==-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,u!==-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,u!==-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,u!==-1){let f=1e3*o;this.millisecond=Math.floor(f)}break;default:throw new Error("Wrong input string for conversion")}let l=i.exec(s);if(l===null)throw new Error("Wrong input string for conversion");for(let f=1;f<l.length;f++)switch(f){case 1:this.year=parseInt(l[f],10);break;case 2:this.month=parseInt(l[f],10);break;case 3:this.day=parseInt(l[f],10);break;case 4:this.hour=parseInt(l[f],10)+a;break;case 5:this.minute=parseInt(l[f],10)+c;break;case 6:this.second=parseInt(l[f],10);break;default:throw new Error("Wrong input string for conversion")}if(t===!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(e="iso"){if(e==="iso"){let t=[];return t.push(Ue(this.year,4)),t.push(Ue(this.month,2)),t.push(Ue(this.day,2)),t.push(Ue(this.hour,2)),t.push(Ue(this.minute,2)),t.push(Ue(this.second,2)),this.millisecond!==0&&(t.push("."),t.push(Ue(this.millisecond,3))),t.push("Z"),t.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}};Ac=os;A.GeneralizedTime=Ac;os.NAME="GeneralizedTime";var Sc,is=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}};Sc=is;A.DATE=Sc;is.NAME="DATE";var Ic,as=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}};Ic=as;A.TimeOfDay=Ic;as.NAME="TimeOfDay";var kc,cs=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}};kc=cs;A.DateTime=kc;cs.NAME="DateTime";var Nc,ls=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}};Nc=ls;A.Duration=Nc;ls.NAME="Duration";var Cc,us=class extends yt{constructor(e={}){super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}};Cc=us;A.TIME=Cc;us.NAME="TIME";function F(r,e="utf8"){let t=xn[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var Kr=class extends Error{constructor(e="An error occurred while verifying a message"){super(e),this.name="VerificationError"}},hs=class extends Error{constructor(e="Missing Web Crypto API"){super(e),this.name="WebCryptoMissingError"}};var Tc={get(r=globalThis){let e=r.crypto;if(e?.subtle==null)throw new hs("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 e}};var Vt=Tc;async function Uc(r){let e=await Vt.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:r,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),t=await Gh(e);return{privateKey:t[0],publicKey:t[1]}}async function Lc(r,e){let t=await Vt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Vt.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},t,e instanceof Uint8Array?e:e.subarray());return new Uint8Array(n,0,n.byteLength)}async function Rc(r,e,t){let n=await Vt.get().subtle.importKey("jwk",r,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Vt.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,e,t instanceof Uint8Array?t:t.subarray())}async function Gh(r){if(r.privateKey==null||r.publicKey==null)throw new Se("Private and public key are required");return Promise.all([Vt.get().subtle.exportKey("jwk",r.privateKey),Vt.get().subtle.exportKey("jwk",r.publicKey)])}function ti(r){if(r.kty!=="RSA")throw new Se("invalid key type");if(r.n==null)throw new Se("invalid key modulus");return q(r.n,"base64url").length*8}var pr=class{type="RSA";_key;_raw;_multihash;constructor(e,t){this._key=e,this._multihash=t}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkix(this._key)),this._raw}toMultihash(){return this._multihash}toCID(){return de.createV1(114,this._multihash)}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}verify(e,t){return Rc(this._key,t,e)}},$r=class{type="RSA";_key;_raw;publicKey;constructor(e,t){this._key=e,this.publicKey=t}get raw(){return this._raw==null&&(this._raw=qr.jwkToPkcs1(this._key)),this._raw}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}sign(e){return Lc(this._key,e)}};var ds=8192,ri=18;function _c(r){let{result:e}=ei(r),t=e.valueBlock.value;return{n:F(et(t[1].toBigInt()),"base64url"),e:F(et(t[2].toBigInt()),"base64url"),d:F(et(t[3].toBigInt()),"base64url"),p:F(et(t[4].toBigInt()),"base64url"),q:F(et(t[5].toBigInt()),"base64url"),dp:F(et(t[6].toBigInt()),"base64url"),dq:F(et(t[7].toBigInt()),"base64url"),qi:F(et(t[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}function Wh(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 Se("JWK was missing components");let t=new mt({value:[new me({value:0}),me.fromBigInt(tt(q(r.n,"base64url"))),me.fromBigInt(tt(q(r.e,"base64url"))),me.fromBigInt(tt(q(r.d,"base64url"))),me.fromBigInt(tt(q(r.p,"base64url"))),me.fromBigInt(tt(q(r.q,"base64url"))),me.fromBigInt(tt(q(r.dp,"base64url"))),me.fromBigInt(tt(q(r.dq,"base64url"))),me.fromBigInt(tt(q(r.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}function Oc(r){let{result:e}=ei(r),t=e.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:F(et(t[0].toBigInt()),"base64url"),e:F(et(t[1].toBigInt()),"base64url")}}function ni(r){if(r.n==null||r.e==null)throw new Se("JWK was missing components");let t=new mt({value:[new mt({value:[new hr({value:"1.2.840.113549.1.1.1"}),new ur]}),new fr({valueHex:new mt({value:[me.fromBigInt(tt(q(r.n,"base64url"))),me.fromBigInt(tt(q(r.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}function et(r){let e=r.toString(16);e.length%2>0&&(e=`0${e}`);let t=e.length/2,n=new Uint8Array(t),s=0,o=0;for(;s<t;)n[s]=parseInt(e.slice(o,o+2),16),s+=1,o+=2;return n}function tt(r){let e=[];return r.forEach(function(t){let n=t.toString(16);n.length%2>0&&(n=`0${n}`),e.push(n)}),BigInt("0x"+e.join(""))}function Vc(r){let e=_c(r);return Pc(e)}function si(r){let e=Oc(r);if(ti(e)>ds)throw new Jt("Key size is too large");let t=cr(Xe.encode({Type:ae.RSA,Data:r})),n=Me(ri,t);return new pr(e,n)}function Pc(r){if(ti(r)>ds)throw new Se("Key size is too large");let e=Mc(r),t=cr(Xe.encode({Type:ae.RSA,Data:ni(e.publicKey)})),n=Me(ri,t);return new $r(e.privateKey,new pr(e.publicKey,n))}async function Dc(r){if(r>ds)throw new Se("Key size is too large");let e=await Uc(r),t=cr(Xe.encode({Type:ae.RSA,Data:ni(e.publicKey)})),n=Me(ri,t);return new $r(e.privateKey,new pr(e.publicKey,n))}function Mc(r){if(r==null)throw new Se("Missing key parameter");return{privateKey:r,publicKey:{kty:r.kty,n:r.n,e:r.e}}}var ps=class extends sr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,ca(e);let n=Ir(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let s=this.blockLen,o=new Uint8Array(s);o.set(n.length>s?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(e){return nr(this),this.iHash.update(e),this}digestInto(e){nr(this),rr(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:n,finished:s,destroyed:o,blockLen:i,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=o,e.blockLen=i,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}},oi=(r,e,t)=>new ps(r,e).update(t).digest();oi.create=(r,e)=>new ps(r,e);function Hc(r){r.lowS!==void 0&&Fe("lowS",r.lowS),r.prehash!==void 0&&Fe("prehash",r.prehash)}function jh(r){let e=Cr(r);Je(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});let{endo:t,Fp:n,a:s}=e;if(t){if(!n.eql(s,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}var{bytesToNumberBE:Zh,hexToBytes:Yh}=fn,xt={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(r,e)=>{let{Err:t}=xt;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length&1)throw new t("tlv.encode: unpadded data");let n=e.length/2,s=Ft(n);if(s.length/2&128)throw new t("tlv.encode: long form length too big");let o=n>127?Ft(s.length/2|128):"";return`${Ft(r)}${o}${s}${e}`},decode(r,e){let{Err:t}=xt,n=0;if(r<0||r>256)throw new t("tlv.encode: wrong tag");if(e.length<2||e[n++]!==r)throw new t("tlv.decode: wrong tlv");let s=e[n++],o=!!(s&128),i=0;if(!o)i=s;else{let c=s&127;if(!c)throw new t("tlv.decode(long): indefinite length not supported");if(c>4)throw new t("tlv.decode(long): byte length is too big");let u=e.subarray(n,n+c);if(u.length!==c)throw new t("tlv.decode: length bytes not complete");if(u[0]===0)throw new t("tlv.decode(long): zero leftmost byte");for(let l of u)i=i<<8|l;if(n+=c,i<128)throw new t("tlv.decode(long): not minimal encoding")}let a=e.subarray(n,n+i);if(a.length!==i)throw new t("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+i)}}},_int:{encode(r){let{Err:e}=xt;if(r<vt)throw new e("integer: negative integers are not allowed");let t=Ft(r);if(Number.parseInt(t[0],16)&8&&(t="00"+t),t.length&1)throw new e("unexpected assertion");return t},decode(r){let{Err:e}=xt;if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return Zh(r)}},toSig(r){let{Err:e,_int:t,_tlv:n}=xt,s=typeof r=="string"?Yh(r):r;ir(s);let{v:o,l:i}=n.decode(48,s);if(i.length)throw new e("Invalid signature: left bytes after parsing");let{v:a,l:c}=n.decode(2,o),{v:u,l}=n.decode(2,c);if(l.length)throw new e("Invalid signature: left bytes after parsing");return{r:t.decode(a),s:t.decode(u)}},hexFromSig(r){let{_tlv:e,_int:t}=xt,n=`${e.encode(2,t.encode(r.r))}${e.encode(2,t.encode(r.s))}`;return e.encode(48,n)}},vt=BigInt(0),fe=BigInt(1),ym=BigInt(2),Fc=BigInt(3),bm=BigInt(4);function Jh(r){let e=jh(r),{Fp:t}=e,n=Ct(e.n,e.nBitLength),s=e.toBytes||((y,d,x)=>{let B=d.toAffine();return ht(Uint8Array.from([4]),t.toBytes(B.x),t.toBytes(B.y))}),o=e.fromBytes||(y=>{let d=y.subarray(1),x=t.fromBytes(d.subarray(0,t.BYTES)),B=t.fromBytes(d.subarray(t.BYTES,2*t.BYTES));return{x,y:B}});function i(y){let{a:d,b:x}=e,B=t.sqr(y),g=t.mul(B,y);return t.add(t.add(g,t.mul(y,d)),x)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function a(y){return kr(y,fe,e.n)}function c(y){let{allowedPrivateKeyLengths:d,nByteLength:x,wrapPrivateKey:B,n:g}=e;if(d&&typeof y!="bigint"){if(It(y)&&(y=ut(y)),typeof y!="string"||!d.includes(y.length))throw new Error("Invalid key");y=y.padStart(x*2,"0")}let S;try{S=typeof y=="bigint"?y:ft(te("private key",y,x))}catch{throw new Error(`private key must be ${x} bytes, hex or bigint, not ${typeof y}`)}return B&&(S=j(S,g)),Ne("private key",S,fe,g),S}function u(y){if(!(y instanceof h))throw new Error("ProjectivePoint expected")}let l=$t((y,d)=>{let{px:x,py:B,pz:g}=y;if(t.eql(g,t.ONE))return{x,y:B};let S=y.is0();d==null&&(d=S?t.ONE:t.inv(g));let L=t.mul(x,d),U=t.mul(B,d),I=t.mul(g,d);if(S)return{x:t.ZERO,y:t.ZERO};if(!t.eql(I,t.ONE))throw new Error("invZ was invalid");return{x:L,y:U}}),f=$t(y=>{if(y.is0()){if(e.allowInfinityPoint&&!t.is0(y.py))return;throw new Error("bad point: ZERO")}let{x:d,y:x}=y.toAffine();if(!t.isValid(d)||!t.isValid(x))throw new Error("bad point: x or y not FE");let B=t.sqr(x),g=i(d);if(!t.eql(B,g))throw new Error("bad point: equation left != right");if(!y.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});class h{constructor(d,x,B){if(this.px=d,this.py=x,this.pz=B,d==null||!t.isValid(d))throw new Error("x required");if(x==null||!t.isValid(x))throw new Error("y required");if(B==null||!t.isValid(B))throw new Error("z required");Object.freeze(this)}static fromAffine(d){let{x,y:B}=d||{};if(!d||!t.isValid(x)||!t.isValid(B))throw new Error("invalid affine point");if(d instanceof h)throw new Error("projective point not allowed");let g=S=>t.eql(S,t.ZERO);return g(x)&&g(B)?h.ZERO:new h(x,B,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(d){let x=t.invertBatch(d.map(B=>B.pz));return d.map((B,g)=>B.toAffine(x[g])).map(h.fromAffine)}static fromHex(d){let x=h.fromAffine(o(te("pointHex",d)));return x.assertValidity(),x}static fromPrivateKey(d){return h.BASE.multiply(c(d))}static msm(d,x){return pn(h,n,d,x)}_setWindowSize(d){m.setWindowSize(this,d)}assertValidity(){f(this)}hasEvenY(){let{y:d}=this.toAffine();if(t.isOdd)return!t.isOdd(d);throw new Error("Field doesn't support isOdd")}equals(d){u(d);let{px:x,py:B,pz:g}=this,{px:S,py:L,pz:U}=d,I=t.eql(t.mul(x,U),t.mul(S,g)),k=t.eql(t.mul(B,U),t.mul(L,g));return I&&k}negate(){return new h(this.px,t.neg(this.py),this.pz)}double(){let{a:d,b:x}=e,B=t.mul(x,Fc),{px:g,py:S,pz:L}=this,U=t.ZERO,I=t.ZERO,k=t.ZERO,T=t.mul(g,g),ne=t.mul(S,S),K=t.mul(L,L),V=t.mul(g,S);return V=t.add(V,V),k=t.mul(g,L),k=t.add(k,k),U=t.mul(d,k),I=t.mul(B,K),I=t.add(U,I),U=t.sub(ne,I),I=t.add(ne,I),I=t.mul(U,I),U=t.mul(V,U),k=t.mul(B,k),K=t.mul(d,K),V=t.sub(T,K),V=t.mul(d,V),V=t.add(V,k),k=t.add(T,T),T=t.add(k,T),T=t.add(T,K),T=t.mul(T,V),I=t.add(I,T),K=t.mul(S,L),K=t.add(K,K),T=t.mul(K,V),U=t.sub(U,T),k=t.mul(K,ne),k=t.add(k,k),k=t.add(k,k),new h(U,I,k)}add(d){u(d);let{px:x,py:B,pz:g}=this,{px:S,py:L,pz:U}=d,I=t.ZERO,k=t.ZERO,T=t.ZERO,ne=e.a,K=t.mul(e.b,Fc),V=t.mul(x,S),se=t.mul(B,L),E=t.mul(g,U),N=t.add(x,B),b=t.add(S,L);N=t.mul(N,b),b=t.add(V,se),N=t.sub(N,b),b=t.add(x,g);let p=t.add(S,U);return b=t.mul(b,p),p=t.add(V,E),b=t.sub(b,p),p=t.add(B,g),I=t.add(L,U),p=t.mul(p,I),I=t.add(se,E),p=t.sub(p,I),T=t.mul(ne,b),I=t.mul(K,E),T=t.add(I,T),I=t.sub(se,T),T=t.add(se,T),k=t.mul(I,T),se=t.add(V,V),se=t.add(se,V),E=t.mul(ne,E),b=t.mul(K,b),se=t.add(se,E),E=t.sub(V,E),E=t.mul(ne,E),b=t.add(b,E),V=t.mul(se,b),k=t.add(k,V),V=t.mul(p,b),I=t.mul(N,I),I=t.sub(I,V),V=t.mul(N,se),T=t.mul(p,T),T=t.add(T,V),new h(I,k,T)}subtract(d){return this.add(d.negate())}is0(){return this.equals(h.ZERO)}wNAF(d){return m.wNAFCached(this,d,h.normalizeZ)}multiplyUnsafe(d){Ne("scalar",d,vt,e.n);let x=h.ZERO;if(d===vt)return x;if(d===fe)return this;let{endo:B}=e;if(!B)return m.unsafeLadder(this,d);let{k1neg:g,k1:S,k2neg:L,k2:U}=B.splitScalar(d),I=x,k=x,T=this;for(;S>vt||U>vt;)S&fe&&(I=I.add(T)),U&fe&&(k=k.add(T)),T=T.double(),S>>=fe,U>>=fe;return g&&(I=I.negate()),L&&(k=k.negate()),k=new h(t.mul(k.px,B.beta),k.py,k.pz),I.add(k)}multiply(d){let{endo:x,n:B}=e;Ne("scalar",d,fe,B);let g,S;if(x){let{k1neg:L,k1:U,k2neg:I,k2:k}=x.splitScalar(d),{p:T,f:ne}=this.wNAF(U),{p:K,f:V}=this.wNAF(k);T=m.constTimeNegate(L,T),K=m.constTimeNegate(I,K),K=new h(t.mul(K.px,x.beta),K.py,K.pz),g=T.add(K),S=ne.add(V)}else{let{p:L,f:U}=this.wNAF(d);g=L,S=U}return h.normalizeZ([g,S])[0]}multiplyAndAddUnsafe(d,x,B){let g=h.BASE,S=(U,I)=>I===vt||I===fe||!U.equals(g)?U.multiplyUnsafe(I):U.multiply(I),L=S(this,x).add(S(d,B));return L.is0()?void 0:L}toAffine(d){return l(this,d)}isTorsionFree(){let{h:d,isTorsionFree:x}=e;if(d===fe)return!0;if(x)return x(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){let{h:d,clearCofactor:x}=e;return d===fe?this:x?x(h,this):this.multiplyUnsafe(e.h)}toRawBytes(d=!0){return Fe("isCompressed",d),this.assertValidity(),s(h,this,d)}toHex(d=!0){return Fe("isCompressed",d),ut(this.toRawBytes(d))}}h.BASE=new h(e.Gx,e.Gy,t.ONE),h.ZERO=new h(t.ZERO,t.ONE,t.ZERO);let w=e.nBitLength,m=dn(h,e.endo?Math.ceil(w/2):w);return{CURVE:e,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:i,isWithinCurveOrder:a}}function Xh(r){let e=Cr(r);return Je(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function Kc(r){let e=Xh(r),{Fp:t,n}=e,s=t.BYTES+1,o=2*t.BYTES+1;function i(E){return j(E,n)}function a(E){return hn(E,n)}let{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:f}=Jh({...e,toBytes(E,N,b){let p=N.toAffine(),v=t.toBytes(p.x),C=ht;return Fe("isCompressed",b),b?C(Uint8Array.from([N.hasEvenY()?2:3]),v):C(Uint8Array.from([4]),v,t.toBytes(p.y))},fromBytes(E){let N=E.length,b=E[0],p=E.subarray(1);if(N===s&&(b===2||b===3)){let v=ft(p);if(!kr(v,fe,t.ORDER))throw new Error("Point is not on curve");let C=l(v),R;try{R=t.sqrt(C)}catch(H){let D=H instanceof Error?": "+H.message:"";throw new Error("Point is not on curve"+D)}let _=(R&fe)===fe;return(b&1)===1!==_&&(R=t.neg(R)),{x:v,y:R}}else if(N===o&&b===4){let v=t.fromBytes(p.subarray(0,t.BYTES)),C=t.fromBytes(p.subarray(t.BYTES,2*t.BYTES));return{x:v,y:C}}else throw new Error(`Point of length ${N} was invalid. Expected ${s} compressed bytes or ${o} uncompressed bytes`)}}),h=E=>ut(Nt(E,e.nByteLength));function w(E){let N=n>>fe;return E>N}function m(E){return w(E)?i(-E):E}let y=(E,N,b)=>ft(E.slice(N,b));class d{constructor(N,b,p){this.r=N,this.s=b,this.recovery=p,this.assertValidity()}static fromCompact(N){let b=e.nByteLength;return N=te("compactSignature",N,b*2),new d(y(N,0,b),y(N,b,2*b))}static fromDER(N){let{r:b,s:p}=xt.toSig(te("DER",N));return new d(b,p)}assertValidity(){Ne("r",this.r,fe,n),Ne("s",this.s,fe,n)}addRecoveryBit(N){return new d(this.r,this.s,N)}recoverPublicKey(N){let{r:b,s:p,recovery:v}=this,C=U(te("msgHash",N));if(v==null||![0,1,2,3].includes(v))throw new Error("recovery id invalid");let R=v===2||v===3?b+e.n:b;if(R>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");let _=v&1?"03":"02",P=c.fromHex(_+h(R)),H=a(R),D=i(-C*H),W=i(p*H),Y=c.BASE.multiplyAndAddUnsafe(P,D,W);if(!Y)throw new Error("point at infinify");return Y.assertValidity(),Y}hasHighS(){return w(this.s)}normalizeS(){return this.hasHighS()?new d(this.r,i(-this.s),this.recovery):this}toDERRawBytes(){return Kt(this.toDERHex())}toDERHex(){return xt.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Kt(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}let x={isValidPrivateKey(E){try{return u(E),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{let E=lo(e.n);return va(e.randomBytes(E),e.n)},precompute(E=8,N=c.BASE){return N._setWindowSize(E),N.multiply(BigInt(3)),N}};function B(E,N=!0){return c.fromPrivateKey(E).toRawBytes(N)}function g(E){let N=It(E),b=typeof E=="string",p=(N||b)&&E.length;return N?p===s||p===o:b?p===2*s||p===2*o:E instanceof c}function S(E,N,b=!0){if(g(E))throw new Error("first arg must be private key");if(!g(N))throw new Error("second arg must be public key");return c.fromHex(N).multiply(u(E)).toRawBytes(b)}let L=e.bits2int||function(E){let N=ft(E),b=E.length*8-e.nBitLength;return b>0?N>>BigInt(b):N},U=e.bits2int_modN||function(E){return i(L(E))},I=Nr(e.nBitLength);function k(E){return Ne(`num < 2^${e.nBitLength}`,E,vt,I),Nt(E,e.nByteLength)}function T(E,N,b=ne){if(["recovered","canonical"].some(ue=>ue in b))throw new Error("sign() legacy options not supported");let{hash:p,randomBytes:v}=e,{lowS:C,prehash:R,extraEntropy:_}=b;C==null&&(C=!0),E=te("msgHash",E),Hc(b),R&&(E=te("prehashed msgHash",p(E)));let P=U(E),H=u(N),D=[k(H),k(P)];if(_!=null&&_!==!1){let ue=_===!0?v(t.BYTES):_;D.push(te("extraEntropy",ue))}let W=ht(...D),Y=P;function le(ue){let he=L(ue);if(!f(he))return;let Be=a(he),oe=c.BASE.multiply(he).toAffine(),ke=i(oe.x);if(ke===vt)return;let ot=i(Be*i(Y+ke*H));if(ot===vt)return;let xr=(oe.x===ke?0:2)|Number(oe.y&fe),vr=ot;return C&&w(ot)&&(vr=m(ot),xr^=1),new d(ke,vr,xr)}return{seed:W,k2sig:le}}let ne={lowS:e.lowS,prehash:!1},K={lowS:e.lowS,prehash:!1};function V(E,N,b=ne){let{seed:p,k2sig:v}=T(E,N,b),C=e;return oo(C.hash.outputLen,C.nByteLength,C.hmac)(p,v)}c.BASE._setWindowSize(8);function se(E,N,b,p=K){let v=E;if(N=te("msgHash",N),b=te("publicKey",b),"strict"in p)throw new Error("options.strict was renamed to lowS");Hc(p);let{lowS:C,prehash:R}=p,_,P;try{if(typeof v=="string"||It(v))try{_=d.fromDER(v)}catch(oe){if(!(oe instanceof xt.Err))throw oe;_=d.fromCompact(v)}else if(typeof v=="object"&&typeof v.r=="bigint"&&typeof v.s=="bigint"){let{r:oe,s:ke}=v;_=new d(oe,ke)}else throw new Error("PARSE");P=c.fromHex(b)}catch(oe){if(oe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(C&&_.hasHighS())return!1;R&&(N=e.hash(N));let{r:H,s:D}=_,W=U(N),Y=a(D),le=i(W*Y),ue=i(H*Y),he=c.BASE.multiplyAndAddUnsafe(P,le,ue)?.toAffine();return he?i(he.x)===H:!1}return{CURVE:e,getPublicKey:B,getSharedSecret:S,sign:V,verify:se,ProjectivePoint:c,Signature:d,utils:x}}function Qh(r){return{hash:r,hmac:(e,...t)=>oi(r,e,Js(...t)),randomBytes:cn}}function qc(r,e){let t=n=>Kc({...r,...Qh(n)});return Object.freeze({...t(e),create:t})}var Gc=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),$c=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ed=BigInt(1),ii=BigInt(2),zc=(r,e)=>(r+e/ii)/e;function td(r){let e=Gc,t=BigInt(3),n=BigInt(6),s=BigInt(11),o=BigInt(22),i=BigInt(23),a=BigInt(44),c=BigInt(88),u=r*r*r%e,l=u*u*r%e,f=Q(l,t,e)*l%e,h=Q(f,t,e)*l%e,w=Q(h,ii,e)*u%e,m=Q(w,s,e)*w%e,y=Q(m,o,e)*m%e,d=Q(y,a,e)*y%e,x=Q(d,c,e)*d%e,B=Q(x,a,e)*y%e,g=Q(B,t,e)*l%e,S=Q(g,i,e)*m%e,L=Q(S,n,e)*u%e,U=Q(L,ii,e);if(!ai.eql(ai.sqr(U),r))throw new Error("Cannot find square root");return U}var ai=Ct(Gc,void 0,void 0,{sqrt:td}),Yt=qc({a:BigInt(0),b:BigInt(7),Fp:ai,n:$c,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:r=>{let e=$c,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-ed*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=t,i=BigInt("0x100000000000000000000000000000000"),a=zc(o*r,e),c=zc(-n*r,e),u=j(r-a*t-c*s,e),l=j(-a*n-c*o,e),f=u>i,h=l>i;if(f&&(u=e-u),h&&(l=e-l),u>i||l>i)throw new Error("splitScalar: Endomorphism failed, k="+r);return{k1neg:f,k1:u,k2neg:h,k2:l}}}},cr),km=BigInt(0);var Nm=Yt.ProjectivePoint;function _e(r,e){e==null&&(e=r.reduce((s,o)=>s+o.length,0));let t=Te(e),n=0;for(let s of r)t.set(s,n),n+=s.length;return t}function Wc(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function jc(r,e,t){let n=Tr.digest(t instanceof Uint8Array?t:t.subarray());if(Wc(n))return n.then(({digest:s})=>Yt.verify(e,s,r)).catch(s=>{throw new Kr(String(s))});try{return Yt.verify(e,n.digest,r)}catch(s){throw new Kr(String(s))}}var gs=class{type="secp256k1";raw;_key;constructor(e){this._key=Yc(e),this.raw=Zc(this._key)}toMultihash(){return ct.digest(Tt(this))}toCID(){return de.createV1(114,this.toMultihash())}toString(){return J.encode(this.toMultihash().bytes).substring(1)}equals(e){return e==null||!(e.raw instanceof Uint8Array)?!1:be(this.raw,e.raw)}verify(e,t){return jc(this._key,t,e)}};function ci(r){return new gs(r)}function Zc(r){return Yt.ProjectivePoint.fromHex(r).toRawBytes(!0)}function Yc(r){try{return Yt.ProjectivePoint.fromHex(r),r}catch(e){throw new Jt(String(e))}}function gr(r){let{Type:e,Data:t}=Xe.decode(r),n=t??new Uint8Array;switch(e){case ae.RSA:return si(n);case ae.Ed25519:return go(n);case ae.secp256k1:return ci(n);default:throw new Dt}}function Jc(r){let{Type:e,Data:t}=Xe.decode(r.digest),n=t??new Uint8Array;switch(e){case ae.Ed25519:return go(n);case ae.secp256k1:return ci(n);default:throw new Dt}}function Tt(r){return Xe.encode({Type:ae[r.type],Data:r.raw})}var Qc=Symbol.for("@achingbrain/uint8arraylist");function Xc(r,e){if(e==null||e<0)throw new RangeError("index is out of bounds");let t=0;for(let n of r){let s=t+n.byteLength;if(e<s)return{buf:n,index:e-t};t=s}throw new RangeError("index is out of bounds")}function ms(r){return!!r?.[Qc]}var je=class r{bufs;length;[Qc]=!0;constructor(...e){this.bufs=[],this.length=0,e.length>0&&this.appendAll(e)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(...e){this.appendAll(e)}appendAll(e){let t=0;for(let n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else if(ms(n))t+=n.byteLength,this.bufs.push(...n.bufs);else throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}prepend(...e){this.prependAll(e)}prependAll(e){let t=0;for(let n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else if(ms(n))t+=n.byteLength,this.bufs.unshift(...n.bufs);else throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");this.length+=t}get(e){let t=Xc(this.bufs,e);return t.buf[t.index]}set(e,t){let n=Xc(this.bufs,e);n.buf[n.index]=t}write(e,t=0){if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else if(ms(e))for(let n=0;n<e.length;n++)this.set(t+n,e.get(n));else throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList")}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength){this.bufs=[],this.length=0;return}for(;this.bufs.length>0;)if(e>=this.bufs[0].byteLength)e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift();else{this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}}}slice(e,t){let{bufs:n,length:s}=this._subList(e,t);return _e(n,s)}subarray(e,t){let{bufs:n,length:s}=this._subList(e,t);return n.length===1?n[0]:_e(n,s)}sublist(e,t){let{bufs:n,length:s}=this._subList(e,t),o=new r;return o.length=s,o.bufs=[...n],o}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(e===0&&t===this.length)return{bufs:this.bufs,length:this.length};let n=[],s=0;for(let o=0;o<this.bufs.length;o++){let i=this.bufs[o],a=s,c=a+i.byteLength;if(s=c,e>=c)continue;let u=e>=a&&e<c,l=t>a&&t<=c;if(u&&l){if(e===a&&t===c){n.push(i);break}let f=e-a;n.push(i.subarray(f,f+(t-e)));break}if(u){if(e===0){n.push(i);continue}n.push(i.subarray(e-a));continue}if(l){if(t===c){n.push(i);break}n.push(i.subarray(0,t-a));break}n.push(i)}return{bufs:n,length:t-e}}indexOf(e,t=0){if(!ms(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');let n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),e.length===0)return t>this.length?this.length:t;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 a=i,c=this.byteLength-n.byteLength,u=n.byteLength-1,l;for(let f=t;f<=c;f+=l){l=0;for(let h=u;h>=0;h--){let w=this.get(f+h);if(n[h]!==w){l=Math.max(1,h-a[w]);break}}if(l===0)return f}return-1}getInt8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){let n=Te(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){let s=pe(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt16(0,t,n),this.write(s,e)}getInt32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){let s=pe(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setInt32(0,t,n),this.write(s,e)}getBigInt64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){let s=pe(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigInt64(0,t,n),this.write(s,e)}getUint8(e){let t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){let n=Te(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){let n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){let s=pe(2);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint16(0,t,n),this.write(s,e)}getUint32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){let s=pe(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setUint32(0,t,n),this.write(s,e)}getBigUint64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){let s=pe(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setBigUint64(0,t,n),this.write(s,e)}getFloat32(e,t){let n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){let s=pe(4);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat32(0,t,n),this.write(s,e)}getFloat64(e,t){let n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){let s=pe(8);new DataView(s.buffer,s.byteOffset,s.byteLength).setFloat64(0,t,n),this.write(s,e)}equals(e){if(e==null||!(e instanceof r)||e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!be(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){let n=new r;return n.bufs=e,t==null&&(t=e.reduce((s,o)=>s+o.byteLength,0)),n.length=t,n}};var zr;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{s.lengthDelimited!==!1&&n.fork(),t.publicKey!=null&&t.publicKey.byteLength>0&&(n.uint32(10),n.bytes(t.publicKey)),t.payloadType!=null&&t.payloadType.byteLength>0&&(n.uint32(18),n.bytes(t.payloadType)),t.payload!=null&&t.payload.byteLength>0&&(n.uint32(26),n.bytes(t.payload)),t.signature!=null&&t.signature.byteLength>0&&(n.uint32(42),n.bytes(t.signature)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={publicKey:pe(0),payloadType:pe(0),payload:pe(0),signature:pe(0)},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 1:{o.publicKey=t.bytes();break}case 2:{o.payloadType=t.bytes();break}case 3:{o.payload=t.bytes();break}case 5:{o.signature=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(zr||(zr={}));var ys=class extends Error{constructor(e="Invalid signature"){super(e),this.name="InvalidSignatureError"}};var rt=class r{static createFromProtobuf=async e=>{let t=zr.decode(e),n=gr(t.publicKey);return new r({publicKey:n,payloadType:t.payloadType,payload:t.payload,signature:t.signature})};static seal=async(e,t)=>{if(t==null)throw new Error("Missing private key");let n=e.domain,s=e.codec,o=e.marshal(),i=el(n,s,o),a=await t.sign(i.subarray());return new r({publicKey:t.publicKey,payloadType:s,payload:o,signature:a})};static openAndCertify=async(e,t)=>{let n=await r.createFromProtobuf(e);if(!await n.validate(t))throw new ys("Envelope signature is not valid for the given domain");return n};publicKey;payloadType;payload;signature;marshaled;constructor(e){let{publicKey:t,payloadType:n,payload:s,signature:o}=e;this.publicKey=t,this.payloadType=n,this.payload=s,this.signature=o}marshal(){return this.marshaled==null&&(this.marshaled=zr.encode({publicKey:Tt(this.publicKey),payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return be(this.marshal(),e.marshal())}async validate(e){let t=el(e,this.payloadType,this.payload);return this.publicKey.verify(t.subarray(),this.signature)}},el=(r,e,t)=>{let n=q(r),s=Oe(n.byteLength),o=Oe(e.length),i=Oe(t.length);return new je(s,n,o,e,i,t)};var tl=Symbol.for("nodejs.util.inspect.custom"),rd=114,Gr=class{type;multihash;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[Fs]=!0;toString(){return this.string==null&&(this.string=J.encode(this.multihash.bytes).slice(1)),this.string}toMultihash(){return this.multihash}toCID(){return de.createV1(rd,this.multihash)}toJSON(){return this.toString()}equals(e){if(e==null)return!1;if(e instanceof Uint8Array)return be(this.multihash.bytes,e);if(typeof e=="string")return this.toString()===e;if(e?.toMultihash()?.bytes!=null)return be(this.multihash.bytes,e.toMultihash().bytes);throw new Error("not valid Id")}[tl](){return`PeerId(${this.toString()})`}},Wr=class extends Gr{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}},jr=class extends Gr{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.publicKey}},Zr=class extends Gr{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.publicKey}},nd=2336,Yr=class{type="url";multihash;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=ct.digest(q(this.url))}[tl](){return`PeerId(${this.url})`}[Fs]=!0;toString(){return this.toCID().toString()}toMultihash(){return this.multihash}toCID(){return de.createV1(nd,this.toMultihash())}toJSON(){return this.toString()}equals(e){return e==null?!1:(e instanceof Uint8Array&&(e=F(e)),e.toString()===this.toString())}};var sd=114,rl=2336;function nl(r){if(r.type==="Ed25519")return new jr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="secp256k1")return new Zr({multihash:r.toCID().multihash,publicKey:r});if(r.type==="RSA")return new Wr({multihash:r.toCID().multihash,publicKey:r});throw new Dt}function li(r){if(id(r))return new Wr({multihash:r});if(od(r))try{let e=Jc(r);if(e.type==="Ed25519")return new jr({multihash:r,publicKey:e});if(e.type==="secp256k1")return new Zr({multihash:r,publicKey:e})}catch{let t=F(r.digest);return new Yr(new URL(t))}throw new rn("Supplied PeerID Multihash is invalid")}function bs(r){if(r?.multihash==null||r.version==null||r.version===1&&r.code!==sd&&r.code!==rl)throw new tn("Supplied PeerID CID is invalid");if(r.code===rl){let e=F(r.multihash.digest);return new Yr(new URL(e))}return li(r.multihash)}function od(r){return r.code===ct.code}function id(r){return r.code===Tr.code}function sl(r,e){let t=(n,s)=>n.toString().localeCompare(s.toString());return r.length!==e.length?!1:(e.sort(t),r.sort(t).every((n,s)=>e[s].equals(n)))}var ws=class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){let t=this.index,n=e();return n===void 0&&(this.index=t),n}parseWith(e){let t=e();if(this.index===this.input.length)return t}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(e){return this.readAtomically(()=>{let t=this.readChar();if(t===e)return t})}readSeparator(e,t,n){return this.readAtomically(()=>{if(!(t>0&&this.readGivenChar(e)===void 0))return n()})}readNumber(e,t,n,s){return this.readAtomically(()=>{let o=0,i=0,a=this.peekChar();if(a===void 0)return;let c=a==="0",u=2**(8*s)-1;for(;;){let l=this.readAtomically(()=>{let f=this.readChar();if(f===void 0)return;let h=Number.parseInt(f,e);if(!Number.isNaN(h))return h});if(l===void 0)break;if(o*=e,o+=l,o>u||(i+=1,t!==void 0&&i>t))return}if(i!==0)return!n&&c&&i>1?void 0:o})}readIPv4Addr(){return this.readAtomically(()=>{let e=new Uint8Array(4);for(let t=0;t<e.length;t++){let n=this.readSeparator(".",t,()=>this.readNumber(10,3,!1,1));if(n===void 0)return;e[t]=n}return e})}readIPv6Addr(){let e=t=>{for(let n=0;n<t.length/2;n++){let s=n*2;if(n<t.length-3){let i=this.readSeparator(":",n,()=>this.readIPv4Addr());if(i!==void 0)return t[s]=i[0],t[s+1]=i[1],t[s+2]=i[2],t[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];t[s]=o>>8,t[s+1]=o&255}return[t.length,!1]};return this.readAtomically(()=>{let t=new Uint8Array(16),[n,s]=e(t);if(n===16)return t;if(s||this.readGivenChar(":")===void 0||this.readGivenChar(":")===void 0)return;let o=new Uint8Array(14),i=16-(n+2),[a]=e(o.subarray(0,i));return t.set(o.subarray(0,a),16-a),t})}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};var ol=45,ad=15,mr=new ws;function ui(r){if(!(r.length>ad))return mr.new(r).parseWith(()=>mr.readIPv4Addr())}function fi(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ol))return mr.new(r).parseWith(()=>mr.readIPv6Addr())}function xs(r){if(r.includes("%")&&(r=r.split("%")[0]),!(r.length>ol))return mr.new(r).parseWith(()=>mr.readIPAddr())}var ob=parseInt("0xFFFF",16),ib=new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function vs(r){return!!ui(r)}function Es(r){return!!fi(r)}function Bs(r){return!!xs(r)}var cl=vs,hd=Es,hi=function(r){let e=0;if(r=r.toString().trim(),cl(r)){let t=new Uint8Array(e+4);return r.split(/\./g).forEach(n=>{t[e++]=parseInt(n,10)&255}),t}if(hd(r)){let t=r.split(":",8),n;for(n=0;n<t.length;n++){let o=cl(t[n]),i;o&&(i=hi(t[n]),t[n]=F(i.slice(0,2),"base16")),i!=null&&++n<8&&t.splice(n,0,F(i.slice(2,4),"base16"))}if(t[0]==="")for(;t.length<8;)t.unshift("0");else if(t[t.length-1]==="")for(;t.length<8;)t.push("0");else if(t.length<8){for(n=0;n<t.length&&t[n]!=="";n++);let o=[n,1];for(n=9-t.length;n>0;n--)o.push("0");t.splice.apply(t,o)}let s=new Uint8Array(e+16);for(n=0;n<t.length;n++){let o=parseInt(t[n],16);s[e++]=o>>8&255,s[e++]=o&255}return s}throw new Error("invalid ip address")},ll=function(r,e=0,t){e=~~e,t=t??r.length-e;let n=new DataView(r.buffer);if(t===4){let s=[];for(let o=0;o<t;o++)s.push(r[e+o]);return s.join(".")}if(t===16){let s=[];for(let o=0;o<t;o+=2)s.push(n.getUint16(e+o).toString(16));return s.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""};var yr={},di={},pd=[[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"]];pd.forEach(r=>{let e=gd(...r);di[e.code]=e,yr[e.name]=e});function gd(r,e,t,n,s){return{code:r,size:e,name:t,resolvable:!!n,path:!!s}}function $(r){if(typeof r=="number"){if(di[r]!=null)return di[r];throw new Error(`no protocol with code: ${r}`)}else if(typeof r=="string"){if(yr[r]!=null)return yr[r];throw new Error(`no protocol with name: ${r}`)}throw new Error(`invalid protocol id type: ${typeof r}`)}var qb=$("ip4"),$b=$("ip6"),zb=$("ipcidr");function yi(r,e){switch($(r).code){case 4:case 41:return yd(e);case 42:return mi(e);case 6:case 273:case 33:case 132:return hl(e).toString();case 53:case 54:case 55:case 56:case 400:case 449:case 777:return mi(e);case 421:return vd(e);case 444:return fl(e);case 445:return fl(e);case 466:return xd(e);case 481:return globalThis.encodeURIComponent(mi(e));default:return F(e,"base16")}}function bi(r,e){switch($(r).code){case 4:return ul(e);case 41:return ul(e);case 42:return gi(e);case 6:case 273:case 33:case 132:return wi(parseInt(e,10));case 53:case 54:case 55:case 56:case 400:case 449:case 777:return gi(e);case 421:return bd(e);case 444:return Ed(e);case 445:return Bd(e);case 466:return wd(e);case 481:return gi(globalThis.decodeURIComponent(e));default:return q(e,"base16")}}var pi=Object.values(Ur).map(r=>r.decoder),md=function(){let r=pi[0].or(pi[1]);return pi.slice(2).forEach(e=>r=r.or(e)),r}();function ul(r){if(!Bs(r))throw new Error("invalid ip address");return hi(r)}function yd(r){let e=ll(r,0,r.length);if(e==null)throw new Error("ipBuff is required");if(!Bs(e))throw new Error("invalid ip address");return e}function wi(r){let e=new ArrayBuffer(2);return new DataView(e).setUint16(0,r),new Uint8Array(e)}function hl(r){return new DataView(r.buffer).getUint16(r.byteOffset)}function gi(r){let e=q(r),t=Uint8Array.from(Oe(e.length));return _e([t,e],t.length+e.length)}function mi(r){let e=dt(r);if(r=r.slice(xe(e)),r.length!==e)throw new Error("inconsistent lengths");return F(r)}function bd(r){let e;r[0]==="Q"||r[0]==="1"?e=Mt(J.decode(`z${r}`)).bytes:e=de.parse(r).multihash.bytes;let t=Uint8Array.from(Oe(e.length));return _e([t,e],t.length+e.length)}function wd(r){let e=md.decode(r),t=Uint8Array.from(Oe(e.length));return _e([t,e],t.length+e.length)}function xd(r){let e=dt(r),t=r.slice(xe(e));if(t.length!==e)throw new Error("inconsistent lengths");return"u"+F(t,"base64url")}function vd(r){let e=dt(r),t=r.slice(xe(e));if(t.length!==e)throw new Error("inconsistent lengths");return F(t,"base58btc")}function Ed(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==16)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion address.`);let t=at.decode("b"+e[0]),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=wi(n);return _e([t,s],t.length+s.length)}function Bd(r){let e=r.split(":");if(e.length!==2)throw new Error(`failed to parse onion addr: ["'${e.join('", "')}'"]' does not contain a port number`);if(e[0].length!==56)throw new Error(`failed to parse onion addr: ${e[0]} not a Tor onion3 address.`);let t=at.decode(`b${e[0]}`),n=parseInt(e[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");let s=wi(n);return _e([t,s],t.length+s.length)}function fl(r){let e=r.slice(0,r.length-2),t=r.slice(r.length-2),n=F(e,"base32"),s=hl(t);return`${n}:${s}`}function dl(r){r=xi(r);let e=[],t=[],n=null,s=r.split("/").slice(1);if(s.length===1&&s[0]==="")return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let o=0;o<s.length;o++){let i=s[o],a=$(i);if(a.size===0){e.push([a.code]),t.push([a.code]);continue}if(o++,o>=s.length)throw gl("invalid address: "+r);if(a.path===!0){n=xi(s.slice(o).join("/")),e.push([a.code,bi(a.code,n)]),t.push([a.code,n]);break}let c=bi(a.code,s[o]);e.push([a.code,c]),t.push([a.code,yi(a.code,c)])}return{string:pl(t),bytes:Ei(e),tuples:e,stringTuples:t,path:n}}function vi(r){let e=[],t=[],n=null,s=0;for(;s<r.length;){let o=dt(r,s),i=xe(o),a=$(o),c=Ad(a,r.slice(s+i));if(c===0){e.push([o]),t.push([o]),s+=i;continue}let u=r.slice(s+i,s+i+c);if(s+=c+i,s>r.length)throw gl("Invalid address Uint8Array: "+F(r,"base16"));e.push([o,u]);let l=yi(o,u);if(t.push([o,l]),a.path===!0){n=l;break}}return{bytes:Uint8Array.from(r),string:pl(t),tuples:e,stringTuples:t,path:n}}function pl(r){let e=[];return r.map(t=>{let n=$(t[0]);return e.push(n.name),t.length>1&&t[1]!=null&&e.push(t[1]),null}),xi(e.join("/"))}function Ei(r){return _e(r.map(e=>{let t=$(e[0]),n=Uint8Array.from(Oe(t.code));return e.length>1&&e[1]!=null&&(n=_e([n,e[1]])),n}))}function Ad(r,e){if(r.size>0)return r.size/8;if(r.size===0)return 0;{let t=dt(e instanceof Uint8Array?e:Uint8Array.from(e));return t+xe(t)}}function xi(r){return"/"+r.trim().split("/").filter(e=>e).join("/")}function gl(r){return new Error("Error parsing address: "+r)}var Sd=Symbol.for("nodejs.util.inspect.custom"),Ai=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Id=[$("dns").code,$("dns4").code,$("dns6").code,$("dnsaddr").code],Bi=class extends Error{constructor(e="No available resolver"){super(e),this.name="NoAvailableResolverError"}},As=class r{bytes;#t;#e;#r;#n;[Ai]=!0;constructor(e){e==null&&(e="");let t;if(e instanceof Uint8Array)t=vi(e);else if(typeof e=="string"){if(e.length>0&&e.charAt(0)!=="/")throw new Error(`multiaddr "${e}" must start with a "/"`);t=dl(e)}else if(yl(e))t=vi(e.bytes);else throw new Error("addr must be a string, Buffer, or another Multiaddr");this.bytes=t.bytes,this.#t=t.string,this.#e=t.tuples,this.#r=t.stringTuples,this.#n=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,s,o="",i=$("tcp"),a=$("udp"),c=$("ip4"),u=$("ip6"),l=$("dns6"),f=$("ip6zone");for(let[w,m]of this.stringTuples())w===f.code&&(o=`%${m??""}`),Id.includes(w)&&(t=i.name,s=443,n=`${m??""}${o}`,e=w===l.code?6:4),(w===i.code||w===a.code)&&(t=$(w).name,s=parseInt(m??"")),(w===c.code||w===u.code)&&(t=$(w).name,n=`${m??""}${o}`,e=w===u.code?6:4);if(e==null||t==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:e,host:n,transport:t,port:s}}protos(){return this.#e.map(([e])=>Object.assign({},$(e)))}protoCodes(){return this.#e.map(([e])=>e)}protoNames(){return this.#e.map(([e])=>$(e).name)}tuples(){return this.#e}stringTuples(){return this.#r}encapsulate(e){return e=new r(e),new r(this.toString()+e.toString())}decapsulate(e){let t=e.toString(),n=this.toString(),s=n.lastIndexOf(t);if(s<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new r(n.slice(0,s))}decapsulateCode(e){let t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new r(Ei(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach(([n,s])=>{n===yr.p2p.code&&e.push([n,s]),n===yr["p2p-circuit"].code&&(e=[])});let t=e.pop();if(t?.[1]!=null){let n=t[1];return n[0]==="Q"||n[0]==="1"?F(J.decode(`z${n}`),"base58btc"):F(de.parse(n).multihash.bytes,"base58btc")}return null}catch{return null}}getPath(){return this.#n}equals(e){return be(this.bytes,e.bytes)}async resolve(e){let t=this.protos().find(o=>o.resolvable);if(t==null)return[this];let n=ml.get(t.name);if(n==null)throw new Bi(`no available resolver for ${t.name}`);return(await n(this,e)).map(o=>nt(o))}nodeAddress(){let e=this.toOptions();if(e.transport!=="tcp"&&e.transport!=="udp")throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){let t=(e??this).protos();return!(t.length!==2||t[0].code!==4&&t[0].code!==41||t[1].code!==6&&t[1].code!==273)}[Sd](){return`Multiaddr(${this.#t})`}};var ml=new Map;function yl(r){return!!r?.[Ai]}function nt(r){return new As(r)}var bl="libp2p-peer-record",wl=Uint8Array.from([3,1]);var Jr;(function(r){let e;(function(n){let s;n.codec=()=>(s==null&&(s=Ge((o,i,a={})=>{a.lengthDelimited!==!1&&i.fork(),o.multiaddr!=null&&o.multiaddr.byteLength>0&&(i.uint32(10),i.bytes(o.multiaddr)),a.lengthDelimited!==!1&&i.ldelim()},(o,i,a={})=>{let c={multiaddr:pe(0)},u=i==null?o.len:o.pos+i;for(;o.pos<u;){let l=o.uint32();switch(l>>>3){case 1:{c.multiaddr=o.bytes();break}default:{o.skipType(l&7);break}}}return c})),s),n.encode=o=>ze(o,n.codec()),n.decode=(o,i)=>$e(o,n.codec(),i)})(e=r.AddressInfo||(r.AddressInfo={}));let t;r.codec=()=>(t==null&&(t=Ge((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:pe(0),seq:0n,addresses:[]},a=s==null?n.len:n.pos+s;for(;n.pos<a;){let c=n.uint32();switch(c>>>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 jt('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(c&7);break}}}return i})),t),r.encode=n=>ze(n,r.codec()),r.decode=(n,s)=>$e(n,r.codec(),s)})(Jr||(Jr={}));var Ze=class r{static createFromProtobuf=e=>{let t=Jr.decode(e),n=li(Mt(t.peerId)),s=(t.addresses??[]).map(i=>nt(i.multiaddr)),o=t.seq;return new r({peerId:n,multiaddrs:s,seqNumber:o})};static DOMAIN=bl;static CODEC=wl;peerId;multiaddrs;seqNumber;domain=r.DOMAIN;codec=r.CODEC;marshaled;constructor(e){let{peerId:t,multiaddrs:n,seqNumber:s}=e;this.peerId=t,this.multiaddrs=n??[],this.seqNumber=s??BigInt(Date.now())}marshal(){return this.marshaled==null&&(this.marshaled=Jr.encode({peerId:this.peerId.toMultihash().bytes,seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map(e=>({multiaddr:e.bytes}))})),this.marshaled}equals(e){return!(!(e instanceof r)||!this.peerId.equals(e.peerId)||this.seqNumber!==e.seqNumber||!sl(this.multiaddrs,e.multiaddrs))}};function kd(r){return r[Symbol.asyncIterator]!=null}function Nd(r){if(kd(r))return(async()=>{for await(let e of r);})();for(let e of r);}var xl=Nd;function Ye(){let r={};return r.promise=new Promise((e,t)=>{r.resolve=e,r.reject=t}),r}var Ss=globalThis.CustomEvent??Event;async function*Si(r,e={}){let t=e.concurrency??1/0;t<1&&(t=1/0);let n=e.ordered==null?!1:e.ordered,s=new EventTarget,o=[],i=Ye(),a=Ye(),c=!1,u,l=!1;s.addEventListener("task-complete",()=>{a.resolve()}),Promise.resolve().then(async()=>{try{for await(let m of r){if(o.length===t&&(i=Ye(),await i.promise),l)break;let y={done:!1};o.push(y),m().then(d=>{y.done=!0,y.ok=!0,y.value=d,s.dispatchEvent(new Ss("task-complete"))},d=>{y.done=!0,y.err=d,s.dispatchEvent(new Ss("task-complete"))})}c=!0,s.dispatchEvent(new Ss("task-complete"))}catch(m){u=m,s.dispatchEvent(new Ss("task-complete"))}});function f(){return n?o[0]?.done:!!o.find(m=>m.done)}function*h(){for(;o.length>0&&o[0].done;){let m=o[0];if(o.shift(),m.ok)yield m.value;else throw l=!0,i.resolve(),m.err;i.resolve()}}function*w(){for(;f();)for(let m=0;m<o.length;m++)if(o[m].done){let y=o[m];if(o.splice(m,1),m--,y.ok)yield y.value;else throw l=!0,i.resolve(),y.err;i.resolve()}}for(;;){if(f()||(a=Ye(),await a.promise),u!=null)throw u;if(n?yield*h():yield*w(),c&&o.length===0)break}}var Is=class extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}};async function vl(r,e,t){if(e==null)return r;if(e.aborted)return Promise.reject(new Is(t?.errorMessage,t?.errorCode,t?.errorName));let n,s=new Is(t?.errorMessage,t?.errorCode,t?.errorName);try{return await Promise.race([r,new Promise((o,i)=>{n=()=>{i(s)},e.addEventListener("abort",n)})])}finally{n!=null&&e.removeEventListener("abort",n)}}var Ii=class{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Ye(),this.haveNext=Ye()}[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 e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=Ye(),e}async throw(e){return this.ended=!0,e!=null&&(this.haveNext.promise.catch(()=>{}),this.haveNext.reject(e)),{done:!0,value:void 0}}async return(){let e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){e!=null?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(e!=null&&this.ended)throw new Error("Cannot push value onto an ended pushable");for(;this.nextResult!=null;)await this.readNext.promise;e!=null?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Ye(),await vl(this.readNext.promise,t?.signal,t)}};function El(){return new Ii}var ks=class extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"};var ki=class extends Error{code;constructor(e,t){super(e),this.code=t}},Ni=class extends ki{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}};function Bl(r,e){let t=El();r.sink(t).catch(async i=>{await t.end(i)}),r.sink=async i=>{for await(let a of i)await t.push(a);await t.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 je;return{read:async(i,a)=>{a?.signal?.throwIfAborted();let c,u=new Promise((l,f)=>{c=()=>{f(new Ni("Read aborted"))},a?.signal?.addEventListener("abort",c)});try{if(i==null){let{done:f,value:h}=await Promise.race([n.next(),u]);return f===!0?new je:h}for(;s.byteLength<i;){let{value:f,done:h}=await Promise.race([n.next(),u]);if(h===!0)throw new ks("unexpected end of input");s.append(f)}let l=s.sublist(0,i);return s.consume(i),l}finally{c!=null&&a?.signal?.removeEventListener("abort",c)}},write:async(i,a)=>{a?.signal?.throwIfAborted(),i instanceof Uint8Array?await t.push(i,a):await t.push(i.subarray(),a)},unwrap:()=>{if(s.byteLength>0){let i=r.source;r.source=async function*(){e?.yieldBytes===!1?yield s:yield*s,yield*i}()}return r}}}var Ns=class extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"},Cs=class extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"},Ts=class extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"};function Al(r,e={}){let t=Bl(r,e);e.maxDataLength!=null&&e.maxLengthLength==null&&(e.maxLengthLength=xe(e.maxDataLength));let n=e?.lengthDecoder??dt,s=e?.lengthEncoder??Oe;return{read:async i=>{let a=-1,c=new je;for(;;){c.append(await t.read(1,i));try{a=n(c)}catch(u){if(u instanceof RangeError)continue;throw u}if(a<0)throw new Ns("Invalid message length");if(e?.maxLengthLength!=null&&c.byteLength>e.maxLengthLength)throw new Ts("message length length too long");if(a>-1)break}if(e?.maxDataLength!=null&&a>e.maxDataLength)throw new Cs("message length too long");return t.read(a,i)},write:async(i,a)=>{await t.write(new je(s(i.byteLength),i),a)},writeV:async(i,a)=>{let c=new je(...i.flatMap(u=>[s(u.byteLength),u]));await t.write(c,a)},unwrap:()=>t.unwrap()}}function br(r,e){let t=Al(r,e),n={read:async(s,o)=>{let i=await t.read(o);return s.decode(i)},write:async(s,o,i)=>{await t.write(o.encode(s),i)},writeV:async(s,o,i)=>{await t.writeV(s.map(a=>o.encode(a)),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:()=>t.unwrap()};return n}var Sl="0.1.0",Il="id",kl="id/push",Nl="1.0.0",Cl="1.0.0";var Pt;(function(r){let e;r.codec=()=>(e==null&&(e=Ge((t,n,s={})=>{if(s.lengthDelimited!==!1&&n.fork(),t.protocolVersion!=null&&(n.uint32(42),n.string(t.protocolVersion)),t.agentVersion!=null&&(n.uint32(50),n.string(t.agentVersion)),t.publicKey!=null&&(n.uint32(10),n.bytes(t.publicKey)),t.listenAddrs!=null)for(let o of t.listenAddrs)n.uint32(18),n.bytes(o);if(t.observedAddr!=null&&(n.uint32(34),n.bytes(t.observedAddr)),t.protocols!=null)for(let o of t.protocols)n.uint32(26),n.string(o);t.signedPeerRecord!=null&&(n.uint32(66),n.bytes(t.signedPeerRecord)),s.lengthDelimited!==!1&&n.ldelim()},(t,n,s={})=>{let o={listenAddrs:[],protocols:[]},i=n==null?t.len:t.pos+n;for(;t.pos<i;){let a=t.uint32();switch(a>>>3){case 5:{o.protocolVersion=t.string();break}case 6:{o.agentVersion=t.string();break}case 1:{o.publicKey=t.bytes();break}case 2:{if(s.limits?.listenAddrs!=null&&o.listenAddrs.length===s.limits.listenAddrs)throw new jt('Decode error - map field "listenAddrs" had too many elements');o.listenAddrs.push(t.bytes());break}case 4:{o.observedAddr=t.bytes();break}case 3:{if(s.limits?.protocols!=null&&o.protocols.length===s.limits.protocols)throw new jt('Decode error - map field "protocols" had too many elements');o.protocols.push(t.string());break}case 8:{o.signedPeerRecord=t.bytes();break}default:{t.skipType(a&7);break}}}return o})),e),r.encode=t=>ze(t,r.codec()),r.decode=(t,n)=>$e(t,r.codec(),n)})(Pt||(Pt={}));var Ll=zi(Ul(),1),Ci=typeof window=="object"&&typeof document=="object"&&document.nodeType===9,Us=(0,Ll.default)(),Rl=Ci&&!Us,_l=Us&&!Ci,Ol=Us&&Ci,Vl=typeof globalThis.process<"u"&&typeof globalThis.process.release<"u"&&globalThis.process.release.name==="node"&&!Us,Pl=typeof importScripts=="function"&&typeof self<"u"&&typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,Xw=typeof globalThis.process<"u"&&typeof globalThis.process.env<"u"&&globalThis.process.env["NODE"+"_"+"ENV"]==="test",Dl=typeof navigator<"u"&&navigator.product==="ReactNative";var Le={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnLimitedConnection:!0,concurrency:32};function Ml(r){if(r!=null&&r.length>0)try{return nt(r)}catch{}}function Ld(r,e){return e!=null||(e=`${r.name}/${r.version}`,Vl||_l?e+=` UserAgent=${globalThis.process.version}`:(Rl||Pl||Ol||Dl)&&(e+=` UserAgent=${globalThis.navigator.userAgent}`)),e}async function Ls(r,e,t,n,s){if(t("received identify from %p",n.remotePeer),s==null)throw new De("message was null or undefined");let o={};if(s.listenAddrs.length>0&&(o.addresses=s.listenAddrs.map(c=>({isCertified:!1,multiaddr:nt(c)}))),s.protocols.length>0&&(o.protocols=s.protocols),s.publicKey!=null){let c=gr(s.publicKey);if(!nl(c).equals(n.remotePeer))throw new De("public key did not match remote PeerId");o.publicKey=c}let i;if(s.signedPeerRecord!=null){t("received signedPeerRecord from %p",n.remotePeer);let c=s.signedPeerRecord,u=await rt.openAndCertify(c,Ze.DOMAIN),l=Ze.createFromProtobuf(u.payload),f=bs(u.publicKey.toCID());if(!l.peerId.equals(f))throw new De("signing key does not match PeerId in the PeerRecord");if(!n.remotePeer.equals(l.peerId))throw new De("signing key does not match remote PeerId");let h;try{h=await r.get(l.peerId)}catch(w){if(w.name!=="NotFoundError")throw w}if(h!=null&&(o.metadata=h.metadata,h.peerRecordEnvelope!=null)){let w=await rt.createFromProtobuf(h.peerRecordEnvelope),m=Ze.createFromProtobuf(w.payload);m.seqNumber>=l.seqNumber&&(t("sequence number was lower or equal to existing sequence number - stored: %d received: %d",m.seqNumber,l.seqNumber),l=m,c=h.peerRecordEnvelope)}o.peerRecordEnvelope=c,o.addresses=l.multiaddrs.map(w=>({isCertified:!0,multiaddr:w})),i={seq:l.seqNumber,addresses:l.multiaddrs}}else t("%p did not send a signed peer record",n.remotePeer);if(t("patching %p with",n.remotePeer,o),await r.patch(n.remotePeer,o),s.agentVersion!=null||s.protocolVersion!=null){let c={};s.agentVersion!=null&&(c.AgentVersion=q(s.agentVersion)),s.protocolVersion!=null&&(c.ProtocolVersion=q(s.protocolVersion)),t("merging %p metadata",n.remotePeer,c),await r.merge(n.remotePeer,{metadata:c})}let a={peerId:n.remotePeer,protocolVersion:s.protocolVersion,agentVersion:s.agentVersion,publicKey:s.publicKey,listenAddrs:s.listenAddrs.map(c=>nt(c)),observedAddr:s.observedAddr==null?void 0:nt(s.observedAddr),protocols:s.protocols,signedPeerRecord:i,connection:n};return e.safeDispatchEvent("peer:identify",{detail:a}),a}var wr=class{host;protocol;started;timeout;peerId;privateKey;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnLimitedConnection;log;constructor(e,t){this.protocol=t.protocol,this.started=!1,this.peerId=e.peerId,this.privateKey=e.privateKey,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.events=e.events,this.log=t.log,this.timeout=t.timeout??Le.timeout,this.maxInboundStreams=t.maxInboundStreams??Le.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Le.maxOutboundStreams,this.maxMessageSize=t.maxMessageSize??Le.maxMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Le.maxObservedAddresses,this.runOnLimitedConnection=t.runOnLimitedConnection??Le.runOnLimitedConnection,this.host={protocolVersion:`${t.protocolPrefix??Le.protocolPrefix}/${Sl}`,agentVersion:Ld(e.nodeInfo,t.agentVersion)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:q(this.host.agentVersion),ProtocolVersion:q(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,e=>{this.handleProtocol(e).catch(t=>{this.log.error(t)})},{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnLimitedConnection:this.runOnLimitedConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}};var Rs=class extends wr{connectionManager;concurrency;constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Le.protocolPrefix}/${kl}/${Cl}`,log:e.logger.forComponent("libp2p:identify-push")}),this.connectionManager=e.connectionManager,this.concurrency=t.concurrency??Le.concurrency,(t.runOnSelfUpdate??Le.runOnSelfUpdate)&&e.events.addEventListener("self:peer:update",n=>{this.push().catch(s=>{this.log.error(s)})})}[nn]=["@libp2p/identify-push"];async push(){if(!this.isStarted())return;let e=this.addressManager.getAddresses().map(l=>l.decapsulateCode($("p2p").code)),t=new Ze({peerId:this.peerId,multiaddrs:e}),n=await rt.seal(t,this.privateKey),s=this.registrar.getProtocols(),o=await this.peerStore.get(this.peerId),i=F(o.metadata.get("AgentVersion")??q(this.host.agentVersion)),a=F(o.metadata.get("ProtocolVersion")??q(this.host.protocolVersion)),c=this;async function*u(){for(let l of c.connectionManager.getConnections())(await c.peerStore.get(l.remotePeer)).protocols.includes(c.protocol)&&(yield async()=>{let h,w=AbortSignal.timeout(c.timeout);Er(1/0,w);try{h=await l.newStream(c.protocol,{signal:w,runOnLimitedConnection:c.runOnLimitedConnection}),await br(h,{maxDataLength:c.maxMessageSize}).pb(Pt).write({listenAddrs:e.map(y=>y.bytes),signedPeerRecord:n.marshal(),protocols:s,agentVersion:i,protocolVersion:a},{signal:w}),await h.close({signal:w})}catch(m){c.log.error("could not push identify update to peer",m),h?.abort(m)}})}await xl(Si(u(),{concurrency:this.concurrency}))}async handleProtocol(e){let{connection:t,stream:n}=e;try{if(this.peerId.equals(t.remotePeer))throw new Error("received push from ourselves?");let s={signal:AbortSignal.timeout(this.timeout)},i=await br(n,{maxDataLength:this.maxMessageSize}).pb(Pt).read(s);await n.close(s),await Ls(this.peerStore,this.events,this.log,t,i)}catch(s){this.log.error("received invalid message",s),n.abort(s);return}this.log("handled push from %p",t.remotePeer)}};var Rd=r=>r.toString().split("/").slice(1),Xr=r=>({match:e=>e.length<1?!1:r(e[0])?e.slice(1):!1,pattern:"fn"}),z=r=>({match:e=>Xr(t=>t===r).match(e),pattern:r}),Vs=()=>({match:r=>Xr(e=>typeof e=="string").match(r),pattern:"{string}"}),Ps=()=>({match:r=>Xr(e=>!isNaN(parseInt(e))).match(r),pattern:"{number}"}),ye=()=>({match:r=>{if(r.length<2||r[0]!=="p2p"&&r[0]!=="ipfs")return!1;if(r[1].startsWith("Q")||r[1].startsWith("1"))try{J.decode(`z${r[1]}`)}catch{return!1}else return!1;return r.slice(2)},pattern:"/p2p/{peerid}"}),_s=()=>({match:r=>{if(r.length<2||r[0]!=="certhash")return!1;try{Lo.decode(r[1])}catch{return!1}return r.slice(2)},pattern:"/certhash/{certhash}"}),ce=r=>({match:e=>{let t=r.match(e);return t===!1?e:t},pattern:`optional(${r.pattern})`}),Pe=(...r)=>({match:e=>{let t;for(let n of r){let s=n.match(e);s!==!1&&(t==null||s.length<t.length)&&(t=s)}return t??!1},pattern:`or(${r.map(e=>e.pattern).join(", ")})`}),Z=(...r)=>({match:e=>{for(let t of r){let n=t.match(e);if(n===!1)return!1;e=n}return e},pattern:`and(${r.map(e=>e.pattern).join(", ")})`});function re(...r){function e(s){let o=Rd(s);for(let i of r){let a=i.match(o);if(a===!1)return!1;o=a}return o}function t(s){return e(s)!==!1}function n(s){let o=e(s);return o===!1?!1:o.length===0}return{matches:t,exactMatch:n}}var Ui=Z(z("dns4"),Vs()),Li=Z(z("dns6"),Vs()),Ri=Z(z("dnsaddr"),Vs()),Hl=Z(z("dns"),Vs()),Sx=re(Ui),Ix=re(Li),kx=re(Ri),Nx=re(Pe(Hl,Ri,Ui,Li)),Fl=Z(z("ip4"),Xr(vs)),Kl=Z(z("ip6"),Xr(Es)),ql=Pe(Fl,Kl),st=Pe(ql,Hl,Ui,Li,Ri),$l=re(st),Cx=re(Fl),Tx=re(Kl),Ux=re(ql),_i=Z(st,z("tcp"),Ps()),Qr=Z(st,z("udp"),Ps()),Lx=re(_i),Rx=re(Qr),Oi=Z(Qr,z("quic")),Ds=Z(Qr,z("quic-v1")),_d=Pe(Oi,Ds),_x=re(Oi),Ox=re(Ds),Ti=Pe(st,_i,Qr,Oi,Ds),zl=Pe(Z(Ti,z("ws"),ce(ye()))),Vx=re(zl),Gl=Pe(Z(Ti,z("wss"),ce(ye())),Z(Ti,z("tls"),z("ws"),ce(ye()))),Px=re(Gl),Wl=Z(Qr,z("webrtc-direct"),ce(_s()),ce(_s()),ce(ye())),Dx=re(Wl),jl=Z(Ds,z("webtransport"),ce(_s()),ce(_s()),ce(ye())),Mx=re(jl),Os=Pe(zl,Gl,Z(_i,ce(ye())),Z(_d,ce(ye())),Z(st,ce(ye())),Wl,jl,ye()),Hx=re(Os),Od=Z(Os,z("p2p-circuit"),ye()),Fx=re(Od),Vd=Pe(Z(Os,z("p2p-circuit"),z("webrtc"),ce(ye())),Z(Os,z("webrtc"),ce(ye())),z("webrtc")),Kx=re(Vd),Pd=Pe(Z(st,z("tcp"),Ps(),z("http"),ce(ye())),Z(st,z("http"),ce(ye()))),qx=re(Pd),Dd=Pe(Z(st,z("tcp"),Pe(Z(z("443"),z("http")),Z(Ps(),z("https"))),ce(ye())),Z(st,z("tls"),z("http"),ce(ye())),Z(st,z("https"),ce(ye()))),$x=re(Dd);var Ms=class extends wr{constructor(e,t={}){super(e,{...t,protocol:`/${t.protocolPrefix??Le.protocolPrefix}/${Il}/${Nl}`,log:e.logger.forComponent("libp2p:identify")}),(t.runOnConnectionOpen??Le.runOnConnectionOpen)&&e.events.addEventListener("connection:open",n=>{let s=n.detail;this.identify(s).catch(o=>{this.log.error("error during identify trigged by connection:open",o)})})}[nn]=["@libp2p/identify"];async _identify(e,t={}){let n;if(t.signal==null){let s=AbortSignal.timeout(this.timeout);Er(1/0,s),t={...t,signal:s}}try{n=await e.newStream(this.protocol,{...t,runOnLimitedConnection:this.runOnLimitedConnection});let o=await br(n,{maxDataLength:this.maxMessageSize}).pb(Pt).read(t);return await n.close(t),o}catch(s){throw this.log.error("error while reading identify message",s),n?.abort(s),s}}async identify(e,t={}){let n=await this._identify(e,t),{publicKey:s,protocols:o,observedAddr:i}=n;if(s==null)throw new De("public key was missing from identify message");let a=gr(s),c=bs(a.toCID());if(!e.remotePeer.equals(c))throw new De("identified peer does not match the expected peer");if(this.peerId.equals(c))throw new De("identified peer is our own peer id?");let u=Ml(i);return this.log("identify completed for peer %p and protocols %o",c,o),this.log("our observed address is %a",u),u!=null&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address %a",u),this.addressManager.addObservedAddr(u)),Ls(this.peerStore,this.events,this.log,e,n)}async handleProtocol(e){let{connection:t,stream:n}=e,s=AbortSignal.timeout(this.timeout);Er(1/0,s);try{let o=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map(l=>l.decapsulateCode($("p2p").code)),a=o.peerRecordEnvelope;if(i.length>0&&a==null){let l=new Ze({peerId:this.peerId,multiaddrs:i});a=(await rt.seal(l,this.privateKey)).marshal().subarray()}let c=t.remoteAddr.bytes;$l.matches(t.remoteAddr)||(c=void 0),await br(n).pb(Pt).write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:Tt(this.privateKey.publicKey),listenAddrs:i.map(l=>l.bytes),signedPeerRecord:a,observedAddr:c,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 Md(r={}){return e=>new Ms(e,r)}function Hd(r={}){return e=>new Rs(e,r)}return cu(Fd);})();
|
|
7
7
|
/*! Bundled license information:
|
|
8
8
|
|
|
9
9
|
pvtsutils/build/index.js:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/identify",
|
|
3
|
-
"version": "2.1.5-
|
|
3
|
+
"version": "2.1.5-e1ca9cced",
|
|
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,11 +52,11 @@
|
|
|
52
52
|
"doc-check": "aegir doc-check"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@libp2p/crypto": "4.1.9-
|
|
56
|
-
"@libp2p/interface": "1.7.0-
|
|
57
|
-
"@libp2p/interface-internal": "1.3.4-
|
|
58
|
-
"@libp2p/peer-id": "4.2.4-
|
|
59
|
-
"@libp2p/peer-record": "7.0.25-
|
|
55
|
+
"@libp2p/crypto": "4.1.9-e1ca9cced",
|
|
56
|
+
"@libp2p/interface": "1.7.0-e1ca9cced",
|
|
57
|
+
"@libp2p/interface-internal": "1.3.4-e1ca9cced",
|
|
58
|
+
"@libp2p/peer-id": "4.2.4-e1ca9cced",
|
|
59
|
+
"@libp2p/peer-record": "7.0.25-e1ca9cced",
|
|
60
60
|
"@multiformats/multiaddr": "^12.2.3",
|
|
61
61
|
"@multiformats/multiaddr-matcher": "^1.2.1",
|
|
62
62
|
"it-drain": "^3.0.7",
|
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
"wherearewe": "^2.0.1"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@libp2p/interface-compliance-tests": "5.4.12-
|
|
72
|
-
"@libp2p/logger": "4.0.20-
|
|
71
|
+
"@libp2p/interface-compliance-tests": "5.4.12-e1ca9cced",
|
|
72
|
+
"@libp2p/logger": "4.0.20-e1ca9cced",
|
|
73
73
|
"aegir": "^44.0.1",
|
|
74
74
|
"delay": "^6.0.0",
|
|
75
75
|
"it-length-prefixed": "^9.0.4",
|