libp2p 1.8.1-a82ff8221 → 1.8.1-a8ec2bcb7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2P = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2P=(()=>{var cp=Object.create;var Bo=Object.defineProperty;var lp=Object.getOwnPropertyDescriptor;var up=Object.getOwnPropertyNames;var fp=Object.getPrototypeOf,hp=Object.prototype.hasOwnProperty;var et=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ve=(r,e)=>{for(var t in e)Bo(r,t,{get:e[t],enumerable:!0})},Ql=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of up(e))!hp.call(r,o)&&o!==t&&Bo(r,o,{get:()=>e[o],enumerable:!(n=lp(e,o))||n.enumerable});return r};var St=(r,e,t)=>(t=r!=null?cp(fp(r)):{},Ql(e||!r||!r.__esModule?Bo(t,"default",{value:r,enumerable:!0}):t,r)),dp=r=>Ql(Bo({},"__esModule",{value:!0}),r);var rf=et(on=>{"use strict";var qg="[object ArrayBuffer]",Dt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===qg}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),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==o[s])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 o=new Uint8Array(n),s=0;for(let i of t){let a=this.toUint8Array(i);o.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},ic="string",$g=/^[0-9a-f]+$/i,zg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Gg=/^[a-zA-Z0-9-_]+$/,Zo=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Dt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}},nt=class{static toString(e,t=!1){let n=Dt.toArrayBuffer(e),o=new DataView(n),s="";for(let i=0;i<n.byteLength;i+=2){let a=o.getUint16(i,t);s+=String.fromCharCode(a)}return s}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let s=0;s<e.length;s++)o.setUint16(s*2,e.charCodeAt(s),t);return n}},Qo=class r{static isHex(e){return typeof e===ic&&$g.test(e)}static isBase64(e){return typeof e===ic&&zg.test(e)}static isBase64Url(e){return typeof e===ic&&Gg.test(e)}static ToString(e,t="utf8"){let n=Dt.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 nt.toString(n,!0);case"utf16":case"utf16be":return nt.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 nt.fromString(e,!0);case"utf16":case"utf16be":return nt.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Dt.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 Zo.fromString(e);case"utf16":case"utf16be":return nt.fromString(e);case"utf16le":case"usc2":return nt.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 Zo.toString(e);case"utf16":case"utf16be":return nt.toString(e);case"utf16le":case"usc2":return nt.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 o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Dt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Dt.toUint8Array(e),n="",o=t.length;for(let s=0;s<o;s++){let i=t[s];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 o=0;o<t.length;o=o+2){let s=t.slice(o,o+2);n[o/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return nt.toString(e,t)}static FromUtf16String(e,t=!1){return nt.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,"")||""}};Qo.DEFAULT_UTF8_ENCODING="utf8";function Yg(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let s in o)t[s]=o[s]}return t}function Wg(...r){let e=r.map(o=>o.byteLength).reduce((o,s)=>o+s),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let s of o)t[n++]=s}),t.buffer}function jg(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}on.BufferSourceConverter=Dt;on.Convert=Qo;on.assign=Yg;on.combine=Wg;on.isEqual=jg});var hh=et((ov,fh)=>{var un=1e3,fn=un*60,hn=fn*60,Ir=hn*24,B0=Ir*7,T0=Ir*365.25;fh.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return C0(r);if(t==="number"&&isFinite(r))return e.long?N0(r):k0(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function C0(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*T0;case"weeks":case"week":case"w":return t*B0;case"days":case"day":case"d":return t*Ir;case"hours":case"hour":case"hrs":case"hr":case"h":return t*hn;case"minutes":case"minute":case"mins":case"min":case"m":return t*fn;case"seconds":case"second":case"secs":case"sec":case"s":return t*un;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function k0(r){var e=Math.abs(r);return e>=Ir?Math.round(r/Ir)+"d":e>=hn?Math.round(r/hn)+"h":e>=fn?Math.round(r/fn)+"m":e>=un?Math.round(r/un)+"s":r+"ms"}function N0(r){var e=Math.abs(r);return e>=Ir?Vs(r,e,Ir,"day"):e>=hn?Vs(r,e,hn,"hour"):e>=fn?Vs(r,e,fn,"minute"):e>=un?Vs(r,e,un,"second"):r+" ms"}function Vs(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var ph=et((sv,dh)=>{function L0(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=o,t.enabled=i,t.humanize=hh(),t.destroy=u,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let l=0;for(let p=0;p<f.length;p++)l=(l<<5)-l+f.charCodeAt(p),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(f){let l,p=null,h,d;function m(...y){if(!m.enabled)return;let g=m,w=Number(new Date),b=w-(l||w);g.diff=b,g.prev=l,g.curr=w,l=w,y[0]=t.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let x=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(S,_)=>{if(S==="%%")return"%";x++;let R=t.formatters[_];if(typeof R=="function"){let q=y[x];S=R.call(g,q),y.splice(x,1),x--}return S}),t.formatArgs.call(g,y),(g.log||t.log).apply(g,y)}return m.namespace=f,m.useColors=t.useColors(),m.color=t.selectColor(f),m.extend=n,m.destroy=t.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(h!==t.namespaces&&(h=t.namespaces,d=t.enabled(f)),d),set:y=>{p=y}}),typeof t.init=="function"&&t.init(m),m}function n(f,l){let p=t(this.namespace+(typeof l>"u"?":":l)+f);return p.log=this.log,p}function o(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let l,p=(typeof f=="string"?f:"").split(/[\s,]+/),h=p.length;for(l=0;l<h;l++)p[l]&&(f=p[l].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function s(){let f=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),f}function i(f){if(f[f.length-1]==="*")return!0;let l,p;for(l=0,p=t.skips.length;l<p;l++)if(t.skips[l].test(f))return!1;for(l=0,p=t.names.length;l<p;l++)if(t.names[l].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}dh.exports=L0});var mh=et((je,Ks)=>{je.formatArgs=P0;je.save=O0;je.load=U0;je.useColors=D0;je.storage=M0();je.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();je.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function D0(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function P0(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Ks.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}je.log=console.debug||console.log||(()=>{});function O0(r){try{r?je.storage.setItem("debug",r):je.storage.removeItem("debug")}catch{}}function U0(){let r;try{r=je.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function M0(){try{return localStorage}catch{}}Ks.exports=ph()(je);var{formatters:F0}=Ks.exports;F0.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Eh=et((ao,qs)=>{(function(r,e){"use strict";var t={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(h){if(!Array.isArray(h)&&!ArrayBuffer.isView(h))return!1;for(var d=0;d<h.length;d++)if(!Number.isInteger(h[d])||h[d]<0||h[d]>255)return!1;return!0}function o(h,d){return(h&65535)*d+(((h>>>16)*d&65535)<<16)}function s(h,d){return h<<d|h>>>32-d}function i(h){return h^=h>>>16,h=o(h,2246822507),h^=h>>>13,h=o(h,3266489909),h^=h>>>16,h}function a(h,d){h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535],d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535];var m=[0,0,0,0];return m[3]+=h[3]+d[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=h[2]+d[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=h[1]+d[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=h[0]+d[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function c(h,d){h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535],d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535];var m=[0,0,0,0];return m[3]+=h[3]*d[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=h[2]*d[3],m[1]+=m[2]>>>16,m[2]&=65535,m[2]+=h[3]*d[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=h[1]*d[3],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=h[2]*d[2],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=h[3]*d[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=h[0]*d[3]+h[1]*d[2]+h[2]*d[1]+h[3]*d[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function u(h,d){return d%=64,d===32?[h[1],h[0]]:d<32?[h[0]<<d|h[1]>>>32-d,h[1]<<d|h[0]>>>32-d]:(d-=32,[h[1]<<d|h[0]>>>32-d,h[0]<<d|h[1]>>>32-d])}function f(h,d){return d%=64,d===0?h:d<32?[h[0]<<d|h[1]>>>32-d,h[1]<<d]:[h[1]<<d-32,0]}function l(h,d){return[h[0]^d[0],h[1]^d[1]]}function p(h){return h=l(h,[0,h[0]>>>1]),h=c(h,[4283543511,3981806797]),h=l(h,[0,h[0]>>>1]),h=c(h,[3301882366,444984403]),h=l(h,[0,h[0]>>>1]),h}t.x86.hash32=function(h,d){if(t.inputValidation&&!n(h))return e;d=d||0;for(var m=h.length%4,y=h.length-m,g=d,w=0,b=3432918353,x=461845907,v=0;v<y;v=v+4)w=h[v]|h[v+1]<<8|h[v+2]<<16|h[v+3]<<24,w=o(w,b),w=s(w,15),w=o(w,x),g^=w,g=s(g,13),g=o(g,5)+3864292196;switch(w=0,m){case 3:w^=h[v+2]<<16;case 2:w^=h[v+1]<<8;case 1:w^=h[v],w=o(w,b),w=s(w,15),w=o(w,x),g^=w}return g^=h.length,g=i(g),g>>>0},t.x86.hash128=function(h,d){if(t.inputValidation&&!n(h))return e;d=d||0;for(var m=h.length%16,y=h.length-m,g=d,w=d,b=d,x=d,v=0,S=0,_=0,R=0,q=597399067,$=2869860233,U=951274213,ee=2716044179,D=0;D<y;D=D+16)v=h[D]|h[D+1]<<8|h[D+2]<<16|h[D+3]<<24,S=h[D+4]|h[D+5]<<8|h[D+6]<<16|h[D+7]<<24,_=h[D+8]|h[D+9]<<8|h[D+10]<<16|h[D+11]<<24,R=h[D+12]|h[D+13]<<8|h[D+14]<<16|h[D+15]<<24,v=o(v,q),v=s(v,15),v=o(v,$),g^=v,g=s(g,19),g+=w,g=o(g,5)+1444728091,S=o(S,$),S=s(S,16),S=o(S,U),w^=S,w=s(w,17),w+=b,w=o(w,5)+197830471,_=o(_,U),_=s(_,17),_=o(_,ee),b^=_,b=s(b,15),b+=x,b=o(b,5)+2530024501,R=o(R,ee),R=s(R,18),R=o(R,q),x^=R,x=s(x,13),x+=g,x=o(x,5)+850148119;switch(v=0,S=0,_=0,R=0,m){case 15:R^=h[D+14]<<16;case 14:R^=h[D+13]<<8;case 13:R^=h[D+12],R=o(R,ee),R=s(R,18),R=o(R,q),x^=R;case 12:_^=h[D+11]<<24;case 11:_^=h[D+10]<<16;case 10:_^=h[D+9]<<8;case 9:_^=h[D+8],_=o(_,U),_=s(_,17),_=o(_,ee),b^=_;case 8:S^=h[D+7]<<24;case 7:S^=h[D+6]<<16;case 6:S^=h[D+5]<<8;case 5:S^=h[D+4],S=o(S,$),S=s(S,16),S=o(S,U),w^=S;case 4:v^=h[D+3]<<24;case 3:v^=h[D+2]<<16;case 2:v^=h[D+1]<<8;case 1:v^=h[D],v=o(v,q),v=s(v,15),v=o(v,$),g^=v}return g^=h.length,w^=h.length,b^=h.length,x^=h.length,g+=w,g+=b,g+=x,w+=g,b+=g,x+=g,g=i(g),w=i(w),b=i(b),x=i(x),g+=w,g+=b,g+=x,w+=g,b+=g,x+=g,("00000000"+(g>>>0).toString(16)).slice(-8)+("00000000"+(w>>>0).toString(16)).slice(-8)+("00000000"+(b>>>0).toString(16)).slice(-8)+("00000000"+(x>>>0).toString(16)).slice(-8)},t.x64.hash128=function(h,d){if(t.inputValidation&&!n(h))return e;d=d||0;for(var m=h.length%16,y=h.length-m,g=[0,d],w=[0,d],b=[0,0],x=[0,0],v=[2277735313,289559509],S=[1291169091,658871167],_=0;_<y;_=_+16)b=[h[_+4]|h[_+5]<<8|h[_+6]<<16|h[_+7]<<24,h[_]|h[_+1]<<8|h[_+2]<<16|h[_+3]<<24],x=[h[_+12]|h[_+13]<<8|h[_+14]<<16|h[_+15]<<24,h[_+8]|h[_+9]<<8|h[_+10]<<16|h[_+11]<<24],b=c(b,v),b=u(b,31),b=c(b,S),g=l(g,b),g=u(g,27),g=a(g,w),g=a(c(g,[0,5]),[0,1390208809]),x=c(x,S),x=u(x,33),x=c(x,v),w=l(w,x),w=u(w,31),w=a(w,g),w=a(c(w,[0,5]),[0,944331445]);switch(b=[0,0],x=[0,0],m){case 15:x=l(x,f([0,h[_+14]],48));case 14:x=l(x,f([0,h[_+13]],40));case 13:x=l(x,f([0,h[_+12]],32));case 12:x=l(x,f([0,h[_+11]],24));case 11:x=l(x,f([0,h[_+10]],16));case 10:x=l(x,f([0,h[_+9]],8));case 9:x=l(x,[0,h[_+8]]),x=c(x,S),x=u(x,33),x=c(x,v),w=l(w,x);case 8:b=l(b,f([0,h[_+7]],56));case 7:b=l(b,f([0,h[_+6]],48));case 6:b=l(b,f([0,h[_+5]],40));case 5:b=l(b,f([0,h[_+4]],32));case 4:b=l(b,f([0,h[_+3]],24));case 3:b=l(b,f([0,h[_+2]],16));case 2:b=l(b,f([0,h[_+1]],8));case 1:b=l(b,[0,h[_]]),b=c(b,v),b=u(b,31),b=c(b,S),g=l(g,b)}return g=l(g,[0,h.length]),w=l(w,[0,h.length]),g=a(g,w),w=a(w,g),g=p(g),w=p(w),g=a(g,w),w=a(w,g),("00000000"+(g[0]>>>0).toString(16)).slice(-8)+("00000000"+(g[1]>>>0).toString(16)).slice(-8)+("00000000"+(w[0]>>>0).toString(16)).slice(-8)+("00000000"+(w[1]>>>0).toString(16)).slice(-8)},typeof ao<"u"?(typeof qs<"u"&&qs.exports&&(ao=qs.exports=t),ao.murmurHash3=t):typeof define=="function"&&define.amd?define([],function(){return t}):(t._murmurHash3=r.murmurHash3,t.noConflict=function(){return r.murmurHash3=t._murmurHash3,t._murmurHash3=e,t.noConflict=e,t},r.murmurHash3=t)})(ao)});var vh=et((Cv,xh)=>{xh.exports=Eh()});var Gh=et((i2,$c)=>{"use strict";var by=Object.prototype.hasOwnProperty,$e="~";function po(){}Object.create&&(po.prototype=Object.create(null),new po().__proto__||($e=!1));function Ey(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function zh(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Ey(t,n||r,o),i=$e?$e+e:e;return r._events[i]?r._events[i].fn?r._events[i]=[r._events[i],s]:r._events[i].push(s):(r._events[i]=s,r._eventsCount++),r}function Xs(r,e){--r._eventsCount===0?r._events=new po:delete r._events[e]}function Me(){this._events=new po,this._eventsCount=0}Me.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)by.call(t,n)&&e.push($e?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Me.prototype.listeners=function(e){var t=$e?$e+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i};Me.prototype.listenerCount=function(e){var t=$e?$e+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Me.prototype.emit=function(e,t,n,o,s,i){var a=$e?$e+e:e;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,f,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,s),!0;case 6:return c.fn.call(c.context,t,n,o,s,i),!0}for(l=1,f=new Array(u-1);l<u;l++)f[l-1]=arguments[l];c.fn.apply(c.context,f)}else{var p=c.length,h;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!f)for(h=1,f=new Array(u-1);h<u;h++)f[h-1]=arguments[h];c[l].fn.apply(c[l].context,f)}}return!0};Me.prototype.on=function(e,t,n){return zh(this,e,t,n,!1)};Me.prototype.once=function(e,t,n){return zh(this,e,t,n,!0)};Me.prototype.removeListener=function(e,t,n,o){var s=$e?$e+e:e;if(!this._events[s])return this;if(!t)return Xs(this,s),this;var i=this._events[s];if(i.fn)i.fn===t&&(!o||i.once)&&(!n||i.context===n)&&Xs(this,s);else{for(var a=0,c=[],u=i.length;a<u;a++)(i[a].fn!==t||o&&!i[a].once||n&&i[a].context!==n)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:Xs(this,s)}return this};Me.prototype.removeAllListeners=function(e){var t;return e?(t=$e?$e+e:e,this._events[t]&&Xs(this,t)):(this._events=new po,this._eventsCount=0),this};Me.prototype.off=Me.prototype.removeListener;Me.prototype.addListener=Me.prototype.on;Me.prefixed=$e;Me.EventEmitter=Me;typeof $c<"u"&&($c.exports=Me)});var al=et((SS,id)=>{"use strict";function sd(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Uy(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return sd(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),sd(new o,t)}}id.exports=Uy});var hd=et(wo=>{(function(){var r,e,t,n,o,s,i,a;a=function(c){var u,f,l,p;return u=(c&255<<24)>>>24,f=(c&255<<16)>>>16,l=(c&65280)>>>8,p=c&255,[u,f,l,p].join(".")},i=function(c){var u,f,l,p,h,d;for(u=[],l=p=0;p<=3&&c.length!==0;l=++p){if(l>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}d=e(c),h=d[0],f=d[1],c=c.substring(f),u.push(h)}if(c.length!==0)throw new Error("Invalid IP");switch(u.length){case 1:if(u[0]>4294967295)throw new Error("Invalid IP");return u[0]>>>0;case 2:if(u[0]>255||u[1]>16777215)throw new Error("Invalid IP");return(u[0]<<24|u[1])>>>0;case 3:if(u[0]>255||u[1]>255||u[2]>65535)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2])>>>0;case 4:if(u[0]>255||u[1]>255||u[2]>255||u[3]>255)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2]<<8|u[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),s=t("a"),o=t("A"),e=function(c){var u,f,l,p,h;for(p=0,u=10,f="9",l=0,c.length>1&&c[l]==="0"&&(c[l+1]==="x"||c[l+1]==="X"?(l+=2,u=16):"0"<=c[l+1]&&c[l+1]<="9"&&(l++,u=8,f="7")),h=l;l<c.length;){if("0"<=c[l]&&c[l]<=f)p=p*u+(t(c[l])-n)>>>0;else if(u===16)if("a"<=c[l]&&c[l]<="f")p=p*u+(10+t(c[l])-s)>>>0;else if("A"<=c[l]&&c[l]<="F")p=p*u+(10+t(c[l])-o)>>>0;else break;else break;if(p>4294967295)throw new Error("too large");l++}if(l===h)throw new Error("empty octet");return[p,l]},r=function(){function c(u,f){var l,p,h,d;if(typeof u!="string")throw new Error("Missing `net' parameter");if(f||(d=u.split("/",2),u=d[0],f=d[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=i(f)}catch(m){throw l=m,new Error("Invalid mask: "+f)}for(p=h=32;h>=0;p=--h)if(this.maskLong===4294967295<<32-p>>>0){this.bitmask=p;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(u)&this.maskLong)>>>0}catch(m){throw l=m,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new c(u)),u instanceof c?this.contains(u.base)&&this.contains(u.broadcast||u.last):(i(u)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(u){return u==null&&(u=1),new c(a(this.netLong+this.size*u),this.mask)},c.prototype.forEach=function(u){var f,l,p;for(p=i(this.first),l=i(this.last),f=0;p<=l;)u(a(p),p,f),f++,p++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),wo.ip2long=i,wo.long2ip=a,wo.Netmask=r}).call(wo)});var Sd=et((LR,Ad)=>{Ad.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(s,i){t[s]=i,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=t[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){t[s]!==void 0?t[s]=i:o(s,i)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var Cd=et((ZR,Td)=>{"use strict";Td.exports=r=>{if(Object.prototype.toString.call(r)!=="[object Object]")return!1;let e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}});var Od=et((Dd,Pd)=>{"use strict";var yi=Cd(),{hasOwnProperty:Nd}=Object.prototype,{propertyIsEnumerable:fw}=Object,In=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0}),hw=Dd,kd={concatArrays:!1,ignoreUndefined:!1},wi=r=>{let e=[];for(let t in r)Nd.call(r,t)&&e.push(t);if(Object.getOwnPropertySymbols){let t=Object.getOwnPropertySymbols(r);for(let n of t)fw.call(r,n)&&e.push(n)}return e};function Bn(r){return Array.isArray(r)?dw(r):yi(r)?pw(r):r}function dw(r){let e=r.slice(0,0);return wi(r).forEach(t=>{In(e,t,Bn(r[t]))}),e}function pw(r){let e=Object.getPrototypeOf(r)===null?Object.create(null):{};return wi(r).forEach(t=>{In(e,t,Bn(r[t]))}),e}var Ld=(r,e,t,n)=>(t.forEach(o=>{typeof e[o]>"u"&&n.ignoreUndefined||(o in r&&r[o]!==Object.getPrototypeOf(r)?In(r,o,xl(r[o],e[o],n)):In(r,o,Bn(e[o])))}),r),mw=(r,e,t)=>{let n=r.slice(0,0),o=0;return[r,e].forEach(s=>{let i=[];for(let a=0;a<s.length;a++)Nd.call(s,a)&&(i.push(String(a)),s===r?In(n,o++,s[a]):In(n,o++,Bn(s[a])));n=Ld(n,s,wi(s).filter(a=>!i.includes(a)),t)}),n};function xl(r,e,t){return t.concatArrays&&Array.isArray(r)&&Array.isArray(e)?mw(r,e,t):!yi(e)||!yi(r)?Bn(e):Ld(r,e,wi(e),t)}Pd.exports=function(...r){let e=xl(Bn(kd),this!==hw&&this||{},kd),t={_:{}};for(let n of r)if(n!==void 0){if(!yi(n))throw new TypeError("`"+n+"` is not an Option Object");t=xl(t,{_:n},e)}return t._}});var Vw={};ve(Vw,{createLibp2p:()=>Fw});var Jl=Symbol.for("@libp2p/connection");var Zi=Symbol.for("@libp2p/content-routing");var Qi=Symbol.for("@libp2p/peer-discovery");var To=Symbol.for("@libp2p/peer-id");function Co(r){return r!=null&&!!r[To]}var Ji=Symbol.for("@libp2p/peer-routing");var eu="keep-alive";var Ww=Symbol.for("@libp2p/transport");var zt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(zt||(zt={}));var Gt=class r extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.name="AbortError",this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},E=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}},ko=class extends AggregateError{code;props;constructor(e,t,n,o){super(e,t),this.code=n,this.name=o?.name??"AggregateCodeError",this.props=o??{}}};var No="ERR_TIMEOUT";var fe=(r,...e)=>{try{[...e]}catch{}};var Rt=class extends EventTarget{#e=new Map;constructor(){super(),fe(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new ta(e,t))}},ea=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},ta=globalThis.CustomEvent??ea;function tu(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}var ra=Symbol.for("@libp2p/service-capabilities"),na=Symbol.for("@libp2p/service-dependencies");var oc={};ve(oc,{Ed25519PrivateKey:()=>Ar,Ed25519PublicKey:()=>qn,generateKeyPair:()=>Vg,generateKeyPairFromSeed:()=>tf,unmarshalEd25519PrivateKey:()=>Mg,unmarshalEd25519PublicKey:()=>Fg});var ca={};ve(ca,{base58btc:()=>ie,base58flickr:()=>bp});var Ab=new Uint8Array(0);function ru(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 nu(r){return new TextEncoder().encode(r)}function ou(r){return new TextDecoder().decode(r)}function pp(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 o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var m=0,y=0,g=0,w=d.length;g!==w&&d[g]===0;)g++,m++;for(var b=(w-g)*f+1>>>0,x=new Uint8Array(b);g!==w;){for(var v=d[g],S=0,_=b-1;(v!==0||S<y)&&_!==-1;_--,S++)v+=256*x[_]>>>0,x[_]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");y=S,g++}for(var R=b-y;R!==b&&x[R]===0;)R++;for(var q=c.repeat(m);R<b;++R)q+=r.charAt(x[R]);return q}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var m=0;if(d[m]!==" "){for(var y=0,g=0;d[m]===c;)y++,m++;for(var w=(d.length-m)*u+1>>>0,b=new Uint8Array(w);d[m];){var x=t[d.charCodeAt(m)];if(x===255)return;for(var v=0,S=w-1;(x!==0||v<g)&&S!==-1;S--,v++)x+=a*b[S]>>>0,b[S]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");g=v,m++}if(d[m]!==" "){for(var _=w-g;_!==w&&b[_]===0;)_++;for(var R=new Uint8Array(y+(w-_)),q=y;_!==w;)R[q++]=b[_++];return R}}}function h(d){var m=p(d);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:h}}var mp=pp,gp=mp,iu=gp;var oa=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")}},sa=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 au(this,e)}},ia=class{decoders;constructor(e){this.decoders=e}or(e){return au(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 au(r,e){return new ia({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var aa=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new oa(e,t,n),this.decoder=new sa(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Kr({name:r,prefix:e,encode:t,decode:n}){return new aa(r,e,t,n)}function Yt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=iu(t,r);return Kr({prefix:e,name:r,encode:n,decode:s=>It(o(s))})}function yp(r,e,t,n){let o={};for(let f=0;f<e.length;++f)o[e[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,u=0;for(let f=0;f<s;++f){let l=o[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,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 wp(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function ce({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Kr({prefix:e,name:r,encode(o){return wp(o,n,t)},decode(o){return yp(o,n,t,r)}})}var ie=Yt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bp=Yt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ua={};ve(ua,{identity:()=>Bt});var Ep=uu,cu=128,xp=127,vp=~xp,_p=Math.pow(2,31);function uu(r,e,t){e=e||[],t=t||0;for(var n=t;r>=_p;)e[t++]=r&255|cu,r/=128;for(;r&vp;)e[t++]=r&255|cu,r>>>=7;return e[t]=r|0,uu.bytes=t-n+1,e}var Ap=la,Sp=128,lu=127;function la(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw la.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&lu)<<o:(i&lu)*Math.pow(2,o),o+=7}while(i>=Sp);return la.bytes=s-n,t}var Rp=Math.pow(2,7),Ip=Math.pow(2,14),Bp=Math.pow(2,21),Tp=Math.pow(2,28),Cp=Math.pow(2,35),kp=Math.pow(2,42),Np=Math.pow(2,49),Lp=Math.pow(2,56),Dp=Math.pow(2,63),Pp=function(r){return r<Rp?1:r<Ip?2:r<Bp?3:r<Tp?4:r<Cp?5:r<kp?6:r<Np?7:r<Lp?8:r<Dp?9:10},Op={encode:Ep,decode:Ap,encodingLength:Pp},Up=Op,Dn=Up;function Pn(r,e=0){return[Dn.decode(r,e),Dn.decode.bytes]}function Hr(r,e,t=0){return Dn.encode(r,e,t),e}function qr(r){return Dn.encodingLength(r)}function mt(r,e){let t=e.byteLength,n=qr(r),o=n+qr(t),s=new Uint8Array(o+t);return Hr(r,s,0),Hr(t,s,n),s.set(e,o),new $r(r,t,e,s)}function gr(r){let e=It(r),[t,n]=Pn(e),[o,s]=Pn(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new $r(t,o,i,e)}function fu(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ru(r.bytes,t.bytes)}}var $r=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var hu=0,Mp="identity",du=It;function Fp(r){return mt(hu,du(r))}var Bt={code:hu,name:Mp,encode:du,digest:Fp};var da={};ve(da,{sha256:()=>Re,sha512:()=>Vp});function ha({name:r,code:e,encode:t}){return new fa(r,e,t)}var fa=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?mt(this.code,t):t.then(n=>mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function mu(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Re=ha({name:"sha2-256",code:18,encode:mu("SHA-256")}),Vp=ha({name:"sha2-512",code:19,encode:mu("SHA-512")});function te(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=0){return new Uint8Array(r)}function Le(r=0){return new Uint8Array(r)}function Ie(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Le(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var pa={};ve(pa,{base10:()=>Kp});var Kp=Yt({prefix:"9",name:"base10",alphabet:"0123456789"});var ma={};ve(ma,{base16:()=>Hp,base16upper:()=>qp});var Hp=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qp=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ga={};ve(ga,{base2:()=>$p});var $p=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ya={};ve(ya,{base256emoji:()=>jp});var gu=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}"),zp=gu.reduce((r,e,t)=>(r[t]=e,r),[]),Gp=gu.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Yp(r){return r.reduce((e,t)=>(e+=zp[t],e),"")}function Wp(r){let e=[];for(let t of r){let n=Gp[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var jp=Kr({prefix:"\u{1F680}",name:"base256emoji",encode:Yp,decode:Wp});var wa={};ve(wa,{base32:()=>Ge,base32hex:()=>Jp,base32hexpad:()=>tm,base32hexpadupper:()=>rm,base32hexupper:()=>em,base32pad:()=>Zp,base32padupper:()=>Qp,base32upper:()=>Xp,base32z:()=>nm});var Ge=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xp=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zp=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qp=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jp=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),em=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tm=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rm=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nm=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ba={};ve(ba,{base36:()=>om,base36upper:()=>sm});var om=Yt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sm=Yt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xa={};ve(xa,{base64:()=>On,base64pad:()=>im,base64url:()=>Ea,base64urlpad:()=>am});var On=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),im=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ea=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),am=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var va={};ve(va,{base8:()=>cm});var cm=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _a={};ve(_a,{identity:()=>lm});var lm=Kr({prefix:"\0",name:"identity",encode:r=>ou(r),decode:r=>nu(r)});var Qb=new TextEncoder,Jb=new TextDecoder;function yu(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return dm(t,Aa(r),e??ie.encoder);default:return pm(t,Aa(r),e??Ge.encoder)}}var wu=new WeakMap;function Aa(r){let e=wu.get(r);if(e==null){let t=new Map;return wu.set(r,t),t}return e}var tt=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Un)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==mm)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=mt(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&&fu(e.multihash,n.multihash)}toString(e){return yu(this,e)}toJSON(){return{"/":yu(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:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??bu(n,o,s.bytes))}else if(t[gm]===!0){let{version:n,multihash:o,code:s}=t,i=gr(o);return r.create(n,s,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!==Un)throw new Error(`Version 0 CID must use dag-pb (code: ${Un}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=bu(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Un,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,o=It(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new $r(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=Pn(e.subarray(t));return t+=p,l},o=n(),s=Un;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),u=t+c,f=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(e,t){let[n,o]=hm(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Aa(s).set(n,e),s}};function hm(r,e){switch(r[0]){case"Q":{let t=e??ie;return[ie.prefix,t.decode(`${ie.prefix}${r}`)]}case ie.prefix:{let t=e??ie;return[ie.prefix,t.decode(r)]}case Ge.prefix:{let t=e??Ge;return[Ge.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 dm(r,e,t){let{prefix:n}=t;if(n!==ie.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function pm(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var Un=112,mm=18;function bu(r,e,t){let n=qr(r),o=n+qr(e),s=new Uint8Array(o+t.byteLength);return Hr(r,s,0),Hr(e,s,n),s.set(t,o),s}var gm=Symbol.for("@ipld/js-cid/CID");var Wt={..._a,...ga,...va,...pa,...ma,...wa,...ba,...ca,...xa,...ya},mE={...da,...ua};function xu(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Eu=xu("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Sa=xu("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=Le(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ym={utf8:Eu,"utf-8":Eu,hex:Wt.base16,latin1:Sa,ascii:Sa,binary:Sa,...Wt},Do=ym;function L(r,e="utf8"){let t=Do[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function rt(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function zr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function wm(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Gr(r,...e){if(!wm(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 Po(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");zr(r.outputLen),zr(r.blockLen)}function Yr(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 vu(r,e){Gr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Oo=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var jr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),at=(r,e)=>r<<32-e|r>>>e;var TE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var bm=async()=>{};async function _u(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let s=Date.now()-n;s>=0&&s<e||(await bm(),n+=s)}}function Au(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function jt(r){return typeof r=="string"&&(r=Au(r)),Gr(r),r}function Ra(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Gr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let s=r[n];t.set(s,o),o+=s.length}return t}var Wr=class{clone(){return this._cloneInto()}},Em={}.toString;function Su(r,e){if(e!==void 0&&Em.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function Uo(r){let e=n=>r().update(jt(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Xr(r=32){if(Oo&&typeof Oo.getRandomValues=="function")return Oo.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function xm(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(t>>o&s),a=Number(t&s),c=n?4:0,u=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+u,a,n)}var Ru=(r,e,t)=>r&e^~r&t,Iu=(r,e,t)=>r&e^r&t^e&t,Zr=class extends Wr{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=jr(this.buffer)}update(e){Yr(this);let{view:t,buffer:n,blockLen:o}=this;e=jt(e);let s=e.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=jr(e);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Yr(this),vu(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)t[l]=0;xm(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=jr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],s)}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:o,finished:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%t&&e.buffer.set(n),e}};var Mo=BigInt(4294967295),Ia=BigInt(32);function Bu(r,e=!1){return e?{h:Number(r&Mo),l:Number(r>>Ia&Mo)}:{h:Number(r>>Ia&Mo)|0,l:Number(r&Mo)|0}}function vm(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Bu(r[o],e);[t[o],n[o]]=[s,i]}return[t,n]}var _m=(r,e)=>BigInt(r>>>0)<<Ia|BigInt(e>>>0),Am=(r,e,t)=>r>>>t,Sm=(r,e,t)=>r<<32-t|e>>>t,Rm=(r,e,t)=>r>>>t|e<<32-t,Im=(r,e,t)=>r<<32-t|e>>>t,Bm=(r,e,t)=>r<<64-t|e>>>t-32,Tm=(r,e,t)=>r>>>t-32|e<<64-t,Cm=(r,e)=>e,km=(r,e)=>r,Nm=(r,e,t)=>r<<t|e>>>32-t,Lm=(r,e,t)=>e<<t|r>>>32-t,Dm=(r,e,t)=>e<<t-32|r>>>64-t,Pm=(r,e,t)=>r<<t-32|e>>>64-t;function Om(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var Um=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Mm=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Fm=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Vm=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Km=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Hm=(r,e,t,n,o,s)=>e+t+n+o+s+(r/2**32|0)|0;var qm={fromBig:Bu,split:vm,toBig:_m,shrSH:Am,shrSL:Sm,rotrSH:Rm,rotrSL:Im,rotrBH:Bm,rotrBL:Tm,rotr32H:Cm,rotr32L:km,rotlSH:Nm,rotlSL:Lm,rotlBH:Dm,rotlBL:Pm,add:Om,add3L:Um,add3H:Mm,add4L:Fm,add4H:Vm,add5H:Hm,add5L:Km},M=qm;var[$m,zm]=M.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))),Xt=new Uint32Array(80),Zt=new Uint32Array(80),Ba=class extends Zr{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:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:p,Gh:h,Gl:d,Hh:m,Hl:y}=this;return[e,t,n,o,s,i,a,c,u,f,l,p,h,d,m,y]}set(e,t,n,o,s,i,a,c,u,f,l,p,h,d,m,y){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=p|0,this.Gh=h|0,this.Gl=d|0,this.Hh=m|0,this.Hl=y|0}process(e,t){for(let b=0;b<16;b++,t+=4)Xt[b]=e.getUint32(t),Zt[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){let x=Xt[b-15]|0,v=Zt[b-15]|0,S=M.rotrSH(x,v,1)^M.rotrSH(x,v,8)^M.shrSH(x,v,7),_=M.rotrSL(x,v,1)^M.rotrSL(x,v,8)^M.shrSL(x,v,7),R=Xt[b-2]|0,q=Zt[b-2]|0,$=M.rotrSH(R,q,19)^M.rotrBH(R,q,61)^M.shrSH(R,q,6),U=M.rotrSL(R,q,19)^M.rotrBL(R,q,61)^M.shrSL(R,q,6),ee=M.add4L(_,U,Zt[b-7],Zt[b-16]),D=M.add4H(ee,S,$,Xt[b-7],Xt[b-16]);Xt[b]=D|0,Zt[b]=ee|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:p,Fh:h,Fl:d,Gh:m,Gl:y,Hh:g,Hl:w}=this;for(let b=0;b<80;b++){let x=M.rotrSH(l,p,14)^M.rotrSH(l,p,18)^M.rotrBH(l,p,41),v=M.rotrSL(l,p,14)^M.rotrSL(l,p,18)^M.rotrBL(l,p,41),S=l&h^~l&m,_=p&d^~p&y,R=M.add5L(w,v,_,zm[b],Zt[b]),q=M.add5H(R,g,x,S,$m[b],Xt[b]),$=R|0,U=M.rotrSH(n,o,28)^M.rotrBH(n,o,34)^M.rotrBH(n,o,39),ee=M.rotrSL(n,o,28)^M.rotrBL(n,o,34)^M.rotrBL(n,o,39),D=n&s^n&a^s&a,Je=o&i^o&c^i&c;g=m|0,w=y|0,m=h|0,y=d|0,h=l|0,d=p|0,{h:l,l:p}=M.add(u|0,f|0,q|0,$|0),u=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=M.add3L($,ee,Je);n=M.add3H(I,q,U,D),o=I|0}({h:n,l:o}=M.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=M.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=M.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=M.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:p}=M.add(this.Eh|0,this.El|0,l|0,p|0),{h,l:d}=M.add(this.Fh|0,this.Fl|0,h|0,d|0),{h:m,l:y}=M.add(this.Gh|0,this.Gl|0,m|0,y|0),{h:g,l:w}=M.add(this.Hh|0,this.Hl|0,g|0,w|0),this.set(n,o,s,i,a,c,u,f,l,p,h,d,m,y,g,w)}roundClean(){Xt.fill(0),Zt.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 Mn=Uo(()=>new Ba);var Vo={};ve(Vo,{abytes:()=>Qr,bitGet:()=>Qm,bitLen:()=>Zm,bitMask:()=>Fn,bitSet:()=>Jm,bytesToHex:()=>Ct,bytesToNumberBE:()=>kt,bytesToNumberLE:()=>Jt,concatBytes:()=>Nt,createHmacDrbg:()=>ka,ensureBytes:()=>le,equalBytes:()=>jm,hexToBytes:()=>wr,hexToNumber:()=>Ca,isBytes:()=>Qt,numberToBytesBE:()=>er,numberToBytesLE:()=>br,numberToHexUnpadded:()=>Nu,numberToVarBytesBE:()=>Wm,utf8ToBytes:()=>Xm,validateObject:()=>gt});var ku=BigInt(0),Fo=BigInt(1),Gm=BigInt(2);function Qt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Qr(r){if(!Qt(r))throw new Error("Uint8Array expected")}var Ym=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ct(r){Qr(r);let e="";for(let t=0;t<r.length;t++)e+=Ym[r[t]];return e}function Nu(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ca(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Tt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Tu(r){if(r>=Tt._0&&r<=Tt._9)return r-Tt._0;if(r>=Tt._A&&r<=Tt._F)return r-(Tt._A-10);if(r>=Tt._a&&r<=Tt._f)return r-(Tt._a-10)}function wr(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 o=0,s=0;o<t;o++,s+=2){let i=Tu(r.charCodeAt(s)),a=Tu(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function kt(r){return Ca(Ct(r))}function Jt(r){return Qr(r),Ca(Ct(Uint8Array.from(r).reverse()))}function er(r,e){return wr(r.toString(16).padStart(e*2,"0"))}function br(r,e){return er(r,e).reverse()}function Wm(r){return wr(Nu(r))}function le(r,e,t){let n;if(typeof e=="string")try{n=wr(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Qt(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function Nt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Qr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let s=r[n];t.set(s,o),o+=s.length}return t}function jm(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 Xm(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Zm(r){let e;for(e=0;r>ku;r>>=Fo,e+=1);return e}function Qm(r,e){return r>>BigInt(e)&Fo}function Jm(r,e,t){return r|(t?Fo:ku)<<BigInt(e)}var Fn=r=>(Gm<<BigInt(r-1))-Fo,Ta=r=>new Uint8Array(r),Cu=r=>Uint8Array.from(r);function ka(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=Ta(r),o=Ta(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>t(o,n,...l),c=(l=Ta())=>{o=a(Cu([0]),l),n=a(),l.length!==0&&(o=a(Cu([1]),l),n=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let h=n.slice();p.push(h),l+=n.length}return Nt(...p)};return(l,p)=>{i(),c(l);let h;for(;!(h=p(u()));)c();return i(),h}}var eg={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"||Qt(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 gt(r,e,t={}){let n=(o,s,i)=>{let a=eg[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${s}`)};for(let[o,s]of Object.entries(e))n(o,s,!1);for(let[o,s]of Object.entries(t))n(o,s,!0);return r}var we=BigInt(0),re=BigInt(1),Er=BigInt(2),tg=BigInt(3),Na=BigInt(4),Lu=BigInt(5),Du=BigInt(8),rg=BigInt(9),ng=BigInt(16);function Q(r,e){let t=r%e;return t>=we?t:e+t}function og(r,e,t){if(t<=we||e<we)throw new Error("Expected power/modulo > 0");if(t===re)return we;let n=re;for(;e>we;)e&re&&(n=n*r%t),r=r*r%t,e>>=re;return n}function ne(r,e,t){let n=r;for(;e-- >we;)n*=n,n%=t;return n}function Ko(r,e){if(r===we||e<=we)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Q(r,e),n=e,o=we,s=re,i=re,a=we;for(;t!==we;){let u=n/t,f=n%t,l=o-i*u,p=s-a*u;n=t,t=f,o=i,s=a,i=l,a=p}if(n!==re)throw new Error("invert: does not exist");return Q(o,e)}function sg(r){let e=(r-re)/Er,t,n,o;for(t=r-re,n=0;t%Er===we;t/=Er,n++);for(o=Er;o<r&&og(o,e,r)!==r-re;o++);if(n===1){let i=(r+re)/Na;return function(c,u){let f=c.pow(u,i);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let s=(t+re)/Er;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,f=a.pow(a.mul(a.ONE,o),t),l=a.pow(c,s),p=a.pow(c,t);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let h=1;for(let m=a.sqr(p);h<u&&!a.eql(m,a.ONE);h++)m=a.sqr(m);let d=a.pow(f,re<<BigInt(u-h-1));f=a.sqr(d),l=a.mul(l,d),p=a.mul(p,f),u=h}return l}}function ig(r){if(r%Na===tg){let e=(r+re)/Na;return function(n,o){let s=n.pow(o,e);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Du===Lu){let e=(r-Lu)/Du;return function(n,o){let s=n.mul(o,Er),i=n.pow(s,e),a=n.mul(o,i),c=n.mul(n.mul(a,Er),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),o))throw new Error("Cannot find square root");return u}}return r%ng,sg(r)}var Pu=(r,e)=>(Q(r,e)&re)===re,ag=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function La(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ag.reduce((n,o)=>(n[o]="function",n),e);return gt(r,t)}function cg(r,e,t){if(t<we)throw new Error("Expected power > 0");if(t===we)return r.ONE;if(t===re)return e;let n=r.ONE,o=e;for(;t>we;)t&re&&(n=r.mul(n,o)),o=r.sqr(o),t>>=re;return n}function lg(r,e){let t=new Array(e.length),n=e.reduce((s,i,a)=>r.is0(i)?s:(t[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return e.reduceRight((s,i,a)=>r.is0(i)?s:(t[a]=r.mul(s,t[a]),r.mul(s,i)),o),t}function Da(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ho(r,e,t=!1,n={}){if(r<=we)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=Da(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=ig(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Fn(o),ZERO:we,ONE:re,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return we<=c&&c<r},is0:c=>c===we,isOdd:c=>(c&re)===re,neg:c=>Q(-c,r),eql:(c,u)=>c===u,sqr:c=>Q(c*c,r),add:(c,u)=>Q(c+u,r),sub:(c,u)=>Q(c-u,r),mul:(c,u)=>Q(c*u,r),pow:(c,u)=>cg(a,c,u),div:(c,u)=>Q(c*Ko(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Ko(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>lg(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>t?br(c,s):er(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?Jt(c):kt(c)}});return Object.freeze(a)}function Ou(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 Pa(r){let e=Ou(r);return e+Math.ceil(e/2)}function Uu(r,e,t=!1){let n=r.length,o=Ou(e),s=Pa(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=t?kt(r):Jt(r),a=Q(i,e-re)+re;return t?br(a,o):er(a,o)}var fg=BigInt(0),Oa=BigInt(1);function qo(r,e){let t=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(e/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:t,unsafeLadder(o,s){let i=r.ZERO,a=o;for(;s>fg;)s&Oa&&(i=i.add(a)),a=a.double(),s>>=Oa;return i},precomputeWindow(o,s){let{windows:i,windowSize:a}=n(s),c=[],u=o,f=u;for(let l=0;l<i;l++){f=u,c.push(f);for(let p=1;p<a;p++)f=f.add(u),c.push(f);u=f.double()}return c},wNAF(o,s,i){let{windows:a,windowSize:c}=n(o),u=r.ZERO,f=r.BASE,l=BigInt(2**o-1),p=2**o,h=BigInt(o);for(let d=0;d<a;d++){let m=d*c,y=Number(i&l);i>>=h,y>c&&(y-=p,i+=Oa);let g=m,w=m+Math.abs(y)-1,b=d%2!==0,x=y<0;y===0?f=f.add(t(b,s[g])):u=u.add(t(x,s[w]))}return{p:u,f}},wNAFCached(o,s,i,a){let c=o._WINDOW_SIZE||1,u=s.get(o);return u||(u=this.precomputeWindow(o,c),c!==1&&s.set(o,a(u))),this.wNAF(c,u,i)}}}function Vn(r){return La(r.Fp),gt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Da(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ct=BigInt(0),Ye=BigInt(1),$o=BigInt(2),hg=BigInt(8),dg={zip215:!0};function pg(r){let e=Vn(r);return gt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Mu(r){let e=pg(r),{Fp:t,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=e,u=$o<<BigInt(a*8)-Ye,f=t.create,l=e.uvRatio||((B,A)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(A))}}catch{return{isValid:!1,value:ct}}}),p=e.adjustScalarBytes||(B=>B),h=e.domain||((B,A,k)=>{if(A.length||k)throw new Error("Contexts/pre-hash are not supported");return B}),d=B=>typeof B=="bigint"&&ct<B,m=(B,A)=>d(B)&&d(A)&&B<A,y=B=>B===ct||m(B,u);function g(B,A){if(m(B,A))return B;throw new Error(`Expected valid scalar < ${A}, got ${typeof B} ${B}`)}function w(B){return B===ct?B:g(B,n)}let b=new Map;function x(B){if(!(B instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(A,k,P,O){if(this.ex=A,this.ey=k,this.ez=P,this.et=O,!y(A))throw new Error("x required");if(!y(k))throw new Error("y required");if(!y(P))throw new Error("z required");if(!y(O))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof v)throw new Error("extended point not allowed");let{x:k,y:P}=A||{};if(!y(k)||!y(P))throw new Error("invalid affine point");return new v(k,P,Ye,f(k*P))}static normalizeZ(A){let k=t.invertBatch(A.map(P=>P.ez));return A.map((P,O)=>P.toAffine(k[O])).map(v.fromAffine)}_setWindowSize(A){this._WINDOW_SIZE=A,b.delete(this)}assertValidity(){let{a:A,d:k}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:P,ey:O,ez:K,et:H}=this,W=f(P*P),G=f(O*O),Y=f(K*K),pe=f(Y*Y),ae=f(W*A),Ae=f(Y*f(ae+G)),Se=f(pe+f(k*f(W*G)));if(Ae!==Se)throw new Error("bad point: equation left != right (1)");let ye=f(P*O),Ne=f(K*H);if(ye!==Ne)throw new Error("bad point: equation left != right (2)")}equals(A){x(A);let{ex:k,ey:P,ez:O}=this,{ex:K,ey:H,ez:W}=A,G=f(k*W),Y=f(K*O),pe=f(P*W),ae=f(H*O);return G===Y&&pe===ae}is0(){return this.equals(v.ZERO)}negate(){return new v(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:A}=e,{ex:k,ey:P,ez:O}=this,K=f(k*k),H=f(P*P),W=f($o*f(O*O)),G=f(A*K),Y=k+P,pe=f(f(Y*Y)-K-H),ae=G+H,Ae=ae-W,Se=G-H,ye=f(pe*Ae),Ne=f(ae*Se),At=f(pe*Se),mr=f(Ae*ae);return new v(ye,Ne,mr,At)}add(A){x(A);let{a:k,d:P}=e,{ex:O,ey:K,ez:H,et:W}=this,{ex:G,ey:Y,ez:pe,et:ae}=A;if(k===BigInt(-1)){let zl=f((K-O)*(Y+G)),Gl=f((K+O)*(Y-G)),Xi=f(Gl-zl);if(Xi===ct)return this.double();let Yl=f(H*$o*ae),Wl=f(W*$o*pe),jl=Wl+Yl,Xl=Gl+zl,Zl=Wl-Yl,op=f(jl*Xi),sp=f(Xl*Zl),ip=f(jl*Zl),ap=f(Xi*Xl);return new v(op,sp,ap,ip)}let Ae=f(O*G),Se=f(K*Y),ye=f(W*P*ae),Ne=f(H*pe),At=f((O+K)*(G+Y)-Ae-Se),mr=Ne-ye,Ln=Ne+ye,$l=f(Se-k*Ae),ep=f(At*mr),tp=f(Ln*$l),rp=f(At*$l),np=f(mr*Ln);return new v(ep,tp,np,rp)}subtract(A){return this.add(A.negate())}wNAF(A){return R.wNAFCached(this,b,A,v.normalizeZ)}multiply(A){let{p:k,f:P}=this.wNAF(g(A,n));return v.normalizeZ([k,P])[0]}multiplyUnsafe(A){let k=w(A);return k===ct?_:this.equals(_)||k===Ye?this:this.equals(S)?this.wNAF(k).p:R.unsafeLadder(this,k)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return R.unsafeLadder(this,n).is0()}toAffine(A){let{ex:k,ey:P,ez:O}=this,K=this.is0();A==null&&(A=K?hg:t.inv(O));let H=f(k*A),W=f(P*A),G=f(O*A);if(K)return{x:ct,y:Ye};if(G!==Ye)throw new Error("invZ was invalid");return{x:H,y:W}}clearCofactor(){let{h:A}=e;return A===Ye?this:this.multiplyUnsafe(A)}static fromHex(A,k=!1){let{d:P,a:O}=e,K=t.BYTES;A=le("pointHex",A,K);let H=A.slice(),W=A[K-1];H[K-1]=W&-129;let G=Jt(H);G===ct||(k?g(G,u):g(G,t.ORDER));let Y=f(G*G),pe=f(Y-Ye),ae=f(P*Y-O),{isValid:Ae,value:Se}=l(pe,ae);if(!Ae)throw new Error("Point.fromHex: invalid y coordinate");let ye=(Se&Ye)===Ye,Ne=(W&128)!==0;if(!k&&Se===ct&&Ne)throw new Error("Point.fromHex: x=0 and x_0=1");return Ne!==ye&&(Se=f(-Se)),v.fromAffine({x:Se,y:G})}static fromPrivateKey(A){return U(A).point}toRawBytes(){let{x:A,y:k}=this.toAffine(),P=br(k,t.BYTES);return P[P.length-1]|=A&Ye?128:0,P}toHex(){return Ct(this.toRawBytes())}}v.BASE=new v(e.Gx,e.Gy,Ye,f(e.Gx*e.Gy)),v.ZERO=new v(ct,Ye,Ye,ct);let{BASE:S,ZERO:_}=v,R=qo(v,a*8);function q(B){return Q(B,n)}function $(B){return q(Jt(B))}function U(B){let A=a;B=le("private key",B,A);let k=le("hashed private key",s(B),2*A),P=p(k.slice(0,A)),O=k.slice(A,2*A),K=$(P),H=S.multiply(K),W=H.toRawBytes();return{head:P,prefix:O,scalar:K,point:H,pointBytes:W}}function ee(B){return U(B).pointBytes}function D(B=new Uint8Array,...A){let k=Nt(...A);return $(s(h(k,le("context",B),!!o)))}function Je(B,A,k={}){B=le("message",B),o&&(B=o(B));let{prefix:P,scalar:O,pointBytes:K}=U(A),H=D(k.context,P,B),W=S.multiply(H).toRawBytes(),G=D(k.context,W,K,B),Y=q(H+G*O);w(Y);let pe=Nt(W,br(Y,t.BYTES));return le("result",pe,a*2)}let I=dg;function N(B,A,k,P=I){let{context:O,zip215:K}=P,H=t.BYTES;B=le("signature",B,2*H),A=le("message",A),o&&(A=o(A));let W=Jt(B.slice(H,2*H)),G,Y,pe;try{G=v.fromHex(k,K),Y=v.fromHex(B.slice(0,H),K),pe=S.multiplyUnsafe(W)}catch{return!1}if(!K&&G.isSmallOrder())return!1;let ae=D(O,Y.toRawBytes(),G.toRawBytes(),A);return Y.add(G.multiplyUnsafe(ae)).subtract(pe).clearCofactor().equals(v.ZERO)}return S._setWindowSize(8),{CURVE:e,getPublicKey:ee,sign:Je,verify:N,ExtendedPoint:v,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(t.BYTES),precompute(B=8,A=v.BASE){return A._setWindowSize(B),A.multiply(BigInt(3)),A}}}}var Ua=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Fu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),QE=BigInt(0),mg=BigInt(1),Vu=BigInt(2),JE=BigInt(3),gg=BigInt(5),yg=BigInt(8);function wg(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),s=Ua,a=r*r%s*r%s,c=ne(a,Vu,s)*a%s,u=ne(c,mg,s)*r%s,f=ne(u,gg,s)*u%s,l=ne(f,e,s)*f%s,p=ne(l,t,s)*l%s,h=ne(p,n,s)*p%s,d=ne(h,o,s)*h%s,m=ne(d,o,s)*h%s,y=ne(m,e,s)*f%s;return{pow_p_5_8:ne(y,Vu,s)*r%s,b2:a}}function bg(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Eg(r,e){let t=Ua,n=Q(e*e*e,t),o=Q(n*n*e,t),s=wg(r*o).pow_p_5_8,i=Q(r*n*s,t),a=Q(e*i*i,t),c=i,u=Q(i*Fu,t),f=a===r,l=a===Q(-r,t),p=a===Q(-r*Fu,t);return f&&(i=c),(l||p)&&(i=u),Pu(i,t)&&(i=Q(-i,t)),{isValid:f||l,value:i}}var xg=Ho(Ua,void 0,!0),vg={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:xg,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:yg,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Mn,randomBytes:Xr,adjustScalarBytes:bg,uvRatio:Eg},Jr=Mu(vg);var en=32,Lt=64,zo=32;function Ku(){let r=Jr.utils.randomPrivateKey(),e=Jr.getPublicKey(r);return{privateKey:zu(r,e),publicKey:e}}function Hu(r){if(r.length!==zo)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=Jr.getPublicKey(e);return{privateKey:zu(e,t),publicKey:t}}function qu(r,e){let t=r.subarray(0,zo);return Jr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function $u(r,e,t){return Jr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function zu(r,e){let t=new Uint8Array(Lt);for(let n=0;n<zo;n++)t[n]=r[n],t[zo+n]=e[n];return t}var Fe={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Ma={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function Gu(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",s=r?.saltLength??16,i=r?.iterations??32767,a=Fe.get();t*=8;async function c(l,p){let h=a.getRandomValues(new Uint8Array(s)),d=a.getRandomValues(new Uint8Array(n)),m={name:e,iv:d};typeof p=="string"&&(p=L(p));let y;if(p.length===0){y=await a.subtle.importKey("jwk",Ma,{name:"AES-GCM"},!0,["encrypt"]);try{let w={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,b,{name:e,length:t},!0,["encrypt"])}catch{y=await a.subtle.importKey("jwk",Ma,{name:"AES-GCM"},!0,["encrypt"])}}else{let w={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,b,{name:e,length:t},!0,["encrypt"])}let g=await a.subtle.encrypt(m,y,l);return Ie([h,m.iv,new Uint8Array(g)])}async function u(l,p){let h=l.subarray(0,s),d=l.subarray(s,s+n),m=l.subarray(s+n),y={name:e,iv:d};typeof p=="string"&&(p=L(p));let g;if(p.length===0)try{let b={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},x=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,x,{name:e,length:t},!0,["decrypt"])}catch{g=await a.subtle.importKey("jwk",Ma,{name:"AES-GCM"},!0,["decrypt"])}else{let b={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},x=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,x,{name:e,length:t},!0,["decrypt"])}let w=await a.subtle.decrypt(y,g,m);return new Uint8Array(w)}return{encrypt:c,decrypt:u}}async function tn(r,e){let n=await Gu().encrypt(r,e);return On.encode(n)}var Sg=Math.pow(2,7),Rg=Math.pow(2,14),Ig=Math.pow(2,21),Fa=Math.pow(2,28),Va=Math.pow(2,35),Ka=Math.pow(2,42),Ha=Math.pow(2,49),X=128,De=127;function me(r){if(r<Sg)return 1;if(r<Rg)return 2;if(r<Ig)return 3;if(r<Fa)return 4;if(r<Va)return 5;if(r<Ka)return 6;if(r<Ha)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function qa(r,e,t=0){switch(me(r)){case 8:e[t++]=r&255|X,r/=128;case 7:e[t++]=r&255|X,r/=128;case 6:e[t++]=r&255|X,r/=128;case 5:e[t++]=r&255|X,r/=128;case 4:e[t++]=r&255|X,r>>>=7;case 3:e[t++]=r&255|X,r>>>=7;case 2:e[t++]=r&255|X,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Bg(r,e,t=0){switch(me(r)){case 8:e.set(t++,r&255|X),r/=128;case 7:e.set(t++,r&255|X),r/=128;case 6:e.set(t++,r&255|X),r/=128;case 5:e.set(t++,r&255|X),r/=128;case 4:e.set(t++,r&255|X),r>>>=7;case 3:e.set(t++,r&255|X),r>>>=7;case 2:e.set(t++,r&255|X),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function $a(r,e){let t=r[e],n=0;if(n+=t&De,t<X||(t=r[e+1],n+=(t&De)<<7,t<X)||(t=r[e+2],n+=(t&De)<<14,t<X)||(t=r[e+3],n+=(t&De)<<21,t<X)||(t=r[e+4],n+=(t&De)*Fa,t<X)||(t=r[e+5],n+=(t&De)*Va,t<X)||(t=r[e+6],n+=(t&De)*Ka,t<X)||(t=r[e+7],n+=(t&De)*Ha,t<X))return n;throw new RangeError("Could not decode varint")}function Tg(r,e){let t=r.get(e),n=0;if(n+=t&De,t<X||(t=r.get(e+1),n+=(t&De)<<7,t<X)||(t=r.get(e+2),n+=(t&De)<<14,t<X)||(t=r.get(e+3),n+=(t&De)<<21,t<X)||(t=r.get(e+4),n+=(t&De)*Fa,t<X)||(t=r.get(e+5),n+=(t&De)*Va,t<X)||(t=r.get(e+6),n+=(t&De)*Ka,t<X)||(t=r.get(e+7),n+=(t&De)*Ha,t<X))return n;throw new RangeError("Could not decode varint")}function Pe(r,e,t=0){return e==null&&(e=Le(me(r))),e instanceof Uint8Array?qa(r,e,t):Bg(r,e,t)}function lt(r,e=0){return r instanceof Uint8Array?$a(r,e):Tg(r,e)}var za=new Float32Array([-0]),tr=new Uint8Array(za.buffer);function Yu(r,e,t){za[0]=r,e[t]=tr[0],e[t+1]=tr[1],e[t+2]=tr[2],e[t+3]=tr[3]}function Wu(r,e){return tr[0]=r[e],tr[1]=r[e+1],tr[2]=r[e+2],tr[3]=r[e+3],za[0]}var Ga=new Float64Array([-0]),Oe=new Uint8Array(Ga.buffer);function ju(r,e,t){Ga[0]=r,e[t]=Oe[0],e[t+1]=Oe[1],e[t+2]=Oe[2],e[t+3]=Oe[3],e[t+4]=Oe[4],e[t+5]=Oe[5],e[t+6]=Oe[6],e[t+7]=Oe[7]}function Xu(r,e){return Oe[0]=r[e],Oe[1]=r[e+1],Oe[2]=r[e+2],Oe[3]=r[e+3],Oe[4]=r[e+4],Oe[5]=r[e+5],Oe[6]=r[e+6],Oe[7]=r[e+7],Ga[0]}var Cg=BigInt(Number.MAX_SAFE_INTEGER),kg=BigInt(Number.MIN_SAFE_INTEGER),We=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 vr;if(e<Cg&&e>kg)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Zu&&(o=0n,++n>Zu&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return vr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}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):vr}},vr=new We(0,0);vr.toBigInt=function(){return 0n};vr.zzEncode=vr.zzDecode=function(){return this};vr.length=function(){return 1};var Zu=4294967296n;function Qu(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 Ju(r,e,t){if(t-e<1)return"";let o,s=[],i=0,a;for(;e<t;)a=r[e++],a<128?s[i++]=a:a>191&&a<224?s[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,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Ya(r,e,t){let n=t,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function ut(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Go(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Wa=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,ut(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 ut(this,4);return Go(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ut(this,4);return Go(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ut(this,4);let e=Wu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ut(this,4);let e=Xu(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 ut(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Ju(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ut(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ut(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 We(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 ut(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 ut(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 ut(this,8);let e=Go(this.buf,this.pos+=4),t=Go(this.buf,this.pos+=4);return new We(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=$a(this.buf,this.pos);return this.pos+=me(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 ja(r){return new Wa(r instanceof Uint8Array?r:r.subarray())}function Ve(r,e,t){let n=ja(r);return e.decode(n,void 0,t)}function Xa(r){let e=r??8192,t=e>>>1,n,o=e;return function(i){if(i<1||i>t)return Le(i);o+i>e&&(n=Le(e),o=0);let a=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),a}}var _r=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Za(){}var Ja=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Ng=Xa();function Lg(r){return globalThis.Buffer!=null?Le(r):Ng(r)}var Hn=class{len;head;tail;states;constructor(){this.len=0,this.head=new _r(Za,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new _r(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ec((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(Yo,10,We.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=We.fromBigInt(e);return this._push(Yo,t.length(),t)}uint64Number(e){return this._push(qa,me(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=We.fromBigInt(e).zzEncode();return this._push(Yo,t.length(),t)}sint64Number(e){let t=We.fromNumber(e).zzEncode();return this._push(Yo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Qa,1,e?1:0)}fixed32(e){return this._push(Kn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=We.fromBigInt(e);return this._push(Kn,4,t.lo)._push(Kn,4,t.hi)}fixed64Number(e){let t=We.fromNumber(e);return this._push(Kn,4,t.lo)._push(Kn,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(Yu,4,e)}double(e){return this._push(ju,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Qa,1,0):this.uint32(t)._push(Pg,t,e)}string(e){let t=Qu(e);return t!==0?this.uint32(t)._push(Ya,t,e):this._push(Qa,1,0)}fork(){return this.states=new Ja(this),this.head=this.tail=new _r(Za,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 _r(Za,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=Lg(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Qa(r,e,t){e[t]=r&255}function Dg(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ec=class extends _r{next;constructor(e,t){super(Dg,e,t),this.next=void 0}};function Yo(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 Kn(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 Pg(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Hn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Og,e,r),this},Hn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Ug,e,r),this});function Og(r,e,t){e.set(r,t)}function Ug(r,e,t){r.length<40?Ya(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(L(r),t)}function tc(){return new Hn}function Ke(r,e){let t=tc();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var rn;(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"})(rn||(rn={}));function Wo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function rc(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(s,i){let a=e(s);i.int32(a)},n=function(s){let i=s.int32();return e(i)};return Wo("enum",rn.VARINT,t,n)}function He(r,e){return Wo("message",rn.LENGTH_DELIMITED,r,e)}var oe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(oe||(oe={}));var nc;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(nc||(nc={}));(function(r){r.codec=()=>rc(nc)})(oe||(oe={}));var yt;(function(r){let e;r.codec=()=>(e==null&&(e=He((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),oe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=oe.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>Ke(t,r.codec()),r.decode=t=>Ve(t,r.codec())})(yt||(yt={}));var wt;(function(r){let e;r.codec=()=>(e==null&&(e=He((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),oe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=oe.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>Ke(t,r.codec()),r.decode=t=>Ve(t,r.codec())})(wt||(wt={}));var qn=class{_key;constructor(e){this._key=nn(e,en)}verify(e,t){return $u(this._key,t,e)}marshal(){return this._key}get bytes(){return yt.encode({Type:oe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return te(this.bytes,e.bytes)}hash(){let e=Re.digest(this.bytes);return rt(e)?e.then(({bytes:t})=>t):e.bytes}},Ar=class{_key;_publicKey;constructor(e,t){this._key=nn(e,Lt),this._publicKey=nn(t,en)}sign(e){return qu(this._key,e)}get public(){return new qn(this._publicKey)}marshal(){return this._key}get bytes(){return wt.encode({Type:oe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return te(this.bytes,e.bytes)}async hash(){let e=Re.digest(this.bytes),t;return rt(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Bt.digest(this.public.bytes);return ie.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return tn(this.bytes,e);throw new E(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Mg(r){if(r.length>Lt){r=nn(r,Lt+en);let n=r.subarray(0,Lt),o=r.subarray(Lt,r.length);return new Ar(n,o)}r=nn(r,Lt);let e=r.subarray(0,Lt),t=r.subarray(en);return new Ar(e,t)}function Fg(r){return r=nn(r,en),new qn(r)}async function Vg(){let{privateKey:r,publicKey:e}=Ku();return new Ar(r,e)}async function tf(r){let{privateKey:e,publicKey:t}=Hu(r);return new Ar(e,t)}function nn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new E(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function F(r,e="utf8"){let t=Do[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var pc={};ve(pc,{MAX_RSA_KEY_SIZE:()=>to,RsaPrivateKey:()=>ln,RsaPublicKey:()=>eo,fromJwk:()=>d0,generateKeyPair:()=>p0,unmarshalRsaPrivateKey:()=>hc,unmarshalRsaPublicKey:()=>h0});function bt(r){if(isNaN(r)||r<=0)throw new E("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Xr(r)}var sr={};ve(sr,{exportToPem:()=>a0,importFromPem:()=>c0,jwkToPkcs1:()=>n0,jwkToPkix:()=>s0,pkcs1ToJwk:()=>r0,pkixToJwk:()=>o0});var Xo=class extends Wr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Po(e);let n=jt(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 o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return Yr(this),this.iHash.update(e),this}digestInto(e){Yr(this),Gr(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:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,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()}},$n=(r,e,t)=>new Xo(r,e).update(t).digest();$n.create=(r,e)=>new Xo(r,e);function Kg(r,e,t,n){Po(r);let o=Su({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:a}=o;if(zr(s),zr(i),zr(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=jt(e),u=jt(t),f=new Uint8Array(i),l=$n.create(r,c),p=l._cloneInto().update(u);return{c:s,dkLen:i,asyncTick:a,DK:f,PRF:l,PRFSalt:p}}function Hg(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function sc(r,e,t,n){let{c:o,dkLen:s,asyncTick:i,DK:a,PRF:c,PRFSalt:u}=Kg(r,e,t,n),f,l=new Uint8Array(4),p=jr(l),h=new Uint8Array(c.outputLen);for(let d=1,m=0;m<s;d++,m+=c.outputLen){let y=a.subarray(m,m+c.outputLen);p.setInt32(0,d,!1),(f=u._cloneInto(f)).update(l).digestInto(h),y.set(h.subarray(0,y.length)),await _u(o-1,i,()=>{c._cloneInto(f).update(h).digestInto(h);for(let g=0;g<y.length;g++)y[g]^=h[g]})}return Hg(c,u,a,f,h)}var z=St(rf());function Sr(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 rr(r,e,t=-1){let n=t,o=r,s=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),s=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}let u=new Uint8Array(c);for(let f=a-1;f>=0;f--){let l=Math.pow(2,f*e);u[s-f-1]=Math.floor(o/l),o-=u[s-f-1]*l}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Jo(...r){let e=0,t=0;for(let s of r)e+=s.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let s of r)o.set(s,t),t+=s.length;return o}function ac(){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=Sr(t,8),o=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)s[a]=r[a];return s[0]&=127,Sr(s,8)-n}function nf(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=rr(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=rr(e,8,n),s=new Uint8Array(o);if(s[0]&128){let i=o.slice(0),a=new Uint8Array(i);o=new ArrayBuffer(o.byteLength+1),s=new Uint8Array(o);for(let c=0;c<i.byteLength;c++)s[c+1]=a[c];s[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function of(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function ze(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let i=0;i<n;i++)o[i]="0";return o.join("").concat(t)}var a1=Math.log(2);function es(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function cc(r){let e=0,t=0;for(let o=0;o<r.length;o++){let s=r[o];e+=s.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let s=r[o];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function Mt(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 Gn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return cc(this.items)}},zn=[new Uint8Array([1])],sf="0123456789";var an="",ht=new ArrayBuffer(0),lc=new Uint8Array(0),Yn="EndOfContent",cf="OCTET STRING",lf="BIT STRING";function Ft(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let s=n[0]||{};this.isHexOnly=(o=s.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=s.valueHex?z.BufferSourceConverter.toUint8Array(s.valueHex):lc}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,s){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Mt(this,i,o,s))return-1;let a=o+s;return this.valueHexView=i.subarray(o,a),this.valueHexView.length?(this.blockLength=s,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",ht)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Pt=class{constructor({blockLength:e=0,error:t=an,warnings:n=[],valueBeforeDecode:o=lc}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=z.BufferSourceConverter.toUint8Array(o)}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:z.Convert.ToHex(this.valueBeforeDecodeView)}}};Pt.NAME="baseBlock";var Ue=class extends Pt{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'")}};Ue.NAME="valueBlock";var ts=class extends Ft(Pt){constructor({idBlock:e={}}={}){var t,n,o,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?z.BufferSourceConverter.toUint8Array(e.valueHex):lc,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!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",ht}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=rr(this.tagNumber,7),s=new Uint8Array(o),i=o.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let c=0;c<i-1;c++)a[c+1]=s[c]|128;a[i]=s[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let s=0;s<o.length-1;s++)n[s+1]=o[s]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=z.BufferSourceConverter.toUint8Array(e);if(!Mt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[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=(s[0]&32)===32,this.isHexOnly=!1;let a=s[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;s[c]&128;){if(u[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let p=new Uint8Array(f);for(let h=0;h<u.length;h++)p[h]=u[h];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=s[c]&127;let l=new Uint8Array(c);for(let p=0;p<c;p++)l[p]=u[p];u=this.valueHexView=new Uint8Array(c),u.set(l),this.blockLength<=9?this.tagNumber=Sr(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}}};ts.NAME="identificationBlock";var rs=class extends Pt{constructor({lenBlock:e={}}={}){var t,n,o;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=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=z.BufferSourceConverter.toUint8Array(e);if(!Mt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;let i=s[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Sr(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 o=rr(this.length,8);if(o.byteLength>127)return this.error="Too big length",ht;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let s=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let i=0;i<o.byteLength;i++)n[i+1]=s[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}}};rs.NAME="lengthBlock";var T={},Be=class extends Pt{constructor({name:e=an,optional:t=!1,primitiveSchema:n,...o}={},s){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new ts(o),this.lenBlock=new rs(o),this.valueBlock=s?new s(o):new Ue(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}toBER(e,t){let n=t||new Gn;t||uf(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(s)}return t?ht: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():z.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${z.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 of(t,n)}};Be.NAME="BaseBlock";function uf(r){if(r instanceof T.Constructed)for(let e of r.valueBlock.value)uf(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var ns=class extends Be{constructor({value:e=an,...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 o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};ns.NAME="BaseStringBlock";var os=class extends Ft(Ue){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};os.NAME="PrimitiveValueBlock";var ff,ss=class extends Be{constructor(e={}){super(e,os),this.idBlock.isConstructed=!1}};ff=ss;T.Primitive=ff;ss.NAME="PRIMITIVE";function Zg(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 Ms(r,e=0,t=r.length){let n=e,o=new Be({},Ue),s=new Pt;if(!Mt(s,r,e,t))return o.error=s.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=Be;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=T.EndOfContent;break;case 1:c=T.Boolean;break;case 2:c=T.Integer;break;case 3:c=T.BitString;break;case 4:c=T.OctetString;break;case 5:c=T.Null;break;case 6:c=T.ObjectIdentifier;break;case 10:c=T.Enumerated;break;case 12:c=T.Utf8String;break;case 13:c=T.RelativeObjectIdentifier;break;case 14:c=T.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=T.Sequence;break;case 17:c=T.Set;break;case 18:c=T.NumericString;break;case 19:c=T.PrintableString;break;case 20:c=T.TeletexString;break;case 21:c=T.VideotexString;break;case 22:c=T.IA5String;break;case 23:c=T.UTCTime;break;case 24:c=T.GeneralizedTime;break;case 25:c=T.GraphicString;break;case 26:c=T.VisibleString;break;case 27:c=T.GeneralString;break;case 28:c=T.UniversalString;break;case 29:c=T.CharacterString;break;case 30:c=T.BmpString;break;case 31:c=T.DATE;break;case 32:c=T.TimeOfDay;break;case 33:c=T.DateTime;break;case 34:c=T.Duration;break;default:{let u=o.idBlock.isConstructed?new T.Constructed:new T.Primitive;u.idBlock=o.idBlock,u.lenBlock=o.lenBlock,u.warnings=o.warnings,o=u}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?T.Constructed:T.Primitive}return o=Zg(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function cn(r){if(!r.byteLength){let e=new Be({},Ue);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ms(z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Qg(r,e){return r?1:e}var Et=class extends Ue{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=z.BufferSourceConverter.toUint8Array(e);if(!Mt(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Qg(this.isIndefiniteForm,n)>0;){let i=Ms(o,s,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(s=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Yn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Yn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){let n=t||new Gn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?ht:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Et.NAME="ConstructedValueBlock";var hf,nr=class extends Be{constructor(e={}){super(e,Et),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
2
+ "use strict";var Libp2P=(()=>{var cp=Object.create;var Bo=Object.defineProperty;var lp=Object.getOwnPropertyDescriptor;var up=Object.getOwnPropertyNames;var fp=Object.getPrototypeOf,hp=Object.prototype.hasOwnProperty;var et=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),ve=(r,e)=>{for(var t in e)Bo(r,t,{get:e[t],enumerable:!0})},Ql=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of up(e))!hp.call(r,o)&&o!==t&&Bo(r,o,{get:()=>e[o],enumerable:!(n=lp(e,o))||n.enumerable});return r};var St=(r,e,t)=>(t=r!=null?cp(fp(r)):{},Ql(e||!r||!r.__esModule?Bo(t,"default",{value:r,enumerable:!0}):t,r)),dp=r=>Ql(Bo({},"__esModule",{value:!0}),r);var rf=et(on=>{"use strict";var qg="[object ArrayBuffer]",Dt=class r{static isArrayBuffer(e){return Object.prototype.toString.call(e)===qg}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),o=r.toUint8Array(t);if(n.length!==o.byteLength)return!1;for(let s=0;s<n.length;s++)if(n[s]!==o[s])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 o=new Uint8Array(n),s=0;for(let i of t){let a=this.toUint8Array(i);o.set(a,s),s+=a.length}return e[e.length-1]instanceof Function?this.toView(o,e[e.length-1]):o.buffer}},ic="string",$g=/^[0-9a-f]+$/i,zg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,Gg=/^[a-zA-Z0-9-_]+$/,Zo=class{static fromString(e){let t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n.buffer}static toString(e){let t=Dt.toUint8Array(e),n="";for(let s=0;s<t.length;s++)n+=String.fromCharCode(t[s]);return decodeURIComponent(escape(n))}},nt=class{static toString(e,t=!1){let n=Dt.toArrayBuffer(e),o=new DataView(n),s="";for(let i=0;i<n.byteLength;i+=2){let a=o.getUint16(i,t);s+=String.fromCharCode(a)}return s}static fromString(e,t=!1){let n=new ArrayBuffer(e.length*2),o=new DataView(n);for(let s=0;s<e.length;s++)o.setUint16(s*2,e.charCodeAt(s),t);return n}},Qo=class r{static isHex(e){return typeof e===ic&&$g.test(e)}static isBase64(e){return typeof e===ic&&zg.test(e)}static isBase64Url(e){return typeof e===ic&&Gg.test(e)}static ToString(e,t="utf8"){let n=Dt.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 nt.toString(n,!0);case"utf16":case"utf16be":return nt.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 nt.fromString(e,!0);case"utf16":case"utf16be":return nt.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){let t=Dt.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 Zo.fromString(e);case"utf16":case"utf16be":return nt.fromString(e);case"utf16le":case"usc2":return nt.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 Zo.toString(e);case"utf16":case"utf16be":return nt.toString(e);case"utf16le":case"usc2":return nt.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 o=0;o<t;o++)n[o]=e.charCodeAt(o);return n.buffer}static ToBinary(e){let t=Dt.toUint8Array(e),n="";for(let o=0;o<t.length;o++)n+=String.fromCharCode(t[o]);return n}static ToHex(e){let t=Dt.toUint8Array(e),n="",o=t.length;for(let s=0;s<o;s++){let i=t[s];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 o=0;o<t.length;o=o+2){let s=t.slice(o,o+2);n[o/2]=parseInt(s,16)}return n.buffer}static ToUtf16String(e,t=!1){return nt.toString(e,t)}static FromUtf16String(e,t=!1){return nt.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,"")||""}};Qo.DEFAULT_UTF8_ENCODING="utf8";function Yg(r,...e){let t=arguments[0];for(let n=1;n<arguments.length;n++){let o=arguments[n];for(let s in o)t[s]=o[s]}return t}function Wg(...r){let e=r.map(o=>o.byteLength).reduce((o,s)=>o+s),t=new Uint8Array(e),n=0;return r.map(o=>new Uint8Array(o)).forEach(o=>{for(let s of o)t[n++]=s}),t.buffer}function jg(r,e){if(!(r&&e)||r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<r.byteLength;o++)if(t[o]!==n[o])return!1;return!0}on.BufferSourceConverter=Dt;on.Convert=Qo;on.assign=Yg;on.combine=Wg;on.isEqual=jg});var hh=et((ov,fh)=>{var un=1e3,fn=un*60,hn=fn*60,Ir=hn*24,B0=Ir*7,T0=Ir*365.25;fh.exports=function(r,e){e=e||{};var t=typeof r;if(t==="string"&&r.length>0)return C0(r);if(t==="number"&&isFinite(r))return e.long?N0(r):k0(r);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(r))};function C0(r){if(r=String(r),!(r.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(r);if(e){var t=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return t*T0;case"weeks":case"week":case"w":return t*B0;case"days":case"day":case"d":return t*Ir;case"hours":case"hour":case"hrs":case"hr":case"h":return t*hn;case"minutes":case"minute":case"mins":case"min":case"m":return t*fn;case"seconds":case"second":case"secs":case"sec":case"s":return t*un;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return t;default:return}}}}function k0(r){var e=Math.abs(r);return e>=Ir?Math.round(r/Ir)+"d":e>=hn?Math.round(r/hn)+"h":e>=fn?Math.round(r/fn)+"m":e>=un?Math.round(r/un)+"s":r+"ms"}function N0(r){var e=Math.abs(r);return e>=Ir?Vs(r,e,Ir,"day"):e>=hn?Vs(r,e,hn,"hour"):e>=fn?Vs(r,e,fn,"minute"):e>=un?Vs(r,e,un,"second"):r+" ms"}function Vs(r,e,t,n){var o=e>=t*1.5;return Math.round(r/t)+" "+n+(o?"s":"")}});var ph=et((sv,dh)=>{function L0(r){t.debug=t,t.default=t,t.coerce=c,t.disable=s,t.enable=o,t.enabled=i,t.humanize=hh(),t.destroy=u,Object.keys(r).forEach(f=>{t[f]=r[f]}),t.names=[],t.skips=[],t.formatters={};function e(f){let l=0;for(let p=0;p<f.length;p++)l=(l<<5)-l+f.charCodeAt(p),l|=0;return t.colors[Math.abs(l)%t.colors.length]}t.selectColor=e;function t(f){let l,p=null,h,d;function m(...y){if(!m.enabled)return;let g=m,w=Number(new Date),b=w-(l||w);g.diff=b,g.prev=l,g.curr=w,l=w,y[0]=t.coerce(y[0]),typeof y[0]!="string"&&y.unshift("%O");let x=0;y[0]=y[0].replace(/%([a-zA-Z%])/g,(S,_)=>{if(S==="%%")return"%";x++;let R=t.formatters[_];if(typeof R=="function"){let q=y[x];S=R.call(g,q),y.splice(x,1),x--}return S}),t.formatArgs.call(g,y),(g.log||t.log).apply(g,y)}return m.namespace=f,m.useColors=t.useColors(),m.color=t.selectColor(f),m.extend=n,m.destroy=t.destroy,Object.defineProperty(m,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(h!==t.namespaces&&(h=t.namespaces,d=t.enabled(f)),d),set:y=>{p=y}}),typeof t.init=="function"&&t.init(m),m}function n(f,l){let p=t(this.namespace+(typeof l>"u"?":":l)+f);return p.log=this.log,p}function o(f){t.save(f),t.namespaces=f,t.names=[],t.skips=[];let l,p=(typeof f=="string"?f:"").split(/[\s,]+/),h=p.length;for(l=0;l<h;l++)p[l]&&(f=p[l].replace(/\*/g,".*?"),f[0]==="-"?t.skips.push(new RegExp("^"+f.slice(1)+"$")):t.names.push(new RegExp("^"+f+"$")))}function s(){let f=[...t.names.map(a),...t.skips.map(a).map(l=>"-"+l)].join(",");return t.enable(""),f}function i(f){if(f[f.length-1]==="*")return!0;let l,p;for(l=0,p=t.skips.length;l<p;l++)if(t.skips[l].test(f))return!1;for(l=0,p=t.names.length;l<p;l++)if(t.names[l].test(f))return!0;return!1}function a(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}function c(f){return f instanceof Error?f.stack||f.message:f}function u(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return t.enable(t.load()),t}dh.exports=L0});var mh=et((je,Ks)=>{je.formatArgs=P0;je.save=O0;je.load=U0;je.useColors=D0;je.storage=M0();je.destroy=(()=>{let r=!1;return()=>{r||(r=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();je.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function D0(){if(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))return!0;if(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let r;return typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&(r=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(r[1],10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function P0(r){if(r[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+r[0]+(this.useColors?"%c ":" ")+"+"+Ks.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;r.splice(1,0,e,"color: inherit");let t=0,n=0;r[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(t++,o==="%c"&&(n=t))}),r.splice(n,0,e)}je.log=console.debug||console.log||(()=>{});function O0(r){try{r?je.storage.setItem("debug",r):je.storage.removeItem("debug")}catch{}}function U0(){let r;try{r=je.storage.getItem("debug")}catch{}return!r&&typeof process<"u"&&"env"in process&&(r=process.env.DEBUG),r}function M0(){try{return localStorage}catch{}}Ks.exports=ph()(je);var{formatters:F0}=Ks.exports;F0.j=function(r){try{return JSON.stringify(r)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var Eh=et((ao,qs)=>{(function(r,e){"use strict";var t={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function n(h){if(!Array.isArray(h)&&!ArrayBuffer.isView(h))return!1;for(var d=0;d<h.length;d++)if(!Number.isInteger(h[d])||h[d]<0||h[d]>255)return!1;return!0}function o(h,d){return(h&65535)*d+(((h>>>16)*d&65535)<<16)}function s(h,d){return h<<d|h>>>32-d}function i(h){return h^=h>>>16,h=o(h,2246822507),h^=h>>>13,h=o(h,3266489909),h^=h>>>16,h}function a(h,d){h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535],d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535];var m=[0,0,0,0];return m[3]+=h[3]+d[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=h[2]+d[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=h[1]+d[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=h[0]+d[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function c(h,d){h=[h[0]>>>16,h[0]&65535,h[1]>>>16,h[1]&65535],d=[d[0]>>>16,d[0]&65535,d[1]>>>16,d[1]&65535];var m=[0,0,0,0];return m[3]+=h[3]*d[3],m[2]+=m[3]>>>16,m[3]&=65535,m[2]+=h[2]*d[3],m[1]+=m[2]>>>16,m[2]&=65535,m[2]+=h[3]*d[2],m[1]+=m[2]>>>16,m[2]&=65535,m[1]+=h[1]*d[3],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=h[2]*d[2],m[0]+=m[1]>>>16,m[1]&=65535,m[1]+=h[3]*d[1],m[0]+=m[1]>>>16,m[1]&=65535,m[0]+=h[0]*d[3]+h[1]*d[2]+h[2]*d[1]+h[3]*d[0],m[0]&=65535,[m[0]<<16|m[1],m[2]<<16|m[3]]}function u(h,d){return d%=64,d===32?[h[1],h[0]]:d<32?[h[0]<<d|h[1]>>>32-d,h[1]<<d|h[0]>>>32-d]:(d-=32,[h[1]<<d|h[0]>>>32-d,h[0]<<d|h[1]>>>32-d])}function f(h,d){return d%=64,d===0?h:d<32?[h[0]<<d|h[1]>>>32-d,h[1]<<d]:[h[1]<<d-32,0]}function l(h,d){return[h[0]^d[0],h[1]^d[1]]}function p(h){return h=l(h,[0,h[0]>>>1]),h=c(h,[4283543511,3981806797]),h=l(h,[0,h[0]>>>1]),h=c(h,[3301882366,444984403]),h=l(h,[0,h[0]>>>1]),h}t.x86.hash32=function(h,d){if(t.inputValidation&&!n(h))return e;d=d||0;for(var m=h.length%4,y=h.length-m,g=d,w=0,b=3432918353,x=461845907,v=0;v<y;v=v+4)w=h[v]|h[v+1]<<8|h[v+2]<<16|h[v+3]<<24,w=o(w,b),w=s(w,15),w=o(w,x),g^=w,g=s(g,13),g=o(g,5)+3864292196;switch(w=0,m){case 3:w^=h[v+2]<<16;case 2:w^=h[v+1]<<8;case 1:w^=h[v],w=o(w,b),w=s(w,15),w=o(w,x),g^=w}return g^=h.length,g=i(g),g>>>0},t.x86.hash128=function(h,d){if(t.inputValidation&&!n(h))return e;d=d||0;for(var m=h.length%16,y=h.length-m,g=d,w=d,b=d,x=d,v=0,S=0,_=0,R=0,q=597399067,$=2869860233,U=951274213,ee=2716044179,D=0;D<y;D=D+16)v=h[D]|h[D+1]<<8|h[D+2]<<16|h[D+3]<<24,S=h[D+4]|h[D+5]<<8|h[D+6]<<16|h[D+7]<<24,_=h[D+8]|h[D+9]<<8|h[D+10]<<16|h[D+11]<<24,R=h[D+12]|h[D+13]<<8|h[D+14]<<16|h[D+15]<<24,v=o(v,q),v=s(v,15),v=o(v,$),g^=v,g=s(g,19),g+=w,g=o(g,5)+1444728091,S=o(S,$),S=s(S,16),S=o(S,U),w^=S,w=s(w,17),w+=b,w=o(w,5)+197830471,_=o(_,U),_=s(_,17),_=o(_,ee),b^=_,b=s(b,15),b+=x,b=o(b,5)+2530024501,R=o(R,ee),R=s(R,18),R=o(R,q),x^=R,x=s(x,13),x+=g,x=o(x,5)+850148119;switch(v=0,S=0,_=0,R=0,m){case 15:R^=h[D+14]<<16;case 14:R^=h[D+13]<<8;case 13:R^=h[D+12],R=o(R,ee),R=s(R,18),R=o(R,q),x^=R;case 12:_^=h[D+11]<<24;case 11:_^=h[D+10]<<16;case 10:_^=h[D+9]<<8;case 9:_^=h[D+8],_=o(_,U),_=s(_,17),_=o(_,ee),b^=_;case 8:S^=h[D+7]<<24;case 7:S^=h[D+6]<<16;case 6:S^=h[D+5]<<8;case 5:S^=h[D+4],S=o(S,$),S=s(S,16),S=o(S,U),w^=S;case 4:v^=h[D+3]<<24;case 3:v^=h[D+2]<<16;case 2:v^=h[D+1]<<8;case 1:v^=h[D],v=o(v,q),v=s(v,15),v=o(v,$),g^=v}return g^=h.length,w^=h.length,b^=h.length,x^=h.length,g+=w,g+=b,g+=x,w+=g,b+=g,x+=g,g=i(g),w=i(w),b=i(b),x=i(x),g+=w,g+=b,g+=x,w+=g,b+=g,x+=g,("00000000"+(g>>>0).toString(16)).slice(-8)+("00000000"+(w>>>0).toString(16)).slice(-8)+("00000000"+(b>>>0).toString(16)).slice(-8)+("00000000"+(x>>>0).toString(16)).slice(-8)},t.x64.hash128=function(h,d){if(t.inputValidation&&!n(h))return e;d=d||0;for(var m=h.length%16,y=h.length-m,g=[0,d],w=[0,d],b=[0,0],x=[0,0],v=[2277735313,289559509],S=[1291169091,658871167],_=0;_<y;_=_+16)b=[h[_+4]|h[_+5]<<8|h[_+6]<<16|h[_+7]<<24,h[_]|h[_+1]<<8|h[_+2]<<16|h[_+3]<<24],x=[h[_+12]|h[_+13]<<8|h[_+14]<<16|h[_+15]<<24,h[_+8]|h[_+9]<<8|h[_+10]<<16|h[_+11]<<24],b=c(b,v),b=u(b,31),b=c(b,S),g=l(g,b),g=u(g,27),g=a(g,w),g=a(c(g,[0,5]),[0,1390208809]),x=c(x,S),x=u(x,33),x=c(x,v),w=l(w,x),w=u(w,31),w=a(w,g),w=a(c(w,[0,5]),[0,944331445]);switch(b=[0,0],x=[0,0],m){case 15:x=l(x,f([0,h[_+14]],48));case 14:x=l(x,f([0,h[_+13]],40));case 13:x=l(x,f([0,h[_+12]],32));case 12:x=l(x,f([0,h[_+11]],24));case 11:x=l(x,f([0,h[_+10]],16));case 10:x=l(x,f([0,h[_+9]],8));case 9:x=l(x,[0,h[_+8]]),x=c(x,S),x=u(x,33),x=c(x,v),w=l(w,x);case 8:b=l(b,f([0,h[_+7]],56));case 7:b=l(b,f([0,h[_+6]],48));case 6:b=l(b,f([0,h[_+5]],40));case 5:b=l(b,f([0,h[_+4]],32));case 4:b=l(b,f([0,h[_+3]],24));case 3:b=l(b,f([0,h[_+2]],16));case 2:b=l(b,f([0,h[_+1]],8));case 1:b=l(b,[0,h[_]]),b=c(b,v),b=u(b,31),b=c(b,S),g=l(g,b)}return g=l(g,[0,h.length]),w=l(w,[0,h.length]),g=a(g,w),w=a(w,g),g=p(g),w=p(w),g=a(g,w),w=a(w,g),("00000000"+(g[0]>>>0).toString(16)).slice(-8)+("00000000"+(g[1]>>>0).toString(16)).slice(-8)+("00000000"+(w[0]>>>0).toString(16)).slice(-8)+("00000000"+(w[1]>>>0).toString(16)).slice(-8)},typeof ao<"u"?(typeof qs<"u"&&qs.exports&&(ao=qs.exports=t),ao.murmurHash3=t):typeof define=="function"&&define.amd?define([],function(){return t}):(t._murmurHash3=r.murmurHash3,t.noConflict=function(){return r.murmurHash3=t._murmurHash3,t._murmurHash3=e,t.noConflict=e,t},r.murmurHash3=t)})(ao)});var vh=et((Cv,xh)=>{xh.exports=Eh()});var Gh=et((i2,$c)=>{"use strict";var by=Object.prototype.hasOwnProperty,$e="~";function po(){}Object.create&&(po.prototype=Object.create(null),new po().__proto__||($e=!1));function Ey(r,e,t){this.fn=r,this.context=e,this.once=t||!1}function zh(r,e,t,n,o){if(typeof t!="function")throw new TypeError("The listener must be a function");var s=new Ey(t,n||r,o),i=$e?$e+e:e;return r._events[i]?r._events[i].fn?r._events[i]=[r._events[i],s]:r._events[i].push(s):(r._events[i]=s,r._eventsCount++),r}function Xs(r,e){--r._eventsCount===0?r._events=new po:delete r._events[e]}function Me(){this._events=new po,this._eventsCount=0}Me.prototype.eventNames=function(){var e=[],t,n;if(this._eventsCount===0)return e;for(n in t=this._events)by.call(t,n)&&e.push($e?n.slice(1):n);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e};Me.prototype.listeners=function(e){var t=$e?$e+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var o=0,s=n.length,i=new Array(s);o<s;o++)i[o]=n[o].fn;return i};Me.prototype.listenerCount=function(e){var t=$e?$e+e:e,n=this._events[t];return n?n.fn?1:n.length:0};Me.prototype.emit=function(e,t,n,o,s,i){var a=$e?$e+e:e;if(!this._events[a])return!1;var c=this._events[a],u=arguments.length,f,l;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),u){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,o),!0;case 5:return c.fn.call(c.context,t,n,o,s),!0;case 6:return c.fn.call(c.context,t,n,o,s,i),!0}for(l=1,f=new Array(u-1);l<u;l++)f[l-1]=arguments[l];c.fn.apply(c.context,f)}else{var p=c.length,h;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),u){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,o);break;default:if(!f)for(h=1,f=new Array(u-1);h<u;h++)f[h-1]=arguments[h];c[l].fn.apply(c[l].context,f)}}return!0};Me.prototype.on=function(e,t,n){return zh(this,e,t,n,!1)};Me.prototype.once=function(e,t,n){return zh(this,e,t,n,!0)};Me.prototype.removeListener=function(e,t,n,o){var s=$e?$e+e:e;if(!this._events[s])return this;if(!t)return Xs(this,s),this;var i=this._events[s];if(i.fn)i.fn===t&&(!o||i.once)&&(!n||i.context===n)&&Xs(this,s);else{for(var a=0,c=[],u=i.length;a<u;a++)(i[a].fn!==t||o&&!i[a].once||n&&i[a].context!==n)&&c.push(i[a]);c.length?this._events[s]=c.length===1?c[0]:c:Xs(this,s)}return this};Me.prototype.removeAllListeners=function(e){var t;return e?(t=$e?$e+e:e,this._events[t]&&Xs(this,t)):(this._events=new po,this._eventsCount=0),this};Me.prototype.off=Me.prototype.removeListener;Me.prototype.addListener=Me.prototype.on;Me.prefixed=$e;Me.EventEmitter=Me;typeof $c<"u"&&($c.exports=Me)});var al=et((SS,id)=>{"use strict";function sd(r,e){for(let t in e)Object.defineProperty(r,t,{value:e[t],enumerable:!0,configurable:!0});return r}function Uy(r,e,t){if(!r||typeof r=="string")throw new TypeError("Please pass an Error to err-code");t||(t={}),typeof e=="object"&&(t=e,e=""),e&&(t.code=e);try{return sd(r,t)}catch{t.message=r.message,t.stack=r.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(r)),sd(new o,t)}}id.exports=Uy});var hd=et(wo=>{(function(){var r,e,t,n,o,s,i,a;a=function(c){var u,f,l,p;return u=(c&255<<24)>>>24,f=(c&255<<16)>>>16,l=(c&65280)>>>8,p=c&255,[u,f,l,p].join(".")},i=function(c){var u,f,l,p,h,d;for(u=[],l=p=0;p<=3&&c.length!==0;l=++p){if(l>0){if(c[0]!==".")throw new Error("Invalid IP");c=c.substring(1)}d=e(c),h=d[0],f=d[1],c=c.substring(f),u.push(h)}if(c.length!==0)throw new Error("Invalid IP");switch(u.length){case 1:if(u[0]>4294967295)throw new Error("Invalid IP");return u[0]>>>0;case 2:if(u[0]>255||u[1]>16777215)throw new Error("Invalid IP");return(u[0]<<24|u[1])>>>0;case 3:if(u[0]>255||u[1]>255||u[2]>65535)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2])>>>0;case 4:if(u[0]>255||u[1]>255||u[2]>255||u[3]>255)throw new Error("Invalid IP");return(u[0]<<24|u[1]<<16|u[2]<<8|u[3])>>>0;default:throw new Error("Invalid IP")}},t=function(c){return c.charCodeAt(0)},n=t("0"),s=t("a"),o=t("A"),e=function(c){var u,f,l,p,h;for(p=0,u=10,f="9",l=0,c.length>1&&c[l]==="0"&&(c[l+1]==="x"||c[l+1]==="X"?(l+=2,u=16):"0"<=c[l+1]&&c[l+1]<="9"&&(l++,u=8,f="7")),h=l;l<c.length;){if("0"<=c[l]&&c[l]<=f)p=p*u+(t(c[l])-n)>>>0;else if(u===16)if("a"<=c[l]&&c[l]<="f")p=p*u+(10+t(c[l])-s)>>>0;else if("A"<=c[l]&&c[l]<="F")p=p*u+(10+t(c[l])-o)>>>0;else break;else break;if(p>4294967295)throw new Error("too large");l++}if(l===h)throw new Error("empty octet");return[p,l]},r=function(){function c(u,f){var l,p,h,d;if(typeof u!="string")throw new Error("Missing `net' parameter");if(f||(d=u.split("/",2),u=d[0],f=d[1]),f||(f=32),typeof f=="string"&&f.indexOf(".")>-1){try{this.maskLong=i(f)}catch(m){throw l=m,new Error("Invalid mask: "+f)}for(p=h=32;h>=0;p=--h)if(this.maskLong===4294967295<<32-p>>>0){this.bitmask=p;break}}else if(f||f===0)this.bitmask=parseInt(f,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0);else throw new Error("Invalid mask: empty");try{this.netLong=(i(u)&this.maskLong)>>>0}catch(m){throw l=m,new Error("Invalid net address: "+u)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+f);this.size=Math.pow(2,32-this.bitmask),this.base=a(this.netLong),this.mask=a(this.maskLong),this.hostmask=a(~this.maskLong),this.first=this.bitmask<=30?a(this.netLong+1):this.base,this.last=this.bitmask<=30?a(this.netLong+this.size-2):a(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?a(this.netLong+this.size-1):void 0}return c.prototype.contains=function(u){return typeof u=="string"&&(u.indexOf("/")>0||u.split(".").length!==4)&&(u=new c(u)),u instanceof c?this.contains(u.base)&&this.contains(u.broadcast||u.last):(i(u)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},c.prototype.next=function(u){return u==null&&(u=1),new c(a(this.netLong+this.size*u),this.mask)},c.prototype.forEach=function(u){var f,l,p;for(p=i(this.first),l=i(this.last),f=0;p<=l;)u(a(p),p,f),f++,p++},c.prototype.toString=function(){return this.base+"/"+this.bitmask},c}(),wo.ip2long=i,wo.long2ip=a,wo.Netmask=r}).call(wo)});var Sd=et((LR,Ad)=>{Ad.exports=function(r){if(!r)throw Error("hashlru must have a max value, of type number, greater than 0");var e=0,t=Object.create(null),n=Object.create(null);function o(s,i){t[s]=i,e++,e>=r&&(e=0,n=t,t=Object.create(null))}return{has:function(s){return t[s]!==void 0||n[s]!==void 0},remove:function(s){t[s]!==void 0&&(t[s]=void 0),n[s]!==void 0&&(n[s]=void 0)},get:function(s){var i=t[s];if(i!==void 0)return i;if((i=n[s])!==void 0)return o(s,i),i},set:function(s,i){t[s]!==void 0?t[s]=i:o(s,i)},clear:function(){t=Object.create(null),n=Object.create(null)}}}});var Cd=et((ZR,Td)=>{"use strict";Td.exports=r=>{if(Object.prototype.toString.call(r)!=="[object Object]")return!1;let e=Object.getPrototypeOf(r);return e===null||e===Object.prototype}});var Od=et((Dd,Pd)=>{"use strict";var yi=Cd(),{hasOwnProperty:Nd}=Object.prototype,{propertyIsEnumerable:fw}=Object,In=(r,e,t)=>Object.defineProperty(r,e,{value:t,writable:!0,enumerable:!0,configurable:!0}),hw=Dd,kd={concatArrays:!1,ignoreUndefined:!1},wi=r=>{let e=[];for(let t in r)Nd.call(r,t)&&e.push(t);if(Object.getOwnPropertySymbols){let t=Object.getOwnPropertySymbols(r);for(let n of t)fw.call(r,n)&&e.push(n)}return e};function Bn(r){return Array.isArray(r)?dw(r):yi(r)?pw(r):r}function dw(r){let e=r.slice(0,0);return wi(r).forEach(t=>{In(e,t,Bn(r[t]))}),e}function pw(r){let e=Object.getPrototypeOf(r)===null?Object.create(null):{};return wi(r).forEach(t=>{In(e,t,Bn(r[t]))}),e}var Ld=(r,e,t,n)=>(t.forEach(o=>{typeof e[o]>"u"&&n.ignoreUndefined||(o in r&&r[o]!==Object.getPrototypeOf(r)?In(r,o,xl(r[o],e[o],n)):In(r,o,Bn(e[o])))}),r),mw=(r,e,t)=>{let n=r.slice(0,0),o=0;return[r,e].forEach(s=>{let i=[];for(let a=0;a<s.length;a++)Nd.call(s,a)&&(i.push(String(a)),s===r?In(n,o++,s[a]):In(n,o++,Bn(s[a])));n=Ld(n,s,wi(s).filter(a=>!i.includes(a)),t)}),n};function xl(r,e,t){return t.concatArrays&&Array.isArray(r)&&Array.isArray(e)?mw(r,e,t):!yi(e)||!yi(r)?Bn(e):Ld(r,e,wi(e),t)}Pd.exports=function(...r){let e=xl(Bn(kd),this!==hw&&this||{},kd),t={_:{}};for(let n of r)if(n!==void 0){if(!yi(n))throw new TypeError("`"+n+"` is not an Option Object");t=xl(t,{_:n},e)}return t._}});var Vw={};ve(Vw,{createLibp2p:()=>Fw});var Jl=Symbol.for("@libp2p/connection");var Zi=Symbol.for("@libp2p/content-routing");var Qi=Symbol.for("@libp2p/peer-discovery");var To=Symbol.for("@libp2p/peer-id");function Co(r){return r!=null&&!!r[To]}var Ji=Symbol.for("@libp2p/peer-routing");var eu="keep-alive";var Ww=Symbol.for("@libp2p/transport");var zt;(function(r){r[r.FATAL_ALL=0]="FATAL_ALL",r[r.NO_FATAL=1]="NO_FATAL"})(zt||(zt={}));var Gt=class r extends Error{code;type;constructor(e="The operation was aborted"){super(e),this.name="AbortError",this.code=r.code,this.type=r.type}static code="ABORT_ERR";static type="aborted"},E=class extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}},ko=class extends AggregateError{code;props;constructor(e,t,n,o){super(e,t),this.code=n,this.name=o?.name??"AggregateCodeError",this.props=o??{}}};var No="ERR_TIMEOUT";var fe=(r,...e)=>{try{[...e]}catch{}};var Rt=class extends EventTarget{#e=new Map;constructor(){super(),fe(1/0,this)}listenerCount(e){let t=this.#e.get(e);return t==null?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let o=this.#e.get(e);o==null&&(o=[],this.#e.set(e,o)),o.push({callback:t,once:(n!==!0&&n!==!1&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let o=this.#e.get(e);o!=null&&(o=o.filter(({callback:s})=>s!==t),this.#e.set(e,o))}dispatchEvent(e){let t=super.dispatchEvent(e),n=this.#e.get(e.type);return n==null||(n=n.filter(({once:o})=>!o),this.#e.set(e.type,n)),t}safeDispatchEvent(e,t={}){return this.dispatchEvent(new ta(e,t))}},ea=class extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}},ta=globalThis.CustomEvent??ea;function tu(r){return r!=null&&typeof r.start=="function"&&typeof r.stop=="function"}var ra=Symbol.for("@libp2p/service-capabilities"),na=Symbol.for("@libp2p/service-dependencies");var oc={};ve(oc,{Ed25519PrivateKey:()=>Ar,Ed25519PublicKey:()=>qn,generateKeyPair:()=>Vg,generateKeyPairFromSeed:()=>tf,unmarshalEd25519PrivateKey:()=>Mg,unmarshalEd25519PublicKey:()=>Fg});var ca={};ve(ca,{base58btc:()=>ie,base58flickr:()=>bp});var Ab=new Uint8Array(0);function ru(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 nu(r){return new TextEncoder().encode(r)}function ou(r){return new TextDecoder().decode(r)}function pp(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 o=0;o<r.length;o++){var s=r.charAt(o),i=s.charCodeAt(0);if(t[i]!==255)throw new TypeError(s+" is ambiguous");t[i]=o}var a=r.length,c=r.charAt(0),u=Math.log(a)/Math.log(256),f=Math.log(256)/Math.log(a);function l(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var m=0,y=0,g=0,w=d.length;g!==w&&d[g]===0;)g++,m++;for(var b=(w-g)*f+1>>>0,x=new Uint8Array(b);g!==w;){for(var v=d[g],S=0,_=b-1;(v!==0||S<y)&&_!==-1;_--,S++)v+=256*x[_]>>>0,x[_]=v%a>>>0,v=v/a>>>0;if(v!==0)throw new Error("Non-zero carry");y=S,g++}for(var R=b-y;R!==b&&x[R]===0;)R++;for(var q=c.repeat(m);R<b;++R)q+=r.charAt(x[R]);return q}function p(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var m=0;if(d[m]!==" "){for(var y=0,g=0;d[m]===c;)y++,m++;for(var w=(d.length-m)*u+1>>>0,b=new Uint8Array(w);d[m];){var x=t[d.charCodeAt(m)];if(x===255)return;for(var v=0,S=w-1;(x!==0||v<g)&&S!==-1;S--,v++)x+=a*b[S]>>>0,b[S]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");g=v,m++}if(d[m]!==" "){for(var _=w-g;_!==w&&b[_]===0;)_++;for(var R=new Uint8Array(y+(w-_)),q=y;_!==w;)R[q++]=b[_++];return R}}}function h(d){var m=p(d);if(m)return m;throw new Error(`Non-${e} character`)}return{encode:l,decodeUnsafe:p,decode:h}}var mp=pp,gp=mp,iu=gp;var oa=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")}},sa=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 au(this,e)}},ia=class{decoders;constructor(e){this.decoders=e}or(e){return au(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 au(r,e){return new ia({...r.decoders??{[r.prefix]:r},...e.decoders??{[e.prefix]:e}})}var aa=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,o){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=o,this.encoder=new oa(e,t,n),this.decoder=new sa(e,t,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Kr({name:r,prefix:e,encode:t,decode:n}){return new aa(r,e,t,n)}function Yt({name:r,prefix:e,alphabet:t}){let{encode:n,decode:o}=iu(t,r);return Kr({prefix:e,name:r,encode:n,decode:s=>It(o(s))})}function yp(r,e,t,n){let o={};for(let f=0;f<e.length;++f)o[e[f]]=f;let s=r.length;for(;r[s-1]==="=";)--s;let i=new Uint8Array(s*t/8|0),a=0,c=0,u=0;for(let f=0;f<s;++f){let l=o[r[f]];if(l===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<t|l,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 wp(r,e,t){let n=e[e.length-1]==="=",o=(1<<t)-1,s="",i=0,a=0;for(let c=0;c<r.length;++c)for(a=a<<8|r[c],i+=8;i>t;)i-=t,s+=e[o&a>>i];if(i!==0&&(s+=e[o&a<<t-i]),n)for(;s.length*t&7;)s+="=";return s}function ce({name:r,prefix:e,bitsPerChar:t,alphabet:n}){return Kr({prefix:e,name:r,encode(o){return wp(o,n,t)},decode(o){return yp(o,n,t,r)}})}var ie=Yt({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bp=Yt({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ua={};ve(ua,{identity:()=>Bt});var Ep=uu,cu=128,xp=127,vp=~xp,_p=Math.pow(2,31);function uu(r,e,t){e=e||[],t=t||0;for(var n=t;r>=_p;)e[t++]=r&255|cu,r/=128;for(;r&vp;)e[t++]=r&255|cu,r>>>=7;return e[t]=r|0,uu.bytes=t-n+1,e}var Ap=la,Sp=128,lu=127;function la(r,n){var t=0,n=n||0,o=0,s=n,i,a=r.length;do{if(s>=a)throw la.bytes=0,new RangeError("Could not decode varint");i=r[s++],t+=o<28?(i&lu)<<o:(i&lu)*Math.pow(2,o),o+=7}while(i>=Sp);return la.bytes=s-n,t}var Rp=Math.pow(2,7),Ip=Math.pow(2,14),Bp=Math.pow(2,21),Tp=Math.pow(2,28),Cp=Math.pow(2,35),kp=Math.pow(2,42),Np=Math.pow(2,49),Lp=Math.pow(2,56),Dp=Math.pow(2,63),Pp=function(r){return r<Rp?1:r<Ip?2:r<Bp?3:r<Tp?4:r<Cp?5:r<kp?6:r<Np?7:r<Lp?8:r<Dp?9:10},Op={encode:Ep,decode:Ap,encodingLength:Pp},Up=Op,Dn=Up;function Pn(r,e=0){return[Dn.decode(r,e),Dn.decode.bytes]}function Hr(r,e,t=0){return Dn.encode(r,e,t),e}function qr(r){return Dn.encodingLength(r)}function mt(r,e){let t=e.byteLength,n=qr(r),o=n+qr(t),s=new Uint8Array(o+t);return Hr(r,s,0),Hr(t,s,n),s.set(e,o),new $r(r,t,e,s)}function gr(r){let e=It(r),[t,n]=Pn(e),[o,s]=Pn(e.subarray(n)),i=e.subarray(n+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new $r(t,o,i,e)}function fu(r,e){if(r===e)return!0;{let t=e;return r.code===t.code&&r.size===t.size&&t.bytes instanceof Uint8Array&&ru(r.bytes,t.bytes)}}var $r=class{code;size;digest;bytes;constructor(e,t,n,o){this.code=e,this.size=t,this.digest=n,this.bytes=o}};var hu=0,Mp="identity",du=It;function Fp(r){return mt(hu,du(r))}var Bt={code:hu,name:Mp,encode:du,digest:Fp};var da={};ve(da,{sha256:()=>Re,sha512:()=>Vp});function ha({name:r,code:e,encode:t}){return new fa(r,e,t)}var fa=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?mt(this.code,t):t.then(n=>mt(this.code,n))}else throw Error("Unknown type, must be binary type")}};function mu(r){return async e=>new Uint8Array(await crypto.subtle.digest(r,e))}var Re=ha({name:"sha2-256",code:18,encode:mu("SHA-256")}),Vp=ha({name:"sha2-512",code:19,encode:mu("SHA-512")});function te(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=0){return new Uint8Array(r)}function Le(r=0){return new Uint8Array(r)}function Ie(r,e){e==null&&(e=r.reduce((o,s)=>o+s.length,0));let t=Le(e),n=0;for(let o of r)t.set(o,n),n+=o.length;return t}var pa={};ve(pa,{base10:()=>Kp});var Kp=Yt({prefix:"9",name:"base10",alphabet:"0123456789"});var ma={};ve(ma,{base16:()=>Hp,base16upper:()=>qp});var Hp=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),qp=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ga={};ve(ga,{base2:()=>$p});var $p=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ya={};ve(ya,{base256emoji:()=>jp});var gu=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}"),zp=gu.reduce((r,e,t)=>(r[t]=e,r),[]),Gp=gu.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function Yp(r){return r.reduce((e,t)=>(e+=zp[t],e),"")}function Wp(r){let e=[];for(let t of r){let n=Gp[t.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(n)}return new Uint8Array(e)}var jp=Kr({prefix:"\u{1F680}",name:"base256emoji",encode:Yp,decode:Wp});var wa={};ve(wa,{base32:()=>Ge,base32hex:()=>Jp,base32hexpad:()=>tm,base32hexpadupper:()=>rm,base32hexupper:()=>em,base32pad:()=>Zp,base32padupper:()=>Qp,base32upper:()=>Xp,base32z:()=>nm});var Ge=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Xp=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Zp=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Qp=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Jp=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),em=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),tm=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),rm=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),nm=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ba={};ve(ba,{base36:()=>om,base36upper:()=>sm});var om=Yt({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),sm=Yt({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xa={};ve(xa,{base64:()=>On,base64pad:()=>im,base64url:()=>Ea,base64urlpad:()=>am});var On=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),im=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Ea=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),am=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var va={};ve(va,{base8:()=>cm});var cm=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var _a={};ve(_a,{identity:()=>lm});var lm=Kr({prefix:"\0",name:"identity",encode:r=>ou(r),decode:r=>nu(r)});var Qb=new TextEncoder,Jb=new TextDecoder;function yu(r,e){let{bytes:t,version:n}=r;switch(n){case 0:return dm(t,Aa(r),e??ie.encoder);default:return pm(t,Aa(r),e??Ge.encoder)}}var wu=new WeakMap;function Aa(r){let e=wu.get(r);if(e==null){let t=new Map;return wu.set(r,t),t}return e}var tt=class r{code;version;multihash;bytes;"/";constructor(e,t,n,o){this.code=t,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:t}=this;if(e!==Un)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==mm)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=mt(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&&fu(e.multihash,n.multihash)}toString(e){return yu(this,e)}toJSON(){return{"/":yu(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:o,multihash:s,bytes:i}=t;return new r(n,o,s,i??bu(n,o,s.bytes))}else if(t[gm]===!0){let{version:n,multihash:o,code:s}=t,i=gr(o);return r.create(n,s,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!==Un)throw new Error(`Version 0 CID must use dag-pb (code: ${Un}) block encoding`);return new r(e,t,n,n.bytes)}case 1:{let o=bu(e,t,n.bytes);return new r(e,t,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,Un,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,o=It(e.subarray(n,n+t.multihashSize));if(o.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=o.subarray(t.multihashSize-t.digestSize),i=new $r(t.multihashCode,t.digestSize,s,o);return[t.version===0?r.createV0(i):r.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0,n=()=>{let[l,p]=Pn(e.subarray(t));return t+=p,l},o=n(),s=Un;if(o===18?(o=0,t=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let i=t,a=n(),c=n(),u=t+c,f=u-i;return{version:o,codec:s,multihashCode:a,digestSize:c,multihashSize:f,size:u}}static parse(e,t){let[n,o]=hm(e,t),s=r.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return Aa(s).set(n,e),s}};function hm(r,e){switch(r[0]){case"Q":{let t=e??ie;return[ie.prefix,t.decode(`${ie.prefix}${r}`)]}case ie.prefix:{let t=e??ie;return[ie.prefix,t.decode(r)]}case Ge.prefix:{let t=e??Ge;return[Ge.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 dm(r,e,t){let{prefix:n}=t;if(n!==ie.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let o=e.get(n);if(o==null){let s=t.encode(r).slice(1);return e.set(n,s),s}else return o}function pm(r,e,t){let{prefix:n}=t,o=e.get(n);if(o==null){let s=t.encode(r);return e.set(n,s),s}else return o}var Un=112,mm=18;function bu(r,e,t){let n=qr(r),o=n+qr(e),s=new Uint8Array(o+t.byteLength);return Hr(r,s,0),Hr(e,s,n),s.set(t,o),s}var gm=Symbol.for("@ipld/js-cid/CID");var Wt={..._a,...ga,...va,...pa,...ma,...wa,...ba,...ca,...xa,...ya},mE={...da,...ua};function xu(r,e,t,n){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:n}}}var Eu=xu("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),Sa=xu("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=Le(r.length);for(let t=0;t<r.length;t++)e[t]=r.charCodeAt(t);return e}),ym={utf8:Eu,"utf-8":Eu,hex:Wt.base16,latin1:Sa,ascii:Sa,binary:Sa,...Wt},Do=ym;function L(r,e="utf8"){let t=Do[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.decoder.decode(`${t.prefix}${r}`)}function rt(r){return r==null?!1:typeof r.then=="function"&&typeof r.catch=="function"&&typeof r.finally=="function"}function zr(r){if(!Number.isSafeInteger(r)||r<0)throw new Error(`positive integer expected, not ${r}`)}function wm(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Gr(r,...e){if(!wm(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 Po(r){if(typeof r!="function"||typeof r.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");zr(r.outputLen),zr(r.blockLen)}function Yr(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 vu(r,e){Gr(r);let t=e.outputLen;if(r.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}var Oo=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;var jr=r=>new DataView(r.buffer,r.byteOffset,r.byteLength),at=(r,e)=>r<<32-e|r>>>e;var TE=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;var bm=async()=>{};async function _u(r,e,t){let n=Date.now();for(let o=0;o<r;o++){t(o);let s=Date.now()-n;s>=0&&s<e||(await bm(),n+=s)}}function Au(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function jt(r){return typeof r=="string"&&(r=Au(r)),Gr(r),r}function Ra(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Gr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let s=r[n];t.set(s,o),o+=s.length}return t}var Wr=class{clone(){return this._cloneInto()}},Em={}.toString;function Su(r,e){if(e!==void 0&&Em.call(e)!=="[object Object]")throw new Error("Options should be object or undefined");return Object.assign(r,e)}function Uo(r){let e=n=>r().update(jt(n)).digest(),t=r();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>r(),e}function Xr(r=32){if(Oo&&typeof Oo.getRandomValues=="function")return Oo.getRandomValues(new Uint8Array(r));throw new Error("crypto.getRandomValues must be defined")}function xm(r,e,t,n){if(typeof r.setBigUint64=="function")return r.setBigUint64(e,t,n);let o=BigInt(32),s=BigInt(4294967295),i=Number(t>>o&s),a=Number(t&s),c=n?4:0,u=n?0:4;r.setUint32(e+c,i,n),r.setUint32(e+u,a,n)}var Ru=(r,e,t)=>r&e^~r&t,Iu=(r,e,t)=>r&e^r&t^e&t,Zr=class extends Wr{constructor(e,t,n,o){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=o,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=jr(this.buffer)}update(e){Yr(this);let{view:t,buffer:n,blockLen:o}=this;e=jt(e);let s=e.length;for(let i=0;i<s;){let a=Math.min(o-this.pos,s-i);if(a===o){let c=jr(e);for(;o<=s-i;i+=o)this.process(c,i);continue}n.set(e.subarray(i,i+a),this.pos),this.pos+=a,i+=a,this.pos===o&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Yr(this),vu(e,this),this.finished=!0;let{buffer:t,view:n,blockLen:o,isLE:s}=this,{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>o-i&&(this.process(n,0),i=0);for(let l=i;l<o;l++)t[l]=0;xm(n,o-8,BigInt(this.length*8),s),this.process(n,0);let a=jr(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");let u=c/4,f=this.get();if(u>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<u;l++)a.setUint32(4*l,f[l],s)}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:o,finished:s,destroyed:i,pos:a}=this;return e.length=o,e.pos=a,e.finished=s,e.destroyed=i,o%t&&e.buffer.set(n),e}};var Mo=BigInt(4294967295),Ia=BigInt(32);function Bu(r,e=!1){return e?{h:Number(r&Mo),l:Number(r>>Ia&Mo)}:{h:Number(r>>Ia&Mo)|0,l:Number(r&Mo)|0}}function vm(r,e=!1){let t=new Uint32Array(r.length),n=new Uint32Array(r.length);for(let o=0;o<r.length;o++){let{h:s,l:i}=Bu(r[o],e);[t[o],n[o]]=[s,i]}return[t,n]}var _m=(r,e)=>BigInt(r>>>0)<<Ia|BigInt(e>>>0),Am=(r,e,t)=>r>>>t,Sm=(r,e,t)=>r<<32-t|e>>>t,Rm=(r,e,t)=>r>>>t|e<<32-t,Im=(r,e,t)=>r<<32-t|e>>>t,Bm=(r,e,t)=>r<<64-t|e>>>t-32,Tm=(r,e,t)=>r>>>t-32|e<<64-t,Cm=(r,e)=>e,km=(r,e)=>r,Nm=(r,e,t)=>r<<t|e>>>32-t,Lm=(r,e,t)=>e<<t|r>>>32-t,Dm=(r,e,t)=>e<<t-32|r>>>64-t,Pm=(r,e,t)=>r<<t-32|e>>>64-t;function Om(r,e,t,n){let o=(e>>>0)+(n>>>0);return{h:r+t+(o/2**32|0)|0,l:o|0}}var Um=(r,e,t)=>(r>>>0)+(e>>>0)+(t>>>0),Mm=(r,e,t,n)=>e+t+n+(r/2**32|0)|0,Fm=(r,e,t,n)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0),Vm=(r,e,t,n,o)=>e+t+n+o+(r/2**32|0)|0,Km=(r,e,t,n,o)=>(r>>>0)+(e>>>0)+(t>>>0)+(n>>>0)+(o>>>0),Hm=(r,e,t,n,o,s)=>e+t+n+o+s+(r/2**32|0)|0;var qm={fromBig:Bu,split:vm,toBig:_m,shrSH:Am,shrSL:Sm,rotrSH:Rm,rotrSL:Im,rotrBH:Bm,rotrBL:Tm,rotr32H:Cm,rotr32L:km,rotlSH:Nm,rotlSL:Lm,rotlBH:Dm,rotlBL:Pm,add:Om,add3L:Um,add3H:Mm,add4L:Fm,add4H:Vm,add5H:Hm,add5L:Km},M=qm;var[$m,zm]=M.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))),Xt=new Uint32Array(80),Zt=new Uint32Array(80),Ba=class extends Zr{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:o,Ch:s,Cl:i,Dh:a,Dl:c,Eh:u,El:f,Fh:l,Fl:p,Gh:h,Gl:d,Hh:m,Hl:y}=this;return[e,t,n,o,s,i,a,c,u,f,l,p,h,d,m,y]}set(e,t,n,o,s,i,a,c,u,f,l,p,h,d,m,y){this.Ah=e|0,this.Al=t|0,this.Bh=n|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=a|0,this.Dl=c|0,this.Eh=u|0,this.El=f|0,this.Fh=l|0,this.Fl=p|0,this.Gh=h|0,this.Gl=d|0,this.Hh=m|0,this.Hl=y|0}process(e,t){for(let b=0;b<16;b++,t+=4)Xt[b]=e.getUint32(t),Zt[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){let x=Xt[b-15]|0,v=Zt[b-15]|0,S=M.rotrSH(x,v,1)^M.rotrSH(x,v,8)^M.shrSH(x,v,7),_=M.rotrSL(x,v,1)^M.rotrSL(x,v,8)^M.shrSL(x,v,7),R=Xt[b-2]|0,q=Zt[b-2]|0,$=M.rotrSH(R,q,19)^M.rotrBH(R,q,61)^M.shrSH(R,q,6),U=M.rotrSL(R,q,19)^M.rotrBL(R,q,61)^M.shrSL(R,q,6),ee=M.add4L(_,U,Zt[b-7],Zt[b-16]),D=M.add4H(ee,S,$,Xt[b-7],Xt[b-16]);Xt[b]=D|0,Zt[b]=ee|0}let{Ah:n,Al:o,Bh:s,Bl:i,Ch:a,Cl:c,Dh:u,Dl:f,Eh:l,El:p,Fh:h,Fl:d,Gh:m,Gl:y,Hh:g,Hl:w}=this;for(let b=0;b<80;b++){let x=M.rotrSH(l,p,14)^M.rotrSH(l,p,18)^M.rotrBH(l,p,41),v=M.rotrSL(l,p,14)^M.rotrSL(l,p,18)^M.rotrBL(l,p,41),S=l&h^~l&m,_=p&d^~p&y,R=M.add5L(w,v,_,zm[b],Zt[b]),q=M.add5H(R,g,x,S,$m[b],Xt[b]),$=R|0,U=M.rotrSH(n,o,28)^M.rotrBH(n,o,34)^M.rotrBH(n,o,39),ee=M.rotrSL(n,o,28)^M.rotrBL(n,o,34)^M.rotrBL(n,o,39),D=n&s^n&a^s&a,Je=o&i^o&c^i&c;g=m|0,w=y|0,m=h|0,y=d|0,h=l|0,d=p|0,{h:l,l:p}=M.add(u|0,f|0,q|0,$|0),u=a|0,f=c|0,a=s|0,c=i|0,s=n|0,i=o|0;let I=M.add3L($,ee,Je);n=M.add3H(I,q,U,D),o=I|0}({h:n,l:o}=M.add(this.Ah|0,this.Al|0,n|0,o|0)),{h:s,l:i}=M.add(this.Bh|0,this.Bl|0,s|0,i|0),{h:a,l:c}=M.add(this.Ch|0,this.Cl|0,a|0,c|0),{h:u,l:f}=M.add(this.Dh|0,this.Dl|0,u|0,f|0),{h:l,l:p}=M.add(this.Eh|0,this.El|0,l|0,p|0),{h,l:d}=M.add(this.Fh|0,this.Fl|0,h|0,d|0),{h:m,l:y}=M.add(this.Gh|0,this.Gl|0,m|0,y|0),{h:g,l:w}=M.add(this.Hh|0,this.Hl|0,g|0,w|0),this.set(n,o,s,i,a,c,u,f,l,p,h,d,m,y,g,w)}roundClean(){Xt.fill(0),Zt.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 Mn=Uo(()=>new Ba);var Vo={};ve(Vo,{abytes:()=>Qr,bitGet:()=>Qm,bitLen:()=>Zm,bitMask:()=>Fn,bitSet:()=>Jm,bytesToHex:()=>Ct,bytesToNumberBE:()=>kt,bytesToNumberLE:()=>Jt,concatBytes:()=>Nt,createHmacDrbg:()=>ka,ensureBytes:()=>le,equalBytes:()=>jm,hexToBytes:()=>wr,hexToNumber:()=>Ca,isBytes:()=>Qt,numberToBytesBE:()=>er,numberToBytesLE:()=>br,numberToHexUnpadded:()=>Nu,numberToVarBytesBE:()=>Wm,utf8ToBytes:()=>Xm,validateObject:()=>gt});var ku=BigInt(0),Fo=BigInt(1),Gm=BigInt(2);function Qt(r){return r instanceof Uint8Array||r!=null&&typeof r=="object"&&r.constructor.name==="Uint8Array"}function Qr(r){if(!Qt(r))throw new Error("Uint8Array expected")}var Ym=Array.from({length:256},(r,e)=>e.toString(16).padStart(2,"0"));function Ct(r){Qr(r);let e="";for(let t=0;t<r.length;t++)e+=Ym[r[t]];return e}function Nu(r){let e=r.toString(16);return e.length&1?`0${e}`:e}function Ca(r){if(typeof r!="string")throw new Error("hex string expected, got "+typeof r);return BigInt(r===""?"0":`0x${r}`)}var Tt={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Tu(r){if(r>=Tt._0&&r<=Tt._9)return r-Tt._0;if(r>=Tt._A&&r<=Tt._F)return r-(Tt._A-10);if(r>=Tt._a&&r<=Tt._f)return r-(Tt._a-10)}function wr(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 o=0,s=0;o<t;o++,s+=2){let i=Tu(r.charCodeAt(s)),a=Tu(r.charCodeAt(s+1));if(i===void 0||a===void 0){let c=r[s]+r[s+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+s)}n[o]=i*16+a}return n}function kt(r){return Ca(Ct(r))}function Jt(r){return Qr(r),Ca(Ct(Uint8Array.from(r).reverse()))}function er(r,e){return wr(r.toString(16).padStart(e*2,"0"))}function br(r,e){return er(r,e).reverse()}function Wm(r){return wr(Nu(r))}function le(r,e,t){let n;if(typeof e=="string")try{n=wr(e)}catch(s){throw new Error(`${r} must be valid hex string, got "${e}". Cause: ${s}`)}else if(Qt(e))n=Uint8Array.from(e);else throw new Error(`${r} must be hex string or Uint8Array`);let o=n.length;if(typeof t=="number"&&o!==t)throw new Error(`${r} expected ${t} bytes, got ${o}`);return n}function Nt(...r){let e=0;for(let n=0;n<r.length;n++){let o=r[n];Qr(o),e+=o.length}let t=new Uint8Array(e);for(let n=0,o=0;n<r.length;n++){let s=r[n];t.set(s,o),o+=s.length}return t}function jm(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 Xm(r){if(typeof r!="string")throw new Error(`utf8ToBytes expected string, got ${typeof r}`);return new Uint8Array(new TextEncoder().encode(r))}function Zm(r){let e;for(e=0;r>ku;r>>=Fo,e+=1);return e}function Qm(r,e){return r>>BigInt(e)&Fo}function Jm(r,e,t){return r|(t?Fo:ku)<<BigInt(e)}var Fn=r=>(Gm<<BigInt(r-1))-Fo,Ta=r=>new Uint8Array(r),Cu=r=>Uint8Array.from(r);function ka(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=Ta(r),o=Ta(r),s=0,i=()=>{n.fill(1),o.fill(0),s=0},a=(...l)=>t(o,n,...l),c=(l=Ta())=>{o=a(Cu([0]),l),n=a(),l.length!==0&&(o=a(Cu([1]),l),n=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let l=0,p=[];for(;l<e;){n=a();let h=n.slice();p.push(h),l+=n.length}return Nt(...p)};return(l,p)=>{i(),c(l);let h;for(;!(h=p(u()));)c();return i(),h}}var eg={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"||Qt(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 gt(r,e,t={}){let n=(o,s,i)=>{let a=eg[s];if(typeof a!="function")throw new Error(`Invalid validator "${s}", expected function`);let c=r[o];if(!(i&&c===void 0)&&!a(c,r))throw new Error(`Invalid param ${String(o)}=${c} (${typeof c}), expected ${s}`)};for(let[o,s]of Object.entries(e))n(o,s,!1);for(let[o,s]of Object.entries(t))n(o,s,!0);return r}var we=BigInt(0),re=BigInt(1),Er=BigInt(2),tg=BigInt(3),Na=BigInt(4),Lu=BigInt(5),Du=BigInt(8),rg=BigInt(9),ng=BigInt(16);function Q(r,e){let t=r%e;return t>=we?t:e+t}function og(r,e,t){if(t<=we||e<we)throw new Error("Expected power/modulo > 0");if(t===re)return we;let n=re;for(;e>we;)e&re&&(n=n*r%t),r=r*r%t,e>>=re;return n}function ne(r,e,t){let n=r;for(;e-- >we;)n*=n,n%=t;return n}function Ko(r,e){if(r===we||e<=we)throw new Error(`invert: expected positive integers, got n=${r} mod=${e}`);let t=Q(r,e),n=e,o=we,s=re,i=re,a=we;for(;t!==we;){let u=n/t,f=n%t,l=o-i*u,p=s-a*u;n=t,t=f,o=i,s=a,i=l,a=p}if(n!==re)throw new Error("invert: does not exist");return Q(o,e)}function sg(r){let e=(r-re)/Er,t,n,o;for(t=r-re,n=0;t%Er===we;t/=Er,n++);for(o=Er;o<r&&og(o,e,r)!==r-re;o++);if(n===1){let i=(r+re)/Na;return function(c,u){let f=c.pow(u,i);if(!c.eql(c.sqr(f),u))throw new Error("Cannot find square root");return f}}let s=(t+re)/Er;return function(a,c){if(a.pow(c,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let u=n,f=a.pow(a.mul(a.ONE,o),t),l=a.pow(c,s),p=a.pow(c,t);for(;!a.eql(p,a.ONE);){if(a.eql(p,a.ZERO))return a.ZERO;let h=1;for(let m=a.sqr(p);h<u&&!a.eql(m,a.ONE);h++)m=a.sqr(m);let d=a.pow(f,re<<BigInt(u-h-1));f=a.sqr(d),l=a.mul(l,d),p=a.mul(p,f),u=h}return l}}function ig(r){if(r%Na===tg){let e=(r+re)/Na;return function(n,o){let s=n.pow(o,e);if(!n.eql(n.sqr(s),o))throw new Error("Cannot find square root");return s}}if(r%Du===Lu){let e=(r-Lu)/Du;return function(n,o){let s=n.mul(o,Er),i=n.pow(s,e),a=n.mul(o,i),c=n.mul(n.mul(a,Er),i),u=n.mul(a,n.sub(c,n.ONE));if(!n.eql(n.sqr(u),o))throw new Error("Cannot find square root");return u}}return r%ng,sg(r)}var Pu=(r,e)=>(Q(r,e)&re)===re,ag=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function La(r){let e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=ag.reduce((n,o)=>(n[o]="function",n),e);return gt(r,t)}function cg(r,e,t){if(t<we)throw new Error("Expected power > 0");if(t===we)return r.ONE;if(t===re)return e;let n=r.ONE,o=e;for(;t>we;)t&re&&(n=r.mul(n,o)),o=r.sqr(o),t>>=re;return n}function lg(r,e){let t=new Array(e.length),n=e.reduce((s,i,a)=>r.is0(i)?s:(t[a]=s,r.mul(s,i)),r.ONE),o=r.inv(n);return e.reduceRight((s,i,a)=>r.is0(i)?s:(t[a]=r.mul(s,t[a]),r.mul(s,i)),o),t}function Da(r,e){let t=e!==void 0?e:r.toString(2).length,n=Math.ceil(t/8);return{nBitLength:t,nByteLength:n}}function Ho(r,e,t=!1,n={}){if(r<=we)throw new Error(`Expected Field ORDER > 0, got ${r}`);let{nBitLength:o,nByteLength:s}=Da(r,e);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");let i=ig(r),a=Object.freeze({ORDER:r,BITS:o,BYTES:s,MASK:Fn(o),ZERO:we,ONE:re,create:c=>Q(c,r),isValid:c=>{if(typeof c!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);return we<=c&&c<r},is0:c=>c===we,isOdd:c=>(c&re)===re,neg:c=>Q(-c,r),eql:(c,u)=>c===u,sqr:c=>Q(c*c,r),add:(c,u)=>Q(c+u,r),sub:(c,u)=>Q(c-u,r),mul:(c,u)=>Q(c*u,r),pow:(c,u)=>cg(a,c,u),div:(c,u)=>Q(c*Ko(u,r),r),sqrN:c=>c*c,addN:(c,u)=>c+u,subN:(c,u)=>c-u,mulN:(c,u)=>c*u,inv:c=>Ko(c,r),sqrt:n.sqrt||(c=>i(a,c)),invertBatch:c=>lg(a,c),cmov:(c,u,f)=>f?u:c,toBytes:c=>t?br(c,s):er(c,s),fromBytes:c=>{if(c.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);return t?Jt(c):kt(c)}});return Object.freeze(a)}function Ou(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 Pa(r){let e=Ou(r);return e+Math.ceil(e/2)}function Uu(r,e,t=!1){let n=r.length,o=Ou(e),s=Pa(e);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);let i=t?kt(r):Jt(r),a=Q(i,e-re)+re;return t?br(a,o):er(a,o)}var fg=BigInt(0),Oa=BigInt(1);function qo(r,e){let t=(o,s)=>{let i=s.negate();return o?i:s},n=o=>{let s=Math.ceil(e/o)+1,i=2**(o-1);return{windows:s,windowSize:i}};return{constTimeNegate:t,unsafeLadder(o,s){let i=r.ZERO,a=o;for(;s>fg;)s&Oa&&(i=i.add(a)),a=a.double(),s>>=Oa;return i},precomputeWindow(o,s){let{windows:i,windowSize:a}=n(s),c=[],u=o,f=u;for(let l=0;l<i;l++){f=u,c.push(f);for(let p=1;p<a;p++)f=f.add(u),c.push(f);u=f.double()}return c},wNAF(o,s,i){let{windows:a,windowSize:c}=n(o),u=r.ZERO,f=r.BASE,l=BigInt(2**o-1),p=2**o,h=BigInt(o);for(let d=0;d<a;d++){let m=d*c,y=Number(i&l);i>>=h,y>c&&(y-=p,i+=Oa);let g=m,w=m+Math.abs(y)-1,b=d%2!==0,x=y<0;y===0?f=f.add(t(b,s[g])):u=u.add(t(x,s[w]))}return{p:u,f}},wNAFCached(o,s,i,a){let c=o._WINDOW_SIZE||1,u=s.get(o);return u||(u=this.precomputeWindow(o,c),c!==1&&s.set(o,a(u))),this.wNAF(c,u,i)}}}function Vn(r){return La(r.Fp),gt(r,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Da(r.n,r.nBitLength),...r,p:r.Fp.ORDER})}var ct=BigInt(0),Ye=BigInt(1),$o=BigInt(2),hg=BigInt(8),dg={zip215:!0};function pg(r){let e=Vn(r);return gt(r,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...e})}function Mu(r){let e=pg(r),{Fp:t,n,prehash:o,hash:s,randomBytes:i,nByteLength:a,h:c}=e,u=$o<<BigInt(a*8)-Ye,f=t.create,l=e.uvRatio||((B,A)=>{try{return{isValid:!0,value:t.sqrt(B*t.inv(A))}}catch{return{isValid:!1,value:ct}}}),p=e.adjustScalarBytes||(B=>B),h=e.domain||((B,A,k)=>{if(A.length||k)throw new Error("Contexts/pre-hash are not supported");return B}),d=B=>typeof B=="bigint"&&ct<B,m=(B,A)=>d(B)&&d(A)&&B<A,y=B=>B===ct||m(B,u);function g(B,A){if(m(B,A))return B;throw new Error(`Expected valid scalar < ${A}, got ${typeof B} ${B}`)}function w(B){return B===ct?B:g(B,n)}let b=new Map;function x(B){if(!(B instanceof v))throw new Error("ExtendedPoint expected")}class v{constructor(A,k,P,O){if(this.ex=A,this.ey=k,this.ez=P,this.et=O,!y(A))throw new Error("x required");if(!y(k))throw new Error("y required");if(!y(P))throw new Error("z required");if(!y(O))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(A){if(A instanceof v)throw new Error("extended point not allowed");let{x:k,y:P}=A||{};if(!y(k)||!y(P))throw new Error("invalid affine point");return new v(k,P,Ye,f(k*P))}static normalizeZ(A){let k=t.invertBatch(A.map(P=>P.ez));return A.map((P,O)=>P.toAffine(k[O])).map(v.fromAffine)}_setWindowSize(A){this._WINDOW_SIZE=A,b.delete(this)}assertValidity(){let{a:A,d:k}=e;if(this.is0())throw new Error("bad point: ZERO");let{ex:P,ey:O,ez:K,et:H}=this,W=f(P*P),G=f(O*O),Y=f(K*K),pe=f(Y*Y),ae=f(W*A),Ae=f(Y*f(ae+G)),Se=f(pe+f(k*f(W*G)));if(Ae!==Se)throw new Error("bad point: equation left != right (1)");let ye=f(P*O),Ne=f(K*H);if(ye!==Ne)throw new Error("bad point: equation left != right (2)")}equals(A){x(A);let{ex:k,ey:P,ez:O}=this,{ex:K,ey:H,ez:W}=A,G=f(k*W),Y=f(K*O),pe=f(P*W),ae=f(H*O);return G===Y&&pe===ae}is0(){return this.equals(v.ZERO)}negate(){return new v(f(-this.ex),this.ey,this.ez,f(-this.et))}double(){let{a:A}=e,{ex:k,ey:P,ez:O}=this,K=f(k*k),H=f(P*P),W=f($o*f(O*O)),G=f(A*K),Y=k+P,pe=f(f(Y*Y)-K-H),ae=G+H,Ae=ae-W,Se=G-H,ye=f(pe*Ae),Ne=f(ae*Se),At=f(pe*Se),mr=f(Ae*ae);return new v(ye,Ne,mr,At)}add(A){x(A);let{a:k,d:P}=e,{ex:O,ey:K,ez:H,et:W}=this,{ex:G,ey:Y,ez:pe,et:ae}=A;if(k===BigInt(-1)){let zl=f((K-O)*(Y+G)),Gl=f((K+O)*(Y-G)),Xi=f(Gl-zl);if(Xi===ct)return this.double();let Yl=f(H*$o*ae),Wl=f(W*$o*pe),jl=Wl+Yl,Xl=Gl+zl,Zl=Wl-Yl,op=f(jl*Xi),sp=f(Xl*Zl),ip=f(jl*Zl),ap=f(Xi*Xl);return new v(op,sp,ap,ip)}let Ae=f(O*G),Se=f(K*Y),ye=f(W*P*ae),Ne=f(H*pe),At=f((O+K)*(G+Y)-Ae-Se),mr=Ne-ye,Ln=Ne+ye,$l=f(Se-k*Ae),ep=f(At*mr),tp=f(Ln*$l),rp=f(At*$l),np=f(mr*Ln);return new v(ep,tp,np,rp)}subtract(A){return this.add(A.negate())}wNAF(A){return R.wNAFCached(this,b,A,v.normalizeZ)}multiply(A){let{p:k,f:P}=this.wNAF(g(A,n));return v.normalizeZ([k,P])[0]}multiplyUnsafe(A){let k=w(A);return k===ct?_:this.equals(_)||k===Ye?this:this.equals(S)?this.wNAF(k).p:R.unsafeLadder(this,k)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return R.unsafeLadder(this,n).is0()}toAffine(A){let{ex:k,ey:P,ez:O}=this,K=this.is0();A==null&&(A=K?hg:t.inv(O));let H=f(k*A),W=f(P*A),G=f(O*A);if(K)return{x:ct,y:Ye};if(G!==Ye)throw new Error("invZ was invalid");return{x:H,y:W}}clearCofactor(){let{h:A}=e;return A===Ye?this:this.multiplyUnsafe(A)}static fromHex(A,k=!1){let{d:P,a:O}=e,K=t.BYTES;A=le("pointHex",A,K);let H=A.slice(),W=A[K-1];H[K-1]=W&-129;let G=Jt(H);G===ct||(k?g(G,u):g(G,t.ORDER));let Y=f(G*G),pe=f(Y-Ye),ae=f(P*Y-O),{isValid:Ae,value:Se}=l(pe,ae);if(!Ae)throw new Error("Point.fromHex: invalid y coordinate");let ye=(Se&Ye)===Ye,Ne=(W&128)!==0;if(!k&&Se===ct&&Ne)throw new Error("Point.fromHex: x=0 and x_0=1");return Ne!==ye&&(Se=f(-Se)),v.fromAffine({x:Se,y:G})}static fromPrivateKey(A){return U(A).point}toRawBytes(){let{x:A,y:k}=this.toAffine(),P=br(k,t.BYTES);return P[P.length-1]|=A&Ye?128:0,P}toHex(){return Ct(this.toRawBytes())}}v.BASE=new v(e.Gx,e.Gy,Ye,f(e.Gx*e.Gy)),v.ZERO=new v(ct,Ye,Ye,ct);let{BASE:S,ZERO:_}=v,R=qo(v,a*8);function q(B){return Q(B,n)}function $(B){return q(Jt(B))}function U(B){let A=a;B=le("private key",B,A);let k=le("hashed private key",s(B),2*A),P=p(k.slice(0,A)),O=k.slice(A,2*A),K=$(P),H=S.multiply(K),W=H.toRawBytes();return{head:P,prefix:O,scalar:K,point:H,pointBytes:W}}function ee(B){return U(B).pointBytes}function D(B=new Uint8Array,...A){let k=Nt(...A);return $(s(h(k,le("context",B),!!o)))}function Je(B,A,k={}){B=le("message",B),o&&(B=o(B));let{prefix:P,scalar:O,pointBytes:K}=U(A),H=D(k.context,P,B),W=S.multiply(H).toRawBytes(),G=D(k.context,W,K,B),Y=q(H+G*O);w(Y);let pe=Nt(W,br(Y,t.BYTES));return le("result",pe,a*2)}let I=dg;function N(B,A,k,P=I){let{context:O,zip215:K}=P,H=t.BYTES;B=le("signature",B,2*H),A=le("message",A),o&&(A=o(A));let W=Jt(B.slice(H,2*H)),G,Y,pe;try{G=v.fromHex(k,K),Y=v.fromHex(B.slice(0,H),K),pe=S.multiplyUnsafe(W)}catch{return!1}if(!K&&G.isSmallOrder())return!1;let ae=D(O,Y.toRawBytes(),G.toRawBytes(),A);return Y.add(G.multiplyUnsafe(ae)).subtract(pe).clearCofactor().equals(v.ZERO)}return S._setWindowSize(8),{CURVE:e,getPublicKey:ee,sign:Je,verify:N,ExtendedPoint:v,utils:{getExtendedPublicKey:U,randomPrivateKey:()=>i(t.BYTES),precompute(B=8,A=v.BASE){return A._setWindowSize(B),A.multiply(BigInt(3)),A}}}}var Ua=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Fu=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),QE=BigInt(0),mg=BigInt(1),Vu=BigInt(2),JE=BigInt(3),gg=BigInt(5),yg=BigInt(8);function wg(r){let e=BigInt(10),t=BigInt(20),n=BigInt(40),o=BigInt(80),s=Ua,a=r*r%s*r%s,c=ne(a,Vu,s)*a%s,u=ne(c,mg,s)*r%s,f=ne(u,gg,s)*u%s,l=ne(f,e,s)*f%s,p=ne(l,t,s)*l%s,h=ne(p,n,s)*p%s,d=ne(h,o,s)*h%s,m=ne(d,o,s)*h%s,y=ne(m,e,s)*f%s;return{pow_p_5_8:ne(y,Vu,s)*r%s,b2:a}}function bg(r){return r[0]&=248,r[31]&=127,r[31]|=64,r}function Eg(r,e){let t=Ua,n=Q(e*e*e,t),o=Q(n*n*e,t),s=wg(r*o).pow_p_5_8,i=Q(r*n*s,t),a=Q(e*i*i,t),c=i,u=Q(i*Fu,t),f=a===r,l=a===Q(-r,t),p=a===Q(-r*Fu,t);return f&&(i=c),(l||p)&&(i=u),Pu(i,t)&&(i=Q(-i,t)),{isValid:f||l,value:i}}var xg=Ho(Ua,void 0,!0),vg={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:xg,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:yg,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Mn,randomBytes:Xr,adjustScalarBytes:bg,uvRatio:Eg},Jr=Mu(vg);var en=32,Lt=64,zo=32;function Ku(){let r=Jr.utils.randomPrivateKey(),e=Jr.getPublicKey(r);return{privateKey:zu(r,e),publicKey:e}}function Hu(r){if(r.length!==zo)throw new TypeError('"seed" must be 32 bytes in length.');if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');let e=r,t=Jr.getPublicKey(e);return{privateKey:zu(e,t),publicKey:t}}function qu(r,e){let t=r.subarray(0,zo);return Jr.sign(e instanceof Uint8Array?e:e.subarray(),t)}function $u(r,e,t){return Jr.verify(e,t instanceof Uint8Array?t:t.subarray(),r)}function zu(r,e){let t=new Uint8Array(Lt);for(let n=0;n<zo;n++)t[n]=r[n],t[zo+n]=e[n];return t}var Fe={get(r=globalThis){let e=r.crypto;if(e==null||e.subtle==null)throw Object.assign(new Error("Missing Web Crypto API. The most likely cause of this error is that this page is being accessed from an insecure context (i.e. not HTTPS). For more information and possible resolutions see https://github.com/libp2p/js-libp2p/blob/main/packages/crypto/README.md#web-crypto-api"),{code:"ERR_MISSING_WEB_CRYPTO"});return e}};var Ma={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function Gu(r){let e=r?.algorithm??"AES-GCM",t=r?.keyLength??16,n=r?.nonceLength??12,o=r?.digest??"SHA-256",s=r?.saltLength??16,i=r?.iterations??32767,a=Fe.get();t*=8;async function c(l,p){let h=a.getRandomValues(new Uint8Array(s)),d=a.getRandomValues(new Uint8Array(n)),m={name:e,iv:d};typeof p=="string"&&(p=L(p));let y;if(p.length===0){y=await a.subtle.importKey("jwk",Ma,{name:"AES-GCM"},!0,["encrypt"]);try{let w={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,b,{name:e,length:t},!0,["encrypt"])}catch{y=await a.subtle.importKey("jwk",Ma,{name:"AES-GCM"},!0,["encrypt"])}}else{let w={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},b=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);y=await a.subtle.deriveKey(w,b,{name:e,length:t},!0,["encrypt"])}let g=await a.subtle.encrypt(m,y,l);return Ie([h,m.iv,new Uint8Array(g)])}async function u(l,p){let h=l.subarray(0,s),d=l.subarray(s,s+n),m=l.subarray(s+n),y={name:e,iv:d};typeof p=="string"&&(p=L(p));let g;if(p.length===0)try{let b={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},x=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,x,{name:e,length:t},!0,["decrypt"])}catch{g=await a.subtle.importKey("jwk",Ma,{name:"AES-GCM"},!0,["decrypt"])}else{let b={name:"PBKDF2",salt:h,iterations:i,hash:{name:o}},x=await a.subtle.importKey("raw",p,{name:"PBKDF2"},!1,["deriveKey"]);g=await a.subtle.deriveKey(b,x,{name:e,length:t},!0,["decrypt"])}let w=await a.subtle.decrypt(y,g,m);return new Uint8Array(w)}return{encrypt:c,decrypt:u}}async function tn(r,e){let n=await Gu().encrypt(r,e);return On.encode(n)}var Sg=Math.pow(2,7),Rg=Math.pow(2,14),Ig=Math.pow(2,21),Fa=Math.pow(2,28),Va=Math.pow(2,35),Ka=Math.pow(2,42),Ha=Math.pow(2,49),X=128,De=127;function me(r){if(r<Sg)return 1;if(r<Rg)return 2;if(r<Ig)return 3;if(r<Fa)return 4;if(r<Va)return 5;if(r<Ka)return 6;if(r<Ha)return 7;if(Number.MAX_SAFE_INTEGER!=null&&r>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function qa(r,e,t=0){switch(me(r)){case 8:e[t++]=r&255|X,r/=128;case 7:e[t++]=r&255|X,r/=128;case 6:e[t++]=r&255|X,r/=128;case 5:e[t++]=r&255|X,r/=128;case 4:e[t++]=r&255|X,r>>>=7;case 3:e[t++]=r&255|X,r>>>=7;case 2:e[t++]=r&255|X,r>>>=7;case 1:{e[t++]=r&255,r>>>=7;break}default:throw new Error("unreachable")}return e}function Bg(r,e,t=0){switch(me(r)){case 8:e.set(t++,r&255|X),r/=128;case 7:e.set(t++,r&255|X),r/=128;case 6:e.set(t++,r&255|X),r/=128;case 5:e.set(t++,r&255|X),r/=128;case 4:e.set(t++,r&255|X),r>>>=7;case 3:e.set(t++,r&255|X),r>>>=7;case 2:e.set(t++,r&255|X),r>>>=7;case 1:{e.set(t++,r&255),r>>>=7;break}default:throw new Error("unreachable")}return e}function $a(r,e){let t=r[e],n=0;if(n+=t&De,t<X||(t=r[e+1],n+=(t&De)<<7,t<X)||(t=r[e+2],n+=(t&De)<<14,t<X)||(t=r[e+3],n+=(t&De)<<21,t<X)||(t=r[e+4],n+=(t&De)*Fa,t<X)||(t=r[e+5],n+=(t&De)*Va,t<X)||(t=r[e+6],n+=(t&De)*Ka,t<X)||(t=r[e+7],n+=(t&De)*Ha,t<X))return n;throw new RangeError("Could not decode varint")}function Tg(r,e){let t=r.get(e),n=0;if(n+=t&De,t<X||(t=r.get(e+1),n+=(t&De)<<7,t<X)||(t=r.get(e+2),n+=(t&De)<<14,t<X)||(t=r.get(e+3),n+=(t&De)<<21,t<X)||(t=r.get(e+4),n+=(t&De)*Fa,t<X)||(t=r.get(e+5),n+=(t&De)*Va,t<X)||(t=r.get(e+6),n+=(t&De)*Ka,t<X)||(t=r.get(e+7),n+=(t&De)*Ha,t<X))return n;throw new RangeError("Could not decode varint")}function Pe(r,e,t=0){return e==null&&(e=Le(me(r))),e instanceof Uint8Array?qa(r,e,t):Bg(r,e,t)}function lt(r,e=0){return r instanceof Uint8Array?$a(r,e):Tg(r,e)}var za=new Float32Array([-0]),tr=new Uint8Array(za.buffer);function Yu(r,e,t){za[0]=r,e[t]=tr[0],e[t+1]=tr[1],e[t+2]=tr[2],e[t+3]=tr[3]}function Wu(r,e){return tr[0]=r[e],tr[1]=r[e+1],tr[2]=r[e+2],tr[3]=r[e+3],za[0]}var Ga=new Float64Array([-0]),Oe=new Uint8Array(Ga.buffer);function ju(r,e,t){Ga[0]=r,e[t]=Oe[0],e[t+1]=Oe[1],e[t+2]=Oe[2],e[t+3]=Oe[3],e[t+4]=Oe[4],e[t+5]=Oe[5],e[t+6]=Oe[6],e[t+7]=Oe[7]}function Xu(r,e){return Oe[0]=r[e],Oe[1]=r[e+1],Oe[2]=r[e+2],Oe[3]=r[e+3],Oe[4]=r[e+4],Oe[5]=r[e+5],Oe[6]=r[e+6],Oe[7]=r[e+7],Ga[0]}var Cg=BigInt(Number.MAX_SAFE_INTEGER),kg=BigInt(Number.MIN_SAFE_INTEGER),We=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 vr;if(e<Cg&&e>kg)return this.fromNumber(Number(e));let t=e<0n;t&&(e=-e);let n=e>>32n,o=e-(n<<32n);return t&&(n=~n|0n,o=~o|0n,++o>Zu&&(o=0n,++n>Zu&&(n=0n))),new r(Number(o),Number(n))}static fromNumber(e){if(e===0)return vr;let t=e<0;t&&(e=-e);let n=e>>>0,o=(e-n)/4294967296>>>0;return t&&(o=~o>>>0,n=~n>>>0,++n>4294967295&&(n=0,++o>4294967295&&(o=0))),new r(n,o)}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):vr}},vr=new We(0,0);vr.toBigInt=function(){return 0n};vr.zzEncode=vr.zzDecode=function(){return this};vr.length=function(){return 1};var Zu=4294967296n;function Qu(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 Ju(r,e,t){if(t-e<1)return"";let o,s=[],i=0,a;for(;e<t;)a=r[e++],a<128?s[i++]=a:a>191&&a<224?s[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,s[i++]=55296+(a>>10),s[i++]=56320+(a&1023)):s[i++]=(a&15)<<12|(r[e++]&63)<<6|r[e++]&63,i>8191&&((o??(o=[])).push(String.fromCharCode.apply(String,s)),i=0);return o!=null?(i>0&&o.push(String.fromCharCode.apply(String,s.slice(0,i))),o.join("")):String.fromCharCode.apply(String,s.slice(0,i))}function Ya(r,e,t){let n=t,o,s;for(let i=0;i<r.length;++i)o=r.charCodeAt(i),o<128?e[t++]=o:o<2048?(e[t++]=o>>6|192,e[t++]=o&63|128):(o&64512)===55296&&((s=r.charCodeAt(i+1))&64512)===56320?(o=65536+((o&1023)<<10)+(s&1023),++i,e[t++]=o>>18|240,e[t++]=o>>12&63|128,e[t++]=o>>6&63|128,e[t++]=o&63|128):(e[t++]=o>>12|224,e[t++]=o>>6&63|128,e[t++]=o&63|128);return t-n}function ut(r,e){return RangeError(`index out of range: ${r.pos} + ${e??1} > ${r.len}`)}function Go(r,e){return(r[e-4]|r[e-3]<<8|r[e-2]<<16|r[e-1]<<24)>>>0}var Wa=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,ut(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 ut(this,4);return Go(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ut(this,4);return Go(this.buf,this.pos+=4)|0}float(){if(this.pos+4>this.len)throw ut(this,4);let e=Wu(this.buf,this.pos);return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ut(this,4);let e=Xu(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 ut(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){let e=this.bytes();return Ju(e,0,e.length)}skip(e){if(typeof e=="number"){if(this.pos+e>this.len)throw ut(this,e);this.pos+=e}else do if(this.pos>=this.len)throw ut(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 We(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 ut(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 ut(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 ut(this,8);let e=Go(this.buf,this.pos+=4),t=Go(this.buf,this.pos+=4);return new We(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=$a(this.buf,this.pos);return this.pos+=me(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 ja(r){return new Wa(r instanceof Uint8Array?r:r.subarray())}function Ve(r,e,t){let n=ja(r);return e.decode(n,void 0,t)}function Xa(r){let e=r??8192,t=e>>>1,n,o=e;return function(i){if(i<1||i>t)return Le(i);o+i>e&&(n=Le(e),o=0);let a=n.subarray(o,o+=i);return o&7&&(o=(o|7)+1),a}}var _r=class{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}};function Za(){}var Ja=class{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}},Ng=Xa();function Lg(r){return globalThis.Buffer!=null?Le(r):Ng(r)}var Hn=class{len;head;tail;states;constructor(){this.len=0,this.head=new _r(Za,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new _r(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ec((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(Yo,10,We.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){let t=We.fromBigInt(e);return this._push(Yo,t.length(),t)}uint64Number(e){return this._push(qa,me(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=We.fromBigInt(e).zzEncode();return this._push(Yo,t.length(),t)}sint64Number(e){let t=We.fromNumber(e).zzEncode();return this._push(Yo,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Qa,1,e?1:0)}fixed32(e){return this._push(Kn,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){let t=We.fromBigInt(e);return this._push(Kn,4,t.lo)._push(Kn,4,t.hi)}fixed64Number(e){let t=We.fromNumber(e);return this._push(Kn,4,t.lo)._push(Kn,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(Yu,4,e)}double(e){return this._push(ju,8,e)}bytes(e){let t=e.length>>>0;return t===0?this._push(Qa,1,0):this.uint32(t)._push(Pg,t,e)}string(e){let t=Qu(e);return t!==0?this.uint32(t)._push(Ya,t,e):this._push(Qa,1,0)}fork(){return this.states=new Ja(this),this.head=this.tail=new _r(Za,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 _r(Za,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=Lg(this.len),n=0;for(;e!=null;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}};function Qa(r,e,t){e[t]=r&255}function Dg(r,e,t){for(;r>127;)e[t++]=r&127|128,r>>>=7;e[t]=r}var ec=class extends _r{next;constructor(e,t){super(Dg,e,t),this.next=void 0}};function Yo(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 Kn(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 Pg(r,e,t){e.set(r,t)}globalThis.Buffer!=null&&(Hn.prototype.bytes=function(r){let e=r.length>>>0;return this.uint32(e),e>0&&this._push(Og,e,r),this},Hn.prototype.string=function(r){let e=globalThis.Buffer.byteLength(r);return this.uint32(e),e>0&&this._push(Ug,e,r),this});function Og(r,e,t){e.set(r,t)}function Ug(r,e,t){r.length<40?Ya(r,e,t):e.utf8Write!=null?e.utf8Write(r,t):e.set(L(r),t)}function tc(){return new Hn}function Ke(r,e){let t=tc();return e.encode(r,t,{lengthDelimited:!1}),t.finish()}var rn;(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"})(rn||(rn={}));function Wo(r,e,t,n){return{name:r,type:e,encode:t,decode:n}}function rc(r){function e(o){if(r[o.toString()]==null)throw new Error("Invalid enum value");return r[o]}let t=function(s,i){let a=e(s);i.int32(a)},n=function(s){let i=s.int32();return e(i)};return Wo("enum",rn.VARINT,t,n)}function He(r,e){return Wo("message",rn.LENGTH_DELIMITED,r,e)}var oe;(function(r){r.RSA="RSA",r.Ed25519="Ed25519",r.Secp256k1="Secp256k1"})(oe||(oe={}));var nc;(function(r){r[r.RSA=0]="RSA",r[r.Ed25519=1]="Ed25519",r[r.Secp256k1=2]="Secp256k1"})(nc||(nc={}));(function(r){r.codec=()=>rc(nc)})(oe||(oe={}));var yt;(function(r){let e;r.codec=()=>(e==null&&(e=He((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),oe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=oe.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>Ke(t,r.codec()),r.decode=t=>Ve(t,r.codec())})(yt||(yt={}));var wt;(function(r){let e;r.codec=()=>(e==null&&(e=He((t,n,o={})=>{o.lengthDelimited!==!1&&n.fork(),t.Type!=null&&(n.uint32(8),oe.codec().encode(t.Type,n)),t.Data!=null&&(n.uint32(18),n.bytes(t.Data)),o.lengthDelimited!==!1&&n.ldelim()},(t,n)=>{let o={},s=n==null?t.len:t.pos+n;for(;t.pos<s;){let i=t.uint32();switch(i>>>3){case 1:o.Type=oe.codec().decode(t);break;case 2:o.Data=t.bytes();break;default:t.skipType(i&7);break}}return o})),e),r.encode=t=>Ke(t,r.codec()),r.decode=t=>Ve(t,r.codec())})(wt||(wt={}));var qn=class{_key;constructor(e){this._key=nn(e,en)}verify(e,t){return $u(this._key,t,e)}marshal(){return this._key}get bytes(){return yt.encode({Type:oe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return te(this.bytes,e.bytes)}hash(){let e=Re.digest(this.bytes);return rt(e)?e.then(({bytes:t})=>t):e.bytes}},Ar=class{_key;_publicKey;constructor(e,t){this._key=nn(e,Lt),this._publicKey=nn(t,en)}sign(e){return qu(this._key,e)}get public(){return new qn(this._publicKey)}marshal(){return this._key}get bytes(){return wt.encode({Type:oe.Ed25519,Data:this.marshal()}).subarray()}equals(e){return te(this.bytes,e.bytes)}async hash(){let e=Re.digest(this.bytes),t;return rt(e)?{bytes:t}=await e:t=e.bytes,t}async id(){let e=Bt.digest(this.public.bytes);return ie.encode(e.bytes).substring(1)}async export(e,t="libp2p-key"){if(t==="libp2p-key")return tn(this.bytes,e);throw new E(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}};function Mg(r){if(r.length>Lt){r=nn(r,Lt+en);let n=r.subarray(0,Lt),o=r.subarray(Lt,r.length);return new Ar(n,o)}r=nn(r,Lt);let e=r.subarray(0,Lt),t=r.subarray(en);return new Ar(e,t)}function Fg(r){return r=nn(r,en),new qn(r)}async function Vg(){let{privateKey:r,publicKey:e}=Ku();return new Ar(r,e)}async function tf(r){let{privateKey:e,publicKey:t}=Hu(r);return new Ar(e,t)}function nn(r,e){if(r=Uint8Array.from(r??[]),r.length!==e)throw new E(`Key must be a Uint8Array of length ${e}, got ${r.length}`,"ERR_INVALID_KEY_TYPE");return r}function F(r,e="utf8"){let t=Do[e];if(t==null)throw new Error(`Unsupported encoding "${e}"`);return t.encoder.encode(r).substring(1)}var pc={};ve(pc,{MAX_RSA_KEY_SIZE:()=>to,RsaPrivateKey:()=>ln,RsaPublicKey:()=>eo,fromJwk:()=>d0,generateKeyPair:()=>p0,unmarshalRsaPrivateKey:()=>hc,unmarshalRsaPublicKey:()=>h0});function bt(r){if(isNaN(r)||r<=0)throw new E("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Xr(r)}var sr={};ve(sr,{exportToPem:()=>a0,importFromPem:()=>c0,jwkToPkcs1:()=>n0,jwkToPkix:()=>s0,pkcs1ToJwk:()=>r0,pkixToJwk:()=>o0});var Xo=class extends Wr{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Po(e);let n=jt(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 o=this.blockLen,s=new Uint8Array(o);s.set(n.length>o?e.create().update(n).digest():n);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=e.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),s.fill(0)}update(e){return Yr(this),this.iHash.update(e),this}digestInto(e){Yr(this),Gr(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:o,destroyed:s,blockLen:i,outputLen:a}=this;return e=e,e.finished=o,e.destroyed=s,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()}},$n=(r,e,t)=>new Xo(r,e).update(t).digest();$n.create=(r,e)=>new Xo(r,e);function Kg(r,e,t,n){Po(r);let o=Su({dkLen:32,asyncTick:10},n),{c:s,dkLen:i,asyncTick:a}=o;if(zr(s),zr(i),zr(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");let c=jt(e),u=jt(t),f=new Uint8Array(i),l=$n.create(r,c),p=l._cloneInto().update(u);return{c:s,dkLen:i,asyncTick:a,DK:f,PRF:l,PRFSalt:p}}function Hg(r,e,t,n,o){return r.destroy(),e.destroy(),n&&n.destroy(),o.fill(0),t}async function sc(r,e,t,n){let{c:o,dkLen:s,asyncTick:i,DK:a,PRF:c,PRFSalt:u}=Kg(r,e,t,n),f,l=new Uint8Array(4),p=jr(l),h=new Uint8Array(c.outputLen);for(let d=1,m=0;m<s;d++,m+=c.outputLen){let y=a.subarray(m,m+c.outputLen);p.setInt32(0,d,!1),(f=u._cloneInto(f)).update(l).digestInto(h),y.set(h.subarray(0,y.length)),await _u(o-1,i,()=>{c._cloneInto(f).update(h).digestInto(h);for(let g=0;g<y.length;g++)y[g]^=h[g]})}return Hg(c,u,a,f,h)}var z=St(rf());function Sr(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 rr(r,e,t=-1){let n=t,o=r,s=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),s=a;else{if(n<a)return new ArrayBuffer(0);c=new ArrayBuffer(n),s=n}let u=new Uint8Array(c);for(let f=a-1;f>=0;f--){let l=Math.pow(2,f*e);u[s-f-1]=Math.floor(o/l),o-=u[s-f-1]*l}return c}i*=Math.pow(2,e)}return new ArrayBuffer(0)}function Jo(...r){let e=0,t=0;for(let s of r)e+=s.length;let n=new ArrayBuffer(e),o=new Uint8Array(n);for(let s of r)o.set(s,t),t+=s.length;return o}function ac(){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=Sr(t,8),o=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(o);for(let a=0;a<this.valueHex.byteLength;a++)s[a]=r[a];return s[0]&=127,Sr(s,8)-n}function nf(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=rr(i,8,n),c=new Uint8Array(a);return c[0]|=128,a}let o=rr(e,8,n),s=new Uint8Array(o);if(s[0]&128){let i=o.slice(0),a=new Uint8Array(i);o=new ArrayBuffer(o.byteLength+1),s=new Uint8Array(o);for(let c=0;c<i.byteLength;c++)s[c+1]=a[c];s[0]=0}return o}t*=Math.pow(2,8)}return new ArrayBuffer(0)}function of(r,e){if(r.byteLength!==e.byteLength)return!1;let t=new Uint8Array(r),n=new Uint8Array(e);for(let o=0;o<t.length;o++)if(t[o]!==n[o])return!1;return!0}function ze(r,e){let t=r.toString(10);if(e<t.length)return"";let n=e-t.length,o=new Array(n);for(let i=0;i<n;i++)o[i]="0";return o.join("").concat(t)}var a1=Math.log(2);function es(){if(typeof BigInt>"u")throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function cc(r){let e=0,t=0;for(let o=0;o<r.length;o++){let s=r[o];e+=s.byteLength}let n=new Uint8Array(e);for(let o=0;o<r.length;o++){let s=r[o];n.set(new Uint8Array(s),t),t+=s.byteLength}return n.buffer}function Mt(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 Gn=class{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return cc(this.items)}},zn=[new Uint8Array([1])],sf="0123456789";var an="",ht=new ArrayBuffer(0),lc=new Uint8Array(0),Yn="EndOfContent",cf="OCTET STRING",lf="BIT STRING";function Ft(r){var e;return e=class extends r{constructor(...n){var o;super(...n);let s=n[0]||{};this.isHexOnly=(o=s.isHexOnly)!==null&&o!==void 0?o:!1,this.valueHexView=s.valueHex?z.BufferSourceConverter.toUint8Array(s.valueHex):lc}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(n){this.valueHexView=new Uint8Array(n)}fromBER(n,o,s){let i=n instanceof ArrayBuffer?new Uint8Array(n):n;if(!Mt(this,i,o,s))return-1;let a=o+s;return this.valueHexView=i.subarray(o,a),this.valueHexView.length?(this.blockLength=s,a):(this.warnings.push("Zero buffer length"),o)}toBER(n=!1){return this.isHexOnly?n?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.byteLength===this.valueHexView.buffer.byteLength?this.valueHexView.buffer:this.valueHexView.slice().buffer:(this.error="Flag 'isHexOnly' is not set, abort",ht)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:z.Convert.ToHex(this.valueHexView)}}},e.NAME="hexBlock",e}var Pt=class{constructor({blockLength:e=0,error:t=an,warnings:n=[],valueBeforeDecode:o=lc}={}){this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=z.BufferSourceConverter.toUint8Array(o)}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:z.Convert.ToHex(this.valueBeforeDecodeView)}}};Pt.NAME="baseBlock";var Ue=class extends Pt{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'")}};Ue.NAME="valueBlock";var ts=class extends Ft(Pt){constructor({idBlock:e={}}={}){var t,n,o,s;super(),e?(this.isHexOnly=(t=e.isHexOnly)!==null&&t!==void 0?t:!1,this.valueHexView=e.valueHex?z.BufferSourceConverter.toUint8Array(e.valueHex):lc,this.tagClass=(n=e.tagClass)!==null&&n!==void 0?n:-1,this.tagNumber=(o=e.tagNumber)!==null&&o!==void 0?o:-1,this.isConstructed=(s=e.isConstructed)!==null&&s!==void 0?s:!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",ht}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){let o=new Uint8Array(1);if(!e){let s=this.tagNumber;s&=31,t|=s,o[0]=t}return o.buffer}if(!this.isHexOnly){let o=rr(this.tagNumber,7),s=new Uint8Array(o),i=o.byteLength,a=new Uint8Array(i+1);if(a[0]=t|31,!e){for(let c=0;c<i-1;c++)a[c+1]=s[c]|128;a[i]=s[i-1]}return a.buffer}let n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=t|31,!e){let o=this.valueHexView;for(let s=0;s<o.length-1;s++)n[s+1]=o[s]|128;n[this.valueHexView.byteLength]=o[o.length-1]}return n.buffer}fromBER(e,t,n){let o=z.BufferSourceConverter.toUint8Array(e);if(!Mt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;switch(s[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=(s[0]&32)===32,this.isHexOnly=!1;let a=s[0]&31;if(a!==31)this.tagNumber=a,this.blockLength=1;else{let c=1,u=this.valueHexView=new Uint8Array(255),f=255;for(;s[c]&128;){if(u[c-1]=s[c]&127,c++,c>=s.length)return this.error="End of input reached before message was fully decoded",-1;if(c===f){f+=255;let p=new Uint8Array(f);for(let h=0;h<u.length;h++)p[h]=u[h];u=this.valueHexView=new Uint8Array(f)}}this.blockLength=c+1,u[c-1]=s[c]&127;let l=new Uint8Array(c);for(let p=0;p<c;p++)l[p]=u[p];u=this.valueHexView=new Uint8Array(c),u.set(l),this.blockLength<=9?this.tagNumber=Sr(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}}};ts.NAME="identificationBlock";var rs=class extends Pt{constructor({lenBlock:e={}}={}){var t,n,o;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=(o=e.length)!==null&&o!==void 0?o:0}fromBER(e,t,n){let o=z.BufferSourceConverter.toUint8Array(e);if(!Mt(this,o,t,n))return-1;let s=o.subarray(t,t+n);if(s.length===0)return this.error="Zero buffer length",-1;if(s[0]===255)return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=s[0]===128,this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(s[0]&128),this.longFormUsed===!1)return this.length=s[0],this.blockLength=1,t+this.blockLength;let i=s[0]&127;if(i>8)return this.error="Too big integer",-1;if(i+1>s.length)return this.error="End of input reached before message was fully decoded",-1;let a=t+1,c=o.subarray(a,a+i);return c[i-1]===0&&this.warnings.push("Needlessly long encoded length"),this.length=Sr(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 o=rr(this.length,8);if(o.byteLength>127)return this.error="Too big length",ht;if(t=new ArrayBuffer(o.byteLength+1),e)return t;let s=new Uint8Array(o);n=new Uint8Array(t),n[0]=o.byteLength|128;for(let i=0;i<o.byteLength;i++)n[i+1]=s[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}}};rs.NAME="lengthBlock";var T={},Be=class extends Pt{constructor({name:e=an,optional:t=!1,primitiveSchema:n,...o}={},s){super(o),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new ts(o),this.lenBlock=new rs(o),this.valueBlock=s?new s(o):new Ue(o)}fromBER(e,t,n){let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}toBER(e,t){let n=t||new Gn;t||uf(this);let o=this.idBlock.toBER(e);if(n.write(o),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{let s=this.valueBlock.toBER(e);this.lenBlock.length=s.byteLength;let i=this.lenBlock.toBER(e);n.write(i),n.write(s)}return t?ht: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():z.Convert.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${z.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 of(t,n)}};Be.NAME="BaseBlock";function uf(r){if(r instanceof T.Constructed)for(let e of r.valueBlock.value)uf(e)&&(r.lenBlock.isIndefiniteForm=!0);return!!r.lenBlock.isIndefiniteForm}var ns=class extends Be{constructor({value:e=an,...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 o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}};ns.NAME="BaseStringBlock";var os=class extends Ft(Ue){constructor({isHexOnly:e=!0,...t}={}){super(t),this.isHexOnly=e}};os.NAME="PrimitiveValueBlock";var ff,ss=class extends Be{constructor(e={}){super(e,os),this.idBlock.isConstructed=!1}};ff=ss;T.Primitive=ff;ss.NAME="PRIMITIVE";function Zg(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 Ms(r,e=0,t=r.length){let n=e,o=new Be({},Ue),s=new Pt;if(!Mt(s,r,e,t))return o.error=s.error,{offset:-1,result:o};if(!r.subarray(e,e+t).length)return o.error="Zero buffer length",{offset:-1,result:o};let a=o.idBlock.fromBER(r,e,t);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),a===-1)return o.error=o.idBlock.error,{offset:-1,result:o};if(e=a,t-=o.idBlock.blockLength,a=o.lenBlock.fromBER(r,e,t),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),a===-1)return o.error=o.lenBlock.error,{offset:-1,result:o};if(e=a,t-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let c=Be;switch(o.idBlock.tagClass){case 1:if(o.idBlock.tagNumber>=37&&o.idBlock.isHexOnly===!1)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};c=T.EndOfContent;break;case 1:c=T.Boolean;break;case 2:c=T.Integer;break;case 3:c=T.BitString;break;case 4:c=T.OctetString;break;case 5:c=T.Null;break;case 6:c=T.ObjectIdentifier;break;case 10:c=T.Enumerated;break;case 12:c=T.Utf8String;break;case 13:c=T.RelativeObjectIdentifier;break;case 14:c=T.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:c=T.Sequence;break;case 17:c=T.Set;break;case 18:c=T.NumericString;break;case 19:c=T.PrintableString;break;case 20:c=T.TeletexString;break;case 21:c=T.VideotexString;break;case 22:c=T.IA5String;break;case 23:c=T.UTCTime;break;case 24:c=T.GeneralizedTime;break;case 25:c=T.GraphicString;break;case 26:c=T.VisibleString;break;case 27:c=T.GeneralString;break;case 28:c=T.UniversalString;break;case 29:c=T.CharacterString;break;case 30:c=T.BmpString;break;case 31:c=T.DATE;break;case 32:c=T.TimeOfDay;break;case 33:c=T.DateTime;break;case 34:c=T.Duration;break;default:{let u=o.idBlock.isConstructed?new T.Constructed:new T.Primitive;u.idBlock=o.idBlock,u.lenBlock=o.lenBlock,u.warnings=o.warnings,o=u}}break;case 2:case 3:case 4:default:c=o.idBlock.isConstructed?T.Constructed:T.Primitive}return o=Zg(o,c),a=o.fromBER(r,e,o.lenBlock.isIndefiniteForm?t:o.lenBlock.length),o.valueBeforeDecodeView=r.subarray(n,n+o.blockLength),{offset:a,result:o}}function cn(r){if(!r.byteLength){let e=new Be({},Ue);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Ms(z.BufferSourceConverter.toUint8Array(r).slice(),0,r.byteLength)}function Qg(r,e){return r?1:e}var Et=class extends Ue{constructor({value:e=[],isIndefiniteForm:t=!1,...n}={}){super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){let o=z.BufferSourceConverter.toUint8Array(e);if(!Mt(this,o,t,n))return-1;if(this.valueBeforeDecodeView=o.subarray(t,t+n),this.valueBeforeDecodeView.length===0)return this.warnings.push("Zero buffer length"),t;let s=t;for(;Qg(this.isIndefiniteForm,n)>0;){let i=Ms(o,s,n);if(i.offset===-1)return this.error=i.result.error,this.warnings.concat(i.result.warnings),-1;if(s=i.offset,this.blockLength+=i.result.blockLength,n-=i.result.blockLength,this.value.push(i.result),this.isIndefiniteForm&&i.result.constructor.NAME===Yn)break}return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Yn?this.value.pop():this.warnings.push("No EndOfContent block encoded")),s}toBER(e,t){let n=t||new Gn;for(let o=0;o<this.value.length;o++)this.value[o].toBER(e,n);return t?ht:n.final()}toJSON(){let e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(let t of this.value)e.value.push(t.toJSON());return e}};Et.NAME="ConstructedValueBlock";var hf,nr=class extends Be{constructor(e={}){super(e,Et),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;let o=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return o===-1?(this.error=this.valueBlock.error,o):(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),o)}onAsciiEncoding(){let e=[];for(let n of this.valueBlock.value)e.push(n.toString("ascii").split(`
3
3
  `).map(o=>` ${o}`).join(`
4
4
  `));let t=this.idBlock.tagClass===3?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :
5
5
  ${e.join(`
@@ -17,7 +17,7 @@ ${e.join(`
17
17
  `),t),t.log.trace('handle: responded with "%s" for "%s"',o,o),{stream:n.unwrap(),protocol:o};if(o==="ls"){let s=new Ee(...e.map(i=>Wi.single(L(`${i}
18
18
  `))),L(`
19
19
  `));t.log.trace('handle: respond with "%s" for %s',e,o),await Fr(n,s,t),t.log.trace('handle: responded with "%s" for %s',e,o);continue}t.log('handle: respond with "na" for "%s"',o),await Fr(n,L(`na
20
- `),t),t.log('handle: responded with "na" for "%s"',o)}}var Dw=500,Hl=class{id;remoteAddr;remotePeer;direction;timeline;multiplexer;encryption;status;transient;log;tags;_newStream;_close;_abort;_getStreams;constructor(e){let{remoteAddr:t,remotePeer:n,newStream:o,close:s,abort:i,getStreams:a}=e;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=n,this.direction=e.direction,this.status="open",this.timeline=e.timeline,this.multiplexer=e.multiplexer,this.encryption=e.encryption,this.transient=e.transient??!1,this.log=e.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`),this.remoteAddr.getPeerId()==null&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=o,this._close=s,this._abort=i,this._getStreams=a,this.tags=[]}[Symbol.toStringTag]="Connection";[Jl]=!0;get streams(){return this._getStreams()}async newStream(e,t){if(this.status==="closing")throw new E("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if(this.status==="closed")throw new E("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&t?.runOnTransientConnection!==!0)throw new E("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");let n=await this._newStream(e,t);return n.direction="outbound",n}async close(e={}){if(!(this.status==="closed"||this.status==="closing")){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",e.signal==null){let t=AbortSignal.timeout(Dw);fe(1/0,t),e={...e,signal:t}}try{this.log.trace("closing all streams"),await Promise.all(this.streams.map(async t=>t.close(e))),this.log.trace("closing underlying transport"),await this._close(e),this.log.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(t){this.log.error("error encountered during graceful close of connection to %a",this.remoteAddr,t),this.abort(t)}}}abort(e){this.log.error("aborting connection to %a due to error",this.remoteAddr,e),this.status="closing",this.streams.forEach(t=>{t.abort(e)}),this.log.error("all streams aborted",this.streams.length),this._abort(e),this.timeline.close=Date.now(),this.status="closed"}};function jd(r){return new Hl(r)}var Pw=3e4;function Ow(r,e){try{let{options:t}=e.getHandler(r);return t.maxInboundStreams}catch(t){if(t.code!==C.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return Dl}function Uw(r,e,t={}){try{let{options:n}=e.getHandler(r);if(n.maxOutboundStreams!=null)return n.maxOutboundStreams}catch(n){if(n.code!==C.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return t.maxOutboundStreams??Pl}function Xd(r,e,t){let n=0;return t.streams.forEach(o=>{o.direction===e&&o.protocol===r&&n++}),n}var ji=class{components;connectionEncryption;muxers;inboundUpgradeTimeout;events;constructor(e,t){this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,t.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout??2e3,this.events=e.events}[Symbol.toStringTag]="@libp2p/upgrader";async shouldBlockConnection(e,t,n){let o=this.components.connectionGater[n];if(o!==void 0&&await o(e,t))throw new E(`The multiaddr connection is blocked by gater.${n}`,C.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new E("connection denied",C.ERR_CONNECTION_DENIED);let o,s,i,a,c,u=AbortSignal.timeout(this.inboundUpgradeTimeout),f=()=>{e.abort(new E("inbound upgrade timeout",No))};u.addEventListener("abort",f,{once:!0}),fe(1/0,u);try{if(await this.components.connectionGater.denyInboundConnection?.(e)===!0)throw new E("The multiaddr connection is blocked by gater.acceptConnection",C.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the inbound connection upgrade");let l=e;if(t?.skipProtection!==!0){let p=this.components.connectionProtector;p!=null&&(e.log("protecting the inbound connection"),l=await p.protect(e))}try{if(o=l,t?.skipEncryption!==!0){t?.onProgress?.(new de("upgrader:encrypt-inbound-connection")),{conn:o,remotePeer:s,protocol:c}=await this._encryptInbound(l);let p={...l,...o};await this.shouldBlockConnection(s,p,"denyInboundEncryptedConnection")}else{let p=e.remoteAddr.getPeerId();if(p==null)throw new E("inbound connection that skipped encryption must have a peer id",C.ERR_INVALID_MULTIADDR);let h=be(p);c="native",s=h}if(i=o,t?.muxerFactory!=null)a=t.muxerFactory;else if(this.muxers.size>0){t?.onProgress?.(new de("upgrader:multiplex-inbound-connection"));let p=await this._multiplexInbound({...l,...o},this.muxers);a=p.muxerFactory,i=p.stream}}catch(p){throw e.log.error("failed to upgrade inbound connection",p),p}return await this.shouldBlockConnection(s,e,"denyInboundUpgradedConnection"),e.log("successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:c,direction:"inbound",maConn:e,upgradedConn:i,muxerFactory:a,remotePeer:s,transient:t?.transient})}finally{u.removeEventListener("abort",f),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(e,t){let n=e.remoteAddr.getPeerId(),o;n!=null&&(o=be(n),await this.shouldBlockConnection(o,e,"denyOutboundConnection"));let s,i,a,c,u;this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the outbound connection upgrade");let f=e;if(t?.skipProtection!==!0){let l=this.components.connectionProtector;l!=null&&(f=await l.protect(e))}try{if(s=f,t?.skipEncryption!==!0){({conn:s,remotePeer:i,protocol:c}=await this._encryptOutbound(f,o));let l={...f,...s};await this.shouldBlockConnection(i,l,"denyOutboundEncryptedConnection")}else{if(o==null)throw new E("Encryption was skipped but no peer id was passed",C.ERR_INVALID_PEER);c="native",i=o}if(a=s,t?.muxerFactory!=null)u=t.muxerFactory;else if(this.muxers.size>0){let l=await this._multiplexOutbound({...f,...s},this.muxers);u=l.muxerFactory,a=l.stream}}catch(l){throw e.log.error("failed to upgrade outbound connection",l),await e.close(l),l}return await this.shouldBlockConnection(i,e,"denyOutboundUpgradedConnection"),e.log("successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:u,remotePeer:i,transient:t?.transient})}_createConnection(e){let{cryptoProtocol:t,direction:n,maConn:o,upgradedConn:s,remotePeer:i,muxerFactory:a,transient:c}=e,u,f,l;a!=null&&(u=a.createStreamMuxer({direction:n,onIncomingStream:d=>{l!=null&&Promise.resolve().then(async()=>{let m=this.components.registrar.getProtocols(),{stream:y,protocol:g}=await Io(d,m,{log:d.log,yieldBytes:!1});if(l==null)return;l.log("incoming stream opened on %s",g);let w=Ow(g,this.components.registrar);if(Xd(g,"inbound",l)===w){let x=new E(`Too many inbound protocol streams for protocol "${g}" - limit ${w}`,C.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw d.abort(x),x}d.source=y.source,d.sink=y.sink,d.protocol=g,y.closeWrite!=null&&(d.closeWrite=y.closeWrite),y.closeRead!=null&&(d.closeRead=y.closeRead),y.close!=null&&(d.close=y.close),await this.components.peerStore.merge(i,{protocols:[g]}),this.components.metrics?.trackProtocolStream(d,l),this._onStream({connection:l,stream:d,protocol:g})}).catch(async m=>{l.log.error("error handling incoming stream id %s",d.id,m.message,m.code,m.stack),d.timeline.close==null&&await d.close()})}}),f=async(d,m={})=>{if(u==null)throw new E("Stream is not multiplexed",C.ERR_MUXER_UNAVAILABLE);l.log("starting new stream for protocols %s",d);let y=await u.newStream();l.log.trace("started new stream %s for protocols %s",y.id,d);try{if(m.signal==null){y.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",d);let v=AbortSignal.timeout(Pw);fe(1/0,v),m={...m,signal:v}}y.log.trace("selecting protocol from protocols %s",d);let{stream:g,protocol:w}=await Ro(y,d,{...m,log:y.log,yieldBytes:!0});y.log("selected protocol %s",w);let b=Uw(w,this.components.registrar,m),x=Xd(w,"outbound",l);if(x>=b){let v=new E(`Too many outbound protocol streams for protocol "${w}" - ${x}/${b}`,C.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw y.abort(v),v}return await this.components.peerStore.merge(i,{protocols:[w]}),y.source=g.source,y.sink=g.sink,y.protocol=w,g.closeWrite!=null&&(y.closeWrite=g.closeWrite),g.closeRead!=null&&(y.closeRead=g.closeRead),g.close!=null&&(y.close=g.close),this.components.metrics?.trackProtocolStream(y,l),y}catch(g){throw l.log.error("could not create new stream for protocols %s",d,g),y.timeline.close==null&&y.abort(g),g.code!=null?g:new E(String(g),C.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([u.sink(s.source),s.sink(u.source)]).catch(d=>{l.log.error("error piping data through muxer",d)}));let p=o.timeline;o.timeline=new Proxy(p,{set:(...d)=>(l!=null&&d[1]==="close"&&d[2]!=null&&p.close==null&&(async()=>{try{l.status==="open"&&await l.close()}catch(m){l.log.error("error closing connection after timeline close",m)}finally{this.events.safeDispatchEvent("connection:close",{detail:l})}})().catch(m=>{l.log.error("error thrown while dispatching connection:close event",m)}),Reflect.set(...d))}),o.timeline.upgraded=Date.now();let h=()=>{throw new E("connection is not multiplexed",C.ERR_CONNECTION_NOT_MULTIPLEXED)};return l=jd({remoteAddr:o.remoteAddr,remotePeer:i,status:"open",direction:n,timeline:o.timeline,multiplexer:u?.protocol,encryption:t,transient:c,logger:this.components.logger,newStream:f??h,getStreams:()=>u!=null?u.streams:[],close:async d=>{u!=null&&(l.log.trace("close muxer"),await u.close(d)),l.log.trace("close maconn"),await o.close(d),l.log.trace("closed maconn")},abort:d=>{o.abort(d),u?.abort(d)}}),this.events.safeDispatchEvent("connection:open",{detail:l}),l}_onStream(e){let{connection:t,stream:n,protocol:o}=e,{handler:s,options:i}=this.components.registrar.getHandler(o);if(t.transient&&i.runOnTransientConnection!==!0)throw new E("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");s({connection:t,stream:n})}async _encryptInbound(e){let t=Array.from(this.connectionEncryption.keys());e.log("handling inbound crypto protocol selection",t);try{let{stream:n,protocol:o}=await Io(e,t,{log:e.log}),s=this.connectionEncryption.get(o);if(s==null)throw new Error(`no crypto module found for ${o}`);return e.log("encrypting inbound connection using",o),{...await s.secureInbound(this.components.peerId,n),protocol:o}}catch(n){throw e.log.error("encrypting inbound connection failed",n),new E(n.message,C.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){let n=Array.from(this.connectionEncryption.keys());e.log("selecting outbound crypto protocol",n);try{e.log.trace("selecting encrypter from %s",n);let{stream:o,protocol:s}=await Ro(e,n,{log:e.log,yieldBytes:!0}),i=this.connectionEncryption.get(s);if(i==null)throw new Error(`no crypto module found for ${s}`);return e.log("encrypting outbound connection to %p using %s",t,i),{...await i.secureOutbound(this.components.peerId,o,t),protocol:s}}catch(o){throw e.log.error("encrypting outbound connection to %p failed",t,o),new E(o.message,C.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){let n=Array.from(t.keys());e.log("outbound selecting muxer %s",n);try{e.log.trace("selecting stream muxer from %s",n);let{stream:o,protocol:s}=await Ro(e,n,{log:e.log,yieldBytes:!0});e.log("selected %s as muxer protocol",s);let i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing outbound connection",o),new E(String(o),C.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){let n=Array.from(t.keys());e.log("inbound handling muxers %s",n);try{let{stream:o,protocol:s}=await Io(e,n,{log:e.log}),i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing inbound connection",o),new E(String(o),C.ERR_MUXER_UNAVAILABLE)}}};var Zd="1.8.1-a82ff8221",Qd="libp2p";var ql=class extends Rt{peerId;peerStore;contentRouting;peerRouting;metrics;services;logger;status;components;log;constructor(e){super(),this.status="stopped";let t=new Rt,n=t.dispatchEvent.bind(t);t.dispatchEvent=a=>{let c=n(a),u=this.dispatchEvent(new ta(a.type,{detail:a.detail}));return c||u},fe(1/0,t),this.peerId=e.peerId,this.logger=e.logger??Hs(),this.log=this.logger.forComponent("libp2p"),this.services={};let o=this.components=ud({peerId:e.peerId,privateKey:e.privateKey,nodeInfo:e.nodeInfo??{name:Qd,version:Zd},logger:this.logger,events:t,datastore:e.datastore??new ii,connectionGater:pd(e.connectionGater),dns:e.dns});this.peerStore=this.configureComponent("peerStore",new oi(o,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),e.metrics!=null&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),o.events.addEventListener("peer:update",a=>{if(a.detail.previous==null){let c={id:a.detail.peer.id,multiaddrs:a.detail.peer.addresses.map(u=>u.multiaddr)};o.events.safeDispatchEvent("peer:discovery",{detail:c})}}),e.connectionProtector!=null&&this.configureComponent("connectionProtector",e.connectionProtector(o)),this.components.upgrader=new ji(this.components,{connectionEncryption:(e.connectionEncryption??[]).map((a,c)=>this.configureComponent(`connection-encryption-${c}`,a(this.components))),muxers:(e.streamMuxers??[]).map((a,c)=>this.configureComponent(`stream-muxers-${c}`,a(this.components))),inboundUpgradeTimeout:e.connectionManager?.inboundUpgradeTimeout}),this.configureComponent("transportManager",new qi(this.components,e.transportManager)),this.configureComponent("connectionManager",new Ui(this.components,e.connectionManager)),this.configureComponent("registrar",new Hi(this.components)),this.configureComponent("addressManager",new ai(this.components,e.addresses));let s=(e.peerRouters??[]).map((a,c)=>this.configureComponent(`peer-router-${c}`,a(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new Vi(this.components,{routers:s}));let i=(e.contentRouters??[]).map((a,c)=>this.configureComponent(`content-router-${c}`,a(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new Mi(this.components,{routers:i})),this.configureComponent("randomWalk",new Ki(this.components)),(e.peerDiscovery??[]).forEach((a,c)=>{this.configureComponent(`peer-discovery-${c}`,a(this.components)).addEventListener("peer",f=>{this.#e(f)})}),e.transports?.forEach((a,c)=>{this.components.transportManager.add(this.configureComponent(`transport-${c}`,a(this.components)))}),e.services!=null)for(let a of Object.keys(e.services)){let c=e.services[a],u=c(this.components);if(u==null){this.log.error("service factory %s returned null or undefined instance",a);continue}this.services[a]=u,this.configureComponent(a,u),u[Zi]!=null&&(this.log("registering service %s for content routing",a),i.push(u[Zi])),u[Ji]!=null&&(this.log("registering service %s for peer routing",a),s.push(u[Ji])),u[Qi]!=null&&(this.log("registering service %s for peer discovery",a),u[Qi].addEventListener?.("peer",f=>{this.#e(f)}))}fd(o)}configureComponent(e,t){return t==null&&this.log.error("component %s was null or undefined",e),this.components[e]=t,t}async start(){if(this.status==="stopped"){this.status="starting",this.log("libp2p is starting");try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.status="started",this.safeDispatchEvent("start",{detail:this}),this.log("libp2p has started")}catch(e){throw this.log.error("An error occurred starting libp2p",e),this.status="started",await this.stop(),e}}}async stop(){this.status==="started"&&(this.log("libp2p is stopping"),this.status="stopping",await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.status="stopped",this.safeDispatchEvent("stop",{detail:this}),this.log("libp2p has stopped"))}getConnections(e){return this.components.connectionManager.getConnections(e)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){let e=new Kt;for(let t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e,t={}){return this.components.connectionManager.openConnection(e,{priority:75,...t})}async dialProtocol(e,t,n={}){if(t==null)throw new E("no protocols were provided to open a stream",C.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(t=Array.isArray(t)?t:[t],t.length===0)throw new E("no protocols were provided to open a stream",C.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,n)).newStream(t,n)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e,t={}){lr(e)&&(e=be(e.getPeerId()??"")),await this.components.connectionManager.closeConnections(e,t)}async getPublicKey(e,t={}){if(this.log("getPublicKey %p",e),e.publicKey!=null)return e.publicKey;try{let s=await this.peerStore.get(e);if(s.id.publicKey!=null)return s.id.publicKey}catch(s){if(s.code!==C.ERR_NOT_FOUND)throw s}let n=Ie([L("/pk/"),e.multihash.digest]),o=await this.contentRouting.get(n,t);return oo(o),await this.peerStore.patch(e,{publicKey:o}),o}async handle(e,t,n){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async o=>{await this.components.registrar.handle(o,t,n)}))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async t=>{await this.components.registrar.unhandle(t)}))}async register(e,t){return this.components.registrar.register(e,t)}unregister(e){this.components.registrar.unregister(e)}async isDialable(e,t={}){return this.components.connectionManager.isDialable(e,t)}#e(e){let{detail:t}=e;if(t.id.toString()===this.peerId.toString()){this.log.error(new Error(C.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(t.id,{multiaddrs:t.multiaddrs}).catch(n=>{this.log.error(n)})}};async function Jd(r={}){let e=r.peerId??=await Bh();if(e.privateKey==null)throw new E("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return r.privateKey??=await so(e.privateKey),new ql(await Md(r))}async function Fw(r={}){let e=await Jd(r);return r.start!==!1&&await e.start(),e}return dp(Vw);})();
20
+ `),t),t.log('handle: responded with "na" for "%s"',o)}}var Dw=500,Hl=class{id;remoteAddr;remotePeer;direction;timeline;multiplexer;encryption;status;transient;log;tags;_newStream;_close;_abort;_getStreams;constructor(e){let{remoteAddr:t,remotePeer:n,newStream:o,close:s,abort:i,getStreams:a}=e;this.id=`${parseInt(String(Math.random()*1e9)).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=n,this.direction=e.direction,this.status="open",this.timeline=e.timeline,this.multiplexer=e.multiplexer,this.encryption=e.encryption,this.transient=e.transient??!1,this.log=e.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`),this.remoteAddr.getPeerId()==null&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=o,this._close=s,this._abort=i,this._getStreams=a,this.tags=[]}[Symbol.toStringTag]="Connection";[Jl]=!0;get streams(){return this._getStreams()}async newStream(e,t){if(this.status==="closing")throw new E("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if(this.status==="closed")throw new E("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&t?.runOnTransientConnection!==!0)throw new E("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");let n=await this._newStream(e,t);return n.direction="outbound",n}async close(e={}){if(!(this.status==="closed"||this.status==="closing")){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",e.signal==null){let t=AbortSignal.timeout(Dw);fe(1/0,t),e={...e,signal:t}}try{this.log.trace("closing all streams"),await Promise.all(this.streams.map(async t=>t.close(e))),this.log.trace("closing underlying transport"),await this._close(e),this.log.trace("updating timeline with close time"),this.status="closed",this.timeline.close=Date.now()}catch(t){this.log.error("error encountered during graceful close of connection to %a",this.remoteAddr,t),this.abort(t)}}}abort(e){this.log.error("aborting connection to %a due to error",this.remoteAddr,e),this.status="closing",this.streams.forEach(t=>{t.abort(e)}),this.log.error("all streams aborted",this.streams.length),this._abort(e),this.timeline.close=Date.now(),this.status="closed"}};function jd(r){return new Hl(r)}var Pw=3e4;function Ow(r,e){try{let{options:t}=e.getHandler(r);return t.maxInboundStreams}catch(t){if(t.code!==C.ERR_NO_HANDLER_FOR_PROTOCOL)throw t}return Dl}function Uw(r,e,t={}){try{let{options:n}=e.getHandler(r);if(n.maxOutboundStreams!=null)return n.maxOutboundStreams}catch(n){if(n.code!==C.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return t.maxOutboundStreams??Pl}function Xd(r,e,t){let n=0;return t.streams.forEach(o=>{o.direction===e&&o.protocol===r&&n++}),n}var ji=class{components;connectionEncryption;muxers;inboundUpgradeTimeout;events;constructor(e,t){this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach(n=>{this.connectionEncryption.set(n.protocol,n)}),this.muxers=new Map,t.muxers.forEach(n=>{this.muxers.set(n.protocol,n)}),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout??2e3,this.events=e.events}[Symbol.toStringTag]="@libp2p/upgrader";async shouldBlockConnection(e,t,n){let o=this.components.connectionGater[n];if(o!==void 0&&await o(e,t))throw new E(`The multiaddr connection is blocked by gater.${n}`,C.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new E("connection denied",C.ERR_CONNECTION_DENIED);let o,s,i,a,c,u=AbortSignal.timeout(this.inboundUpgradeTimeout),f=()=>{e.abort(new E("inbound upgrade timeout",No))};u.addEventListener("abort",f,{once:!0}),fe(1/0,u);try{if(await this.components.connectionGater.denyInboundConnection?.(e)===!0)throw new E("The multiaddr connection is blocked by gater.acceptConnection",C.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the inbound connection upgrade");let l=e;if(t?.skipProtection!==!0){let p=this.components.connectionProtector;p!=null&&(e.log("protecting the inbound connection"),l=await p.protect(e))}try{if(o=l,t?.skipEncryption!==!0){t?.onProgress?.(new de("upgrader:encrypt-inbound-connection")),{conn:o,remotePeer:s,protocol:c}=await this._encryptInbound(l);let p={...l,...o};await this.shouldBlockConnection(s,p,"denyInboundEncryptedConnection")}else{let p=e.remoteAddr.getPeerId();if(p==null)throw new E("inbound connection that skipped encryption must have a peer id",C.ERR_INVALID_MULTIADDR);let h=be(p);c="native",s=h}if(i=o,t?.muxerFactory!=null)a=t.muxerFactory;else if(this.muxers.size>0){t?.onProgress?.(new de("upgrader:multiplex-inbound-connection"));let p=await this._multiplexInbound({...l,...o},this.muxers);a=p.muxerFactory,i=p.stream}}catch(p){throw e.log.error("failed to upgrade inbound connection",p),p}return await this.shouldBlockConnection(s,e,"denyInboundUpgradedConnection"),e.log("successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:c,direction:"inbound",maConn:e,upgradedConn:i,muxerFactory:a,remotePeer:s,transient:t?.transient})}finally{u.removeEventListener("abort",f),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(e,t){let n=e.remoteAddr.getPeerId(),o;n!=null&&(o=be(n),await this.shouldBlockConnection(o,e,"denyOutboundConnection"));let s,i,a,c,u;this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the outbound connection upgrade");let f=e;if(t?.skipProtection!==!0){let l=this.components.connectionProtector;l!=null&&(f=await l.protect(e))}try{if(s=f,t?.skipEncryption!==!0){({conn:s,remotePeer:i,protocol:c}=await this._encryptOutbound(f,o));let l={...f,...s};await this.shouldBlockConnection(i,l,"denyOutboundEncryptedConnection")}else{if(o==null)throw new E("Encryption was skipped but no peer id was passed",C.ERR_INVALID_PEER);c="native",i=o}if(a=s,t?.muxerFactory!=null)u=t.muxerFactory;else if(this.muxers.size>0){let l=await this._multiplexOutbound({...f,...s},this.muxers);u=l.muxerFactory,a=l.stream}}catch(l){throw e.log.error("failed to upgrade outbound connection",l),await e.close(l),l}return await this.shouldBlockConnection(i,e,"denyOutboundUpgradedConnection"),e.log("successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:c,direction:"outbound",maConn:e,upgradedConn:a,muxerFactory:u,remotePeer:i,transient:t?.transient})}_createConnection(e){let{cryptoProtocol:t,direction:n,maConn:o,upgradedConn:s,remotePeer:i,muxerFactory:a,transient:c}=e,u,f,l;a!=null&&(u=a.createStreamMuxer({direction:n,onIncomingStream:d=>{l!=null&&Promise.resolve().then(async()=>{let m=this.components.registrar.getProtocols(),{stream:y,protocol:g}=await Io(d,m,{log:d.log,yieldBytes:!1});if(l==null)return;l.log("incoming stream opened on %s",g);let w=Ow(g,this.components.registrar);if(Xd(g,"inbound",l)===w){let x=new E(`Too many inbound protocol streams for protocol "${g}" - limit ${w}`,C.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw d.abort(x),x}d.source=y.source,d.sink=y.sink,d.protocol=g,y.closeWrite!=null&&(d.closeWrite=y.closeWrite),y.closeRead!=null&&(d.closeRead=y.closeRead),y.close!=null&&(d.close=y.close),await this.components.peerStore.merge(i,{protocols:[g]}),this.components.metrics?.trackProtocolStream(d,l),this._onStream({connection:l,stream:d,protocol:g})}).catch(async m=>{l.log.error("error handling incoming stream id %s",d.id,m.message,m.code,m.stack),d.timeline.close==null&&await d.close()})}}),f=async(d,m={})=>{if(u==null)throw new E("Stream is not multiplexed",C.ERR_MUXER_UNAVAILABLE);l.log("starting new stream for protocols %s",d);let y=await u.newStream();l.log.trace("started new stream %s for protocols %s",y.id,d);try{if(m.signal==null){y.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",d);let v=AbortSignal.timeout(Pw);fe(1/0,v),m={...m,signal:v}}y.log.trace("selecting protocol from protocols %s",d);let{stream:g,protocol:w}=await Ro(y,d,{...m,log:y.log,yieldBytes:!0});y.log("selected protocol %s",w);let b=Uw(w,this.components.registrar,m),x=Xd(w,"outbound",l);if(x>=b){let v=new E(`Too many outbound protocol streams for protocol "${w}" - ${x}/${b}`,C.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw y.abort(v),v}return await this.components.peerStore.merge(i,{protocols:[w]}),y.source=g.source,y.sink=g.sink,y.protocol=w,g.closeWrite!=null&&(y.closeWrite=g.closeWrite),g.closeRead!=null&&(y.closeRead=g.closeRead),g.close!=null&&(y.close=g.close),this.components.metrics?.trackProtocolStream(y,l),y}catch(g){throw l.log.error("could not create new stream for protocols %s",d,g),y.timeline.close==null&&y.abort(g),g.code!=null?g:new E(String(g),C.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([u.sink(s.source),s.sink(u.source)]).catch(d=>{l.log.error("error piping data through muxer",d)}));let p=o.timeline;o.timeline=new Proxy(p,{set:(...d)=>(l!=null&&d[1]==="close"&&d[2]!=null&&p.close==null&&(async()=>{try{l.status==="open"&&await l.close()}catch(m){l.log.error("error closing connection after timeline close",m)}finally{this.events.safeDispatchEvent("connection:close",{detail:l})}})().catch(m=>{l.log.error("error thrown while dispatching connection:close event",m)}),Reflect.set(...d))}),o.timeline.upgraded=Date.now();let h=()=>{throw new E("connection is not multiplexed",C.ERR_CONNECTION_NOT_MULTIPLEXED)};return l=jd({remoteAddr:o.remoteAddr,remotePeer:i,status:"open",direction:n,timeline:o.timeline,multiplexer:u?.protocol,encryption:t,transient:c,logger:this.components.logger,newStream:f??h,getStreams:()=>u!=null?u.streams:[],close:async d=>{u!=null&&(l.log.trace("close muxer"),await u.close(d)),l.log.trace("close maconn"),await o.close(d),l.log.trace("closed maconn")},abort:d=>{o.abort(d),u?.abort(d)}}),this.events.safeDispatchEvent("connection:open",{detail:l}),l}_onStream(e){let{connection:t,stream:n,protocol:o}=e,{handler:s,options:i}=this.components.registrar.getHandler(o);if(t.transient&&i.runOnTransientConnection!==!0)throw new E("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");s({connection:t,stream:n})}async _encryptInbound(e){let t=Array.from(this.connectionEncryption.keys());e.log("handling inbound crypto protocol selection",t);try{let{stream:n,protocol:o}=await Io(e,t,{log:e.log}),s=this.connectionEncryption.get(o);if(s==null)throw new Error(`no crypto module found for ${o}`);return e.log("encrypting inbound connection using",o),{...await s.secureInbound(this.components.peerId,n),protocol:o}}catch(n){throw e.log.error("encrypting inbound connection failed",n),new E(n.message,C.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){let n=Array.from(this.connectionEncryption.keys());e.log("selecting outbound crypto protocol",n);try{e.log.trace("selecting encrypter from %s",n);let{stream:o,protocol:s}=await Ro(e,n,{log:e.log,yieldBytes:!0}),i=this.connectionEncryption.get(s);if(i==null)throw new Error(`no crypto module found for ${s}`);return e.log("encrypting outbound connection to %p using %s",t,i),{...await i.secureOutbound(this.components.peerId,o,t),protocol:s}}catch(o){throw e.log.error("encrypting outbound connection to %p failed",t,o),new E(o.message,C.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){let n=Array.from(t.keys());e.log("outbound selecting muxer %s",n);try{e.log.trace("selecting stream muxer from %s",n);let{stream:o,protocol:s}=await Ro(e,n,{log:e.log,yieldBytes:!0});e.log("selected %s as muxer protocol",s);let i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing outbound connection",o),new E(String(o),C.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){let n=Array.from(t.keys());e.log("inbound handling muxers %s",n);try{let{stream:o,protocol:s}=await Io(e,n,{log:e.log}),i=t.get(s);return{stream:o,muxerFactory:i}}catch(o){throw e.log.error("error multiplexing inbound connection",o),new E(String(o),C.ERR_MUXER_UNAVAILABLE)}}};var Zd="1.8.1-a8ec2bcb7",Qd="libp2p";var ql=class extends Rt{peerId;peerStore;contentRouting;peerRouting;metrics;services;logger;status;components;log;constructor(e){super(),this.status="stopped";let t=new Rt,n=t.dispatchEvent.bind(t);t.dispatchEvent=a=>{let c=n(a),u=this.dispatchEvent(new ta(a.type,{detail:a.detail}));return c||u},fe(1/0,t),this.peerId=e.peerId,this.logger=e.logger??Hs(),this.log=this.logger.forComponent("libp2p"),this.services={};let o=this.components=ud({peerId:e.peerId,privateKey:e.privateKey,nodeInfo:e.nodeInfo??{name:Qd,version:Zd},logger:this.logger,events:t,datastore:e.datastore??new ii,connectionGater:pd(e.connectionGater),dns:e.dns});this.peerStore=this.configureComponent("peerStore",new oi(o,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),e.metrics!=null&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),o.events.addEventListener("peer:update",a=>{if(a.detail.previous==null){let c={id:a.detail.peer.id,multiaddrs:a.detail.peer.addresses.map(u=>u.multiaddr)};o.events.safeDispatchEvent("peer:discovery",{detail:c})}}),e.connectionProtector!=null&&this.configureComponent("connectionProtector",e.connectionProtector(o)),this.components.upgrader=new ji(this.components,{connectionEncryption:(e.connectionEncryption??[]).map((a,c)=>this.configureComponent(`connection-encryption-${c}`,a(this.components))),muxers:(e.streamMuxers??[]).map((a,c)=>this.configureComponent(`stream-muxers-${c}`,a(this.components))),inboundUpgradeTimeout:e.connectionManager?.inboundUpgradeTimeout}),this.configureComponent("transportManager",new qi(this.components,e.transportManager)),this.configureComponent("connectionManager",new Ui(this.components,e.connectionManager)),this.configureComponent("registrar",new Hi(this.components)),this.configureComponent("addressManager",new ai(this.components,e.addresses));let s=(e.peerRouters??[]).map((a,c)=>this.configureComponent(`peer-router-${c}`,a(this.components)));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new Vi(this.components,{routers:s}));let i=(e.contentRouters??[]).map((a,c)=>this.configureComponent(`content-router-${c}`,a(this.components)));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new Mi(this.components,{routers:i})),this.configureComponent("randomWalk",new Ki(this.components)),(e.peerDiscovery??[]).forEach((a,c)=>{this.configureComponent(`peer-discovery-${c}`,a(this.components)).addEventListener("peer",f=>{this.#e(f)})}),e.transports?.forEach((a,c)=>{this.components.transportManager.add(this.configureComponent(`transport-${c}`,a(this.components)))}),e.services!=null)for(let a of Object.keys(e.services)){let c=e.services[a],u=c(this.components);if(u==null){this.log.error("service factory %s returned null or undefined instance",a);continue}this.services[a]=u,this.configureComponent(a,u),u[Zi]!=null&&(this.log("registering service %s for content routing",a),i.push(u[Zi])),u[Ji]!=null&&(this.log("registering service %s for peer routing",a),s.push(u[Ji])),u[Qi]!=null&&(this.log("registering service %s for peer discovery",a),u[Qi].addEventListener?.("peer",f=>{this.#e(f)}))}fd(o)}configureComponent(e,t){return t==null&&this.log.error("component %s was null or undefined",e),this.components[e]=t,t}async start(){if(this.status==="stopped"){this.status="starting",this.log("libp2p is starting");try{await this.components.beforeStart?.(),await this.components.start(),await this.components.afterStart?.(),this.status="started",this.safeDispatchEvent("start",{detail:this}),this.log("libp2p has started")}catch(e){throw this.log.error("An error occurred starting libp2p",e),this.status="started",await this.stop(),e}}}async stop(){this.status==="started"&&(this.log("libp2p is stopping"),this.status="stopping",await this.components.beforeStop?.(),await this.components.stop(),await this.components.afterStop?.(),this.status="stopped",this.safeDispatchEvent("stop",{detail:this}),this.log("libp2p has stopped"))}getConnections(e){return this.components.connectionManager.getConnections(e)}getDialQueue(){return this.components.connectionManager.getDialQueue()}getPeers(){let e=new Kt;for(let t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e,t={}){return this.components.connectionManager.openConnection(e,{priority:75,...t})}async dialProtocol(e,t,n={}){if(t==null)throw new E("no protocols were provided to open a stream",C.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(t=Array.isArray(t)?t:[t],t.length===0)throw new E("no protocols were provided to open a stream",C.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,n)).newStream(t,n)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e,t={}){lr(e)&&(e=be(e.getPeerId()??"")),await this.components.connectionManager.closeConnections(e,t)}async getPublicKey(e,t={}){if(this.log("getPublicKey %p",e),e.publicKey!=null)return e.publicKey;try{let s=await this.peerStore.get(e);if(s.id.publicKey!=null)return s.id.publicKey}catch(s){if(s.code!==C.ERR_NOT_FOUND)throw s}let n=Ie([L("/pk/"),e.multihash.digest]),o=await this.contentRouting.get(n,t);return oo(o),await this.peerStore.patch(e,{publicKey:o}),o}async handle(e,t,n){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async o=>{await this.components.registrar.handle(o,t,n)}))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map(async t=>{await this.components.registrar.unhandle(t)}))}async register(e,t){return this.components.registrar.register(e,t)}unregister(e){this.components.registrar.unregister(e)}async isDialable(e,t={}){return this.components.connectionManager.isDialable(e,t)}#e(e){let{detail:t}=e;if(t.id.toString()===this.peerId.toString()){this.log.error(new Error(C.ERR_DISCOVERED_SELF));return}this.components.peerStore.merge(t.id,{multiaddrs:t.multiaddrs}).catch(n=>{this.log.error(n)})}};async function Jd(r={}){let e=r.peerId??=await Bh();if(e.privateKey==null)throw new E("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return r.privateKey??=await so(e.privateKey),new ql(await Md(r))}async function Fw(r={}){let e=await Jd(r);return r.start!==!1&&await e.start(),e}return dp(Vw);})();
21
21
  /*! Bundled license information:
22
22
 
23
23
  pvtsutils/build/index.js:
@@ -1,3 +1,3 @@
1
- export declare const version = "1.8.1-a82ff8221";
1
+ export declare const version = "1.8.1-a8ec2bcb7";
2
2
  export declare const name = "libp2p";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
- export const version = '1.8.1-a82ff8221';
1
+ export const version = '1.8.1-a8ec2bcb7';
2
2
  export const name = 'libp2p';
3
3
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libp2p",
3
- "version": "1.8.1-a82ff8221",
3
+ "version": "1.8.1-a8ec2bcb7",
4
4
  "description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/libp2p#readme",
@@ -85,16 +85,16 @@
85
85
  "test:webkit": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" -- --browser webkit"
86
86
  },
87
87
  "dependencies": {
88
- "@libp2p/crypto": "4.1.6-a82ff8221",
89
- "@libp2p/interface": "1.6.1-a82ff8221",
90
- "@libp2p/interface-internal": "1.3.1-a82ff8221",
91
- "@libp2p/logger": "4.0.17-a82ff8221",
92
- "@libp2p/multistream-select": "5.1.14-a82ff8221",
93
- "@libp2p/peer-collections": "5.2.6-a82ff8221",
94
- "@libp2p/peer-id": "4.2.1-a82ff8221",
95
- "@libp2p/peer-id-factory": "4.2.1-a82ff8221",
96
- "@libp2p/peer-store": "10.1.2-a82ff8221",
97
- "@libp2p/utils": "5.4.6-a82ff8221",
88
+ "@libp2p/crypto": "4.1.6-a8ec2bcb7",
89
+ "@libp2p/interface": "1.6.1-a8ec2bcb7",
90
+ "@libp2p/interface-internal": "1.3.1-a8ec2bcb7",
91
+ "@libp2p/logger": "4.0.17-a8ec2bcb7",
92
+ "@libp2p/multistream-select": "5.1.14-a8ec2bcb7",
93
+ "@libp2p/peer-collections": "5.2.6-a8ec2bcb7",
94
+ "@libp2p/peer-id": "4.2.1-a8ec2bcb7",
95
+ "@libp2p/peer-id-factory": "4.2.1-a8ec2bcb7",
96
+ "@libp2p/peer-store": "10.1.2-a8ec2bcb7",
97
+ "@libp2p/utils": "5.4.6-a8ec2bcb7",
98
98
  "@multiformats/dns": "^1.0.6",
99
99
  "@multiformats/multiaddr": "^12.2.3",
100
100
  "@multiformats/multiaddr-matcher": "^1.2.1",
@@ -113,13 +113,13 @@
113
113
  },
114
114
  "devDependencies": {
115
115
  "@chainsafe/libp2p-yamux": "^6.0.2",
116
- "@libp2p/circuit-relay-v2": "1.1.2-a82ff8221",
117
- "@libp2p/identify": "2.1.2-a82ff8221",
118
- "@libp2p/interface-compliance-tests": "5.4.9-a82ff8221",
119
- "@libp2p/mplex": "10.1.2-a82ff8221",
120
- "@libp2p/plaintext": "1.1.2-a82ff8221",
121
- "@libp2p/tcp": "9.1.2-a82ff8221",
122
- "@libp2p/websockets": "8.1.2-a82ff8221",
116
+ "@libp2p/circuit-relay-v2": "1.1.2-a8ec2bcb7",
117
+ "@libp2p/identify": "2.1.2-a8ec2bcb7",
118
+ "@libp2p/interface-compliance-tests": "5.4.9-a8ec2bcb7",
119
+ "@libp2p/mplex": "10.1.2-a8ec2bcb7",
120
+ "@libp2p/plaintext": "1.1.2-a8ec2bcb7",
121
+ "@libp2p/tcp": "9.1.2-a8ec2bcb7",
122
+ "@libp2p/websockets": "8.1.2-a8ec2bcb7",
123
123
  "@multiformats/mafmt": "^12.1.6",
124
124
  "aegir": "^43.0.1",
125
125
  "delay": "^6.0.0",
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '1.8.1-a82ff8221'
1
+ export const version = '1.8.1-a8ec2bcb7'
2
2
  export const name = 'libp2p'