mirror of
https://github.com/logos-messaging/lab.waku.org.git
synced 2026-01-09 17:23:07 +00:00
3 lines
1.5 MiB
3 lines
1.5 MiB
/*! For license information please see main.b0962d94.js.LICENSE.txt */
|
|
(()=>{var __webpack_modules__={4762:e=>{"use strict";e.exports=function(e,t){var r=new Array(arguments.length-1),n=0,i=2,s=!0;for(;i<arguments.length;)r[n++]=arguments[i++];return new Promise((function(i,o){r[n]=function(e){if(s)if(s=!1,e)o(e);else{for(var t=new Array(arguments.length-1),r=0;r<t.length;)t[r++]=arguments[r];i.apply(null,t)}};try{e.apply(t||null,r)}catch(a){s&&(s=!1,o(a))}}))}},6762:(e,t)=>{"use strict";var r=t;r.length=function(e){var t=e.length;if(!t)return 0;for(var r=0;--t%4>1&&"="===e.charAt(t);)++r;return Math.ceil(3*e.length)/4-r};for(var n=new Array(64),i=new Array(123),s=0;s<64;)i[n[s]=s<26?s+65:s<52?s+71:s<62?s-4:s-59|43]=s++;r.encode=function(e,t,r){for(var i,s=null,o=[],a=0,c=0;t<r;){var u=e[t++];switch(c){case 0:o[a++]=n[u>>2],i=(3&u)<<4,c=1;break;case 1:o[a++]=n[i|u>>4],i=(15&u)<<2,c=2;break;case 2:o[a++]=n[i|u>>6],o[a++]=n[63&u],c=0}a>8191&&((s||(s=[])).push(String.fromCharCode.apply(String,o)),a=0)}return c&&(o[a++]=n[i],o[a++]=61,1===c&&(o[a++]=61)),s?(a&&s.push(String.fromCharCode.apply(String,o.slice(0,a))),s.join("")):String.fromCharCode.apply(String,o.slice(0,a))};var o="invalid encoding";r.decode=function(e,t,r){for(var n,s=r,a=0,c=0;c<e.length;){var u=e.charCodeAt(c++);if(61===u&&a>1)break;if(void 0===(u=i[u]))throw Error(o);switch(a){case 0:n=u,a=1;break;case 1:t[r++]=n<<2|(48&u)>>4,n=u,a=2;break;case 2:t[r++]=(15&n)<<4|(60&u)>>2,n=u,a=3;break;case 3:t[r++]=(3&n)<<6|u,a=0}}if(1===a)throw Error(o);return r-s},r.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},7351:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,r){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:r||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var r=this._listeners[e],n=0;n<r.length;)r[n].fn===t?r.splice(n,1):++n;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var r=[],n=1;n<arguments.length;)r.push(arguments[n++]);for(n=0;n<t.length;)t[n].fn.apply(t[n++].ctx,r)}return this}},217:e=>{"use strict";function t(e){return"undefined"!==typeof Float32Array?function(){var t=new Float32Array([-0]),r=new Uint8Array(t.buffer),n=128===r[3];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3]}function s(e,n,i){t[0]=e,n[i]=r[3],n[i+1]=r[2],n[i+2]=r[1],n[i+3]=r[0]}function o(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],t[0]}function a(e,n){return r[3]=e[n],r[2]=e[n+1],r[1]=e[n+2],r[0]=e[n+3],t[0]}e.writeFloatLE=n?i:s,e.writeFloatBE=n?s:i,e.readFloatLE=n?o:a,e.readFloatBE=n?a:o}():function(){function t(e,t,r,n){var i=t<0?1:0;if(i&&(t=-t),0===t)e(1/t>0?0:2147483648,r,n);else if(isNaN(t))e(2143289344,r,n);else if(t>34028234663852886e22)e((i<<31|2139095040)>>>0,r,n);else if(t<11754943508222875e-54)e((i<<31|Math.round(t/1401298464324817e-60))>>>0,r,n);else{var s=Math.floor(Math.log(t)/Math.LN2);e((i<<31|s+127<<23|8388607&Math.round(t*Math.pow(2,-s)*8388608))>>>0,r,n)}}function o(e,t,r){var n=e(t,r),i=2*(n>>31)+1,s=n>>>23&255,o=8388607&n;return 255===s?o?NaN:i*(1/0):0===s?1401298464324817e-60*i*o:i*Math.pow(2,s-150)*(o+8388608)}e.writeFloatLE=t.bind(null,r),e.writeFloatBE=t.bind(null,n),e.readFloatLE=o.bind(null,i),e.readFloatBE=o.bind(null,s)}(),"undefined"!==typeof Float64Array?function(){var t=new Float64Array([-0]),r=new Uint8Array(t.buffer),n=128===r[7];function i(e,n,i){t[0]=e,n[i]=r[0],n[i+1]=r[1],n[i+2]=r[2],n[i+3]=r[3],n[i+4]=r[4],n[i+5]=r[5],n[i+6]=r[6],n[i+7]=r[7]}function s(e,n,i){t[0]=e,n[i]=r[7],n[i+1]=r[6],n[i+2]=r[5],n[i+3]=r[4],n[i+4]=r[3],n[i+5]=r[2],n[i+6]=r[1],n[i+7]=r[0]}function o(e,n){return r[0]=e[n],r[1]=e[n+1],r[2]=e[n+2],r[3]=e[n+3],r[4]=e[n+4],r[5]=e[n+5],r[6]=e[n+6],r[7]=e[n+7],t[0]}function a(e,n){return r[7]=e[n],r[6]=e[n+1],r[5]=e[n+2],r[4]=e[n+3],r[3]=e[n+4],r[2]=e[n+5],r[1]=e[n+6],r[0]=e[n+7],t[0]}e.writeDoubleLE=n?i:s,e.writeDoubleBE=n?s:i,e.readDoubleLE=n?o:a,e.readDoubleBE=n?a:o}():function(){function t(e,t,r,n,i,s){var o=n<0?1:0;if(o&&(n=-n),0===n)e(0,i,s+t),e(1/n>0?0:2147483648,i,s+r);else if(isNaN(n))e(0,i,s+t),e(2146959360,i,s+r);else if(n>17976931348623157e292)e(0,i,s+t),e((o<<31|2146435072)>>>0,i,s+r);else{var a;if(n<22250738585072014e-324)e((a=n/5e-324)>>>0,i,s+t),e((o<<31|a/4294967296)>>>0,i,s+r);else{var c=Math.floor(Math.log(n)/Math.LN2);1024===c&&(c=1023),e(4503599627370496*(a=n*Math.pow(2,-c))>>>0,i,s+t),e((o<<31|c+1023<<20|1048576*a&1048575)>>>0,i,s+r)}}}function o(e,t,r,n,i){var s=e(n,i+t),o=e(n,i+r),a=2*(o>>31)+1,c=o>>>20&2047,u=4294967296*(1048575&o)+s;return 2047===c?u?NaN:a*(1/0):0===c?5e-324*a*u:a*Math.pow(2,c-1075)*(u+4503599627370496)}e.writeDoubleLE=t.bind(null,r,0,4),e.writeDoubleBE=t.bind(null,n,4,0),e.readDoubleLE=o.bind(null,i,0,4),e.readDoubleBE=o.bind(null,s,4,0)}(),e}function r(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function n(e,t,r){t[r]=e>>>24,t[r+1]=e>>>16&255,t[r+2]=e>>>8&255,t[r+3]=255&e}function i(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function s(e,t){return(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}e.exports=t(t)},4882:module=>{"use strict";function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},6931:e=>{"use strict";e.exports=function(e,t,r){var n=r||8192,i=n>>>1,s=null,o=n;return function(r){if(r<1||r>i)return e(r);o+r>n&&(s=e(n),o=0);var a=t.call(s,o,o+=r);return 7&o&&(o=1+(7|o)),a}}},8626:(e,t)=>{"use strict";var r=t;r.length=function(e){for(var t=0,r=0,n=0;n<e.length;++n)(r=e.charCodeAt(n))<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t},r.read=function(e,t,r){if(r-t<1)return"";for(var n,i=null,s=[],o=0;t<r;)(n=e[t++])<128?s[o++]=n:n>191&&n<224?s[o++]=(31&n)<<6|63&e[t++]:n>239&&n<365?(n=((7&n)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,s[o++]=55296+(n>>10),s[o++]=56320+(1023&n)):s[o++]=(15&n)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),o=0);return i?(o&&i.push(String.fromCharCode.apply(String,s.slice(0,o))),i.join("")):String.fromCharCode.apply(String,s.slice(0,o))},r.write=function(e,t,r){for(var n,i,s=r,o=0;o<e.length;++o)(n=e.charCodeAt(o))<128?t[r++]=n:n<2048?(t[r++]=n>>6|192,t[r++]=63&n|128):55296===(64512&n)&&56320===(64512&(i=e.charCodeAt(o+1)))?(n=65536+((1023&n)<<10)+(1023&i),++o,t[r++]=n>>18|240,t[r++]=n>>12&63|128,t[r++]=n>>6&63|128,t[r++]=63&n|128):(t[r++]=n>>12|224,t[r++]=n>>6&63|128,t[r++]=63&n|128);return r-s}},6522:(e,t,r)=>{t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))})),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(r){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(r){}!e&&"undefined"!==typeof process&&"env"in process&&(e={NODE_ENV:"production",PUBLIC_URL:"/web-chat",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DEBUG);return e},t.useColors=function(){if("undefined"!==typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!==typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!==typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!==typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!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`."))}})(),t.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"],t.log=console.debug||console.log||(()=>{}),e.exports=r(5237)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},5237:(e,t,r)=>{e.exports=function(e){function t(e){let r,i,s,o=null;function a(){for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];if(!a.enabled)return;const s=a,o=Number(new Date),c=o-(r||o);s.diff=c,s.prev=r,s.curr=o,r=o,n[0]=t.coerce(n[0]),"string"!==typeof n[0]&&n.unshift("%O");let u=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,((e,r)=>{if("%%"===e)return"%";u++;const i=t.formatters[r];if("function"===typeof i){const t=n[u];e=i.call(s,t),n.splice(u,1),u--}return e})),t.formatArgs.call(s,n);(s.log||t.log).apply(s,n)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=n,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==o?o:(i!==t.namespaces&&(i=t.namespaces,s=t.enabled(e)),s),set:e=>{o=e}}),"function"===typeof t.init&&t.init(a),a}function n(e,r){const n=t(this.namespace+("undefined"===typeof r?":":r)+e);return n.log=this.log,n}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){if(e instanceof Error)return e.stack||e.message;return e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let r;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"===typeof e?e:"").split(/[\s,]+/),i=n.length;for(r=0;r<i;r++)n[r]&&("-"===(e=n[r].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.slice(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let r,n;for(r=0,n=t.skips.length;r<n;r++)if(t.skips[r].test(e))return!1;for(r=0,n=t.names.length;r<n;r++)if(t.names[r].test(e))return!0;return!1},t.humanize=r(7340),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((r=>{t[r]=e[r]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let r=0;for(let t=0;t<e.length;t++)r=(r<<5)-r+e.charCodeAt(t),r|=0;return t.colors[Math.abs(r)%t.colors.length]},t.enable(t.load()),t}},80:e=>{"use strict";function t(e,t){t=t||{};this._capacity=t.capacity,this._head=0,this._tail=0,Array.isArray(e)?this._fromArray(e):(this._capacityMask=3,this._list=new Array(4))}t.prototype.peekAt=function(e){var t=e;if(t===(0|t)){var r=this.size();if(!(t>=r||t<-r))return t<0&&(t+=r),t=this._head+t&this._capacityMask,this._list[t]}},t.prototype.get=function(e){return this.peekAt(e)},t.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},t.prototype.peekFront=function(){return this.peek()},t.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(t.prototype,"length",{get:function(){return this.size()}}),t.prototype.size=function(){return this._head===this._tail?0:this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.unshift=function(e){if(0===arguments.length)return this.size();var t=this._list.length;return this._head=this._head-1+t&this._capacityMask,this._list[this._head]=e,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.pop(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.shift=function(){var e=this._head;if(e!==this._tail){var t=this._list[e];return this._list[e]=void 0,this._head=e+1&this._capacityMask,e<2&&this._tail>1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},t.prototype.push=function(e){if(0===arguments.length)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head<this._tail?this._tail-this._head:this._capacityMask+1-(this._head-this._tail)},t.prototype.pop=function(){var e=this._tail;if(e!==this._head){var t=this._list.length;this._tail=e-1+t&this._capacityMask;var r=this._list[this._tail];return this._list[this._tail]=void 0,this._head<2&&e>1e4&&e<=t>>>2&&this._shrinkArray(),r}},t.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var r=this.size(),n=this._list.length;if(!(t>=r||t<-r)){t<0&&(t+=r),t=this._head+t&this._capacityMask;var i,s=this._list[t];if(e<r/2){for(i=e;i>0;i--)this._list[t]=this._list[t=t-1+n&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(i=r-1-e;i>0;i--)this._list[t]=this._list[t=t+1+n&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+n&this._capacityMask}return s}}},t.prototype.remove=function(e,t){var r,n=e,i=t;if(n===(0|n)&&this._head!==this._tail){var s=this.size(),o=this._list.length;if(!(n>=s||n<-s||t<1)){if(n<0&&(n+=s),1===t||!t)return(r=new Array(1))[0]=this.removeOne(n),r;if(0===n&&n+t>=s)return r=this.toArray(),this.clear(),r;var a;for(n+t>s&&(t=s-n),r=new Array(t),a=0;a<t;a++)r[a]=this._list[this._head+n+a&this._capacityMask];if(n=this._head+n&this._capacityMask,e+t===s){for(this._tail=this._tail-t+o&this._capacityMask,a=t;a>0;a--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(0===e){for(this._head=this._head+t+o&this._capacityMask,a=t-1;a>0;a--)this._list[n=n+1+o&this._capacityMask]=void 0;return r}if(n<s/2){for(this._head=this._head+e+t+o&this._capacityMask,a=e;a>0;a--)this.unshift(this._list[n=n-1+o&this._capacityMask]);for(n=this._head-1+o&this._capacityMask;i>0;)this._list[n=n-1+o&this._capacityMask]=void 0,i--;e<0&&(this._tail=n)}else{for(this._tail=n,n=n+t+o&this._capacityMask,a=s-(t+e);a>0;a--)this.push(this._list[n++]);for(n=this._tail;i>0;)this._list[n=n+1+o&this._capacityMask]=void 0,i--}return this._head<2&&this._tail>1e4&&this._tail<=o>>>2&&this._shrinkArray(),r}}},t.prototype.splice=function(e,t){var r=e;if(r===(0|r)){var n=this.size();if(r<0&&(r+=n),!(r>n)){if(arguments.length>2){var i,s,o,a=arguments.length,c=this._list.length,u=2;if(!n||r<n/2){for(s=new Array(r),i=0;i<r;i++)s[i]=this._list[this._head+i&this._capacityMask];for(0===t?(o=[],r>0&&(this._head=this._head+r+c&this._capacityMask)):(o=this.remove(r,t),this._head=this._head+r+c&this._capacityMask);a>u;)this.unshift(arguments[--a]);for(i=r;i>0;i--)this.unshift(s[i-1])}else{var l=(s=new Array(n-(r+t))).length;for(i=0;i<l;i++)s[i]=this._list[this._head+r+t+i&this._capacityMask];for(0===t?(o=[],r!=n&&(this._tail=this._head+r+c&this._capacityMask)):(o=this.remove(r,t),this._tail=this._tail-l+c&this._capacityMask);u<a;)this.push(arguments[u++]);for(i=0;i<l;i++)this.push(s[i])}return o}return this.remove(r,t)}}},t.prototype.clear=function(){this._list=new Array(this._list.length),this._head=0,this._tail=0},t.prototype.isEmpty=function(){return this._head===this._tail},t.prototype.toArray=function(){return this._copyArray(!1)},t.prototype._fromArray=function(e){var t=e.length,r=this._nextPowerOf2(t);this._list=new Array(r),this._capacityMask=r-1,this._tail=t;for(var n=0;n<t;n++)this._list[n]=e[n]},t.prototype._copyArray=function(e,t){var r=this._list,n=r.length,i=this.length;if((t|=i)==i&&this._head<this._tail)return this._list.slice(this._head,this._tail);var s,o=new Array(t),a=0;if(e||this._head>this._tail){for(s=this._head;s<n;s++)o[a++]=r[s];for(s=0;s<this._tail;s++)o[a++]=r[s]}else for(s=this._head;s<this._tail;s++)o[a++]=r[s];return o},t.prototype._growArray=function(){if(0!=this._head){var e=this._copyArray(!0,this._list.length<<1);this._tail=this._list.length,this._head=0,this._list=e}else this._tail=this._list.length,this._list.length<<=1;this._capacityMask=this._capacityMask<<1|1},t.prototype._shrinkArray=function(){this._list.length>>>=1,this._capacityMask>>>=1},t.prototype._nextPowerOf2=function(e){var t=1<<Math.log(e)/Math.log(2)+1;return Math.max(t,4)},e.exports=t},4823:e=>{"use strict";function t(e,t){for(const r in t)Object.defineProperty(e,r,{value:t[r],enumerable:!0,configurable:!0});return e}e.exports=function(e,r,n){if(!e||"string"===typeof e)throw new TypeError("Please pass an Error to err-code");n||(n={}),"object"===typeof r&&(n=r,r=""),r&&(n.code=r);try{return t(e,n)}catch(i){n.message=e.message,n.stack=e.stack;const r=function(){};r.prototype=Object.create(Object.getPrototypeOf(e));return t(new r,n)}}},2605:(e,t,r)=>{"use strict";const n=r(9020);t.PP=n.EventIterator,n.EventIterator},9020:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class r{constructor(){this.pullQueue=[],this.pushQueue=[],this.eventHandlers={},this.isPaused=!1,this.isStopped=!1}push(e){if(this.isStopped)return;const t={value:e,done:!1};if(this.pullQueue.length){const e=this.pullQueue.shift();e&&e.resolve(t)}else this.pushQueue.push(Promise.resolve(t)),void 0!==this.highWaterMark&&this.pushQueue.length>=this.highWaterMark&&!this.isPaused&&(this.isPaused=!0,this.eventHandlers.highWater?this.eventHandlers.highWater():console&&console.warn(`EventIterator queue reached ${this.pushQueue.length} items`))}stop(){if(!this.isStopped){this.isStopped=!0,this.remove();for(const e of this.pullQueue)e.resolve({value:void 0,done:!0});this.pullQueue.length=0}}fail(e){if(!this.isStopped)if(this.isStopped=!0,this.remove(),this.pullQueue.length){for(const t of this.pullQueue)t.reject(e);this.pullQueue.length=0}else{const t=Promise.reject(e);t.catch((()=>{})),this.pushQueue.push(t)}}remove(){Promise.resolve().then((()=>{this.removeCallback&&this.removeCallback()}))}[Symbol.asyncIterator](){return{next:e=>{const t=this.pushQueue.shift();return t?(void 0!==this.lowWaterMark&&this.pushQueue.length<=this.lowWaterMark&&this.isPaused&&(this.isPaused=!1,this.eventHandlers.lowWater&&this.eventHandlers.lowWater()),t):this.isStopped?Promise.resolve({value:void 0,done:!0}):new Promise(((e,t)=>{this.pullQueue.push({resolve:e,reject:t})}))},return:()=>(this.isStopped=!0,this.pushQueue.length=0,this.remove(),Promise.resolve({value:void 0,done:!0}))}}}class n{constructor(e){let{highWaterMark:t=100,lowWaterMark:n=1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new r;i.highWaterMark=t,i.lowWaterMark=n,i.removeCallback=e({push:e=>i.push(e),stop:()=>i.stop(),fail:e=>i.fail(e),on:(e,t)=>{i.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>i[Symbol.asyncIterator](),Object.freeze(this)}}t.EventIterator=n,t.default=n},7283:e=>{"use strict";var t=Object.prototype.hasOwnProperty,r="~";function n(){}function i(e,t,r){this.fn=e,this.context=t,this.once=r||!1}function s(e,t,n,s,o){if("function"!==typeof n)throw new TypeError("The listener must be a function");var a=new i(n,s||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=a,e._eventsCount++),e}function o(e,t){0===--e._eventsCount?e._events=new n:delete e._events[t]}function a(){this._events=new n,this._eventsCount=0}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(r=!1)),a.prototype.eventNames=function(){var e,n,i=[];if(0===this._eventsCount)return i;for(n in e=this._events)t.call(e,n)&&i.push(r?n.slice(1):n);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,s=n.length,o=new Array(s);i<s;i++)o[i]=n[i].fn;return o},a.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},a.prototype.emit=function(e,t,n,i,s,o){var a=r?r+e:e;if(!this._events[a])return!1;var c,u,l=this._events[a],h=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),h){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,i),!0;case 5:return l.fn.call(l.context,t,n,i,s),!0;case 6:return l.fn.call(l.context,t,n,i,s,o),!0}for(u=1,c=new Array(h-1);u<h;u++)c[u-1]=arguments[u];l.fn.apply(l.context,c)}else{var d,f=l.length;for(u=0;u<f;u++)switch(l[u].once&&this.removeListener(e,l[u].fn,void 0,!0),h){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,t);break;case 3:l[u].fn.call(l[u].context,t,n);break;case 4:l[u].fn.call(l[u].context,t,n,i);break;default:if(!c)for(d=1,c=new Array(h-1);d<h;d++)c[d-1]=arguments[d];l[u].fn.apply(l[u].context,c)}}return!0},a.prototype.on=function(e,t,r){return s(this,e,t,r,!1)},a.prototype.once=function(e,t,r){return s(this,e,t,r,!0)},a.prototype.removeListener=function(e,t,n,i){var s=r?r+e:e;if(!this._events[s])return this;if(!t)return o(this,s),this;var a=this._events[s];if(a.fn)a.fn!==t||i&&!a.once||n&&a.context!==n||o(this,s);else{for(var c=0,u=[],l=a.length;c<l;c++)(a[c].fn!==t||i&&!a[c].once||n&&a[c].context!==n)&&u.push(a[c]);u.length?this._events[s]=1===u.length?u[0]:u:o(this,s)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&o(this,t)):(this._events=new n,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=r,a.EventEmitter=a,e.exports=a},101:e=>{e.exports=function(e){if(!e)throw Error("hashlru must have a max value, of type number, greater than 0");var t=0,r=Object.create(null),n=Object.create(null);function i(i,s){r[i]=s,++t>=e&&(t=0,n=r,r=Object.create(null))}return{has:function(e){return void 0!==r[e]||void 0!==n[e]},remove:function(e){void 0!==r[e]&&(r[e]=void 0),void 0!==n[e]&&(n[e]=void 0)},get:function(e){var t=r[e];return void 0!==t?t:void 0!==(t=n[e])?(i(e,t),t):void 0},set:function(e,t){void 0!==r[e]?r[e]=t:i(e,t)},clear:function(){r=Object.create(null),n=Object.create(null)}}}},5411:(e,t,r)=>{var n;!function(){"use strict";var t="object"===typeof window?window:{};!t.HI_BASE32_NO_NODE_JS&&"object"===typeof process&&process.versions&&process.versions.node&&(t=r.g);var i=!t.HI_BASE32_NO_COMMON_JS&&e.exports,s=r.amdO,o="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567".split(""),a={A:0,B:1,C:2,D:3,E:4,F:5,G:6,H:7,I:8,J:9,K:10,L:11,M:12,N:13,O:14,P:15,Q:16,R:17,S:18,T:19,U:20,V:21,W:22,X:23,Y:24,Z:25,2:26,3:27,4:28,5:29,6:30,7:31},c=[0,0,0,0,0,0,0,0],u=function(e,t){t.length>10&&(t="..."+t.substr(-10));var r=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+e+" bytes: "+t+" <-");throw r.position=e,r},l=function(e){if(""===e)return[];if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");for(var t,r,n,i,s,o,c,u,l=[],h=0,d=(e=e.replace(/=/g,"")).length,f=0,p=d>>3<<3;f<p;)t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],s=a[e.charAt(f++)],o=a[e.charAt(f++)],c=a[e.charAt(f++)],u=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|s>>>1),l[h++]=255&(s<<7|o<<2|c>>>3),l[h++]=255&(c<<5|u);var g=d-p;return 2===g?(t=a[e.charAt(f++)],r=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2)):4===g?(t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4)):5===g?(t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],s=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|s>>>1)):7===g&&(t=a[e.charAt(f++)],r=a[e.charAt(f++)],n=a[e.charAt(f++)],i=a[e.charAt(f++)],s=a[e.charAt(f++)],o=a[e.charAt(f++)],c=a[e.charAt(f++)],l[h++]=255&(t<<3|r>>>2),l[h++]=255&(r<<6|n<<1|i>>>4),l[h++]=255&(i<<4|s>>>1),l[h++]=255&(s<<7|o<<2|c>>>3)),l},h=function(e,t){if(!t)return function(e){for(var t,r,n="",i=e.length,s=0,o=0;s<i;)if((t=e[s++])<=127)n+=String.fromCharCode(t);else{t>191&&t<=223?(r=31&t,o=1):t<=239?(r=15&t,o=2):t<=247?(r=7&t,o=3):u(s,n);for(var a=0;a<o;++a)((t=e[s++])<128||t>191)&&u(s,n),r<<=6,r+=63&t;r>=55296&&r<=57343&&u(s,n),r>1114111&&u(s,n),r<=65535?n+=String.fromCharCode(r):(r-=65536,n+=String.fromCharCode(55296+(r>>10)),n+=String.fromCharCode(56320+(1023&r)))}return n}(l(e));if(""===e)return"";if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");var r,n,i,s,o,c,h,d,f="",p=e.indexOf("=");-1===p&&(p=e.length);for(var g=0,b=p>>3<<3;g<b;)r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],s=a[e.charAt(g++)],o=a[e.charAt(g++)],c=a[e.charAt(g++)],h=a[e.charAt(g++)],d=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|s>>>4))+String.fromCharCode(255&(s<<4|o>>>1))+String.fromCharCode(255&(o<<7|c<<2|h>>>3))+String.fromCharCode(255&(h<<5|d));var y=p-b;return 2===y?(r=a[e.charAt(g++)],n=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))):4===y?(r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],s=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|s>>>4))):5===y?(r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],s=a[e.charAt(g++)],o=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|s>>>4))+String.fromCharCode(255&(s<<4|o>>>1))):7===y&&(r=a[e.charAt(g++)],n=a[e.charAt(g++)],i=a[e.charAt(g++)],s=a[e.charAt(g++)],o=a[e.charAt(g++)],c=a[e.charAt(g++)],h=a[e.charAt(g++)],f+=String.fromCharCode(255&(r<<3|n>>>2))+String.fromCharCode(255&(n<<6|i<<1|s>>>4))+String.fromCharCode(255&(s<<4|o>>>1))+String.fromCharCode(255&(o<<7|c<<2|h>>>3))),f},d={encode:function(e,t){var r="string"!==typeof e;return r&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),r?function(e){for(var t,r,n,i,s,a="",c=e.length,u=0,l=5*parseInt(c/5);u<l;)t=e[u++],r=e[u++],n=e[u++],i=e[u++],s=e[u++],a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[31&(n<<1|i>>>7)]+o[i>>>2&31]+o[31&(i<<3|s>>>5)]+o[31&s];var h=c-l;return 1===h?(t=e[u],a+=o[t>>>3]+o[t<<2&31]+"======"):2===h?(t=e[u++],r=e[u],a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[r<<4&31]+"===="):3===h?(t=e[u++],r=e[u++],n=e[u],a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[n<<1&31]+"==="):4===h&&(t=e[u++],r=e[u++],n=e[u++],i=e[u],a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[31&(n<<1|i>>>7)]+o[i>>>2&31]+o[i<<3&31]+"="),a}(e):t?function(e){for(var t,r,n,i,s,a="",c=e.length,u=0,l=5*parseInt(c/5);u<l;)t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u++),i=e.charCodeAt(u++),s=e.charCodeAt(u++),a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[31&(n<<1|i>>>7)]+o[i>>>2&31]+o[31&(i<<3|s>>>5)]+o[31&s];var h=c-l;return 1===h?(t=e.charCodeAt(u),a+=o[t>>>3]+o[t<<2&31]+"======"):2===h?(t=e.charCodeAt(u++),r=e.charCodeAt(u),a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[r<<4&31]+"===="):3===h?(t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u),a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[n<<1&31]+"==="):4===h&&(t=e.charCodeAt(u++),r=e.charCodeAt(u++),n=e.charCodeAt(u++),i=e.charCodeAt(u),a+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[31&(n<<1|i>>>7)]+o[i>>>2&31]+o[i<<3&31]+"="),a}(e):function(e){var t,r,n,i,s,a,u,l=!1,h="",d=0,f=0,p=e.length;if(""===e)return h;do{for(c[0]=c[5],c[1]=c[6],c[2]=c[7],u=f;d<p&&u<5;++d)(a=e.charCodeAt(d))<128?c[u++]=a:a<2048?(c[u++]=192|a>>6,c[u++]=128|63&a):a<55296||a>=57344?(c[u++]=224|a>>12,c[u++]=128|a>>6&63,c[u++]=128|63&a):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++d)),c[u++]=240|a>>18,c[u++]=128|a>>12&63,c[u++]=128|a>>6&63,c[u++]=128|63&a);f=u-5,d===p&&++d,d>p&&u<6&&(l=!0),t=c[0],u>4?(r=c[1],n=c[2],i=c[3],s=c[4],h+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[31&(n<<1|i>>>7)]+o[i>>>2&31]+o[31&(i<<3|s>>>5)]+o[31&s]):1===u?h+=o[t>>>3]+o[t<<2&31]+"======":2===u?(r=c[1],h+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[r<<4&31]+"===="):3===u?(r=c[1],n=c[2],h+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[n<<1&31]+"==="):(r=c[1],n=c[2],i=c[3],h+=o[t>>>3]+o[31&(t<<2|r>>>6)]+o[r>>>1&31]+o[31&(r<<4|n>>>4)]+o[31&(n<<1|i>>>7)]+o[i>>>2&31]+o[i<<3&31]+"=")}while(!l);return h}(e)},decode:h};h.asBytes=l,i?e.exports=d:(t.base32=d,s&&(void 0===(n=function(){return d}.call(d,r,d,e))||(e.exports=n)))}()},4053:e=>{e.exports=function(){return"undefined"!==typeof window&&"object"===typeof window.process&&"renderer"===window.process.type||(!("undefined"===typeof process||"object"!==typeof process.versions||!process.versions.electron)||"object"===typeof navigator&&"string"===typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0)}},8313:e=>{"use strict";e.exports=e=>{if("[object Object]"!==Object.prototype.toString.call(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}},2161:(e,t,r)=>{var n;!function(){"use strict";var i="input is invalid type",s="object"===typeof window,o=s?window:{};o.JS_SHA3_NO_WINDOW&&(s=!1);var a=!s&&"object"===typeof self;!o.JS_SHA3_NO_NODE_JS&&"object"===typeof process&&process.versions&&process.versions.node?o=r.g:a&&(o=self);for(var c=!o.JS_SHA3_NO_COMMON_JS&&e.exports,u=r.amdO,l=!o.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!==typeof ArrayBuffer,h="0123456789abcdef".split(""),d=[4,1024,262144,67108864],f=[0,8,16,24],p=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],g=[224,256,384,512],b=[128,256],y=["hex","buffer","arrayBuffer","array","digest"],m={128:168,256:136},w=o.JS_SHA3_NO_NODE_JS||!Array.isArray?function(e){return"[object Array]"===Object.prototype.toString.call(e)}:Array.isArray,v=!l||!o.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(e){return"object"===typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer},_=function(e){var t=typeof e;if("string"===t)return[e,!0];if("object"!==t||null===e)throw new Error(i);if(l&&e.constructor===ArrayBuffer)return[new Uint8Array(e),!1];if(!w(e)&&!v(e))throw new Error(i);return[e,!1]},E=function(e){return 0===_(e)[0].length},S=function(e){for(var t=[],r=0;r<e.length;++r)t[r]=e[r];return t},A=function(e,t,r){return function(n){return new q(e,t,e).update(n)[r]()}},k=function(e,t,r){return function(n,i){return new q(e,t,i).update(n)[r]()}},x=function(e,t,r){return function(t,n,i,s){return P["cshake"+e].update(t,n,i,s)[r]()}},I=function(e,t,r){return function(t,n,i,s){return P["kmac"+e].update(t,n,i,s)[r]()}},C=function(e,t,r,n){for(var i=0;i<y.length;++i){var s=y[i];e[s]=t(r,n,s)}return e},T=function(e,t){var r=A(e,t,"hex");return r.create=function(){return new q(e,t,e)},r.update=function(e){return r.create().update(e)},C(r,A,e,t)},R=[{name:"keccak",padding:[1,256,65536,16777216],bits:g,createMethod:T},{name:"sha3",padding:[6,1536,393216,100663296],bits:g,createMethod:T},{name:"shake",padding:[31,7936,2031616,520093696],bits:b,createMethod:function(e,t){var r=k(e,t,"hex");return r.create=function(r){return new q(e,t,r)},r.update=function(e,t){return r.create(t).update(e)},C(r,k,e,t)}},{name:"cshake",padding:d,bits:b,createMethod:function(e,t){var r=m[e],n=x(e,0,"hex");return n.create=function(n,i,s){return E(i)&&E(s)?P["shake"+e].create(n):new q(e,t,n).bytepad([i,s],r)},n.update=function(e,t,r,i){return n.create(t,r,i).update(e)},C(n,x,e,t)}},{name:"kmac",padding:d,bits:b,createMethod:function(e,t){var r=m[e],n=I(e,0,"hex");return n.create=function(n,i,s){return new K(e,t,i).bytepad(["KMAC",s],r).bytepad([n],r)},n.update=function(e,t,r,i){return n.create(e,r,i).update(t)},C(n,I,e,t)}}],P={},D=[],N=0;N<R.length;++N)for(var B=R[N],U=B.bits,L=0;L<U.length;++L){var M=B.name+"_"+U[L];if(D.push(M),P[M]=B.createMethod(U[L],B.padding),"sha3"!==B.name){var O=B.name+U[L];D.push(O),P[O]=P[M]}}function q(e,t,r){this.blocks=[],this.s=[],this.padding=t,this.outputBits=r,this.reset=!0,this.finalized=!1,this.block=0,this.start=0,this.blockCount=1600-(e<<1)>>5,this.byteCount=this.blockCount<<2,this.outputBlocks=r>>5,this.extraBytes=(31&r)>>3;for(var n=0;n<50;++n)this.s[n]=0}function K(e,t,r){q.call(this,e,t,r)}q.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t=_(e);e=t[0];for(var r,n,i=t[1],s=this.blocks,o=this.byteCount,a=e.length,c=this.blockCount,u=0,l=this.s;u<a;){if(this.reset)for(this.reset=!1,s[0]=this.block,r=1;r<c+1;++r)s[r]=0;if(i)for(r=this.start;u<a&&r<o;++u)(n=e.charCodeAt(u))<128?s[r>>2]|=n<<f[3&r++]:n<2048?(s[r>>2]|=(192|n>>6)<<f[3&r++],s[r>>2]|=(128|63&n)<<f[3&r++]):n<55296||n>=57344?(s[r>>2]|=(224|n>>12)<<f[3&r++],s[r>>2]|=(128|n>>6&63)<<f[3&r++],s[r>>2]|=(128|63&n)<<f[3&r++]):(n=65536+((1023&n)<<10|1023&e.charCodeAt(++u)),s[r>>2]|=(240|n>>18)<<f[3&r++],s[r>>2]|=(128|n>>12&63)<<f[3&r++],s[r>>2]|=(128|n>>6&63)<<f[3&r++],s[r>>2]|=(128|63&n)<<f[3&r++]);else for(r=this.start;u<a&&r<o;++u)s[r>>2]|=e[u]<<f[3&r++];if(this.lastByteIndex=r,r>=o){for(this.start=r-o,this.block=s[c],r=0;r<c;++r)l[r]^=s[r];F(l),this.reset=!0}else this.start=r}return this},q.prototype.encode=function(e,t){var r=255&e,n=1,i=[r];for(r=255&(e>>=8);r>0;)i.unshift(r),r=255&(e>>=8),++n;return t?i.push(n):i.unshift(n),this.update(i),i.length},q.prototype.encodeString=function(e){var t=_(e);e=t[0];var r=t[1],n=0,i=e.length;if(r)for(var s=0;s<e.length;++s){var o=e.charCodeAt(s);o<128?n+=1:o<2048?n+=2:o<55296||o>=57344?n+=3:(o=65536+((1023&o)<<10|1023&e.charCodeAt(++s)),n+=4)}else n=i;return n+=this.encode(8*n),this.update(e),n},q.prototype.bytepad=function(e,t){for(var r=this.encode(t),n=0;n<e.length;++n)r+=this.encodeString(e[n]);var i=(t-r%t)%t,s=[];return s.length=i,this.update(s),this},q.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,r=this.blockCount,n=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[r],t=1;t<r+1;++t)e[t]=0;for(e[r-1]|=2147483648,t=0;t<r;++t)n[t]^=e[t];F(n)}},q.prototype.toString=q.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a="";o<n;){for(s=0;s<t&&o<n;++s,++o)e=r[s],a+=h[e>>4&15]+h[15&e]+h[e>>12&15]+h[e>>8&15]+h[e>>20&15]+h[e>>16&15]+h[e>>28&15]+h[e>>24&15];o%t===0&&(r=S(r),F(r),s=0)}return i&&(e=r[s],a+=h[e>>4&15]+h[15&e],i>1&&(a+=h[e>>12&15]+h[e>>8&15]),i>2&&(a+=h[e>>20&15]+h[e>>16&15])),a},q.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,r=this.s,n=this.outputBlocks,i=this.extraBytes,s=0,o=0,a=this.outputBits>>3;e=i?new ArrayBuffer(n+1<<2):new ArrayBuffer(a);for(var c=new Uint32Array(e);o<n;){for(s=0;s<t&&o<n;++s,++o)c[o]=r[s];o%t===0&&(r=S(r),F(r))}return i&&(c[o]=r[s],e=e.slice(0,a)),e},q.prototype.buffer=q.prototype.arrayBuffer,q.prototype.digest=q.prototype.array=function(){this.finalize();for(var e,t,r=this.blockCount,n=this.s,i=this.outputBlocks,s=this.extraBytes,o=0,a=0,c=[];a<i;){for(o=0;o<r&&a<i;++o,++a)e=a<<2,t=n[o],c[e]=255&t,c[e+1]=t>>8&255,c[e+2]=t>>16&255,c[e+3]=t>>24&255;a%r===0&&(n=S(n),F(n))}return s&&(e=a<<2,t=n[o],c[e]=255&t,s>1&&(c[e+1]=t>>8&255),s>2&&(c[e+2]=t>>16&255)),c},K.prototype=new q,K.prototype.finalize=function(){return this.encode(this.outputBits,!0),q.prototype.finalize.call(this)};var F=function(e){var t,r,n,i,s,o,a,c,u,l,h,d,f,g,b,y,m,w,v,_,E,S,A,k,x,I,C,T,R,P,D,N,B,U,L,M,O,q,K,F,V,z,$,H,j,G,W,Y,Q,J,X,Z,ee,te,re,ne,ie,se,oe,ae,ce,ue,le;for(n=0;n<48;n+=2)i=e[0]^e[10]^e[20]^e[30]^e[40],s=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],c=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],l=e[6]^e[16]^e[26]^e[36]^e[46],h=e[7]^e[17]^e[27]^e[37]^e[47],t=(d=e[8]^e[18]^e[28]^e[38]^e[48])^(o<<1|a>>>31),r=(f=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|o>>>31),e[0]^=t,e[1]^=r,e[10]^=t,e[11]^=r,e[20]^=t,e[21]^=r,e[30]^=t,e[31]^=r,e[40]^=t,e[41]^=r,t=i^(c<<1|u>>>31),r=s^(u<<1|c>>>31),e[2]^=t,e[3]^=r,e[12]^=t,e[13]^=r,e[22]^=t,e[23]^=r,e[32]^=t,e[33]^=r,e[42]^=t,e[43]^=r,t=o^(l<<1|h>>>31),r=a^(h<<1|l>>>31),e[4]^=t,e[5]^=r,e[14]^=t,e[15]^=r,e[24]^=t,e[25]^=r,e[34]^=t,e[35]^=r,e[44]^=t,e[45]^=r,t=c^(d<<1|f>>>31),r=u^(f<<1|d>>>31),e[6]^=t,e[7]^=r,e[16]^=t,e[17]^=r,e[26]^=t,e[27]^=r,e[36]^=t,e[37]^=r,e[46]^=t,e[47]^=r,t=l^(i<<1|s>>>31),r=h^(s<<1|i>>>31),e[8]^=t,e[9]^=r,e[18]^=t,e[19]^=r,e[28]^=t,e[29]^=r,e[38]^=t,e[39]^=r,e[48]^=t,e[49]^=r,g=e[0],b=e[1],G=e[11]<<4|e[10]>>>28,W=e[10]<<4|e[11]>>>28,T=e[20]<<3|e[21]>>>29,R=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,ce=e[30]<<9|e[31]>>>23,z=e[40]<<18|e[41]>>>14,$=e[41]<<18|e[40]>>>14,U=e[2]<<1|e[3]>>>31,L=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,m=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,Q=e[23]<<10|e[22]>>>22,P=e[33]<<13|e[32]>>>19,D=e[32]<<13|e[33]>>>19,ue=e[42]<<2|e[43]>>>30,le=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,re=e[4]<<30|e[5]>>>2,M=e[14]<<6|e[15]>>>26,O=e[15]<<6|e[14]>>>26,w=e[25]<<11|e[24]>>>21,v=e[24]<<11|e[25]>>>21,J=e[34]<<15|e[35]>>>17,X=e[35]<<15|e[34]>>>17,N=e[45]<<29|e[44]>>>3,B=e[44]<<29|e[45]>>>3,k=e[6]<<28|e[7]>>>4,x=e[7]<<28|e[6]>>>4,ne=e[17]<<23|e[16]>>>9,ie=e[16]<<23|e[17]>>>9,q=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,_=e[36]<<21|e[37]>>>11,E=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,H=e[8]<<27|e[9]>>>5,j=e[9]<<27|e[8]>>>5,I=e[18]<<20|e[19]>>>12,C=e[19]<<20|e[18]>>>12,se=e[29]<<7|e[28]>>>25,oe=e[28]<<7|e[29]>>>25,F=e[38]<<8|e[39]>>>24,V=e[39]<<8|e[38]>>>24,S=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=g^~y&w,e[1]=b^~m&v,e[10]=k^~I&T,e[11]=x^~C&R,e[20]=U^~M&q,e[21]=L^~O&K,e[30]=H^~G&Y,e[31]=j^~W&Q,e[40]=te^~ne&se,e[41]=re^~ie&oe,e[2]=y^~w&_,e[3]=m^~v&E,e[12]=I^~T&P,e[13]=C^~R&D,e[22]=M^~q&F,e[23]=O^~K&V,e[32]=G^~Y&J,e[33]=W^~Q&X,e[42]=ne^~se&ae,e[43]=ie^~oe&ce,e[4]=w^~_&S,e[5]=v^~E&A,e[14]=T^~P&N,e[15]=R^~D&B,e[24]=q^~F&z,e[25]=K^~V&$,e[34]=Y^~J&Z,e[35]=Q^~X&ee,e[44]=se^~ae&ue,e[45]=oe^~ce&le,e[6]=_^~S&g,e[7]=E^~A&b,e[16]=P^~N&k,e[17]=D^~B&x,e[26]=F^~z&U,e[27]=V^~$&L,e[36]=J^~Z&H,e[37]=X^~ee&j,e[46]=ae^~ue&te,e[47]=ce^~le&re,e[8]=S^~g&y,e[9]=A^~b&m,e[18]=N^~k&I,e[19]=B^~x&C,e[28]=z^~U&M,e[29]=$^~L&O,e[38]=Z^~H&G,e[39]=ee^~j&W,e[48]=ue^~te&ne,e[49]=le^~re&ie,e[0]^=p[n],e[1]^=p[n+1]};if(c)e.exports=P;else{for(N=0;N<D.length;++N)o[D[N]]=P[D[N]];u&&(void 0===(n=function(){return P}.call(t,r,t,e))||(e.exports=n))}}()},8355:function(e,t,r){"use strict";const n=r(8313),{hasOwnProperty:i}=Object.prototype,{propertyIsEnumerable:s}=Object,o=(e,t,r)=>Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0}),a=this,c={concatArrays:!1,ignoreUndefined:!1},u=e=>{const t=[];for(const r in e)i.call(e,r)&&t.push(r);if(Object.getOwnPropertySymbols){const r=Object.getOwnPropertySymbols(e);for(const n of r)s.call(e,n)&&t.push(n)}return t};function l(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return u(e).forEach((r=>{o(t,r,l(e[r]))})),t}(e):n(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return u(e).forEach((r=>{o(t,r,l(e[r]))})),t}(e):e}const h=(e,t,r,n)=>(r.forEach((r=>{"undefined"===typeof t[r]&&n.ignoreUndefined||(r in e&&e[r]!==Object.getPrototypeOf(e)?o(e,r,f(e[r],t[r],n)):o(e,r,l(t[r])))})),e),d=(e,t,r)=>{let n=e.slice(0,0),s=0;return[e,t].forEach((t=>{const a=[];for(let r=0;r<t.length;r++)i.call(t,r)&&(a.push(String(r)),o(n,s++,t===e?t[r]:l(t[r])));n=h(n,t,u(t).filter((e=>!a.includes(e))),r)})),n};function f(e,t,r){return r.concatArrays&&Array.isArray(e)&&Array.isArray(t)?d(e,t,r):n(t)&&n(e)?h(e,t,u(t),r):l(t)}e.exports=function(){const e=f(l(c),this!==a&&this||{},c);let t={_:{}};for(var r=arguments.length,i=new Array(r),s=0;s<r;s++)i[s]=arguments[s];for(const o of i)if(void 0!==o){if(!n(o))throw new TypeError("`"+o+"` is not an Option Object");t=f(t,{_:o},e)}return t._}},7340:e=>{var t=1e3,r=60*t,n=60*r,i=24*n,s=7*i,o=365.25*i;function a(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,c){c=c||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var a=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*i;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return c.long?function(e){var s=Math.abs(e);if(s>=i)return a(e,s,i,"day");if(s>=n)return a(e,s,n,"hour");if(s>=r)return a(e,s,r,"minute");if(s>=t)return a(e,s,t,"second");return e+" ms"}(e):function(e){var s=Math.abs(e);if(s>=i)return Math.round(e/i)+"d";if(s>=n)return Math.round(e/n)+"h";if(s>=r)return Math.round(e/r)+"m";if(s>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},7364:function(e,t){(function(){var e,r,n,i,s,o,a,c;c=function(e){return[(e&255<<24)>>>24,(e&255<<16)>>>16,(65280&e)>>>8,255&e].join(".")},a=function(e){var t,n,i,s,o,a;for(t=[],i=s=0;s<=3&&0!==e.length;i=++s){if(i>0){if("."!==e[0])throw new Error("Invalid IP");e=e.substring(1)}o=(a=r(e))[0],n=a[1],e=e.substring(n),t.push(o)}if(0!==e.length)throw new Error("Invalid IP");switch(t.length){case 1:if(t[0]>4294967295)throw new Error("Invalid IP");return t[0]>>>0;case 2:if(t[0]>255||t[1]>16777215)throw new Error("Invalid IP");return(t[0]<<24|t[1])>>>0;case 3:if(t[0]>255||t[1]>255||t[2]>65535)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2])>>>0;case 4:if(t[0]>255||t[1]>255||t[2]>255||t[3]>255)throw new Error("Invalid IP");return(t[0]<<24|t[1]<<16|t[2]<<8|t[3])>>>0;default:throw new Error("Invalid IP")}},i=(n=function(e){return e.charCodeAt(0)})("0"),o=n("a"),s=n("A"),r=function(e){var t,r,a,c,u;for(c=0,t=10,r="9",a=0,e.length>1&&"0"===e[a]&&("x"===e[a+1]||"X"===e[a+1]?(a+=2,t=16):"0"<=e[a+1]&&e[a+1]<="9"&&(a++,t=8,r="7")),u=a;a<e.length;){if("0"<=e[a]&&e[a]<=r)c=c*t+(n(e[a])-i)>>>0;else{if(16!==t)break;if("a"<=e[a]&&e[a]<="f")c=c*t+(10+n(e[a])-o)>>>0;else{if(!("A"<=e[a]&&e[a]<="F"))break;c=c*t+(10+n(e[a])-s)>>>0}}if(c>4294967295)throw new Error("too large");a++}if(a===u)throw new Error("empty octet");return[c,a]},e=function(){function e(e,t){var r,n,i;if("string"!==typeof e)throw new Error("Missing `net' parameter");if(t||(i=e.split("/",2),e=i[0],t=i[1]),t||(t=32),"string"===typeof t&&t.indexOf(".")>-1){try{this.maskLong=a(t)}catch(s){throw s,new Error("Invalid mask: "+t)}for(r=n=32;n>=0;r=--n)if(this.maskLong===4294967295<<32-r>>>0){this.bitmask=r;break}}else{if(!t&&0!==t)throw new Error("Invalid mask: empty");this.bitmask=parseInt(t,10),this.maskLong=0,this.bitmask>0&&(this.maskLong=4294967295<<32-this.bitmask>>>0)}try{this.netLong=(a(e)&this.maskLong)>>>0}catch(s){throw s,new Error("Invalid net address: "+e)}if(!(this.bitmask<=32))throw new Error("Invalid mask for ip4: "+t);this.size=Math.pow(2,32-this.bitmask),this.base=c(this.netLong),this.mask=c(this.maskLong),this.hostmask=c(~this.maskLong),this.first=this.bitmask<=30?c(this.netLong+1):this.base,this.last=this.bitmask<=30?c(this.netLong+this.size-2):c(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?c(this.netLong+this.size-1):void 0}return e.prototype.contains=function(t){return"string"===typeof t&&(t.indexOf("/")>0||4!==t.split(".").length)&&(t=new e(t)),t instanceof e?this.contains(t.base)&&this.contains(t.broadcast||t.last):(a(t)&this.maskLong)>>>0===(this.netLong&this.maskLong)>>>0},e.prototype.next=function(t){return null==t&&(t=1),new e(c(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,r,n;for(n=a(this.first),r=a(this.last),t=0;n<=r;)e(c(n),n,t),t++,n++},e.prototype.toString=function(){return this.base+"/"+this.bitmask},e}(),t.ip2long=a,t.long2ip=c,t.Netmask=e}).call(this)},9353:(e,t,r)=>{var n=r(45);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.aes.Algorithm(e,t)}))}r(9151),r(1655),r(3900),e.exports=n.aes=n.aes||{},n.aes.startEncrypting=function(e,t,r,n){var i=g({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},n.aes.createEncryptionCipher=function(e,t){return g({key:e,output:null,decrypt:!1,mode:t})},n.aes.startDecrypting=function(e,t,r,n){var i=g({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},n.aes.createDecryptionCipher=function(e,t){return g({key:e,output:null,decrypt:!0,mode:t})},n.aes.Algorithm=function(e,t){l||d();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return p(r._w,e,t,!1)},decrypt:function(e,t){return p(r._w,e,t,!0)}}}),r._init=!1},n.aes.Algorithm.prototype.initialize=function(e){if(!this._init){var t,r=e.key;if("string"!==typeof r||16!==r.length&&24!==r.length&&32!==r.length){if(n.util.isArray(r)&&(16===r.length||24===r.length||32===r.length)){t=r,r=n.util.createBuffer();for(var i=0;i<t.length;++i)r.putByte(t[i])}}else r=n.util.createBuffer(r);if(!n.util.isArray(r)){t=r,r=[];var s=t.length();if(16===s||24===s||32===s){s>>>=2;for(i=0;i<s;++i)r.push(t.getInt32())}}if(!n.util.isArray(r)||4!==r.length&&6!==r.length&&8!==r.length)throw new Error("Invalid key parameter.");var o=this.mode.name,a=-1!==["CFB","OFB","CTR","GCM"].indexOf(o);this._w=f(r,e.decrypt&&!a),this._init=!0}},n.aes._expandKey=function(e,t){return l||d(),f(e,t)},n.aes._updateBlock=p,i("AES-ECB",n.cipher.modes.ecb),i("AES-CBC",n.cipher.modes.cbc),i("AES-CFB",n.cipher.modes.cfb),i("AES-OFB",n.cipher.modes.ofb),i("AES-CTR",n.cipher.modes.ctr),i("AES-GCM",n.cipher.modes.gcm);var s,o,a,c,u,l=!1,h=4;function d(){l=!0,a=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;s=new Array(256),o=new Array(256),c=new Array(4),u=new Array(4);for(t=0;t<4;++t)c[t]=new Array(256),u[t]=new Array(256);var r,n,i,h,d,f,p,g=0,b=0;for(t=0;t<256;++t){h=(h=b^b<<1^b<<2^b<<3^b<<4)>>8^255&h^99,s[g]=h,o[h]=g,f=(d=e[h])<<24^h<<16^h<<8^h^d,p=((r=e[g])^(n=e[r])^(i=e[n]))<<24^(g^i)<<16^(g^n^i)<<8^g^r^i;for(var y=0;y<4;++y)c[y][g]=f,u[y][h]=p,f=f<<24|f>>>8,p=p<<24|p>>>8;0===g?g=b=1:(g=r^e[e[e[r^i]]],b^=e[e[b]])}}function f(e,t){for(var r,n=e.slice(0),i=1,o=n.length,c=h*(o+6+1),l=o;l<c;++l)r=n[l-1],l%o===0?(r=s[r>>>16&255]<<24^s[r>>>8&255]<<16^s[255&r]<<8^s[r>>>24]^a[i]<<24,i++):o>6&&l%o===4&&(r=s[r>>>24]<<24^s[r>>>16&255]<<16^s[r>>>8&255]<<8^s[255&r]),n[l]=n[l-o]^r;if(t){for(var d,f=u[0],p=u[1],g=u[2],b=u[3],y=n.slice(0),m=(l=0,(c=n.length)-h);l<c;l+=h,m-=h)if(0===l||l===c-h)y[l]=n[m],y[l+1]=n[m+3],y[l+2]=n[m+2],y[l+3]=n[m+1];else for(var w=0;w<h;++w)d=n[m+w],y[l+(3&-w)]=f[s[d>>>24]]^p[s[d>>>16&255]]^g[s[d>>>8&255]]^b[s[255&d]];n=y}return n}function p(e,t,r,n){var i,a,l,h,d,f,p,g,b,y,m,w,v=e.length/4-1;n?(i=u[0],a=u[1],l=u[2],h=u[3],d=o):(i=c[0],a=c[1],l=c[2],h=c[3],d=s),f=t[0]^e[0],p=t[n?3:1]^e[1],g=t[2]^e[2],b=t[n?1:3]^e[3];for(var _=3,E=1;E<v;++E)y=i[f>>>24]^a[p>>>16&255]^l[g>>>8&255]^h[255&b]^e[++_],m=i[p>>>24]^a[g>>>16&255]^l[b>>>8&255]^h[255&f]^e[++_],w=i[g>>>24]^a[b>>>16&255]^l[f>>>8&255]^h[255&p]^e[++_],b=i[b>>>24]^a[f>>>16&255]^l[p>>>8&255]^h[255&g]^e[++_],f=y,p=m,g=w;r[0]=d[f>>>24]<<24^d[p>>>16&255]<<16^d[g>>>8&255]<<8^d[255&b]^e[++_],r[n?3:1]=d[p>>>24]<<24^d[g>>>16&255]<<16^d[b>>>8&255]<<8^d[255&f]^e[++_],r[2]=d[g>>>24]<<24^d[b>>>16&255]<<16^d[f>>>8&255]<<8^d[255&p]^e[++_],r[n?1:3]=d[b>>>24]<<24^d[f>>>16&255]<<16^d[p>>>8&255]<<8^d[255&g]^e[++_]}function g(e){var t,r="AES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,i.call(t,r)},t}},5465:(e,t,r)=>{var n=r(45);r(3900),r(3225);var i=e.exports=n.asn1=n.asn1||{};function s(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}i.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},i.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},i.create=function(e,t,r,s,o){if(n.util.isArray(s)){for(var a=[],c=0;c<s.length;++c)void 0!==s[c]&&a.push(s[c]);s=a}var u={tagClass:e,type:t,constructed:r,composed:r||n.util.isArray(s),value:s};return o&&"bitStringContents"in o&&(u.bitStringContents=o.bitStringContents,u.original=i.copy(u)),u},i.copy=function(e,t){var r;if(n.util.isArray(e)){r=[];for(var s=0;s<e.length;++s)r.push(i.copy(e[s],t));return r}return"string"===typeof e?e:(r={tagClass:e.tagClass,type:e.type,constructed:e.constructed,composed:e.composed,value:i.copy(e.value,t)},t&&!t.excludeBitStringContents&&(r.bitStringContents=e.bitStringContents),r)},i.equals=function(e,t,r){if(n.util.isArray(e)){if(!n.util.isArray(t))return!1;if(e.length!==t.length)return!1;for(var s=0;s<e.length;++s)if(!i.equals(e[s],t[s]))return!1;return!0}if(typeof e!==typeof t)return!1;if("string"===typeof e)return e===t;var o=e.tagClass===t.tagClass&&e.type===t.type&&e.constructed===t.constructed&&e.composed===t.composed&&i.equals(e.value,t.value);return r&&r.includeBitStringContents&&(o=o&&e.bitStringContents===t.bitStringContents),o},i.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};function o(e,t,r,n){var a;s(e,t,2);var c=e.getByte();t--;var u=192&c,l=31&c;a=e.length();var h,d,f=function(e,t){var r=e.getByte();if(t--,128!==r){var n;if(128&r){var i=127&r;s(e,t,i),n=e.getInt(i<<3)}else n=r;if(n<0)throw new Error("Negative length: "+n);return n}}(e,t);if(t-=a-e.length(),void 0!==f&&f>t){if(n.strict){var p=new Error("Too few bytes to read ASN.1 value.");throw p.available=e.length(),p.remaining=t,p.requested=f,p}f=t}var g=32===(32&c);if(g)if(h=[],void 0===f)for(;;){if(s(e,t,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),t-=2;break}a=e.length(),h.push(o(e,t,r+1,n)),t-=a-e.length()}else for(;f>0;)a=e.length(),h.push(o(e,f,r+1,n)),t-=a-e.length(),f-=a-e.length();if(void 0===h&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&(d=e.bytes(f)),void 0===h&&n.decodeBitStrings&&u===i.Class.UNIVERSAL&&l===i.Type.BITSTRING&&f>1){var b=e.read,y=t,m=0;if(l===i.Type.BITSTRING&&(s(e,t,1),m=e.getByte(),t--),0===m)try{a=e.length();var w=o(e,t,r+1,{strict:!0,decodeBitStrings:!0}),v=a-e.length();t-=v,l==i.Type.BITSTRING&&v++;var _=w.tagClass;v!==f||_!==i.Class.UNIVERSAL&&_!==i.Class.CONTEXT_SPECIFIC||(h=[w])}catch(S){}void 0===h&&(e.read=b,t=y)}if(void 0===h){if(void 0===f){if(n.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");f=t}if(l===i.Type.BMPSTRING)for(h="";f>0;f-=2)s(e,t,2),h+=String.fromCharCode(e.getInt16()),t-=2;else h=e.getBytes(f),t-=f}var E=void 0===d?null:{bitStringContents:d};return i.create(u,l,g,h,E)}i.fromDer=function(e,t){void 0===t&&(t={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),"boolean"===typeof t&&(t={strict:t,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in t||(t.strict=!0),"parseAllBytes"in t||(t.parseAllBytes=!0),"decodeBitStrings"in t||(t.decodeBitStrings=!0),"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.length(),i=o(e,e.length(),0,t);if(t.parseAllBytes&&0!==e.length()){var s=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw s.byteCount=r,s.remaining=e.length(),s}return i},i.toDer=function(e){var t=n.util.createBuffer(),r=e.tagClass|e.type,s=n.util.createBuffer(),o=!1;if("bitStringContents"in e&&(o=!0,e.original&&(o=i.equals(e,e.original))),o)s.putBytes(e.bitStringContents);else if(e.composed){e.constructed?r|=32:s.putByte(0);for(var a=0;a<e.value.length;++a)void 0!==e.value[a]&&s.putBuffer(i.toDer(e.value[a]))}else if(e.type===i.Type.BMPSTRING)for(a=0;a<e.value.length;++a)s.putInt16(e.value.charCodeAt(a));else e.type===i.Type.INTEGER&&e.value.length>1&&(0===e.value.charCodeAt(0)&&0===(128&e.value.charCodeAt(1))||255===e.value.charCodeAt(0)&&128===(128&e.value.charCodeAt(1)))?s.putBytes(e.value.substr(1)):s.putBytes(e.value);if(t.putByte(r),s.length()<=127)t.putByte(127&s.length());else{var c=s.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);t.putByte(128|u.length);for(a=u.length-1;a>=0;--a)t.putByte(u.charCodeAt(a))}return t.putBuffer(s),t},i.oidToDer=function(e){var t,r,i,s,o=e.split("."),a=n.util.createBuffer();a.putByte(40*parseInt(o[0],10)+parseInt(o[1],10));for(var c=2;c<o.length;++c){t=!0,r=[],i=parseInt(o[c],10);do{s=127&i,i>>>=7,t||(s|=128),r.push(s),t=!1}while(i>0);for(var u=r.length-1;u>=0;--u)a.putByte(r[u])}return a},i.derToOid=function(e){var t;"string"===typeof e&&(e=n.util.createBuffer(e));var r=e.getByte();t=Math.floor(r/40)+"."+r%40;for(var i=0;e.length()>0;)i<<=7,128&(r=e.getByte())?i+=127&r:(t+="."+(i+r),i=0);return t},i.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),s=parseInt(e.substr(6,2),10),o=parseInt(e.substr(8,2),10),a=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(a=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(s,o,a,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},i.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=parseInt(e.substr(10,2),10),a=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var h=e.length-5,d=e.charAt(h);"+"!==d&&"-"!==d||(u=60*parseInt(e.substr(h+1,2),10)+parseInt(e.substr(h+4,2),10),u*=6e4,"+"===d&&(u*=-1),l=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(s,o,a,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(s,o,a,c)),t},i.dateToUtcTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},i.dateToGeneralizedTime=function(e){if("string"===typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},i.integerToDer=function(e){var t=n.util.createBuffer();if(e>=-128&&e<128)return t.putSignedInt(e,8);if(e>=-32768&&e<32768)return t.putSignedInt(e,16);if(e>=-8388608&&e<8388608)return t.putSignedInt(e,24);if(e>=-2147483648&&e<2147483648)return t.putSignedInt(e,32);var r=new Error("Integer too large; max is 32-bits.");throw r.integer=e,r},i.derToInteger=function(e){"string"===typeof e&&(e=n.util.createBuffer(e));var t=8*e.length();if(t>32)throw new Error("Integer too large; max is 32-bits.");return e.getSignedInt(t)},i.validate=function(e,t,r,s){var o=!1;if(e.tagClass!==t.tagClass&&"undefined"!==typeof t.tagClass||e.type!==t.type&&"undefined"!==typeof t.type)s&&(e.tagClass!==t.tagClass&&s.push("["+t.name+'] Expected tag class "'+t.tagClass+'", got "'+e.tagClass+'"'),e.type!==t.type&&s.push("["+t.name+'] Expected type "'+t.type+'", got "'+e.type+'"'));else if(e.constructed===t.constructed||"undefined"===typeof t.constructed){if(o=!0,t.value&&n.util.isArray(t.value))for(var a=0,c=0;o&&c<t.value.length;++c)o=t.value[c].optional||!1,e.value[a]&&((o=i.validate(e.value[a],t.value[c],r,s))?++a:t.value[c].optional&&(o=!0)),!o&&s&&s.push("["+t.name+'] Tag class "'+t.tagClass+'", type "'+t.type+'" expected value length "'+t.value.length+'", got "'+e.value.length+'"');if(o&&r)if(t.capture&&(r[t.capture]=e.value),t.captureAsn1&&(r[t.captureAsn1]=e),t.captureBitStringContents&&"bitStringContents"in e&&(r[t.captureBitStringContents]=e.bitStringContents),t.captureBitStringValue&&"bitStringContents"in e)if(e.bitStringContents.length<2)r[t.captureBitStringValue]="";else{if(0!==e.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");r[t.captureBitStringValue]=e.bitStringContents.slice(1)}}else s&&s.push("["+t.name+'] Expected constructed "'+t.constructed+'", got "'+e.constructed+'"');return o};var a=/[^\\u0000-\\u00ff]/;i.prettyPrint=function(e,t,r){var s="";r=r||2,(t=t||0)>0&&(s+="\n");for(var o="",c=0;c<t*r;++c)o+=" ";switch(s+=o+"Tag: ",e.tagClass){case i.Class.UNIVERSAL:s+="Universal:";break;case i.Class.APPLICATION:s+="Application:";break;case i.Class.CONTEXT_SPECIFIC:s+="Context-Specific:";break;case i.Class.PRIVATE:s+="Private:"}if(e.tagClass===i.Class.UNIVERSAL)switch(s+=e.type,e.type){case i.Type.NONE:s+=" (None)";break;case i.Type.BOOLEAN:s+=" (Boolean)";break;case i.Type.INTEGER:s+=" (Integer)";break;case i.Type.BITSTRING:s+=" (Bit string)";break;case i.Type.OCTETSTRING:s+=" (Octet string)";break;case i.Type.NULL:s+=" (Null)";break;case i.Type.OID:s+=" (Object Identifier)";break;case i.Type.ODESC:s+=" (Object Descriptor)";break;case i.Type.EXTERNAL:s+=" (External or Instance of)";break;case i.Type.REAL:s+=" (Real)";break;case i.Type.ENUMERATED:s+=" (Enumerated)";break;case i.Type.EMBEDDED:s+=" (Embedded PDV)";break;case i.Type.UTF8:s+=" (UTF8)";break;case i.Type.ROID:s+=" (Relative Object Identifier)";break;case i.Type.SEQUENCE:s+=" (Sequence)";break;case i.Type.SET:s+=" (Set)";break;case i.Type.PRINTABLESTRING:s+=" (Printable String)";break;case i.Type.IA5String:s+=" (IA5String (ASCII))";break;case i.Type.UTCTIME:s+=" (UTC time)";break;case i.Type.GENERALIZEDTIME:s+=" (Generalized time)";break;case i.Type.BMPSTRING:s+=" (BMP String)"}else s+=e.type;if(s+="\n",s+=o+"Constructed: "+e.constructed+"\n",e.composed){var u=0,l="";for(c=0;c<e.value.length;++c)void 0!==e.value[c]&&(u+=1,l+=i.prettyPrint(e.value[c],t+1,r),c+1<e.value.length&&(l+=","));s+=o+"Sub values: "+u+l}else{if(s+=o+"Value: ",e.type===i.Type.OID){var h=i.derToOid(e.value);s+=h,n.pki&&n.pki.oids&&h in n.pki.oids&&(s+=" ("+n.pki.oids[h]+") ")}if(e.type===i.Type.INTEGER)try{s+=i.derToInteger(e.value)}catch(f){s+="0x"+n.util.bytesToHex(e.value)}else if(e.type===i.Type.BITSTRING){if(e.value.length>1?s+="0x"+n.util.bytesToHex(e.value.slice(1)):s+="(none)",e.value.length>0){var d=e.value.charCodeAt(0);1==d?s+=" (1 unused bit shown)":d>1&&(s+=" ("+d+" unused bits shown)")}}else if(e.type===i.Type.OCTETSTRING)a.test(e.value)||(s+="("+e.value+") "),s+="0x"+n.util.bytesToHex(e.value);else if(e.type===i.Type.UTF8)try{s+=n.util.decodeUtf8(e.value)}catch(p){if("URI malformed"!==p.message)throw p;s+="0x"+n.util.bytesToHex(e.value)+" (malformed UTF8)"}else e.type===i.Type.PRINTABLESTRING||e.type===i.Type.IA5String?s+=e.value:a.test(e.value)?s+="0x"+n.util.bytesToHex(e.value):0===e.value.length?s+="[null]":s+=e.value}return s}},6407:e=>{var t={};e.exports=t;var r={};t.encode=function(e,t,r){if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!==typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,s=t.length,o=t.charAt(0),a=[0];for(i=0;i<e.length;++i){for(var c=0,u=e[i];c<a.length;++c)u+=a[c]<<8,a[c]=u%s,u=u/s|0;for(;u>0;)a.push(u%s),u=u/s|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=o;for(i=a.length-1;i>=0;--i)n+=t[a[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),s=[0];for(r=0;r<e.length();++r){for(var o=0,a=e.at(r);o<s.length;++o)a+=s[o]<<8,s[o]=a%n,a=a/n|0;for(;a>0;)s.push(a%n),a=a/n|0}var c="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)c+=i;for(r=s.length-1;r>=0;--r)c+=t[s[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},t.decode=function(e,t){if("string"!==typeof e)throw new TypeError('"input" must be a string.');if("string"!==typeof t)throw new TypeError('"alphabet" must be a string.');var n=r[t];if(!n){n=r[t]=[];for(var i=0;i<t.length;++i)n[t.charCodeAt(i)]=i}e=e.replace(/\s/g,"");var s=t.length,o=t.charAt(0),a=[0];for(i=0;i<e.length;i++){var c=n[e.charCodeAt(i)];if(void 0===c)return;for(var u=0,l=c;u<a.length;++u)l+=a[u]*s,a[u]=255&l,l>>=8;for(;l>0;)a.push(255&l),l>>=8}for(var h=0;e[h]===o&&h<e.length-1;++h)a.push(0);return"undefined"!==typeof Buffer?Buffer.from(a.reverse()):new Uint8Array(a.reverse())}},9151:(e,t,r)=>{var n=r(45);r(3900),e.exports=n.cipher=n.cipher||{},n.cipher.algorithms=n.cipher.algorithms||{},n.cipher.createCipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!1})},n.cipher.createDecipher=function(e,t){var r=e;if("string"===typeof r&&(r=n.cipher.getAlgorithm(r))&&(r=r()),!r)throw new Error("Unsupported algorithm: "+e);return new n.cipher.BlockCipher({algorithm:r,key:t,decrypt:!0})},n.cipher.registerAlgorithm=function(e,t){e=e.toUpperCase(),n.cipher.algorithms[e]=t},n.cipher.getAlgorithm=function(e){return(e=e.toUpperCase())in n.cipher.algorithms?n.cipher.algorithms[e]:null};var i=n.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};i.prototype.start=function(e){e=e||{};var t={};for(var r in e)t[r]=e[r];t.decrypt=this._decrypt,this._finish=!1,this._input=n.util.createBuffer(),this.output=e.output||n.util.createBuffer(),this.mode.start(t)},i.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},i.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))}},1655:(e,t,r)=>{var n=r(45);r(3900),n.cipher=n.cipher||{};var i=e.exports=n.cipher.modes=n.cipher.modes||{};function s(e,t){if("string"===typeof e&&(e=n.util.createBuffer(e)),n.util.isArray(e)&&e.length>4){var r=e;e=n.util.createBuffer();for(var i=0;i<r.length;++i)e.putByte(r[i])}if(e.length()<t)throw new Error("Invalid IV length; got "+e.length()+" bytes and expected "+t+" bytes.");if(!n.util.isArray(e)){var s=[],o=t/4;for(i=0;i<o;++i)s.push(e.getInt32());e=s}return e}function o(e){e[e.length-1]=e[e.length-1]+1&4294967295}function a(e){return[e/4294967296|0,4294967295&e]}i.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.ecb.prototype.start=function(e){},i.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},i.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},i.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},i.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},i.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},i.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},i.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},i.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},i.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},i.cfb=function(e){e=e||{},this.name="CFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(s>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(s>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb=function(e){e=e||{},this.name="OFB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(s>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},i.ofb.prototype.decrypt=i.ofb.prototype.encrypt,i.ctr=function(e){e=e||{},this.name="CTR",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0},i.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=s(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},i.ctr.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]);else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(s>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}o(this._inBlock)},i.ctr.prototype.decrypt=i.ctr.prototype.encrypt,i.gcm=function(e){e=e||{},this.name="GCM",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=n.util.createBuffer(),this._partialBytes=0,this._R=3774873600},i.gcm.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");var t,r=n.util.createBuffer(e.iv);if(this._cipherLength=0,t="additionalData"in e?n.util.createBuffer(e.additionalData):n.util.createBuffer(),this._tagLength="tagLength"in e?e.tagLength:128,this._tag=null,e.decrypt&&(this._tag=n.util.createBuffer(e.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var i=r.length();if(12===i)this._j0=[r.getInt32(),r.getInt32(),r.getInt32(),1];else{for(this._j0=[0,0,0,0];r.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(a(8*i)))}this._inBlock=this._j0.slice(0),o(this._inBlock),this._partialBytes=0,t=n.util.createBuffer(t),this._aDataLength=a(8*t.length());var s=t.length()%this.blockSize;for(s&&t.fillWithByte(0,this.blockSize-s),this._s=[0,0,0,0];t.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[t.getInt32(),t.getInt32(),t.getInt32(),t.getInt32()])},i.gcm.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize){for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^=e.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-n)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(s<=0||r){if(r){var a=n%this.blockSize;this._cipherLength+=a,this._partialOutput.truncate(this.blockSize-a)}else this._cipherLength+=this.blockSize;for(i=0;i<this._ints;++i)this._outBlock[i]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),o(this._inBlock)},i.gcm.prototype.decrypt=function(e,t,r){var n=e.length();if(n<this.blockSize&&!(r&&n>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),o(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var i=0;i<this._ints;++i)t.putInt32(this._outBlock[i]^this._hashBlock[i]);n<this.blockSize?this._cipherLength+=n%this.blockSize:this._cipherLength+=this.blockSize},i.gcm.prototype.afterFinish=function(e,t){var r=!0;t.decrypt&&t.overflow&&e.truncate(this.blockSize-t.overflow),this.tag=n.util.createBuffer();var i=this._aDataLength.concat(a(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,i);var s=[];this.cipher.encrypt(this._j0,s);for(var o=0;o<this._ints;++o)this.tag.putInt32(this._s[o]^s[o]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),t.decrypt&&this.tag.bytes()!==this._tag&&(r=!1),r},i.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),i=0;i<128;++i){e[i/32|0]&1<<31-i%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r},i.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},i.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},i.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},i.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,s=new Array(i),o=0;o<i;++o){var a=[0,0,0,0],c=(n-1-o%n)*t;a[o/n|0]=1<<t-1<<c,s[o]=this.generateSubHashTable(this.multiply(a,e),t)}return s},i.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,i=new Array(r);i[n]=e.slice(0);for(var s=n>>>1;s>0;)this.pow(i[2*s],i[s]=[]),s>>=1;for(s=2;s<n;){for(var o=1;o<s;++o){var a=i[s],c=i[o];i[s+o]=[a[0]^c[0],a[1]^c[1],a[2]^c[2],a[3]^c[3]]}s*=2}for(i[0]=[0,0,0,0],s=n+1;s<r;++s){var u=i[s^n];i[s]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return i}},2986:(e,t,r)=>{var n=r(45);function i(e,t){n.cipher.registerAlgorithm(e,(function(){return new n.des.Algorithm(e,t)}))}r(9151),r(1655),r(3900),e.exports=n.des=n.des||{},n.des.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},n.des.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},n.des.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},n.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return f(r._keys,e,t,!1)},decrypt:function(e,t){return f(r._keys,e,t,!0)}}}),r._init=!1},n.des.Algorithm.prototype.initialize=function(e){if(!this._init){var t=n.util.createBuffer(e.key);if(0===this.name.indexOf("3DES")&&24!==t.length())throw new Error("Invalid Triple-DES key size: "+8*t.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],s=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],o=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],a=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],h=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],d=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],f=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],p=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],b=e.length()>8?3:1,y=[],m=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],w=0,v=0;v<b;v++){var _=e.getInt32(),E=e.getInt32();_^=(t=252645135&(_>>>4^E))<<4,_^=t=65535&((E^=t)>>>-16^_),_^=(t=858993459&(_>>>2^(E^=t<<-16)))<<2,_^=t=65535&((E^=t)>>>-16^_),_^=(t=1431655765&(_>>>1^(E^=t<<-16)))<<1,_^=t=16711935&((E^=t)>>>8^_),t=(_^=(t=1431655765&(_>>>1^(E^=t<<8)))<<1)<<8|(E^=t)>>>20&240,_=E<<24|E<<8&16711680|E>>>8&65280|E>>>24&240,E=t;for(var S=0;S<m.length;++S){m[S]?(_=_<<2|_>>>26,E=E<<2|E>>>26):(_=_<<1|_>>>27,E=E<<1|E>>>27),E&=-15;var A=r[(_&=-15)>>>28]|n[_>>>24&15]|i[_>>>20&15]|s[_>>>16&15]|o[_>>>12&15]|a[_>>>8&15]|c[_>>>4&15],k=u[E>>>28]|l[E>>>24&15]|h[E>>>20&15]|d[E>>>16&15]|f[E>>>12&15]|p[E>>>8&15]|g[E>>>4&15];t=65535&(k>>>16^A),y[w++]=A^t,y[w++]=k^t<<16}}return y}(t),this._init=!0}},i("DES-ECB",n.cipher.modes.ecb),i("DES-CBC",n.cipher.modes.cbc),i("DES-CFB",n.cipher.modes.cfb),i("DES-OFB",n.cipher.modes.ofb),i("DES-CTR",n.cipher.modes.ctr),i("3DES-ECB",n.cipher.modes.ecb),i("3DES-CBC",n.cipher.modes.cbc),i("3DES-CFB",n.cipher.modes.cfb),i("3DES-OFB",n.cipher.modes.ofb),i("3DES-CTR",n.cipher.modes.ctr);var s=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],o=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],a=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],c=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],u=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],l=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],h=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],d=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function f(e,t,r,n){var i,f,p=32===e.length?3:9;i=3===p?n?[30,-2,-2]:[0,32,2]:n?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var g=t[0],b=t[1];g^=(f=252645135&(g>>>4^b))<<4,g^=(f=65535&(g>>>16^(b^=f)))<<16,g^=f=858993459&((b^=f)>>>2^g),g^=f=16711935&((b^=f<<2)>>>8^g),g=(g^=(f=1431655765&(g>>>1^(b^=f<<8)))<<1)<<1|g>>>31,b=(b^=f)<<1|b>>>31;for(var y=0;y<p;y+=3){for(var m=i[y+1],w=i[y+2],v=i[y];v!=m;v+=w){var _=b^e[v],E=(b>>>4|b<<28)^e[v+1];f=g,g=b,b=f^(o[_>>>24&63]|c[_>>>16&63]|l[_>>>8&63]|d[63&_]|s[E>>>24&63]|a[E>>>16&63]|u[E>>>8&63]|h[63&E])}f=g,g=b,b=f}b=b>>>1|b<<31,b^=f=1431655765&((g=g>>>1|g<<31)>>>1^b),b^=(f=16711935&(b>>>8^(g^=f<<1)))<<8,b^=(f=858993459&(b>>>2^(g^=f)))<<2,b^=f=65535&((g^=f)>>>16^b),b^=f=252645135&((g^=f<<16)>>>4^b),g^=f<<4,r[0]=g,r[1]=b}function p(e){var t,r="DES-"+((e=e||{}).mode||"CBC").toUpperCase(),i=(t=e.decrypt?n.cipher.createDecipher(r,e.key):n.cipher.createCipher(r,e.key)).start;return t.start=function(e,r){var s=null;r instanceof n.util.ByteBuffer&&(s=r,r={}),(r=r||{}).output=s,r.iv=e,i.call(t,r)},t}},45:e=>{e.exports={options:{usePureJavaScript:!1}}},8163:(e,t,r)=>{var n=r(45);r(5693),r(3900),(e.exports=n.hmac=n.hmac||{}).create=function(){var e=null,t=null,r=null,i=null,s={start:function(s,o){if(null!==s)if("string"===typeof s){if(!((s=s.toLowerCase())in n.md.algorithms))throw new Error('Unknown hash algorithm "'+s+'"');t=n.md.algorithms[s].create()}else t=s;if(null===o)o=e;else{if("string"===typeof o)o=n.util.createBuffer(o);else if(n.util.isArray(o)){var a=o;o=n.util.createBuffer();for(var c=0;c<a.length;++c)o.putByte(a[c])}var u=o.length();u>t.blockLength&&(t.start(),t.update(o.bytes()),o=t.digest()),r=n.util.createBuffer(),i=n.util.createBuffer(),u=o.length();for(c=0;c<u;++c){a=o.at(c);r.putByte(54^a),i.putByte(92^a)}if(u<t.blockLength)for(a=t.blockLength-u,c=0;c<a;++c)r.putByte(54),i.putByte(92);e=o,r=r.bytes(),i=i.bytes()}t.start(),t.update(r)},update:function(e){t.update(e)},getMac:function(){var e=t.digest().bytes();return t.start(),t.update(i),t.update(e),t.digest()}};return s.digest=s.getMac,s}},9463:(e,t,r)=>{var n,i=r(45);e.exports=i.jsbn=i.jsbn||{};function s(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function o(){return new s(null)}function a(e,t,r,n,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=a*c+u*o;i=((c=o*c+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+a*u,r.data[n++]=268435455&c}return i}i.jsbn.BigInteger=s,"undefined"===typeof navigator?(s.prototype.am=a,n=28):"Microsoft Internet Explorer"==navigator.appName?(s.prototype.am=function(e,t,r,n,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=a*c+u*o;i=((c=o*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+a*u+(i>>>30),r.data[n++]=1073741823&c}return i},n=30):"Netscape"!=navigator.appName?(s.prototype.am=function(e,t,r,n,i,s){for(;--s>=0;){var o=t*this.data[e++]+r.data[n]+i;i=Math.floor(o/67108864),r.data[n++]=67108863&o}return i},n=26):(s.prototype.am=a,n=28),s.prototype.DB=n,s.prototype.DM=(1<<n)-1,s.prototype.DV=1<<n;s.prototype.FV=Math.pow(2,52),s.prototype.F1=52-n,s.prototype.F2=2*n-52;var c,u,l="0123456789abcdefghijklmnopqrstuvwxyz",h=new Array;for(c="0".charCodeAt(0),u=0;u<=9;++u)h[c++]=u;for(c="a".charCodeAt(0),u=10;u<36;++u)h[c++]=u;for(c="A".charCodeAt(0),u=10;u<36;++u)h[c++]=u;function d(e){return l.charAt(e)}function f(e,t){var r=h[e.charCodeAt(t)];return null==r?-1:r}function p(e){var t=o();return t.fromInt(e),t}function g(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function b(e){this.m=e}function y(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function m(e,t){return e&t}function w(e,t){return e|t}function v(e,t){return e^t}function _(e,t){return e&~t}function E(e){if(0==e)return-1;var t=0;return 0==(65535&e)&&(e>>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function S(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function A(){}function k(e){return e}function x(e){this.r2=o(),this.q3=o(),s.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}b.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},b.prototype.revert=function(e){return e},b.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},b.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},b.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},y.prototype.convert=function(e){var t=o();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(s.ZERO)>0&&this.m.subTo(t,t),t},y.prototype.revert=function(e){var t=o();return e.copyTo(t),this.reduce(t),t},y.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},y.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},y.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},s.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},s.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},s.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var a=8==r?255&e[n]:f(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this.data[this.t++]=a:o+r>this.DB?(this.data[this.t-1]|=(a&(1<<this.DB-o)-1)<<o,this.data[this.t++]=a>>this.DB-o):this.data[this.t-1]|=a<<o,(o+=r)>=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this.data[this.t-1]|=(1<<this.DB-o)-1<<o)),this.clamp(),i&&s.ZERO.subTo(this,this)},s.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},s.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},s.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},s.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(e/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+o+1]=this.data[r]>>i|a,a=(this.data[r]&s)<<n;for(r=o-1;r>=0;--r)t.data[r]=0;t.data[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},s.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,s=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var o=r+1;o<this.t;++o)t.data[o-r-1]|=(this.data[o]&s)<<i,t.data[o-r]=this.data[o]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&s)<<i),t.t=this.t-r,t.clamp()}},s.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},s.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t.data[i]=0;for(i=0;i<n.t;++i)t.data[i+r.t]=r.am(0,n.data[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&s.ZERO.subTo(t,t)},s.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},s.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=o());var a=o(),c=this.s,u=e.s,l=this.DB-g(n.data[n.t-1]);l>0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,d=a.data[h-1];if(0!=d){var f=d*(1<<this.F1)+(h>1?a.data[h-2]>>this.F2:0),p=this.FV/f,b=(1<<this.F1)/f,y=1<<this.F2,m=r.t,w=m-h,v=null==t?o():t;for(a.dlShiftTo(w,v),r.compareTo(v)>=0&&(r.data[r.t++]=1,r.subTo(v,r)),s.ONE.dlShiftTo(h,v),v.subTo(a,a);a.t<h;)a.data[a.t++]=0;for(;--w>=0;){var _=r.data[--m]==d?this.DM:Math.floor(r.data[m]*p+(r.data[m-1]+y)*b);if((r.data[m]+=a.am(0,_,r,w,0,h))<_)for(a.dlShiftTo(w,v),r.subTo(v,r);r.data[m]<--_;)r.subTo(v,r)}null!=t&&(r.drShiftTo(h,t),c!=u&&s.ZERO.subTo(t,t)),r.t=h,r.clamp(),l>0&&r.rShiftTo(l,r),c<0&&s.ZERO.subTo(r,r)}}},s.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},s.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},s.prototype.exp=function(e,t){if(e>4294967295||e<1)return s.ONE;var r=o(),n=o(),i=t.convert(this),a=g(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<<a)>0)t.mulTo(n,i,r);else{var c=r;r=n,n=c}return t.revert(r)},s.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(r=this.data[o]>>a)>0&&(i=!0,s=d(r));o>=0;)a<t?(r=(this.data[o]&(1<<a)-1)<<t-a,r|=this.data[--o]>>(a+=this.DB-t)):(r=this.data[o]>>(a-=t)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=d(r));return i?s:"0"},s.prototype.negate=function(){var e=o();return s.ZERO.subTo(this,e),e},s.prototype.abs=function(){return this.s<0?this.negate():this},s.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},s.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+g(this.data[this.t-1]^this.s&this.DM)},s.prototype.mod=function(e){var t=o();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(s.ZERO)>0&&e.subTo(t,t),t},s.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new b(t):new y(t),this.exp(e,r)},s.ZERO=p(0),s.ONE=p(1),A.prototype.convert=k,A.prototype.revert=k,A.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},A.prototype.sqrTo=function(e,t){e.squareTo(t)},x.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=o();return e.copyTo(t),this.reduce(t),t},x.prototype.revert=function(e){return e},x.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},x.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},x.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var I=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509],C=(1<<26)/I[I.length-1];s.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},s.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=p(r),i=o(),s=o(),a="";for(this.divRemTo(n,i,s);i.signum()>0;)a=(r+s.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,s);return s.intValue().toString(e)+a},s.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,a=0,c=0;c<e.length;++c){var u=f(e,c);u<0?"-"==e.charAt(c)&&0==this.signum()&&(i=!0):(a=t*a+u,++o>=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),i&&s.ZERO.subTo(this,this)},s.prototype.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(s.ONE.shiftLeft(e-1),w,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(s.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<<i)-1:n[0]=0,this.fromString(n,256)}},s.prototype.bitwiseTo=function(e,t,r){var n,i,s=Math.min(e.t,this.t);for(n=0;n<s;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=s;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=s;n<e.t;++n)r.data[n]=t(i,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},s.prototype.changeBit=function(e,t){var r=s.ONE.shiftLeft(e);return this.bitwiseTo(r,t,r),r},s.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},s.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},s.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},s.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i<n;++i)r.data[i+this.t]=this.am(0,e.data[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e.data[i],r,i,0,t-i);r.clamp()},s.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},s.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},s.prototype.millerRabin=function(e){var t=this.subtract(s.ONE),r=t.getLowestSetBit();if(r<=0)return!1;for(var n,i=t.shiftRight(r),o={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},a=0;a<e;++a){do{n=new s(this.bitLength(),o)}while(n.compareTo(s.ONE)<=0||n.compareTo(t)>=0);var c=n.modPow(i,this);if(0!=c.compareTo(s.ONE)&&0!=c.compareTo(t)){for(var u=1;u++<r&&0!=c.compareTo(t);)if(0==(c=c.modPowInt(2,this)).compareTo(s.ONE))return!1;if(0!=c.compareTo(t))return!1}}return!0},s.prototype.clone=function(){var e=o();return this.copyTo(e),e},s.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},s.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},s.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},s.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},s.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},s.prototype.equals=function(e){return 0==this.compareTo(e)},s.prototype.min=function(e){return this.compareTo(e)<0?this:e},s.prototype.max=function(e){return this.compareTo(e)>0?this:e},s.prototype.and=function(e){var t=o();return this.bitwiseTo(e,m,t),t},s.prototype.or=function(e){var t=o();return this.bitwiseTo(e,w,t),t},s.prototype.xor=function(e){var t=o();return this.bitwiseTo(e,v,t),t},s.prototype.andNot=function(e){var t=o();return this.bitwiseTo(e,_,t),t},s.prototype.not=function(){for(var e=o(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},s.prototype.shiftLeft=function(e){var t=o();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},s.prototype.shiftRight=function(e){var t=o();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},s.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+E(this.data[e]);return this.s<0?this.t*this.DB:-1},s.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=S(this.data[r]^t);return e},s.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:0!=(this.data[t]&1<<e%this.DB)},s.prototype.setBit=function(e){return this.changeBit(e,w)},s.prototype.clearBit=function(e){return this.changeBit(e,_)},s.prototype.flipBit=function(e){return this.changeBit(e,v)},s.prototype.add=function(e){var t=o();return this.addTo(e,t),t},s.prototype.subtract=function(e){var t=o();return this.subTo(e,t),t},s.prototype.multiply=function(e){var t=o();return this.multiplyTo(e,t),t},s.prototype.divide=function(e){var t=o();return this.divRemTo(e,t,null),t},s.prototype.remainder=function(e){var t=o();return this.divRemTo(e,null,t),t},s.prototype.divideAndRemainder=function(e){var t=o(),r=o();return this.divRemTo(e,t,r),new Array(t,r)},s.prototype.modPow=function(e,t){var r,n,i=e.bitLength(),s=p(1);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6,n=i<8?new b(t):t.isEven()?new x(t):new y(t);var a=new Array,c=3,u=r-1,l=(1<<r)-1;if(a[1]=n.convert(this),r>1){var h=o();for(n.sqrTo(a[1],h);c<=l;)a[c]=o(),n.mulTo(h,a[c-2],a[c]),c+=2}var d,f,m=e.t-1,w=!0,v=o();for(i=g(e.data[m])-1;m>=0;){for(i>=u?d=e.data[m]>>i-u&l:(d=(e.data[m]&(1<<i+1)-1)<<u-i,m>0&&(d|=e.data[m-1]>>this.DB+i-u)),c=r;0==(1&d);)d>>=1,--c;if((i-=c)<0&&(i+=this.DB,--m),w)a[d].copyTo(s),w=!1;else{for(;c>1;)n.sqrTo(s,v),n.sqrTo(v,s),c-=2;c>0?n.sqrTo(s,v):(f=s,s=v,v=f),n.mulTo(v,a[d],s)}for(;m>=0&&0==(e.data[m]&1<<i);)n.sqrTo(s,v),f=s,s=v,v=f,--i<0&&(i=this.DB-1,--m)}return n.revert(s)},s.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return s.ZERO;for(var r=e.clone(),n=this.clone(),i=p(1),o=p(0),a=p(0),c=p(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),t?(i.isEven()&&o.isEven()||(i.addTo(this,i),o.subTo(e,o)),i.rShiftTo(1,i)):o.isEven()||o.subTo(e,o),o.rShiftTo(1,o);for(;n.isEven();)n.rShiftTo(1,n),t?(a.isEven()&&c.isEven()||(a.addTo(this,a),c.subTo(e,c)),a.rShiftTo(1,a)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(a,i),o.subTo(c,o)):(n.subTo(r,n),t&&a.subTo(i,a),c.subTo(o,c))}return 0!=n.compareTo(s.ONE)?s.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},s.prototype.pow=function(e){return this.exp(e,new A)},s.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return t;for(i<s&&(s=i),s>0&&(t.rShiftTo(s,t),r.rShiftTo(s,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},s.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=I[I.length-1]){for(t=0;t<I.length;++t)if(r.data[0]==I[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<I.length;){for(var n=I[t],i=t+1;i<I.length&&n<C;)n*=I[i++];for(n=r.modInt(n);t<i;)if(n%I[t++]==0)return!1}return r.millerRabin(e)}},5693:(e,t,r)=>{var n=r(45);e.exports=n.md=n.md||{},n.md.algorithms=n.md.algorithms||{}},3225:(e,t,r)=>{var n=r(45);n.pki=n.pki||{};var i=e.exports=n.pki.oids=n.oids=n.oids||{};function s(e,t){i[e]=t,i[t]=e}function o(e,t){i[e]=t}s("1.2.840.113549.1.1.1","rsaEncryption"),s("1.2.840.113549.1.1.4","md5WithRSAEncryption"),s("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),s("1.2.840.113549.1.1.7","RSAES-OAEP"),s("1.2.840.113549.1.1.8","mgf1"),s("1.2.840.113549.1.1.9","pSpecified"),s("1.2.840.113549.1.1.10","RSASSA-PSS"),s("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),s("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),s("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),s("1.3.101.112","EdDSA25519"),s("1.2.840.10040.4.3","dsa-with-sha1"),s("1.3.14.3.2.7","desCBC"),s("1.3.14.3.2.26","sha1"),s("1.3.14.3.2.29","sha1WithRSASignature"),s("2.16.840.1.101.3.4.2.1","sha256"),s("2.16.840.1.101.3.4.2.2","sha384"),s("2.16.840.1.101.3.4.2.3","sha512"),s("2.16.840.1.101.3.4.2.4","sha224"),s("2.16.840.1.101.3.4.2.5","sha512-224"),s("2.16.840.1.101.3.4.2.6","sha512-256"),s("1.2.840.113549.2.2","md2"),s("1.2.840.113549.2.5","md5"),s("1.2.840.113549.1.7.1","data"),s("1.2.840.113549.1.7.2","signedData"),s("1.2.840.113549.1.7.3","envelopedData"),s("1.2.840.113549.1.7.4","signedAndEnvelopedData"),s("1.2.840.113549.1.7.5","digestedData"),s("1.2.840.113549.1.7.6","encryptedData"),s("1.2.840.113549.1.9.1","emailAddress"),s("1.2.840.113549.1.9.2","unstructuredName"),s("1.2.840.113549.1.9.3","contentType"),s("1.2.840.113549.1.9.4","messageDigest"),s("1.2.840.113549.1.9.5","signingTime"),s("1.2.840.113549.1.9.6","counterSignature"),s("1.2.840.113549.1.9.7","challengePassword"),s("1.2.840.113549.1.9.8","unstructuredAddress"),s("1.2.840.113549.1.9.14","extensionRequest"),s("1.2.840.113549.1.9.20","friendlyName"),s("1.2.840.113549.1.9.21","localKeyId"),s("1.2.840.113549.1.9.22.1","x509Certificate"),s("1.2.840.113549.1.12.10.1.1","keyBag"),s("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),s("1.2.840.113549.1.12.10.1.3","certBag"),s("1.2.840.113549.1.12.10.1.4","crlBag"),s("1.2.840.113549.1.12.10.1.5","secretBag"),s("1.2.840.113549.1.12.10.1.6","safeContentsBag"),s("1.2.840.113549.1.5.13","pkcs5PBES2"),s("1.2.840.113549.1.5.12","pkcs5PBKDF2"),s("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),s("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),s("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),s("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),s("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),s("1.2.840.113549.2.7","hmacWithSHA1"),s("1.2.840.113549.2.8","hmacWithSHA224"),s("1.2.840.113549.2.9","hmacWithSHA256"),s("1.2.840.113549.2.10","hmacWithSHA384"),s("1.2.840.113549.2.11","hmacWithSHA512"),s("1.2.840.113549.3.7","des-EDE3-CBC"),s("2.16.840.1.101.3.4.1.2","aes128-CBC"),s("2.16.840.1.101.3.4.1.22","aes192-CBC"),s("2.16.840.1.101.3.4.1.42","aes256-CBC"),s("2.5.4.3","commonName"),s("2.5.4.4","surname"),s("2.5.4.5","serialNumber"),s("2.5.4.6","countryName"),s("2.5.4.7","localityName"),s("2.5.4.8","stateOrProvinceName"),s("2.5.4.9","streetAddress"),s("2.5.4.10","organizationName"),s("2.5.4.11","organizationalUnitName"),s("2.5.4.12","title"),s("2.5.4.13","description"),s("2.5.4.15","businessCategory"),s("2.5.4.17","postalCode"),s("2.5.4.42","givenName"),s("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),s("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),s("2.16.840.1.113730.1.1","nsCertType"),s("2.16.840.1.113730.1.13","nsComment"),o("2.5.29.1","authorityKeyIdentifier"),o("2.5.29.2","keyAttributes"),o("2.5.29.3","certificatePolicies"),o("2.5.29.4","keyUsageRestriction"),o("2.5.29.5","policyMapping"),o("2.5.29.6","subtreesConstraint"),o("2.5.29.7","subjectAltName"),o("2.5.29.8","issuerAltName"),o("2.5.29.9","subjectDirectoryAttributes"),o("2.5.29.10","basicConstraints"),o("2.5.29.11","nameConstraints"),o("2.5.29.12","policyConstraints"),o("2.5.29.13","basicConstraints"),s("2.5.29.14","subjectKeyIdentifier"),s("2.5.29.15","keyUsage"),o("2.5.29.16","privateKeyUsagePeriod"),s("2.5.29.17","subjectAltName"),s("2.5.29.18","issuerAltName"),s("2.5.29.19","basicConstraints"),o("2.5.29.20","cRLNumber"),o("2.5.29.21","cRLReason"),o("2.5.29.22","expirationDate"),o("2.5.29.23","instructionCode"),o("2.5.29.24","invalidityDate"),o("2.5.29.25","cRLDistributionPoints"),o("2.5.29.26","issuingDistributionPoint"),o("2.5.29.27","deltaCRLIndicator"),o("2.5.29.28","issuingDistributionPoint"),o("2.5.29.29","certificateIssuer"),o("2.5.29.30","nameConstraints"),s("2.5.29.31","cRLDistributionPoints"),s("2.5.29.32","certificatePolicies"),o("2.5.29.33","policyMappings"),o("2.5.29.34","policyConstraints"),s("2.5.29.35","authorityKeyIdentifier"),o("2.5.29.36","policyConstraints"),s("2.5.29.37","extKeyUsage"),o("2.5.29.46","freshestCRL"),o("2.5.29.54","inhibitAnyPolicy"),s("1.3.6.1.4.1.11129.2.4.2","timestampList"),s("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),s("1.3.6.1.5.5.7.3.1","serverAuth"),s("1.3.6.1.5.5.7.3.2","clientAuth"),s("1.3.6.1.5.5.7.3.3","codeSigning"),s("1.3.6.1.5.5.7.3.4","emailProtection"),s("1.3.6.1.5.5.7.3.8","timeStamping")},3555:(e,t,r)=>{var n=r(45);if(r(9353),r(5465),r(2986),r(5693),r(3225),r(8009),r(5224),r(2795),r(1577),r(9408),r(3900),"undefined"===typeof i)var i=n.jsbn.BigInteger;var s=n.asn1,o=n.pki=n.pki||{};e.exports=o.pbe=n.pbe=n.pbe||{};var a=o.oids,c={name:"EncryptedPrivateKeyInfo",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},u={name:"PBES2Algorithms",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:s.Class.UNIVERSAL,type:s.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},l={name:"pkcs-12PbeParams",tagClass:s.Class.UNIVERSAL,type:s.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:s.Class.UNIVERSAL,type:s.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:s.Class.UNIVERSAL,type:s.Type.INTEGER,constructed:!1,capture:"iterations"}]};function h(e,t){return e.start().update(t).digest().getBytes()}function d(e){var t;if(e){if(!(t=o.oids[s.derToOid(e)])){var r=new Error("Unsupported PRF OID.");throw r.oid=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}}else t="hmacWithSHA1";return f(t)}function f(e){var t=n.md;switch(e){case"hmacWithSHA224":t=n.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":e=e.substr(8).toLowerCase();break;default:var r=new Error("Unsupported PRF algorithm.");throw r.algorithm=e,r.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],r}if(!t||!(e in t))throw new Error("Unknown hash algorithm: "+e);return t[e].create()}o.encryptPrivateKeyInfo=function(e,t,r){(r=r||{}).saltSize=r.saltSize||8,r.count=r.count||2048,r.algorithm=r.algorithm||"aes128",r.prfAlgorithm=r.prfAlgorithm||"sha1";var i,c,u,l=n.random.getBytesSync(r.saltSize),h=r.count,d=s.integerToDer(h);if(0===r.algorithm.indexOf("aes")||"des"===r.algorithm){var p,g,b;switch(r.algorithm){case"aes128":i=16,p=16,g=a["aes128-CBC"],b=n.aes.createEncryptionCipher;break;case"aes192":i=24,p=16,g=a["aes192-CBC"],b=n.aes.createEncryptionCipher;break;case"aes256":i=32,p=16,g=a["aes256-CBC"],b=n.aes.createEncryptionCipher;break;case"des":i=8,p=8,g=a.desCBC,b=n.des.createEncryptionCipher;break;default:throw(E=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,E}var y="hmacWith"+r.prfAlgorithm.toUpperCase(),m=f(y),w=n.pkcs5.pbkdf2(t,l,h,i,m),v=n.random.getBytesSync(p);(S=b(w)).start(v),S.update(s.toDer(e)),S.finish(),u=S.output.getBytes();var _=function(e,t,r,i){var a=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,e),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,t.getBytes())]);"hmacWithSHA1"!==i&&a.value.push(s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,n.util.hexToBytes(r.toString(16))),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(o.oids[i]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.NULL,!1,"")]));return a}(l,d,i,y);c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBES2).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a.pkcs5PBKDF2).getBytes()),_]),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(g).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,v)])])])}else{var E;if("3des"!==r.algorithm)throw(E=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=r.algorithm,E;i=24;var S,A=new n.util.ByteBuffer(l);w=o.pbe.generatePkcs12Key(t,A,1,h,i),v=o.pbe.generatePkcs12Key(t,A,2,h,i);(S=n.des.createEncryptionCipher(w)).start(v),S.update(s.toDer(e)),S.finish(),u=S.output.getBytes(),c=s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OID,!1,s.oidToDer(a["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,l),s.create(s.Class.UNIVERSAL,s.Type.INTEGER,!1,d.getBytes())])])}return s.create(s.Class.UNIVERSAL,s.Type.SEQUENCE,!0,[c,s.create(s.Class.UNIVERSAL,s.Type.OCTETSTRING,!1,u)])},o.decryptPrivateKeyInfo=function(e,t){var r=null,i={},a=[];if(!s.validate(e,c,i,a)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=a,u}var l=s.derToOid(i.encryptionOid),h=o.pbe.getCipher(l,i.encryptionParams,t),d=n.util.createBuffer(i.encryptedData);return h.update(d),h.finish()&&(r=s.fromDer(h.output)),r},o.encryptedPrivateKeyToPem=function(e,t){var r={type:"ENCRYPTED PRIVATE KEY",body:s.toDer(e).getBytes()};return n.pem.encode(r,{maxline:t})},o.encryptedPrivateKeyFromPem=function(e){var t=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==t.type){var r=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw r.headerType=t.type,r}if(t.procType&&"ENCRYPTED"===t.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return s.fromDer(t.body)},o.encryptRsaPrivateKey=function(e,t,r){if(!(r=r||{}).legacy){var i=o.wrapRsaPrivateKey(o.privateKeyToAsn1(e));return i=o.encryptPrivateKeyInfo(i,t,r),o.encryptedPrivateKeyToPem(i)}var a,c,u,l;switch(r.algorithm){case"aes128":a="AES-128-CBC",u=16,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes192":a="AES-192-CBC",u=24,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"aes256":a="AES-256-CBC",u=32,c=n.random.getBytesSync(16),l=n.aes.createEncryptionCipher;break;case"3des":a="DES-EDE3-CBC",u=24,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;case"des":a="DES-CBC",u=8,c=n.random.getBytesSync(8),l=n.des.createEncryptionCipher;break;default:var h=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+r.algorithm+'".');throw h.algorithm=r.algorithm,h}var d=l(n.pbe.opensslDeriveBytes(t,c.substr(0,8),u));d.start(c),d.update(s.toDer(o.privateKeyToAsn1(e))),d.finish();var f={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:a,parameters:n.util.bytesToHex(c).toUpperCase()},body:d.output.getBytes()};return n.pem.encode(f)},o.decryptRsaPrivateKey=function(e,t){var r=null,i=n.pem.decode(e)[0];if("ENCRYPTED PRIVATE KEY"!==i.type&&"PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(i.procType&&"ENCRYPTED"===i.procType.type){var a,c;switch(i.dekInfo.algorithm){case"DES-CBC":a=8,c=n.des.createDecryptionCipher;break;case"DES-EDE3-CBC":a=24,c=n.des.createDecryptionCipher;break;case"AES-128-CBC":a=16,c=n.aes.createDecryptionCipher;break;case"AES-192-CBC":a=24,c=n.aes.createDecryptionCipher;break;case"AES-256-CBC":a=32,c=n.aes.createDecryptionCipher;break;case"RC2-40-CBC":a=5,c=function(e){return n.rc2.createDecryptionCipher(e,40)};break;case"RC2-64-CBC":a=8,c=function(e){return n.rc2.createDecryptionCipher(e,64)};break;case"RC2-128-CBC":a=16,c=function(e){return n.rc2.createDecryptionCipher(e,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+i.dekInfo.algorithm+'".')).algorithm=i.dekInfo.algorithm,u}var l=n.util.hexToBytes(i.dekInfo.parameters),h=c(n.pbe.opensslDeriveBytes(t,l.substr(0,8),a));if(h.start(l),h.update(n.util.createBuffer(i.body)),!h.finish())return r;r=h.output.getBytes()}else r=i.body;return null!==(r="ENCRYPTED PRIVATE KEY"===i.type?o.decryptPrivateKeyInfo(s.fromDer(r),t):s.fromDer(r))&&(r=o.privateKeyFromAsn1(r)),r},o.pbe.generatePkcs12Key=function(e,t,r,i,s,o){var a,c;if("undefined"===typeof o||null===o){if(!("sha1"in n.md))throw new Error('"sha1" hash algorithm unavailable.');o=n.md.sha1.create()}var u=o.digestLength,l=o.blockLength,h=new n.util.ByteBuffer,d=new n.util.ByteBuffer;if(null!==e&&void 0!==e){for(c=0;c<e.length;c++)d.putInt16(e.charCodeAt(c));d.putInt16(0)}var f=d.length(),p=t.length(),g=new n.util.ByteBuffer;g.fillWithByte(r,l);var b=l*Math.ceil(p/l),y=new n.util.ByteBuffer;for(c=0;c<b;c++)y.putByte(t.at(c%p));var m=l*Math.ceil(f/l),w=new n.util.ByteBuffer;for(c=0;c<m;c++)w.putByte(d.at(c%f));var v=y;v.putBuffer(w);for(var _=Math.ceil(s/u),E=1;E<=_;E++){var S=new n.util.ByteBuffer;S.putBytes(g.bytes()),S.putBytes(v.bytes());for(var A=0;A<i;A++)o.start(),o.update(S.getBytes()),S=o.digest();var k=new n.util.ByteBuffer;for(c=0;c<l;c++)k.putByte(S.at(c%u));var x=Math.ceil(p/l)+Math.ceil(f/l),I=new n.util.ByteBuffer;for(a=0;a<x;a++){var C=new n.util.ByteBuffer(v.getBytes(l)),T=511;for(c=k.length()-1;c>=0;c--)T>>=8,T+=k.at(c)+C.at(c),C.setAt(c,255&T);I.putBuffer(C)}v=I,h.putBuffer(S)}return h.truncate(h.length()-s),h},o.pbe.getCipher=function(e,t,r){switch(e){case o.oids.pkcs5PBES2:return o.pbe.getCipherForPBES2(e,t,r);case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case o.oids["pbewithSHAAnd40BitRC2-CBC"]:return o.pbe.getCipherForPKCS12PBE(e,t,r);default:var n=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw n.oid=e,n.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],n}},o.pbe.getCipherForPBES2=function(e,t,r){var i,a={},c=[];if(!s.validate(t,u,a,c))throw(i=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,i;if((e=s.derToOid(a.kdfOid))!==o.oids.pkcs5PBKDF2)throw(i=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=e,i.supportedOids=["pkcs5PBKDF2"],i;if((e=s.derToOid(a.encOid))!==o.oids["aes128-CBC"]&&e!==o.oids["aes192-CBC"]&&e!==o.oids["aes256-CBC"]&&e!==o.oids["des-EDE3-CBC"]&&e!==o.oids.desCBC)throw(i=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=e,i.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],i;var l,h,f=a.kdfSalt,p=n.util.createBuffer(a.kdfIterationCount);switch(p=p.getInt(p.length()<<3),o.oids[e]){case"aes128-CBC":l=16,h=n.aes.createDecryptionCipher;break;case"aes192-CBC":l=24,h=n.aes.createDecryptionCipher;break;case"aes256-CBC":l=32,h=n.aes.createDecryptionCipher;break;case"des-EDE3-CBC":l=24,h=n.des.createDecryptionCipher;break;case"desCBC":l=8,h=n.des.createDecryptionCipher}var g=d(a.prfOid),b=n.pkcs5.pbkdf2(r,f,p,l,g),y=a.encIv,m=h(b);return m.start(y),m},o.pbe.getCipherForPKCS12PBE=function(e,t,r){var i={},a=[];if(!s.validate(t,l,i,a))throw(g=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=a,g;var c,u,h,f=n.util.createBuffer(i.salt),p=n.util.createBuffer(i.iterations);switch(p=p.getInt(p.length()<<3),e){case o.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:c=24,u=8,h=n.des.startDecrypting;break;case o.oids["pbewithSHAAnd40BitRC2-CBC"]:c=5,u=8,h=function(e,t){var r=n.rc2.createDecryptionCipher(e,40);return r.start(t,null),r};break;default:var g;throw(g=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=e,g}var b=d(i.prfOid),y=o.pbe.generatePkcs12Key(r,f,1,p,c,b);return b.start(),h(y,o.pbe.generatePkcs12Key(r,f,2,p,u,b))},o.pbe.opensslDeriveBytes=function(e,t,r,i){if("undefined"===typeof i||null===i){if(!("md5"in n.md))throw new Error('"md5" hash algorithm unavailable.');i=n.md.md5.create()}null===t&&(t="");for(var s=[h(i,e+t)],o=16,a=1;o<r;++a,o+=16)s.push(h(i,s[a-1]+e+t));return s.join("").substr(0,r)}},8009:(e,t,r)=>{var n=r(45);r(8163),r(5693),r(3900);var i,s=n.pkcs5=n.pkcs5||{};n.util.isNodejs&&!n.options.usePureJavaScript&&(i=r(310)),e.exports=n.pbkdf2=s.pbkdf2=function(e,t,r,s,o,a){if("function"===typeof o&&(a=o,o=null),n.util.isNodejs&&!n.options.usePureJavaScript&&i.pbkdf2&&(null===o||"object"!==typeof o)&&(i.pbkdf2Sync.length>4||!o||"sha1"===o))return"string"!==typeof o&&(o="sha1"),e=Buffer.from(e,"binary"),t=Buffer.from(t,"binary"),a?4===i.pbkdf2Sync.length?i.pbkdf2(e,t,r,s,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):i.pbkdf2(e,t,r,s,o,(function(e,t){if(e)return a(e);a(null,t.toString("binary"))})):4===i.pbkdf2Sync.length?i.pbkdf2Sync(e,t,r,s).toString("binary"):i.pbkdf2Sync(e,t,r,s,o).toString("binary");if("undefined"!==typeof o&&null!==o||(o="sha1"),"string"===typeof o){if(!(o in n.md.algorithms))throw new Error("Unknown hash algorithm: "+o);o=n.md[o].create()}var c=o.digestLength;if(s>4294967295*c){var u=new Error("Derived key is too long.");if(a)return a(u);throw u}var l=Math.ceil(s/c),h=s-(l-1)*c,d=n.hmac.create();d.start(o,e);var f,p,g,b="";if(!a){for(var y=1;y<=l;++y){d.start(null,null),d.update(t),d.update(n.util.int32ToBytes(y)),f=g=d.digest().getBytes();for(var m=2;m<=r;++m)d.start(null,null),d.update(g),p=d.digest().getBytes(),f=n.util.xorBytes(f,p,c),g=p;b+=y<l?f:f.substr(0,h)}return b}y=1;function w(){if(y>l)return a(null,b);d.start(null,null),d.update(t),d.update(n.util.int32ToBytes(y)),f=g=d.digest().getBytes(),m=2,v()}function v(){if(m<=r)return d.start(null,null),d.update(g),p=d.digest().getBytes(),f=n.util.xorBytes(f,p,c),g=p,++m,n.util.setImmediate(v);b+=y<l?f:f.substr(0,h),++y,w()}w()}},5224:(e,t,r)=>{var n=r(45);r(3900);var i=e.exports=n.pem=n.pem||{};function s(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var s=0,o=-1;for(i=0;i<t.length;++i,++s)if(s>65&&-1!==o){var a=t[o];","===a?(++o,t=t.substr(0,o)+"\r\n "+t.substr(o)):t=t.substr(0,o)+"\r\n"+a+t.substr(o+1),s=i-o-1,o=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(o=i);return t}function o(e){return e.replace(/^\s+/,"")}i.encode=function(e,t){t=t||{};var r,i="-----BEGIN "+e.type+"-----\r\n";if(e.procType&&(i+=s(r={name:"Proc-Type",values:[String(e.procType.version),e.procType.type]})),e.contentDomain&&(i+=s(r={name:"Content-Domain",values:[e.contentDomain]})),e.dekInfo&&(r={name:"DEK-Info",values:[e.dekInfo.algorithm]},e.dekInfo.parameters&&r.values.push(e.dekInfo.parameters),i+=s(r)),e.headers)for(var o=0;o<e.headers.length;++o)i+=s(e.headers[o]);return e.procType&&(i+="\r\n"),i+=n.util.encode64(e.body,t.maxline||64)+"\r\n",i+="-----END "+e.type+"-----\r\n"},i.decode=function(e){for(var t,r=[],i=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,s=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,a=/\r?\n/;t=i.exec(e);){var c=t[1];"NEW CERTIFICATE REQUEST"===c&&(c="CERTIFICATE REQUEST");var u={type:c,procType:null,contentDomain:null,dekInfo:null,headers:[],body:n.util.decode64(t[3])};if(r.push(u),t[2]){for(var l=t[2].split(a),h=0;t&&h<l.length;){for(var d=l[h].replace(/\s+$/,""),f=h+1;f<l.length;++f){var p=l[f];if(!/\s/.test(p[0]))break;d+=p,h=f}if(t=d.match(s)){for(var g={name:t[1],values:[]},b=t[2].split(","),y=0;y<b.length;++y)g.values.push(o(b[y]));if(u.procType)if(u.contentDomain||"Content-Domain"!==g.name)if(u.dekInfo||"DEK-Info"!==g.name)u.headers.push(g);else{if(0===g.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');u.dekInfo={algorithm:b[0],parameters:b[1]||null}}else u.contentDomain=b[0]||"";else{if("Proc-Type"!==g.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==g.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');u.procType={version:b[0],type:b[1]}}}++h}if("ENCRYPTED"===u.procType&&!u.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===r.length)throw new Error("Invalid PEM formatted message.");return r}},7668:(e,t,r)=>{var n=r(45);r(3900),r(2795),r(3753);var i=e.exports=n.pkcs1=n.pkcs1||{};function s(e,t,r){r||(r=n.md.sha1.create());for(var i="",s=Math.ceil(t/r.digestLength),o=0;o<s;++o){var a=String.fromCharCode(o>>24&255,o>>16&255,o>>8&255,255&o);r.start(),r.update(e+a),i+=r.digest().getBytes()}return i.substring(0,t)}i.encode_rsa_oaep=function(e,t,r){var i,o,a,c;"string"===typeof r?(i=r,o=arguments[3]||void 0,a=arguments[4]||void 0):r&&(i=r.label||void 0,o=r.seed||void 0,a=r.md||void 0,r.mgf1&&r.mgf1.md&&(c=r.mgf1.md)),a?a.start():a=n.md.sha1.create(),c||(c=a);var u=Math.ceil(e.n.bitLength()/8),l=u-2*a.digestLength-2;if(t.length>l)throw(b=new Error("RSAES-OAEP input message length is too long.")).length=t.length,b.maxLength=l,b;i||(i=""),a.update(i,"raw");for(var h=a.digest(),d="",f=l-t.length,p=0;p<f;p++)d+="\0";var g=h.getBytes()+d+"\x01"+t;if(o){if(o.length!==a.digestLength){var b;throw(b=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=o.length,b.digestLength=a.digestLength,b}}else o=n.random.getBytes(a.digestLength);var y=s(o,u-a.digestLength-1,c),m=n.util.xorBytes(g,y,g.length),w=s(m,a.digestLength,c);return"\0"+n.util.xorBytes(o,w,o.length)+m},i.decode_rsa_oaep=function(e,t,r){var i,o,a;"string"===typeof r?(i=r,o=arguments[3]||void 0):r&&(i=r.label||void 0,o=r.md||void 0,r.mgf1&&r.mgf1.md&&(a=r.mgf1.md));var c=Math.ceil(e.n.bitLength()/8);if(t.length!==c)throw(y=new Error("RSAES-OAEP encoded message length is invalid.")).length=t.length,y.expectedLength=c,y;if(void 0===o?o=n.md.sha1.create():o.start(),a||(a=o),c<2*o.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");i||(i=""),o.update(i,"raw");for(var u=o.digest().getBytes(),l=t.charAt(0),h=t.substring(1,o.digestLength+1),d=t.substring(1+o.digestLength),f=s(d,o.digestLength,a),p=s(n.util.xorBytes(h,f,h.length),c-o.digestLength-1,a),g=n.util.xorBytes(d,p,d.length),b=g.substring(0,o.digestLength),y="\0"!==l,m=0;m<o.digestLength;++m)y|=u.charAt(m)!==b.charAt(m);for(var w=1,v=o.digestLength,_=o.digestLength;_<g.length;_++){var E=g.charCodeAt(_);y|=E&(w?65534:0),v+=w&=1&E^1}if(y||1!==g.charCodeAt(v))throw new Error("Invalid RSAES-OAEP padding.");return g.substring(v+1)}},8353:(e,t,r)=>{var n=r(45);r(3900),r(9463),r(2795),function(){if(n.prime)e.exports=n.prime;else{var t=e.exports=n.prime=n.prime||{},r=n.jsbn.BigInteger,i=[6,4,2,4,2,4,6,2],s=new r(null);s.fromInt(30);var o=function(e,t){return e|t};t.generateProbablePrime=function(e,t,i){"function"===typeof t&&(i=t,t={});var s=(t=t||{}).algorithm||"PRIMEINC";"string"===typeof s&&(s={name:s}),s.options=s.options||{};var o=t.prng||n.random,c={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===s.name)return function(e,t,i,s){if("workers"in i)return function(e,t,i,s){if("undefined"===typeof Worker)return a(e,t,i,s);var o=u(e,t),c=i.workers,l=i.workLoad||100,h=30*l/8,d=i.workerScript||"forge/prime.worker.js";if(-1===c)return n.util.estimateCores((function(e,t){e&&(t=2),c=t-1,f()}));function f(){c=Math.max(1,c);for(var n=[],i=0;i<c;++i)n[i]=new Worker(d);for(i=0;i<c;++i)n[i].addEventListener("message",f);var a=!1;function f(i){if(!a){0;var c=i.data;if(c.found){for(var d=0;d<n.length;++d)n[d].terminate();return a=!0,s(null,new r(c.prime,16))}o.bitLength()>e&&(o=u(e,t));var f=o.toString(16);i.target.postMessage({hex:f,workLoad:l}),o.dAddOffset(h,0)}}}f()}(e,t,i,s);return a(e,t,i,s)}(e,c,s.options,i);throw new Error("Invalid prime generation algorithm: "+s.name)}}function a(e,t,r,n){var i=u(e,t),s=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(s=r.millerRabinTests);var o=10;"maxBlockTime"in r&&(o=r.maxBlockTime),c(i,e,t,0,s,o,n)}function c(e,t,r,s,o,a,l){var h=+new Date;do{if(e.bitLength()>t&&(e=u(t,r)),e.isProbablePrime(o))return l(null,e);e.dAddOffset(i[s++%8],0)}while(a<0||+new Date-h<a);n.util.setImmediate((function(){c(e,t,r,s,o,a,l)}))}function u(e,t){var n=new r(e,t),i=e-1;return n.testBit(i)||n.bitwiseTo(r.ONE.shiftLeft(i),o,n),n.dAddOffset(31-n.mod(s).byteValue(),0),n}}()},1513:(e,t,r)=>{var n=r(45);r(3900);var i=null;!n.util.isNodejs||n.options.usePureJavaScript||process.versions["node-webkit"]||(i=r(310)),(e.exports=n.prng=n.prng||{}).create=function(e){for(var t={plugin:e,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},r=e.md,s=new Array(32),o=0;o<32;++o)s[o]=r.create();function a(){if(t.pools[0].messageLength>=32)return c();var e=32-t.pools[0].messageLength<<5;t.collect(t.seedFileSync(e)),c()}function c(){t.reseeds=4294967295===t.reseeds?0:t.reseeds+1;var e=t.plugin.md.create();e.update(t.keyBytes);for(var r=1,n=0;n<32;++n)t.reseeds%r===0&&(e.update(t.pools[n].digest().getBytes()),t.pools[n].start()),r<<=1;t.keyBytes=e.digest().getBytes(),e.start(),e.update(t.keyBytes);var i=e.digest().getBytes();t.key=t.plugin.formatKey(t.keyBytes),t.seed=t.plugin.formatSeed(i),t.generated=0}function u(e){var t=null,r=n.util.globalScope,i=r.crypto||r.msCrypto;i&&i.getRandomValues&&(t=function(e){return i.getRandomValues(e)});var s=n.util.createBuffer();if(t)for(;s.length()<e;){var o=Math.max(1,Math.min(e-s.length(),65536)/4),a=new Uint32Array(Math.floor(o));try{t(a);for(var c=0;c<a.length;++c)s.putInt32(a[c])}catch(f){if(!("undefined"!==typeof QuotaExceededError&&f instanceof QuotaExceededError))throw f}}if(s.length()<e)for(var u,l,h,d=Math.floor(65536*Math.random());s.length()<e;){l=16807*(65535&d),l+=(32767&(u=16807*(d>>16)))<<16,d=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)h=d>>>(c<<3),h^=Math.floor(256*Math.random()),s.putByte(255&h)}return s.getBytes(e)}return t.pools=s,t.pool=0,t.generate=function(e,r){if(!r)return t.generateSync(e);var i=t.plugin.cipher,s=t.plugin.increment,o=t.plugin.formatKey,a=t.plugin.formatSeed,u=n.util.createBuffer();t.key=null,function l(h){if(h)return r(h);if(u.length()>=e)return r(null,u.getBytes(e));t.generated>1048575&&(t.key=null);if(null===t.key)return n.util.nextTick((function(){!function(e){if(t.pools[0].messageLength>=32)return c(),e();var r=32-t.pools[0].messageLength<<5;t.seedFile(r,(function(r,n){if(r)return e(r);t.collect(n),c(),e()}))}(l)}));var d=i(t.key,t.seed);t.generated+=d.length,u.putBytes(d),t.key=o(i(t.key,s(t.seed))),t.seed=a(i(t.key,t.seed)),n.util.setImmediate(l)}()},t.generateSync=function(e){var r=t.plugin.cipher,i=t.plugin.increment,s=t.plugin.formatKey,o=t.plugin.formatSeed;t.key=null;for(var c=n.util.createBuffer();c.length()<e;){t.generated>1048575&&(t.key=null),null===t.key&&a();var u=r(t.key,t.seed);t.generated+=u.length,c.putBytes(u),t.key=s(r(t.key,i(t.seed))),t.seed=o(r(t.key,t.seed))}return c.getBytes(e)},i?(t.seedFile=function(e,t){i.randomBytes(e,(function(e,r){if(e)return t(e);t(null,r.toString())}))},t.seedFileSync=function(e){return i.randomBytes(e).toString()}):(t.seedFile=function(e,t){try{t(null,u(e))}catch(r){t(r)}},t.seedFileSync=u),t.collect=function(e){for(var r=e.length,n=0;n<r;++n)t.pools[t.pool].update(e.substr(n,1)),t.pool=31===t.pool?0:t.pool+1},t.collectInt=function(e,r){for(var n="",i=0;i<r;i+=8)n+=String.fromCharCode(e>>i&255);t.collect(n)},t.registerWorker=function(e){if(e===self)t.seedFile=function(e,t){self.addEventListener("message",(function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))})),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",(function(r){var n=r.data;n.forge&&n.forge.prng&&t.seedFile(n.forge.prng.needed,(function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})}))}))}},t}},2795:(e,t,r)=>{var n=r(45);r(9353),r(3899),r(1513),r(3900),n.random&&n.random.getBytes?e.exports=n.random:function(t){var r={},i=new Array(4),s=n.util.createBuffer();function o(){var e=n.prng.create(r);return e.getBytes=function(t,r){return e.generate(t,r)},e.getBytesSync=function(t){return e.generate(t)},e}r.formatKey=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),n.aes._expandKey(e,!1)},r.formatSeed=function(e){var t=n.util.createBuffer(e);return(e=new Array(4))[0]=t.getInt32(),e[1]=t.getInt32(),e[2]=t.getInt32(),e[3]=t.getInt32(),e},r.cipher=function(e,t){return n.aes._updateBlock(e,t,i,!1),s.putInt32(i[0]),s.putInt32(i[1]),s.putInt32(i[2]),s.putInt32(i[3]),s.getBytes()},r.increment=function(e){return++e[3],e},r.md=n.md.sha256;var a=o(),c=null,u=n.util.globalScope,l=u.crypto||u.msCrypto;if(l&&l.getRandomValues&&(c=function(e){return l.getRandomValues(e)}),n.options.usePureJavaScript||!n.util.isNodejs&&!c){if("undefined"===typeof window||window.document,a.collectInt(+new Date,32),"undefined"!==typeof navigator){var h="";for(var d in navigator)try{"string"==typeof navigator[d]&&(h+=navigator[d])}catch(f){}a.collect(h),h=null}t&&(t().mousemove((function(e){a.collectInt(e.clientX,16),a.collectInt(e.clientY,16)})),t().keypress((function(e){a.collectInt(e.charCode,8)})))}if(n.random)for(var d in a)n.random[d]=a[d];else n.random=a;n.random.createInstance=o,e.exports=n.random}("undefined"!==typeof jQuery?jQuery:null)},1577:(e,t,r)=>{var n=r(45);r(3900);var i=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],s=[1,2,3,5],o=function(e,t){return e<<t&65535|(65535&e)>>16-t},a=function(e,t){return(65535&e)>>t|e<<16-t&65535};e.exports=n.rc2=n.rc2||{},n.rc2.expandKey=function(e,t){"string"===typeof e&&(e=n.util.createBuffer(e)),t=t||128;var r,s=e,o=e.length(),a=t,c=Math.ceil(a/8),u=255>>(7&a);for(r=o;r<128;r++)s.putByte(i[s.at(r-1)+s.at(r-o)&255]);for(s.setAt(128-c,i[s.at(128-c)&u]),r=127-c;r>=0;r--)s.setAt(r,i[s.at(r+1)^s.at(r+c)]);return s};var c=function(e,t,r){var i,c,u,l,h=!1,d=null,f=null,p=null,g=[];for(e=n.rc2.expandKey(e,t),u=0;u<64;u++)g.push(e.getInt16Le());r?(i=function(e){for(u=0;u<4;u++)e[u]+=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=o(e[u],s[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=g[63&e[(u+3)%4]]}):(i=function(e){for(u=3;u>=0;u--)e[u]=a(e[u],s[u]),e[u]-=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=g[63&e[(u+3)%4]]});var b=function(e){var t=[];for(u=0;u<4;u++){var n=d.getInt16Le();null!==p&&(r?n^=p.getInt16Le():p.putInt16Le(n)),t.push(65535&n)}l=r?0:63;for(var i=0;i<e.length;i++)for(var s=0;s<e[i][0];s++)e[i][1](t);for(u=0;u<4;u++)null!==p&&(r?p.putInt16Le(t[u]):t[u]^=p.getInt16Le()),f.putInt16Le(t[u])},y=null;return y={start:function(e,t){e&&"string"===typeof e&&(e=n.util.createBuffer(e)),h=!1,d=n.util.createBuffer(),f=t||new n.util.createBuffer,p=e,y.output=f},update:function(e){for(h||d.putBuffer(e);d.length()>=8;)b([[5,i],[1,c],[6,i],[1,c],[5,i]])},finish:function(e){var t=!0;if(r)if(e)t=e(8,d,!r);else{var n=8===d.length()?8:8-d.length();d.fillWithByte(n,n)}if(t&&(h=!0,y.update()),!r&&(t=0===d.length()))if(e)t=e(8,f,!r);else{var i=f.length(),s=f.at(i-1);s>i?t=!1:f.truncate(s)}return t}}};n.rc2.startEncrypting=function(e,t,r){var i=n.rc2.createEncryptionCipher(e,128);return i.start(t,r),i},n.rc2.createEncryptionCipher=function(e,t){return c(e,t,!0)},n.rc2.startDecrypting=function(e,t,r){var i=n.rc2.createDecryptionCipher(e,128);return i.start(t,r),i},n.rc2.createDecryptionCipher=function(e,t){return c(e,t,!1)}},9408:(e,t,r)=>{var n=r(45);if(r(5465),r(9463),r(3225),r(7668),r(8353),r(2795),r(3900),"undefined"===typeof i)var i=n.jsbn.BigInteger;var s=n.util.isNodejs?r(310):null,o=n.asn1,a=n.util;n.pki=n.pki||{},e.exports=n.pki.rsa=n.rsa=n.rsa||{};var c=n.pki,u=[6,4,2,4,2,4,6,2],l={name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},h={name:"RSAPrivateKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},d={name:"RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:o.Class.UNIVERSAL,type:o.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},f=n.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},p={name:"DigestInfo",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:o.Class.UNIVERSAL,type:o.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:o.Class.UNIVERSAL,type:o.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:o.Class.UNIVERSAL,type:o.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:o.Class.UNIVERSAL,type:o.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},g=function(e){var t;if(!(e.algorithm in c.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=c.oids[e.algorithm];var n=o.oidToDer(t).getBytes(),i=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]),s=o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[]);s.value.push(o.create(o.Class.UNIVERSAL,o.Type.OID,!1,n)),s.value.push(o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,""));var a=o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,e.digest().getBytes());return i.value.push(s),i.value.push(a),o.toDer(i).getBytes()},b=function(e,t,r){if(r)return e.modPow(t.e,t.n);if(!t.p||!t.q)return e.modPow(t.d,t.n);var s;t.dP||(t.dP=t.d.mod(t.p.subtract(i.ONE))),t.dQ||(t.dQ=t.d.mod(t.q.subtract(i.ONE))),t.qInv||(t.qInv=t.q.modInverse(t.p));do{s=new i(n.util.bytesToHex(n.random.getBytes(t.n.bitLength()/8)),16)}while(s.compareTo(t.n)>=0||!s.gcd(t.n).equals(i.ONE));for(var o=(e=e.multiply(s.modPow(t.e,t.n)).mod(t.n)).mod(t.p).modPow(t.dP,t.p),a=e.mod(t.q).modPow(t.dQ,t.q);o.compareTo(a)<0;)o=o.add(t.p);var c=o.subtract(a).multiply(t.qInv).mod(t.p).multiply(t.q).add(a);return c=c.multiply(s.modInverse(t.n)).mod(t.n)};function y(e,t,r){var i=n.util.createBuffer(),s=Math.ceil(t.n.bitLength()/8);if(e.length>s-11){var o=new Error("Message is too long for PKCS#1 v1.5 padding.");throw o.length=e.length,o.max=s-11,o}i.putByte(0),i.putByte(r);var a,c=s-3-e.length;if(0===r||1===r){a=0===r?0:255;for(var u=0;u<c;++u)i.putByte(a)}else for(;c>0;){var l=0,h=n.random.getBytes(c);for(u=0;u<c;++u)0===(a=h.charCodeAt(u))?++l:i.putByte(a);c=l}return i.putByte(0),i.putBytes(e),i}function m(e,t,r,i){var s=Math.ceil(t.n.bitLength()/8),o=n.util.createBuffer(e),a=o.getByte(),c=o.getByte();if(0!==a||r&&0!==c&&1!==c||!r&&2!=c||r&&0===c&&"undefined"===typeof i)throw new Error("Encryption block is invalid.");var u=0;if(0===c){u=s-3-i;for(var l=0;l<u;++l)if(0!==o.getByte())throw new Error("Encryption block is invalid.")}else if(1===c)for(u=0;o.length()>1;){if(255!==o.getByte()){--o.read;break}++u}else if(2===c)for(u=0;o.length()>1;){if(0===o.getByte()){--o.read;break}++u}if(0!==o.getByte()||u!==s-3-o.length())throw new Error("Encryption block is invalid.");return o.getBytes()}function w(e){var t=e.toString(16);t[0]>="8"&&(t="00"+t);var r=n.util.hexToBytes(t);return r.length>1&&(0===r.charCodeAt(0)&&0===(128&r.charCodeAt(1))||255===r.charCodeAt(0)&&128===(128&r.charCodeAt(1)))?r.substr(1):r}function v(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function _(e){return n.util.isNodejs&&"function"===typeof s[e]}function E(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.crypto&&"object"===typeof a.globalScope.crypto.subtle&&"function"===typeof a.globalScope.crypto.subtle[e]}function S(e){return"undefined"!==typeof a.globalScope&&"object"===typeof a.globalScope.msCrypto&&"object"===typeof a.globalScope.msCrypto.subtle&&"function"===typeof a.globalScope.msCrypto.subtle[e]}function A(e){for(var t=n.util.hexToBytes(e.toString(16)),r=new Uint8Array(t.length),i=0;i<t.length;++i)r[i]=t.charCodeAt(i);return r}c.rsa.encrypt=function(e,t,r){var s,o=r,a=Math.ceil(t.n.bitLength()/8);!1!==r&&!0!==r?(o=2===r,s=y(e,t,r)):(s=n.util.createBuffer()).putBytes(e);for(var c=new i(s.toHex(),16),u=b(c,t,o).toString(16),l=n.util.createBuffer(),h=a-Math.ceil(u.length/2);h>0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),l.getBytes()},c.rsa.decrypt=function(e,t,r,s){var o=Math.ceil(t.n.bitLength()/8);if(e.length!==o){var a=new Error("Encrypted message length is invalid.");throw a.length=e.length,a.expected=o,a}var c=new i(n.util.createBuffer(e).toHex(),16);if(c.compareTo(t.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=b(c,t,r).toString(16),l=n.util.createBuffer(),h=o-Math.ceil(u.length/2);h>0;)l.putByte(0),--h;return l.putBytes(n.util.hexToBytes(u)),!1!==s?m(l.getBytes(),t,r):l.getBytes()},c.rsa.createKeyPairGenerationState=function(e,t,r){"string"===typeof e&&(e=parseInt(e,10)),e=e||2048;var s,o=(r=r||{}).prng||n.random,a={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},c=r.algorithm||"PRIMEINC";if("PRIMEINC"!==c)throw new Error("Invalid key generation algorithm: "+c);return(s={algorithm:c,state:0,bits:e,rng:a,eInt:t||65537,e:new i(null),p:null,q:null,qBits:e>>1,pBits:e-(e>>1),pqState:0,num:null,keys:null}).e.fromInt(s.eInt),s},c.rsa.stepKeyPairGenerationState=function(e,t){"algorithm"in e||(e.algorithm="PRIMEINC");var r=new i(null);r.fromInt(30);for(var n,s=0,o=function(e,t){return e|t},a=+new Date,l=0;null===e.keys&&(t<=0||l<t);){if(0===e.state){var h=null===e.p?e.pBits:e.qBits,d=h-1;0===e.pqState?(e.num=new i(h,e.rng),e.num.testBit(d)||e.num.bitwiseTo(i.ONE.shiftLeft(d),o,e.num),e.num.dAddOffset(31-e.num.mod(r).byteValue(),0),s=0,++e.pqState):1===e.pqState?e.num.bitLength()>h?e.pqState=0:e.num.isProbablePrime(v(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(u[s++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(i.ONE).gcd(e.e).compareTo(i.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(i.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var f=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,f,e.p,e.q,f.mod(e.p1),f.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)}}l+=(n=+new Date)-a,a=n}return null!==e.keys},c.rsa.generateKeyPair=function(e,t,r,u){if(1===arguments.length?"object"===typeof e?(r=e,e=void 0):"function"===typeof e&&(u=e,e=void 0):2===arguments.length?"number"===typeof e?"function"===typeof t?(u=t,t=void 0):"number"!==typeof t&&(r=t,t=void 0):(r=e,u=t,e=void 0,t=void 0):3===arguments.length&&("number"===typeof t?"function"===typeof r&&(u=r,r=void 0):(u=r,r=t,t=void 0)),r=r||{},void 0===e&&(e=r.bits||2048),void 0===t&&(t=r.e||65537),!n.options.usePureJavaScript&&!r.prng&&e>=256&&e<=16384&&(65537===t||3===t))if(u){if(_("generateKeyPair"))return s.generateKeyPair("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},(function(e,t,r){if(e)return u(e);u(null,{privateKey:c.privateKeyFromPem(r),publicKey:c.publicKeyFromPem(t)})}));if(E("generateKey")&&E("exportKey"))return a.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:A(t),hash:{name:"SHA-256"}},!0,["sign","verify"]).then((function(e){return a.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)})).then(void 0,(function(e){u(e)})).then((function(e){if(e){var t=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(e)));u(null,{privateKey:t,publicKey:c.setRsaPublicKey(t.n,t.e)})}}));if(S("generateKey")&&S("exportKey")){var l=a.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:A(t),hash:{name:"SHA-256"}},!0,["sign","verify"]);return l.oncomplete=function(e){var t=e.target.result,r=a.globalScope.msCrypto.subtle.exportKey("pkcs8",t.privateKey);r.oncomplete=function(e){var t=e.target.result,r=c.privateKeyFromAsn1(o.fromDer(n.util.createBuffer(t)));u(null,{privateKey:r,publicKey:c.setRsaPublicKey(r.n,r.e)})},r.onerror=function(e){u(e)}},void(l.onerror=function(e){u(e)})}}else if(_("generateKeyPairSync")){var h=s.generateKeyPairSync("rsa",{modulusLength:e,publicExponent:t,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:c.privateKeyFromPem(h.privateKey),publicKey:c.publicKeyFromPem(h.publicKey)}}var d=c.rsa.createKeyPairGenerationState(e,t,r);if(!u)return c.rsa.stepKeyPairGenerationState(d,0),d.keys;!function(e,t,r){"function"===typeof t&&(r=t,t={});t=t||{};var s={algorithm:{name:t.algorithm||"PRIMEINC",options:{workers:t.workers||2,workLoad:t.workLoad||100,workerScript:t.workerScript}}};"prng"in t&&(s.prng=t.prng);function o(){a(e.pBits,(function(t,n){return t?r(t):(e.p=n,null!==e.q?u(t,e.q):void a(e.qBits,u))}))}function a(e,t){n.prime.generateProbablePrime(e,s,t)}function u(t,n){if(t)return r(t);if(e.q=n,e.p.compareTo(e.q)<0){var s=e.p;e.p=e.q,e.q=s}if(0!==e.p.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.p=null,void o();if(0!==e.q.subtract(i.ONE).gcd(e.e).compareTo(i.ONE))return e.q=null,void a(e.qBits,u);if(e.p1=e.p.subtract(i.ONE),e.q1=e.q.subtract(i.ONE),e.phi=e.p1.multiply(e.q1),0!==e.phi.gcd(e.e).compareTo(i.ONE))return e.p=e.q=null,void o();if(e.n=e.p.multiply(e.q),e.n.bitLength()!==e.bits)return e.q=null,void a(e.qBits,u);var l=e.e.modInverse(e.phi);e.keys={privateKey:c.rsa.setPrivateKey(e.n,e.e,l,e.p,e.q,l.mod(e.p1),l.mod(e.q1),e.q.modInverse(e.p)),publicKey:c.rsa.setPublicKey(e.n,e.e)},r(null,e.keys)}o()}(d,r,u)},c.setRsaPublicKey=c.rsa.setPublicKey=function(e,t){var r={n:e,e:t,encrypt:function(e,t,i){if("string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===t)t={encode:function(e,t,r){return y(e,t,2).getBytes()}};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={encode:function(e,t){return n.pkcs1.encode_rsa_oaep(t,e,i)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(t))t={encode:function(e){return e}};else if("string"===typeof t)throw new Error('Unsupported encryption scheme: "'+t+'".');var s=t.encode(e,r,!0);return c.rsa.encrypt(s,r,!0)},verify:function(e,t,i,s){"string"===typeof i?i=i.toUpperCase():void 0===i&&(i="RSASSA-PKCS1-V1_5"),void 0===s&&(s={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in s||(s._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===i?i={verify:function(e,t){t=m(t,r,!0);var i=o.fromDer(t,{parseAllBytes:s._parseAllDigestBytes}),a={},c=[];if(!o.validate(i,p,a,c))throw(u=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=c,u;var u,l=o.derToOid(a.algorithmIdentifier);if(l!==n.oids.md2&&l!==n.oids.md5&&l!==n.oids.sha1&&l!==n.oids.sha224&&l!==n.oids.sha256&&l!==n.oids.sha384&&l!==n.oids.sha512&&l!==n.oids["sha512-224"]&&l!==n.oids["sha512-256"])throw(u=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=l,u;if((l===n.oids.md2||l===n.oids.md5)&&!("parameters"in a))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return e===a.digest}}:"NONE"!==i&&"NULL"!==i&&null!==i||(i={verify:function(e,t){return e===(t=m(t,r,!0))}});var a=c.rsa.decrypt(t,r,!0,!1);return i.verify(e,a,r.n.bitLength())}};return r},c.setRsaPrivateKey=c.rsa.setPrivateKey=function(e,t,r,i,s,o,a,u){var l={n:e,e:t,d:r,p:i,q:s,dP:o,dQ:a,qInv:u,decrypt:function(e,t,r){"string"===typeof t?t=t.toUpperCase():void 0===t&&(t="RSAES-PKCS1-V1_5");var i=c.rsa.decrypt(e,l,!1,!1);if("RSAES-PKCS1-V1_5"===t)t={decode:m};else if("RSA-OAEP"===t||"RSAES-OAEP"===t)t={decode:function(e,t){return n.pkcs1.decode_rsa_oaep(t,e,r)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(t))throw new Error('Unsupported encryption scheme: "'+t+'".');t={decode:function(e){return e}}}return t.decode(i,l,!1)},sign:function(e,t){var r=!1;"string"===typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:g},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,l.n.bitLength());return c.rsa.encrypt(n,l,r)}};return l},c.wrapRsaPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.OCTETSTRING,!1,o.toDer(e).getBytes())])},c.privateKeyFromAsn1=function(e){var t,r,s,a,u,d,f,p,g={},b=[];if(o.validate(e,l,g,b)&&(e=o.fromDer(n.util.createBuffer(g.privateKey))),g={},b=[],!o.validate(e,h,g,b)){var y=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw y.errors=b,y}return t=n.util.createBuffer(g.privateKeyModulus).toHex(),r=n.util.createBuffer(g.privateKeyPublicExponent).toHex(),s=n.util.createBuffer(g.privateKeyPrivateExponent).toHex(),a=n.util.createBuffer(g.privateKeyPrime1).toHex(),u=n.util.createBuffer(g.privateKeyPrime2).toHex(),d=n.util.createBuffer(g.privateKeyExponent1).toHex(),f=n.util.createBuffer(g.privateKeyExponent2).toHex(),p=n.util.createBuffer(g.privateKeyCoefficient).toHex(),c.setRsaPrivateKey(new i(t,16),new i(r,16),new i(s,16),new i(a,16),new i(u,16),new i(d,16),new i(f,16),new i(p,16))},c.privateKeyToAsn1=c.privateKeyToRSAPrivateKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,o.integerToDer(0).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.e)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.d)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.p)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.q)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.dP)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.dQ)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.qInv))])},c.publicKeyFromAsn1=function(e){var t={},r=[];if(o.validate(e,f,t,r)){var s,a=o.derToOid(t.publicKeyOid);if(a!==c.oids.rsaEncryption)throw(s=new Error("Cannot read public key. Unknown OID.")).oid=a,s;e=t.rsaPublicKey}if(r=[],!o.validate(e,d,t,r))throw(s=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=r,s;var u=n.util.createBuffer(t.publicKeyModulus).toHex(),l=n.util.createBuffer(t.publicKeyExponent).toHex();return c.setRsaPublicKey(new i(u,16),new i(l,16))},c.publicKeyToAsn1=c.publicKeyToSubjectPublicKeyInfo=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.OID,!1,o.oidToDer(c.oids.rsaEncryption).getBytes()),o.create(o.Class.UNIVERSAL,o.Type.NULL,!1,"")]),o.create(o.Class.UNIVERSAL,o.Type.BITSTRING,!1,[c.publicKeyToRSAPublicKey(e)])])},c.publicKeyToRSAPublicKey=function(e){return o.create(o.Class.UNIVERSAL,o.Type.SEQUENCE,!0,[o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.n)),o.create(o.Class.UNIVERSAL,o.Type.INTEGER,!1,w(e.e))])}},3753:(e,t,r)=>{var n=r(45);r(5693),r(3900);var i=e.exports=n.sha1=n.sha1||{};n.md.sha1=n.md.algorithms.sha1=i,i.create=function(){o||(s=String.fromCharCode(128),s+=n.util.fillString(String.fromCharCode(0),64),o=!0);var e=null,t=n.util.createBuffer(),r=new Array(80),i={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,s=0;s<r;++s)i.fullMessageLength.push(0);return t=n.util.createBuffer(),e={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},i}};return i.start(),i.update=function(s,o){"utf8"===o&&(s=n.util.encodeUtf8(s));var c=s.length;i.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=c[1],c[1]=c[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return t.putBytes(s),a(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(t.bytes());var c,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h<i.fullMessageLength.length-1;++h)l+=(c=8*i.fullMessageLength[h+1])/4294967296>>>0,o.putInt32(l>>>0),l=c>>>0;o.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4};a(d,r,o);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f},i};var s=null,o=!1;function a(e,t,r){for(var n,i,s,o,a,c,u,l=r.length();l>=64;){for(i=e.h0,s=e.h1,o=e.h2,a=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^s&(o^a))+c+1518500249+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+1859775393+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(s&o|a&(s^o))+c+2400959708+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(s^o^a)+c+3395469782+n,c=a,a=o,o=(s<<30|s>>>2)>>>0,s=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+s|0,e.h2=e.h2+o|0,e.h3=e.h3+a|0,e.h4=e.h4+c|0,l-=64}}},3899:(e,t,r)=>{var n=r(45);r(5693),r(3900);var i=e.exports=n.sha256=n.sha256||{};n.md.sha256=n.md.algorithms.sha256=i,i.create=function(){o||(s=String.fromCharCode(128),s+=n.util.fillString(String.fromCharCode(0),64),a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],o=!0);var e=null,t=n.util.createBuffer(),r=new Array(64),i={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){i.messageLength=0,i.fullMessageLength=i.messageLength64=[];for(var r=i.messageLengthSize/4,s=0;s<r;++s)i.fullMessageLength.push(0);return t=n.util.createBuffer(),e={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},i}};return i.start(),i.update=function(s,o){"utf8"===o&&(s=n.util.encodeUtf8(s));var a=s.length;i.messageLength+=a,a=[a/4294967296>>>0,a>>>0];for(var u=i.fullMessageLength.length-1;u>=0;--u)i.fullMessageLength[u]+=a[1],a[1]=a[0]+(i.fullMessageLength[u]/4294967296>>>0),i.fullMessageLength[u]=i.fullMessageLength[u]>>>0,a[0]=a[1]/4294967296>>>0;return t.putBytes(s),c(e,r,t),(t.read>2048||0===t.length())&&t.compact(),i},i.digest=function(){var o=n.util.createBuffer();o.putBytes(t.bytes());var a,u=i.fullMessageLength[i.fullMessageLength.length-1]+i.messageLengthSize&i.blockLength-1;o.putBytes(s.substr(0,i.blockLength-u));for(var l=8*i.fullMessageLength[0],h=0;h<i.fullMessageLength.length-1;++h)l+=(a=8*i.fullMessageLength[h+1])/4294967296>>>0,o.putInt32(l>>>0),l=a>>>0;o.putInt32(l);var d={h0:e.h0,h1:e.h1,h2:e.h2,h3:e.h3,h4:e.h4,h5:e.h5,h6:e.h6,h7:e.h7};c(d,r,o);var f=n.util.createBuffer();return f.putInt32(d.h0),f.putInt32(d.h1),f.putInt32(d.h2),f.putInt32(d.h3),f.putInt32(d.h4),f.putInt32(d.h5),f.putInt32(d.h6),f.putInt32(d.h7),f},i};var s=null,o=!1,a=null;function c(e,t,r){for(var n,i,s,o,c,u,l,h,d,f,p,g,b,y=r.length();y>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,i=((i=t[c-15])>>>7|i<<25)^(i>>>18|i<<14)^i>>>3,t[c]=n+t[c-7]+i+t[c-16]|0;for(u=e.h0,l=e.h1,h=e.h2,d=e.h3,f=e.h4,p=e.h5,g=e.h6,b=e.h7,c=0;c<64;++c)s=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&l|h&(u^l),n=b+((f>>>6|f<<26)^(f>>>11|f<<21)^(f>>>25|f<<7))+(g^f&(p^g))+a[c]+t[c],b=g,g=p,p=f,f=d+n>>>0,d=h,h=l,l=u,u=n+(i=s+o)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+h|0,e.h3=e.h3+d|0,e.h4=e.h4+f|0,e.h5=e.h5+p|0,e.h6=e.h6+g|0,e.h7=e.h7+b|0,y-=64}}},8138:(e,t,r)=>{var n=r(45);r(5693),r(3900);var i=e.exports=n.sha512=n.sha512||{};n.md.sha512=n.md.algorithms.sha512=i;var s=n.sha384=n.sha512.sha384=n.sha512.sha384||{};s.create=function(){return i.create("SHA-384")},n.md.sha384=n.md.algorithms.sha384=s,n.sha512.sha256=n.sha512.sha256||{create:function(){return i.create("SHA-512/256")}},n.md["sha512/256"]=n.md.algorithms["sha512/256"]=n.sha512.sha256,n.sha512.sha224=n.sha512.sha224||{create:function(){return i.create("SHA-512/224")}},n.md["sha512/224"]=n.md.algorithms["sha512/224"]=n.sha512.sha224,i.create=function(e){if(a||(o=String.fromCharCode(128),o+=n.util.fillString(String.fromCharCode(0),128),c=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(u={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],u["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],u["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],u["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],a=!0),"undefined"===typeof e&&(e="SHA-512"),!(e in u))throw new Error("Invalid SHA-512 algorithm: "+e);for(var t=u[e],r=null,i=n.util.createBuffer(),s=new Array(80),h=0;h<80;++h)s[h]=new Array(2);var d=64;switch(e){case"SHA-384":d=48;break;case"SHA-512/256":d=32;break;case"SHA-512/224":d=28}var f={algorithm:e.replace("-","").toLowerCase(),blockLength:128,digestLength:d,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){f.messageLength=0,f.fullMessageLength=f.messageLength128=[];for(var e=f.messageLengthSize/4,s=0;s<e;++s)f.fullMessageLength.push(0);i=n.util.createBuffer(),r=new Array(t.length);for(s=0;s<t.length;++s)r[s]=t[s].slice(0);return f}};return f.start(),f.update=function(e,t){"utf8"===t&&(e=n.util.encodeUtf8(e));var o=e.length;f.messageLength+=o,o=[o/4294967296>>>0,o>>>0];for(var a=f.fullMessageLength.length-1;a>=0;--a)f.fullMessageLength[a]+=o[1],o[1]=o[0]+(f.fullMessageLength[a]/4294967296>>>0),f.fullMessageLength[a]=f.fullMessageLength[a]>>>0,o[0]=o[1]/4294967296>>>0;return i.putBytes(e),l(r,s,i),(i.read>2048||0===i.length())&&i.compact(),f},f.digest=function(){var t=n.util.createBuffer();t.putBytes(i.bytes());var a,c=f.fullMessageLength[f.fullMessageLength.length-1]+f.messageLengthSize&f.blockLength-1;t.putBytes(o.substr(0,f.blockLength-c));for(var u=8*f.fullMessageLength[0],h=0;h<f.fullMessageLength.length-1;++h)u+=(a=8*f.fullMessageLength[h+1])/4294967296>>>0,t.putInt32(u>>>0),u=a>>>0;t.putInt32(u);var d=new Array(r.length);for(h=0;h<r.length;++h)d[h]=r[h].slice(0);l(d,s,t);var p,g=n.util.createBuffer();p="SHA-512"===e?d.length:"SHA-384"===e?d.length-2:d.length-4;for(h=0;h<p;++h)g.putInt32(d[h][0]),h===p-1&&"SHA-512/224"===e||g.putInt32(d[h][1]);return g},f};var o=null,a=!1,c=null,u=null;function l(e,t,r){for(var n,i,s,o,a,u,l,h,d,f,p,g,b,y,m,w,v,_,E,S,A,k,x,I,C,T,R,P,D,N,B,U,L,M=r.length();M>=128;){for(R=0;R<16;++R)t[R][0]=r.getInt32()>>>0,t[R][1]=r.getInt32()>>>0;for(;R<80;++R)n=(((P=(N=t[R-2])[0])>>>19|(D=N[1])<<13)^(D>>>29|P<<3)^P>>>6)>>>0,i=((P<<13|D>>>19)^(D<<3|P>>>29)^(P<<26|D>>>6))>>>0,s=(((P=(U=t[R-15])[0])>>>1|(D=U[1])<<31)^(P>>>8|D<<24)^P>>>7)>>>0,o=((P<<31|D>>>1)^(P<<24|D>>>8)^(P<<25|D>>>7))>>>0,B=t[R-7],L=t[R-16],D=i+B[1]+o+L[1],t[R][0]=n+B[0]+s+L[0]+(D/4294967296>>>0)>>>0,t[R][1]=D>>>0;for(p=e[0][0],g=e[0][1],b=e[1][0],y=e[1][1],m=e[2][0],w=e[2][1],v=e[3][0],_=e[3][1],E=e[4][0],S=e[4][1],A=e[5][0],k=e[5][1],x=e[6][0],I=e[6][1],C=e[7][0],T=e[7][1],R=0;R<80;++R)l=((E>>>14|S<<18)^(E>>>18|S<<14)^(S>>>9|E<<23))>>>0,h=(x^E&(A^x))>>>0,a=((p>>>28|g<<4)^(g>>>2|p<<30)^(g>>>7|p<<25))>>>0,u=((p<<4|g>>>28)^(g<<30|p>>>2)^(g<<25|p>>>7))>>>0,d=(p&b|m&(p^b))>>>0,f=(g&y|w&(g^y))>>>0,D=T+(((E<<18|S>>>14)^(E<<14|S>>>18)^(S<<23|E>>>9))>>>0)+((I^S&(k^I))>>>0)+c[R][1]+t[R][1],n=C+l+h+c[R][0]+t[R][0]+(D/4294967296>>>0)>>>0,i=D>>>0,s=a+d+((D=u+f)/4294967296>>>0)>>>0,o=D>>>0,C=x,T=I,x=A,I=k,A=E,k=S,E=v+n+((D=_+i)/4294967296>>>0)>>>0,S=D>>>0,v=m,_=w,m=b,w=y,b=p,y=g,p=n+s+((D=i+o)/4294967296>>>0)>>>0,g=D>>>0;D=e[0][1]+g,e[0][0]=e[0][0]+p+(D/4294967296>>>0)>>>0,e[0][1]=D>>>0,D=e[1][1]+y,e[1][0]=e[1][0]+b+(D/4294967296>>>0)>>>0,e[1][1]=D>>>0,D=e[2][1]+w,e[2][0]=e[2][0]+m+(D/4294967296>>>0)>>>0,e[2][1]=D>>>0,D=e[3][1]+_,e[3][0]=e[3][0]+v+(D/4294967296>>>0)>>>0,e[3][1]=D>>>0,D=e[4][1]+S,e[4][0]=e[4][0]+E+(D/4294967296>>>0)>>>0,e[4][1]=D>>>0,D=e[5][1]+k,e[5][0]=e[5][0]+A+(D/4294967296>>>0)>>>0,e[5][1]=D>>>0,D=e[6][1]+I,e[6][0]=e[6][0]+x+(D/4294967296>>>0)>>>0,e[6][1]=D>>>0,D=e[7][1]+T,e[7][0]=e[7][0]+C+(D/4294967296>>>0)>>>0,e[7][1]=D>>>0,M-=128}}},3900:(e,t,r)=>{var n=r(45),i=r(6407),s=e.exports=n.util=n.util||{};function o(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function a(e){if(this.data="",this.read=0,"string"===typeof e)this.data=e;else if(s.isArrayBuffer(e)||s.isArrayBufferView(e))if("undefined"!==typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(n){for(var r=0;r<t.length;++r)this.putByte(t[r])}}else(e instanceof a||"object"===typeof e&&"string"===typeof e.data&&"number"===typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!==typeof process&&process.nextTick&&!process.browser)return s.nextTick=process.nextTick,void("function"===typeof setImmediate?s.setImmediate=setImmediate:s.setImmediate=s.nextTick);if("function"===typeof setImmediate)return s.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(s.nextTick=function(e){return setImmediate(e)});if(s.setImmediate=function(e){setTimeout(e,0)},"undefined"!==typeof window&&"function"===typeof window.postMessage){var e="forge.setImmediate",t=[];s.setImmediate=function(r){t.push(r),1===t.length&&window.postMessage(e,"*")},window.addEventListener("message",(function(r){if(r.source===window&&r.data===e){r.stopPropagation();var n=t.slice();t.length=0,n.forEach((function(e){e()}))}}),!0)}if("undefined"!==typeof MutationObserver){var r=Date.now(),n=!0,i=document.createElement("div");t=[];new MutationObserver((function(){var e=t.slice();t.length=0,e.forEach((function(e){e()}))})).observe(i,{attributes:!0});var o=s.setImmediate;s.setImmediate=function(e){Date.now()-r>15?(r=Date.now(),o(e)):(t.push(e),1===t.length&&i.setAttribute("a",n=!n))}}s.nextTick=s.setImmediate}(),s.isNodejs="undefined"!==typeof process&&process.versions&&process.versions.node,s.globalScope=s.isNodejs?r.g:"undefined"===typeof self?window:self,s.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},s.isArrayBuffer=function(e){return"undefined"!==typeof ArrayBuffer&&e instanceof ArrayBuffer},s.isArrayBufferView=function(e){return e&&s.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},s.ByteBuffer=a,s.ByteStringBuffer=a;s.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},s.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},s.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},s.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},s.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},s.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},s.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(s.encodeUtf8(e))},s.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},s.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},s.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},s.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},s.ByteStringBuffer.prototype.putInt=function(e,t){o(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},s.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},s.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},s.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},s.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},s.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},s.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},s.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},s.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},s.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},s.ByteStringBuffer.prototype.getInt=function(e){o(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},s.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},s.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},s.ByteStringBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},s.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},s.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},s.ByteStringBuffer.prototype.copy=function(){var e=s.createBuffer(this.data);return e.read=this.read,e},s.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},s.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},s.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},s.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},s.ByteStringBuffer.prototype.toString=function(){return s.decodeUtf8(this.bytes())},s.DataBuffer=function(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var r=s.isArrayBuffer(e),n=s.isArrayBufferView(e);if(r||n)return this.data=r?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in t?t.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!==e&&void 0!==e&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)},s.DataBuffer.prototype.length=function(){return this.write-this.read},s.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},s.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},s.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},s.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},s.DataBuffer.prototype.putBytes=function(e,t){if(s.isArrayBufferView(e)){var r=(n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-n.byteOffset;return this.accommodate(r),new Uint8Array(this.data.buffer,this.write).set(n),this.write+=r,this}if(s.isArrayBuffer(e)){var n=new Uint8Array(e);return this.accommodate(n.byteLength),new Uint8Array(this.data.buffer).set(n,this.write),this.write+=n.byteLength,this}if(e instanceof s.DataBuffer||"object"===typeof e&&"number"===typeof e.read&&"number"===typeof e.write&&s.isArrayBufferView(e.data)){n=new Uint8Array(e.data.byteLength,e.read,e.length());return this.accommodate(n.byteLength),new Uint8Array(e.data.byteLength,this.write).set(n),this.write+=n.byteLength,this}if(e instanceof s.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary","string"===typeof e){var i;if("hex"===t)return this.accommodate(Math.ceil(e.length/2)),i=new Uint8Array(this.data.buffer,this.write),this.write+=s.binary.hex.decode(e,i,this.write),this;if("base64"===t)return this.accommodate(3*Math.ceil(e.length/4)),i=new Uint8Array(this.data.buffer,this.write),this.write+=s.binary.base64.decode(e,i,this.write),this;if("utf8"===t&&(e=s.encodeUtf8(e),t="binary"),"binary"===t||"raw"===t)return this.accommodate(e.length),i=new Uint8Array(this.data.buffer,this.write),this.write+=s.binary.raw.decode(i),this;if("utf16"===t)return this.accommodate(2*e.length),i=new Uint16Array(this.data.buffer,this.write),this.write+=s.text.utf16.encode(i),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},s.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},s.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},s.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},s.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},s.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},s.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},s.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},s.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},s.DataBuffer.prototype.putInt=function(e,t){o(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},s.DataBuffer.prototype.putSignedInt=function(e,t){return o(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},s.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},s.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},s.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},s.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},s.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},s.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},s.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},s.DataBuffer.prototype.getInt=function(e){o(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},s.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},s.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},s.DataBuffer.prototype.bytes=function(e){return"undefined"===typeof e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},s.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},s.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},s.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},s.DataBuffer.prototype.copy=function(){return new s.DataBuffer(this)},s.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},s.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},s.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},s.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},s.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return s.binary.raw.encode(t);if("hex"===e)return s.binary.hex.encode(t);if("base64"===e)return s.binary.base64.encode(t);if("utf8"===e)return s.text.utf8.decode(t);if("utf16"===e)return s.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},s.createBuffer=function(e,t){return t=t||"raw",void 0!==e&&"utf8"===t&&(e=s.encodeUtf8(e)),new s.ByteBuffer(e)},s.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},s.xorBytes=function(e,t,r){for(var n="",i="",s="",o=0,a=0;r>0;--r,++o)i=e.charCodeAt(o)^t.charCodeAt(o),a>=10&&(n+=s,s="",a=0),s+=String.fromCharCode(i),++a;return n+=s},s.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},s.bytesToHex=function(e){return s.createBuffer(e).toHex()},s.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],l="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";s.encode64=function(e,t){for(var r,n,i,s="",o="",a=0;a<e.length;)r=e.charCodeAt(a++),n=e.charCodeAt(a++),i=e.charCodeAt(a++),s+=c.charAt(r>>2),s+=c.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=c.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":c.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},s.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,s="",o=0;o<e.length;)t=u[e.charCodeAt(o++)-43],r=u[e.charCodeAt(o++)-43],n=u[e.charCodeAt(o++)-43],i=u[e.charCodeAt(o++)-43],s+=String.fromCharCode(t<<2|r>>4),64!==n&&(s+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(s+=String.fromCharCode((3&n)<<6|i)));return s},s.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},s.decodeUtf8=function(e){return decodeURIComponent(escape(e))},s.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:i.encode,decode:i.decode}},s.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},s.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,s=0;s<e.length;++s)n[i++]=e.charCodeAt(s);return t?i-r:n},s.binary.hex.encode=s.bytesToHex,s.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var i=0,s=r=r||0;for(1&e.length&&(i=1,n[s++]=parseInt(e[0],16));i<e.length;i+=2)n[s++]=parseInt(e.substr(i,2),16);return t?s-r:n},s.binary.base64.encode=function(e,t){for(var r,n,i,s="",o="",a=0;a<e.byteLength;)r=e[a++],n=e[a++],i=e[a++],s+=c.charAt(r>>2),s+=c.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=c.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":c.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},s.binary.base64.decode=function(e,t,r){var n,i,s,o,a=t;a||(a=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var c=0,l=r=r||0;c<e.length;)n=u[e.charCodeAt(c++)-43],i=u[e.charCodeAt(c++)-43],s=u[e.charCodeAt(c++)-43],o=u[e.charCodeAt(c++)-43],a[l++]=n<<2|i>>4,64!==s&&(a[l++]=(15&i)<<4|s>>2,64!==o&&(a[l++]=(3&s)<<6|o));return t?l-r:a.subarray(0,l)},s.binary.base58.encode=function(e,t){return s.binary.baseN.encode(e,l,t)},s.binary.base58.decode=function(e,t){return s.binary.baseN.decode(e,l,t)},s.text={utf8:{},utf16:{}},s.text.utf8.encode=function(e,t,r){e=s.encodeUtf8(e);var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,o=0;o<e.length;++o)n[i++]=e.charCodeAt(o);return t?i-r:n},s.text.utf8.decode=function(e){return s.decodeUtf8(String.fromCharCode.apply(null,e))},s.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var i=new Uint16Array(n.buffer),s=r=r||0,o=r,a=0;a<e.length;++a)i[o++]=e.charCodeAt(a),s+=2;return t?s-r:n},s.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},s.deflate=function(e,t,r){if(t=s.decode64(e.deflate(s.encode64(t)).rval),r){var n=2;32&t.charCodeAt(1)&&(n=6),t=t.substring(n,t.length-4)}return t},s.inflate=function(e,t,r){var n=e.inflate(s.encode64(t)).rval;return null===n?null:s.decode64(n)};var h=function(e,t,r){if(!e)throw new Error("WebStorage not available.");var n;if(null===r?n=e.removeItem(t):(r=s.encode64(JSON.stringify(r)),n=e.setItem(t,r)),"undefined"!==typeof n&&!0!==n.rval){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}},d=function(e,t){if(!e)throw new Error("WebStorage not available.");var r=e.getItem(t);if(e.init)if(null===r.rval){if(r.error){var n=new Error(r.error.message);throw n.id=r.error.id,n.name=r.error.name,n}r=null}else r=r.rval;return null!==r&&(r=JSON.parse(s.decode64(r))),r},f=function(e,t,r,n){var i=d(e,t);null===i&&(i={}),i[r]=n,h(e,t,i)},p=function(e,t,r){var n=d(e,t);return null!==n&&(n=r in n?n[r]:null),n},g=function(e,t,r){var n=d(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var s in n){i=!1;break}i&&(n=null),h(e,t,n)}},b=function(e,t){h(e,t,null)},y=function(e,t,r){var n,i=null;"undefined"===typeof r&&(r=["web","flash"]);var s=!1,o=null;for(var a in r){n=r[a];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");i=e.apply(this,t),s="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),s=!0)}catch(c){o=c}if(s)break}if(!s)throw o;return i};s.setItem=function(e,t,r,n,i){y(f,arguments,i)},s.getItem=function(e,t,r,n){return y(p,arguments,n)},s.removeItem=function(e,t,r,n){y(g,arguments,n)},s.clearItems=function(e,t,r){y(b,arguments,r)},s.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},s.format=function(e){for(var t,r,n=/%./g,i=0,s=[],o=0;t=n.exec(e);){(r=e.substring(o,n.lastIndex-2)).length>0&&s.push(r),o=n.lastIndex;var a=t[0][1];switch(a){case"s":case"o":i<arguments.length?s.push(arguments[1+i++]):s.push("<?>");break;case"%":s.push("%");break;default:s.push("<%"+a+"?>")}}return s.push(e.substring(o)),s.join("")},s.formatNumber=function(e,t,r,n){var i=e,s=isNaN(t=Math.abs(t))?2:t,o=void 0===r?",":r,a=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(s),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+a:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+a)+(s?o+Math.abs(i-u).toFixed(s).slice(2):"")},s.formatSize=function(e){return e=e>=1073741824?s.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?s.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?s.formatNumber(e/1024,0)+" KiB":s.formatNumber(e,0)+" bytes"},s.bytesFromIP=function(e){return-1!==e.indexOf(".")?s.bytesFromIPv4(e):-1!==e.indexOf(":")?s.bytesFromIPv6(e):null},s.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=s.createBuffer(),r=0;r<e.length;++r){var n=parseInt(e[r],10);if(isNaN(n))return null;t.putByte(n)}return t.getBytes()},s.bytesFromIPv6=function(e){for(var t=0,r=2*(8-(e=e.split(":").filter((function(e){return 0===e.length&&++t,!0}))).length+t),n=s.createBuffer(),i=0;i<8;++i)if(e[i]&&0!==e[i].length){var o=s.hexToBytes(e[i]);o.length<2&&n.putByte(0),n.putBytes(o)}else n.fillWithByte(0,r),r=0;return n.getBytes()},s.bytesToIP=function(e){return 4===e.length?s.bytesToIPv4(e):16===e.length?s.bytesToIPv6(e):null},s.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},s.bytesToIPv6=function(e){if(16!==e.length)return null;for(var t=[],r=[],n=0,i=0;i<e.length;i+=2){for(var o=s.bytesToHex(e[i]+e[i+1]);"0"===o[0]&&"0"!==o;)o=o.substr(1);if("0"===o){var a=r[r.length-1],c=t.length;a&&c===a.end+1?(a.end=c,a.end-a.start>r[n].end-r[n].start&&(n=r.length-1)):r.push({start:c,end:c})}t.push(o)}if(r.length>0){var u=r[n];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},s.estimateCores=function(e,t){if("function"===typeof e&&(t=e,e={}),e=e||{},"cores"in s&&!e.update)return t(null,s.cores);if("undefined"!==typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return s.cores=navigator.hardwareConcurrency,t(null,s.cores);if("undefined"===typeof Worker)return s.cores=1,t(null,s.cores);if("undefined"===typeof Blob)return s.cores=2,t(null,s.cores);var r=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",(function(e){for(var t=Date.now(),r=t+4;Date.now()<r;);self.postMessage({st:t,et:r})}))}.toString(),")()"],{type:"application/javascript"}));!function e(n,i,o){if(0===i){var a=Math.floor(n.reduce((function(e,t){return e+t}),0)/n.length);return s.cores=Math.max(1,a),URL.revokeObjectURL(r),t(null,s.cores)}!function(e,t){for(var n=[],i=[],s=0;s<e;++s){var o=new Worker(r);o.addEventListener("message",(function(r){if(i.push(r.data),i.length===e){for(var s=0;s<e;++s)n[s].terminate();t(null,i)}})),n.push(o)}for(s=0;s<e;++s)n[s].postMessage(s)}(o,(function(t,r){n.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],s=r[n]=[],o=0;o<e;++o)if(n!==o){var a=t[o];(i.st>a.st&&i.st<a.et||a.st>i.st&&a.st<i.et)&&s.push(o)}return r.reduce((function(e,t){return Math.max(e,t.length)}),0)}(o,r)),e(n,i-1,o)}))}([],5,16)}},2123:e=>{"use strict";var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(i){return!1}}()?Object.assign:function(e,i){for(var s,o,a=function(e){if(null===e||void 0===e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),c=1;c<arguments.length;c++){for(var u in s=Object(arguments[c]))r.call(s,u)&&(a[u]=s[u]);if(t){o=t(s);for(var l=0;l<o.length;l++)n.call(s,o[l])&&(a[o[l]]=s[o[l]])}}return a}},3338:(e,t,r)=>{"use strict";e.exports=c;var n,i=r(1509),s=i.LongBits,o=i.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function c(e){this.buf=e,this.pos=0,this.len=e.length}var u="undefined"!==typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new c(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new c(e);throw Error("illegal buffer")},l=function(){return i.Buffer?function(e){return(c.create=function(e){return i.Buffer.isBuffer(e)?new n(e):u(e)})(e)}:u};function h(){var e=new s(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function d(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function f(){if(this.pos+8>this.len)throw a(this,8);return new s(d(this.buf,this.pos+=4),d(this.buf,this.pos+=4))}c.create=l(),c.prototype._slice=i.Array.prototype.subarray||i.Array.prototype.slice,c.prototype.uint32=function(){var e=4294967295;return function(){if(e=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return e}}(),c.prototype.int32=function(){return 0|this.uint32()},c.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},c.prototype.bool=function(){return 0!==this.uint32()},c.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return d(this.buf,this.pos+=4)},c.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|d(this.buf,this.pos+=4)},c.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=i.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},c.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=i.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},c.prototype.bytes=function(){var e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw a(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,r);if(t===r){var n=i.Buffer;return n?n.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,r)},c.prototype.string=function(){var e=this.bytes();return o.read(e,0,e.length)},c.prototype.skip=function(e){if("number"===typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},c.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},c._configure=function(e){n=e,c.create=l(),n._configure();var t=i.Long?"toLong":"toNumber";i.merge(c.prototype,{int64:function(){return h.call(this)[t](!1)},uint64:function(){return h.call(this)[t](!0)},sint64:function(){return h.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},7707:(e,t,r)=>{"use strict";e.exports=s;var n=r(3338);(s.prototype=Object.create(n.prototype)).constructor=s;var i=r(1509);function s(e){n.call(this,e)}s._configure=function(){i.Buffer&&(s.prototype._slice=i.Buffer.prototype.slice)},s.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},s._configure()},6350:(e,t,r)=>{"use strict";e.exports=i;var n=r(1509);function i(e,t){this.lo=e>>>0,this.hi=t>>>0}var s=i.zero=new i(0,0);s.toNumber=function(){return 0},s.zzEncode=s.zzDecode=function(){return this},s.length=function(){return 1};var o=i.zeroHash="\0\0\0\0\0\0\0\0";i.fromNumber=function(e){if(0===e)return s;var t=e<0;t&&(e=-e);var r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new i(r,n)},i.from=function(e){if("number"===typeof e)return i.fromNumber(e);if(n.isString(e)){if(!n.Long)return i.fromNumber(parseInt(e,10));e=n.Long.fromString(e)}return e.low||e.high?new i(e.low>>>0,e.high>>>0):s},i.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,r=~this.hi>>>0;return t||(r=r+1>>>0),-(t+4294967296*r)}return this.lo+4294967296*this.hi},i.prototype.toLong=function(e){return n.Long?new n.Long(0|this.lo,0|this.hi,Boolean(e)):{low:0|this.lo,high:0|this.hi,unsigned:Boolean(e)}};var a=String.prototype.charCodeAt;i.fromHash=function(e){return e===o?s:new i((a.call(e,0)|a.call(e,1)<<8|a.call(e,2)<<16|a.call(e,3)<<24)>>>0,(a.call(e,4)|a.call(e,5)<<8|a.call(e,6)<<16|a.call(e,7)<<24)>>>0)},i.prototype.toHash=function(){return String.fromCharCode(255&this.lo,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,255&this.hi,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},i.prototype.zzEncode=function(){var e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this},i.prototype.zzDecode=function(){var e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this},i.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}},1509:function(e,t,r){"use strict";var n=t;function i(e,t,r){for(var n=Object.keys(t),i=0;i<n.length;++i)void 0!==e[n[i]]&&r||(e[n[i]]=t[n[i]]);return e}function s(e){function t(e,r){if(!(this instanceof t))return new t(e,r);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),r&&i(this,r)}return t.prototype=Object.create(Error.prototype,{constructor:{value:t,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return e},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),t}n.asPromise=r(4762),n.base64=r(6762),n.EventEmitter=r(7351),n.float=r(217),n.inquire=r(4882),n.utf8=r(8626),n.pool=r(6931),n.LongBits=r(6350),n.isNode=Boolean("undefined"!==typeof r.g&&r.g&&r.g.process&&r.g.process.versions&&r.g.process.versions.node),n.global=n.isNode&&r.g||"undefined"!==typeof window&&window||"undefined"!==typeof self&&self||this,n.emptyArray=Object.freeze?Object.freeze([]):[],n.emptyObject=Object.freeze?Object.freeze({}):{},n.isInteger=Number.isInteger||function(e){return"number"===typeof e&&isFinite(e)&&Math.floor(e)===e},n.isString=function(e){return"string"===typeof e||e instanceof String},n.isObject=function(e){return e&&"object"===typeof e},n.isset=n.isSet=function(e,t){var r=e[t];return!(null==r||!e.hasOwnProperty(t))&&("object"!==typeof r||(Array.isArray(r)?r.length:Object.keys(r).length)>0)},n.Buffer=function(){try{var e=n.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(t){return null}}(),n._Buffer_from=null,n._Buffer_allocUnsafe=null,n.newBuffer=function(e){return"number"===typeof e?n.Buffer?n._Buffer_allocUnsafe(e):new n.Array(e):n.Buffer?n._Buffer_from(e):"undefined"===typeof Uint8Array?e:new Uint8Array(e)},n.Array="undefined"!==typeof Uint8Array?Uint8Array:Array,n.Long=n.global.dcodeIO&&n.global.dcodeIO.Long||n.global.Long||n.inquire("long"),n.key2Re=/^true|false|0|1$/,n.key32Re=/^-?(?:0|[1-9][0-9]*)$/,n.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,n.longToHash=function(e){return e?n.LongBits.from(e).toHash():n.LongBits.zeroHash},n.longFromHash=function(e,t){var r=n.LongBits.fromHash(e);return n.Long?n.Long.fromBits(r.lo,r.hi,t):r.toNumber(Boolean(t))},n.merge=i,n.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},n.newError=s,n.ProtocolError=s("ProtocolError"),n.oneOfGetter=function(e){for(var t={},r=0;r<e.length;++r)t[e[r]]=1;return function(){for(var e=Object.keys(this),r=e.length-1;r>-1;--r)if(1===t[e[r]]&&void 0!==this[e[r]]&&null!==this[e[r]])return e[r]}},n.oneOfSetter=function(e){return function(t){for(var r=0;r<e.length;++r)e[r]!==t&&delete this[e[r]]}},n.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},n._configure=function(){var e=n.Buffer;e?(n._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,r){return new e(t,r)},n._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):n._Buffer_from=n._Buffer_allocUnsafe=null}},5850:(e,t,r)=>{"use strict";e.exports=h;var n,i=r(1509),s=i.LongBits,o=i.base64,a=i.utf8;function c(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}function u(){}function l(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function h(){this.len=0,this.head=new c(u,0,0),this.tail=this.head,this.states=null}var d=function(){return i.Buffer?function(){return(h.create=function(){return new n})()}:function(){return new h}};function f(e,t,r){t[r]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,r){for(;e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function b(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}h.create=d(),h.alloc=function(e){return new i.Array(e)},i.Array!==Array&&(h.alloc=i.pool(h.alloc,i.Array.prototype.subarray)),h.prototype._push=function(e,t,r){return this.tail=this.tail.next=new c(e,t,r),this.len+=t,this},p.prototype=Object.create(c.prototype),p.prototype.fn=function(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e},h.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new p((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},h.prototype.int32=function(e){return e<0?this._push(g,10,s.fromNumber(e)):this.uint32(e)},h.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},h.prototype.uint64=function(e){var t=s.from(e);return this._push(g,t.length(),t)},h.prototype.int64=h.prototype.uint64,h.prototype.sint64=function(e){var t=s.from(e).zzEncode();return this._push(g,t.length(),t)},h.prototype.bool=function(e){return this._push(f,1,e?1:0)},h.prototype.fixed32=function(e){return this._push(b,4,e>>>0)},h.prototype.sfixed32=h.prototype.fixed32,h.prototype.fixed64=function(e){var t=s.from(e);return this._push(b,4,t.lo)._push(b,4,t.hi)},h.prototype.sfixed64=h.prototype.fixed64,h.prototype.float=function(e){return this._push(i.float.writeFloatLE,4,e)},h.prototype.double=function(e){return this._push(i.float.writeDoubleLE,8,e)};var y=i.Array.prototype.set?function(e,t,r){t.set(e,r)}:function(e,t,r){for(var n=0;n<e.length;++n)t[r+n]=e[n]};h.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(f,1,0);if(i.isString(e)){var r=h.alloc(t=o.length(e));o.decode(e,r,0),e=r}return this.uint32(t)._push(y,t,e)},h.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},h.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new c(u,0,0),this.len=0,this},h.prototype.reset=function(){return this.states?(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 c(u,0,0),this.len=0),this},h.prototype.ldelim=function(){var e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this},h.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),r=0;e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t},h._configure=function(e){n=e,h.create=d(),n._configure()}},3931:(e,t,r)=>{"use strict";e.exports=s;var n=r(5850);(s.prototype=Object.create(n.prototype)).constructor=s;var i=r(1509);function s(){n.call(this)}function o(e,t,r){e.length<40?i.utf8.write(e,t,r):t.utf8Write?t.utf8Write(e,r):t.write(e,r)}s._configure=function(){s.alloc=i._Buffer_allocUnsafe,s.writeBytesBuffer=i.Buffer&&i.Buffer.prototype instanceof Uint8Array&&"set"===i.Buffer.prototype.set.name?function(e,t,r){t.set(e,r)}:function(e,t,r){if(e.copy)e.copy(t,r,0,e.length);else for(var n=0;n<e.length;)t[r++]=e[n++]}},s.prototype.bytes=function(e){i.isString(e)&&(e=i._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(s.writeBytesBuffer,t,e),this},s.prototype.string=function(e){var t=i.Buffer.byteLength(e);return this.uint32(t),t&&this._push(o,t,e),this},s._configure()},8275:(e,t)=>{"use strict";class r{static isArrayBuffer(e){return"[object ArrayBuffer]"===Object.prototype.toString.call(e)}static toArrayBuffer(e){return this.isArrayBuffer(e)?e:e.byteLength===e.buffer.byteLength||0===e.byteOffset&&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){const n=r.toUint8Array(e),i=r.toUint8Array(t);if(n.length!==i.byteLength)return!1;for(let r=0;r<n.length;r++)if(n[r]!==i[r])return!1;return!0}static concat(){let e;for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];e=!Array.isArray(r[0])||r[1]instanceof Function?Array.isArray(r[0])&&r[1]instanceof Function?r[0]:r[r.length-1]instanceof Function?r.slice(0,r.length-1):r:r[0];let i=0;for(const a of e)i+=a.byteLength;const s=new Uint8Array(i);let o=0;for(const a of e){const e=this.toUint8Array(a);s.set(e,o),o+=e.length}return r[r.length-1]instanceof Function?this.toView(s,r[r.length-1]):s.buffer}}const n="string",i=/^[0-9a-f]+$/i,s=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,o=/^[a-zA-Z0-9-_]+$/;class a{static fromString(e){const t=unescape(encodeURIComponent(e)),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r.buffer}static toString(e){const t=r.toUint8Array(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return decodeURIComponent(escape(n))}}class c{static toString(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=r.toArrayBuffer(e),i=new DataView(n);let s="";for(let r=0;r<n.byteLength;r+=2){const e=i.getUint16(r,t);s+=String.fromCharCode(e)}return s}static fromString(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=new ArrayBuffer(2*e.length),n=new DataView(r);for(let i=0;i<e.length;i++)n.setUint16(2*i,e.charCodeAt(i),t);return r}}class u{static isHex(e){return typeof e===n&&i.test(e)}static isBase64(e){return typeof e===n&&s.test(e)}static isBase64Url(e){return typeof e===n&&o.test(e)}static ToString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const n=r.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 c.toString(n,!0);case"utf16":case"utf16be":return c.toString(n);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"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 c.fromString(e,!0);case"utf16":case"utf16be":return c.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=r.toUint8Array(e);if("undefined"!==typeof btoa){const e=this.ToString(t,"binary");return btoa(e)}return Buffer.from(t).toString("base64")}static FromBase64(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!u.isBase64(t))throw new TypeError("Argument 'base64Text' is not Base64 encoded");return"undefined"!==typeof atob?this.FromBinary(atob(t)):new Uint8Array(Buffer.from(t,"base64")).buffer}static FromBase64Url(e){const t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!u.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){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.FromBinary(e);case"utf8":return a.fromString(e);case"utf16":case"utf16be":return c.fromString(e);case"utf16le":case"usc2":return c.fromString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToUtf8String(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:u.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.ToBinary(e);case"utf8":return a.toString(e);case"utf16":case"utf16be":return c.toString(e);case"utf16le":case"usc2":return c.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,r=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);return r.buffer}static ToBinary(e){const t=r.toUint8Array(e);let n="";for(let r=0;r<t.length;r++)n+=String.fromCharCode(t[r]);return n}static ToHex(e){const t=r.toUint8Array(e);let n="";const i=t.length;for(let r=0;r<i;r++){const e=t[r];e<16&&(n+="0"),n+=e.toString(16)}return n}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!u.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2){const e=t.slice(n,n+2);r[n/2]=parseInt(e,16)}return r.buffer}static ToUtf16String(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return c.toString(e,t)}static FromUtf16String(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return c.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let r=0;r<t;r++)e+="=";return e}static formatString(e){return(null===e||void 0===e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}u.DEFAULT_UTF8_ENCODING="utf8",t._H=r,t.U$=u},2730:(e,t,r)=>{"use strict";var n=r(5043),i=r(2123),s=r(8853);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}if(!n)throw Error(o(227));var a=new Set,c={};function u(e,t){l(e,t),l(e+"Capture",t)}function l(e,t){for(c[e]=t,e=0;e<t.length;e++)a.add(t[e])}var h=!("undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement),d=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f=Object.prototype.hasOwnProperty,p={},g={};function b(e,t,r,n,i,s,o){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=r,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=o}var y={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){y[e]=new b(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var t=e[0];y[t]=new b(t,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){y[e]=new b(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){y[e]=new b(e,2,!1,e,null,!1,!1)})),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach((function(e){y[e]=new b(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){y[e]=new b(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){y[e]=new b(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){y[e]=new b(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){y[e]=new b(e,5,!1,e.toLowerCase(),null,!1,!1)}));var m=/[\-:]([a-z])/g;function w(e){return e[1].toUpperCase()}function v(e,t,r,n){var i=y.hasOwnProperty(t)?y[t]:null;(null!==i?0===i.type:!n&&(2<t.length&&("o"===t[0]||"O"===t[0])&&("n"===t[1]||"N"===t[1])))||(function(e,t,r,n){if(null===t||"undefined"===typeof t||function(e,t,r,n){if(null!==r&&0===r.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!n&&(null!==r?!r.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,r,n))return!0;if(n)return!1;if(null!==r)switch(r.type){case 3:return!t;case 4:return!1===t;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}(t,r,i,n)&&(r=null),n||null===i?function(e){return!!f.call(g,e)||!f.call(p,e)&&(d.test(e)?g[e]=!0:(p[e]=!0,!1))}(t)&&(null===r?e.removeAttribute(t):e.setAttribute(t,""+r)):i.mustUseProperty?e[i.propertyName]=null===r?3!==i.type&&"":r:(t=i.attributeName,n=i.attributeNamespace,null===r?e.removeAttribute(t):(r=3===(i=i.type)||4===i&&!0===r?"":""+r,n?e.setAttributeNS(n,t,r):e.setAttribute(t,r))))}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach((function(e){var t=e.replace(m,w);y[t]=new b(t,1,!1,e,null,!1,!1)})),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach((function(e){var t=e.replace(m,w);y[t]=new b(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((function(e){var t=e.replace(m,w);y[t]=new b(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((function(e){y[e]=new b(e,1,!1,e.toLowerCase(),null,!1,!1)})),y.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((function(e){y[e]=new b(e,1,!1,e.toLowerCase(),null,!0,!0)}));var _=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=60103,S=60106,A=60107,k=60108,x=60114,I=60109,C=60110,T=60112,R=60113,P=60120,D=60115,N=60116,B=60121,U=60128,L=60129,M=60130,O=60131;if("function"===typeof Symbol&&Symbol.for){var q=Symbol.for;E=q("react.element"),S=q("react.portal"),A=q("react.fragment"),k=q("react.strict_mode"),x=q("react.profiler"),I=q("react.provider"),C=q("react.context"),T=q("react.forward_ref"),R=q("react.suspense"),P=q("react.suspense_list"),D=q("react.memo"),N=q("react.lazy"),B=q("react.block"),q("react.scope"),U=q("react.opaque.id"),L=q("react.debug_trace_mode"),M=q("react.offscreen"),O=q("react.legacy_hidden")}var K,F="function"===typeof Symbol&&Symbol.iterator;function V(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=F&&e[F]||e["@@iterator"])?e:null}function z(e){if(void 0===K)try{throw Error()}catch(r){var t=r.stack.trim().match(/\n( *(at )?)/);K=t&&t[1]||""}return"\n"+K+e}var $=!1;function H(e,t){if(!e||$)return"";$=!0;var r=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),"object"===typeof Reflect&&Reflect.construct){try{Reflect.construct(t,[])}catch(c){var n=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){n=c}e.call(t.prototype)}else{try{throw Error()}catch(c){n=c}e()}}catch(c){if(c&&n&&"string"===typeof c.stack){for(var i=c.stack.split("\n"),s=n.stack.split("\n"),o=i.length-1,a=s.length-1;1<=o&&0<=a&&i[o]!==s[a];)a--;for(;1<=o&&0<=a;o--,a--)if(i[o]!==s[a]){if(1!==o||1!==a)do{if(o--,0>--a||i[o]!==s[a])return"\n"+i[o].replace(" at new "," at ")}while(1<=o&&0<=a);break}}}finally{$=!1,Error.prepareStackTrace=r}return(e=e?e.displayName||e.name:"")?z(e):""}function j(e){switch(e.tag){case 5:return z(e.type);case 16:return z("Lazy");case 13:return z("Suspense");case 19:return z("SuspenseList");case 0:case 2:case 15:return e=H(e.type,!1);case 11:return e=H(e.type.render,!1);case 22:return e=H(e.type._render,!1);case 1:return e=H(e.type,!0);default:return""}}function G(e){if(null==e)return null;if("function"===typeof e)return e.displayName||e.name||null;if("string"===typeof e)return e;switch(e){case A:return"Fragment";case S:return"Portal";case x:return"Profiler";case k:return"StrictMode";case R:return"Suspense";case P:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case C:return(e.displayName||"Context")+".Consumer";case I:return(e._context.displayName||"Context")+".Provider";case T:var t=e.render;return t=t.displayName||t.name||"",e.displayName||(""!==t?"ForwardRef("+t+")":"ForwardRef");case D:return G(e.type);case B:return G(e._render);case N:t=e._payload,e=e._init;try{return G(e(t))}catch(r){}}return null}function W(e){switch(typeof e){case"boolean":case"number":case"object":case"string":case"undefined":return e;default:return""}}function Y(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function Q(e){e._valueTracker||(e._valueTracker=function(e){var t=Y(e)?"checked":"value",r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),n=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof r&&"function"===typeof r.get&&"function"===typeof r.set){var i=r.get,s=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=""+e,s.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function J(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var r=t.getValue(),n="";return e&&(n=Y(e)?e.checked?"true":"false":e.value),(e=n)!==r&&(t.setValue(e),!0)}function X(e){if("undefined"===typeof(e=e||("undefined"!==typeof document?document:void 0)))return null;try{return e.activeElement||e.body}catch(t){return e.body}}function Z(e,t){var r=t.checked;return i({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=r?r:e._wrapperState.initialChecked})}function ee(e,t){var r=null==t.defaultValue?"":t.defaultValue,n=null!=t.checked?t.checked:t.defaultChecked;r=W(null!=t.value?t.value:r),e._wrapperState={initialChecked:n,initialValue:r,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function te(e,t){null!=(t=t.checked)&&v(e,"checked",t,!1)}function re(e,t){te(e,t);var r=W(t.value),n=t.type;if(null!=r)"number"===n?(0===r&&""===e.value||e.value!=r)&&(e.value=""+r):e.value!==""+r&&(e.value=""+r);else if("submit"===n||"reset"===n)return void e.removeAttribute("value");t.hasOwnProperty("value")?ie(e,t.type,r):t.hasOwnProperty("defaultValue")&&ie(e,t.type,W(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function ne(e,t,r){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var n=t.type;if(!("submit"!==n&&"reset"!==n||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,r||t===e.value||(e.value=t),e.defaultValue=t}""!==(r=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==r&&(e.name=r)}function ie(e,t,r){"number"===t&&X(e.ownerDocument)===e||(null==r?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+r&&(e.defaultValue=""+r))}function se(e,t){return e=i({children:void 0},t),(t=function(e){var t="";return n.Children.forEach(e,(function(e){null!=e&&(t+=e)})),t}(t.children))&&(e.children=t),e}function oe(e,t,r,n){if(e=e.options,t){t={};for(var i=0;i<r.length;i++)t["$"+r[i]]=!0;for(r=0;r<e.length;r++)i=t.hasOwnProperty("$"+e[r].value),e[r].selected!==i&&(e[r].selected=i),i&&n&&(e[r].defaultSelected=!0)}else{for(r=""+W(r),t=null,i=0;i<e.length;i++){if(e[i].value===r)return e[i].selected=!0,void(n&&(e[i].defaultSelected=!0));null!==t||e[i].disabled||(t=e[i])}null!==t&&(t.selected=!0)}}function ae(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(o(91));return i({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function ce(e,t){var r=t.value;if(null==r){if(r=t.children,t=t.defaultValue,null!=r){if(null!=t)throw Error(o(92));if(Array.isArray(r)){if(!(1>=r.length))throw Error(o(93));r=r[0]}t=r}null==t&&(t=""),r=t}e._wrapperState={initialValue:W(r)}}function ue(e,t){var r=W(t.value),n=W(t.defaultValue);null!=r&&((r=""+r)!==e.value&&(e.value=r),null==t.defaultValue&&e.defaultValue!==r&&(e.defaultValue=r)),null!=n&&(e.defaultValue=""+n)}function le(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}var he={html:"http://www.w3.org/1999/xhtml",mathml:"http://www.w3.org/1998/Math/MathML",svg:"http://www.w3.org/2000/svg"};function de(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function fe(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?de(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var pe,ge,be=(ge=function(e,t){if(e.namespaceURI!==he.svg||"innerHTML"in e)e.innerHTML=t;else{for((pe=pe||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=pe.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!==typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,r,n){MSApp.execUnsafeLocalFunction((function(){return ge(e,t)}))}:ge);function ye(e,t){if(t){var r=e.firstChild;if(r&&r===e.lastChild&&3===r.nodeType)return void(r.nodeValue=t)}e.textContent=t}var me={animationIterationCount:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},we=["Webkit","ms","Moz","O"];function ve(e,t,r){return null==t||"boolean"===typeof t||""===t?"":r||"number"!==typeof t||0===t||me.hasOwnProperty(e)&&me[e]?(""+t).trim():t+"px"}function _e(e,t){for(var r in e=e.style,t)if(t.hasOwnProperty(r)){var n=0===r.indexOf("--"),i=ve(r,t[r],n);"float"===r&&(r="cssFloat"),n?e.setProperty(r,i):e[r]=i}}Object.keys(me).forEach((function(e){we.forEach((function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),me[t]=me[e]}))}));var Ee=i({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Se(e,t){if(t){if(Ee[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(o(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(o(60));if("object"!==typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(o(61))}if(null!=t.style&&"object"!==typeof t.style)throw Error(o(62))}}function Ae(e,t){if(-1===e.indexOf("-"))return"string"===typeof t.is;switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}function ke(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var xe=null,Ie=null,Ce=null;function Te(e){if(e=ri(e)){if("function"!==typeof xe)throw Error(o(280));var t=e.stateNode;t&&(t=ii(t),xe(e.stateNode,e.type,t))}}function Re(e){Ie?Ce?Ce.push(e):Ce=[e]:Ie=e}function Pe(){if(Ie){var e=Ie,t=Ce;if(Ce=Ie=null,Te(e),t)for(e=0;e<t.length;e++)Te(t[e])}}function De(e,t){return e(t)}function Ne(e,t,r,n,i){return e(t,r,n,i)}function Be(){}var Ue=De,Le=!1,Me=!1;function Oe(){null===Ie&&null===Ce||(Be(),Pe())}function qe(e,t){var r=e.stateNode;if(null===r)return null;var n=ii(r);if(null===n)return null;r=n[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(n=!n.disabled)||(n=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!n;break e;default:e=!1}if(e)return null;if(r&&"function"!==typeof r)throw Error(o(231,t,typeof r));return r}var Ke=!1;if(h)try{var Fe={};Object.defineProperty(Fe,"passive",{get:function(){Ke=!0}}),window.addEventListener("test",Fe,Fe),window.removeEventListener("test",Fe,Fe)}catch(ge){Ke=!1}function Ve(e,t,r,n,i,s,o,a,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(r,u)}catch(l){this.onError(l)}}var ze=!1,$e=null,He=!1,je=null,Ge={onError:function(e){ze=!0,$e=e}};function We(e,t,r,n,i,s,o,a,c){ze=!1,$e=null,Ve.apply(Ge,arguments)}function Ye(e){var t=e,r=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!==(1026&(t=e).flags)&&(r=t.return),e=t.return}while(e)}return 3===t.tag?r:null}function Qe(e){if(13===e.tag){var t=e.memoizedState;if(null===t&&(null!==(e=e.alternate)&&(t=e.memoizedState)),null!==t)return t.dehydrated}return null}function Je(e){if(Ye(e)!==e)throw Error(o(188))}function Xe(e){if(e=function(e){var t=e.alternate;if(!t){if(null===(t=Ye(e)))throw Error(o(188));return t!==e?null:e}for(var r=e,n=t;;){var i=r.return;if(null===i)break;var s=i.alternate;if(null===s){if(null!==(n=i.return)){r=n;continue}break}if(i.child===s.child){for(s=i.child;s;){if(s===r)return Je(i),e;if(s===n)return Je(i),t;s=s.sibling}throw Error(o(188))}if(r.return!==n.return)r=i,n=s;else{for(var a=!1,c=i.child;c;){if(c===r){a=!0,r=i,n=s;break}if(c===n){a=!0,n=i,r=s;break}c=c.sibling}if(!a){for(c=s.child;c;){if(c===r){a=!0,r=s,n=i;break}if(c===n){a=!0,n=s,r=i;break}c=c.sibling}if(!a)throw Error(o(189))}}if(r.alternate!==n)throw Error(o(190))}if(3!==r.tag)throw Error(o(188));return r.stateNode.current===r?e:t}(e),!e)return null;for(var t=e;;){if(5===t.tag||6===t.tag)return t;if(t.child)t.child.return=t,t=t.child;else{if(t===e)break;for(;!t.sibling;){if(!t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}}return null}function Ze(e,t){for(var r=e.alternate;null!==t;){if(t===e||t===r)return!0;t=t.return}return!1}var et,tt,rt,nt,it=!1,st=[],ot=null,at=null,ct=null,ut=new Map,lt=new Map,ht=[],dt="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function ft(e,t,r,n,i){return{blockedOn:e,domEventName:t,eventSystemFlags:16|r,nativeEvent:i,targetContainers:[n]}}function pt(e,t){switch(e){case"focusin":case"focusout":ot=null;break;case"dragenter":case"dragleave":at=null;break;case"mouseover":case"mouseout":ct=null;break;case"pointerover":case"pointerout":ut.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":lt.delete(t.pointerId)}}function gt(e,t,r,n,i,s){return null===e||e.nativeEvent!==s?(e=ft(t,r,n,i,s),null!==t&&(null!==(t=ri(t))&&tt(t)),e):(e.eventSystemFlags|=n,t=e.targetContainers,null!==i&&-1===t.indexOf(i)&&t.push(i),e)}function bt(e){var t=ti(e.target);if(null!==t){var r=Ye(t);if(null!==r)if(13===(t=r.tag)){if(null!==(t=Qe(r)))return e.blockedOn=t,void nt(e.lanePriority,(function(){s.unstable_runWithPriority(e.priority,(function(){rt(r)}))}))}else if(3===t&&r.stateNode.hydrate)return void(e.blockedOn=3===r.tag?r.stateNode.containerInfo:null)}e.blockedOn=null}function yt(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var r=Xt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==r)return null!==(t=ri(r))&&tt(t),e.blockedOn=r,!1;t.shift()}return!0}function mt(e,t,r){yt(e)&&r.delete(t)}function wt(){for(it=!1;0<st.length;){var e=st[0];if(null!==e.blockedOn){null!==(e=ri(e.blockedOn))&&et(e);break}for(var t=e.targetContainers;0<t.length;){var r=Xt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==r){e.blockedOn=r;break}t.shift()}null===e.blockedOn&&st.shift()}null!==ot&&yt(ot)&&(ot=null),null!==at&&yt(at)&&(at=null),null!==ct&&yt(ct)&&(ct=null),ut.forEach(mt),lt.forEach(mt)}function vt(e,t){e.blockedOn===t&&(e.blockedOn=null,it||(it=!0,s.unstable_scheduleCallback(s.unstable_NormalPriority,wt)))}function _t(e){function t(t){return vt(t,e)}if(0<st.length){vt(st[0],e);for(var r=1;r<st.length;r++){var n=st[r];n.blockedOn===e&&(n.blockedOn=null)}}for(null!==ot&&vt(ot,e),null!==at&&vt(at,e),null!==ct&&vt(ct,e),ut.forEach(t),lt.forEach(t),r=0;r<ht.length;r++)(n=ht[r]).blockedOn===e&&(n.blockedOn=null);for(;0<ht.length&&null===(r=ht[0]).blockedOn;)bt(r),null===r.blockedOn&&ht.shift()}function Et(e,t){var r={};return r[e.toLowerCase()]=t.toLowerCase(),r["Webkit"+e]="webkit"+t,r["Moz"+e]="moz"+t,r}var St={animationend:Et("Animation","AnimationEnd"),animationiteration:Et("Animation","AnimationIteration"),animationstart:Et("Animation","AnimationStart"),transitionend:Et("Transition","TransitionEnd")},At={},kt={};function xt(e){if(At[e])return At[e];if(!St[e])return e;var t,r=St[e];for(t in r)if(r.hasOwnProperty(t)&&t in kt)return At[e]=r[t];return e}h&&(kt=document.createElement("div").style,"AnimationEvent"in window||(delete St.animationend.animation,delete St.animationiteration.animation,delete St.animationstart.animation),"TransitionEvent"in window||delete St.transitionend.transition);var It=xt("animationend"),Ct=xt("animationiteration"),Tt=xt("animationstart"),Rt=xt("transitionend"),Pt=new Map,Dt=new Map,Nt=["abort","abort",It,"animationEnd",Ct,"animationIteration",Tt,"animationStart","canplay","canPlay","canplaythrough","canPlayThrough","durationchange","durationChange","emptied","emptied","encrypted","encrypted","ended","ended","error","error","gotpointercapture","gotPointerCapture","load","load","loadeddata","loadedData","loadedmetadata","loadedMetadata","loadstart","loadStart","lostpointercapture","lostPointerCapture","playing","playing","progress","progress","seeking","seeking","stalled","stalled","suspend","suspend","timeupdate","timeUpdate",Rt,"transitionEnd","waiting","waiting"];function Bt(e,t){for(var r=0;r<e.length;r+=2){var n=e[r],i=e[r+1];i="on"+(i[0].toUpperCase()+i.slice(1)),Dt.set(n,t),Pt.set(n,i),u(i,[n])}}(0,s.unstable_now)();var Ut=8;function Lt(e){if(0!==(1&e))return Ut=15,1;if(0!==(2&e))return Ut=14,2;if(0!==(4&e))return Ut=13,4;var t=24&e;return 0!==t?(Ut=12,t):0!==(32&e)?(Ut=11,32):0!==(t=192&e)?(Ut=10,t):0!==(256&e)?(Ut=9,256):0!==(t=3584&e)?(Ut=8,t):0!==(4096&e)?(Ut=7,4096):0!==(t=4186112&e)?(Ut=6,t):0!==(t=62914560&e)?(Ut=5,t):67108864&e?(Ut=4,67108864):0!==(134217728&e)?(Ut=3,134217728):0!==(t=805306368&e)?(Ut=2,t):0!==(1073741824&e)?(Ut=1,1073741824):(Ut=8,e)}function Mt(e,t){var r=e.pendingLanes;if(0===r)return Ut=0;var n=0,i=0,s=e.expiredLanes,o=e.suspendedLanes,a=e.pingedLanes;if(0!==s)n=s,i=Ut=15;else if(0!==(s=134217727&r)){var c=s&~o;0!==c?(n=Lt(c),i=Ut):0!==(a&=s)&&(n=Lt(a),i=Ut)}else 0!==(s=r&~o)?(n=Lt(s),i=Ut):0!==a&&(n=Lt(a),i=Ut);if(0===n)return 0;if(n=r&((0>(n=31-zt(n))?0:1<<n)<<1)-1,0!==t&&t!==n&&0===(t&o)){if(Lt(t),i<=Ut)return t;Ut=i}if(0!==(t=e.entangledLanes))for(e=e.entanglements,t&=n;0<t;)i=1<<(r=31-zt(t)),n|=e[r],t&=~i;return n}function Ot(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function qt(e,t){switch(e){case 15:return 1;case 14:return 2;case 12:return 0===(e=Kt(24&~t))?qt(10,t):e;case 10:return 0===(e=Kt(192&~t))?qt(8,t):e;case 8:return 0===(e=Kt(3584&~t))&&(0===(e=Kt(4186112&~t))&&(e=512)),e;case 2:return 0===(t=Kt(805306368&~t))&&(t=268435456),t}throw Error(o(358,e))}function Kt(e){return e&-e}function Ft(e){for(var t=[],r=0;31>r;r++)t.push(e);return t}function Vt(e,t,r){e.pendingLanes|=t;var n=t-1;e.suspendedLanes&=n,e.pingedLanes&=n,(e=e.eventTimes)[t=31-zt(t)]=r}var zt=Math.clz32?Math.clz32:function(e){return 0===e?32:31-($t(e)/Ht|0)|0},$t=Math.log,Ht=Math.LN2;var jt=s.unstable_UserBlockingPriority,Gt=s.unstable_runWithPriority,Wt=!0;function Yt(e,t,r,n){Le||Be();var i=Jt,s=Le;Le=!0;try{Ne(i,e,t,r,n)}finally{(Le=s)||Oe()}}function Qt(e,t,r,n){Gt(jt,Jt.bind(null,e,t,r,n))}function Jt(e,t,r,n){var i;if(Wt)if((i=0===(4&t))&&0<st.length&&-1<dt.indexOf(e))e=ft(null,e,t,r,n),st.push(e);else{var s=Xt(e,t,r,n);if(null===s)i&&pt(e,n);else{if(i){if(-1<dt.indexOf(e))return e=ft(s,e,t,r,n),void st.push(e);if(function(e,t,r,n,i){switch(t){case"focusin":return ot=gt(ot,e,t,r,n,i),!0;case"dragenter":return at=gt(at,e,t,r,n,i),!0;case"mouseover":return ct=gt(ct,e,t,r,n,i),!0;case"pointerover":var s=i.pointerId;return ut.set(s,gt(ut.get(s)||null,e,t,r,n,i)),!0;case"gotpointercapture":return s=i.pointerId,lt.set(s,gt(lt.get(s)||null,e,t,r,n,i)),!0}return!1}(s,e,t,r,n))return;pt(e,n)}Bn(e,t,n,null,r)}}}function Xt(e,t,r,n){var i=ke(n);if(null!==(i=ti(i))){var s=Ye(i);if(null===s)i=null;else{var o=s.tag;if(13===o){if(null!==(i=Qe(s)))return i;i=null}else if(3===o){if(s.stateNode.hydrate)return 3===s.tag?s.stateNode.containerInfo:null;i=null}else s!==i&&(i=null)}}return Bn(e,t,n,i,r),null}var Zt=null,er=null,tr=null;function rr(){if(tr)return tr;var e,t,r=er,n=r.length,i="value"in Zt?Zt.value:Zt.textContent,s=i.length;for(e=0;e<n&&r[e]===i[e];e++);var o=n-e;for(t=1;t<=o&&r[n-t]===i[s-t];t++);return tr=i.slice(e,1<t?1-t:void 0)}function nr(e){var t=e.keyCode;return"charCode"in e?0===(e=e.charCode)&&13===t&&(e=13):e=t,10===e&&(e=13),32<=e||13===e?e:0}function ir(){return!0}function sr(){return!1}function or(e){function t(t,r,n,i,s){for(var o in this._reactName=t,this._targetInst=n,this.type=r,this.nativeEvent=i,this.target=s,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(null!=i.defaultPrevented?i.defaultPrevented:!1===i.returnValue)?ir:sr,this.isPropagationStopped=sr,this}return i(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():"unknown"!==typeof e.returnValue&&(e.returnValue=!1),this.isDefaultPrevented=ir)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!==typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=ir)},persist:function(){},isPersistent:ir}),t}var ar,cr,ur,lr={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hr=or(lr),dr=i({},lr,{view:0,detail:0}),fr=or(dr),pr=i({},dr,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:xr,button:0,buttons:0,relatedTarget:function(e){return void 0===e.relatedTarget?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==ur&&(ur&&"mousemove"===e.type?(ar=e.screenX-ur.screenX,cr=e.screenY-ur.screenY):cr=ar=0,ur=e),ar)},movementY:function(e){return"movementY"in e?e.movementY:cr}}),gr=or(pr),br=or(i({},pr,{dataTransfer:0})),yr=or(i({},dr,{relatedTarget:0})),mr=or(i({},lr,{animationName:0,elapsedTime:0,pseudoElement:0})),wr=i({},lr,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),vr=or(wr),_r=or(i({},lr,{data:0})),Er={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Sr={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},Ar={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function kr(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=Ar[e])&&!!t[e]}function xr(){return kr}var Ir=i({},dr,{key:function(e){if(e.key){var t=Er[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=nr(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?Sr[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:xr,charCode:function(e){return"keypress"===e.type?nr(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?nr(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),Cr=or(Ir),Tr=or(i({},pr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Rr=or(i({},dr,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:xr})),Pr=or(i({},lr,{propertyName:0,elapsedTime:0,pseudoElement:0})),Dr=i({},pr,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),Nr=or(Dr),Br=[9,13,27,32],Ur=h&&"CompositionEvent"in window,Lr=null;h&&"documentMode"in document&&(Lr=document.documentMode);var Mr=h&&"TextEvent"in window&&!Lr,Or=h&&(!Ur||Lr&&8<Lr&&11>=Lr),qr=String.fromCharCode(32),Kr=!1;function Fr(e,t){switch(e){case"keyup":return-1!==Br.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Vr(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var zr=!1;var $r={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!$r[e.type]:"textarea"===t}function jr(e,t,r,n){Re(n),0<(t=Ln(t,"onChange")).length&&(r=new hr("onChange","change",null,r,n),e.push({event:r,listeners:t}))}var Gr=null,Wr=null;function Yr(e){Cn(e,0)}function Qr(e){if(J(ni(e)))return e}function Jr(e,t){if("change"===e)return t}var Xr=!1;if(h){var Zr;if(h){var en="oninput"in document;if(!en){var tn=document.createElement("div");tn.setAttribute("oninput","return;"),en="function"===typeof tn.oninput}Zr=en}else Zr=!1;Xr=Zr&&(!document.documentMode||9<document.documentMode)}function rn(){Gr&&(Gr.detachEvent("onpropertychange",nn),Wr=Gr=null)}function nn(e){if("value"===e.propertyName&&Qr(Wr)){var t=[];if(jr(t,Wr,e,ke(e)),e=Yr,Le)e(t);else{Le=!0;try{De(e,t)}finally{Le=!1,Oe()}}}}function sn(e,t,r){"focusin"===e?(rn(),Wr=r,(Gr=t).attachEvent("onpropertychange",nn)):"focusout"===e&&rn()}function on(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Qr(Wr)}function an(e,t){if("click"===e)return Qr(t)}function cn(e,t){if("input"===e||"change"===e)return Qr(t)}var un="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t},ln=Object.prototype.hasOwnProperty;function hn(e,t){if(un(e,t))return!0;if("object"!==typeof e||null===e||"object"!==typeof t||null===t)return!1;var r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(n=0;n<r.length;n++)if(!ln.call(t,r[n])||!un(e[r[n]],t[r[n]]))return!1;return!0}function dn(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fn(e,t){var r,n=dn(e);for(e=0;n;){if(3===n.nodeType){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=dn(n)}}function pn(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?pn(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function gn(){for(var e=window,t=X();t instanceof e.HTMLIFrameElement;){try{var r="string"===typeof t.contentWindow.location.href}catch(n){r=!1}if(!r)break;t=X((e=t.contentWindow).document)}return t}function bn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&("input"===t&&("text"===e.type||"search"===e.type||"tel"===e.type||"url"===e.type||"password"===e.type)||"textarea"===t||"true"===e.contentEditable)}var yn=h&&"documentMode"in document&&11>=document.documentMode,mn=null,wn=null,vn=null,_n=!1;function En(e,t,r){var n=r.window===r?r.document:9===r.nodeType?r:r.ownerDocument;_n||null==mn||mn!==X(n)||("selectionStart"in(n=mn)&&bn(n)?n={start:n.selectionStart,end:n.selectionEnd}:n={anchorNode:(n=(n.ownerDocument&&n.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:n.anchorOffset,focusNode:n.focusNode,focusOffset:n.focusOffset},vn&&hn(vn,n)||(vn=n,0<(n=Ln(wn,"onSelect")).length&&(t=new hr("onSelect","select",null,t,r),e.push({event:t,listeners:n}),t.target=mn)))}Bt("cancel cancel click click close close contextmenu contextMenu copy copy cut cut auxclick auxClick dblclick doubleClick dragend dragEnd dragstart dragStart drop drop focusin focus focusout blur input input invalid invalid keydown keyDown keypress keyPress keyup keyUp mousedown mouseDown mouseup mouseUp paste paste pause pause play play pointercancel pointerCancel pointerdown pointerDown pointerup pointerUp ratechange rateChange reset reset seeked seeked submit submit touchcancel touchCancel touchend touchEnd touchstart touchStart volumechange volumeChange".split(" "),0),Bt("drag drag dragenter dragEnter dragexit dragExit dragleave dragLeave dragover dragOver mousemove mouseMove mouseout mouseOut mouseover mouseOver pointermove pointerMove pointerout pointerOut pointerover pointerOver scroll scroll toggle toggle touchmove touchMove wheel wheel".split(" "),1),Bt(Nt,2);for(var Sn="change selectionchange textInput compositionstart compositionend compositionupdate".split(" "),An=0;An<Sn.length;An++)Dt.set(Sn[An],0);l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),u("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),u("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),u("onBeforeInput",["compositionend","keypress","textInput","paste"]),u("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),u("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var kn="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),xn=new Set("cancel close invalid load scroll toggle".split(" ").concat(kn));function In(e,t,r){var n=e.type||"unknown-event";e.currentTarget=r,function(e,t,r,n,i,s,a,c,u){if(We.apply(this,arguments),ze){if(!ze)throw Error(o(198));var l=$e;ze=!1,$e=null,He||(He=!0,je=l)}}(n,t,void 0,e),e.currentTarget=null}function Cn(e,t){t=0!==(4&t);for(var r=0;r<e.length;r++){var n=e[r],i=n.event;n=n.listeners;e:{var s=void 0;if(t)for(var o=n.length-1;0<=o;o--){var a=n[o],c=a.instance,u=a.currentTarget;if(a=a.listener,c!==s&&i.isPropagationStopped())break e;In(i,a,u),s=c}else for(o=0;o<n.length;o++){if(c=(a=n[o]).instance,u=a.currentTarget,a=a.listener,c!==s&&i.isPropagationStopped())break e;In(i,a,u),s=c}}}if(He)throw e=je,He=!1,je=null,e}function Tn(e,t){var r=si(t),n=e+"__bubble";r.has(n)||(Nn(t,e,2,!1),r.add(n))}var Rn="_reactListening"+Math.random().toString(36).slice(2);function Pn(e){e[Rn]||(e[Rn]=!0,a.forEach((function(t){xn.has(t)||Dn(t,!1,e,null),Dn(t,!0,e,null)})))}function Dn(e,t,r,n){var i=4<arguments.length&&void 0!==arguments[4]?arguments[4]:0,s=r;if("selectionchange"===e&&9!==r.nodeType&&(s=r.ownerDocument),null!==n&&!t&&xn.has(e)){if("scroll"!==e)return;i|=2,s=n}var o=si(s),a=e+"__"+(t?"capture":"bubble");o.has(a)||(t&&(i|=4),Nn(s,e,i,t),o.add(a))}function Nn(e,t,r,n){var i=Dt.get(t);switch(void 0===i?2:i){case 0:i=Yt;break;case 1:i=Qt;break;default:i=Jt}r=i.bind(null,t,r,e),i=void 0,!Ke||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(i=!0),n?void 0!==i?e.addEventListener(t,r,{capture:!0,passive:i}):e.addEventListener(t,r,!0):void 0!==i?e.addEventListener(t,r,{passive:i}):e.addEventListener(t,r,!1)}function Bn(e,t,r,n,i){var s=n;if(0===(1&t)&&0===(2&t)&&null!==n)e:for(;;){if(null===n)return;var o=n.tag;if(3===o||4===o){var a=n.stateNode.containerInfo;if(a===i||8===a.nodeType&&a.parentNode===i)break;if(4===o)for(o=n.return;null!==o;){var c=o.tag;if((3===c||4===c)&&((c=o.stateNode.containerInfo)===i||8===c.nodeType&&c.parentNode===i))return;o=o.return}for(;null!==a;){if(null===(o=ti(a)))return;if(5===(c=o.tag)||6===c){n=s=o;continue e}a=a.parentNode}}n=n.return}!function(e,t,r){if(Me)return e(t,r);Me=!0;try{return Ue(e,t,r)}finally{Me=!1,Oe()}}((function(){var n=s,i=ke(r),o=[];e:{var a=Pt.get(e);if(void 0!==a){var c=hr,u=e;switch(e){case"keypress":if(0===nr(r))break e;case"keydown":case"keyup":c=Cr;break;case"focusin":u="focus",c=yr;break;case"focusout":u="blur",c=yr;break;case"beforeblur":case"afterblur":c=yr;break;case"click":if(2===r.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":c=gr;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":c=br;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":c=Rr;break;case It:case Ct:case Tt:c=mr;break;case Rt:c=Pr;break;case"scroll":c=fr;break;case"wheel":c=Nr;break;case"copy":case"cut":case"paste":c=vr;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":c=Tr}var l=0!==(4&t),h=!l&&"scroll"===e,d=l?null!==a?a+"Capture":null:a;l=[];for(var f,p=n;null!==p;){var g=(f=p).stateNode;if(5===f.tag&&null!==g&&(f=g,null!==d&&(null!=(g=qe(p,d))&&l.push(Un(p,g,f)))),h)break;p=p.return}0<l.length&&(a=new c(a,u,null,r,i),o.push({event:a,listeners:l}))}}if(0===(7&t)){if(c="mouseout"===e||"pointerout"===e,(!(a="mouseover"===e||"pointerover"===e)||0!==(16&t)||!(u=r.relatedTarget||r.fromElement)||!ti(u)&&!u[Zn])&&(c||a)&&(a=i.window===i?i:(a=i.ownerDocument)?a.defaultView||a.parentWindow:window,c?(c=n,null!==(u=(u=r.relatedTarget||r.toElement)?ti(u):null)&&(u!==(h=Ye(u))||5!==u.tag&&6!==u.tag)&&(u=null)):(c=null,u=n),c!==u)){if(l=gr,g="onMouseLeave",d="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(l=Tr,g="onPointerLeave",d="onPointerEnter",p="pointer"),h=null==c?a:ni(c),f=null==u?a:ni(u),(a=new l(g,p+"leave",c,r,i)).target=h,a.relatedTarget=f,g=null,ti(i)===n&&((l=new l(d,p+"enter",u,r,i)).target=f,l.relatedTarget=h,g=l),h=g,c&&u)e:{for(d=u,p=0,f=l=c;f;f=Mn(f))p++;for(f=0,g=d;g;g=Mn(g))f++;for(;0<p-f;)l=Mn(l),p--;for(;0<f-p;)d=Mn(d),f--;for(;p--;){if(l===d||null!==d&&l===d.alternate)break e;l=Mn(l),d=Mn(d)}l=null}else l=null;null!==c&&On(o,a,c,l,!1),null!==u&&null!==h&&On(o,h,u,l,!0)}if("select"===(c=(a=n?ni(n):window).nodeName&&a.nodeName.toLowerCase())||"input"===c&&"file"===a.type)var b=Jr;else if(Hr(a))if(Xr)b=cn;else{b=on;var y=sn}else(c=a.nodeName)&&"input"===c.toLowerCase()&&("checkbox"===a.type||"radio"===a.type)&&(b=an);switch(b&&(b=b(e,n))?jr(o,b,r,i):(y&&y(e,a,n),"focusout"===e&&(y=a._wrapperState)&&y.controlled&&"number"===a.type&&ie(a,"number",a.value)),y=n?ni(n):window,e){case"focusin":(Hr(y)||"true"===y.contentEditable)&&(mn=y,wn=n,vn=null);break;case"focusout":vn=wn=mn=null;break;case"mousedown":_n=!0;break;case"contextmenu":case"mouseup":case"dragend":_n=!1,En(o,r,i);break;case"selectionchange":if(yn)break;case"keydown":case"keyup":En(o,r,i)}var m;if(Ur)e:{switch(e){case"compositionstart":var w="onCompositionStart";break e;case"compositionend":w="onCompositionEnd";break e;case"compositionupdate":w="onCompositionUpdate";break e}w=void 0}else zr?Fr(e,r)&&(w="onCompositionEnd"):"keydown"===e&&229===r.keyCode&&(w="onCompositionStart");w&&(Or&&"ko"!==r.locale&&(zr||"onCompositionStart"!==w?"onCompositionEnd"===w&&zr&&(m=rr()):(er="value"in(Zt=i)?Zt.value:Zt.textContent,zr=!0)),0<(y=Ln(n,w)).length&&(w=new _r(w,e,null,r,i),o.push({event:w,listeners:y}),m?w.data=m:null!==(m=Vr(r))&&(w.data=m))),(m=Mr?function(e,t){switch(e){case"compositionend":return Vr(t);case"keypress":return 32!==t.which?null:(Kr=!0,qr);case"textInput":return(e=t.data)===qr&&Kr?null:e;default:return null}}(e,r):function(e,t){if(zr)return"compositionend"===e||!Ur&&Fr(e,t)?(e=rr(),tr=er=Zt=null,zr=!1,e):null;switch(e){case"paste":default:return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return Or&&"ko"!==t.locale?null:t.data}}(e,r))&&(0<(n=Ln(n,"onBeforeInput")).length&&(i=new _r("onBeforeInput","beforeinput",null,r,i),o.push({event:i,listeners:n}),i.data=m))}Cn(o,t)}))}function Un(e,t,r){return{instance:e,listener:t,currentTarget:r}}function Ln(e,t){for(var r=t+"Capture",n=[];null!==e;){var i=e,s=i.stateNode;5===i.tag&&null!==s&&(i=s,null!=(s=qe(e,r))&&n.unshift(Un(e,s,i)),null!=(s=qe(e,t))&&n.push(Un(e,s,i))),e=e.return}return n}function Mn(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function On(e,t,r,n,i){for(var s=t._reactName,o=[];null!==r&&r!==n;){var a=r,c=a.alternate,u=a.stateNode;if(null!==c&&c===n)break;5===a.tag&&null!==u&&(a=u,i?null!=(c=qe(r,s))&&o.unshift(Un(r,c,a)):i||null!=(c=qe(r,s))&&o.push(Un(r,c,a))),r=r.return}0!==o.length&&e.push({event:t,listeners:o})}function qn(){}var Kn=null,Fn=null;function Vn(e,t){switch(e){case"button":case"input":case"select":case"textarea":return!!t.autoFocus}return!1}function zn(e,t){return"textarea"===e||"option"===e||"noscript"===e||"string"===typeof t.children||"number"===typeof t.children||"object"===typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var $n="function"===typeof setTimeout?setTimeout:void 0,Hn="function"===typeof clearTimeout?clearTimeout:void 0;function jn(e){1===e.nodeType?e.textContent="":9===e.nodeType&&(null!=(e=e.body)&&(e.textContent=""))}function Gn(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break}return e}function Wn(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var r=e.data;if("$"===r||"$!"===r||"$?"===r){if(0===t)return e;t--}else"/$"===r&&t++}e=e.previousSibling}return null}var Yn=0;var Qn=Math.random().toString(36).slice(2),Jn="__reactFiber$"+Qn,Xn="__reactProps$"+Qn,Zn="__reactContainer$"+Qn,ei="__reactEvents$"+Qn;function ti(e){var t=e[Jn];if(t)return t;for(var r=e.parentNode;r;){if(t=r[Zn]||r[Jn]){if(r=t.alternate,null!==t.child||null!==r&&null!==r.child)for(e=Wn(e);null!==e;){if(r=e[Jn])return r;e=Wn(e)}return t}r=(e=r).parentNode}return null}function ri(e){return!(e=e[Jn]||e[Zn])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function ni(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(o(33))}function ii(e){return e[Xn]||null}function si(e){var t=e[ei];return void 0===t&&(t=e[ei]=new Set),t}var oi=[],ai=-1;function ci(e){return{current:e}}function ui(e){0>ai||(e.current=oi[ai],oi[ai]=null,ai--)}function li(e,t){ai++,oi[ai]=e.current,e.current=t}var hi={},di=ci(hi),fi=ci(!1),pi=hi;function gi(e,t){var r=e.type.contextTypes;if(!r)return hi;var n=e.stateNode;if(n&&n.__reactInternalMemoizedUnmaskedChildContext===t)return n.__reactInternalMemoizedMaskedChildContext;var i,s={};for(i in r)s[i]=t[i];return n&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function bi(e){return null!==(e=e.childContextTypes)&&void 0!==e}function yi(){ui(fi),ui(di)}function mi(e,t,r){if(di.current!==hi)throw Error(o(168));li(di,t),li(fi,r)}function wi(e,t,r){var n=e.stateNode;if(e=t.childContextTypes,"function"!==typeof n.getChildContext)return r;for(var s in n=n.getChildContext())if(!(s in e))throw Error(o(108,G(t)||"Unknown",s));return i({},r,n)}function vi(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||hi,pi=di.current,li(di,e),li(fi,fi.current),!0}function _i(e,t,r){var n=e.stateNode;if(!n)throw Error(o(169));r?(e=wi(e,t,pi),n.__reactInternalMemoizedMergedChildContext=e,ui(fi),ui(di),li(di,e)):ui(fi),li(fi,r)}var Ei=null,Si=null,Ai=s.unstable_runWithPriority,ki=s.unstable_scheduleCallback,xi=s.unstable_cancelCallback,Ii=s.unstable_shouldYield,Ci=s.unstable_requestPaint,Ti=s.unstable_now,Ri=s.unstable_getCurrentPriorityLevel,Pi=s.unstable_ImmediatePriority,Di=s.unstable_UserBlockingPriority,Ni=s.unstable_NormalPriority,Bi=s.unstable_LowPriority,Ui=s.unstable_IdlePriority,Li={},Mi=void 0!==Ci?Ci:function(){},Oi=null,qi=null,Ki=!1,Fi=Ti(),Vi=1e4>Fi?Ti:function(){return Ti()-Fi};function zi(){switch(Ri()){case Pi:return 99;case Di:return 98;case Ni:return 97;case Bi:return 96;case Ui:return 95;default:throw Error(o(332))}}function $i(e){switch(e){case 99:return Pi;case 98:return Di;case 97:return Ni;case 96:return Bi;case 95:return Ui;default:throw Error(o(332))}}function Hi(e,t){return e=$i(e),Ai(e,t)}function ji(e,t,r){return e=$i(e),ki(e,t,r)}function Gi(){if(null!==qi){var e=qi;qi=null,xi(e)}Wi()}function Wi(){if(!Ki&&null!==Oi){Ki=!0;var e=0;try{var t=Oi;Hi(99,(function(){for(;e<t.length;e++){var r=t[e];do{r=r(!0)}while(null!==r)}})),Oi=null}catch(r){throw null!==Oi&&(Oi=Oi.slice(e+1)),ki(Pi,Gi),r}finally{Ki=!1}}}var Yi=_.ReactCurrentBatchConfig;function Qi(e,t){if(e&&e.defaultProps){for(var r in t=i({},t),e=e.defaultProps)void 0===t[r]&&(t[r]=e[r]);return t}return t}var Ji=ci(null),Xi=null,Zi=null,es=null;function ts(){es=Zi=Xi=null}function rs(e){var t=Ji.current;ui(Ji),e.type._context._currentValue=t}function ns(e,t){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)===t){if(null===r||(r.childLanes&t)===t)break;r.childLanes|=t}else e.childLanes|=t,null!==r&&(r.childLanes|=t);e=e.return}}function is(e,t){Xi=e,es=Zi=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(Lo=!0),e.firstContext=null)}function ss(e,t){if(es!==e&&!1!==t&&0!==t)if("number"===typeof t&&1073741823!==t||(es=e,t=1073741823),t={context:e,observedBits:t,next:null},null===Zi){if(null===Xi)throw Error(o(308));Zi=t,Xi.dependencies={lanes:0,firstContext:t,responders:null}}else Zi=Zi.next=t;return e._currentValue}var os=!1;function as(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null},effects:null}}function cs(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function us(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ls(e,t){if(null!==(e=e.updateQueue)){var r=(e=e.shared).pending;null===r?t.next=t:(t.next=r.next,r.next=t),e.pending=t}}function hs(e,t){var r=e.updateQueue,n=e.alternate;if(null!==n&&r===(n=n.updateQueue)){var i=null,s=null;if(null!==(r=r.firstBaseUpdate)){do{var o={eventTime:r.eventTime,lane:r.lane,tag:r.tag,payload:r.payload,callback:r.callback,next:null};null===s?i=s=o:s=s.next=o,r=r.next}while(null!==r);null===s?i=s=t:s=s.next=t}else i=s=t;return r={baseState:n.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:n.shared,effects:n.effects},void(e.updateQueue=r)}null===(e=r.lastBaseUpdate)?r.firstBaseUpdate=t:e.next=t,r.lastBaseUpdate=t}function ds(e,t,r,n){var s=e.updateQueue;os=!1;var o=s.firstBaseUpdate,a=s.lastBaseUpdate,c=s.shared.pending;if(null!==c){s.shared.pending=null;var u=c,l=u.next;u.next=null,null===a?o=l:a.next=l,a=u;var h=e.alternate;if(null!==h){var d=(h=h.updateQueue).lastBaseUpdate;d!==a&&(null===d?h.firstBaseUpdate=l:d.next=l,h.lastBaseUpdate=u)}}if(null!==o){for(d=s.baseState,a=0,h=l=u=null;;){c=o.lane;var f=o.eventTime;if((n&c)===c){null!==h&&(h=h.next={eventTime:f,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var p=e,g=o;switch(c=t,f=r,g.tag){case 1:if("function"===typeof(p=g.payload)){d=p.call(f,d,c);break e}d=p;break e;case 3:p.flags=-4097&p.flags|64;case 0:if(null===(c="function"===typeof(p=g.payload)?p.call(f,d,c):p)||void 0===c)break e;d=i({},d,c);break e;case 2:os=!0}}null!==o.callback&&(e.flags|=32,null===(c=s.effects)?s.effects=[o]:c.push(o))}else f={eventTime:f,lane:c,tag:o.tag,payload:o.payload,callback:o.callback,next:null},null===h?(l=h=f,u=d):h=h.next=f,a|=c;if(null===(o=o.next)){if(null===(c=s.shared.pending))break;o=c.next,c.next=null,s.lastBaseUpdate=c,s.shared.pending=null}}null===h&&(u=d),s.baseState=u,s.firstBaseUpdate=l,s.lastBaseUpdate=h,Fa|=a,e.lanes=a,e.memoizedState=d}}function fs(e,t,r){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var n=e[t],i=n.callback;if(null!==i){if(n.callback=null,n=r,"function"!==typeof i)throw Error(o(191,i));i.call(n)}}}var ps=(new n.Component).refs;function gs(e,t,r,n){r=null===(r=r(n,t=e.memoizedState))||void 0===r?t:i({},t,r),e.memoizedState=r,0===e.lanes&&(e.updateQueue.baseState=r)}var bs={isMounted:function(e){return!!(e=e._reactInternals)&&Ye(e)===e},enqueueSetState:function(e,t,r){e=e._reactInternals;var n=dc(),i=fc(e),s=us(n,i);s.payload=t,void 0!==r&&null!==r&&(s.callback=r),ls(e,s),pc(e,i,n)},enqueueReplaceState:function(e,t,r){e=e._reactInternals;var n=dc(),i=fc(e),s=us(n,i);s.tag=1,s.payload=t,void 0!==r&&null!==r&&(s.callback=r),ls(e,s),pc(e,i,n)},enqueueForceUpdate:function(e,t){e=e._reactInternals;var r=dc(),n=fc(e),i=us(r,n);i.tag=2,void 0!==t&&null!==t&&(i.callback=t),ls(e,i),pc(e,n,r)}};function ys(e,t,r,n,i,s,o){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(n,s,o):!t.prototype||!t.prototype.isPureReactComponent||(!hn(r,n)||!hn(i,s))}function ms(e,t,r){var n=!1,i=hi,s=t.contextType;return"object"===typeof s&&null!==s?s=ss(s):(i=bi(t)?pi:di.current,s=(n=null!==(n=t.contextTypes)&&void 0!==n)?gi(e,i):hi),t=new t(r,s),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=bs,e.stateNode=t,t._reactInternals=e,n&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function ws(e,t,r,n){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(r,n),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(r,n),t.state!==e&&bs.enqueueReplaceState(t,t.state,null)}function vs(e,t,r,n){var i=e.stateNode;i.props=r,i.state=e.memoizedState,i.refs=ps,as(e);var s=t.contextType;"object"===typeof s&&null!==s?i.context=ss(s):(s=bi(t)?pi:di.current,i.context=gi(e,s)),ds(e,r,i,n),i.state=e.memoizedState,"function"===typeof(s=t.getDerivedStateFromProps)&&(gs(e,t,s,r),i.state=e.memoizedState),"function"===typeof t.getDerivedStateFromProps||"function"===typeof i.getSnapshotBeforeUpdate||"function"!==typeof i.UNSAFE_componentWillMount&&"function"!==typeof i.componentWillMount||(t=i.state,"function"===typeof i.componentWillMount&&i.componentWillMount(),"function"===typeof i.UNSAFE_componentWillMount&&i.UNSAFE_componentWillMount(),t!==i.state&&bs.enqueueReplaceState(i,i.state,null),ds(e,r,i,n),i.state=e.memoizedState),"function"===typeof i.componentDidMount&&(e.flags|=4)}var _s=Array.isArray;function Es(e,t,r){if(null!==(e=r.ref)&&"function"!==typeof e&&"object"!==typeof e){if(r._owner){if(r=r._owner){if(1!==r.tag)throw Error(o(309));var n=r.stateNode}if(!n)throw Error(o(147,e));var i=""+e;return null!==t&&null!==t.ref&&"function"===typeof t.ref&&t.ref._stringRef===i?t.ref:(t=function(e){var t=n.refs;t===ps&&(t=n.refs={}),null===e?delete t[i]:t[i]=e},t._stringRef=i,t)}if("string"!==typeof e)throw Error(o(284));if(!r._owner)throw Error(o(290,e))}return e}function Ss(e,t){if("textarea"!==e.type)throw Error(o(31,"[object Object]"===Object.prototype.toString.call(t)?"object with keys {"+Object.keys(t).join(", ")+"}":t))}function As(e){function t(t,r){if(e){var n=t.lastEffect;null!==n?(n.nextEffect=r,t.lastEffect=r):t.firstEffect=t.lastEffect=r,r.nextEffect=null,r.flags=8}}function r(r,n){if(!e)return null;for(;null!==n;)t(r,n),n=n.sibling;return null}function n(e,t){for(e=new Map;null!==t;)null!==t.key?e.set(t.key,t):e.set(t.index,t),t=t.sibling;return e}function i(e,t){return(e=jc(e,t)).index=0,e.sibling=null,e}function s(t,r,n){return t.index=n,e?null!==(n=t.alternate)?(n=n.index)<r?(t.flags=2,r):n:(t.flags=2,r):r}function a(t){return e&&null===t.alternate&&(t.flags=2),t}function c(e,t,r,n){return null===t||6!==t.tag?((t=Qc(r,e.mode,n)).return=e,t):((t=i(t,r)).return=e,t)}function u(e,t,r,n){return null!==t&&t.elementType===r.type?((n=i(t,r.props)).ref=Es(e,t,r),n.return=e,n):((n=Gc(r.type,r.key,r.props,null,e.mode,n)).ref=Es(e,t,r),n.return=e,n)}function l(e,t,r,n){return null===t||4!==t.tag||t.stateNode.containerInfo!==r.containerInfo||t.stateNode.implementation!==r.implementation?((t=Jc(r,e.mode,n)).return=e,t):((t=i(t,r.children||[])).return=e,t)}function h(e,t,r,n,s){return null===t||7!==t.tag?((t=Wc(r,e.mode,n,s)).return=e,t):((t=i(t,r)).return=e,t)}function d(e,t,r){if("string"===typeof t||"number"===typeof t)return(t=Qc(""+t,e.mode,r)).return=e,t;if("object"===typeof t&&null!==t){switch(t.$$typeof){case E:return(r=Gc(t.type,t.key,t.props,null,e.mode,r)).ref=Es(e,null,t),r.return=e,r;case S:return(t=Jc(t,e.mode,r)).return=e,t}if(_s(t)||V(t))return(t=Wc(t,e.mode,r,null)).return=e,t;Ss(e,t)}return null}function f(e,t,r,n){var i=null!==t?t.key:null;if("string"===typeof r||"number"===typeof r)return null!==i?null:c(e,t,""+r,n);if("object"===typeof r&&null!==r){switch(r.$$typeof){case E:return r.key===i?r.type===A?h(e,t,r.props.children,n,i):u(e,t,r,n):null;case S:return r.key===i?l(e,t,r,n):null}if(_s(r)||V(r))return null!==i?null:h(e,t,r,n,null);Ss(e,r)}return null}function p(e,t,r,n,i){if("string"===typeof n||"number"===typeof n)return c(t,e=e.get(r)||null,""+n,i);if("object"===typeof n&&null!==n){switch(n.$$typeof){case E:return e=e.get(null===n.key?r:n.key)||null,n.type===A?h(t,e,n.props.children,i,n.key):u(t,e,n,i);case S:return l(t,e=e.get(null===n.key?r:n.key)||null,n,i)}if(_s(n)||V(n))return h(t,e=e.get(r)||null,n,i,null);Ss(t,n)}return null}function g(i,o,a,c){for(var u=null,l=null,h=o,g=o=0,b=null;null!==h&&g<a.length;g++){h.index>g?(b=h,h=null):b=h.sibling;var y=f(i,h,a[g],c);if(null===y){null===h&&(h=b);break}e&&h&&null===y.alternate&&t(i,h),o=s(y,o,g),null===l?u=y:l.sibling=y,l=y,h=b}if(g===a.length)return r(i,h),u;if(null===h){for(;g<a.length;g++)null!==(h=d(i,a[g],c))&&(o=s(h,o,g),null===l?u=h:l.sibling=h,l=h);return u}for(h=n(i,h);g<a.length;g++)null!==(b=p(h,i,g,a[g],c))&&(e&&null!==b.alternate&&h.delete(null===b.key?g:b.key),o=s(b,o,g),null===l?u=b:l.sibling=b,l=b);return e&&h.forEach((function(e){return t(i,e)})),u}function b(i,a,c,u){var l=V(c);if("function"!==typeof l)throw Error(o(150));if(null==(c=l.call(c)))throw Error(o(151));for(var h=l=null,g=a,b=a=0,y=null,m=c.next();null!==g&&!m.done;b++,m=c.next()){g.index>b?(y=g,g=null):y=g.sibling;var w=f(i,g,m.value,u);if(null===w){null===g&&(g=y);break}e&&g&&null===w.alternate&&t(i,g),a=s(w,a,b),null===h?l=w:h.sibling=w,h=w,g=y}if(m.done)return r(i,g),l;if(null===g){for(;!m.done;b++,m=c.next())null!==(m=d(i,m.value,u))&&(a=s(m,a,b),null===h?l=m:h.sibling=m,h=m);return l}for(g=n(i,g);!m.done;b++,m=c.next())null!==(m=p(g,i,b,m.value,u))&&(e&&null!==m.alternate&&g.delete(null===m.key?b:m.key),a=s(m,a,b),null===h?l=m:h.sibling=m,h=m);return e&&g.forEach((function(e){return t(i,e)})),l}return function(e,n,s,c){var u="object"===typeof s&&null!==s&&s.type===A&&null===s.key;u&&(s=s.props.children);var l="object"===typeof s&&null!==s;if(l)switch(s.$$typeof){case E:e:{for(l=s.key,u=n;null!==u;){if(u.key===l){if(7===u.tag){if(s.type===A){r(e,u.sibling),(n=i(u,s.props.children)).return=e,e=n;break e}}else if(u.elementType===s.type){r(e,u.sibling),(n=i(u,s.props)).ref=Es(e,u,s),n.return=e,e=n;break e}r(e,u);break}t(e,u),u=u.sibling}s.type===A?((n=Wc(s.props.children,e.mode,c,s.key)).return=e,e=n):((c=Gc(s.type,s.key,s.props,null,e.mode,c)).ref=Es(e,n,s),c.return=e,e=c)}return a(e);case S:e:{for(u=s.key;null!==n;){if(n.key===u){if(4===n.tag&&n.stateNode.containerInfo===s.containerInfo&&n.stateNode.implementation===s.implementation){r(e,n.sibling),(n=i(n,s.children||[])).return=e,e=n;break e}r(e,n);break}t(e,n),n=n.sibling}(n=Jc(s,e.mode,c)).return=e,e=n}return a(e)}if("string"===typeof s||"number"===typeof s)return s=""+s,null!==n&&6===n.tag?(r(e,n.sibling),(n=i(n,s)).return=e,e=n):(r(e,n),(n=Qc(s,e.mode,c)).return=e,e=n),a(e);if(_s(s))return g(e,n,s,c);if(V(s))return b(e,n,s,c);if(l&&Ss(e,s),"undefined"===typeof s&&!u)switch(e.tag){case 1:case 22:case 0:case 11:case 15:throw Error(o(152,G(e.type)||"Component"))}return r(e,n)}}var ks=As(!0),xs=As(!1),Is={},Cs=ci(Is),Ts=ci(Is),Rs=ci(Is);function Ps(e){if(e===Is)throw Error(o(174));return e}function Ds(e,t){switch(li(Rs,t),li(Ts,e),li(Cs,Is),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:fe(null,"");break;default:t=fe(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}ui(Cs),li(Cs,t)}function Ns(){ui(Cs),ui(Ts),ui(Rs)}function Bs(e){Ps(Rs.current);var t=Ps(Cs.current),r=fe(t,e.type);t!==r&&(li(Ts,e),li(Cs,r))}function Us(e){Ts.current===e&&(ui(Cs),ui(Ts))}var Ls=ci(0);function Ms(e){for(var t=e;null!==t;){if(13===t.tag){var r=t.memoizedState;if(null!==r&&(null===(r=r.dehydrated)||"$?"===r.data||"$!"===r.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!==(64&t.flags))return t}else if(null!==t.child){t.child.return=t,t=t.child;continue}if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Os=null,qs=null,Ks=!1;function Fs(e,t){var r=$c(5,null,null,0);r.elementType="DELETED",r.type="DELETED",r.stateNode=t,r.return=e,r.flags=8,null!==e.lastEffect?(e.lastEffect.nextEffect=r,e.lastEffect=r):e.firstEffect=e.lastEffect=r}function Vs(e,t){switch(e.tag){case 5:var r=e.type;return null!==(t=1!==t.nodeType||r.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,!0);default:return!1}}function zs(e){if(Ks){var t=qs;if(t){var r=t;if(!Vs(e,t)){if(!(t=Gn(r.nextSibling))||!Vs(e,t))return e.flags=-1025&e.flags|2,Ks=!1,void(Os=e);Fs(Os,r)}Os=e,qs=Gn(t.firstChild)}else e.flags=-1025&e.flags|2,Ks=!1,Os=e}}function $s(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;Os=e}function Hs(e){if(e!==Os)return!1;if(!Ks)return $s(e),Ks=!0,!1;var t=e.type;if(5!==e.tag||"head"!==t&&"body"!==t&&!zn(t,e.memoizedProps))for(t=qs;t;)Fs(e,t),t=Gn(t.nextSibling);if($s(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(o(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var r=e.data;if("/$"===r){if(0===t){qs=Gn(e.nextSibling);break e}t--}else"$"!==r&&"$!"!==r&&"$?"!==r||t++}e=e.nextSibling}qs=null}}else qs=Os?Gn(e.stateNode.nextSibling):null;return!0}function js(){qs=Os=null,Ks=!1}var Gs=[];function Ws(){for(var e=0;e<Gs.length;e++)Gs[e]._workInProgressVersionPrimary=null;Gs.length=0}var Ys=_.ReactCurrentDispatcher,Qs=_.ReactCurrentBatchConfig,Js=0,Xs=null,Zs=null,eo=null,to=!1,ro=!1;function no(){throw Error(o(321))}function io(e,t){if(null===t)return!1;for(var r=0;r<t.length&&r<e.length;r++)if(!un(e[r],t[r]))return!1;return!0}function so(e,t,r,n,i,s){if(Js=s,Xs=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ys.current=null===e||null===e.memoizedState?Do:No,e=r(n,i),ro){s=0;do{if(ro=!1,!(25>s))throw Error(o(301));s+=1,eo=Zs=null,t.updateQueue=null,Ys.current=Bo,e=r(n,i)}while(ro)}if(Ys.current=Po,t=null!==Zs&&null!==Zs.next,Js=0,eo=Zs=Xs=null,to=!1,t)throw Error(o(300));return e}function oo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===eo?Xs.memoizedState=eo=e:eo=eo.next=e,eo}function ao(){if(null===Zs){var e=Xs.alternate;e=null!==e?e.memoizedState:null}else e=Zs.next;var t=null===eo?Xs.memoizedState:eo.next;if(null!==t)eo=t,Zs=e;else{if(null===e)throw Error(o(310));e={memoizedState:(Zs=e).memoizedState,baseState:Zs.baseState,baseQueue:Zs.baseQueue,queue:Zs.queue,next:null},null===eo?Xs.memoizedState=eo=e:eo=eo.next=e}return eo}function co(e,t){return"function"===typeof t?t(e):t}function uo(e){var t=ao(),r=t.queue;if(null===r)throw Error(o(311));r.lastRenderedReducer=e;var n=Zs,i=n.baseQueue,s=r.pending;if(null!==s){if(null!==i){var a=i.next;i.next=s.next,s.next=a}n.baseQueue=i=s,r.pending=null}if(null!==i){i=i.next,n=n.baseState;var c=a=s=null,u=i;do{var l=u.lane;if((Js&l)===l)null!==c&&(c=c.next={lane:0,action:u.action,eagerReducer:u.eagerReducer,eagerState:u.eagerState,next:null}),n=u.eagerReducer===e?u.eagerState:e(n,u.action);else{var h={lane:l,action:u.action,eagerReducer:u.eagerReducer,eagerState:u.eagerState,next:null};null===c?(a=c=h,s=n):c=c.next=h,Xs.lanes|=l,Fa|=l}u=u.next}while(null!==u&&u!==i);null===c?s=n:c.next=a,un(n,t.memoizedState)||(Lo=!0),t.memoizedState=n,t.baseState=s,t.baseQueue=c,r.lastRenderedState=n}return[t.memoizedState,r.dispatch]}function lo(e){var t=ao(),r=t.queue;if(null===r)throw Error(o(311));r.lastRenderedReducer=e;var n=r.dispatch,i=r.pending,s=t.memoizedState;if(null!==i){r.pending=null;var a=i=i.next;do{s=e(s,a.action),a=a.next}while(a!==i);un(s,t.memoizedState)||(Lo=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),r.lastRenderedState=s}return[s,n]}function ho(e,t,r){var n=t._getVersion;n=n(t._source);var i=t._workInProgressVersionPrimary;if(null!==i?e=i===n:(e=e.mutableReadLanes,(e=(Js&e)===e)&&(t._workInProgressVersionPrimary=n,Gs.push(t))),e)return r(t._source);throw Gs.push(t),Error(o(350))}function fo(e,t,r,n){var i=Na;if(null===i)throw Error(o(349));var s=t._getVersion,a=s(t._source),c=Ys.current,u=c.useState((function(){return ho(i,t,r)})),l=u[1],h=u[0];u=eo;var d=e.memoizedState,f=d.refs,p=f.getSnapshot,g=d.source;d=d.subscribe;var b=Xs;return e.memoizedState={refs:f,source:t,subscribe:n},c.useEffect((function(){f.getSnapshot=r,f.setSnapshot=l;var e=s(t._source);if(!un(a,e)){e=r(t._source),un(h,e)||(l(e),e=fc(b),i.mutableReadLanes|=e&i.pendingLanes),e=i.mutableReadLanes,i.entangledLanes|=e;for(var n=i.entanglements,o=e;0<o;){var c=31-zt(o),u=1<<c;n[c]|=e,o&=~u}}}),[r,t,n]),c.useEffect((function(){return n(t._source,(function(){var e=f.getSnapshot,r=f.setSnapshot;try{r(e(t._source));var n=fc(b);i.mutableReadLanes|=n&i.pendingLanes}catch(s){r((function(){throw s}))}}))}),[t,n]),un(p,r)&&un(g,t)&&un(d,n)||((e={pending:null,dispatch:null,lastRenderedReducer:co,lastRenderedState:h}).dispatch=l=Ro.bind(null,Xs,e),u.queue=e,u.baseQueue=null,h=ho(i,t,r),u.memoizedState=u.baseState=h),h}function po(e,t,r){return fo(ao(),e,t,r)}function go(e){var t=oo();return"function"===typeof e&&(e=e()),t.memoizedState=t.baseState=e,e=(e=t.queue={pending:null,dispatch:null,lastRenderedReducer:co,lastRenderedState:e}).dispatch=Ro.bind(null,Xs,e),[t.memoizedState,e]}function bo(e,t,r,n){return e={tag:e,create:t,destroy:r,deps:n,next:null},null===(t=Xs.updateQueue)?(t={lastEffect:null},Xs.updateQueue=t,t.lastEffect=e.next=e):null===(r=t.lastEffect)?t.lastEffect=e.next=e:(n=r.next,r.next=e,e.next=n,t.lastEffect=e),e}function yo(e){return e={current:e},oo().memoizedState=e}function mo(){return ao().memoizedState}function wo(e,t,r,n){var i=oo();Xs.flags|=e,i.memoizedState=bo(1|t,r,void 0,void 0===n?null:n)}function vo(e,t,r,n){var i=ao();n=void 0===n?null:n;var s=void 0;if(null!==Zs){var o=Zs.memoizedState;if(s=o.destroy,null!==n&&io(n,o.deps))return void bo(t,r,s,n)}Xs.flags|=e,i.memoizedState=bo(1|t,r,s,n)}function _o(e,t){return wo(516,4,e,t)}function Eo(e,t){return vo(516,4,e,t)}function So(e,t){return vo(4,2,e,t)}function Ao(e,t){return"function"===typeof t?(e=e(),t(e),function(){t(null)}):null!==t&&void 0!==t?(e=e(),t.current=e,function(){t.current=null}):void 0}function ko(e,t,r){return r=null!==r&&void 0!==r?r.concat([e]):null,vo(4,2,Ao.bind(null,t,e),r)}function xo(){}function Io(e,t){var r=ao();t=void 0===t?null:t;var n=r.memoizedState;return null!==n&&null!==t&&io(t,n[1])?n[0]:(r.memoizedState=[e,t],e)}function Co(e,t){var r=ao();t=void 0===t?null:t;var n=r.memoizedState;return null!==n&&null!==t&&io(t,n[1])?n[0]:(e=e(),r.memoizedState=[e,t],e)}function To(e,t){var r=zi();Hi(98>r?98:r,(function(){e(!0)})),Hi(97<r?97:r,(function(){var r=Qs.transition;Qs.transition=1;try{e(!1),t()}finally{Qs.transition=r}}))}function Ro(e,t,r){var n=dc(),i=fc(e),s={lane:i,action:r,eagerReducer:null,eagerState:null,next:null},o=t.pending;if(null===o?s.next=s:(s.next=o.next,o.next=s),t.pending=s,o=e.alternate,e===Xs||null!==o&&o===Xs)ro=to=!0;else{if(0===e.lanes&&(null===o||0===o.lanes)&&null!==(o=t.lastRenderedReducer))try{var a=t.lastRenderedState,c=o(a,r);if(s.eagerReducer=o,s.eagerState=c,un(c,a))return}catch(u){}pc(e,i,n)}}var Po={readContext:ss,useCallback:no,useContext:no,useEffect:no,useImperativeHandle:no,useLayoutEffect:no,useMemo:no,useReducer:no,useRef:no,useState:no,useDebugValue:no,useDeferredValue:no,useTransition:no,useMutableSource:no,useOpaqueIdentifier:no,unstable_isNewReconciler:!1},Do={readContext:ss,useCallback:function(e,t){return oo().memoizedState=[e,void 0===t?null:t],e},useContext:ss,useEffect:_o,useImperativeHandle:function(e,t,r){return r=null!==r&&void 0!==r?r.concat([e]):null,wo(4,2,Ao.bind(null,t,e),r)},useLayoutEffect:function(e,t){return wo(4,2,e,t)},useMemo:function(e,t){var r=oo();return t=void 0===t?null:t,e=e(),r.memoizedState=[e,t],e},useReducer:function(e,t,r){var n=oo();return t=void 0!==r?r(t):t,n.memoizedState=n.baseState=t,e=(e=n.queue={pending:null,dispatch:null,lastRenderedReducer:e,lastRenderedState:t}).dispatch=Ro.bind(null,Xs,e),[n.memoizedState,e]},useRef:yo,useState:go,useDebugValue:xo,useDeferredValue:function(e){var t=go(e),r=t[0],n=t[1];return _o((function(){var t=Qs.transition;Qs.transition=1;try{n(e)}finally{Qs.transition=t}}),[e]),r},useTransition:function(){var e=go(!1),t=e[0];return yo(e=To.bind(null,e[1])),[e,t]},useMutableSource:function(e,t,r){var n=oo();return n.memoizedState={refs:{getSnapshot:t,setSnapshot:null},source:e,subscribe:r},fo(n,e,t,r)},useOpaqueIdentifier:function(){if(Ks){var e=!1,t=function(e){return{$$typeof:U,toString:e,valueOf:e}}((function(){throw e||(e=!0,r("r:"+(Yn++).toString(36))),Error(o(355))})),r=go(t)[1];return 0===(2&Xs.mode)&&(Xs.flags|=516,bo(5,(function(){r("r:"+(Yn++).toString(36))}),void 0,null)),t}return go(t="r:"+(Yn++).toString(36)),t},unstable_isNewReconciler:!1},No={readContext:ss,useCallback:Io,useContext:ss,useEffect:Eo,useImperativeHandle:ko,useLayoutEffect:So,useMemo:Co,useReducer:uo,useRef:mo,useState:function(){return uo(co)},useDebugValue:xo,useDeferredValue:function(e){var t=uo(co),r=t[0],n=t[1];return Eo((function(){var t=Qs.transition;Qs.transition=1;try{n(e)}finally{Qs.transition=t}}),[e]),r},useTransition:function(){var e=uo(co)[0];return[mo().current,e]},useMutableSource:po,useOpaqueIdentifier:function(){return uo(co)[0]},unstable_isNewReconciler:!1},Bo={readContext:ss,useCallback:Io,useContext:ss,useEffect:Eo,useImperativeHandle:ko,useLayoutEffect:So,useMemo:Co,useReducer:lo,useRef:mo,useState:function(){return lo(co)},useDebugValue:xo,useDeferredValue:function(e){var t=lo(co),r=t[0],n=t[1];return Eo((function(){var t=Qs.transition;Qs.transition=1;try{n(e)}finally{Qs.transition=t}}),[e]),r},useTransition:function(){var e=lo(co)[0];return[mo().current,e]},useMutableSource:po,useOpaqueIdentifier:function(){return lo(co)[0]},unstable_isNewReconciler:!1},Uo=_.ReactCurrentOwner,Lo=!1;function Mo(e,t,r,n){t.child=null===e?xs(t,null,r,n):ks(t,e.child,r,n)}function Oo(e,t,r,n,i){r=r.render;var s=t.ref;return is(t,i),n=so(e,t,r,n,s,i),null===e||Lo?(t.flags|=1,Mo(e,t,n,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-517,e.lanes&=~i,sa(e,t,i))}function qo(e,t,r,n,i,s){if(null===e){var o=r.type;return"function"!==typeof o||Hc(o)||void 0!==o.defaultProps||null!==r.compare||void 0!==r.defaultProps?((e=Gc(r.type,null,n,t,t.mode,s)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=o,Ko(e,t,o,n,i,s))}return o=e.child,0===(i&s)&&(i=o.memoizedProps,(r=null!==(r=r.compare)?r:hn)(i,n)&&e.ref===t.ref)?sa(e,t,s):(t.flags|=1,(e=jc(o,n)).ref=t.ref,e.return=t,t.child=e)}function Ko(e,t,r,n,i,s){if(null!==e&&hn(e.memoizedProps,n)&&e.ref===t.ref){if(Lo=!1,0===(s&i))return t.lanes=e.lanes,sa(e,t,s);0!==(16384&e.flags)&&(Lo=!0)}return zo(e,t,r,n,s)}function Fo(e,t,r){var n=t.pendingProps,i=n.children,s=null!==e?e.memoizedState:null;if("hidden"===n.mode||"unstable-defer-without-hiding"===n.mode)if(0===(4&t.mode))t.memoizedState={baseLanes:0},Ec(t,r);else{if(0===(1073741824&r))return e=null!==s?s.baseLanes|r:r,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e},Ec(t,e),null;t.memoizedState={baseLanes:0},Ec(t,null!==s?s.baseLanes:r)}else null!==s?(n=s.baseLanes|r,t.memoizedState=null):n=r,Ec(t,n);return Mo(e,t,i,r),t.child}function Vo(e,t){var r=t.ref;(null===e&&null!==r||null!==e&&e.ref!==r)&&(t.flags|=128)}function zo(e,t,r,n,i){var s=bi(r)?pi:di.current;return s=gi(t,s),is(t,i),r=so(e,t,r,n,s,i),null===e||Lo?(t.flags|=1,Mo(e,t,r,i),t.child):(t.updateQueue=e.updateQueue,t.flags&=-517,e.lanes&=~i,sa(e,t,i))}function $o(e,t,r,n,i){if(bi(r)){var s=!0;vi(t)}else s=!1;if(is(t,i),null===t.stateNode)null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),ms(t,r,n),vs(t,r,n,i),n=!0;else if(null===e){var o=t.stateNode,a=t.memoizedProps;o.props=a;var c=o.context,u=r.contextType;"object"===typeof u&&null!==u?u=ss(u):u=gi(t,u=bi(r)?pi:di.current);var l=r.getDerivedStateFromProps,h="function"===typeof l||"function"===typeof o.getSnapshotBeforeUpdate;h||"function"!==typeof o.UNSAFE_componentWillReceiveProps&&"function"!==typeof o.componentWillReceiveProps||(a!==n||c!==u)&&ws(t,o,n,u),os=!1;var d=t.memoizedState;o.state=d,ds(t,n,o,i),c=t.memoizedState,a!==n||d!==c||fi.current||os?("function"===typeof l&&(gs(t,r,l,n),c=t.memoizedState),(a=os||ys(t,r,a,n,d,c,u))?(h||"function"!==typeof o.UNSAFE_componentWillMount&&"function"!==typeof o.componentWillMount||("function"===typeof o.componentWillMount&&o.componentWillMount(),"function"===typeof o.UNSAFE_componentWillMount&&o.UNSAFE_componentWillMount()),"function"===typeof o.componentDidMount&&(t.flags|=4)):("function"===typeof o.componentDidMount&&(t.flags|=4),t.memoizedProps=n,t.memoizedState=c),o.props=n,o.state=c,o.context=u,n=a):("function"===typeof o.componentDidMount&&(t.flags|=4),n=!1)}else{o=t.stateNode,cs(e,t),a=t.memoizedProps,u=t.type===t.elementType?a:Qi(t.type,a),o.props=u,h=t.pendingProps,d=o.context,"object"===typeof(c=r.contextType)&&null!==c?c=ss(c):c=gi(t,c=bi(r)?pi:di.current);var f=r.getDerivedStateFromProps;(l="function"===typeof f||"function"===typeof o.getSnapshotBeforeUpdate)||"function"!==typeof o.UNSAFE_componentWillReceiveProps&&"function"!==typeof o.componentWillReceiveProps||(a!==h||d!==c)&&ws(t,o,n,c),os=!1,d=t.memoizedState,o.state=d,ds(t,n,o,i);var p=t.memoizedState;a!==h||d!==p||fi.current||os?("function"===typeof f&&(gs(t,r,f,n),p=t.memoizedState),(u=os||ys(t,r,u,n,d,p,c))?(l||"function"!==typeof o.UNSAFE_componentWillUpdate&&"function"!==typeof o.componentWillUpdate||("function"===typeof o.componentWillUpdate&&o.componentWillUpdate(n,p,c),"function"===typeof o.UNSAFE_componentWillUpdate&&o.UNSAFE_componentWillUpdate(n,p,c)),"function"===typeof o.componentDidUpdate&&(t.flags|=4),"function"===typeof o.getSnapshotBeforeUpdate&&(t.flags|=256)):("function"!==typeof o.componentDidUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof o.getSnapshotBeforeUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=256),t.memoizedProps=n,t.memoizedState=p),o.props=n,o.state=p,o.context=c,n=u):("function"!==typeof o.componentDidUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),"function"!==typeof o.getSnapshotBeforeUpdate||a===e.memoizedProps&&d===e.memoizedState||(t.flags|=256),n=!1)}return Ho(e,t,r,n,s,i)}function Ho(e,t,r,n,i,s){Vo(e,t);var o=0!==(64&t.flags);if(!n&&!o)return i&&_i(t,r,!1),sa(e,t,s);n=t.stateNode,Uo.current=t;var a=o&&"function"!==typeof r.getDerivedStateFromError?null:n.render();return t.flags|=1,null!==e&&o?(t.child=ks(t,e.child,null,s),t.child=ks(t,null,a,s)):Mo(e,t,a,s),t.memoizedState=n.state,i&&_i(t,r,!0),t.child}function jo(e){var t=e.stateNode;t.pendingContext?mi(0,t.pendingContext,t.pendingContext!==t.context):t.context&&mi(0,t.context,!1),Ds(e,t.containerInfo)}var Go,Wo,Yo,Qo,Jo={dehydrated:null,retryLane:0};function Xo(e,t,r){var n,i=t.pendingProps,s=Ls.current,o=!1;return(n=0!==(64&t.flags))||(n=(null===e||null!==e.memoizedState)&&0!==(2&s)),n?(o=!0,t.flags&=-65):null!==e&&null===e.memoizedState||void 0===i.fallback||!0===i.unstable_avoidThisFallback||(s|=1),li(Ls,1&s),null===e?(void 0!==i.fallback&&zs(t),e=i.children,s=i.fallback,o?(e=Zo(t,e,s,r),t.child.memoizedState={baseLanes:r},t.memoizedState=Jo,e):"number"===typeof i.unstable_expectedLoadTime?(e=Zo(t,e,s,r),t.child.memoizedState={baseLanes:r},t.memoizedState=Jo,t.lanes=33554432,e):((r=Yc({mode:"visible",children:e},t.mode,r,null)).return=t,t.child=r)):(e.memoizedState,o?(i=ta(e,t,i.children,i.fallback,r),o=t.child,s=e.child.memoizedState,o.memoizedState=null===s?{baseLanes:r}:{baseLanes:s.baseLanes|r},o.childLanes=e.childLanes&~r,t.memoizedState=Jo,i):(r=ea(e,t,i.children,r),t.memoizedState=null,r))}function Zo(e,t,r,n){var i=e.mode,s=e.child;return t={mode:"hidden",children:t},0===(2&i)&&null!==s?(s.childLanes=0,s.pendingProps=t):s=Yc(t,i,0,null),r=Wc(r,i,n,null),s.return=e,r.return=e,s.sibling=r,e.child=s,r}function ea(e,t,r,n){var i=e.child;return e=i.sibling,r=jc(i,{mode:"visible",children:r}),0===(2&t.mode)&&(r.lanes=n),r.return=t,r.sibling=null,null!==e&&(e.nextEffect=null,e.flags=8,t.firstEffect=t.lastEffect=e),t.child=r}function ta(e,t,r,n,i){var s=t.mode,o=e.child;e=o.sibling;var a={mode:"hidden",children:r};return 0===(2&s)&&t.child!==o?((r=t.child).childLanes=0,r.pendingProps=a,null!==(o=r.lastEffect)?(t.firstEffect=r.firstEffect,t.lastEffect=o,o.nextEffect=null):t.firstEffect=t.lastEffect=null):r=jc(o,a),null!==e?n=jc(e,n):(n=Wc(n,s,i,null)).flags|=2,n.return=t,r.return=t,r.sibling=n,t.child=r,n}function ra(e,t){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),ns(e.return,t)}function na(e,t,r,n,i,s){var o=e.memoizedState;null===o?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:n,tail:r,tailMode:i,lastEffect:s}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=n,o.tail=r,o.tailMode=i,o.lastEffect=s)}function ia(e,t,r){var n=t.pendingProps,i=n.revealOrder,s=n.tail;if(Mo(e,t,n.children,r),0!==(2&(n=Ls.current)))n=1&n|2,t.flags|=64;else{if(null!==e&&0!==(64&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&ra(e,r);else if(19===e.tag)ra(e,r);else if(null!==e.child){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;null===e.sibling;){if(null===e.return||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}n&=1}if(li(Ls,n),0===(2&t.mode))t.memoizedState=null;else switch(i){case"forwards":for(r=t.child,i=null;null!==r;)null!==(e=r.alternate)&&null===Ms(e)&&(i=r),r=r.sibling;null===(r=i)?(i=t.child,t.child=null):(i=r.sibling,r.sibling=null),na(t,!1,i,r,s,t.lastEffect);break;case"backwards":for(r=null,i=t.child,t.child=null;null!==i;){if(null!==(e=i.alternate)&&null===Ms(e)){t.child=i;break}e=i.sibling,i.sibling=r,r=i,i=e}na(t,!0,r,null,s,t.lastEffect);break;case"together":na(t,!1,null,null,void 0,t.lastEffect);break;default:t.memoizedState=null}return t.child}function sa(e,t,r){if(null!==e&&(t.dependencies=e.dependencies),Fa|=t.lanes,0!==(r&t.childLanes)){if(null!==e&&t.child!==e.child)throw Error(o(153));if(null!==t.child){for(r=jc(e=t.child,e.pendingProps),t.child=r,r.return=t;null!==e.sibling;)e=e.sibling,(r=r.sibling=jc(e,e.pendingProps)).return=t;r.sibling=null}return t.child}return null}function oa(e,t){if(!Ks)switch(e.tailMode){case"hidden":t=e.tail;for(var r=null;null!==t;)null!==t.alternate&&(r=t),t=t.sibling;null===r?e.tail=null:r.sibling=null;break;case"collapsed":r=e.tail;for(var n=null;null!==r;)null!==r.alternate&&(n=r),r=r.sibling;null===n?t||null===e.tail?e.tail=null:e.tail.sibling=null:n.sibling=null}}function aa(e,t,r){var n=t.pendingProps;switch(t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return null;case 1:case 17:return bi(t.type)&&yi(),null;case 3:return Ns(),ui(fi),ui(di),Ws(),(n=t.stateNode).pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),null!==e&&null!==e.child||(Hs(t)?t.flags|=4:n.hydrate||(t.flags|=256)),Wo(t),null;case 5:Us(t);var s=Ps(Rs.current);if(r=t.type,null!==e&&null!=t.stateNode)Yo(e,t,r,n,s),e.ref!==t.ref&&(t.flags|=128);else{if(!n){if(null===t.stateNode)throw Error(o(166));return null}if(e=Ps(Cs.current),Hs(t)){n=t.stateNode,r=t.type;var a=t.memoizedProps;switch(n[Jn]=t,n[Xn]=a,r){case"dialog":Tn("cancel",n),Tn("close",n);break;case"iframe":case"object":case"embed":Tn("load",n);break;case"video":case"audio":for(e=0;e<kn.length;e++)Tn(kn[e],n);break;case"source":Tn("error",n);break;case"img":case"image":case"link":Tn("error",n),Tn("load",n);break;case"details":Tn("toggle",n);break;case"input":ee(n,a),Tn("invalid",n);break;case"select":n._wrapperState={wasMultiple:!!a.multiple},Tn("invalid",n);break;case"textarea":ce(n,a),Tn("invalid",n)}for(var u in Se(r,a),e=null,a)a.hasOwnProperty(u)&&(s=a[u],"children"===u?"string"===typeof s?n.textContent!==s&&(e=["children",s]):"number"===typeof s&&n.textContent!==""+s&&(e=["children",""+s]):c.hasOwnProperty(u)&&null!=s&&"onScroll"===u&&Tn("scroll",n));switch(r){case"input":Q(n),ne(n,a,!0);break;case"textarea":Q(n),le(n);break;case"select":case"option":break;default:"function"===typeof a.onClick&&(n.onclick=qn)}n=e,t.updateQueue=n,null!==n&&(t.flags|=4)}else{switch(u=9===s.nodeType?s:s.ownerDocument,e===he.html&&(e=de(r)),e===he.html?"script"===r?((e=u.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"===typeof n.is?e=u.createElement(r,{is:n.is}):(e=u.createElement(r),"select"===r&&(u=e,n.multiple?u.multiple=!0:n.size&&(u.size=n.size))):e=u.createElementNS(e,r),e[Jn]=t,e[Xn]=n,Go(e,t,!1,!1),t.stateNode=e,u=Ae(r,n),r){case"dialog":Tn("cancel",e),Tn("close",e),s=n;break;case"iframe":case"object":case"embed":Tn("load",e),s=n;break;case"video":case"audio":for(s=0;s<kn.length;s++)Tn(kn[s],e);s=n;break;case"source":Tn("error",e),s=n;break;case"img":case"image":case"link":Tn("error",e),Tn("load",e),s=n;break;case"details":Tn("toggle",e),s=n;break;case"input":ee(e,n),s=Z(e,n),Tn("invalid",e);break;case"option":s=se(e,n);break;case"select":e._wrapperState={wasMultiple:!!n.multiple},s=i({},n,{value:void 0}),Tn("invalid",e);break;case"textarea":ce(e,n),s=ae(e,n),Tn("invalid",e);break;default:s=n}Se(r,s);var l=s;for(a in l)if(l.hasOwnProperty(a)){var h=l[a];"style"===a?_e(e,h):"dangerouslySetInnerHTML"===a?null!=(h=h?h.__html:void 0)&&be(e,h):"children"===a?"string"===typeof h?("textarea"!==r||""!==h)&&ye(e,h):"number"===typeof h&&ye(e,""+h):"suppressContentEditableWarning"!==a&&"suppressHydrationWarning"!==a&&"autoFocus"!==a&&(c.hasOwnProperty(a)?null!=h&&"onScroll"===a&&Tn("scroll",e):null!=h&&v(e,a,h,u))}switch(r){case"input":Q(e),ne(e,n,!1);break;case"textarea":Q(e),le(e);break;case"option":null!=n.value&&e.setAttribute("value",""+W(n.value));break;case"select":e.multiple=!!n.multiple,null!=(a=n.value)?oe(e,!!n.multiple,a,!1):null!=n.defaultValue&&oe(e,!!n.multiple,n.defaultValue,!0);break;default:"function"===typeof s.onClick&&(e.onclick=qn)}Vn(r,n)&&(t.flags|=4)}null!==t.ref&&(t.flags|=128)}return null;case 6:if(e&&null!=t.stateNode)Qo(e,t,e.memoizedProps,n);else{if("string"!==typeof n&&null===t.stateNode)throw Error(o(166));r=Ps(Rs.current),Ps(Cs.current),Hs(t)?(n=t.stateNode,r=t.memoizedProps,n[Jn]=t,n.nodeValue!==r&&(t.flags|=4)):((n=(9===r.nodeType?r:r.ownerDocument).createTextNode(n))[Jn]=t,t.stateNode=n)}return null;case 13:return ui(Ls),n=t.memoizedState,0!==(64&t.flags)?(t.lanes=r,t):(n=null!==n,r=!1,null===e?void 0!==t.memoizedProps.fallback&&Hs(t):r=null!==e.memoizedState,n&&!r&&0!==(2&t.mode)&&(null===e&&!0!==t.memoizedProps.unstable_avoidThisFallback||0!==(1&Ls.current)?0===Oa&&(Oa=3):(0!==Oa&&3!==Oa||(Oa=4),null===Na||0===(134217727&Fa)&&0===(134217727&Va)||mc(Na,Ua))),(n||r)&&(t.flags|=4),null);case 4:return Ns(),Wo(t),null===e&&Pn(t.stateNode.containerInfo),null;case 10:return rs(t),null;case 19:if(ui(Ls),null===(n=t.memoizedState))return null;if(a=0!==(64&t.flags),null===(u=n.rendering))if(a)oa(n,!1);else{if(0!==Oa||null!==e&&0!==(64&e.flags))for(e=t.child;null!==e;){if(null!==(u=Ms(e))){for(t.flags|=64,oa(n,!1),null!==(a=u.updateQueue)&&(t.updateQueue=a,t.flags|=4),null===n.lastEffect&&(t.firstEffect=null),t.lastEffect=n.lastEffect,n=r,r=t.child;null!==r;)e=n,(a=r).flags&=2,a.nextEffect=null,a.firstEffect=null,a.lastEffect=null,null===(u=a.alternate)?(a.childLanes=0,a.lanes=e,a.child=null,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=u.childLanes,a.lanes=u.lanes,a.child=u.child,a.memoizedProps=u.memoizedProps,a.memoizedState=u.memoizedState,a.updateQueue=u.updateQueue,a.type=u.type,e=u.dependencies,a.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),r=r.sibling;return li(Ls,1&Ls.current|2),t.child}e=e.sibling}null!==n.tail&&Vi()>ja&&(t.flags|=64,a=!0,oa(n,!1),t.lanes=33554432)}else{if(!a)if(null!==(e=Ms(u))){if(t.flags|=64,a=!0,null!==(r=e.updateQueue)&&(t.updateQueue=r,t.flags|=4),oa(n,!0),null===n.tail&&"hidden"===n.tailMode&&!u.alternate&&!Ks)return null!==(t=t.lastEffect=n.lastEffect)&&(t.nextEffect=null),null}else 2*Vi()-n.renderingStartTime>ja&&1073741824!==r&&(t.flags|=64,a=!0,oa(n,!1),t.lanes=33554432);n.isBackwards?(u.sibling=t.child,t.child=u):(null!==(r=n.last)?r.sibling=u:t.child=u,n.last=u)}return null!==n.tail?(r=n.tail,n.rendering=r,n.tail=r.sibling,n.lastEffect=t.lastEffect,n.renderingStartTime=Vi(),r.sibling=null,t=Ls.current,li(Ls,a?1&t|2:1&t),r):null;case 23:case 24:return Sc(),null!==e&&null!==e.memoizedState!==(null!==t.memoizedState)&&"unstable-defer-without-hiding"!==n.mode&&(t.flags|=4),null}throw Error(o(156,t.tag))}function ca(e){switch(e.tag){case 1:bi(e.type)&&yi();var t=e.flags;return 4096&t?(e.flags=-4097&t|64,e):null;case 3:if(Ns(),ui(fi),ui(di),Ws(),0!==(64&(t=e.flags)))throw Error(o(285));return e.flags=-4097&t|64,e;case 5:return Us(e),null;case 13:return ui(Ls),4096&(t=e.flags)?(e.flags=-4097&t|64,e):null;case 19:return ui(Ls),null;case 4:return Ns(),null;case 10:return rs(e),null;case 23:case 24:return Sc(),null;default:return null}}function ua(e,t){try{var r="",n=t;do{r+=j(n),n=n.return}while(n);var i=r}catch(s){i="\nError generating stack: "+s.message+"\n"+s.stack}return{value:e,source:t,stack:i}}function la(e,t){try{console.error(t.value)}catch(r){setTimeout((function(){throw r}))}}Go=function(e,t){for(var r=t.child;null!==r;){if(5===r.tag||6===r.tag)e.appendChild(r.stateNode);else if(4!==r.tag&&null!==r.child){r.child.return=r,r=r.child;continue}if(r===t)break;for(;null===r.sibling;){if(null===r.return||r.return===t)return;r=r.return}r.sibling.return=r.return,r=r.sibling}},Wo=function(){},Yo=function(e,t,r,n){var s=e.memoizedProps;if(s!==n){e=t.stateNode,Ps(Cs.current);var o,a=null;switch(r){case"input":s=Z(e,s),n=Z(e,n),a=[];break;case"option":s=se(e,s),n=se(e,n),a=[];break;case"select":s=i({},s,{value:void 0}),n=i({},n,{value:void 0}),a=[];break;case"textarea":s=ae(e,s),n=ae(e,n),a=[];break;default:"function"!==typeof s.onClick&&"function"===typeof n.onClick&&(e.onclick=qn)}for(h in Se(r,n),r=null,s)if(!n.hasOwnProperty(h)&&s.hasOwnProperty(h)&&null!=s[h])if("style"===h){var u=s[h];for(o in u)u.hasOwnProperty(o)&&(r||(r={}),r[o]="")}else"dangerouslySetInnerHTML"!==h&&"children"!==h&&"suppressContentEditableWarning"!==h&&"suppressHydrationWarning"!==h&&"autoFocus"!==h&&(c.hasOwnProperty(h)?a||(a=[]):(a=a||[]).push(h,null));for(h in n){var l=n[h];if(u=null!=s?s[h]:void 0,n.hasOwnProperty(h)&&l!==u&&(null!=l||null!=u))if("style"===h)if(u){for(o in u)!u.hasOwnProperty(o)||l&&l.hasOwnProperty(o)||(r||(r={}),r[o]="");for(o in l)l.hasOwnProperty(o)&&u[o]!==l[o]&&(r||(r={}),r[o]=l[o])}else r||(a||(a=[]),a.push(h,r)),r=l;else"dangerouslySetInnerHTML"===h?(l=l?l.__html:void 0,u=u?u.__html:void 0,null!=l&&u!==l&&(a=a||[]).push(h,l)):"children"===h?"string"!==typeof l&&"number"!==typeof l||(a=a||[]).push(h,""+l):"suppressContentEditableWarning"!==h&&"suppressHydrationWarning"!==h&&(c.hasOwnProperty(h)?(null!=l&&"onScroll"===h&&Tn("scroll",e),a||u===l||(a=[])):"object"===typeof l&&null!==l&&l.$$typeof===U?l.toString():(a=a||[]).push(h,l))}r&&(a=a||[]).push("style",r);var h=a;(t.updateQueue=h)&&(t.flags|=4)}},Qo=function(e,t,r,n){r!==n&&(t.flags|=4)};var ha="function"===typeof WeakMap?WeakMap:Map;function da(e,t,r){(r=us(-1,r)).tag=3,r.payload={element:null};var n=t.value;return r.callback=function(){Qa||(Qa=!0,Ja=n),la(0,t)},r}function fa(e,t,r){(r=us(-1,r)).tag=3;var n=e.type.getDerivedStateFromError;if("function"===typeof n){var i=t.value;r.payload=function(){return la(0,t),n(i)}}var s=e.stateNode;return null!==s&&"function"===typeof s.componentDidCatch&&(r.callback=function(){"function"!==typeof n&&(null===Xa?Xa=new Set([this]):Xa.add(this),la(0,t));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),r}var pa="function"===typeof WeakSet?WeakSet:Set;function ga(e){var t=e.ref;if(null!==t)if("function"===typeof t)try{t(null)}catch(r){Kc(e,r)}else t.current=null}function ba(e,t){switch(t.tag){case 0:case 11:case 15:case 22:case 5:case 6:case 4:case 17:return;case 1:if(256&t.flags&&null!==e){var r=e.memoizedProps,n=e.memoizedState;t=(e=t.stateNode).getSnapshotBeforeUpdate(t.elementType===t.type?r:Qi(t.type,r),n),e.__reactInternalSnapshotBeforeUpdate=t}return;case 3:return void(256&t.flags&&jn(t.stateNode.containerInfo))}throw Error(o(163))}function ya(e,t,r){switch(r.tag){case 0:case 11:case 15:case 22:if(null!==(t=null!==(t=r.updateQueue)?t.lastEffect:null)){e=t=t.next;do{if(3===(3&e.tag)){var n=e.create;e.destroy=n()}e=e.next}while(e!==t)}if(null!==(t=null!==(t=r.updateQueue)?t.lastEffect:null)){e=t=t.next;do{var i=e;n=i.next,0!==(4&(i=i.tag))&&0!==(1&i)&&(Mc(r,e),Lc(r,e)),e=n}while(e!==t)}return;case 1:return e=r.stateNode,4&r.flags&&(null===t?e.componentDidMount():(n=r.elementType===r.type?t.memoizedProps:Qi(r.type,t.memoizedProps),e.componentDidUpdate(n,t.memoizedState,e.__reactInternalSnapshotBeforeUpdate))),void(null!==(t=r.updateQueue)&&fs(r,t,e));case 3:if(null!==(t=r.updateQueue)){if(e=null,null!==r.child)switch(r.child.tag){case 5:case 1:e=r.child.stateNode}fs(r,t,e)}return;case 5:return e=r.stateNode,void(null===t&&4&r.flags&&Vn(r.type,r.memoizedProps)&&e.focus());case 6:case 4:case 12:case 19:case 17:case 20:case 21:case 23:case 24:return;case 13:return void(null===r.memoizedState&&(r=r.alternate,null!==r&&(r=r.memoizedState,null!==r&&(r=r.dehydrated,null!==r&&_t(r)))))}throw Error(o(163))}function ma(e,t){for(var r=e;;){if(5===r.tag){var n=r.stateNode;if(t)"function"===typeof(n=n.style).setProperty?n.setProperty("display","none","important"):n.display="none";else{n=r.stateNode;var i=r.memoizedProps.style;i=void 0!==i&&null!==i&&i.hasOwnProperty("display")?i.display:null,n.style.display=ve("display",i)}}else if(6===r.tag)r.stateNode.nodeValue=t?"":r.memoizedProps;else if((23!==r.tag&&24!==r.tag||null===r.memoizedState||r===e)&&null!==r.child){r.child.return=r,r=r.child;continue}if(r===e)break;for(;null===r.sibling;){if(null===r.return||r.return===e)return;r=r.return}r.sibling.return=r.return,r=r.sibling}}function wa(e,t){if(Si&&"function"===typeof Si.onCommitFiberUnmount)try{Si.onCommitFiberUnmount(Ei,t)}catch(s){}switch(t.tag){case 0:case 11:case 14:case 15:case 22:if(null!==(e=t.updateQueue)&&null!==(e=e.lastEffect)){var r=e=e.next;do{var n=r,i=n.destroy;if(n=n.tag,void 0!==i)if(0!==(4&n))Mc(t,r);else{n=t;try{i()}catch(s){Kc(n,s)}}r=r.next}while(r!==e)}break;case 1:if(ga(t),"function"===typeof(e=t.stateNode).componentWillUnmount)try{e.props=t.memoizedProps,e.state=t.memoizedState,e.componentWillUnmount()}catch(s){Kc(t,s)}break;case 5:ga(t);break;case 4:ka(e,t)}}function va(e){e.alternate=null,e.child=null,e.dependencies=null,e.firstEffect=null,e.lastEffect=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.return=null,e.updateQueue=null}function _a(e){return 5===e.tag||3===e.tag||4===e.tag}function Ea(e){e:{for(var t=e.return;null!==t;){if(_a(t))break e;t=t.return}throw Error(o(160))}var r=t;switch(t=r.stateNode,r.tag){case 5:var n=!1;break;case 3:case 4:t=t.containerInfo,n=!0;break;default:throw Error(o(161))}16&r.flags&&(ye(t,""),r.flags&=-17);e:t:for(r=e;;){for(;null===r.sibling;){if(null===r.return||_a(r.return)){r=null;break e}r=r.return}for(r.sibling.return=r.return,r=r.sibling;5!==r.tag&&6!==r.tag&&18!==r.tag;){if(2&r.flags)continue t;if(null===r.child||4===r.tag)continue t;r.child.return=r,r=r.child}if(!(2&r.flags)){r=r.stateNode;break e}}n?Sa(e,r,t):Aa(e,r,t)}function Sa(e,t,r){var n=e.tag,i=5===n||6===n;if(i)e=i?e.stateNode:e.stateNode.instance,t?8===r.nodeType?r.parentNode.insertBefore(e,t):r.insertBefore(e,t):(8===r.nodeType?(t=r.parentNode).insertBefore(e,r):(t=r).appendChild(e),null!==(r=r._reactRootContainer)&&void 0!==r||null!==t.onclick||(t.onclick=qn));else if(4!==n&&null!==(e=e.child))for(Sa(e,t,r),e=e.sibling;null!==e;)Sa(e,t,r),e=e.sibling}function Aa(e,t,r){var n=e.tag,i=5===n||6===n;if(i)e=i?e.stateNode:e.stateNode.instance,t?r.insertBefore(e,t):r.appendChild(e);else if(4!==n&&null!==(e=e.child))for(Aa(e,t,r),e=e.sibling;null!==e;)Aa(e,t,r),e=e.sibling}function ka(e,t){for(var r,n,i=t,s=!1;;){if(!s){s=i.return;e:for(;;){if(null===s)throw Error(o(160));switch(r=s.stateNode,s.tag){case 5:n=!1;break e;case 3:case 4:r=r.containerInfo,n=!0;break e}s=s.return}s=!0}if(5===i.tag||6===i.tag){e:for(var a=e,c=i,u=c;;)if(wa(a,u),null!==u.child&&4!==u.tag)u.child.return=u,u=u.child;else{if(u===c)break e;for(;null===u.sibling;){if(null===u.return||u.return===c)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}n?(a=r,c=i.stateNode,8===a.nodeType?a.parentNode.removeChild(c):a.removeChild(c)):r.removeChild(i.stateNode)}else if(4===i.tag){if(null!==i.child){r=i.stateNode.containerInfo,n=!0,i.child.return=i,i=i.child;continue}}else if(wa(e,i),null!==i.child){i.child.return=i,i=i.child;continue}if(i===t)break;for(;null===i.sibling;){if(null===i.return||i.return===t)return;4===(i=i.return).tag&&(s=!1)}i.sibling.return=i.return,i=i.sibling}}function xa(e,t){switch(t.tag){case 0:case 11:case 14:case 15:case 22:var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var n=r=r.next;do{3===(3&n.tag)&&(e=n.destroy,n.destroy=void 0,void 0!==e&&e()),n=n.next}while(n!==r)}return;case 1:case 12:case 17:return;case 5:if(null!=(r=t.stateNode)){n=t.memoizedProps;var i=null!==e?e.memoizedProps:n;e=t.type;var s=t.updateQueue;if(t.updateQueue=null,null!==s){for(r[Xn]=n,"input"===e&&"radio"===n.type&&null!=n.name&&te(r,n),Ae(e,i),t=Ae(e,n),i=0;i<s.length;i+=2){var a=s[i],c=s[i+1];"style"===a?_e(r,c):"dangerouslySetInnerHTML"===a?be(r,c):"children"===a?ye(r,c):v(r,a,c,t)}switch(e){case"input":re(r,n);break;case"textarea":ue(r,n);break;case"select":e=r._wrapperState.wasMultiple,r._wrapperState.wasMultiple=!!n.multiple,null!=(s=n.value)?oe(r,!!n.multiple,s,!1):e!==!!n.multiple&&(null!=n.defaultValue?oe(r,!!n.multiple,n.defaultValue,!0):oe(r,!!n.multiple,n.multiple?[]:"",!1))}}}return;case 6:if(null===t.stateNode)throw Error(o(162));return void(t.stateNode.nodeValue=t.memoizedProps);case 3:return void((r=t.stateNode).hydrate&&(r.hydrate=!1,_t(r.containerInfo)));case 13:return null!==t.memoizedState&&(Ha=Vi(),ma(t.child,!0)),void Ia(t);case 19:return void Ia(t);case 23:case 24:return void ma(t,null!==t.memoizedState)}throw Error(o(163))}function Ia(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var r=e.stateNode;null===r&&(r=e.stateNode=new pa),t.forEach((function(t){var n=Vc.bind(null,e,t);r.has(t)||(r.add(t),t.then(n,n))}))}}function Ca(e,t){return null!==e&&(null===(e=e.memoizedState)||null!==e.dehydrated)&&(null!==(t=t.memoizedState)&&null===t.dehydrated)}var Ta=Math.ceil,Ra=_.ReactCurrentDispatcher,Pa=_.ReactCurrentOwner,Da=0,Na=null,Ba=null,Ua=0,La=0,Ma=ci(0),Oa=0,qa=null,Ka=0,Fa=0,Va=0,za=0,$a=null,Ha=0,ja=1/0;function Ga(){ja=Vi()+500}var Wa,Ya=null,Qa=!1,Ja=null,Xa=null,Za=!1,ec=null,tc=90,rc=[],nc=[],ic=null,sc=0,oc=null,ac=-1,cc=0,uc=0,lc=null,hc=!1;function dc(){return 0!==(48&Da)?Vi():-1!==ac?ac:ac=Vi()}function fc(e){if(0===(2&(e=e.mode)))return 1;if(0===(4&e))return 99===zi()?1:2;if(0===cc&&(cc=Ka),0!==Yi.transition){0!==uc&&(uc=null!==$a?$a.pendingLanes:0),e=cc;var t=4186112&~uc;return 0===(t&=-t)&&(0===(t=(e=4186112&~e)&-e)&&(t=8192)),t}return e=zi(),0!==(4&Da)&&98===e?e=qt(12,cc):e=qt(e=function(e){switch(e){case 99:return 15;case 98:return 10;case 97:case 96:return 8;case 95:return 2;default:return 0}}(e),cc),e}function pc(e,t,r){if(50<sc)throw sc=0,oc=null,Error(o(185));if(null===(e=gc(e,t)))return null;Vt(e,t,r),e===Na&&(Va|=t,4===Oa&&mc(e,Ua));var n=zi();1===t?0!==(8&Da)&&0===(48&Da)?wc(e):(bc(e,r),0===Da&&(Ga(),Gi())):(0===(4&Da)||98!==n&&99!==n||(null===ic?ic=new Set([e]):ic.add(e)),bc(e,r)),$a=e}function gc(e,t){e.lanes|=t;var r=e.alternate;for(null!==r&&(r.lanes|=t),r=e,e=e.return;null!==e;)e.childLanes|=t,null!==(r=e.alternate)&&(r.childLanes|=t),r=e,e=e.return;return 3===r.tag?r.stateNode:null}function bc(e,t){for(var r=e.callbackNode,n=e.suspendedLanes,i=e.pingedLanes,s=e.expirationTimes,a=e.pendingLanes;0<a;){var c=31-zt(a),u=1<<c,l=s[c];if(-1===l){if(0===(u&n)||0!==(u&i)){l=t,Lt(u);var h=Ut;s[c]=10<=h?l+250:6<=h?l+5e3:-1}}else l<=t&&(e.expiredLanes|=u);a&=~u}if(n=Mt(e,e===Na?Ua:0),t=Ut,0===n)null!==r&&(r!==Li&&xi(r),e.callbackNode=null,e.callbackPriority=0);else{if(null!==r){if(e.callbackPriority===t)return;r!==Li&&xi(r)}15===t?(r=wc.bind(null,e),null===Oi?(Oi=[r],qi=ki(Pi,Wi)):Oi.push(r),r=Li):14===t?r=ji(99,wc.bind(null,e)):(r=function(e){switch(e){case 15:case 14:return 99;case 13:case 12:case 11:case 10:return 98;case 9:case 8:case 7:case 6:case 4:case 5:return 97;case 3:case 2:case 1:return 95;case 0:return 90;default:throw Error(o(358,e))}}(t),r=ji(r,yc.bind(null,e))),e.callbackPriority=t,e.callbackNode=r}}function yc(e){if(ac=-1,uc=cc=0,0!==(48&Da))throw Error(o(327));var t=e.callbackNode;if(Uc()&&e.callbackNode!==t)return null;var r=Mt(e,e===Na?Ua:0);if(0===r)return null;var n=r,i=Da;Da|=16;var s=xc();for(Na===e&&Ua===n||(Ga(),Ac(e,n));;)try{Tc();break}catch(c){kc(e,c)}if(ts(),Ra.current=s,Da=i,null!==Ba?n=0:(Na=null,Ua=0,n=Oa),0!==(Ka&Va))Ac(e,0);else if(0!==n){if(2===n&&(Da|=64,e.hydrate&&(e.hydrate=!1,jn(e.containerInfo)),0!==(r=Ot(e))&&(n=Ic(e,r))),1===n)throw t=qa,Ac(e,0),mc(e,r),bc(e,Vi()),t;switch(e.finishedWork=e.current.alternate,e.finishedLanes=r,n){case 0:case 1:throw Error(o(345));case 2:case 5:Dc(e);break;case 3:if(mc(e,r),(62914560&r)===r&&10<(n=Ha+500-Vi())){if(0!==Mt(e,0))break;if(((i=e.suspendedLanes)&r)!==r){dc(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=$n(Dc.bind(null,e),n);break}Dc(e);break;case 4:if(mc(e,r),(4186112&r)===r)break;for(n=e.eventTimes,i=-1;0<r;){var a=31-zt(r);s=1<<a,(a=n[a])>i&&(i=a),r&=~s}if(r=i,10<(r=(120>(r=Vi()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ta(r/1960))-r)){e.timeoutHandle=$n(Dc.bind(null,e),r);break}Dc(e);break;default:throw Error(o(329))}}return bc(e,Vi()),e.callbackNode===t?yc.bind(null,e):null}function mc(e,t){for(t&=~za,t&=~Va,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var r=31-zt(t),n=1<<r;e[r]=-1,t&=~n}}function wc(e){if(0!==(48&Da))throw Error(o(327));if(Uc(),e===Na&&0!==(e.expiredLanes&Ua)){var t=Ua,r=Ic(e,t);0!==(Ka&Va)&&(r=Ic(e,t=Mt(e,t)))}else r=Ic(e,t=Mt(e,0));if(0!==e.tag&&2===r&&(Da|=64,e.hydrate&&(e.hydrate=!1,jn(e.containerInfo)),0!==(t=Ot(e))&&(r=Ic(e,t))),1===r)throw r=qa,Ac(e,0),mc(e,t),bc(e,Vi()),r;return e.finishedWork=e.current.alternate,e.finishedLanes=t,Dc(e),bc(e,Vi()),null}function vc(e,t){var r=Da;Da|=1;try{return e(t)}finally{0===(Da=r)&&(Ga(),Gi())}}function _c(e,t){var r=Da;Da&=-2,Da|=8;try{return e(t)}finally{0===(Da=r)&&(Ga(),Gi())}}function Ec(e,t){li(Ma,La),La|=t,Ka|=t}function Sc(){La=Ma.current,ui(Ma)}function Ac(e,t){e.finishedWork=null,e.finishedLanes=0;var r=e.timeoutHandle;if(-1!==r&&(e.timeoutHandle=-1,Hn(r)),null!==Ba)for(r=Ba.return;null!==r;){var n=r;switch(n.tag){case 1:null!==(n=n.type.childContextTypes)&&void 0!==n&&yi();break;case 3:Ns(),ui(fi),ui(di),Ws();break;case 5:Us(n);break;case 4:Ns();break;case 13:case 19:ui(Ls);break;case 10:rs(n);break;case 23:case 24:Sc()}r=r.return}Na=e,Ba=jc(e.current,null),Ua=La=Ka=t,Oa=0,qa=null,za=Va=Fa=0}function kc(e,t){for(;;){var r=Ba;try{if(ts(),Ys.current=Po,to){for(var n=Xs.memoizedState;null!==n;){var i=n.queue;null!==i&&(i.pending=null),n=n.next}to=!1}if(Js=0,eo=Zs=Xs=null,ro=!1,Pa.current=null,null===r||null===r.return){Oa=1,qa=t,Ba=null;break}e:{var s=e,o=r.return,a=r,c=t;if(t=Ua,a.flags|=2048,a.firstEffect=a.lastEffect=null,null!==c&&"object"===typeof c&&"function"===typeof c.then){var u=c;if(0===(2&a.mode)){var l=a.alternate;l?(a.updateQueue=l.updateQueue,a.memoizedState=l.memoizedState,a.lanes=l.lanes):(a.updateQueue=null,a.memoizedState=null)}var h=0!==(1&Ls.current),d=o;do{var f;if(f=13===d.tag){var p=d.memoizedState;if(null!==p)f=null!==p.dehydrated;else{var g=d.memoizedProps;f=void 0!==g.fallback&&(!0!==g.unstable_avoidThisFallback||!h)}}if(f){var b=d.updateQueue;if(null===b){var y=new Set;y.add(u),d.updateQueue=y}else b.add(u);if(0===(2&d.mode)){if(d.flags|=64,a.flags|=16384,a.flags&=-2981,1===a.tag)if(null===a.alternate)a.tag=17;else{var m=us(-1,1);m.tag=2,ls(a,m)}a.lanes|=1;break e}c=void 0,a=t;var w=s.pingCache;if(null===w?(w=s.pingCache=new ha,c=new Set,w.set(u,c)):void 0===(c=w.get(u))&&(c=new Set,w.set(u,c)),!c.has(a)){c.add(a);var v=Fc.bind(null,s,u,a);u.then(v,v)}d.flags|=4096,d.lanes=t;break e}d=d.return}while(null!==d);c=Error((G(a.type)||"A React component")+" suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.")}5!==Oa&&(Oa=2),c=ua(c,a),d=o;do{switch(d.tag){case 3:s=c,d.flags|=4096,t&=-t,d.lanes|=t,hs(d,da(0,s,t));break e;case 1:s=c;var _=d.type,E=d.stateNode;if(0===(64&d.flags)&&("function"===typeof _.getDerivedStateFromError||null!==E&&"function"===typeof E.componentDidCatch&&(null===Xa||!Xa.has(E)))){d.flags|=4096,t&=-t,d.lanes|=t,hs(d,fa(d,s,t));break e}}d=d.return}while(null!==d)}Pc(r)}catch(S){t=S,Ba===r&&null!==r&&(Ba=r=r.return);continue}break}}function xc(){var e=Ra.current;return Ra.current=Po,null===e?Po:e}function Ic(e,t){var r=Da;Da|=16;var n=xc();for(Na===e&&Ua===t||Ac(e,t);;)try{Cc();break}catch(i){kc(e,i)}if(ts(),Da=r,Ra.current=n,null!==Ba)throw Error(o(261));return Na=null,Ua=0,Oa}function Cc(){for(;null!==Ba;)Rc(Ba)}function Tc(){for(;null!==Ba&&!Ii();)Rc(Ba)}function Rc(e){var t=Wa(e.alternate,e,La);e.memoizedProps=e.pendingProps,null===t?Pc(e):Ba=t,Pa.current=null}function Pc(e){var t=e;do{var r=t.alternate;if(e=t.return,0===(2048&t.flags)){if(null!==(r=aa(r,t,La)))return void(Ba=r);if(24!==(r=t).tag&&23!==r.tag||null===r.memoizedState||0!==(1073741824&La)||0===(4&r.mode)){for(var n=0,i=r.child;null!==i;)n|=i.lanes|i.childLanes,i=i.sibling;r.childLanes=n}null!==e&&0===(2048&e.flags)&&(null===e.firstEffect&&(e.firstEffect=t.firstEffect),null!==t.lastEffect&&(null!==e.lastEffect&&(e.lastEffect.nextEffect=t.firstEffect),e.lastEffect=t.lastEffect),1<t.flags&&(null!==e.lastEffect?e.lastEffect.nextEffect=t:e.firstEffect=t,e.lastEffect=t))}else{if(null!==(r=ca(t)))return r.flags&=2047,void(Ba=r);null!==e&&(e.firstEffect=e.lastEffect=null,e.flags|=2048)}if(null!==(t=t.sibling))return void(Ba=t);Ba=t=e}while(null!==t);0===Oa&&(Oa=5)}function Dc(e){var t=zi();return Hi(99,Nc.bind(null,e,t)),null}function Nc(e,t){do{Uc()}while(null!==ec);if(0!==(48&Da))throw Error(o(327));var r=e.finishedWork;if(null===r)return null;if(e.finishedWork=null,e.finishedLanes=0,r===e.current)throw Error(o(177));e.callbackNode=null;var n=r.lanes|r.childLanes,i=n,s=e.pendingLanes&~i;e.pendingLanes=i,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=i,e.mutableReadLanes&=i,e.entangledLanes&=i,i=e.entanglements;for(var a=e.eventTimes,c=e.expirationTimes;0<s;){var u=31-zt(s),l=1<<u;i[u]=0,a[u]=-1,c[u]=-1,s&=~l}if(null!==ic&&0===(24&n)&&ic.has(e)&&ic.delete(e),e===Na&&(Ba=Na=null,Ua=0),1<r.flags?null!==r.lastEffect?(r.lastEffect.nextEffect=r,n=r.firstEffect):n=r:n=r.firstEffect,null!==n){if(i=Da,Da|=32,Pa.current=null,Kn=Wt,bn(a=gn())){if("selectionStart"in a)c={start:a.selectionStart,end:a.selectionEnd};else e:if(c=(c=a.ownerDocument)&&c.defaultView||window,(l=c.getSelection&&c.getSelection())&&0!==l.rangeCount){c=l.anchorNode,s=l.anchorOffset,u=l.focusNode,l=l.focusOffset;try{c.nodeType,u.nodeType}catch(x){c=null;break e}var h=0,d=-1,f=-1,p=0,g=0,b=a,y=null;t:for(;;){for(var m;b!==c||0!==s&&3!==b.nodeType||(d=h+s),b!==u||0!==l&&3!==b.nodeType||(f=h+l),3===b.nodeType&&(h+=b.nodeValue.length),null!==(m=b.firstChild);)y=b,b=m;for(;;){if(b===a)break t;if(y===c&&++p===s&&(d=h),y===u&&++g===l&&(f=h),null!==(m=b.nextSibling))break;y=(b=y).parentNode}b=m}c=-1===d||-1===f?null:{start:d,end:f}}else c=null;c=c||{start:0,end:0}}else c=null;Fn={focusedElem:a,selectionRange:c},Wt=!1,lc=null,hc=!1,Ya=n;do{try{Bc()}catch(x){if(null===Ya)throw Error(o(330));Kc(Ya,x),Ya=Ya.nextEffect}}while(null!==Ya);lc=null,Ya=n;do{try{for(a=e;null!==Ya;){var w=Ya.flags;if(16&w&&ye(Ya.stateNode,""),128&w){var v=Ya.alternate;if(null!==v){var _=v.ref;null!==_&&("function"===typeof _?_(null):_.current=null)}}switch(1038&w){case 2:Ea(Ya),Ya.flags&=-3;break;case 6:Ea(Ya),Ya.flags&=-3,xa(Ya.alternate,Ya);break;case 1024:Ya.flags&=-1025;break;case 1028:Ya.flags&=-1025,xa(Ya.alternate,Ya);break;case 4:xa(Ya.alternate,Ya);break;case 8:ka(a,c=Ya);var E=c.alternate;va(c),null!==E&&va(E)}Ya=Ya.nextEffect}}catch(x){if(null===Ya)throw Error(o(330));Kc(Ya,x),Ya=Ya.nextEffect}}while(null!==Ya);if(_=Fn,v=gn(),w=_.focusedElem,a=_.selectionRange,v!==w&&w&&w.ownerDocument&&pn(w.ownerDocument.documentElement,w)){null!==a&&bn(w)&&(v=a.start,void 0===(_=a.end)&&(_=v),"selectionStart"in w?(w.selectionStart=v,w.selectionEnd=Math.min(_,w.value.length)):(_=(v=w.ownerDocument||document)&&v.defaultView||window).getSelection&&(_=_.getSelection(),c=w.textContent.length,E=Math.min(a.start,c),a=void 0===a.end?E:Math.min(a.end,c),!_.extend&&E>a&&(c=a,a=E,E=c),c=fn(w,E),s=fn(w,a),c&&s&&(1!==_.rangeCount||_.anchorNode!==c.node||_.anchorOffset!==c.offset||_.focusNode!==s.node||_.focusOffset!==s.offset)&&((v=v.createRange()).setStart(c.node,c.offset),_.removeAllRanges(),E>a?(_.addRange(v),_.extend(s.node,s.offset)):(v.setEnd(s.node,s.offset),_.addRange(v))))),v=[];for(_=w;_=_.parentNode;)1===_.nodeType&&v.push({element:_,left:_.scrollLeft,top:_.scrollTop});for("function"===typeof w.focus&&w.focus(),w=0;w<v.length;w++)(_=v[w]).element.scrollLeft=_.left,_.element.scrollTop=_.top}Wt=!!Kn,Fn=Kn=null,e.current=r,Ya=n;do{try{for(w=e;null!==Ya;){var S=Ya.flags;if(36&S&&ya(w,Ya.alternate,Ya),128&S){v=void 0;var A=Ya.ref;if(null!==A){var k=Ya.stateNode;Ya.tag,v=k,"function"===typeof A?A(v):A.current=v}}Ya=Ya.nextEffect}}catch(x){if(null===Ya)throw Error(o(330));Kc(Ya,x),Ya=Ya.nextEffect}}while(null!==Ya);Ya=null,Mi(),Da=i}else e.current=r;if(Za)Za=!1,ec=e,tc=t;else for(Ya=n;null!==Ya;)t=Ya.nextEffect,Ya.nextEffect=null,8&Ya.flags&&((S=Ya).sibling=null,S.stateNode=null),Ya=t;if(0===(n=e.pendingLanes)&&(Xa=null),1===n?e===oc?sc++:(sc=0,oc=e):sc=0,r=r.stateNode,Si&&"function"===typeof Si.onCommitFiberRoot)try{Si.onCommitFiberRoot(Ei,r,void 0,64===(64&r.current.flags))}catch(x){}if(bc(e,Vi()),Qa)throw Qa=!1,e=Ja,Ja=null,e;return 0!==(8&Da)||Gi(),null}function Bc(){for(;null!==Ya;){var e=Ya.alternate;hc||null===lc||(0!==(8&Ya.flags)?Ze(Ya,lc)&&(hc=!0):13===Ya.tag&&Ca(e,Ya)&&Ze(Ya,lc)&&(hc=!0));var t=Ya.flags;0!==(256&t)&&ba(e,Ya),0===(512&t)||Za||(Za=!0,ji(97,(function(){return Uc(),null}))),Ya=Ya.nextEffect}}function Uc(){if(90!==tc){var e=97<tc?97:tc;return tc=90,Hi(e,Oc)}return!1}function Lc(e,t){rc.push(t,e),Za||(Za=!0,ji(97,(function(){return Uc(),null})))}function Mc(e,t){nc.push(t,e),Za||(Za=!0,ji(97,(function(){return Uc(),null})))}function Oc(){if(null===ec)return!1;var e=ec;if(ec=null,0!==(48&Da))throw Error(o(331));var t=Da;Da|=32;var r=nc;nc=[];for(var n=0;n<r.length;n+=2){var i=r[n],s=r[n+1],a=i.destroy;if(i.destroy=void 0,"function"===typeof a)try{a()}catch(u){if(null===s)throw Error(o(330));Kc(s,u)}}for(r=rc,rc=[],n=0;n<r.length;n+=2){i=r[n],s=r[n+1];try{var c=i.create;i.destroy=c()}catch(u){if(null===s)throw Error(o(330));Kc(s,u)}}for(c=e.current.firstEffect;null!==c;)e=c.nextEffect,c.nextEffect=null,8&c.flags&&(c.sibling=null,c.stateNode=null),c=e;return Da=t,Gi(),!0}function qc(e,t,r){ls(e,t=da(0,t=ua(r,t),1)),t=dc(),null!==(e=gc(e,1))&&(Vt(e,1,t),bc(e,t))}function Kc(e,t){if(3===e.tag)qc(e,e,t);else for(var r=e.return;null!==r;){if(3===r.tag){qc(r,e,t);break}if(1===r.tag){var n=r.stateNode;if("function"===typeof r.type.getDerivedStateFromError||"function"===typeof n.componentDidCatch&&(null===Xa||!Xa.has(n))){var i=fa(r,e=ua(t,e),1);if(ls(r,i),i=dc(),null!==(r=gc(r,1)))Vt(r,1,i),bc(r,i);else if("function"===typeof n.componentDidCatch&&(null===Xa||!Xa.has(n)))try{n.componentDidCatch(t,e)}catch(s){}break}}r=r.return}}function Fc(e,t,r){var n=e.pingCache;null!==n&&n.delete(t),t=dc(),e.pingedLanes|=e.suspendedLanes&r,Na===e&&(Ua&r)===r&&(4===Oa||3===Oa&&(62914560&Ua)===Ua&&500>Vi()-Ha?Ac(e,0):za|=r),bc(e,t)}function Vc(e,t){var r=e.stateNode;null!==r&&r.delete(t),0===(t=0)&&(0===(2&(t=e.mode))?t=1:0===(4&t)?t=99===zi()?1:2:(0===cc&&(cc=Ka),0===(t=Kt(62914560&~cc))&&(t=4194304))),r=dc(),null!==(e=gc(e,t))&&(Vt(e,t,r),bc(e,r))}function zc(e,t,r,n){this.tag=e,this.key=r,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=n,this.flags=0,this.lastEffect=this.firstEffect=this.nextEffect=null,this.childLanes=this.lanes=0,this.alternate=null}function $c(e,t,r,n){return new zc(e,t,r,n)}function Hc(e){return!(!(e=e.prototype)||!e.isReactComponent)}function jc(e,t){var r=e.alternate;return null===r?((r=$c(e.tag,t,e.key,e.mode)).elementType=e.elementType,r.type=e.type,r.stateNode=e.stateNode,r.alternate=e,e.alternate=r):(r.pendingProps=t,r.type=e.type,r.flags=0,r.nextEffect=null,r.firstEffect=null,r.lastEffect=null),r.childLanes=e.childLanes,r.lanes=e.lanes,r.child=e.child,r.memoizedProps=e.memoizedProps,r.memoizedState=e.memoizedState,r.updateQueue=e.updateQueue,t=e.dependencies,r.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},r.sibling=e.sibling,r.index=e.index,r.ref=e.ref,r}function Gc(e,t,r,n,i,s){var a=2;if(n=e,"function"===typeof e)Hc(e)&&(a=1);else if("string"===typeof e)a=5;else e:switch(e){case A:return Wc(r.children,i,s,t);case L:a=8,i|=16;break;case k:a=8,i|=1;break;case x:return(e=$c(12,r,t,8|i)).elementType=x,e.type=x,e.lanes=s,e;case R:return(e=$c(13,r,t,i)).type=R,e.elementType=R,e.lanes=s,e;case P:return(e=$c(19,r,t,i)).elementType=P,e.lanes=s,e;case M:return Yc(r,i,s,t);case O:return(e=$c(24,r,t,i)).elementType=O,e.lanes=s,e;default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case I:a=10;break e;case C:a=9;break e;case T:a=11;break e;case D:a=14;break e;case N:a=16,n=null;break e;case B:a=22;break e}throw Error(o(130,null==e?e:typeof e,""))}return(t=$c(a,r,t,i)).elementType=e,t.type=n,t.lanes=s,t}function Wc(e,t,r,n){return(e=$c(7,e,n,t)).lanes=r,e}function Yc(e,t,r,n){return(e=$c(23,e,n,t)).elementType=M,e.lanes=r,e}function Qc(e,t,r){return(e=$c(6,e,null,t)).lanes=r,e}function Jc(e,t,r){return(t=$c(4,null!==e.children?e.children:[],e.key,t)).lanes=r,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Xc(e,t,r){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.pendingContext=this.context=null,this.hydrate=r,this.callbackNode=null,this.callbackPriority=0,this.eventTimes=Ft(0),this.expirationTimes=Ft(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ft(0),this.mutableSourceEagerHydrationData=null}function Zc(e,t,r,n){var i=t.current,s=dc(),a=fc(i);e:if(r){t:{if(Ye(r=r._reactInternals)!==r||1!==r.tag)throw Error(o(170));var c=r;do{switch(c.tag){case 3:c=c.stateNode.context;break t;case 1:if(bi(c.type)){c=c.stateNode.__reactInternalMemoizedMergedChildContext;break t}}c=c.return}while(null!==c);throw Error(o(171))}if(1===r.tag){var u=r.type;if(bi(u)){r=wi(r,u,c);break e}}r=c}else r=hi;return null===t.context?t.context=r:t.pendingContext=r,(t=us(s,a)).payload={element:e},null!==(n=void 0===n?null:n)&&(t.callback=n),ls(i,t),pc(i,a,s),a}function eu(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function tu(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var r=e.retryLane;e.retryLane=0!==r&&r<t?r:t}}function ru(e,t){tu(e,t),(e=e.alternate)&&tu(e,t)}function nu(e,t,r){var n=null!=r&&null!=r.hydrationOptions&&r.hydrationOptions.mutableSources||null;if(r=new Xc(e,t,null!=r&&!0===r.hydrate),t=$c(3,null,null,2===t?7:1===t?3:0),r.current=t,t.stateNode=r,as(t),e[Zn]=r.current,Pn(8===e.nodeType?e.parentNode:e),n)for(e=0;e<n.length;e++){var i=(t=n[e])._getVersion;i=i(t._source),null==r.mutableSourceEagerHydrationData?r.mutableSourceEagerHydrationData=[t,i]:r.mutableSourceEagerHydrationData.push(t,i)}this._internalRoot=r}function iu(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function su(e,t,r,n,i){var s=r._reactRootContainer;if(s){var o=s._internalRoot;if("function"===typeof i){var a=i;i=function(){var e=eu(o);a.call(e)}}Zc(t,o,e,i)}else{if(s=r._reactRootContainer=function(e,t){if(t||(t=!(!(t=e?9===e.nodeType?e.documentElement:e.firstChild:null)||1!==t.nodeType||!t.hasAttribute("data-reactroot"))),!t)for(var r;r=e.lastChild;)e.removeChild(r);return new nu(e,0,t?{hydrate:!0}:void 0)}(r,n),o=s._internalRoot,"function"===typeof i){var c=i;i=function(){var e=eu(o);c.call(e)}}_c((function(){Zc(t,o,e,i)}))}return eu(o)}function ou(e,t){var r=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!iu(t))throw Error(o(200));return function(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:S,key:null==n?null:""+n,children:e,containerInfo:t,implementation:r}}(e,t,null,r)}Wa=function(e,t,r){var n=t.lanes;if(null!==e)if(e.memoizedProps!==t.pendingProps||fi.current)Lo=!0;else{if(0===(r&n)){switch(Lo=!1,t.tag){case 3:jo(t),js();break;case 5:Bs(t);break;case 1:bi(t.type)&&vi(t);break;case 4:Ds(t,t.stateNode.containerInfo);break;case 10:n=t.memoizedProps.value;var i=t.type._context;li(Ji,i._currentValue),i._currentValue=n;break;case 13:if(null!==t.memoizedState)return 0!==(r&t.child.childLanes)?Xo(e,t,r):(li(Ls,1&Ls.current),null!==(t=sa(e,t,r))?t.sibling:null);li(Ls,1&Ls.current);break;case 19:if(n=0!==(r&t.childLanes),0!==(64&e.flags)){if(n)return ia(e,t,r);t.flags|=64}if(null!==(i=t.memoizedState)&&(i.rendering=null,i.tail=null,i.lastEffect=null),li(Ls,Ls.current),n)break;return null;case 23:case 24:return t.lanes=0,Fo(e,t,r)}return sa(e,t,r)}Lo=0!==(16384&e.flags)}else Lo=!1;switch(t.lanes=0,t.tag){case 2:if(n=t.type,null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,i=gi(t,di.current),is(t,r),i=so(null,t,n,e,i,r),t.flags|=1,"object"===typeof i&&null!==i&&"function"===typeof i.render&&void 0===i.$$typeof){if(t.tag=1,t.memoizedState=null,t.updateQueue=null,bi(n)){var s=!0;vi(t)}else s=!1;t.memoizedState=null!==i.state&&void 0!==i.state?i.state:null,as(t);var a=n.getDerivedStateFromProps;"function"===typeof a&&gs(t,n,a,e),i.updater=bs,t.stateNode=i,i._reactInternals=t,vs(t,n,e,r),t=Ho(null,t,n,!0,s,r)}else t.tag=0,Mo(null,t,i,r),t=t.child;return t;case 16:i=t.elementType;e:{switch(null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),e=t.pendingProps,i=(s=i._init)(i._payload),t.type=i,s=t.tag=function(e){if("function"===typeof e)return Hc(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===T)return 11;if(e===D)return 14}return 2}(i),e=Qi(i,e),s){case 0:t=zo(null,t,i,e,r);break e;case 1:t=$o(null,t,i,e,r);break e;case 11:t=Oo(null,t,i,e,r);break e;case 14:t=qo(null,t,i,Qi(i.type,e),n,r);break e}throw Error(o(306,i,""))}return t;case 0:return n=t.type,i=t.pendingProps,zo(e,t,n,i=t.elementType===n?i:Qi(n,i),r);case 1:return n=t.type,i=t.pendingProps,$o(e,t,n,i=t.elementType===n?i:Qi(n,i),r);case 3:if(jo(t),n=t.updateQueue,null===e||null===n)throw Error(o(282));if(n=t.pendingProps,i=null!==(i=t.memoizedState)?i.element:null,cs(e,t),ds(t,n,null,r),(n=t.memoizedState.element)===i)js(),t=sa(e,t,r);else{if((s=(i=t.stateNode).hydrate)&&(qs=Gn(t.stateNode.containerInfo.firstChild),Os=t,s=Ks=!0),s){if(null!=(e=i.mutableSourceEagerHydrationData))for(i=0;i<e.length;i+=2)(s=e[i])._workInProgressVersionPrimary=e[i+1],Gs.push(s);for(r=xs(t,null,n,r),t.child=r;r;)r.flags=-3&r.flags|1024,r=r.sibling}else Mo(e,t,n,r),js();t=t.child}return t;case 5:return Bs(t),null===e&&zs(t),n=t.type,i=t.pendingProps,s=null!==e?e.memoizedProps:null,a=i.children,zn(n,i)?a=null:null!==s&&zn(n,s)&&(t.flags|=16),Vo(e,t),Mo(e,t,a,r),t.child;case 6:return null===e&&zs(t),null;case 13:return Xo(e,t,r);case 4:return Ds(t,t.stateNode.containerInfo),n=t.pendingProps,null===e?t.child=ks(t,null,n,r):Mo(e,t,n,r),t.child;case 11:return n=t.type,i=t.pendingProps,Oo(e,t,n,i=t.elementType===n?i:Qi(n,i),r);case 7:return Mo(e,t,t.pendingProps,r),t.child;case 8:case 12:return Mo(e,t,t.pendingProps.children,r),t.child;case 10:e:{n=t.type._context,i=t.pendingProps,a=t.memoizedProps,s=i.value;var c=t.type._context;if(li(Ji,c._currentValue),c._currentValue=s,null!==a)if(c=a.value,0===(s=un(c,s)?0:0|("function"===typeof n._calculateChangedBits?n._calculateChangedBits(c,s):1073741823))){if(a.children===i.children&&!fi.current){t=sa(e,t,r);break e}}else for(null!==(c=t.child)&&(c.return=t);null!==c;){var u=c.dependencies;if(null!==u){a=c.child;for(var l=u.firstContext;null!==l;){if(l.context===n&&0!==(l.observedBits&s)){1===c.tag&&((l=us(-1,r&-r)).tag=2,ls(c,l)),c.lanes|=r,null!==(l=c.alternate)&&(l.lanes|=r),ns(c.return,r),u.lanes|=r;break}l=l.next}}else a=10===c.tag&&c.type===t.type?null:c.child;if(null!==a)a.return=c;else for(a=c;null!==a;){if(a===t){a=null;break}if(null!==(c=a.sibling)){c.return=a.return,a=c;break}a=a.return}c=a}Mo(e,t,i.children,r),t=t.child}return t;case 9:return i=t.type,n=(s=t.pendingProps).children,is(t,r),n=n(i=ss(i,s.unstable_observedBits)),t.flags|=1,Mo(e,t,n,r),t.child;case 14:return s=Qi(i=t.type,t.pendingProps),qo(e,t,i,s=Qi(i.type,s),n,r);case 15:return Ko(e,t,t.type,t.pendingProps,n,r);case 17:return n=t.type,i=t.pendingProps,i=t.elementType===n?i:Qi(n,i),null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2),t.tag=1,bi(n)?(e=!0,vi(t)):e=!1,is(t,r),ms(t,n,i),vs(t,n,i,r),Ho(null,t,n,!0,e,r);case 19:return ia(e,t,r);case 23:case 24:return Fo(e,t,r)}throw Error(o(156,t.tag))},nu.prototype.render=function(e){Zc(e,this._internalRoot,null,null)},nu.prototype.unmount=function(){var e=this._internalRoot,t=e.containerInfo;Zc(null,e,null,(function(){t[Zn]=null}))},et=function(e){13===e.tag&&(pc(e,4,dc()),ru(e,4))},tt=function(e){13===e.tag&&(pc(e,67108864,dc()),ru(e,67108864))},rt=function(e){if(13===e.tag){var t=dc(),r=fc(e);pc(e,r,t),ru(e,r)}},nt=function(e,t){return t()},xe=function(e,t,r){switch(t){case"input":if(re(e,r),t=r.name,"radio"===r.type&&null!=t){for(r=e;r.parentNode;)r=r.parentNode;for(r=r.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<r.length;t++){var n=r[t];if(n!==e&&n.form===e.form){var i=ii(n);if(!i)throw Error(o(90));J(n),re(n,i)}}}break;case"textarea":ue(e,r);break;case"select":null!=(t=r.value)&&oe(e,!!r.multiple,t,!1)}},De=vc,Ne=function(e,t,r,n,i){var s=Da;Da|=4;try{return Hi(98,e.bind(null,t,r,n,i))}finally{0===(Da=s)&&(Ga(),Gi())}},Be=function(){0===(49&Da)&&(function(){if(null!==ic){var e=ic;ic=null,e.forEach((function(e){e.expiredLanes|=24&e.pendingLanes,bc(e,Vi())}))}Gi()}(),Uc())},Ue=function(e,t){var r=Da;Da|=2;try{return e(t)}finally{0===(Da=r)&&(Ga(),Gi())}};var au={Events:[ri,ni,ii,Re,Pe,Uc,{current:!1}]},cu={findFiberByHostInstance:ti,bundleType:0,version:"17.0.2",rendererPackageName:"react-dom"},uu={bundleType:cu.bundleType,version:cu.version,rendererPackageName:cu.rendererPackageName,rendererConfig:cu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=Xe(e))?null:e.stateNode},findFiberByHostInstance:cu.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null};if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var lu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!lu.isDisabled&&lu.supportsFiber)try{Ei=lu.inject(uu),Si=lu}catch(ge){}}t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=au,t.createPortal=ou,t.findDOMNode=function(e){if(null==e)return null;if(1===e.nodeType)return e;var t=e._reactInternals;if(void 0===t){if("function"===typeof e.render)throw Error(o(188));throw Error(o(268,Object.keys(e)))}return e=null===(e=Xe(t))?null:e.stateNode},t.flushSync=function(e,t){var r=Da;if(0!==(48&r))return e(t);Da|=1;try{if(e)return Hi(99,e.bind(null,t))}finally{Da=r,Gi()}},t.hydrate=function(e,t,r){if(!iu(t))throw Error(o(200));return su(null,e,t,!0,r)},t.render=function(e,t,r){if(!iu(t))throw Error(o(200));return su(null,e,t,!1,r)},t.unmountComponentAtNode=function(e){if(!iu(e))throw Error(o(40));return!!e._reactRootContainer&&(_c((function(){su(null,null,e,!1,(function(){e._reactRootContainer=null,e[Zn]=null}))})),!0)},t.unstable_batchedUpdates=vc,t.unstable_createPortal=function(e,t){return ou(e,t,2<arguments.length&&void 0!==arguments[2]?arguments[2]:null)},t.unstable_renderSubtreeIntoContainer=function(e,t,r,n){if(!iu(r))throw Error(o(200));if(null==e||void 0===e._reactInternals)throw Error(o(38));return su(e,t,r,!1,n)},t.version="17.0.2"},7950:(e,t,r)=>{"use strict";!function e(){if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"===typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}(),e.exports=r(2730)},1153:(e,t,r)=>{"use strict";r(2123);var n=r(5043),i=60103;if(60107,"function"===typeof Symbol&&Symbol.for){var s=Symbol.for;i=s("react.element"),s("react.fragment")}var o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a=Object.prototype.hasOwnProperty,c={key:!0,ref:!0,__self:!0,__source:!0};function u(e,t,r){var n,s={},u=null,l=null;for(n in void 0!==r&&(u=""+r),void 0!==t.key&&(u=""+t.key),void 0!==t.ref&&(l=t.ref),t)a.call(t,n)&&!c.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:i,type:e,key:u,ref:l,props:s,_owner:o.current}}t.jsx=u,t.jsxs=u},4202:(e,t,r)=>{"use strict";var n=r(2123),i=60103,s=60106;t.Fragment=60107,t.StrictMode=60108,t.Profiler=60114;var o=60109,a=60110,c=60112;t.Suspense=60113;var u=60115,l=60116;if("function"===typeof Symbol&&Symbol.for){var h=Symbol.for;i=h("react.element"),s=h("react.portal"),t.Fragment=h("react.fragment"),t.StrictMode=h("react.strict_mode"),t.Profiler=h("react.profiler"),o=h("react.provider"),a=h("react.context"),c=h("react.forward_ref"),t.Suspense=h("react.suspense"),u=h("react.memo"),l=h("react.lazy")}var d="function"===typeof Symbol&&Symbol.iterator;function f(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r<arguments.length;r++)t+="&args[]="+encodeURIComponent(arguments[r]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g={};function b(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||p}function y(){}function m(e,t,r){this.props=e,this.context=t,this.refs=g,this.updater=r||p}b.prototype.isReactComponent={},b.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error(f(85));this.updater.enqueueSetState(this,e,t,"setState")},b.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},y.prototype=b.prototype;var w=m.prototype=new y;w.constructor=m,n(w,b.prototype),w.isPureReactComponent=!0;var v={current:null},_=Object.prototype.hasOwnProperty,E={key:!0,ref:!0,__self:!0,__source:!0};function S(e,t,r){var n,s={},o=null,a=null;if(null!=t)for(n in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(o=""+t.key),t)_.call(t,n)&&!E.hasOwnProperty(n)&&(s[n]=t[n]);var c=arguments.length-2;if(1===c)s.children=r;else if(1<c){for(var u=Array(c),l=0;l<c;l++)u[l]=arguments[l+2];s.children=u}if(e&&e.defaultProps)for(n in c=e.defaultProps)void 0===s[n]&&(s[n]=c[n]);return{$$typeof:i,type:e,key:o,ref:a,props:s,_owner:v.current}}function A(e){return"object"===typeof e&&null!==e&&e.$$typeof===i}var k=/\/+/g;function x(e,t){return"object"===typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,(function(e){return t[e]}))}(""+e.key):t.toString(36)}function I(e,t,r,n,o){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var c=!1;if(null===e)c=!0;else switch(a){case"string":case"number":c=!0;break;case"object":switch(e.$$typeof){case i:case s:c=!0}}if(c)return o=o(c=e),e=""===n?"."+x(c,0):n,Array.isArray(o)?(r="",null!=e&&(r=e.replace(k,"$&/")+"/"),I(o,t,r,"",(function(e){return e}))):null!=o&&(A(o)&&(o=function(e,t){return{$$typeof:i,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(o,r+(!o.key||c&&c.key===o.key?"":(""+o.key).replace(k,"$&/")+"/")+e)),t.push(o)),1;if(c=0,n=""===n?".":n+":",Array.isArray(e))for(var u=0;u<e.length;u++){var l=n+x(a=e[u],u);c+=I(a,t,r,l,o)}else if(l=function(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=d&&e[d]||e["@@iterator"])?e:null}(e),"function"===typeof l)for(e=l.call(e),u=0;!(a=e.next()).done;)c+=I(a=a.value,t,r,l=n+x(a,u++),o);else if("object"===a)throw t=""+e,Error(f(31,"[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t));return c}function C(e,t,r){if(null==e)return e;var n=[],i=0;return I(e,n,"","",(function(e){return t.call(r,e,i++)})),n}function T(e){if(-1===e._status){var t=e._result;t=t(),e._status=0,e._result=t,t.then((function(t){0===e._status&&(t=t.default,e._status=1,e._result=t)}),(function(t){0===e._status&&(e._status=2,e._result=t)}))}if(1===e._status)return e._result;throw e._result}var R={current:null};function P(){var e=R.current;if(null===e)throw Error(f(321));return e}var D={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:v,IsSomeRendererActing:{current:!1},assign:n};t.Children={map:C,forEach:function(e,t,r){C(e,(function(){t.apply(this,arguments)}),r)},count:function(e){var t=0;return C(e,(function(){t++})),t},toArray:function(e){return C(e,(function(e){return e}))||[]},only:function(e){if(!A(e))throw Error(f(143));return e}},t.Component=b,t.PureComponent=m,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=D,t.cloneElement=function(e,t,r){if(null===e||void 0===e)throw Error(f(267,e));var s=n({},e.props),o=e.key,a=e.ref,c=e._owner;if(null!=t){if(void 0!==t.ref&&(a=t.ref,c=v.current),void 0!==t.key&&(o=""+t.key),e.type&&e.type.defaultProps)var u=e.type.defaultProps;for(l in t)_.call(t,l)&&!E.hasOwnProperty(l)&&(s[l]=void 0===t[l]&&void 0!==u?u[l]:t[l])}var l=arguments.length-2;if(1===l)s.children=r;else if(1<l){u=Array(l);for(var h=0;h<l;h++)u[h]=arguments[h+2];s.children=u}return{$$typeof:i,type:e.type,key:o,ref:a,props:s,_owner:c}},t.createContext=function(e,t){return void 0===t&&(t=null),(e={$$typeof:a,_calculateChangedBits:t,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null}).Provider={$$typeof:o,_context:e},e.Consumer=e},t.createElement=S,t.createFactory=function(e){var t=S.bind(null,e);return t.type=e,t},t.createRef=function(){return{current:null}},t.forwardRef=function(e){return{$$typeof:c,render:e}},t.isValidElement=A,t.lazy=function(e){return{$$typeof:l,_payload:{_status:-1,_result:e},_init:T}},t.memo=function(e,t){return{$$typeof:u,type:e,compare:void 0===t?null:t}},t.useCallback=function(e,t){return P().useCallback(e,t)},t.useContext=function(e,t){return P().useContext(e,t)},t.useDebugValue=function(){},t.useEffect=function(e,t){return P().useEffect(e,t)},t.useImperativeHandle=function(e,t,r){return P().useImperativeHandle(e,t,r)},t.useLayoutEffect=function(e,t){return P().useLayoutEffect(e,t)},t.useMemo=function(e,t){return P().useMemo(e,t)},t.useReducer=function(e,t,r){return P().useReducer(e,t,r)},t.useRef=function(e){return P().useRef(e)},t.useState=function(e){return P().useState(e)},t.version="17.0.2"},5043:(e,t,r)=>{"use strict";e.exports=r(4202)},579:(e,t,r)=>{"use strict";e.exports=r(1153)},7234:(e,t)=>{"use strict";var r,n,i,s;if("object"===typeof performance&&"function"===typeof performance.now){var o=performance;t.unstable_now=function(){return o.now()}}else{var a=Date,c=a.now();t.unstable_now=function(){return a.now()-c}}if("undefined"===typeof window||"function"!==typeof MessageChannel){var u=null,l=null,h=function(){if(null!==u)try{var e=t.unstable_now();u(!0,e),u=null}catch(r){throw setTimeout(h,0),r}};r=function(e){null!==u?setTimeout(r,0,e):(u=e,setTimeout(h,0))},n=function(e,t){l=setTimeout(e,t)},i=function(){clearTimeout(l)},t.unstable_shouldYield=function(){return!1},s=t.unstable_forceFrameRate=function(){}}else{var d=window.setTimeout,f=window.clearTimeout;if("undefined"!==typeof console){var p=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills"),"function"!==typeof p&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")}var g=!1,b=null,y=-1,m=5,w=0;t.unstable_shouldYield=function(){return t.unstable_now()>=w},s=function(){},t.unstable_forceFrameRate=function(e){0>e||125<e?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):m=0<e?Math.floor(1e3/e):5};var v=new MessageChannel,_=v.port2;v.port1.onmessage=function(){if(null!==b){var e=t.unstable_now();w=e+m;try{b(!0,e)?_.postMessage(null):(g=!1,b=null)}catch(r){throw _.postMessage(null),r}}else g=!1},r=function(e){b=e,g||(g=!0,_.postMessage(null))},n=function(e,r){y=d((function(){e(t.unstable_now())}),r)},i=function(){f(y),y=-1}}function E(e,t){var r=e.length;e.push(t);e:for(;;){var n=r-1>>>1,i=e[n];if(!(void 0!==i&&0<k(i,t)))break e;e[n]=t,e[r]=i,r=n}}function S(e){return void 0===(e=e[0])?null:e}function A(e){var t=e[0];if(void 0!==t){var r=e.pop();if(r!==t){e[0]=r;e:for(var n=0,i=e.length;n<i;){var s=2*(n+1)-1,o=e[s],a=s+1,c=e[a];if(void 0!==o&&0>k(o,r))void 0!==c&&0>k(c,o)?(e[n]=c,e[a]=r,n=a):(e[n]=o,e[s]=r,n=s);else{if(!(void 0!==c&&0>k(c,r)))break e;e[n]=c,e[a]=r,n=a}}}return t}return null}function k(e,t){var r=e.sortIndex-t.sortIndex;return 0!==r?r:e.id-t.id}var x=[],I=[],C=1,T=null,R=3,P=!1,D=!1,N=!1;function B(e){for(var t=S(I);null!==t;){if(null===t.callback)A(I);else{if(!(t.startTime<=e))break;A(I),t.sortIndex=t.expirationTime,E(x,t)}t=S(I)}}function U(e){if(N=!1,B(e),!D)if(null!==S(x))D=!0,r(L);else{var t=S(I);null!==t&&n(U,t.startTime-e)}}function L(e,r){D=!1,N&&(N=!1,i()),P=!0;var s=R;try{for(B(r),T=S(x);null!==T&&(!(T.expirationTime>r)||e&&!t.unstable_shouldYield());){var o=T.callback;if("function"===typeof o){T.callback=null,R=T.priorityLevel;var a=o(T.expirationTime<=r);r=t.unstable_now(),"function"===typeof a?T.callback=a:T===S(x)&&A(x),B(r)}else A(x);T=S(x)}if(null!==T)var c=!0;else{var u=S(I);null!==u&&n(U,u.startTime-r),c=!1}return c}finally{T=null,R=s,P=!1}}var M=s;t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(e){e.callback=null},t.unstable_continueExecution=function(){D||P||(D=!0,r(L))},t.unstable_getCurrentPriorityLevel=function(){return R},t.unstable_getFirstCallbackNode=function(){return S(x)},t.unstable_next=function(e){switch(R){case 1:case 2:case 3:var t=3;break;default:t=R}var r=R;R=t;try{return e()}finally{R=r}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=M,t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var r=R;R=e;try{return t()}finally{R=r}},t.unstable_scheduleCallback=function(e,s,o){var a=t.unstable_now();switch("object"===typeof o&&null!==o?o="number"===typeof(o=o.delay)&&0<o?a+o:a:o=a,e){case 1:var c=-1;break;case 2:c=250;break;case 5:c=1073741823;break;case 4:c=1e4;break;default:c=5e3}return e={id:C++,callback:s,priorityLevel:e,startTime:o,expirationTime:c=o+c,sortIndex:-1},o>a?(e.sortIndex=o,E(I,e),null===S(x)&&e===S(I)&&(N?i():N=!0,n(U,o-a))):(e.sortIndex=c,E(x,e),D||P||(D=!0,r(L))),e},t.unstable_wrapCallback=function(e){var t=R;return function(){var r=R;R=t;try{return e.apply(this,arguments)}finally{R=r}}}},8853:(e,t,r)=>{"use strict";e.exports=r(7234)},5013:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Nouns=t.Adjectives=void 0,t.Adjectives=["Adorable","Adventurous","Agressive","Alert","Alive","Amused","Angry","Annoyed","Annoying","silent","empty","dry","dark","summer","icy","delicate","quiet","white","cool","spring","winter","patient","twilight","dawn","crimson","wispy","weathered","blue","billowing","broken","cold","damp","falling","frosty","green","long","late","lingering","bold","little","morning","muddy","old","red","rough","still","small","sparkling","throbbing","shy","wandering","withered","wild","black","young","holy","solitary","fragrant","aged","snowy","proud","floral","restless","divine","polished","ancient","purple","lively","nameless"],t.Nouns=["waterfall","river","breeze","moon","rain","wind","sea","morning","snow","lake","sunset","pine","shadow","leaf","dawn","glitter","forest","hill","cloud","meadow","sun","glade","bird","brook","butterfly","bush","dew","dust","field","fire","flower","firefly","feather","grass","haze","mountain","night","pond","darkness","snowflake","silence","sound","sky","shape","surf","thunder","violet","water","wildflower","wave","water","resonance","sun","wood","dream","cherry","tree","fog","frost","voice","paper","frog","smoke","star"]},2676:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5013);t.default=()=>n.Adjectives[Math.floor(Math.random()*n.Adjectives.length)]+" "+n.Nouns[Math.floor(Math.random()*n.Nouns.length)]},9233:(e,t,r)=>{"use strict";var n=r(2676);Object.defineProperty(t,"c",{enumerable:!0,get:function(){return n.default}})},1170:e=>{e.exports=function e(n,i){var s,o=0,a=0,c=i=i||0,u=n.length;do{if(c>=u||a>49)throw e.bytes=0,new RangeError("Could not decode varint");s=n[c++],o+=a<28?(s&r)<<a:(s&r)*Math.pow(2,a),a+=7}while(s>=t);return e.bytes=c-i,o};var t=128,r=127},2070:e=>{e.exports=function e(i,s,o){if(Number.MAX_SAFE_INTEGER&&i>Number.MAX_SAFE_INTEGER)throw e.bytes=0,new RangeError("Could not encode varint");s=s||[];var a=o=o||0;for(;i>=n;)s[o++]=255&i|t,i/=128;for(;i&r;)s[o++]=255&i|t,i>>>=7;return s[o]=0|i,e.bytes=o-a+1,s};var t=128,r=-128,n=Math.pow(2,31)},1870:(e,t,r)=>{e.exports={encode:r(2070),decode:r(1170),encodingLength:r(940)}},940:e=>{var t=Math.pow(2,7),r=Math.pow(2,14),n=Math.pow(2,21),i=Math.pow(2,28),s=Math.pow(2,35),o=Math.pow(2,42),a=Math.pow(2,49),c=Math.pow(2,56),u=Math.pow(2,63);e.exports=function(e){return e<t?1:e<r?2:e<n?3:e<i?4:e<s?5:e<o?6:e<a?7:e<c?8:e<u?9:10}},495:()=>{},310:()=>{}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__webpack_require__),r.exports}__webpack_require__.amdO={},(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;__webpack_require__.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"===typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"===typeof r.then)return r}var i=Object.create(null);__webpack_require__.r(i);var s={};e=e||[null,t({}),t([]),t(t)];for(var o=2&n&&r;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach((e=>s[e]=()=>r[e]));return s.default=()=>r,__webpack_require__.d(i,s),i}})(),__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}(),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__={};(()=>{"use strict";var e={};__webpack_require__.r(e),__webpack_require__.d(e,{base10:()=>Ws});var t={};__webpack_require__.r(t),__webpack_require__.d(t,{base16:()=>Ys,base16upper:()=>Qs});var r={};__webpack_require__.r(r),__webpack_require__.d(r,{base2:()=>Js});var n={};__webpack_require__.r(n),__webpack_require__.d(n,{base256emoji:()=>to});var i={};__webpack_require__.r(i),__webpack_require__.d(i,{base32:()=>ro,base32hex:()=>oo,base32hexpad:()=>co,base32hexpadupper:()=>uo,base32hexupper:()=>ao,base32pad:()=>io,base32padupper:()=>so,base32upper:()=>no,base32z:()=>lo});var s={};__webpack_require__.r(s),__webpack_require__.d(s,{base36:()=>ho,base36upper:()=>fo});var o={};__webpack_require__.r(o),__webpack_require__.d(o,{base58btc:()=>po,base58flickr:()=>go});var a={};__webpack_require__.r(a),__webpack_require__.d(a,{base64:()=>bo,base64pad:()=>yo,base64url:()=>mo,base64urlpad:()=>wo});var c={};__webpack_require__.r(c),__webpack_require__.d(c,{base8:()=>vo});var u={};__webpack_require__.r(u),__webpack_require__.d(u,{identity:()=>_o});var l={};__webpack_require__.r(l),__webpack_require__.d(l,{code:()=>ko,decode:()=>Io,encode:()=>xo,name:()=>Ao});var h={};__webpack_require__.r(h),__webpack_require__.d(h,{code:()=>To,decode:()=>Po,encode:()=>Ro,name:()=>Co});var d={};__webpack_require__.r(d),__webpack_require__.d(d,{identity:()=>ea});var f={};__webpack_require__.r(f),__webpack_require__.d(f,{sha256:()=>ia,sha512:()=>sa});var p={};__webpack_require__.r(p),__webpack_require__.d(p,{base10:()=>tu});var g={};__webpack_require__.r(g),__webpack_require__.d(g,{base16:()=>ru,base16upper:()=>nu});var b={};__webpack_require__.r(b),__webpack_require__.d(b,{base2:()=>iu});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{base256emoji:()=>cu});var m={};__webpack_require__.r(m),__webpack_require__.d(m,{base32:()=>uu,base32hex:()=>fu,base32hexpad:()=>gu,base32hexpadupper:()=>bu,base32hexupper:()=>pu,base32pad:()=>hu,base32padupper:()=>du,base32upper:()=>lu,base32z:()=>yu});var w={};__webpack_require__.r(w),__webpack_require__.d(w,{base36:()=>mu,base36upper:()=>wu});var v={};__webpack_require__.r(v),__webpack_require__.d(v,{base58btc:()=>vu,base58flickr:()=>_u});var _={};__webpack_require__.r(_),__webpack_require__.d(_,{base64:()=>Eu,base64pad:()=>Su,base64url:()=>Au,base64urlpad:()=>ku});var E={};__webpack_require__.r(E),__webpack_require__.d(E,{base8:()=>xu});var S={};__webpack_require__.r(S),__webpack_require__.d(S,{identity:()=>Iu});var A={};__webpack_require__.r(A),__webpack_require__.d(A,{code:()=>Pu,decode:()=>Nu,encode:()=>Du,name:()=>Ru});var k={};__webpack_require__.r(k),__webpack_require__.d(k,{code:()=>Uu,decode:()=>Mu,encode:()=>Lu,name:()=>Bu});var x={};__webpack_require__.r(x),__webpack_require__.d(x,{identity:()=>ol});var I={};__webpack_require__.r(I),__webpack_require__.d(I,{sha256:()=>ll,sha512:()=>hl});var C={};__webpack_require__.r(C),__webpack_require__.d(C,{DO:()=>xf,OG:()=>qf,My:()=>Cf,bytesToNumberBE:()=>Nf,lX:()=>Bf,Id:()=>Of,fg:()=>Vf,qj:()=>Mf,hexToBytes:()=>Df,aY:()=>kf,lq:()=>Uf,z:()=>Lf,Q5:()=>$f});var T={};__webpack_require__.r(T),__webpack_require__.d(T,{base10:()=>fg});var R={};__webpack_require__.r(R),__webpack_require__.d(R,{base16:()=>pg,base16upper:()=>gg});var P={};__webpack_require__.r(P),__webpack_require__.d(P,{base2:()=>bg});var D={};__webpack_require__.r(D),__webpack_require__.d(D,{base256emoji:()=>vg});var N={};__webpack_require__.r(N),__webpack_require__.d(N,{base32:()=>_g,base32hex:()=>kg,base32hexpad:()=>Ig,base32hexpadupper:()=>Cg,base32hexupper:()=>xg,base32pad:()=>Sg,base32padupper:()=>Ag,base32upper:()=>Eg,base32z:()=>Tg});var B={};__webpack_require__.r(B),__webpack_require__.d(B,{base36:()=>Rg,base36upper:()=>Pg});var U={};__webpack_require__.r(U),__webpack_require__.d(U,{base58btc:()=>Dg,base58flickr:()=>Ng});var L={};__webpack_require__.r(L),__webpack_require__.d(L,{base64:()=>Bg,base64pad:()=>Ug,base64url:()=>Lg,base64urlpad:()=>Mg});var M={};__webpack_require__.r(M),__webpack_require__.d(M,{base8:()=>Og});var O={};__webpack_require__.r(O),__webpack_require__.d(O,{identity:()=>qg});var q={};__webpack_require__.r(q),__webpack_require__.d(q,{code:()=>zg,decode:()=>Hg,encode:()=>$g,name:()=>Vg});var K={};__webpack_require__.r(K),__webpack_require__.d(K,{code:()=>Gg,decode:()=>Yg,encode:()=>Wg,name:()=>jg});var F={};__webpack_require__.r(F),__webpack_require__.d(F,{identity:()=>mb});var V={};__webpack_require__.r(V),__webpack_require__.d(V,{sha256:()=>Eb,sha512:()=>Sb});var z={};__webpack_require__.r(z),__webpack_require__.d(z,{Ed25519PrivateKey:()=>Cy,Ed25519PublicKey:()=>Iy,generateKeyPair:()=>Py,generateKeyPairFromSeed:()=>Dy,unmarshalEd25519PrivateKey:()=>Ty,unmarshalEd25519PublicKey:()=>Ry});var $={};__webpack_require__.r($),__webpack_require__.d($,{MAX_KEY_SIZE:()=>Fy,RsaPrivateKey:()=>zy,RsaPublicKey:()=>Vy,fromJwk:()=>jy,generateKeyPair:()=>Gy,unmarshalRsaPrivateKey:()=>$y,unmarshalRsaPublicKey:()=>Hy});var H={};__webpack_require__.r(H),__webpack_require__.d(H,{Secp256k1PrivateKey:()=>fm,Secp256k1PublicKey:()=>dm,generateKeyPair:()=>bm,unmarshalSecp256k1PrivateKey:()=>pm,unmarshalSecp256k1PublicKey:()=>gm});var j={};__webpack_require__.r(j),__webpack_require__.d(j,{base58btc:()=>Nm,base58flickr:()=>Bm});var G={};__webpack_require__.r(G),__webpack_require__.d(G,{base10:()=>Um});var W={};__webpack_require__.r(W),__webpack_require__.d(W,{base16:()=>Lm,base16upper:()=>Mm});var Y={};__webpack_require__.r(Y),__webpack_require__.d(Y,{base2:()=>Om});var Q={};__webpack_require__.r(Q),__webpack_require__.d(Q,{base256emoji:()=>Vm});var J={};__webpack_require__.r(J),__webpack_require__.d(J,{base32:()=>zm,base32hex:()=>Gm,base32hexpad:()=>Ym,base32hexpadupper:()=>Qm,base32hexupper:()=>Wm,base32pad:()=>Hm,base32padupper:()=>jm,base32upper:()=>$m,base32z:()=>Jm});var X={};__webpack_require__.r(X),__webpack_require__.d(X,{base36:()=>Xm,base36upper:()=>Zm});var Z={};__webpack_require__.r(Z),__webpack_require__.d(Z,{base64:()=>ew,base64pad:()=>tw,base64url:()=>rw,base64urlpad:()=>nw});var ee={};__webpack_require__.r(ee),__webpack_require__.d(ee,{base8:()=>iw});var te={};__webpack_require__.r(te),__webpack_require__.d(te,{identity:()=>sw});var re={};__webpack_require__.r(re),__webpack_require__.d(re,{code:()=>uw,decode:()=>hw,encode:()=>lw,name:()=>cw});var ne={};__webpack_require__.r(ne),__webpack_require__.d(ne,{code:()=>fw,decode:()=>gw,encode:()=>pw,name:()=>dw});var ie={};__webpack_require__.r(ie),__webpack_require__.d(ie,{identity:()=>Kw});var se={};__webpack_require__.r(se),__webpack_require__.d(se,{sha256:()=>$w,sha512:()=>Hw});var oe={};__webpack_require__.r(oe),__webpack_require__.d(oe,{base58btc:()=>A_,base58flickr:()=>k_});var ae={};__webpack_require__.r(ae),__webpack_require__.d(ae,{base10:()=>x_});var ce={};__webpack_require__.r(ce),__webpack_require__.d(ce,{base16:()=>I_,base16upper:()=>C_});var ue={};__webpack_require__.r(ue),__webpack_require__.d(ue,{base2:()=>T_});var le={};__webpack_require__.r(le),__webpack_require__.d(le,{base256emoji:()=>N_});var he={};__webpack_require__.r(he),__webpack_require__.d(he,{base32:()=>B_,base32hex:()=>O_,base32hexpad:()=>K_,base32hexpadupper:()=>F_,base32hexupper:()=>q_,base32pad:()=>L_,base32padupper:()=>M_,base32upper:()=>U_,base32z:()=>V_});var de={};__webpack_require__.r(de),__webpack_require__.d(de,{base36:()=>z_,base36upper:()=>$_});var fe={};__webpack_require__.r(fe),__webpack_require__.d(fe,{base64:()=>H_,base64pad:()=>j_,base64url:()=>G_,base64urlpad:()=>W_});var pe={};__webpack_require__.r(pe),__webpack_require__.d(pe,{base8:()=>Y_});var ge={};__webpack_require__.r(ge),__webpack_require__.d(ge,{identity:()=>Q_});var be={};__webpack_require__.r(be),__webpack_require__.d(be,{code:()=>eE,decode:()=>rE,encode:()=>tE,name:()=>Z_});var ye={};__webpack_require__.r(ye),__webpack_require__.d(ye,{code:()=>iE,decode:()=>oE,encode:()=>sE,name:()=>nE});var me={};__webpack_require__.r(me),__webpack_require__.d(me,{identity:()=>PE});var we={};__webpack_require__.r(we),__webpack_require__.d(we,{sha256:()=>UE,sha512:()=>LE});var ve={};__webpack_require__.r(ve),__webpack_require__.d(ve,{base58btc:()=>gS,base58flickr:()=>bS});var _e={};__webpack_require__.r(_e),__webpack_require__.d(_e,{base32:()=>yS,base32hex:()=>_S,base32hexpad:()=>SS,base32hexpadupper:()=>AS,base32hexupper:()=>ES,base32pad:()=>wS,base32padupper:()=>vS,base32upper:()=>mS,base32z:()=>kS});var Ee={};__webpack_require__.r(Ee),__webpack_require__.d(Ee,{base10:()=>yA});var Se={};__webpack_require__.r(Se),__webpack_require__.d(Se,{base16:()=>mA,base16upper:()=>wA});var Ae={};__webpack_require__.r(Ae),__webpack_require__.d(Ae,{base2:()=>vA});var ke={};__webpack_require__.r(ke),__webpack_require__.d(ke,{base256emoji:()=>AA});var xe={};__webpack_require__.r(xe),__webpack_require__.d(xe,{base32:()=>kA,base32hex:()=>TA,base32hexpad:()=>PA,base32hexpadupper:()=>DA,base32hexupper:()=>RA,base32pad:()=>IA,base32padupper:()=>CA,base32upper:()=>xA,base32z:()=>NA});var Ie={};__webpack_require__.r(Ie),__webpack_require__.d(Ie,{base36:()=>BA,base36upper:()=>UA});var Ce={};__webpack_require__.r(Ce),__webpack_require__.d(Ce,{base58btc:()=>LA,base58flickr:()=>MA});var Te={};__webpack_require__.r(Te),__webpack_require__.d(Te,{base64:()=>OA,base64pad:()=>qA,base64url:()=>KA,base64urlpad:()=>FA});var Re={};__webpack_require__.r(Re),__webpack_require__.d(Re,{base8:()=>VA});var Pe={};__webpack_require__.r(Pe),__webpack_require__.d(Pe,{identity:()=>zA});var De={};__webpack_require__.r(De),__webpack_require__.d(De,{code:()=>GA,decode:()=>YA,encode:()=>WA,name:()=>jA});var Ne={};__webpack_require__.r(Ne),__webpack_require__.d(Ne,{code:()=>JA,decode:()=>ZA,encode:()=>XA,name:()=>QA});var Be={};__webpack_require__.r(Be),__webpack_require__.d(Be,{identity:()=>Ek});var Ue={};__webpack_require__.r(Ue),__webpack_require__.d(Ue,{sha256:()=>xk,sha512:()=>Ik});var Le={};__webpack_require__.r(Le),__webpack_require__.d(Le,{base10:()=>Fk});var Me={};__webpack_require__.r(Me),__webpack_require__.d(Me,{base16:()=>Vk,base16upper:()=>zk});var Oe={};__webpack_require__.r(Oe),__webpack_require__.d(Oe,{base2:()=>$k});var qe={};__webpack_require__.r(qe),__webpack_require__.d(qe,{base256emoji:()=>Wk});var Ke={};__webpack_require__.r(Ke),__webpack_require__.d(Ke,{base36:()=>Yk,base36upper:()=>Qk});var Fe={};__webpack_require__.r(Fe),__webpack_require__.d(Fe,{base64:()=>Jk,base64pad:()=>Xk,base64url:()=>Zk,base64urlpad:()=>ex});var Ve={};__webpack_require__.r(Ve),__webpack_require__.d(Ve,{base8:()=>tx});var ze={};__webpack_require__.r(ze),__webpack_require__.d(ze,{identity:()=>rx});var $e={};__webpack_require__.r($e),__webpack_require__.d($e,{code:()=>ox,decode:()=>cx,encode:()=>ax,name:()=>sx});var He={};__webpack_require__.r(He),__webpack_require__.d(He,{code:()=>lx,decode:()=>dx,encode:()=>hx,name:()=>ux});var je={};__webpack_require__.r(je),__webpack_require__.d(je,{identity:()=>px});var Ge={};__webpack_require__.r(Ge),__webpack_require__.d(Ge,{sha256:()=>mx,sha512:()=>wx});var We={};__webpack_require__.r(We),__webpack_require__.d(We,{base58btc:()=>PC,base58flickr:()=>DC});var Ye={};__webpack_require__.r(Ye),__webpack_require__.d(Ye,{base10:()=>NC});var Qe={};__webpack_require__.r(Qe),__webpack_require__.d(Qe,{base16:()=>BC,base16upper:()=>UC});var Je={};__webpack_require__.r(Je),__webpack_require__.d(Je,{base2:()=>LC});var Xe={};__webpack_require__.r(Xe),__webpack_require__.d(Xe,{base256emoji:()=>KC});var Ze={};__webpack_require__.r(Ze),__webpack_require__.d(Ze,{base32:()=>FC,base32hex:()=>HC,base32hexpad:()=>GC,base32hexpadupper:()=>WC,base32hexupper:()=>jC,base32pad:()=>zC,base32padupper:()=>$C,base32upper:()=>VC,base32z:()=>YC});var et={};__webpack_require__.r(et),__webpack_require__.d(et,{base36:()=>QC,base36upper:()=>JC});var tt={};__webpack_require__.r(tt),__webpack_require__.d(tt,{base64:()=>XC,base64pad:()=>ZC,base64url:()=>eT,base64urlpad:()=>tT});var rt={};__webpack_require__.r(rt),__webpack_require__.d(rt,{base8:()=>rT});var nt={};__webpack_require__.r(nt),__webpack_require__.d(nt,{identity:()=>nT});var it={};__webpack_require__.r(it),__webpack_require__.d(it,{code:()=>aT,decode:()=>uT,encode:()=>cT,name:()=>oT});var st={};__webpack_require__.r(st),__webpack_require__.d(st,{code:()=>hT,decode:()=>fT,encode:()=>dT,name:()=>lT});var ot={};__webpack_require__.r(ot),__webpack_require__.d(ot,{identity:()=>OT});var at={};__webpack_require__.r(at),__webpack_require__.d(at,{sha256:()=>VT,sha512:()=>zT});var ct={};__webpack_require__.r(ct),__webpack_require__.d(ct,{base58btc:()=>_R,base58flickr:()=>ER});var ut={};__webpack_require__.r(ut),__webpack_require__.d(ut,{base10:()=>SR});var lt={};__webpack_require__.r(lt),__webpack_require__.d(lt,{base16:()=>AR,base16upper:()=>kR});var ht={};__webpack_require__.r(ht),__webpack_require__.d(ht,{base2:()=>xR});var dt={};__webpack_require__.r(dt),__webpack_require__.d(dt,{base256emoji:()=>RR});var ft={};__webpack_require__.r(ft),__webpack_require__.d(ft,{base32:()=>PR,base32hex:()=>UR,base32hexpad:()=>MR,base32hexpadupper:()=>OR,base32hexupper:()=>LR,base32pad:()=>NR,base32padupper:()=>BR,base32upper:()=>DR,base32z:()=>qR});var pt={};__webpack_require__.r(pt),__webpack_require__.d(pt,{base36:()=>KR,base36upper:()=>FR});var gt={};__webpack_require__.r(gt),__webpack_require__.d(gt,{base64:()=>VR,base64pad:()=>zR,base64url:()=>$R,base64urlpad:()=>HR});var bt={};__webpack_require__.r(bt),__webpack_require__.d(bt,{base8:()=>jR});var yt={};__webpack_require__.r(yt),__webpack_require__.d(yt,{identity:()=>GR});var mt={};__webpack_require__.r(mt),__webpack_require__.d(mt,{code:()=>JR,decode:()=>ZR,encode:()=>XR,name:()=>QR});var wt={};__webpack_require__.r(wt),__webpack_require__.d(wt,{code:()=>tP,decode:()=>nP,encode:()=>rP,name:()=>eP});var vt={};__webpack_require__.r(vt),__webpack_require__.d(vt,{identity:()=>CP});var _t={};__webpack_require__.r(_t),__webpack_require__.d(_t,{sha256:()=>DP,sha512:()=>NP});var Et={};__webpack_require__.r(Et),__webpack_require__.d(Et,{Ed25519PrivateKey:()=>BN,Ed25519PublicKey:()=>NN,generateKeyPair:()=>MN,generateKeyPairFromSeed:()=>ON,unmarshalEd25519PrivateKey:()=>UN,unmarshalEd25519PublicKey:()=>LN});var St={};__webpack_require__.r(St),__webpack_require__.d(St,{MAX_RSA_KEY_SIZE:()=>iL,RsaPrivateKey:()=>oL,RsaPublicKey:()=>sL,fromJwk:()=>uL,generateKeyPair:()=>lL,unmarshalRsaPrivateKey:()=>aL,unmarshalRsaPublicKey:()=>cL});var At={};__webpack_require__.r(At),__webpack_require__.d(At,{Secp256k1PrivateKey:()=>fL,Secp256k1PublicKey:()=>dL,generateKeyPair:()=>bL,unmarshalSecp256k1PrivateKey:()=>pL,unmarshalSecp256k1PublicKey:()=>gL});var kt={};__webpack_require__.r(kt),__webpack_require__.d(kt,{base10:()=>mq});var xt={};__webpack_require__.r(xt),__webpack_require__.d(xt,{base16:()=>wq,base16upper:()=>vq});var It={};__webpack_require__.r(It),__webpack_require__.d(It,{base2:()=>_q});var Ct={};__webpack_require__.r(Ct),__webpack_require__.d(Ct,{base256emoji:()=>kq});var Tt={};__webpack_require__.r(Tt),__webpack_require__.d(Tt,{base32:()=>xq,base32hex:()=>Rq,base32hexpad:()=>Dq,base32hexpadupper:()=>Nq,base32hexupper:()=>Pq,base32pad:()=>Cq,base32padupper:()=>Tq,base32upper:()=>Iq,base32z:()=>Bq});var Rt={};__webpack_require__.r(Rt),__webpack_require__.d(Rt,{base36:()=>Uq,base36upper:()=>Lq});var Pt={};__webpack_require__.r(Pt),__webpack_require__.d(Pt,{base58btc:()=>Mq,base58flickr:()=>Oq});var Dt={};__webpack_require__.r(Dt),__webpack_require__.d(Dt,{base64:()=>qq,base64pad:()=>Kq,base64url:()=>Fq,base64urlpad:()=>Vq});var Nt={};__webpack_require__.r(Nt),__webpack_require__.d(Nt,{base8:()=>zq});var Bt={};__webpack_require__.r(Bt),__webpack_require__.d(Bt,{identity:()=>$q});var Ut={};__webpack_require__.r(Ut),__webpack_require__.d(Ut,{code:()=>Wq,decode:()=>Qq,encode:()=>Yq,name:()=>Gq});var Lt={};__webpack_require__.r(Lt),__webpack_require__.d(Lt,{code:()=>Xq,decode:()=>eK,encode:()=>Zq,name:()=>Jq});var Mt={};__webpack_require__.r(Mt),__webpack_require__.d(Mt,{identity:()=>SK});var Ot={};__webpack_require__.r(Ot),__webpack_require__.d(Ot,{sha256:()=>IK,sha512:()=>CK});var qt={};__webpack_require__.r(qt),__webpack_require__.d(qt,{base10:()=>xF});var Kt={};__webpack_require__.r(Kt),__webpack_require__.d(Kt,{base16:()=>IF,base16upper:()=>CF});var Ft={};__webpack_require__.r(Ft),__webpack_require__.d(Ft,{base2:()=>TF});var Vt={};__webpack_require__.r(Vt),__webpack_require__.d(Vt,{base256emoji:()=>NF});var zt={};__webpack_require__.r(zt),__webpack_require__.d(zt,{base32:()=>BF,base32hex:()=>OF,base32hexpad:()=>KF,base32hexpadupper:()=>FF,base32hexupper:()=>qF,base32pad:()=>LF,base32padupper:()=>MF,base32upper:()=>UF,base32z:()=>VF});var $t={};__webpack_require__.r($t),__webpack_require__.d($t,{base36:()=>zF,base36upper:()=>$F});var Ht={};__webpack_require__.r(Ht),__webpack_require__.d(Ht,{base58btc:()=>HF,base58flickr:()=>jF});var jt={};__webpack_require__.r(jt),__webpack_require__.d(jt,{base64:()=>GF,base64pad:()=>WF,base64url:()=>YF,base64urlpad:()=>QF});var Gt={};__webpack_require__.r(Gt),__webpack_require__.d(Gt,{base8:()=>JF});var Wt={};__webpack_require__.r(Wt),__webpack_require__.d(Wt,{identity:()=>XF});var Yt={};__webpack_require__.r(Yt),__webpack_require__.d(Yt,{code:()=>rV,decode:()=>iV,encode:()=>nV,name:()=>tV});var Qt={};__webpack_require__.r(Qt),__webpack_require__.d(Qt,{code:()=>oV,decode:()=>cV,encode:()=>aV,name:()=>sV});var Jt={};__webpack_require__.r(Jt),__webpack_require__.d(Jt,{identity:()=>PV});var Xt={};__webpack_require__.r(Xt),__webpack_require__.d(Xt,{sha256:()=>UV,sha512:()=>LV});var Zt={};__webpack_require__.r(Zt),__webpack_require__.d(Zt,{base58btc:()=>dz,base58flickr:()=>fz});var er={};__webpack_require__.r(er),__webpack_require__.d(er,{base10:()=>pz});var tr={};__webpack_require__.r(tr),__webpack_require__.d(tr,{base16:()=>gz,base16upper:()=>bz});var rr={};__webpack_require__.r(rr),__webpack_require__.d(rr,{base2:()=>yz});var nr={};__webpack_require__.r(nr),__webpack_require__.d(nr,{base256emoji:()=>_z});var ir={};__webpack_require__.r(ir),__webpack_require__.d(ir,{base32:()=>Ez,base32hex:()=>xz,base32hexpad:()=>Cz,base32hexpadupper:()=>Tz,base32hexupper:()=>Iz,base32pad:()=>Az,base32padupper:()=>kz,base32upper:()=>Sz,base32z:()=>Rz});var sr={};__webpack_require__.r(sr),__webpack_require__.d(sr,{base36:()=>Pz,base36upper:()=>Dz});var or={};__webpack_require__.r(or),__webpack_require__.d(or,{base64:()=>Nz,base64pad:()=>Bz,base64url:()=>Uz,base64urlpad:()=>Lz});var ar={};__webpack_require__.r(ar),__webpack_require__.d(ar,{base8:()=>Mz});var cr={};__webpack_require__.r(cr),__webpack_require__.d(cr,{identity:()=>Oz});var ur={};__webpack_require__.r(ur),__webpack_require__.d(ur,{code:()=>Vz,decode:()=>$z,encode:()=>zz,name:()=>Fz});var lr={};__webpack_require__.r(lr),__webpack_require__.d(lr,{code:()=>jz,decode:()=>Wz,encode:()=>Gz,name:()=>Hz});var hr={};__webpack_require__.r(hr),__webpack_require__.d(hr,{identity:()=>w$});var dr={};__webpack_require__.r(dr),__webpack_require__.d(dr,{sha256:()=>S$,sha512:()=>A$});var fr={};__webpack_require__.r(fr),__webpack_require__.d(fr,{Ed25519PrivateKey:()=>Rj,Ed25519PublicKey:()=>Tj,generateKeyPair:()=>Nj,generateKeyPairFromSeed:()=>Bj,unmarshalEd25519PrivateKey:()=>Pj,unmarshalEd25519PublicKey:()=>Dj});var pr={};__webpack_require__.r(pr),__webpack_require__.d(pr,{MAX_RSA_KEY_SIZE:()=>Hj,RsaPrivateKey:()=>Gj,RsaPublicKey:()=>jj,fromJwk:()=>Qj,generateKeyPair:()=>Jj,unmarshalRsaPrivateKey:()=>Wj,unmarshalRsaPublicKey:()=>Yj});var gr={};__webpack_require__.r(gr),__webpack_require__.d(gr,{Secp256k1PrivateKey:()=>eG,Secp256k1PublicKey:()=>Zj,generateKeyPair:()=>nG,unmarshalSecp256k1PrivateKey:()=>tG,unmarshalSecp256k1PublicKey:()=>rG});var br={};__webpack_require__.r(br),__webpack_require__.d(br,{sha256:()=>qG,sha512:()=>KG});var yr={};__webpack_require__.r(yr),__webpack_require__.d(yr,{base10:()=>JG});var mr={};__webpack_require__.r(mr),__webpack_require__.d(mr,{base16:()=>XG,base16upper:()=>ZG});var wr={};__webpack_require__.r(wr),__webpack_require__.d(wr,{base2:()=>eW});var vr={};__webpack_require__.r(vr),__webpack_require__.d(vr,{base256emoji:()=>iW});var _r={};__webpack_require__.r(_r),__webpack_require__.d(_r,{base32:()=>sW,base32hex:()=>uW,base32hexpad:()=>hW,base32hexpadupper:()=>dW,base32hexupper:()=>lW,base32pad:()=>aW,base32padupper:()=>cW,base32upper:()=>oW,base32z:()=>fW});var Er={};__webpack_require__.r(Er),__webpack_require__.d(Er,{base36:()=>pW,base36upper:()=>gW});var Sr={};__webpack_require__.r(Sr),__webpack_require__.d(Sr,{base58btc:()=>bW,base58flickr:()=>yW});var Ar={};__webpack_require__.r(Ar),__webpack_require__.d(Ar,{base64:()=>mW,base64pad:()=>wW,base64url:()=>vW,base64urlpad:()=>_W});var kr={};__webpack_require__.r(kr),__webpack_require__.d(kr,{base8:()=>EW});var xr={};__webpack_require__.r(xr),__webpack_require__.d(xr,{identity:()=>SW});var Ir={};__webpack_require__.r(Ir),__webpack_require__.d(Ir,{code:()=>IW,decode:()=>TW,encode:()=>CW,name:()=>xW});var Cr={};__webpack_require__.r(Cr),__webpack_require__.d(Cr,{code:()=>PW,decode:()=>NW,encode:()=>DW,name:()=>RW});var Tr={};__webpack_require__.r(Tr),__webpack_require__.d(Tr,{identity:()=>UW});var Rr={};__webpack_require__.r(Rr),__webpack_require__.d(Rr,{base58btc:()=>bY,base58flickr:()=>yY});var Pr={};__webpack_require__.r(Pr),__webpack_require__.d(Pr,{identity:()=>VY});var Dr={};__webpack_require__.r(Dr),__webpack_require__.d(Dr,{sha256:()=>jY,sha512:()=>GY});var Nr={};__webpack_require__.r(Nr),__webpack_require__.d(Nr,{base10:()=>YY});var Br={};__webpack_require__.r(Br),__webpack_require__.d(Br,{base16:()=>QY,base16upper:()=>JY});var Ur={};__webpack_require__.r(Ur),__webpack_require__.d(Ur,{base2:()=>XY});var Lr={};__webpack_require__.r(Lr),__webpack_require__.d(Lr,{base256emoji:()=>rQ});var Mr={};__webpack_require__.r(Mr),__webpack_require__.d(Mr,{base32:()=>nQ,base32hex:()=>aQ,base32hexpad:()=>uQ,base32hexpadupper:()=>lQ,base32hexupper:()=>cQ,base32pad:()=>sQ,base32padupper:()=>oQ,base32upper:()=>iQ,base32z:()=>hQ});var Or={};__webpack_require__.r(Or),__webpack_require__.d(Or,{base36:()=>dQ,base36upper:()=>fQ});var qr={};__webpack_require__.r(qr),__webpack_require__.d(qr,{base64:()=>pQ,base64pad:()=>gQ,base64url:()=>bQ,base64urlpad:()=>yQ});var Kr={};__webpack_require__.r(Kr),__webpack_require__.d(Kr,{base8:()=>mQ});var Fr={};__webpack_require__.r(Fr),__webpack_require__.d(Fr,{identity:()=>wQ});var Vr={};__webpack_require__.r(Vr),__webpack_require__.d(Vr,{code:()=>SQ,decode:()=>kQ,encode:()=>AQ,name:()=>EQ});var zr={};__webpack_require__.r(zr),__webpack_require__.d(zr,{code:()=>IQ,decode:()=>TQ,encode:()=>CQ,name:()=>xQ});var $r={};__webpack_require__.r($r),__webpack_require__.d($r,{Ed25519PrivateKey:()=>OJ,Ed25519PublicKey:()=>MJ,generateKeyPair:()=>FJ,generateKeyPairFromSeed:()=>VJ,unmarshalEd25519PrivateKey:()=>qJ,unmarshalEd25519PublicKey:()=>KJ});var Hr={};__webpack_require__.r(Hr),__webpack_require__.d(Hr,{MAX_RSA_KEY_SIZE:()=>eX,RsaPrivateKey:()=>rX,RsaPublicKey:()=>tX,fromJwk:()=>sX,generateKeyPair:()=>oX,unmarshalRsaPrivateKey:()=>nX,unmarshalRsaPublicKey:()=>iX});var jr={};__webpack_require__.r(jr),__webpack_require__.d(jr,{Secp256k1PrivateKey:()=>uX,Secp256k1PublicKey:()=>cX,generateKeyPair:()=>dX,unmarshalSecp256k1PrivateKey:()=>lX,unmarshalSecp256k1PublicKey:()=>hX});var Gr={};__webpack_require__.r(Gr),__webpack_require__.d(Gr,{base58btc:()=>PX,base58flickr:()=>DX});var Wr={};__webpack_require__.r(Wr),__webpack_require__.d(Wr,{base10:()=>NX});var Yr={};__webpack_require__.r(Yr),__webpack_require__.d(Yr,{base16:()=>BX,base16upper:()=>UX});var Qr={};__webpack_require__.r(Qr),__webpack_require__.d(Qr,{base2:()=>LX});var Jr={};__webpack_require__.r(Jr),__webpack_require__.d(Jr,{base256emoji:()=>KX});var Xr={};__webpack_require__.r(Xr),__webpack_require__.d(Xr,{base32:()=>FX,base32hex:()=>HX,base32hexpad:()=>GX,base32hexpadupper:()=>WX,base32hexupper:()=>jX,base32pad:()=>zX,base32padupper:()=>$X,base32upper:()=>VX,base32z:()=>YX});var Zr={};__webpack_require__.r(Zr),__webpack_require__.d(Zr,{base36:()=>QX,base36upper:()=>JX});var en={};__webpack_require__.r(en),__webpack_require__.d(en,{base64:()=>XX,base64pad:()=>ZX,base64url:()=>eZ,base64urlpad:()=>tZ});var tn={};__webpack_require__.r(tn),__webpack_require__.d(tn,{base8:()=>rZ});var rn={};__webpack_require__.r(rn),__webpack_require__.d(rn,{identity:()=>nZ});var nn={};__webpack_require__.r(nn),__webpack_require__.d(nn,{code:()=>aZ,decode:()=>uZ,encode:()=>cZ,name:()=>oZ});var sn={};__webpack_require__.r(sn),__webpack_require__.d(sn,{code:()=>hZ,decode:()=>fZ,encode:()=>dZ,name:()=>lZ});var on={};__webpack_require__.r(on),__webpack_require__.d(on,{identity:()=>OZ});var an={};__webpack_require__.r(an),__webpack_require__.d(an,{sha256:()=>VZ,sha512:()=>zZ});var cn={};__webpack_require__.r(cn),__webpack_require__.d(cn,{base58btc:()=>N0,base58flickr:()=>B0});var un={};__webpack_require__.r(un),__webpack_require__.d(un,{identity:()=>s1});var ln={};__webpack_require__.r(ln),__webpack_require__.d(ln,{sha256:()=>u1,sha512:()=>l1});var hn={};__webpack_require__.r(hn),__webpack_require__.d(hn,{base10:()=>d1});var dn={};__webpack_require__.r(dn),__webpack_require__.d(dn,{base16:()=>f1,base16upper:()=>p1});var fn={};__webpack_require__.r(fn),__webpack_require__.d(fn,{base2:()=>g1});var pn={};__webpack_require__.r(pn),__webpack_require__.d(pn,{base256emoji:()=>w1});var gn={};__webpack_require__.r(gn),__webpack_require__.d(gn,{base32:()=>v1,base32hex:()=>A1,base32hexpad:()=>x1,base32hexpadupper:()=>I1,base32hexupper:()=>k1,base32pad:()=>E1,base32padupper:()=>S1,base32upper:()=>_1,base32z:()=>C1});var bn={};__webpack_require__.r(bn),__webpack_require__.d(bn,{base36:()=>T1,base36upper:()=>R1});var yn={};__webpack_require__.r(yn),__webpack_require__.d(yn,{base64:()=>P1,base64pad:()=>D1,base64url:()=>N1,base64urlpad:()=>B1});var mn={};__webpack_require__.r(mn),__webpack_require__.d(mn,{base8:()=>U1});var wn={};__webpack_require__.r(wn),__webpack_require__.d(wn,{identity:()=>L1});var vn={};__webpack_require__.r(vn),__webpack_require__.d(vn,{code:()=>K1,decode:()=>V1,encode:()=>F1,name:()=>q1});var _n={};__webpack_require__.r(_n),__webpack_require__.d(_n,{code:()=>$1,decode:()=>j1,encode:()=>H1,name:()=>z1});var En={};__webpack_require__.r(En),__webpack_require__.d(En,{Ed25519PrivateKey:()=>t3,Ed25519PublicKey:()=>e3,generateKeyPair:()=>i3,generateKeyPairFromSeed:()=>s3,unmarshalEd25519PrivateKey:()=>r3,unmarshalEd25519PublicKey:()=>n3});var Sn={};__webpack_require__.r(Sn),__webpack_require__.d(Sn,{MAX_RSA_KEY_SIZE:()=>y3,RsaPrivateKey:()=>w3,RsaPublicKey:()=>m3,fromJwk:()=>E3,generateKeyPair:()=>S3,unmarshalRsaPrivateKey:()=>v3,unmarshalRsaPublicKey:()=>_3});var An={};__webpack_require__.r(An),__webpack_require__.d(An,{Secp256k1PrivateKey:()=>x3,Secp256k1PublicKey:()=>k3,generateKeyPair:()=>T3,unmarshalSecp256k1PrivateKey:()=>I3,unmarshalSecp256k1PublicKey:()=>C3});var kn={};__webpack_require__.r(kn),__webpack_require__.d(kn,{base58btc:()=>c6,base58flickr:()=>u6});var xn={};__webpack_require__.r(xn),__webpack_require__.d(xn,{base10:()=>l6});var In={};__webpack_require__.r(In),__webpack_require__.d(In,{base16:()=>h6,base16upper:()=>d6});var Cn={};__webpack_require__.r(Cn),__webpack_require__.d(Cn,{base2:()=>f6});var Tn={};__webpack_require__.r(Tn),__webpack_require__.d(Tn,{base256emoji:()=>y6});var Rn={};__webpack_require__.r(Rn),__webpack_require__.d(Rn,{base32:()=>m6,base32hex:()=>E6,base32hexpad:()=>A6,base32hexpadupper:()=>k6,base32hexupper:()=>S6,base32pad:()=>v6,base32padupper:()=>_6,base32upper:()=>w6,base32z:()=>x6});var Pn={};__webpack_require__.r(Pn),__webpack_require__.d(Pn,{base36:()=>I6,base36upper:()=>C6});var Dn={};__webpack_require__.r(Dn),__webpack_require__.d(Dn,{base64:()=>T6,base64pad:()=>R6,base64url:()=>P6,base64urlpad:()=>D6});var Nn={};__webpack_require__.r(Nn),__webpack_require__.d(Nn,{base8:()=>N6});var Bn={};__webpack_require__.r(Bn),__webpack_require__.d(Bn,{identity:()=>B6});var Un={};__webpack_require__.r(Un),__webpack_require__.d(Un,{code:()=>O6,decode:()=>K6,encode:()=>q6,name:()=>M6});var Ln={};__webpack_require__.r(Ln),__webpack_require__.d(Ln,{code:()=>V6,decode:()=>$6,encode:()=>z6,name:()=>F6});var Mn={};__webpack_require__.r(Mn),__webpack_require__.d(Mn,{identity:()=>g4});var On={};__webpack_require__.r(On),__webpack_require__.d(On,{sha256:()=>w4,sha512:()=>v4});var qn={};__webpack_require__.r(qn),__webpack_require__.d(qn,{base10:()=>K8});var Kn={};__webpack_require__.r(Kn),__webpack_require__.d(Kn,{base16:()=>F8,base16upper:()=>V8});var Fn={};__webpack_require__.r(Fn),__webpack_require__.d(Fn,{base2:()=>z8});var Vn={};__webpack_require__.r(Vn),__webpack_require__.d(Vn,{base256emoji:()=>G8});var zn={};__webpack_require__.r(zn),__webpack_require__.d(zn,{base32:()=>W8,base32hex:()=>X8,base32hexpad:()=>e7,base32hexpadupper:()=>t7,base32hexupper:()=>Z8,base32pad:()=>Q8,base32padupper:()=>J8,base32upper:()=>Y8,base32z:()=>r7});var $n={};__webpack_require__.r($n),__webpack_require__.d($n,{base36:()=>n7,base36upper:()=>i7});var Hn={};__webpack_require__.r(Hn),__webpack_require__.d(Hn,{base58btc:()=>s7,base58flickr:()=>o7});var jn={};__webpack_require__.r(jn),__webpack_require__.d(jn,{base64:()=>a7,base64pad:()=>c7,base64url:()=>u7,base64urlpad:()=>l7});var Gn={};__webpack_require__.r(Gn),__webpack_require__.d(Gn,{base8:()=>h7});var Wn={};__webpack_require__.r(Wn),__webpack_require__.d(Wn,{identity:()=>d7});var Yn={};__webpack_require__.r(Yn),__webpack_require__.d(Yn,{code:()=>b7,decode:()=>m7,encode:()=>y7,name:()=>g7});var Qn={};__webpack_require__.r(Qn),__webpack_require__.d(Qn,{code:()=>v7,decode:()=>E7,encode:()=>_7,name:()=>w7});var Jn={};__webpack_require__.r(Jn),__webpack_require__.d(Jn,{identity:()=>H7});var Xn={};__webpack_require__.r(Xn),__webpack_require__.d(Xn,{sha256:()=>Y7,sha512:()=>Q7});var Zn={};__webpack_require__.r(Zn),__webpack_require__.d(Zn,{base10:()=>Iee});var ei={};__webpack_require__.r(ei),__webpack_require__.d(ei,{base16:()=>Cee,base16upper:()=>Tee});var ti={};__webpack_require__.r(ti),__webpack_require__.d(ti,{base2:()=>Ree});var ri={};__webpack_require__.r(ri),__webpack_require__.d(ri,{base256emoji:()=>Bee});var ni={};__webpack_require__.r(ni),__webpack_require__.d(ni,{base32:()=>Uee,base32hex:()=>qee,base32hexpad:()=>Fee,base32hexpadupper:()=>Vee,base32hexupper:()=>Kee,base32pad:()=>Mee,base32padupper:()=>Oee,base32upper:()=>Lee,base32z:()=>zee});var ii={};__webpack_require__.r(ii),__webpack_require__.d(ii,{base36:()=>$ee,base36upper:()=>Hee});var si={};__webpack_require__.r(si),__webpack_require__.d(si,{base58btc:()=>jee,base58flickr:()=>Gee});var oi={};__webpack_require__.r(oi),__webpack_require__.d(oi,{base64:()=>Wee,base64pad:()=>Yee,base64url:()=>Qee,base64urlpad:()=>Jee});var ai={};__webpack_require__.r(ai),__webpack_require__.d(ai,{base8:()=>Xee});var ci={};__webpack_require__.r(ci),__webpack_require__.d(ci,{identity:()=>Zee});var ui={};__webpack_require__.r(ui),__webpack_require__.d(ui,{code:()=>nte,decode:()=>ste,encode:()=>ite,name:()=>rte});var li={};__webpack_require__.r(li),__webpack_require__.d(li,{code:()=>ate,decode:()=>ute,encode:()=>cte,name:()=>ote});var hi={};__webpack_require__.r(hi),__webpack_require__.d(hi,{identity:()=>Dte});var di={};__webpack_require__.r(di),__webpack_require__.d(di,{sha256:()=>Lte,sha512:()=>Mte});var fi={};__webpack_require__.r(fi),__webpack_require__.d(fi,{base10:()=>$re});var pi={};__webpack_require__.r(pi),__webpack_require__.d(pi,{base16:()=>Hre,base16upper:()=>jre});var gi={};__webpack_require__.r(gi),__webpack_require__.d(gi,{base2:()=>Gre});var bi={};__webpack_require__.r(bi),__webpack_require__.d(bi,{base256emoji:()=>Jre});var yi={};__webpack_require__.r(yi),__webpack_require__.d(yi,{base32:()=>Xre,base32hex:()=>rne,base32hexpad:()=>ine,base32hexpadupper:()=>sne,base32hexupper:()=>nne,base32pad:()=>ene,base32padupper:()=>tne,base32upper:()=>Zre,base32z:()=>one});var mi={};__webpack_require__.r(mi),__webpack_require__.d(mi,{base36:()=>ane,base36upper:()=>cne});var wi={};__webpack_require__.r(wi),__webpack_require__.d(wi,{base58btc:()=>une,base58flickr:()=>lne});var vi={};__webpack_require__.r(vi),__webpack_require__.d(vi,{base64:()=>hne,base64pad:()=>dne,base64url:()=>fne,base64urlpad:()=>pne});var _i={};__webpack_require__.r(_i),__webpack_require__.d(_i,{base8:()=>gne});var Ei={};__webpack_require__.r(Ei),__webpack_require__.d(Ei,{identity:()=>bne});var Si={};__webpack_require__.r(Si),__webpack_require__.d(Si,{code:()=>vne,decode:()=>Ene,encode:()=>_ne,name:()=>wne});var Ai={};__webpack_require__.r(Ai),__webpack_require__.d(Ai,{code:()=>Ane,decode:()=>xne,encode:()=>kne,name:()=>Sne});var ki={};__webpack_require__.r(ki),__webpack_require__.d(ki,{identity:()=>Yne});var xi={};__webpack_require__.r(xi),__webpack_require__.d(xi,{sha256:()=>Zne,sha512:()=>eie});var Ii={};__webpack_require__.r(Ii),__webpack_require__.d(Ii,{base58btc:()=>toe,base58flickr:()=>roe});var Ci={};__webpack_require__.r(Ci),__webpack_require__.d(Ci,{identity:()=>Ioe});var Ti={};__webpack_require__.r(Ti),__webpack_require__.d(Ti,{sha256:()=>Poe,sha512:()=>Doe});var Ri={};__webpack_require__.r(Ri),__webpack_require__.d(Ri,{base10:()=>Boe});var Pi={};__webpack_require__.r(Pi),__webpack_require__.d(Pi,{base16:()=>Uoe,base16upper:()=>Loe});var Di={};__webpack_require__.r(Di),__webpack_require__.d(Di,{base2:()=>Moe});var Ni={};__webpack_require__.r(Ni),__webpack_require__.d(Ni,{base256emoji:()=>Foe});var Bi={};__webpack_require__.r(Bi),__webpack_require__.d(Bi,{base32:()=>Voe,base32hex:()=>joe,base32hexpad:()=>Woe,base32hexpadupper:()=>Yoe,base32hexupper:()=>Goe,base32pad:()=>$oe,base32padupper:()=>Hoe,base32upper:()=>zoe,base32z:()=>Qoe});var Ui={};__webpack_require__.r(Ui),__webpack_require__.d(Ui,{base36:()=>Joe,base36upper:()=>Xoe});var Li={};__webpack_require__.r(Li),__webpack_require__.d(Li,{base64:()=>Zoe,base64pad:()=>eae,base64url:()=>tae,base64urlpad:()=>rae});var Mi={};__webpack_require__.r(Mi),__webpack_require__.d(Mi,{base8:()=>nae});var Oi={};__webpack_require__.r(Oi),__webpack_require__.d(Oi,{identity:()=>iae});var qi={};__webpack_require__.r(qi),__webpack_require__.d(qi,{code:()=>cae,decode:()=>lae,encode:()=>uae,name:()=>aae});var Ki={};__webpack_require__.r(Ki),__webpack_require__.d(Ki,{code:()=>dae,decode:()=>pae,encode:()=>fae,name:()=>hae});var Fi={};__webpack_require__.r(Fi),__webpack_require__.d(Fi,{Ed25519PrivateKey:()=>Sce,Ed25519PublicKey:()=>Ece,generateKeyPair:()=>xce,generateKeyPairFromSeed:()=>Ice,unmarshalEd25519PrivateKey:()=>Ace,unmarshalEd25519PublicKey:()=>kce});var Vi={};__webpack_require__.r(Vi),__webpack_require__.d(Vi,{MAX_RSA_KEY_SIZE:()=>qce,RsaPrivateKey:()=>Fce,RsaPublicKey:()=>Kce,fromJwk:()=>$ce,generateKeyPair:()=>Hce,unmarshalRsaPrivateKey:()=>Vce,unmarshalRsaPublicKey:()=>zce});var zi={};__webpack_require__.r(zi),__webpack_require__.d(zi,{Secp256k1PrivateKey:()=>Wce,Secp256k1PublicKey:()=>Gce,generateKeyPair:()=>Jce,unmarshalSecp256k1PrivateKey:()=>Yce,unmarshalSecp256k1PublicKey:()=>Qce});var $i={};__webpack_require__.r($i),__webpack_require__.d($i,{base10:()=>ude});var Hi={};__webpack_require__.r(Hi),__webpack_require__.d(Hi,{base16:()=>lde,base16upper:()=>hde});var ji={};__webpack_require__.r(ji),__webpack_require__.d(ji,{base2:()=>dde});var Gi={};__webpack_require__.r(Gi),__webpack_require__.d(Gi,{base256emoji:()=>bde});var Wi={};__webpack_require__.r(Wi),__webpack_require__.d(Wi,{base32:()=>yde,base32hex:()=>_de,base32hexpad:()=>Sde,base32hexpadupper:()=>Ade,base32hexupper:()=>Ede,base32pad:()=>wde,base32padupper:()=>vde,base32upper:()=>mde,base32z:()=>kde});var Yi={};__webpack_require__.r(Yi),__webpack_require__.d(Yi,{base36:()=>xde,base36upper:()=>Ide});var Qi={};__webpack_require__.r(Qi),__webpack_require__.d(Qi,{base58btc:()=>Cde,base58flickr:()=>Tde});var Ji={};__webpack_require__.r(Ji),__webpack_require__.d(Ji,{base64:()=>Rde,base64pad:()=>Pde,base64url:()=>Dde,base64urlpad:()=>Nde});var Xi={};__webpack_require__.r(Xi),__webpack_require__.d(Xi,{base8:()=>Bde});var Zi={};__webpack_require__.r(Zi),__webpack_require__.d(Zi,{identity:()=>Ude});var es={};__webpack_require__.r(es),__webpack_require__.d(es,{code:()=>qde,decode:()=>Fde,encode:()=>Kde,name:()=>Ode});var ts={};__webpack_require__.r(ts),__webpack_require__.d(ts,{code:()=>zde,decode:()=>Hde,encode:()=>$de,name:()=>Vde});var rs={};__webpack_require__.r(rs),__webpack_require__.d(rs,{identity:()=>pfe});var ns={};__webpack_require__.r(ns),__webpack_require__.d(ns,{sha256:()=>mfe,sha512:()=>wfe});var is=__webpack_require__(5043),ss=__webpack_require__(7950);const os=Math.pow(2,7),as=Math.pow(2,14),cs=Math.pow(2,21),us=Math.pow(2,28),ls=Math.pow(2,35),hs=Math.pow(2,42),ds=Math.pow(2,49),fs=128,ps=127;function gs(e){if(e<os)return 1;if(e<as)return 2;if(e<cs)return 3;if(e<us)return 4;if(e<ls)return 5;if(e<hs)return 6;if(e<ds)return 7;if(null!=Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function bs(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(gs(e)){case 8:t[r++]=255&e|fs,e/=128;case 7:t[r++]=255&e|fs,e/=128;case 6:t[r++]=255&e|fs,e/=128;case 5:t[r++]=255&e|fs,e/=128;case 4:t[r++]=255&e|fs,e>>>=7;case 3:t[r++]=255&e|fs,e>>>=7;case 2:t[r++]=255&e|fs,e>>>=7;case 1:t[r++]=255&e,e>>>=7;break;default:throw new Error("unreachable")}return t}function ys(e,t){let r=e[t],n=0;if(n+=r&ps,r<fs)return n;if(r=e[t+1],n+=(r&ps)<<7,r<fs)return n;if(r=e[t+2],n+=(r&ps)<<14,r<fs)return n;if(r=e[t+3],n+=(r&ps)<<21,r<fs)return n;if(r=e[t+4],n+=(r&ps)*us,r<fs)return n;if(r=e[t+5],n+=(r&ps)*ls,r<fs)return n;if(r=e[t+6],n+=(r&ps)*hs,r<fs)return n;if(r=e[t+7],n+=(r&ps)*ds,r<fs)return n;throw new RangeError("Could not decode varint")}function ms(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return null==t&&(t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}(gs(e))),t instanceof Uint8Array?bs(e,t,r):function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(gs(e)){case 8:t.set(r++,255&e|fs),e/=128;case 7:t.set(r++,255&e|fs),e/=128;case 6:t.set(r++,255&e|fs),e/=128;case 5:t.set(r++,255&e|fs),e/=128;case 4:t.set(r++,255&e|fs),e>>>=7;case 3:t.set(r++,255&e|fs),e>>>=7;case 2:t.set(r++,255&e|fs),e>>>=7;case 1:t.set(r++,255&e),e>>>=7;break;default:throw new Error("unreachable")}return t}(e,t,r)}function ws(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e instanceof Uint8Array?ys(e,t):function(e,t){let r=e.get(t),n=0;if(n+=r&ps,r<fs)return n;if(r=e.get(t+1),n+=(r&ps)<<7,r<fs)return n;if(r=e.get(t+2),n+=(r&ps)<<14,r<fs)return n;if(r=e.get(t+3),n+=(r&ps)<<21,r<fs)return n;if(r=e.get(t+4),n+=(r&ps)*us,r<fs)return n;if(r=e.get(t+5),n+=(r&ps)*ls,r<fs)return n;if(r=e.get(t+6),n+=(r&ps)*hs,r<fs)return n;if(r=e.get(t+7),n+=(r&ps)*ds,r<fs)return n;throw new RangeError("Could not decode varint")}(e,t)}const vs=new Float32Array([-0]),_s=new Uint8Array(vs.buffer);function Es(e,t,r){vs[0]=e,t[r]=_s[0],t[r+1]=_s[1],t[r+2]=_s[2],t[r+3]=_s[3]}const Ss=new Float64Array([-0]),As=new Uint8Array(Ss.buffer);function ks(e,t,r){Ss[0]=e,t[r]=As[0],t[r+1]=As[1],t[r+2]=As[2],t[r+3]=As[3],t[r+4]=As[4],t[r+5]=As[5],t[r+6]=As[6],t[r+7]=As[7]}const xs=BigInt(Number.MAX_SAFE_INTEGER),Is=BigInt(Number.MIN_SAFE_INTEGER);class Cs{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return Ts;if(e<xs&&e>Is)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>Rs&&(n=0n,++r>Rs&&(r=0n))),new Cs(Number(n),Number(r))}static fromNumber(e){if(0===e)return Ts;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new Cs(r,n)}static from(e){return"number"===typeof e?Cs.fromNumber(e):"bigint"===typeof e?Cs.fromBigInt(e):"string"===typeof e?Cs.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new Cs(e.low>>>0,e.high>>>0):Ts}}const Ts=new Cs(0,0);Ts.toBigInt=function(){return 0n},Ts.zzEncode=Ts.zzDecode=function(){return this},Ts.length=function(){return 1};const Rs=4294967296n;function Ps(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function Ds(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Ns(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Bs{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Ds(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw Ds(this,4);return Ns(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Ds(this,4);return 0|Ns(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw Ds(this,4);const e=(t=this.buf,r=this.pos,_s[0]=t[r],_s[1]=t[r+1],_s[2]=t[r+2],_s[3]=t[r+3],vs[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Ds(this,4);const e=(t=this.buf,r=this.pos,As[0]=t[r],As[1]=t[r+1],As[2]=t[r+2],As[3]=t[r+3],As[4]=t[r+4],As[5]=t[r+5],As[6]=t[r+6],As[7]=t[r+7],Ss[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw Ds(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw Ds(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Ds(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new Cs(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Ds(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Ds(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Ds(this,8);const e=Ns(this.buf,this.pos+=4),t=Ns(this.buf,this.pos+=4);return new Cs(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 Us(e,t,r){const n=function(e){return new Bs(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function Ls(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}new Uint8Array(0);function Ms(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Os=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const qs=Os;class Ks{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Fs{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return zs(this,e)}}class Vs{decoders;constructor(e){this.decoders=e}or(e){return zs(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function zs(e,t){return new Vs({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class $s{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Ks(e,t,r),this.decoder=new Fs(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Hs(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new $s(t,r,n,i)}function js(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=qs(n,t);return Hs({prefix:r,name:t,encode:i,decode:e=>Ms(s(e))})}function Gs(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Hs({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const Ws=js({prefix:"9",name:"base10",alphabet:"0123456789"}),Ys=Gs({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Qs=Gs({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Js=Gs({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Xs=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Zs=Xs.reduce(((e,t,r)=>(e[r]=t,e)),[]),eo=Xs.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const to=Hs({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Zs[t]),"")},decode:function(e){const t=[];for(const r of e){const e=eo[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),ro=Gs({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),no=Gs({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),io=Gs({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),so=Gs({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),oo=Gs({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ao=Gs({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),co=Gs({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),uo=Gs({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),lo=Gs({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),ho=js({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fo=js({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),po=js({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),go=js({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),bo=Gs({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yo=Gs({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mo=Gs({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),wo=Gs({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),vo=Gs({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),_o=Hs({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Eo=new TextEncoder,So=new TextDecoder,Ao="json",ko=512;function xo(e){return Eo.encode(JSON.stringify(e))}function Io(e){return JSON.parse(So.decode(e))}const Co="raw",To=85;function Ro(e){return Ms(e)}function Po(e){return Ms(e)}var Do=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Uo;)r[n++]=255&t|No,t/=128;for(;t&Bo;)r[n++]=255&t|No,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},No=128,Bo=-128,Uo=Math.pow(2,31);var Lo=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&Oo)<<s:(n&Oo)*Math.pow(2,s),s+=7}while(n>=Mo);return e.bytes=o-r,i},Mo=128,Oo=127;var qo=Math.pow(2,7),Ko=Math.pow(2,14),Fo=Math.pow(2,21),Vo=Math.pow(2,28),zo=Math.pow(2,35),$o=Math.pow(2,42),Ho=Math.pow(2,49),jo=Math.pow(2,56),Go=Math.pow(2,63);const Wo={encode:Do,decode:Lo,encodingLength:function(e){return e<qo?1:e<Ko?2:e<Fo?3:e<Vo?4:e<zo?5:e<$o?6:e<Ho?7:e<jo?8:e<Go?9:10}};function Yo(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Wo.encode(e,t,r),t}function Qo(e){return Wo.encodingLength(e)}function Jo(e,t){const r=t.byteLength,n=Qo(e),i=n+Qo(r),s=new Uint8Array(i+r);return Yo(e,s,0),Yo(r,s,n),s.set(t,i),new Xo(e,r,t,s)}class Xo{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Zo=Ms;const ea={code:0,name:"identity",encode:Zo,digest:function(e){return Jo(0,Zo(e))}};function ta(e){let{name:t,code:r,encode:n}=e;return new ra(t,r,n)}class ra{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Jo(this.code,t):t.then((e=>Jo(this.code,e)))}throw Error("Unknown type, must be binary type")}}function na(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const ia=ta({name:"sha2-256",code:18,encode:na("SHA-256")}),sa=ta({name:"sha2-512",code:19,encode:na("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const oa={...u,...r,...c,...e,...t,...i,...s,...o,...a,...n};function aa(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const ca=aa("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),ua=aa("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Ls((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),la={utf8:ca,"utf-8":ca,hex:oa.base16,latin1:ua,ascii:ua,binary:ua,...oa};class ha{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function da(){}class fa{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const pa=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return Ls(e);i+e>t&&(n=Ls(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class ga{len;head;tail;states;constructor(){this.len=0,this.head=new ha(da,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new ha(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new ma((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(wa,10,Cs.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=Cs.fromBigInt(e);return this._push(wa,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=Cs.fromBigInt(e).zzEncode();return this._push(wa,t.length(),t)}sint64Number(e){const t=Cs.fromNumber(e).zzEncode();return this._push(wa,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(ba,1,e?1:0)}fixed32(e){return this._push(va,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=Cs.fromBigInt(e);return this._push(va,4,t.lo)._push(va,4,t.hi)}fixed64Number(e){const t=Cs.fromNumber(e);return this._push(va,4,t.lo)._push(va,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(Es,4,e)}double(e){return this._push(ks,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(ba,1,0):this.uint32(t)._push(_a,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(Ps,t,e):this._push(ba,1,0)}fork(){return this.states=new fa(this),this.head=this.tail=new ha(da,0,0),this.len=0,this}reset(){return null!=this.states?(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 ha(da,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?Ls(r):pa(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function ba(e,t,r){t[r]=255&e}function ya(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class ma extends ha{next;constructor(e,t){super(ya,e,t),this.next=void 0}}function wa(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function va(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function _a(e,t,r){t.set(e,r)}function Ea(e,t,r){t.set(e,r)}function Sa(e,t,r){e.length<40?Ps(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=la[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}(e),r)}function Aa(e,t){const r=new ga;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var ka,xa,Ia,Ca,Ta,Ra,Pa,Da,Na,Ba,Ua,La,Ma,Oa,qa,Ka,Fa,Va,za,$a,Ha,ja,Ga,Wa,Ya,Qa,Ja,Xa,Za,ec,tc,rc,nc;function ic(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function sc(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return ic("enum",ka.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}function oc(e,t){return ic("message",ka.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(ga.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(Ea,t,e),this},ga.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Sa,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(ka||(ka={}));Error;function ac(e){return Boolean(e)}function cc(e){const t=new Map;return e.forEach((e=>{let r=t.get(e.contentTopic);r||(t.set(e.contentTopic,[]),r=t.get(e.contentTopic)),r.push(e)})),t}!function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(xa||(xa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),xa.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=xa.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ia||(Ia={})),function(e){let t,r;!function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.contentTopic=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(t=e.ContentFilter||(e.ContentFilter={})),e.codec=()=>(null==r&&(r=oc((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.subscribe&&!1!==t.subscribe&&(r.uint32(8),r.bool(t.subscribe)),null!=t.topic&&""!==t.topic&&(r.uint32(18),r.string(t.topic)),null!=t.contentFilters)for(const i of t.contentFilters)r.uint32(26),e.ContentFilter.codec().encode(i,r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={subscribe:!1,topic:"",contentFilters:[]},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.subscribe=t.bool();break;case 2:n.topic=t.string();break;case 3:n.contentFilters.push(e.ContentFilter.codec().decode(t,t.uint32()));break;default:t.skipType(7&r)}}return n}))),r),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ca||(Ca={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.messages)for(const n of e.messages)t.uint32(10),Da.codec().encode(n,t);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={messages:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.messages.push(Da.codec().decode(e,e.uint32()));else e.skipType(7&t)}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ta||(Ta={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),Ca.codec().encode(e.request,t)),null!=e.push&&(t.uint32(26),Ta.codec().encode(e.push,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.request=Ca.codec().decode(e,e.uint32());break;case 3:r.push=Ta.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ra||(Ra={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Pa||(Pa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Pa.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Pa.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Da||(Da={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===2)r.contentTopic=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Na||(Na={})),function(e){let t,r,n;!function(e){e.SUBSCRIBER_PING="SUBSCRIBER_PING",e.SUBSCRIBE="SUBSCRIBE",e.UNSUBSCRIBE="UNSUBSCRIBE",e.UNSUBSCRIBE_ALL="UNSUBSCRIBE_ALL"}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),function(e){e[e.SUBSCRIBER_PING=0]="SUBSCRIBER_PING",e[e.SUBSCRIBE=1]="SUBSCRIBE",e[e.UNSUBSCRIBE=2]="UNSUBSCRIBE",e[e.UNSUBSCRIBE_ALL=3]="UNSUBSCRIBE_ALL"}(r||(r={})),function(e){e.codec=()=>sc(r)}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),e.codec=()=>(null==n&&(n=oc((function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==i.lengthDelimited&&n.fork(),null!=t.requestId&&""!==t.requestId&&(n.uint32(10),n.string(t.requestId)),null!=t.filterSubscribeType&&0!==r[t.filterSubscribeType]&&(n.uint32(16),e.FilterSubscribeType.codec().encode(t.filterSubscribeType,n)),null!=t.pubsubTopic&&(n.uint32(82),n.string(t.pubsubTopic)),null!=t.contentTopics)for(const e of t.contentTopics)n.uint32(90),n.string(e);!1!==i.lengthDelimited&&n.ldelim()}),((r,n)=>{const i={requestId:"",filterSubscribeType:t.SUBSCRIBER_PING,contentTopics:[]},s=null==n?r.len:r.pos+n;for(;r.pos<s;){const t=r.uint32();switch(t>>>3){case 1:i.requestId=r.string();break;case 2:i.filterSubscribeType=e.FilterSubscribeType.codec().decode(r);break;case 10:i.pubsubTopic=r.string();break;case 11:i.contentTopics.push(r.string());break;default:r.skipType(7&t)}}return i}))),n),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ba||(Ba={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.statusCode&&0!==e.statusCode&&(t.uint32(80),t.uint32(e.statusCode)),null!=e.statusDesc&&(t.uint32(90),t.string(e.statusDesc)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:"",statusCode:0},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 10:r.statusCode=e.uint32();break;case 11:r.statusDesc=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ua||(Ua={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.wakuMessage&&(t.uint32(10),Oa.codec().encode(e.wakuMessage,t)),null!=e.pubsubTopic&&(t.uint32(18),t.string(e.pubsubTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.wakuMessage=Oa.codec().decode(e,e.uint32());break;case 2:r.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(La||(La={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ma||(Ma={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Ma.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Ma.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Oa||(Oa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.pubsubTopic&&""!==e.pubsubTopic&&(t.uint32(10),t.string(e.pubsubTopic)),null!=e.message&&(t.uint32(18),za.codec().encode(e.message,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={pubsubTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.pubsubTopic=e.string();break;case 2:r.message=za.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(qa||(qa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.isSuccess&&!1!==e.isSuccess&&(t.uint32(8),t.bool(e.isSuccess)),null!=e.info&&(t.uint32(18),t.string(e.info)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={isSuccess:!1},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.isSuccess=e.bool();break;case 2:r.info=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ka||(Ka={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),qa.codec().encode(e.request,t)),null!=e.response&&(t.uint32(26),Ka.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.request=qa.codec().decode(e,e.uint32());break;case 3:r.response=Ka.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Fa||(Fa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Va||(Va={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Va.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Va.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(za||(za={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.digest&&e.digest.byteLength>0&&(t.uint32(10),t.bytes(e.digest)),null!=e.receiverTime&&0n!==e.receiverTime&&(t.uint32(16),t.sint64(e.receiverTime)),null!=e.senderTime&&0n!==e.senderTime&&(t.uint32(24),t.sint64(e.senderTime)),null!=e.pubsubTopic&&""!==e.pubsubTopic&&(t.uint32(34),t.string(e.pubsubTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={digest:new Uint8Array(0),receiverTime:0n,senderTime:0n,pubsubTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.digest=e.bytes();break;case 2:r.receiverTime=e.sint64();break;case 3:r.senderTime=e.sint64();break;case 4:r.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}($a||($a={})),function(e){let t,r,n;!function(e){e.BACKWARD="BACKWARD",e.FORWARD="FORWARD"}(t=e.Direction||(e.Direction={})),function(e){e[e.BACKWARD=0]="BACKWARD",e[e.FORWARD=1]="FORWARD"}(r||(r={})),function(e){e.codec=()=>sc(r)}(t=e.Direction||(e.Direction={})),e.codec=()=>(null==n&&(n=oc((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&r.fork(),null!=t.pageSize&&(r.uint32(8),r.uint64(t.pageSize)),null!=t.cursor&&(r.uint32(18),$a.codec().encode(t.cursor,r)),null!=t.direction&&(r.uint32(24),e.Direction.codec().encode(t.direction,r)),!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.pageSize=t.uint64();break;case 2:n.cursor=$a.codec().decode(t,t.uint32());break;case 3:n.direction=e.Direction.codec().decode(t);break;default:t.skipType(7&r)}}return n}))),n),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ha||(Ha={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.contentTopic=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(ja||(ja={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.pubsubTopic&&(t.uint32(18),t.string(e.pubsubTopic)),null!=e.contentFilters)for(const n of e.contentFilters)t.uint32(26),ja.codec().encode(n,t);null!=e.pagingInfo&&(t.uint32(34),Ha.codec().encode(e.pagingInfo,t)),null!=e.startTime&&(t.uint32(40),t.sint64(e.startTime)),null!=e.endTime&&(t.uint32(48),t.sint64(e.endTime)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={contentFilters:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 2:r.pubsubTopic=e.string();break;case 3:r.contentFilters.push(ja.codec().decode(e,e.uint32()));break;case 4:r.pagingInfo=Ha.codec().decode(e,e.uint32());break;case 5:r.startTime=e.sint64();break;case 6:r.endTime=e.sint64();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ga||(Ga={})),function(e){let t,r,n;!function(e){e.NONE="NONE",e.INVALID_CURSOR="INVALID_CURSOR"}(t=e.HistoryError||(e.HistoryError={})),function(e){e[e.NONE=0]="NONE",e[e.INVALID_CURSOR=1]="INVALID_CURSOR"}(r||(r={})),function(e){e.codec=()=>sc(r)}(t=e.HistoryError||(e.HistoryError={})),e.codec=()=>(null==n&&(n=oc((function(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==i.lengthDelimited&&n.fork(),null!=t.messages)for(const e of t.messages)n.uint32(18),Ja.codec().encode(e,n);null!=t.pagingInfo&&(n.uint32(26),Ha.codec().encode(t.pagingInfo,n)),null!=t.error&&0!==r[t.error]&&(n.uint32(32),e.HistoryError.codec().encode(t.error,n)),!1!==i.lengthDelimited&&n.ldelim()}),((r,n)=>{const i={messages:[],error:t.NONE},s=null==n?r.len:r.pos+n;for(;r.pos<s;){const t=r.uint32();switch(t>>>3){case 2:i.messages.push(Ja.codec().decode(r,r.uint32()));break;case 3:i.pagingInfo=Ha.codec().decode(r,r.uint32());break;case 4:i.error=e.HistoryError.codec().decode(r);break;default:r.skipType(7&t)}}return i}))),n),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Wa||(Wa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.query&&(t.uint32(18),Ga.codec().encode(e.query,t)),null!=e.response&&(t.uint32(26),Wa.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={requestId:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.query=Ga.codec().decode(e,e.uint32());break;case 3:r.response=Wa.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ya||(Ya={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.proof&&e.proof.byteLength>0&&(t.uint32(10),t.bytes(e.proof)),null!=e.merkleRoot&&e.merkleRoot.byteLength>0&&(t.uint32(18),t.bytes(e.merkleRoot)),null!=e.epoch&&e.epoch.byteLength>0&&(t.uint32(26),t.bytes(e.epoch)),null!=e.shareX&&e.shareX.byteLength>0&&(t.uint32(34),t.bytes(e.shareX)),null!=e.shareY&&e.shareY.byteLength>0&&(t.uint32(42),t.bytes(e.shareY)),null!=e.nullifier&&e.nullifier.byteLength>0&&(t.uint32(50),t.bytes(e.nullifier)),null!=e.rlnIdentifier&&e.rlnIdentifier.byteLength>0&&(t.uint32(58),t.bytes(e.rlnIdentifier)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={proof:new Uint8Array(0),merkleRoot:new Uint8Array(0),epoch:new Uint8Array(0),shareX:new Uint8Array(0),shareY:new Uint8Array(0),nullifier:new Uint8Array(0),rlnIdentifier:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.proof=e.bytes();break;case 2:r.merkleRoot=e.bytes();break;case 3:r.epoch=e.bytes();break;case 4:r.shareX=e.bytes();break;case 5:r.shareY=e.bytes();break;case 6:r.nullifier=e.bytes();break;case 7:r.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Qa||(Qa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(10),t.bytes(e.payload)),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),null!=e.version&&(t.uint32(24),t.uint32(e.version)),null!=e.timestamp&&(t.uint32(80),t.sint64(e.timestamp)),null!=e.meta&&(t.uint32(90),t.bytes(e.meta)),null!=e.rateLimitProof&&(t.uint32(170),Qa.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={payload:new Uint8Array(0),contentTopic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.payload=e.bytes();break;case 2:r.contentTopic=e.string();break;case 3:r.version=e.uint32();break;case 10:r.timestamp=e.sint64();break;case 11:r.meta=e.bytes();break;case 21:r.rateLimitProof=Qa.codec().decode(e,e.uint32());break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Ja||(Ja={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.enr&&(t.uint32(10),t.bytes(e.enr)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.enr=e.bytes();else e.skipType(7&t)}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Xa||(Xa={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.numPeers&&(t.uint32(8),t.uint64(e.numPeers)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.numPeers=e.uint64();else e.skipType(7&t)}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(Za||(Za={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.peerInfos)for(const n of e.peerInfos)t.uint32(10),Xa.codec().encode(n,t);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={peerInfos:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.peerInfos.push(Xa.codec().decode(e,e.uint32()));else e.skipType(7&t)}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(ec||(ec={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.query&&(t.uint32(10),Za.codec().encode(e.query,t)),null!=e.response&&(t.uint32(18),ec.codec().encode(e.response,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.query=Za.codec().decode(e,e.uint32());break;case 2:r.response=ec.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(tc||(tc={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const n of e.shards)t.uint32(16),t.uint32(n);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={shards:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.clusterId=e.uint32();break;case 2:r.shards.push(e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(rc||(rc={})),function(e){let t;e.codec=()=>(null==t&&(t=oc((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const n of e.shards)t.uint32(16),t.uint32(n);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={shards:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.clusterId=e.uint32();break;case 2:r.shards.push(e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Aa(t,e.codec()),e.decode=t=>Us(t,e.codec())}(nc||(nc={}));async function uc(e,t,r){const n=r?.iteratorDelay??60,i=[];let s;s=await e.subscribe(t,(e=>{i.push(e)}));const o=Number.isInteger(r?.timeoutMs),a=r?.timeoutMs??0,c=Date.now();return{iterator:async function*(){for(;;){if(o&&Date.now()-c>=a)return;await lc(n);const e=i.shift();if(!s&&0===i.length)return e;!e&&s||(yield e)}}(),async stop(){s&&(await s(),s=void 0)}}}function lc(e){return new Promise((t=>{setTimeout(t,e)}))}const hc=e=>e.length/1048576<=1;function dc(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function fc(e){if(!((t=e)instanceof Uint8Array||null!=t&&"object"===typeof t&&"Uint8Array"===t.constructor.name))throw new Error("Uint8Array expected");for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];if(n.length>0&&!n.includes(e.length))throw new Error(`Uint8Array expected of length ${n}, not of length=${e.length}`)}function pc(e){if("function"!==typeof e||"function"!==typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");dc(e.outputLen),dc(e.blockLen)}function gc(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function bc(e,t){fc(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const yc="object"===typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;const mc=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),wc=(e,t)=>e<<32-t|e>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];const vc=async()=>{};async function _c(e,t,r){let n=Date.now();for(let i=0;i<e;i++){r(i);const e=Date.now()-n;e>=0&&e<t||(await vc(),n+=e)}}function Ec(e){if("string"!==typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function Sc(e){return"string"===typeof e&&(e=Ec(e)),fc(e),e}function Ac(){let e=0;for(let r=0;r<arguments.length;r++){const t=r<0||arguments.length<=r?void 0:arguments[r];fc(t),e+=t.length}const t=new Uint8Array(e);for(let r=0,n=0;r<arguments.length;r++){const e=r<0||arguments.length<=r?void 0:arguments[r];t.set(e,n),n+=e.length}return t}class kc{clone(){return this._cloneInto()}}const xc={}.toString;function Ic(e){const t=t=>e().update(Sc(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Cc(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(yc&&"function"===typeof yc.getRandomValues)return yc.getRandomValues(new Uint8Array(e));throw new Error("crypto.getRandomValues must be defined")}const Tc=(e,t,r)=>e&t^e&r^t&r;class Rc extends kc{constructor(e,t,r,n){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=mc(this.buffer)}update(e){gc(this);const{view:t,buffer:r,blockLen:n}=this,i=(e=Sc(e)).length;for(let s=0;s<i;){const o=Math.min(n-this.pos,i-s);if(o!==n)r.set(e.subarray(s,s+o),this.pos),this.pos+=o,s+=o,this.pos===n&&(this.process(t,0),this.pos=0);else{const t=mc(e);for(;n<=i-s;s+=n)this.process(t,s)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){gc(this),bc(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:n,isLE:i}=this;let{pos:s}=this;t[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>n-s&&(this.process(r,0),s=0);for(let l=s;l<n;l++)t[l]=0;!function(e,t,r,n){if("function"===typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,u=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+u,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const o=mc(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<c;l++)o.setUint32(4*l,u[l],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:n,finished:i,destroyed:s,pos:o}=this;return e.length=n,e.pos=o,e.finished=i,e.destroyed=s,n%t&&e.buffer.set(r),e}}const Pc=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Dc=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Nc=new Uint32Array(64);class Bc extends Rc{constructor(){super(64,32,8,!1),this.A=0|Dc[0],this.B=0|Dc[1],this.C=0|Dc[2],this.D=0|Dc[3],this.E=0|Dc[4],this.F=0|Dc[5],this.G=0|Dc[6],this.H=0|Dc[7]}get(){const{A:e,B:t,C:r,D:n,E:i,F:s,G:o,H:a}=this;return[e,t,r,n,i,s,o,a]}set(e,t,r,n,i,s,o,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|s,this.G=0|o,this.H=0|a}process(e,t){for(let h=0;h<16;h++,t+=4)Nc[h]=e.getUint32(t,!1);for(let h=16;h<64;h++){const e=Nc[h-15],t=Nc[h-2],r=wc(e,7)^wc(e,18)^e>>>3,n=wc(t,17)^wc(t,19)^t>>>10;Nc[h]=n+Nc[h-7]+r+Nc[h-16]|0}let{A:r,B:n,C:i,D:s,E:o,F:a,G:c,H:u}=this;for(let h=0;h<64;h++){const e=u+(wc(o,6)^wc(o,11)^wc(o,25))+((l=o)&a^~l&c)+Pc[h]+Nc[h]|0,t=(wc(r,2)^wc(r,13)^wc(r,22))+Tc(r,n,i)|0;u=c,c=a,a=o,o=s+e|0,s=i,i=n,n=r,r=e+t|0}var l;r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,s=s+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,n,i,s,o,a,c,u)}roundClean(){Nc.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Uc=Ic((()=>new Bc));var Lc,Mc,Oc,qc,Kc,Fc;!function(e){e.Relay="relay",e.Store="store",e.LightPush="lightpush",e.Filter="filter"}(Lc||(Lc={})),function(e){e.GENERIC_FAIL="Generic error",e.ENCODE_FAILED="Failed to encode",e.DECODE_FAILED="Failed to decode",e.EMPTY_PAYLOAD="Payload is empty",e.SIZE_TOO_BIG="Size is too big",e.TOPIC_NOT_CONFIGURED="Topic not configured",e.NO_PEER_AVAILABLE="No peer available",e.REMOTE_PEER_FAULT="Remote peer fault",e.REMOTE_PEER_REJECTED="Remote peer rejected",e.REQUEST_TIMEOUT="Request timeout"}(Mc||(Mc={})),function(e){e.BACKWARD="backward",e.FORWARD="forward"}(Oc||(Oc={})),function(e){e.BOOTSTRAP="bootstrap",e.PEER_EXCHANGE="peer-exchange",e.LOCAL="local-peer-cache"}(qc||(qc={})),function(e){e.PEER_DISCOVERY_BOOTSTRAP="peer:discovery:bootstrap",e.PEER_DISCOVERY_PEER_EXCHANGE="peer:discovery:peer-exchange",e.PEER_CONNECT_BOOTSTRAP="peer:connected:bootstrap",e.PEER_CONNECT_PEER_EXCHANGE="peer:connected:peer-exchange"}(Kc||(Kc={})),function(e){e.CONNECTION_STATUS="waku:connection"}(Fc||(Fc={}));const Vc="/waku/2/default-waku/proto",zc=1;new Uint8Array(0);function $c(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Hc=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const jc=Hc;class Gc{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Wc{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return Qc(this,e)}}class Yc{decoders;constructor(e){this.decoders=e}or(e){return Qc(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function Qc(e,t){return new Yc({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class Jc{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Gc(e,t,r),this.decoder=new Wc(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Xc(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Jc(t,r,n,i)}function Zc(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=jc(n,t);return Xc({prefix:r,name:t,encode:i,decode:e=>$c(s(e))})}function eu(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Xc({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const tu=Zc({prefix:"9",name:"base10",alphabet:"0123456789"}),ru=eu({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),nu=eu({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),iu=eu({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),su=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),ou=su.reduce(((e,t,r)=>(e[r]=t,e)),[]),au=su.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const cu=Xc({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=ou[t]),"")},decode:function(e){const t=[];for(const r of e){const e=au[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),uu=eu({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),lu=eu({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),hu=eu({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),du=eu({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),fu=eu({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),pu=eu({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gu=eu({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),bu=eu({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),yu=eu({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),mu=Zc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),wu=Zc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),vu=Zc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),_u=Zc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Eu=eu({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Su=eu({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Au=eu({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ku=eu({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),xu=eu({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Iu=Xc({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Cu=new TextEncoder,Tu=new TextDecoder,Ru="json",Pu=512;function Du(e){return Cu.encode(JSON.stringify(e))}function Nu(e){return JSON.parse(Tu.decode(e))}const Bu="raw",Uu=85;function Lu(e){return $c(e)}function Mu(e){return $c(e)}var Ou=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Fu;)r[n++]=255&t|qu,t/=128;for(;t&Ku;)r[n++]=255&t|qu,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},qu=128,Ku=-128,Fu=Math.pow(2,31);var Vu=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&$u)<<s:(n&$u)*Math.pow(2,s),s+=7}while(n>=zu);return e.bytes=o-r,i},zu=128,$u=127;var Hu=Math.pow(2,7),ju=Math.pow(2,14),Gu=Math.pow(2,21),Wu=Math.pow(2,28),Yu=Math.pow(2,35),Qu=Math.pow(2,42),Ju=Math.pow(2,49),Xu=Math.pow(2,56),Zu=Math.pow(2,63);const el={encode:Ou,decode:Vu,encodingLength:function(e){return e<Hu?1:e<ju?2:e<Gu?3:e<Wu?4:e<Yu?5:e<Qu?6:e<Ju?7:e<Xu?8:e<Zu?9:10}};function tl(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return el.encode(e,t,r),t}function rl(e){return el.encodingLength(e)}function nl(e,t){const r=t.byteLength,n=rl(e),i=n+rl(r),s=new Uint8Array(i+r);return tl(e,s,0),tl(r,s,n),s.set(t,i),new il(e,r,t,s)}class il{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const sl=$c;const ol={code:0,name:"identity",encode:sl,digest:function(e){return nl(0,sl(e))}};function al(e){let{name:t,code:r,encode:n}=e;return new cl(t,r,n)}class cl{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?nl(this.code,t):t.then((e=>nl(this.code,e)))}throw Error("Unknown type, must be binary type")}}function ul(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const ll=al({name:"sha2-256",code:18,encode:ul("SHA-256")}),hl=al({name:"sha2-512",code:19,encode:ul("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const dl={...S,...b,...E,...p,...g,...m,...w,...v,..._,...y};function fl(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const pl=fl("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),gl=fl("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),bl={utf8:pl,"utf-8":pl,hex:dl.base16,latin1:gl,ascii:gl,binary:gl,...dl};function yl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=bl[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function ml(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=bl[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function wl(e){if("string"===typeof e){return yl(e.replace(/^0x/i,"").toLowerCase(),"base16")}return e}const vl=e=>ml(e,"base16"),_l=e=>ml(e,"utf8"),El=e=>yl(e,"utf8");function Sl(e,t){const r=t??e.reduce(((e,t)=>e+t.length),0),n=new Uint8Array(r);let i=0;for(const s of e)n.set(s,i),i+=s.length;return n}const Al=e=>{if(void 0===e.clusterId||void 0===e.shard)throw new Error("Invalid shard");return`/waku/2/rs/${e.clusterId}/${e.shard}`},kl=e=>{if("contentTopics"in e&&e.contentTopics)return Array.from(new Set(e.contentTopics.map((t=>Tl(t,e.clusterId)))));if("shards"in e){if(void 0===e.shards)throw new Error("Invalid shard");return Array.from(new Set(e.shards.map((t=>`/waku/2/rs/${e.clusterId??zc}/${t}`))))}if("application"in e&&"version"in e)return[Tl(`/${e.application}/${e.version}/default/default`,e.clusterId)];throw new Error("Missing required configuration in shard parameters")},xl=e=>{const t=e.split("/");if(6!=t.length||"waku"!==t[1]||"2"!==t[2]||"rs"!==t[3])throw new Error("Invalid pubsub topic");const r=parseInt(t[4]),n=parseInt(t[5]);if(isNaN(r)||isNaN(n))throw new Error("Invalid clusterId or shard");return{clusterId:r,shard:n}};function Il(e,t){if(!t.includes(e))throw new Error(`Pubsub topic ${e} has not been configured on this instance. Configured topics are: ${t}. Please update your configuration by passing in the topic during Waku node instantiation.`)}function Cl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const{application:r,version:n}=function(e){const t=e.split("/");if(t.length<5||t.length>6)throw Error("Content topic format is invalid");let r=0;if(6==t.length){if(r=parseInt(t[1]),isNaN(r))throw new Error("Invalid generation field in content topic");if(r>0)throw new Error("Generation greater than 0 is not supported")}const n=t.splice(-4);if(0==n[0].length)throw new Error("Application field cannot be empty");if(0==n[1].length)throw new Error("Version field cannot be empty");if(0==n[2].length)throw new Error("Topic name field cannot be empty");if(0==n[3].length)throw new Error("Encoding field cannot be empty");return{generation:r,application:n[0],version:n[1],topicName:n[2],encoding:n[3]}}(e),i=Uc(Sl([El(r),El(n)])),s=new DataView(i.buffer.slice(-8));return Number(s.getBigUint64(0,!1)%BigInt(t))}function Tl(e){return`/waku/2/rs/${arguments.length>1&&void 0!==arguments[1]?arguments[1]:zc}/${Cl(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:8)}`}function Rl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Vc;return"string"==typeof t?t:t?t.shard?Al(t):Tl(e,t.clusterId):Vc}const Pl=e=>{const t=e.clusterId??zc,r="shards"in e?e.shards:[],n="contentTopics"in e?e.contentTopics:[],[i,s]="application"in e&&"version"in e?[e.application,e.version]:[void 0,void 0],o=r&&r.length>0,a=n&&n.length>0,c=i&&s;if(o)return{shardingParams:{clusterId:t,shards:r},shardInfo:{clusterId:t,shards:r},pubsubTopics:kl({clusterId:t,shards:r})};if(a){const e=Array.from(new Set(n.map((e=>Tl(e,t))))),r=Array.from(new Set(n.map((e=>Cl(e)))));return{shardingParams:{clusterId:t,contentTopics:n},shardInfo:{clusterId:t,shards:r},pubsubTopics:e}}if(c){const e=Tl(`/${i}/${s}/default/default`,t);return{shardingParams:{clusterId:t,application:i,version:s},shardInfo:{clusterId:t,shards:[xl(e).shard]},pubsubTopics:[e]}}throw new Error("Missing minimum required configuration options for static sharding or autosharding.")};const Dl=e=>{if((e=new Uint8Array(e)).length<3)throw new Error("Insufficient data");const t=new DataView(e.buffer),r=t.getUint16(0),n=[];if(130===e.length)for(let i=0;i<1024;i++){const e=Math.floor(i/8)+2,r=7-i%8;t.getUint8(e)&1<<r&&n.push(i)}else{const r=t.getUint8(2);for(let i=0,s=3;i<r;i++,s+=2){if(s+1>=e.length)throw new Error("Unexpected end of data");n.push(t.getUint16(s))}}return{clusterId:r,shards:n}},Nl=e=>{const{clusterId:t,shards:r}=e,n=r.length>=64?130:3+2*r.length,i=new ArrayBuffer(n),s=new DataView(i);if(s.setUint16(0,t),r.length>=64)for(const o of r){const e=Math.floor(o/8)+2,t=7-o%8;s.setUint8(e,s.getUint8(e)|1<<t)}else{s.setUint8(2,r.length);for(let e=0,t=3;e<r.length;e++,t+=2)s.setUint16(t,r[e])}return new Uint8Array(i)};var Bl=__webpack_require__(6522);const Ul="waku";class Ll{_info;_warn;_error;static createDebugNamespace(e,t){return t?`${Ul}:${e}:${t}`:`${Ul}:${e}`}constructor(e){this._info=Bl(Ll.createDebugNamespace("info",e)),this._warn=Bl(Ll.createDebugNamespace("warn",e)),this._error=Bl(Ll.createDebugNamespace("error",e))}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(e){const t=this[e];for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];t(...n)}}const Ml=new Ll("message:version-0"),Ol=BigInt(1e6);class ql{pubsubTopic;proto;constructor(e,t){this.pubsubTopic=e,this.proto=t}get ephemeral(){return Boolean(this.proto.ephemeral)}get payload(){return this.proto.payload}get contentTopic(){return this.proto.contentTopic}get _rawTimestamp(){return this.proto.timestamp}get timestamp(){try{if(this.proto.timestamp){const e=this.proto.timestamp/Ol;return new Date(Number(e))}return}catch(e){return}}get meta(){return this.proto.meta}get version(){return this.proto.version??0}get rateLimitProof(){return this.proto.rateLimitProof}}class Kl{contentTopic;ephemeral;pubsubTopic;metaSetter;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0;if(this.contentTopic=e,this.ephemeral=t,this.pubsubTopic=r,this.metaSetter=n,!e||""===e)throw new Error("Content topic must be specified")}async toWire(e){return Ia.encode(await this.toProtoObj(e))}async toProtoObj(e){const t=e.timestamp??new Date,r={payload:e.payload,version:0,contentTopic:this.contentTopic,timestamp:BigInt(t.valueOf())*Ol,meta:void 0,rateLimitProof:e.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const e=this.metaSetter(r);return{...r,meta:e}}return r}}function Fl(e){let{pubsubTopic:t,pubsubTopicShardInfo:r,contentTopic:n,ephemeral:i,metaSetter:s}=e;return new Kl(n,i,Rl(n,t??r),s)}class Vl{pubsubTopic;contentTopic;constructor(e,t){if(this.pubsubTopic=e,this.contentTopic=t,!t||""===t)throw new Error("Content topic must be specified")}fromWireToProtoObj(e){const t=Ia.decode(e);return Promise.resolve({payload:t.payload,contentTopic:t.contentTopic,version:t.version??void 0,timestamp:t.timestamp??void 0,meta:t.meta??void 0,rateLimitProof:t.rateLimitProof??void 0,ephemeral:t.ephemeral??!1})}async fromProtoObj(e,t){return t.version?(Ml.error("Failed to decode due to incorrect version, expected:",0,", actual:",t.version),Promise.resolve(void 0)):new ql(e,t)}}function zl(e,t){return new Vl(Rl(e,t),e)}function $l(e,t){const r=function(e,t){const r=El(e),n=El(t.contentTopic);let i;return i=t.meta?Sl([r,t.payload,n,t.meta]):Sl([r,t.payload,n]),Uc(i)}(e,t);return _l(r)}const Hl=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{const t=[];for await(const r of e)t.push(r);return t})();const t=[];for(const r of e)t.push(r);return t};function jl(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Gl(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function Wl(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=Gl(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Yl(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const Ql=Symbol.for("@achingbrain/uint8arraylist");function Jl(e,t){if(null==t||t<0)throw new RangeError("index is out of bounds");let r=0;for(const n of e){const e=r+n.byteLength;if(t<e)return{buf:n,index:t-r};r=e}throw new RangeError("index is out of bounds")}function Xl(e){return Boolean(e?.[Ql])}class Zl{bufs;length;[Ql]=!0;constructor(){this.bufs=[],this.length=0;for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];t.length>0&&this.appendAll(t)}*[Symbol.iterator](){yield*this.bufs}get byteLength(){return this.length}append(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.appendAll(t)}appendAll(e){let t=0;for(const r of e)if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.push(r);else{if(!Xl(r))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.push(...r.bufs)}this.length+=t}prepend(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this.prependAll(t)}prependAll(e){let t=0;for(const r of e.reverse())if(r instanceof Uint8Array)t+=r.byteLength,this.bufs.unshift(r);else{if(!Xl(r))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=r.byteLength,this.bufs.unshift(...r.bufs)}this.length+=t}get(e){const t=Jl(this.bufs,e);return t.buf[t.index]}set(e,t){const r=Jl(this.bufs,e);r.buf[r.index]=t}write(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e instanceof Uint8Array)for(let r=0;r<e.length;r++)this.set(t+r,e[r]);else{if(!Xl(e))throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList");for(let r=0;r<e.length;r++)this.set(t+r,e.get(r))}}consume(e){if(e=Math.trunc(e),!(Number.isNaN(e)||e<=0)){if(e===this.byteLength)return this.bufs=[],void(this.length=0);for(;this.bufs.length>0;){if(!(e>=this.bufs[0].byteLength)){this.bufs[0]=this.bufs[0].subarray(e),this.length-=e;break}e-=this.bufs[0].byteLength,this.length-=this.bufs[0].byteLength,this.bufs.shift()}}}slice(e,t){const{bufs:r,length:n}=this._subList(e,t);return Wl(r,n)}subarray(e,t){const{bufs:r,length:n}=this._subList(e,t);return 1===r.length?r[0]:Wl(r,n)}sublist(e,t){const{bufs:r,length:n}=this._subList(e,t),i=new Zl;return i.length=n,i.bufs=[...r],i}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:this.bufs,length:this.length};const r=[];let n=0;for(let i=0;i<this.bufs.length;i++){const s=this.bufs[i],o=n,a=o+s.byteLength;if(n=a,e>=a)continue;const c=e>=o&&e<a,u=t>o&&t<=a;if(c&&u){if(e===o&&t===a){r.push(s);break}const n=e-o;r.push(s.subarray(n,n+(t-e)));break}if(c){if(0===e){r.push(s);continue}r.push(s.subarray(e-o))}else{if(u){if(t===a){r.push(s);break}r.push(s.subarray(0,t-o));break}r.push(s)}}return{bufs:r,length:t-e}}indexOf(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!Xl(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const r=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const n=r.byteLength;if(0===n)throw new TypeError("search must be at least 1 byte long");const i=new Int32Array(256);for(let u=0;u<256;u++)i[u]=-1;for(let u=0;u<n;u++)i[r[u]]=u;const s=i,o=this.byteLength-r.byteLength,a=r.byteLength-1;let c;for(let u=t;u<=o;u+=c){c=0;for(let e=a;e>=0;e--){const t=this.get(u+e);if(r[e]!==t){c=Math.max(1,e-s[t]);break}}if(0===c)return u}return-1}getInt8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getInt8(0)}setInt8(e,t){const r=Gl(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt8(0,t),this.write(r,e)}getInt16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt16(0,t)}setInt16(e,t,r){const n=jl(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt16(0,t,r),this.write(n,e)}getInt32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getInt32(0,t)}setInt32(e,t,r){const n=jl(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt32(0,t,r),this.write(n,e)}getBigInt64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigInt64(0,t)}setBigInt64(e,t,r){const n=jl(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigInt64(0,t,r),this.write(n,e)}getUint8(e){const t=this.subarray(e,e+1);return new DataView(t.buffer,t.byteOffset,t.byteLength).getUint8(0)}setUint8(e,t){const r=Gl(1);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint8(0,t),this.write(r,e)}getUint16(e,t){const r=this.subarray(e,e+2);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint16(0,t)}setUint16(e,t,r){const n=jl(2);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint16(0,t,r),this.write(n,e)}getUint32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,t)}setUint32(e,t,r){const n=jl(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint32(0,t,r),this.write(n,e)}getBigUint64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getBigUint64(0,t)}setBigUint64(e,t,r){const n=jl(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setBigUint64(0,t,r),this.write(n,e)}getFloat32(e,t){const r=this.subarray(e,e+4);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat32(0,t)}setFloat32(e,t,r){const n=jl(4);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat32(0,t,r),this.write(n,e)}getFloat64(e,t){const r=this.subarray(e,e+8);return new DataView(r.buffer,r.byteOffset,r.byteLength).getFloat64(0,t)}setFloat64(e,t,r){const n=jl(8);new DataView(n.buffer,n.byteOffset,n.byteLength).setFloat64(0,t,r),this.write(n,e)}equals(e){if(null==e)return!1;if(!(e instanceof Zl))return!1;if(e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Yl(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){const r=new Zl;return r.bufs=e,null==t&&(t=e.reduce(((e,t)=>e+t.byteLength),0)),r.length=t,r}}function eh(e){return null!=e[Symbol.asyncIterator]}const th=e=>{const t=gs(e),r=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}(t);return ms(e,r),th.bytes=t,r};function rh(e,t){const r=(t=t??{}).lengthEncoder??th;function*n(e){const t=r(e.byteLength);t instanceof Uint8Array?yield t:yield*t,e instanceof Uint8Array?yield e:yield*e}return eh(e)?async function*(){for await(const t of e)yield*n(t)}():function*(){for(const t of e)yield*n(t)}()}th.bytes=0,rh.single=(e,t)=>{const r=(t=t??{}).lengthEncoder??th;return new Zl(r(e.byteLength),e)};var nh=__webpack_require__(4823);var ih;!function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"}(ih||(ih={}));const sh=e=>{const t=ws(e);return sh.bytes=gs(t),t};function oh(e,t){const r=new Zl;let n=ih.LENGTH,i=-1;const s=t?.lengthDecoder??sh,o=t?.maxLengthLength??8,a=t?.maxDataLength??4194304;function*c(){for(;r.byteLength>0;){if(n===ih.LENGTH)try{if(i=s(r),i<0)throw nh(new Error("invalid message length"),"ERR_INVALID_MSG_LENGTH");if(i>a)throw nh(new Error("message length too long"),"ERR_MSG_DATA_TOO_LONG");const e=s.bytes;r.consume(e),null!=t?.onLength&&t.onLength(i),n=ih.DATA}catch(e){if(e instanceof RangeError){if(r.byteLength>o)throw nh(new Error("message length length too long"),"ERR_MSG_LENGTH_TOO_LONG");break}throw e}if(n===ih.DATA){if(r.byteLength<i)break;const e=r.sublist(0,i);r.consume(i),null!=t?.onData&&t.onData(e),yield e,n=ih.LENGTH}}}return eh(e)?async function*(){for await(const t of e)r.append(t),yield*c();if(r.byteLength>0)throw nh(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}():function*(){for(const t of e)r.append(t),yield*c();if(r.byteLength>0)throw nh(new Error("unexpected end of input"),"ERR_UNEXPECTED_EOF")}()}function ah(){const e={};return e.promise=new Promise(((t,r)=>{e.resolve=t,e.reject=r})),e}sh.bytes=0,oh.fromReader=(e,t)=>{let r=1;return oh(async function*(){for(;;)try{const{done:t,value:n}=await e.next(r);if(!0===t)return;null!=n&&(yield n)}catch(t){if("ERR_UNDER_READ"===t.code)return{done:!0,value:null};throw t}finally{r=1}}(),{...t??{},onLength:e=>{r=e}})};class ch{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||0!==(e-1&e))throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return void 0===this.buffer[this.top]&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){const e=this.buffer[this.btm];if(void 0!==e)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return void 0===this.buffer[this.btm]}}class uh{size;hwm;head;tail;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.hwm=e.splitLimit??16,this.head=new ch(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return null!=e?.byteLength?e.byteLength:1}push(e){if(null!=e?.value&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){const t=this.head;this.head=t.next=new ch(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(void 0===e&&null!=this.tail.next){const t=this.tail.next;this.tail.next=null,this.tail=t,e=this.tail.shift()}return null!=e?.value&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}}class lh extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function hh(){return dh((e=>{const t=e.shift();if(null==t)return{done:!0};if(null!=t.error)throw t.error;return{done:!0===t.done,value:t.value}}),arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}function dh(e,t){let r,n,i,s=(t=t??{}).onEnd,o=new uh,a=ah();const c=e=>null!=n?n(e):(o.push(e),r),u=e=>{if(i)return r;if(!0!==t?.objectMode&&null==e?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return c({done:!1,value:e})},l=e=>i?r:(i=!0,null!=e?(e=>(o=new uh,null!=n?n({error:e}):(o.push({error:e}),r)))(e):c({done:!0}));if(r={[Symbol.asyncIterator](){return this},next:async()=>{try{return o.isEmpty()?i?{done:!0}:await new Promise(((t,i)=>{n=s=>{n=null,o.push(s);try{t(e(o))}catch(a){i(a)}return r}})):e(o)}finally{o.isEmpty()&&queueMicrotask((()=>{a.resolve(),a=ah()}))}},return:()=>(o=new uh,l(),{done:!0}),throw:e=>(l(e),{done:!0}),push:u,end:l,get readableLength(){return o.size},onEmpty:async e=>{const t=e?.signal;if(t?.throwIfAborted(),o.isEmpty())return;let r,n;null!=t&&(r=new Promise(((e,r)=>{n=()=>{r(new lh)},t.addEventListener("abort",n)})));try{await Promise.race([a.promise,r])}finally{null!=n&&null!=t&&t?.removeEventListener("abort",n)}}},null==s)return r;const h=r;return r={[Symbol.asyncIterator](){return this},next:()=>h.next(),throw:e=>(h.throw(e),null!=s&&(s(e),s=void 0),{done:!0}),return:()=>(h.return(),null!=s&&(s(),s=void 0),{done:!0}),push:u,end:e=>(h.end(e),null!=s&&(s(e),s=void 0),r),get readableLength(){return h.readableLength},onEmpty:e=>h.onEmpty(e)},r}const fh=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const n=[];for(const i of t)null==i[Symbol.asyncIterator]&&n.push(i);return n.length===t.length?function*(){for(const e of n)yield*e}():async function*(){const e=hh({objectMode:!0});Promise.resolve().then((async()=>{try{await Promise.all(t.map((async t=>{for await(const r of t)e.push(r)}))),e.end()}catch(r){e.end(r)}})),yield*e}()};function ph(e){if(null==e)throw new Error("Empty pipeline");if(mh(e)){const t=e;e=()=>t.source}else if(yh(e)||bh(e)){const t=e;e=()=>t}for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];const i=[e,...r];if(i.length>1&&mh(i[i.length-1])&&(i[i.length-1]=i[i.length-1].sink),i.length>2)for(let s=1;s<i.length-1;s++)mh(i[s])&&(i[s]=wh(i[s]));return gh(...i)}const gh=function(){let e;for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];for(;r.length>0;)e=r.shift()(e);return e},bh=e=>null!=e?.[Symbol.asyncIterator],yh=e=>null!=e?.[Symbol.iterator],mh=e=>null!=e&&(null!=e.sink&&null!=e.source),wh=e=>t=>{const r=e.sink(t);if(null!=r?.then){const t=hh({objectMode:!0});let n;r.then((()=>{t.end()}),(e=>{t.end(e)}));const i=e.source;if(bh(i))n=async function*(){yield*i,t.end()};else{if(!yh(i))throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");n=function*(){yield*i,t.end()}}return fh(t,n())}return e.source};class vh{multicodec;getConnections;addEventListener;streamPool;log;constructor(e,t,r){this.multicodec=e,this.getConnections=t,this.addEventListener=r,this.log=new Ll(`stream-manager:${e}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool.bind(this)),this.getStream=this.getStream.bind(this),this.streamPool=new Map}async getStream(e){const t=e.id.toString(),r=this.streamPool.get(t);if(!r)return this.newStream(e);this.streamPool.delete(t),this.prepareNewStream(e);const n=await r;return n&&"closed"!==n.status?n:this.newStream(e)}async newStream(e){const t=function(e){if(!e.length)return;if(1===e.length)return e[0];let t;return e.forEach((e=>{"open"===e.status&&(t?e.timeline.open>t.timeline.open&&(t=e):t=e)})),t}(this.getConnections(e.id));if(!t)throw new Error("Failed to get a connection to the peer");return t.newStream(this.multicodec)}prepareNewStream(e){const t=this.newStream(e).catch((()=>{this.log.error(`Failed to prepare a new stream for ${e.id.toString()}`)}));this.streamPool.set(e.id.toString(),t)}handlePeerUpdateStreamPool=e=>{const t=e.detail.peer;t.protocols.includes(this.multicodec)&&(this.log.info(`Preemptively opening a stream to ${t.id.toString()}`),this.prepareNewStream(t))}}class _h{multicodec;components;log;pubsubTopics;options;addLibp2pEventListener;removeLibp2pEventListener;streamManager;constructor(e,t,r,n,i){this.multicodec=e,this.components=t,this.log=r,this.pubsubTopics=n,this.options=i,this.addLibp2pEventListener=t.events.addEventListener.bind(t.events),this.removeLibp2pEventListener=t.events.removeEventListener.bind(t.events),this.streamManager=new vh(e,t.connectionManager.getConnections.bind(t.connectionManager),this.addLibp2pEventListener)}async getStream(e){return this.streamManager.getStream(e)}get peerStore(){return this.components.peerStore}async allPeers(){return async function(e,t){const r=[];return await e.forEach((e=>{for(let n=0;n<t.length;n++)if(e.protocols.includes(t[n])){r.push(e);break}})),r}(this.peerStore,[this.multicodec])}async connectedPeers(){return(await this.allPeers()).filter((e=>this.components.connectionManager.getConnections(e.id).length>0))}async getPeers(){let{numPeers:e,maxBootstrapPeers:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{maxBootstrapPeers:1,numPeers:0};const r=await async function(e,t,r,n){const i=e.filter((e=>"open"===e.status)).map((async e=>{const i=await t.get(e.remotePeer);if(r.some((e=>i.protocols.includes(e)))){if(!n)return i;{const e=i.metadata.get("shardInfo"),t=e&&Dl(e);if(t&&n.clusterId===t.clusterId)return i}}return null}));return(await Promise.all(i)).filter((e=>null!==e))}(this.components.connectionManager.getConnections(),this.peerStore,[this.multicodec],this.options?.shardInfo?Pl(this.options.shardInfo).shardInfo:void 0),n=function(e,t,r){let n=e.filter((e=>e.tags.has(qc.BOOTSTRAP))).slice(0,r);t>0&&t<n.length&&(n=n.slice(0,t));const i=e.filter((e=>!e.tags.has(qc.BOOTSTRAP)));if(0===t)return[...n,...i];const s=[...n];for(;s.length<t&&i.length>0;){const e=Math.floor(Math.random()*i.length),t=i.splice(e,1)[0];s.push(t)}return s}(r,e,t),i=await async function(e,t){return 0===t.length?[]:(await Promise.all(t.map((async t=>{try{const r=(await e.get(t.id)).metadata.get("ping");return r?{peer:t,ping:Number(_l(r))}:{peer:t,ping:1/0}}catch(r){return{peer:t,ping:1/0}}})))).filter((e=>null!==e)).sort(((e,t)=>e.ping-t.ping)).map((e=>e.peer))}(this.peerStore,n);return 0===i.length&&this.log.warn("No peers found. Ensure you have a connection to the network."),i.length<e&&this.log.warn(`Only ${i.length} peers found. Requested ${e}.`),i}}const Eh={randomUUID:"undefined"!==typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let Sh;const Ah=new Uint8Array(16);function kh(){if(!Sh&&(Sh="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Sh))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Sh(Ah)}const xh=[];for(let Lpe=0;Lpe<256;++Lpe)xh.push((Lpe+256).toString(16).slice(1));function Ih(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return xh[e[t+0]]+xh[e[t+1]]+xh[e[t+2]]+xh[e[t+3]]+"-"+xh[e[t+4]]+xh[e[t+5]]+"-"+xh[e[t+6]]+xh[e[t+7]]+"-"+xh[e[t+8]]+xh[e[t+9]]+"-"+xh[e[t+10]]+xh[e[t+11]]+xh[e[t+12]]+xh[e[t+13]]+xh[e[t+14]]+xh[e[t+15]]}const Ch=function(e,t,r){if(Eh.randomUUID&&!t&&!e)return Eh.randomUUID();const n=(e=e||{}).random||(e.rng||kh)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return Ih(n)};class Th{proto;constructor(e){this.proto=e}static decode(e){const t=La.decode(e);return new Th(t)}encode(){return La.encode(this.proto)}get wakuMessage(){return this.proto.wakuMessage}get pubsubTopic(){return this.proto.pubsubTopic}}class Rh{proto;constructor(e){this.proto=e}static createSubscribeRequest(e,t){return new Rh({requestId:Ch(),filterSubscribeType:Ba.FilterSubscribeType.SUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeRequest(e,t){return new Rh({requestId:Ch(),filterSubscribeType:Ba.FilterSubscribeType.UNSUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeAllRequest(e){return new Rh({requestId:Ch(),filterSubscribeType:Ba.FilterSubscribeType.UNSUBSCRIBE_ALL,pubsubTopic:e,contentTopics:[]})}static createSubscriberPingRequest(){return new Rh({requestId:Ch(),filterSubscribeType:Ba.FilterSubscribeType.SUBSCRIBER_PING,pubsubTopic:"",contentTopics:[]})}static decode(e){const t=Ba.decode(e);return new Rh(t)}encode(){return Ba.encode(this.proto)}get filterSubscribeType(){return this.proto.filterSubscribeType}get requestId(){return this.proto.requestId}get pubsubTopic(){return this.proto.pubsubTopic}get contentTopics(){return this.proto.contentTopics}}class Ph{proto;constructor(e){this.proto=e}static decode(e){const t=Ua.decode(e);return new Ph(t)}encode(){return Ua.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get requestId(){return this.proto.requestId}}const Dh=new Ll("filter:v2"),Nh="/vac/waku/filter-subscribe/2.0.0-beta1",Bh="/vac/waku/filter-push/2.0.0-beta1";class Uh{peers;pubsubTopic;newStream;receivedMessagesHashStr=[];subscriptionCallbacks;constructor(e,t,r){this.peers=t,this.pubsubTopic=e,this.newStream=r,this.subscriptionCallbacks=new Map}async subscribe(e,t){const r=Array.isArray(e)?e:[e];r.forEach((e=>{if(e.pubsubTopic!==this.pubsubTopic)throw new Error(`Pubsub topic not configured: decoder is configured for pubsub topic ${e.pubsubTopic} but this subscription is for pubsub topic ${this.pubsubTopic}. Please create a new Subscription for the different pubsub topic.`)}));const n=cc(r),i=Array.from(n.keys()),s=this.peers.map((async e=>{const t=await this.newStream(e),r=Rh.createSubscribeRequest(this.pubsubTopic,i);try{const n=await ph([r.encode()],rh,t,oh,(async e=>await Hl(e)));if(!n||!n.length)throw Error(`No response received for request ${r.requestId}: ${n}`);const{statusCode:s,requestId:o,statusDesc:a}=Ph.decode(n[0].slice());if(s<200||s>=300)throw new Error(`Filter subscribe request ${o} failed with status code ${s}: ${a}`);Dh.info("Subscribed to peer ",e.id.toString(),"for content topics",i)}catch(n){throw new Error("Error subscribing to peer: "+e.id.toString()+" for content topics: "+i+": "+n)}})),o=await Promise.allSettled(s);this.handleErrors(o,"subscribe"),n.forEach(((e,r)=>{const n={decoders:e,callback:t};this.subscriptionCallbacks.set(r,n)}))}async unsubscribe(e){const t=this.peers.map((async t=>{const r=await this.newStream(t),n=Rh.createUnsubscribeRequest(this.pubsubTopic,e);try{await ph([n.encode()],rh,r.sink)}catch(i){throw new Error("Error unsubscribing: "+i)}e.forEach((e=>{this.subscriptionCallbacks.delete(e)}))})),r=await Promise.allSettled(t);this.handleErrors(r,"unsubscribe")}async ping(){const e=this.peers.map((async e=>{const t=await this.newStream(e),r=Rh.createSubscriberPingRequest();try{const n=await ph([r.encode()],rh,t,oh,(async e=>await Hl(e)));if(!n||!n.length)throw Error(`No response received for request ${r.requestId}: ${n}`);const{statusCode:i,requestId:s,statusDesc:o}=Ph.decode(n[0].slice());if(i<200||i>=300)throw new Error(`Filter ping request ${s} failed with status code ${i}: ${o}`);Dh.info(`Ping successful for peer ${e.id.toString()}`)}catch(n){throw Dh.error("Error pinging: ",n),n}})),t=await Promise.allSettled(e);this.handleErrors(t,"ping")}async unsubscribeAll(){const e=this.peers.map((async e=>{const t=await this.newStream(e),r=Rh.createUnsubscribeAllRequest(this.pubsubTopic);try{const e=await ph([r.encode()],rh,t,oh,(async e=>await Hl(e)));if(!e||!e.length)throw Error(`No response received for request ${r.requestId}: ${e}`);const{statusCode:n,requestId:i,statusDesc:s}=Ph.decode(e[0].slice());if(n<200||n>=300)throw new Error(`Filter unsubscribe all request ${i} failed with status code ${n}: ${s}`);this.subscriptionCallbacks.clear(),Dh.info(`Unsubscribed from all content topics for pubsub topic ${this.pubsubTopic}`)}catch(n){throw new Error("Error unsubscribing from all content topics: "+n)}})),t=await Promise.allSettled(e);this.handleErrors(t,"unsubscribeAll")}async processMessage(e){const t=$l(this.pubsubTopic,e);if(this.receivedMessagesHashStr.includes(t))return void Dh.info("Message already received, skipping");this.receivedMessagesHashStr.push(t);const{contentTopic:r}=e,n=this.subscriptionCallbacks.get(r);n?(Dh.info("Processing message with content topic ",r," on pubsub topic ",this.pubsubTopic),await async function(e,t,r){const{decoders:n,callback:i}=e,{contentTopic:s}=r;if(!s)return void Dh.warn("Message has no content topic, skipping");try{const e=n.map((e=>e.fromProtoObj(t,r).then((e=>e||Promise.reject("Decoding failed"))))),s=await Promise.any(e);await i(s)}catch(o){Dh.error("Error decoding message",o)}}(n,this.pubsubTopic,e)):Dh.error("No subscription callback available for ",r)}handleErrors(e,t){const r=e.filter((e=>"rejected"===e.status)).map((e=>e.reason));if(r.length===this.peers.length){const e=new Map;r.forEach((t=>{const r=t instanceof Error?t.message:String(t);e.set(r,(e.get(r)||0)+1)}));const n=Array.from(e,(e=>{let[t,r]=e;return`${t} (occurred ${r} times)`})).join(", ");throw new Error(`Error ${t} all peers: ${n}`)}r.length>0?Dh.warn(`Some ${t} failed. These will be refreshed with new peers`,r):Dh.info(`${t} successful for all peers`)}}class Lh extends _h{activeSubscriptions=new Map;getActiveSubscription(e){return this.activeSubscriptions.get(e)}setActiveSubscription(e,t){return this.activeSubscriptions.set(e,t),t}numPeersToUse;constructor(e,t){super(Nh,e.components,Dh,t.pubsubTopics,t),this.numPeersToUse=t?.numPeersToUse??3,e.handle(Bh,this.onRequest.bind(this)).catch((e=>{Dh.error("Failed to register ",Bh,e)})),this.activeSubscriptions=new Map}async createSubscription(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Vc;const t="string"==typeof e?e:Al(e);Il(t,this.pubsubTopics);const r=await this.getPeers({maxBootstrapPeers:1,numPeers:this.numPeersToUse});if(0===r.length)throw new Error("No peer found to initiate subscription.");Dh.info(`Creating filter subscription with ${r.length} peers: `,r.map((e=>e.id.toString())));return this.getActiveSubscription(t)??this.setActiveSubscription(t,new Uh(t,r,this.getStream.bind(this)))}toSubscriptionIterator(e){return uc(this,e)}async subscribe(e,t){const r=await this.createSubscription();await r.subscribe(e,t);const n=Array.from(cc(Array.isArray(e)?e:[e]).keys());return async()=>{await r.unsubscribe(n)}}onRequest(e){const{connection:t,stream:r}=e,{remotePeer:n}=t;Dh.info(`Received message from ${n.toString()}`);try{ph(r,oh,(async e=>{for await(const t of e){const e=Th.decode(t.slice()),{pubsubTopic:r,wakuMessage:n}=e;if(!n)return void Dh.error("Received empty message");if(!r)return void Dh.error("Pubsub topic missing from push message");const i=this.getActiveSubscription(r);if(!i)return void Dh.error(`No subscription locally registered for topic ${r}`);await i.processMessage(n)}})).then((()=>{Dh.info("Receiving pipe closed.")}),(e=>{Dh.error("Error with receiving pipe",e)}))}catch(i){Dh.error("Error decoding message",i)}}}class Mh{proto;constructor(e){this.proto=e}static createRequest(e,t){return new Mh({requestId:Ch(),request:{message:e,pubsubTopic:t},response:void 0})}static decode(e){const t=Fa.decode(e);return new Mh(t)}encode(){return Fa.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const Oh=new Ll("light-push");class qh extends _h{constructor(e,t){super("/vac/waku/lightpush/2.0.0-beta1",e.components,Oh,t.pubsubTopics,t)}async preparePushMessage(e,t){try{if(!t.payload||0===t.payload.length)return Oh.error("Failed to send waku light push: payload is empty"),{query:null,error:Mc.EMPTY_PAYLOAD};if(!await async function(e,t){const r=await e.toWire(t);return!!r&&hc(r)}(e,t))return Oh.error("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:Mc.SIZE_TOO_BIG};const r=await e.toProtoObj(t);if(!r)return Oh.error("Failed to encode to protoMessage, aborting push"),{query:null,error:Mc.ENCODE_FAILED};return{query:Mh.createRequest(r,e.pubsubTopic),error:null}}catch(r){return Oh.error("Failed to prepare push message",r),{query:null,error:Mc.GENERIC_FAIL}}}async send(e,t,r){const{query:n,error:i}=await this.preparePushMessage(e,t);if(i||!n)return{success:null,failure:{error:i,peerId:r.id}};let s,o;try{s=await this.getStream(r)}catch(u){return Oh.error(`Failed to get a stream for remote peer${r.id.toString()}`,u),{success:null,failure:{error:Mc.REMOTE_PEER_FAULT,peerId:r.id}}}try{o=await ph([n.encode()],rh,s,oh,(async e=>await Hl(e)))}catch(u){return Oh.error("Failed to send waku light push request",u),{success:null,failure:{error:Mc.GENERIC_FAIL,peerId:r.id}}}const a=new Zl;let c;o.forEach((e=>{a.append(e)}));try{c=Mh.decode(a).response}catch(u){return Oh.error("Failed to decode push reply",u),{success:null,failure:{error:Mc.DECODE_FAILED,peerId:r.id}}}return c?c.isSuccess?{success:r.id,failure:null}:(Oh.error("Remote peer rejected the message: ",c.info),{success:null,failure:{error:Mc.REMOTE_PEER_REJECTED,peerId:r.id}}):(Oh.error("Remote peer fault: No response in PushRPC"),{success:null,failure:{error:Mc.REMOTE_PEER_FAULT,peerId:r.id}})}}const Kh={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};const Fh=BigInt(1e6);var Vh;!function(e){e.BACKWARD="backward",e.FORWARD="forward"}(Vh||(Vh={}));class zh{proto;constructor(e){this.proto=e}get query(){return this.proto.query}get response(){return this.proto.response}static createQuery(e){const t=e.contentTopics.map((e=>({contentTopic:e}))),r=function(e){switch(e){case Vh.BACKWARD:return Ha.Direction.BACKWARD;case Vh.FORWARD:return Ha.Direction.FORWARD;default:return Ha.Direction.BACKWARD}}(e.pageDirection),n={pageSize:BigInt(e.pageSize),cursor:e.cursor,direction:r};let i,s;return e.startTime&&(i=BigInt(e.startTime.valueOf())*Fh),e.endTime&&(s=BigInt(e.endTime.valueOf())*Fh),new zh({requestId:Ch(),query:{pubsubTopic:e.pubsubTopic,contentFilters:t,pagingInfo:n,startTime:i,endTime:s},response:void 0})}decode(e){const t=Ya.decode(e);return new zh(t)}encode(){return Ya.encode(this.proto)}}var $h=Wa.HistoryError;const Hh=new Ll("store");class jh extends _h{constructor(e,t){super("/vac/waku/store/2.0.0-beta4",e.components,Hh,t.pubsubTopics,t)}async*queryPerPage(e,t,r){if(e.contentTopics.toString()!==Array.from(t.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let n=e.cursor;for(;;){e.cursor=n;const i=zh.createQuery(e),s=await this.getStream(r),o=await ph([i.encode()],rh,s,oh,(async e=>await Hl(e))),a=new Zl;o.forEach((e=>{a.append(e)}));const c=i.decode(a);if(!c.response){Hh.warn("Stopping pagination due to store `response` field missing");break}const u=c.response;if(u.error&&u.error!==$h.NONE)throw"History response contains an Error: "+u.error;if(!u.messages||!u.messages.length){Hh.warn("Stopping pagination due to store `response.messages` field missing or empty");break}Hh.error(`${u.messages.length} messages retrieved from store`),yield u.messages.map((r=>{const n=r.contentTopic;if("undefined"!==typeof n){const s=t.get(n);if(s)return s.fromProtoObj(e.pubsubTopic,(i=r,{...Kh,...i}))}var i;return Promise.resolve(void 0)}));const l=u.pagingInfo?.cursor;if("undefined"===typeof l){Hh.warn("Stopping pagination due to `response.pagingInfo.cursor` missing from store response");break}n=l;const h=u.pagingInfo?.pageSize,d=i.query?.pagingInfo?.pageSize;if(h&&d&&h<d)break}}}class Gh extends Error{constructor(e){super(e),this.name="TimeoutError"}}class Wh extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Yh=e=>void 0===globalThis.DOMException?new Wh(e):new DOMException(e),Qh=e=>{const t=void 0===e.reason?Yh("This operation was aborted."):e.reason;return t instanceof Error?t:Yh(t)};function Jh(e,t){const{milliseconds:r,fallback:n,message:i,customTimers:s={setTimeout:setTimeout,clearTimeout:clearTimeout}}=t;let o;const a=new Promise(((a,c)=>{if("number"!==typeof r||1!==Math.sign(r))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${r}\``);if(t.signal){const{signal:e}=t;e.aborted&&c(Qh(e)),e.addEventListener("abort",(()=>{c(Qh(e))}))}if(r===Number.POSITIVE_INFINITY)return void e.then(a,c);const u=new Gh;o=s.setTimeout.call(void 0,(()=>{if(n)try{a(n())}catch(t){c(t)}else"function"===typeof e.cancel&&e.cancel(),!1===i?a():i instanceof Error?c(i):(u.message=i??`Promise timed out after ${r} milliseconds`,c(u))}),r),(async()=>{try{a(await e)}catch(t){c(t)}})()})).finally((()=>{a.clear()}));return a.clear=()=>{s.clearTimeout.call(void 0,o),o=void 0},a}const Xh=e=>{const t=e.addEventListener||e.on||e.addListener,r=e.removeEventListener||e.off||e.removeListener;if(!t||!r)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:r.bind(e)}};function Zh(e,t,r){"function"===typeof r&&(r={filter:r});const n=function(e,t,r){let n;const i=new Promise(((i,s)=>{if(!((r={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...r}).count>=0)||r.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(r.count))throw new TypeError("The `count` option should be at least 0 or more");r.signal?.throwIfAborted();const o=[t].flat(),a=[],{addListener:c,removeListener:u}=Xh(e),l=function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];const o=r.multiArgs?t:t[0];r.filter&&!r.filter(o)||(a.push(o),r.count===a.length&&(n(),i(a)))},h=e=>{n(),s(e)};n=()=>{for(const e of o)u(e,l);for(const e of r.rejectionEvents)u(e,h)};for(const e of o)c(e,l);for(const e of r.rejectionEvents)c(e,h);r.signal&&r.signal.addEventListener("abort",(()=>{h(r.signal.reason)}),{once:!0}),r.resolveImmediately&&i(a)}));if(i.cancel=n,"number"===typeof r.timeout){const e=Jh(i,{milliseconds:r.timeout});return e.cancel=n,e}return i}(e,t,r={...r,count:1,resolveImmediately:!1}),i=n.then((e=>e[0]));return i.cancel=n.cancel,i}const ed=new Ll("wait-for-remote-peer");async function td(e,t,r){if(t=t??function(e){const t=[];e.relay&&t.push(Lc.Relay);e.filter&&t.push(Lc.Filter);e.store&&t.push(Lc.Store);e.lightPush&&t.push(Lc.LightPush);return t}(e),!e.isStarted())return Promise.reject("Waku node is not started");const n=[];if(t.includes(Lc.Relay)){if(!e.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");n.push(async function(e){let t=e.getMeshPeers();const r=e.pubsubTopics;for(const n of r)for(;0==t.length;)await Zh(e.gossipSub,"gossipsub:heartbeat"),t=e.getMeshPeers(n)}(e.relay))}if(t.includes(Lc.Store)){if(!e.store)throw new Error("Cannot wait for Store peer: protocol not mounted");n.push(rd(e.store.protocol,e.libp2p.services.metadata))}if(t.includes(Lc.LightPush)){if(!e.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");n.push(rd(e.lightPush.protocol,e.libp2p.services.metadata))}if(t.includes(Lc.Filter)){if(!e.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");n.push(rd(e.filter,e.libp2p.services.metadata))}r?await async function(e,t,r){await Promise.race([e,nd(t,r)])}(Promise.all(n),r,"Timed out waiting for a remote peer."):await Promise.all(n)}async function rd(e,t){const r=e.multicodec,n=await e.connectedPeers();if(n.length){if(!t)return void ed.info(`${r} peer found: `,n[0].id.toString());try{return void await Promise.any(n.map((e=>t.confirmOrAttemptHandshake(e.id))))}catch(i){"ERR_CONNECTION_BEING_CLOSED"===i.code&&ed.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${i}`),ed.error(`Error waiting for handshake confirmation: ${i}`)}}ed.info(`Waiting for ${r} peer`),await new Promise((n=>{const i=s=>{s.detail?.protocols?.includes(r)&&(t?t.confirmOrAttemptHandshake(s.detail.peerId).then((()=>{e.removeLibp2pEventListener("peer:identify",i),n()})).catch((e=>{"ERR_CONNECTION_BEING_CLOSED"===e.code&&ed.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${e}`),ed.error(`Error waiting for handshake confirmation: ${e}`)})):(e.removeLibp2pEventListener("peer:identify",i),n()))};e.addLibp2pEventListener("peer:identify",i)}))}const nd=(e,t)=>new Promise(((r,n)=>setTimeout((()=>n(t)),e)));const id=function(e){try{for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n]}catch{}};class sd extends EventTarget{#e=new Map;constructor(){super(),id(1/0,this)}listenerCount(e){const t=this.#e.get(e);return null==t?0:t.length}addEventListener(e,t,r){super.addEventListener(e,t,r);let n=this.#e.get(e);null==n&&(n=[],this.#e.set(e,n)),n.push({callback:t,once:(!0!==r&&!1!==r&&r?.once)??!1})}removeEventListener(e,t,r){super.removeEventListener(e.toString(),t??null,r);let n=this.#e.get(e);null!=n&&(n=n.filter((e=>{let{callback:r}=e;return r!==t})),this.#e.set(e,n))}dispatchEvent(e){const t=super.dispatchEvent(e);let r=this.#e.get(e.type);return null==r||(r=r.filter((e=>{let{once:t}=e;return!t})),this.#e.set(e.type,r)),t}safeDispatchEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.dispatchEvent(new ad(e,t))}}class od extends Event{detail;constructor(e,t){super(e,t),this.detail=t?.detail}}const ad=globalThis.CustomEvent??od,cd=new Ll("keep-alive");class ud{pingKeepAliveTimers;relayKeepAliveTimers;options;relay;constructor(e,t){this.pingKeepAliveTimers=new Map,this.relayKeepAliveTimers=new Map,this.options=e,this.relay=t}start(e,t,r){this.stop(e);const{pingKeepAlive:n,relayKeepAlive:i}=this.options,s=e.toString();if(0!==n){const i=setInterval((()=>{(async()=>{let i;try{try{i=await t.ping(e),cd.info(`Ping succeeded (${s})`,i)}catch(o){return void cd.error(`Ping failed for peer (${s}).\n Next ping will be attempted in ${n} seconds.\n `)}try{await r.patch(e,{metadata:{ping:El(i.toString())}})}catch(a){cd.error("Failed to update ping",a)}}catch(a){cd.error(`Ping failed (${s})`,a)}})()}),1e3*n);this.pingKeepAliveTimers.set(s,i)}const o=this.relay;if(o&&0!==i){const t=this.scheduleRelayPings(o,i,e.toString());this.relayKeepAliveTimers.set(e,t)}}stop(e){const t=e.toString();this.pingKeepAliveTimers.has(t)&&(clearInterval(this.pingKeepAliveTimers.get(t)),this.pingKeepAliveTimers.delete(t)),this.relayKeepAliveTimers.has(e)&&(this.relayKeepAliveTimers.get(e)?.map(clearInterval),this.relayKeepAliveTimers.delete(e))}stopAll(){for(const e of[...Object.values(this.pingKeepAliveTimers),...Object.values(this.relayKeepAliveTimers)])clearInterval(e);this.pingKeepAliveTimers.clear(),this.relayKeepAliveTimers.clear()}connectionsExist(){return this.pingKeepAliveTimers.size>0||this.relayKeepAliveTimers.size>0}scheduleRelayPings(e,t,r){const n=[];for(const i of e.pubsubTopics){if(!e.getMeshPeers(i).includes(r))continue;const s=Fl({pubsubTopicShardInfo:xl(i),contentTopic:"/relay-ping/1/ping/null",ephemeral:!0}),o=setInterval((()=>{cd.info("Sending Waku Relay ping message"),e.send(s,{payload:new Uint8Array([1])}).catch((e=>cd.error("Failed to send relay ping",e)))}),1e3*t);n.push(o)}return n}}const ld=new Ll("connection-manager");class hd extends sd{configuredPubsubTopics;static instances=new Map;keepAliveManager;options;libp2p;dialAttemptsForPeer=new Map;dialErrorsForPeer=new Map;currentActiveParallelDialCount=0;pendingPeerDialQueue=[];online=!1;isConnected(){return this.online}toggleOnline(){this.online||(this.online=!0,this.dispatchEvent(new ad(Fc.CONNECTION_STATUS,{detail:this.online})))}toggleOffline(){this.online&&0==this.libp2p.getConnections().length&&(this.online=!1,this.dispatchEvent(new ad(Fc.CONNECTION_STATUS,{detail:this.online})))}static create(e,t,r,n,i,s){let o=hd.instances.get(e);return o||(o=new hd(t,r,n,i,s),hd.instances.set(e,o)),o}async getPeersByDiscovery(){const e=await this.libp2p.peerStore.all(),t=this.libp2p.getConnections().map((e=>e.remotePeer)),r=[],n=[],i=[],s=[],o=[],a=[];for(const c of e){const e=await this.getTagNamesForPeer(c.id);e.includes(qc.BOOTSTRAP)?r.push(c):e.includes(qc.PEER_EXCHANGE)?n.push(c):e.includes(qc.LOCAL)&&i.push(c)}for(const c of t){const e=await this.libp2p.peerStore.get(c),t=await this.getTagNamesForPeer(c);t.includes(qc.BOOTSTRAP)?s.push(e):t.includes(qc.PEER_EXCHANGE)?o.push(e):t.includes(qc.LOCAL)&&a.push(e)}return{DISCOVERED:{[qc.BOOTSTRAP]:r,[qc.PEER_EXCHANGE]:n,[qc.LOCAL]:i},CONNECTED:{[qc.BOOTSTRAP]:s,[qc.PEER_EXCHANGE]:o,[qc.LOCAL]:a}}}constructor(e,t,r,n,i){super(),this.configuredPubsubTopics=r,this.libp2p=e,this.configuredPubsubTopics=r,this.options={maxDialAttemptsForPeer:3,maxBootstrapPeersAllowed:1,maxParallelDials:3,...i},this.keepAliveManager=new ud(t,n),this.run().then((()=>ld.info("Connection Manager is now running"))).catch((e=>ld.error("Unexpected error while running service",e))),this.dialPeerStorePeers().catch((e=>ld.error("Unexpected error while dialing peer store peers",e)))}async dialPeerStorePeers(){const e=await this.libp2p.peerStore.all(),t=[];for(const n of e)this.libp2p.getConnections().find((e=>e.remotePeer===n.id))||t.push(this.attemptDial(n.id));try{await Promise.all(t)}catch(r){ld.error("Unexpected error while dialing peer store peers",r)}}async run(){this.startPeerDiscoveryListener(),this.startPeerConnectionListener(),this.startPeerDisconnectionListener()}stop(){this.keepAliveManager.stopAll(),this.libp2p.removeEventListener("peer:connect",this.onEventHandlers["peer:connect"]),this.libp2p.removeEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"]),this.libp2p.removeEventListener("peer:discovery",this.onEventHandlers["peer:discovery"])}async dialPeer(e){this.currentActiveParallelDialCount+=1;let t=0;for(;t<this.options.maxDialAttemptsForPeer;)try{ld.info(`Dialing peer ${e.toString()} on attempt ${t+1}`),await this.libp2p.dial(e);const r=await this.getTagNamesForPeer(e);this.libp2p.getConnections(e).forEach((e=>{e.tags=Array.from(new Set([...e.tags,...r]))})),this.dialAttemptsForPeer.set(e.toString(),-1);break}catch(r){r instanceof AggregateError?ld.error(`Error dialing peer ${e.toString()} - ${r.errors}`):ld.error(`Error dialing peer ${e.toString()} - ${r.message}`),this.dialErrorsForPeer.set(e.toString(),r),t++,this.dialAttemptsForPeer.set(e.toString(),t)}if(this.currentActiveParallelDialCount--,this.processDialQueue(),t===this.options.maxDialAttemptsForPeer)try{const t=this.dialErrorsForPeer.get(e.toString());if(t){let r;t instanceof AggregateError?t.errors?0===t.errors.length?ld.warn("Errors array is empty for AggregateError"):r=JSON.stringify(t.errors[0]):ld.warn("No errors array found for AggregateError"):r=t.message,ld.info(`Deleting undialable peer ${e.toString()} from peer store. Reason: ${r}`)}this.dialErrorsForPeer.delete(e.toString()),await this.libp2p.peerStore.delete(e)}catch(r){throw new Error(`Error deleting undialable peer ${e.toString()} from peer store - ${r}`)}}async dropConnection(e){try{this.keepAliveManager.stop(e),await this.libp2p.hangUp(e),ld.info(`Dropped connection with peer ${e.toString()}`)}catch(t){ld.error(`Error dropping connection with peer ${e.toString()} - ${t}`)}}processDialQueue(){if(this.pendingPeerDialQueue.length>0&&this.currentActiveParallelDialCount<this.options.maxParallelDials){const e=this.pendingPeerDialQueue.shift();if(!e)return;this.attemptDial(e).catch((e=>{ld.error(e)}))}}startPeerDiscoveryListener(){this.libp2p.addEventListener("peer:discovery",this.onEventHandlers["peer:discovery"])}startPeerConnectionListener(){this.libp2p.addEventListener("peer:connect",this.onEventHandlers["peer:connect"])}startPeerDisconnectionListener(){this.libp2p.addEventListener("peer:disconnect",this.onEventHandlers["peer:disconnect"])}async attemptDial(e){await this.shouldDialPeer(e)&&(this.currentActiveParallelDialCount>=this.options.maxParallelDials?this.pendingPeerDialQueue.push(e):this.dialPeer(e).catch((t=>{ld.error(`Error dialing peer ${e.toString()} : ${t}`)})))}onEventHandlers={"peer:discovery":e=>{(async()=>{const{id:t}=e.detail;await this.dispatchDiscoveryEvent(t);try{await this.attemptDial(t)}catch(r){ld.error(`Error dialing peer ${t.toString()} : ${r}`)}})()},"peer:connect":e=>{(async()=>{ld.info(`Connected to peer ${e.detail.toString()}`);const t=e.detail;this.keepAliveManager.start(t,this.libp2p.services.ping,this.libp2p.peerStore);if((await this.getTagNamesForPeer(t)).includes(qc.BOOTSTRAP)){this.libp2p.getConnections().filter((e=>e.tags.includes(qc.BOOTSTRAP))).length>this.options.maxBootstrapPeersAllowed?await this.dropConnection(t):this.dispatchEvent(new ad(Kc.PEER_CONNECT_BOOTSTRAP,{detail:t}))}else this.dispatchEvent(new ad(Kc.PEER_CONNECT_PEER_EXCHANGE,{detail:t}));this.toggleOnline()})()},"peer:disconnect":e=>{(async()=>{this.keepAliveManager.stop(e.detail),this.toggleOffline()})()}};async shouldDialPeer(e){if(this.libp2p.getConnections(e).length>0)return ld.warn(`Already connected to peer ${e.toString()}. Not dialing.`),!1;if(!await this.isPeerTopicConfigured(e)){const t=await this.getPeerShardInfo(e,this.libp2p.peerStore);return ld.warn(`Discovered peer ${e.toString()} with ShardInfo ${t} is not part of any of the configured pubsub topics (${this.configuredPubsubTopics}).\n Not dialing.`),!1}return await this.isPeerDialableBasedOnBootstrapStatus(e)?!this.dialAttemptsForPeer.has(e.toString())||(ld.warn(`Peer ${e.toString()} has already been attempted dial before, or already has a dial attempt in progress, skipping dial`),!1):(ld.warn(`Peer ${e.toString()} is not dialable based on bootstrap status. Not dialing.`),!1)}async isPeerDialableBasedOnBootstrapStatus(e){if(!(await this.getTagNamesForPeer(e)).some((e=>e===qc.BOOTSTRAP)))return!0;if(this.libp2p.getConnections().filter((e=>e.tags.find((e=>e===qc.BOOTSTRAP)))).length<this.options.maxBootstrapPeersAllowed)return!0;return!1}async dispatchDiscoveryEvent(e){const t=(await this.getTagNamesForPeer(e)).includes(qc.BOOTSTRAP);this.dispatchEvent(new ad(t?Kc.PEER_DISCOVERY_BOOTSTRAP:Kc.PEER_DISCOVERY_PEER_EXCHANGE,{detail:e}))}async getTagNamesForPeer(e){try{const t=await this.libp2p.peerStore.get(e);return Array.from(t.tags.keys())}catch(t){return ld.error(`Failed to get peer ${e}, error: ${t}`),[]}}async isPeerTopicConfigured(e){const t=await this.getPeerShardInfo(e,this.libp2p.peerStore);if(!t)return!0;return kl(t).some((e=>this.configuredPubsubTopics.includes(e)))}async getPeerShardInfo(e,t){const r=(await t.get(e)).metadata.get("shardInfo");if(r)return Dl(r)}}const dd=new Ll("metadata"),fd="/vac/waku/metadata/1.0.0";class pd extends _h{shardInfo;libp2pComponents;handshakesConfirmed=new Map;constructor(e,t){super(fd,t.components,dd,kl(e)),this.shardInfo=e,this.libp2pComponents=t,t.registrar.handle(fd,(e=>{this.onRequest(e)}))}async onRequest(e){try{const{stream:t,connection:r}=e,n=nc.encode(this.shardInfo),i=await ph([n],rh,t,oh,(async e=>await Hl(e))),{error:s,shardInfo:o}=this.decodeMetadataResponse(i);if(s)return;await this.savePeerShardInfo(r.remotePeer,o)}catch(t){dd.error("Error handling metadata request",t)}}async query(e){const t=rc.encode(this.shardInfo),r=await this.peerStore.get(e);if(!r)return{shardInfo:null,error:Mc.NO_PEER_AVAILABLE};const n=await this.getStream(r),i=await ph([t],rh,n,oh,(async e=>await Hl(e))),{error:s,shardInfo:o}=this.decodeMetadataResponse(i);return s?{shardInfo:null,error:s}:(await this.savePeerShardInfo(e,o),{shardInfo:o,error:null})}async confirmOrAttemptHandshake(e){const t=this.handshakesConfirmed.get(e.toString());return t?{shardInfo:t,error:null}:await this.query(e)}decodeMetadataResponse(e){const t=new Zl;e.forEach((e=>{t.append(e)}));const r=nc.decode(t);return r?{shardInfo:r,error:null}:(dd.error("Error decoding metadata response"),{shardInfo:null,error:Mc.DECODE_FAILED})}async savePeerShardInfo(e,t){await this.libp2pComponents.peerStore.merge(e,{metadata:{shardInfo:Nl(t)}}),this.handshakesConfirmed.set(e.toString(),t)}}function gd(e){return t=>new pd(e,t)}class bd extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=t??"ABORT_ERR"}}async function yd(e,t,r){if(null==t)return e;if(t.aborted)return Promise.reject(new bd(r?.errorMessage,r?.errorCode));let n;const i=new bd(r?.errorMessage,r?.errorCode);try{return await Promise.race([e,new Promise(((e,r)=>{n=()=>{r(i)},t.addEventListener("abort",n)}))])}finally{null!=n&&t.removeEventListener("abort",n)}}class md{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=ah(),this.haveNext=ah()}[Symbol.asyncIterator](){return this}async next(){if(null==this.nextResult&&await this.haveNext.promise,null==this.nextResult)throw new Error("HaveNext promise resolved but nextResult was undefined");const e=this.nextResult;return this.nextResult=void 0,this.readNext.resolve(),this.readNext=ah(),e}async throw(e){this.ended=!0,null!=e&&this.haveNext.reject(e);return{done:!0,value:void 0}}async return(){const e={done:!0,value:void 0};return await this._push(void 0),e}async push(e,t){await this._push(e,t)}async end(e,t){null!=e?await this.throw(e):await this._push(void 0,t)}async _push(e,t){if(null!=e&&this.ended)throw new Error("Cannot push value onto an ended pushable");if(null!=this.nextResult&&(await this.readNext.promise,null!=this.nextResult))throw new Error("NeedNext promise resolved but nextResult was not consumed");null!=e?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=ah(),await yd(this.readNext.promise,t?.signal,t)}}class wd extends Error{code;constructor(e,t){super(e),this.code=t}}class vd extends wd{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted"}}function _d(e,t){const r=new md;e.sink(r).catch((async e=>{await r.end(e)})),e.sink=async e=>{for await(const t of e)await r.push(t);await r.end()};let n=e.source;null!=e.source[Symbol.iterator]?n=e.source[Symbol.iterator]():null!=e.source[Symbol.asyncIterator]&&(n=e.source[Symbol.asyncIterator]());const i=new Zl,s={read:async(e,t)=>{let r;t?.signal?.throwIfAborted();const s=new Promise(((e,n)=>{r=()=>{n(new vd("Read aborted"))},t?.signal?.addEventListener("abort",r)}));try{if(null==e){const{done:e,value:t}=await Promise.race([n.next(),s]);return!0===e?new Zl:t}for(;i.byteLength<e;){const{value:e,done:t}=await Promise.race([n.next(),s]);if(!0===t)throw new wd("unexpected end of input","ERR_UNEXPECTED_EOF");i.append(e)}const t=i.sublist(0,e);return i.consume(e),t}finally{null!=r&&t?.signal?.removeEventListener("abort",r)}},write:async(e,t)=>{t?.signal?.throwIfAborted(),e instanceof Uint8Array?await r.push(e,t):await r.push(e.subarray(),t)},unwrap:()=>{if(i.byteLength>0){const r=e.source;e.source=async function*(){!1===t?.yieldBytes?yield i:yield*i,yield*r}()}return e}};return s}class Ed extends Error{code;constructor(e,t){super(e),this.code=t}}function Sd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=_d(e,t);null!=t.maxDataLength&&null==t.maxLengthLength&&(t.maxLengthLength=gs(t.maxDataLength));const n=t?.lengthDecoder??ws,i=t?.lengthEncoder??ms;return{read:async e=>{let i=-1;const s=new Zl;for(;;){s.append(await r.read(1,e));try{i=n(s)}catch(o){if(o instanceof RangeError)continue;throw o}if(null!=t?.maxLengthLength&&s.byteLength>t.maxLengthLength)throw new Ed("message length length too long","ERR_MSG_LENGTH_TOO_LONG");if(i>-1)break}if(null!=t?.maxDataLength&&i>t.maxDataLength)throw new Ed("message length too long","ERR_MSG_DATA_TOO_LONG");return r.read(i,e)},write:async(e,t)=>{await r.write(new Zl(i(e.byteLength),e),t)},writeV:async(e,t)=>{const n=new Zl(...e.flatMap((e=>[i(e.byteLength),e])));await r.write(n,t)},unwrap:()=>r.unwrap()}}function Ad(){const e=ah();let t=!1;return{sink:async r=>{if(t)throw new Error("already piped");t=!0,e.resolve(r)},source:async function*(){const t=await e.promise;yield*t}()}}function kd(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function xd(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}const Id=65535,Cd=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS),Td=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));function Rd(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}const Pd=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function Dd(e){if("string"!==typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function Nd(e){if("string"===typeof e)e=Dd(e);else{if(!Rd(e))throw new Error("expected Uint8Array, got "+typeof e);e=e.slice()}return e}const Bd=e=>"[object Object]"===Object.prototype.toString.call(e)&&e.constructor===Object;function Ud(e,t){if(!Rd(e))throw new Error("Uint8Array expected");if("number"===typeof t&&e.length!==t)throw new Error(`Uint8Array length ${t} expected`)}const Ld=(e,t)=>(Object.assign(t,e),t);function Md(e,t,r,n){if("function"===typeof e.setBigUint64)return e.setBigUint64(t,r,n);const i=BigInt(32),s=BigInt(4294967295),o=Number(r>>i&s),a=Number(r&s),c=n?4:0,u=n?0:4;e.setUint32(t+c,o,n),e.setUint32(t+u,a,n)}function Od(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`wrong positive integer: ${e}`)}function qd(e){if("boolean"!==typeof e)throw new Error(`boolean expected, not ${e}`)}function Kd(e){if(null==(t=e)||"object"!==typeof t||!(t instanceof Uint8Array||"Uint8Array"===t.constructor.name))throw new Error("Uint8Array expected");for(var t,r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];if(n.length>0&&!n.includes(e.length))throw new Error(`Uint8Array expected of length ${n}, not of length=${e.length}`)}function Fd(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Vd(e,t){Kd(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const zd=(e,t)=>255&e[t++]|(255&e[t++])<<8;class $d{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Ud(e=Nd(e),32);const t=zd(e,0),r=zd(e,2),n=zd(e,4),i=zd(e,6),s=zd(e,8),o=zd(e,10),a=zd(e,12),c=zd(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|r<<3),this.r[2]=7939&(r>>>10|n<<6),this.r[3]=8191&(n>>>7|i<<9),this.r[4]=255&(i>>>4|s<<12),this.r[5]=s>>>1&8190,this.r[6]=8191&(s>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let u=0;u<8;u++)this.pad[u]=zd(e,16+2*u)}process(e,t){const r=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?0:2048,{h:n,r:i}=this,s=i[0],o=i[1],a=i[2],c=i[3],u=i[4],l=i[5],h=i[6],d=i[7],f=i[8],p=i[9],g=zd(e,t+0),b=zd(e,t+2),y=zd(e,t+4),m=zd(e,t+6),w=zd(e,t+8),v=zd(e,t+10),_=zd(e,t+12),E=zd(e,t+14);let S=n[0]+(8191&g),A=n[1]+(8191&(g>>>13|b<<3)),k=n[2]+(8191&(b>>>10|y<<6)),x=n[3]+(8191&(y>>>7|m<<9)),I=n[4]+(8191&(m>>>4|w<<12)),C=n[5]+(w>>>1&8191),T=n[6]+(8191&(w>>>14|v<<2)),R=n[7]+(8191&(v>>>11|_<<5)),P=n[8]+(8191&(_>>>8|E<<8)),D=n[9]+(E>>>5|r),N=0,B=N+S*s+A*(5*p)+k*(5*f)+x*(5*d)+I*(5*h);N=B>>>13,B&=8191,B+=C*(5*l)+T*(5*u)+R*(5*c)+P*(5*a)+D*(5*o),N+=B>>>13,B&=8191;let U=N+S*o+A*s+k*(5*p)+x*(5*f)+I*(5*d);N=U>>>13,U&=8191,U+=C*(5*h)+T*(5*l)+R*(5*u)+P*(5*c)+D*(5*a),N+=U>>>13,U&=8191;let L=N+S*a+A*o+k*s+x*(5*p)+I*(5*f);N=L>>>13,L&=8191,L+=C*(5*d)+T*(5*h)+R*(5*l)+P*(5*u)+D*(5*c),N+=L>>>13,L&=8191;let M=N+S*c+A*a+k*o+x*s+I*(5*p);N=M>>>13,M&=8191,M+=C*(5*f)+T*(5*d)+R*(5*h)+P*(5*l)+D*(5*u),N+=M>>>13,M&=8191;let O=N+S*u+A*c+k*a+x*o+I*s;N=O>>>13,O&=8191,O+=C*(5*p)+T*(5*f)+R*(5*d)+P*(5*h)+D*(5*l),N+=O>>>13,O&=8191;let q=N+S*l+A*u+k*c+x*a+I*o;N=q>>>13,q&=8191,q+=C*s+T*(5*p)+R*(5*f)+P*(5*d)+D*(5*h),N+=q>>>13,q&=8191;let K=N+S*h+A*l+k*u+x*c+I*a;N=K>>>13,K&=8191,K+=C*o+T*s+R*(5*p)+P*(5*f)+D*(5*d),N+=K>>>13,K&=8191;let F=N+S*d+A*h+k*l+x*u+I*c;N=F>>>13,F&=8191,F+=C*a+T*o+R*s+P*(5*p)+D*(5*f),N+=F>>>13,F&=8191;let V=N+S*f+A*d+k*h+x*l+I*u;N=V>>>13,V&=8191,V+=C*c+T*a+R*o+P*s+D*(5*p),N+=V>>>13,V&=8191;let z=N+S*p+A*f+k*d+x*h+I*l;N=z>>>13,z&=8191,z+=C*u+T*c+R*a+P*o+D*s,N+=z>>>13,z&=8191,N=(N<<2)+N|0,N=N+B|0,B=8191&N,N>>>=13,U+=N,n[0]=B,n[1]=U,n[2]=L,n[3]=M,n[4]=O,n[5]=q,n[6]=K,n[7]=F,n[8]=V,n[9]=z}finalize(){const{h:e,pad:t}=this,r=new Uint16Array(10);let n=e[1]>>>13;e[1]&=8191;for(let o=2;o<10;o++)e[o]+=n,n=e[o]>>>13,e[o]&=8191;e[0]+=5*n,n=e[0]>>>13,e[0]&=8191,e[1]+=n,n=e[1]>>>13,e[1]&=8191,e[2]+=n,r[0]=e[0]+5,n=r[0]>>>13,r[0]&=8191;for(let o=1;o<10;o++)r[o]=e[o]+n,n=r[o]>>>13,r[o]&=8191;r[9]-=8192;let i=(1^n)-1;for(let o=0;o<10;o++)r[o]&=i;i=~i;for(let o=0;o<10;o++)e[o]=e[o]&i|r[o];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let s=e[0]+t[0];e[0]=65535&s;for(let o=1;o<8;o++)s=(e[o]+t[o]|0)+(s>>>16)|0,e[o]=65535&s}update(e){Fd(this);const{buffer:t,blockLen:r}=this,n=(e=Nd(e)).length;for(let i=0;i<n;){const s=Math.min(r-this.pos,n-i);if(s!==r)t.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0,!1),this.pos=0);else for(;r<=n-i;i+=r)this.process(e,i)}return this}destroy(){this.h.fill(0),this.r.fill(0),this.buffer.fill(0),this.pad.fill(0)}digestInto(e){Fd(this),Vd(e,this),this.finished=!0;const{buffer:t,h:r}=this;let{pos:n}=this;if(n){for(t[n++]=1;n<16;n++)t[n]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let s=0;s<8;s++)e[i++]=r[s]>>>0,e[i++]=r[s]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}}const Hd=function(e){const t=(t,r)=>e(r).update(Nd(t)).digest(),r=e(new Uint8Array(32));return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}((e=>new $d(e))),jd=Dd("expand 16-byte k"),Gd=Dd("expand 32-byte k"),Wd=Td(jd),Yd=Td(Gd);function Qd(e,t){return e<<t|e>>>32-t}function Jd(e){return e.byteOffset%4===0}const Xd=64,Zd=16,ef=2**32-1,tf=new Uint32Array;function rf(e,t){const{allowShortKeys:r,extendNonceFn:n,counterLength:i,counterRight:s,rounds:o}=function(e,t){if(void 0!==t&&("object"!==typeof t||!Bd(t)))throw new Error("options must be object or undefined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!==typeof e)throw new Error("core must be a function");return Od(i),Od(o),qd(s),qd(r),function(t,a,c,u){let l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;Kd(t),Kd(a),Kd(c);const h=c.length;if(u||(u=new Uint8Array(h)),Kd(u),Od(l),l<0||l>=ef)throw new Error("arx: counter overflow");if(u.length<h)throw new Error(`arx: output (${u.length}) is shorter than data (${h})`);const d=[];let f,p,g=t.length;if(32===g)f=t.slice(),d.push(f),p=Yd;else{if(16!==g||!r)throw new Error(`arx: invalid 32-byte key, got length=${g}`);f=new Uint8Array(32),f.set(t),f.set(t,16),p=Wd,d.push(f)}Jd(a)||(a=a.slice(),d.push(a));const b=Td(f);if(n){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");n(p,b,Td(a.subarray(0,16)),b),a=a.subarray(16)}const y=16-i;if(y!==a.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(12!==y){const e=new Uint8Array(12);e.set(a,s?0:12-a.length),a=e,d.push(a)}const m=Td(a);for(!function(e,t,r,n,i,s,o,a){const c=i.length,u=new Uint8Array(Xd),l=Td(u),h=Jd(i)&&Jd(s),d=h?Td(i):tf,f=h?Td(s):tf;for(let p=0;p<c;o++){if(e(t,r,n,l,o,a),o>=ef)throw new Error("arx: counter overflow");const g=Math.min(Xd,c-p);if(h&&g===Xd){const e=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let t,r=0;r<Zd;r++)t=e+r,f[t]=d[t]^l[r];p+=Xd}else{for(let e,t=0;t<g;t++)e=p+t,s[e]=i[e]^u[t];p+=g}}}(e,p,b,m,c,u,l,o);d.length>0;)d.pop().fill(0);return u}}function nf(e,t,r,n,i){let s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:20,o=e[0],a=e[1],c=e[2],u=e[3],l=t[0],h=t[1],d=t[2],f=t[3],p=t[4],g=t[5],b=t[6],y=t[7],m=i,w=r[0],v=r[1],_=r[2],E=o,S=a,A=c,k=u,x=l,I=h,C=d,T=f,R=p,P=g,D=b,N=y,B=m,U=w,L=v,M=_;for(let q=0;q<s;q+=2)E=E+x|0,B=Qd(B^E,16),R=R+B|0,x=Qd(x^R,12),E=E+x|0,B=Qd(B^E,8),R=R+B|0,x=Qd(x^R,7),S=S+I|0,U=Qd(U^S,16),P=P+U|0,I=Qd(I^P,12),S=S+I|0,U=Qd(U^S,8),P=P+U|0,I=Qd(I^P,7),A=A+C|0,L=Qd(L^A,16),D=D+L|0,C=Qd(C^D,12),A=A+C|0,L=Qd(L^A,8),D=D+L|0,C=Qd(C^D,7),k=k+T|0,M=Qd(M^k,16),N=N+M|0,T=Qd(T^N,12),k=k+T|0,M=Qd(M^k,8),N=N+M|0,T=Qd(T^N,7),E=E+I|0,M=Qd(M^E,16),D=D+M|0,I=Qd(I^D,12),E=E+I|0,M=Qd(M^E,8),D=D+M|0,I=Qd(I^D,7),S=S+C|0,B=Qd(B^S,16),N=N+B|0,C=Qd(C^N,12),S=S+C|0,B=Qd(B^S,8),N=N+B|0,C=Qd(C^N,7),A=A+T|0,U=Qd(U^A,16),R=R+U|0,T=Qd(T^R,12),A=A+T|0,U=Qd(U^A,8),R=R+U|0,T=Qd(T^R,7),k=k+x|0,L=Qd(L^k,16),P=P+L|0,x=Qd(x^P,12),k=k+x|0,L=Qd(L^k,8),P=P+L|0,x=Qd(x^P,7);let O=0;n[O++]=o+E|0,n[O++]=a+S|0,n[O++]=c+A|0,n[O++]=u+k|0,n[O++]=l+x|0,n[O++]=h+I|0,n[O++]=d+C|0,n[O++]=f+T|0,n[O++]=p+R|0,n[O++]=g+P|0,n[O++]=b+D|0,n[O++]=y+N|0,n[O++]=m+B|0,n[O++]=w+U|0,n[O++]=v+L|0,n[O++]=_+M|0}const sf=rf(nf,{counterRight:!1,counterLength:4,allowShortKeys:!1}),of=rf(nf,{counterRight:!1,counterLength:8,extendNonceFn:function(e,t,r,n){let i=e[0],s=e[1],o=e[2],a=e[3],c=t[0],u=t[1],l=t[2],h=t[3],d=t[4],f=t[5],p=t[6],g=t[7],b=r[0],y=r[1],m=r[2],w=r[3];for(let _=0;_<20;_+=2)i=i+c|0,b=Qd(b^i,16),d=d+b|0,c=Qd(c^d,12),i=i+c|0,b=Qd(b^i,8),d=d+b|0,c=Qd(c^d,7),s=s+u|0,y=Qd(y^s,16),f=f+y|0,u=Qd(u^f,12),s=s+u|0,y=Qd(y^s,8),f=f+y|0,u=Qd(u^f,7),o=o+l|0,m=Qd(m^o,16),p=p+m|0,l=Qd(l^p,12),o=o+l|0,m=Qd(m^o,8),p=p+m|0,l=Qd(l^p,7),a=a+h|0,w=Qd(w^a,16),g=g+w|0,h=Qd(h^g,12),a=a+h|0,w=Qd(w^a,8),g=g+w|0,h=Qd(h^g,7),i=i+u|0,w=Qd(w^i,16),p=p+w|0,u=Qd(u^p,12),i=i+u|0,w=Qd(w^i,8),p=p+w|0,u=Qd(u^p,7),s=s+l|0,b=Qd(b^s,16),g=g+b|0,l=Qd(l^g,12),s=s+l|0,b=Qd(b^s,8),g=g+b|0,l=Qd(l^g,7),o=o+h|0,y=Qd(y^o,16),d=d+y|0,h=Qd(h^d,12),o=o+h|0,y=Qd(y^o,8),d=d+y|0,h=Qd(h^d,7),a=a+c|0,m=Qd(m^a,16),f=f+m|0,c=Qd(c^f,12),a=a+c|0,m=Qd(m^a,8),f=f+m|0,c=Qd(c^f,7);let v=0;n[v++]=i,n[v++]=s,n[v++]=o,n[v++]=a,n[v++]=b,n[v++]=y,n[v++]=m,n[v++]=w},allowShortKeys:!1}),af=new Uint8Array(16),cf=(e,t)=>{e.update(t);const r=t.length%16;r&&e.update(af.subarray(r))},uf=new Uint8Array(32);function lf(e,t,r,n,i){const s=e(t,r,uf),o=Hd.create(s);i&&cf(o,i),cf(o,n);const a=new Uint8Array(16),c=Pd(a);Md(c,0,BigInt(i?i.length:0),!0),Md(c,8,BigInt(n.length),!0),o.update(a);const u=o.digest();return s.fill(0),u}const hf=e=>(t,r,n)=>{const i=16;return Ud(t,32),Ud(r),{encrypt:(s,o)=>{const a=s.length,c=a+i;o?Ud(o,c):o=new Uint8Array(c),e(t,r,s,o,1);const u=lf(e,t,r,o.subarray(0,-16),n);return o.set(u,a),o},decrypt:(s,o)=>{const a=s.length,c=a-i;if(a<i)throw new Error("encrypted data must be at least 16 bytes");o?Ud(o,c):o=new Uint8Array(c);const u=s.subarray(0,-16);if(!function(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e[n]^t[n];return 0===r}(s.subarray(-16),lf(e,t,r,u,n)))throw new Error("invalid tag");return e(t,r,u,o,1),o}}},df=Ld({blockSize:64,nonceLength:12,tagLength:16},hf(sf)),ff=(hf(of),BigInt(2**32-1)),pf=BigInt(32);function gf(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{h:Number(e&ff),l:Number(e>>pf&ff)}:{h:0|Number(e>>pf&ff),l:0|Number(e&ff)}}const bf={fromBig:gf,split:function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:s,l:o}=gf(e[i],t);[r[i],n[i]]=[s,o]}return[r,n]},toBig:(e,t)=>BigInt(e>>>0)<<pf|BigInt(t>>>0),shrSH:(e,t,r)=>e>>>r,shrSL:(e,t,r)=>e<<32-r|t>>>r,rotrSH:(e,t,r)=>e>>>r|t<<32-r,rotrSL:(e,t,r)=>e<<32-r|t>>>r,rotrBH:(e,t,r)=>e<<64-r|t>>>r-32,rotrBL:(e,t,r)=>e>>>r-32|t<<64-r,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,r)=>e<<r|t>>>32-r,rotlSL:(e,t,r)=>t<<r|e>>>32-r,rotlBH:(e,t,r)=>t<<r-32|e>>>64-r,rotlBL:(e,t,r)=>e<<r-32|t>>>64-r,add:function(e,t,r,n){const i=(t>>>0)+(n>>>0);return{h:e+r+(i/2**32|0)|0,l:0|i}},add3L:(e,t,r)=>(e>>>0)+(t>>>0)+(r>>>0),add3H:(e,t,r,n)=>t+r+n+(e/2**32|0)|0,add4L:(e,t,r,n)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0),add4H:(e,t,r,n,i)=>t+r+n+i+(e/2**32|0)|0,add5H:(e,t,r,n,i,s)=>t+r+n+i+s+(e/2**32|0)|0,add5L:(e,t,r,n,i)=>(e>>>0)+(t>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},[yf,mf]=(()=>bf.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((e=>BigInt(e)))))(),wf=new Uint32Array(80),vf=new Uint32Array(80);class _f extends Rc{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(){const{Ah:e,Al:t,Bh:r,Bl:n,Ch:i,Cl:s,Dh:o,Dl:a,Eh:c,El:u,Fh:l,Fl:h,Gh:d,Gl:f,Hh:p,Hl:g}=this;return[e,t,r,n,i,s,o,a,c,u,l,h,d,f,p,g]}set(e,t,r,n,i,s,o,a,c,u,l,h,d,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|s,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|u,this.Fh=0|l,this.Fl=0|h,this.Gh=0|d,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let m=0;m<16;m++,t+=4)wf[m]=e.getUint32(t),vf[m]=e.getUint32(t+=4);for(let m=16;m<80;m++){const e=0|wf[m-15],t=0|vf[m-15],r=bf.rotrSH(e,t,1)^bf.rotrSH(e,t,8)^bf.shrSH(e,t,7),n=bf.rotrSL(e,t,1)^bf.rotrSL(e,t,8)^bf.shrSL(e,t,7),i=0|wf[m-2],s=0|vf[m-2],o=bf.rotrSH(i,s,19)^bf.rotrBH(i,s,61)^bf.shrSH(i,s,6),a=bf.rotrSL(i,s,19)^bf.rotrBL(i,s,61)^bf.shrSL(i,s,6),c=bf.add4L(n,a,vf[m-7],vf[m-16]),u=bf.add4H(c,r,o,wf[m-7],wf[m-16]);wf[m]=0|u,vf[m]=0|c}let{Ah:r,Al:n,Bh:i,Bl:s,Ch:o,Cl:a,Dh:c,Dl:u,Eh:l,El:h,Fh:d,Fl:f,Gh:p,Gl:g,Hh:b,Hl:y}=this;for(let m=0;m<80;m++){const e=bf.rotrSH(l,h,14)^bf.rotrSH(l,h,18)^bf.rotrBH(l,h,41),t=bf.rotrSL(l,h,14)^bf.rotrSL(l,h,18)^bf.rotrBL(l,h,41),w=l&d^~l&p,v=h&f^~h&g,_=bf.add5L(y,t,v,mf[m],vf[m]),E=bf.add5H(_,b,e,w,yf[m],wf[m]),S=0|_,A=bf.rotrSH(r,n,28)^bf.rotrBH(r,n,34)^bf.rotrBH(r,n,39),k=bf.rotrSL(r,n,28)^bf.rotrBL(r,n,34)^bf.rotrBL(r,n,39),x=r&i^r&o^i&o,I=n&s^n&a^s&a;b=0|p,y=0|g,p=0|d,g=0|f,d=0|l,f=0|h,({h:l,l:h}=bf.add(0|c,0|u,0|E,0|S)),c=0|o,u=0|a,o=0|i,a=0|s,i=0|r,s=0|n;const C=bf.add3L(S,k,I);r=bf.add3H(C,E,A,x),n=0|C}({h:r,l:n}=bf.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:s}=bf.add(0|this.Bh,0|this.Bl,0|i,0|s)),({h:o,l:a}=bf.add(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:u}=bf.add(0|this.Dh,0|this.Dl,0|c,0|u)),({h:l,l:h}=bf.add(0|this.Eh,0|this.El,0|l,0|h)),({h:d,l:f}=bf.add(0|this.Fh,0|this.Fl,0|d,0|f)),({h:p,l:g}=bf.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:b,l:y}=bf.add(0|this.Hh,0|this.Hl,0|b,0|y)),this.set(r,n,i,s,o,a,c,u,l,h,d,f,p,g,b,y)}roundClean(){wf.fill(0),vf.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)}}const Ef=Ic((()=>new _f)),Sf=(BigInt(0),BigInt(1)),Af=BigInt(2);function kf(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}function xf(e){if(!kf(e))throw new Error("Uint8Array expected")}const If=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Cf(e){xf(e);let t="";for(let r=0;r<e.length;r++)t+=If[e[r]];return t}function Tf(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const Rf={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Pf(e){return e>=Rf._0&&e<=Rf._9?e-Rf._0:e>=Rf._A&&e<=Rf._F?e-(Rf._A-10):e>=Rf._a&&e<=Rf._f?e-(Rf._a-10):void 0}function Df(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const n=new Uint8Array(r);for(let i=0,s=0;i<r;i++,s+=2){const t=Pf(e.charCodeAt(s)),r=Pf(e.charCodeAt(s+1));if(void 0===t||void 0===r){const t=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+s)}n[i]=16*t+r}return n}function Nf(e){return Tf(Cf(e))}function Bf(e){return xf(e),Tf(Cf(Uint8Array.from(e).reverse()))}function Uf(e,t){return Df(e.toString(16).padStart(2*t,"0"))}function Lf(e,t){return Uf(e,t).reverse()}function Mf(e,t,r){let n;if("string"===typeof t)try{n=Df(t)}catch(s){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`)}else{if(!kf(t))throw new Error(`${e} must be hex string or Uint8Array`);n=Uint8Array.from(t)}const i=n.length;if("number"===typeof r&&i!==r)throw new Error(`${e} expected ${r} bytes, got ${i}`);return n}function Of(){let e=0;for(let r=0;r<arguments.length;r++){const t=r<0||arguments.length<=r?void 0:arguments[r];xf(t),e+=t.length}const t=new Uint8Array(e);for(let r=0,n=0;r<arguments.length;r++){const e=r<0||arguments.length<=r?void 0:arguments[r];t.set(e,n),n+=e.length}return t}const qf=e=>(Af<<BigInt(e-1))-Sf,Kf=e=>new Uint8Array(e),Ff=e=>Uint8Array.from(e);function Vf(e,t,r){if("number"!==typeof e||e<2)throw new Error("hashLen must be a number");if("number"!==typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!==typeof r)throw new Error("hmacFn must be a function");let n=Kf(e),i=Kf(e),s=0;const o=()=>{n.fill(1),i.fill(0),s=0},a=function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return r(i,n,...t)},c=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Kf();i=a(Ff([0]),e),n=a(),0!==e.length&&(i=a(Ff([1]),e),n=a())},u=()=>{if(s++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e<t;){n=a();const t=n.slice();r.push(t),e+=n.length}return Of(...r)};return(e,t)=>{let r;for(o(),c(e);!(r=t(u()));)c();return o(),r}}const zf={bigint:e=>"bigint"===typeof e,function:e=>"function"===typeof e,boolean:e=>"boolean"===typeof e,string:e=>"string"===typeof e,stringOrUint8Array:e=>"string"===typeof e||kf(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"===typeof e&&Number.isSafeInteger(e.outputLen)};function $f(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=(t,r,n)=>{const i=zf[r];if("function"!==typeof i)throw new Error(`Invalid validator "${r}", expected function`);const s=e[t];if((!n||void 0!==s)&&!i(s,e))throw new Error(`Invalid param ${String(t)}=${s} (${typeof s}), expected ${r}`)};for(const[i,s]of Object.entries(t))n(i,s,!1);for(const[i,s]of Object.entries(r))n(i,s,!0);return e}const Hf=BigInt(0),jf=BigInt(1),Gf=BigInt(2),Wf=BigInt(3),Yf=BigInt(4),Qf=BigInt(5),Jf=BigInt(8);BigInt(9),BigInt(16);function Xf(e,t){const r=e%t;return r>=Hf?r:t+r}function Zf(e,t,r){if(r<=Hf||t<Hf)throw new Error("Expected power/modulo > 0");if(r===jf)return Hf;let n=jf;for(;t>Hf;)t&jf&&(n=n*e%r),e=e*e%r,t>>=jf;return n}function ep(e,t,r){let n=e;for(;t-- >Hf;)n*=n,n%=r;return n}function tp(e,t){if(e===Hf||t<=Hf)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=Xf(e,t),n=t,i=Hf,s=jf,o=jf,a=Hf;for(;r!==Hf;){const e=n/r,t=n%r,c=i-o*e,u=s-a*e;n=r,r=t,i=o,s=a,o=c,a=u}if(n!==jf)throw new Error("invert: does not exist");return Xf(i,t)}function rp(e){if(e%Yf===Wf){const t=(e+jf)/Yf;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}if(e%Jf===Qf){const t=(e-Qf)/Jf;return function(e,r){const n=e.mul(r,Gf),i=e.pow(n,t),s=e.mul(r,i),o=e.mul(e.mul(s,Gf),i),a=e.mul(s,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-jf)/Gf;let r,n,i;for(r=e-jf,n=0;r%Gf===Hf;r/=Gf,n++);for(i=Gf;i<e&&Zf(i,t,e)!==e-jf;i++);if(1===n){const t=(e+jf)/Yf;return function(e,r){const n=e.pow(r,t);if(!e.eql(e.sqr(n),r))throw new Error("Cannot find square root");return n}}const s=(r+jf)/Gf;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=n,c=e.pow(e.mul(e.ONE,i),r),u=e.pow(o,s),l=e.pow(o,r);for(;!e.eql(l,e.ONE);){if(e.eql(l,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(l);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const r=e.pow(c,jf<<BigInt(a-t-1));c=e.sqr(r),u=e.mul(u,r),l=e.mul(l,c),a=t}return u}}(e)}const np=(e,t)=>(Xf(e,t)&jf)===jf,ip=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function sp(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function op(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e<=Hf)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:s}=sp(e,t);if(s>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=rp(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:s,MASK:qf(i),ZERO:Hf,ONE:jf,create:t=>Xf(t,e),isValid:t=>{if("bigint"!==typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Hf<=t&&t<e},is0:e=>e===Hf,isOdd:e=>(e&jf)===jf,neg:t=>Xf(-t,e),eql:(e,t)=>e===t,sqr:t=>Xf(t*t,e),add:(t,r)=>Xf(t+r,e),sub:(t,r)=>Xf(t-r,e),mul:(t,r)=>Xf(t*r,e),pow:(e,t)=>function(e,t,r){if(r<Hf)throw new Error("Expected power > 0");if(r===Hf)return e.ONE;if(r===jf)return t;let n=e.ONE,i=t;for(;r>Hf;)r&jf&&(n=e.mul(n,i)),i=e.sqr(i),r>>=jf;return n}(a,e,t),div:(t,r)=>Xf(t*tp(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>tp(t,e),sqrt:n.sqrt||(e=>o(a,e)),invertBatch:e=>function(e,t){const r=new Array(t.length),n=t.reduce(((t,n,i)=>e.is0(n)?t:(r[i]=t,e.mul(t,n))),e.ONE),i=e.inv(n);return t.reduceRight(((t,n,i)=>e.is0(n)?t:(r[i]=e.mul(t,r[i]),e.mul(t,n))),i),r}(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?Lf(e,s):Uf(e,s),fromBytes:e=>{if(e.length!==s)throw new Error(`Fp.fromBytes: expected ${s}, got ${e.length}`);return r?Bf(e):Nf(e)}});return Object.freeze(a)}function ap(e){if("bigint"!==typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function cp(e){const t=ap(e);return t+Math.ceil(t/2)}const up=BigInt(0),lp=BigInt(1);function hp(e,t){const r=(e,t)=>{const r=t.negate();return e?r:t},n=e=>({windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:r,unsafeLadder(t,r){let n=e.ZERO,i=t;for(;r>up;)r&lp&&(n=n.add(i)),i=i.double(),r>>=lp;return n},precomputeWindow(e,t){const{windows:r,windowSize:i}=n(t),s=[];let o=e,a=o;for(let n=0;n<r;n++){a=o,s.push(a);for(let e=1;e<i;e++)a=a.add(o),s.push(a);o=a.double()}return s},wNAF(t,i,s){const{windows:o,windowSize:a}=n(t);let c=e.ZERO,u=e.BASE;const l=BigInt(2**t-1),h=2**t,d=BigInt(t);for(let e=0;e<o;e++){const t=e*a;let n=Number(s&l);s>>=d,n>a&&(n-=h,s+=lp);const o=t,f=t+Math.abs(n)-1,p=e%2!==0,g=n<0;0===n?u=u.add(r(p,i[o])):c=c.add(r(g,i[f]))}return{p:c,f:u}},wNAFCached(e,t,r,n){const i=e._WINDOW_SIZE||1;let s=t.get(e);return s||(s=this.precomputeWindow(e,i),1!==i&&t.set(e,n(s))),this.wNAF(i,s,r)}}}function dp(e){return function(e){const t=ip.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});$f(e,t)}(e.Fp),$f(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...sp(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const fp=BigInt(0),pp=BigInt(1),gp=BigInt(2),bp=BigInt(8),yp={zip215:!0};function mp(e){const t=function(e){const t=dp(e);return $f(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:n,prehash:i,hash:s,randomBytes:o,nByteLength:a,h:c}=t,u=gp<<BigInt(8*a)-pp,l=r.create,h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch(n){return{isValid:!1,value:fp}}}),d=t.adjustScalarBytes||(e=>e),f=t.domain||((e,t,r)=>{if(t.length||r)throw new Error("Contexts/pre-hash are not supported");return e}),p=e=>"bigint"===typeof e&&fp<e,g=(e,t)=>p(e)&&p(t)&&e<t,b=e=>e===fp||g(e,u);function y(e,t){if(g(e,t))return e;throw new Error(`Expected valid scalar < ${t}, got ${typeof e} ${e}`)}function m(e){return e===fp?e:y(e,n)}const w=new Map;function v(e){if(!(e instanceof _))throw new Error("ExtendedPoint expected")}class _{constructor(e,t,r,n){if(this.ex=e,this.ey=t,this.ez=r,this.et=n,!b(e))throw new Error("x required");if(!b(t))throw new Error("y required");if(!b(r))throw new Error("z required");if(!b(n))throw new Error("t required")}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof _)throw new Error("extended point not allowed");const{x:t,y:r}=e||{};if(!b(t)||!b(r))throw new Error("invalid affine point");return new _(t,r,pp,l(t*r))}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.ez)));return e.map(((e,r)=>e.toAffine(t[r]))).map(_.fromAffine)}_setWindowSize(e){this._WINDOW_SIZE=e,w.delete(this)}assertValidity(){const{a:e,d:r}=t;if(this.is0())throw new Error("bad point: ZERO");const{ex:n,ey:i,ez:s,et:o}=this,a=l(n*n),c=l(i*i),u=l(s*s),h=l(u*u),d=l(a*e);if(l(u*l(d+c))!==l(h+l(r*l(a*c))))throw new Error("bad point: equation left != right (1)");if(l(n*i)!==l(s*o))throw new Error("bad point: equation left != right (2)")}equals(e){v(e);const{ex:t,ey:r,ez:n}=this,{ex:i,ey:s,ez:o}=e,a=l(t*o),c=l(i*n),u=l(r*o),h=l(s*n);return a===c&&u===h}is0(){return this.equals(_.ZERO)}negate(){return new _(l(-this.ex),this.ey,this.ez,l(-this.et))}double(){const{a:e}=t,{ex:r,ey:n,ez:i}=this,s=l(r*r),o=l(n*n),a=l(gp*l(i*i)),c=l(e*s),u=r+n,h=l(l(u*u)-s-o),d=c+o,f=d-a,p=c-o,g=l(h*f),b=l(d*p),y=l(h*p),m=l(f*d);return new _(g,b,m,y)}add(e){v(e);const{a:r,d:n}=t,{ex:i,ey:s,ez:o,et:a}=this,{ex:c,ey:u,ez:h,et:d}=e;if(r===BigInt(-1)){const e=l((s-i)*(u+c)),t=l((s+i)*(u-c)),r=l(t-e);if(r===fp)return this.double();const n=l(o*gp*d),f=l(a*gp*h),p=f+n,g=t+e,b=f-n,y=l(p*r),m=l(g*b),w=l(p*b),v=l(r*g);return new _(y,m,v,w)}const f=l(i*c),p=l(s*u),g=l(a*n*d),b=l(o*h),y=l((i+s)*(c+u)-f-p),m=b-g,w=b+g,E=l(p-r*f),S=l(y*m),A=l(w*E),k=l(y*E),x=l(m*w);return new _(S,A,x,k)}subtract(e){return this.add(e.negate())}wNAF(e){return A.wNAFCached(this,w,e,_.normalizeZ)}multiply(e){const{p:t,f:r}=this.wNAF(y(e,n));return _.normalizeZ([t,r])[0]}multiplyUnsafe(e){let t=m(e);return t===fp?S:this.equals(S)||t===pp?this:this.equals(E)?this.wNAF(t).p:A.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return A.unsafeLadder(this,n).is0()}toAffine(e){const{ex:t,ey:n,ez:i}=this,s=this.is0();null==e&&(e=s?bp:r.inv(i));const o=l(t*e),a=l(n*e),c=l(i*e);if(s)return{x:fp,y:pp};if(c!==pp)throw new Error("invZ was invalid");return{x:o,y:a}}clearCofactor(){const{h:e}=t;return e===pp?this:this.multiplyUnsafe(e)}static fromHex(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{d:i,a:s}=t,o=r.BYTES,a=(e=Mf("pointHex",e,o)).slice(),c=e[o-1];a[o-1]=-129&c;const d=Bf(a);d===fp||y(d,n?u:r.ORDER);const f=l(d*d),p=l(f-pp),g=l(i*f-s);let{isValid:b,value:m}=h(p,g);if(!b)throw new Error("Point.fromHex: invalid y coordinate");const w=(m&pp)===pp,v=0!==(128&c);if(!n&&m===fp&&v)throw new Error("Point.fromHex: x=0 and x_0=1");return v!==w&&(m=l(-m)),_.fromAffine({x:m,y:d})}static fromPrivateKey(e){return I(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),n=Lf(t,r.BYTES);return n[n.length-1]|=e&pp?128:0,n}toHex(){return Cf(this.toRawBytes())}}_.BASE=new _(t.Gx,t.Gy,pp,l(t.Gx*t.Gy)),_.ZERO=new _(fp,pp,pp,fp);const{BASE:E,ZERO:S}=_,A=hp(_,8*a);function k(e){return Xf(e,n)}function x(e){return k(Bf(e))}function I(e){const t=a;e=Mf("private key",e,t);const r=Mf("hashed private key",s(e),2*t),n=d(r.slice(0,t)),i=r.slice(t,2*t),o=x(n),c=E.multiply(o),u=c.toRawBytes();return{head:n,prefix:i,scalar:o,point:c,pointBytes:u}}function C(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];const o=Of(...r);return x(s(f(o,Mf("context",e),!!i)))}const T=yp;E._setWindowSize(8);const R={getExtendedPublicKey:I,randomPrivateKey:()=>o(r.BYTES),precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:_.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};return{CURVE:t,getPublicKey:function(e){return I(e).pointBytes},sign:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=Mf("message",e),i&&(e=i(e));const{prefix:s,scalar:o,pointBytes:c}=I(t),u=C(n.context,s,e),l=E.multiply(u).toRawBytes(),h=k(u+C(n.context,l,c,e)*o);return m(h),Mf("result",Of(l,Lf(h,r.BYTES)),2*a)},verify:function(e,t,n){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:T;const{context:o,zip215:a}=s,c=r.BYTES;e=Mf("signature",e,2*c),t=Mf("message",t),i&&(t=i(t));const u=Bf(e.slice(c,2*c));let l,h,d;try{l=_.fromHex(n,a),h=_.fromHex(e.slice(0,c),a),d=E.multiplyUnsafe(u)}catch(p){return!1}if(!a&&l.isSmallOrder())return!1;const f=C(o,h.toRawBytes(),l.toRawBytes(),t);return h.add(l.multiplyUnsafe(f)).subtract(d).clearCofactor().equals(_.ZERO)},ExtendedPoint:_,utils:R}}const wp=BigInt(0),vp=BigInt(1);function _p(e){const t=($f(r=e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...r}));var r;const{P:n}=t,i=e=>Xf(e,n),s=t.montgomeryBits,o=Math.ceil(s/8),a=t.nByteLength,c=t.adjustScalarBytes||(e=>e),u=t.powPminus2||(e=>Zf(e,n-BigInt(2),n));function l(e,t,r){const n=i(e*(t-r));return[t=i(t-n),r=i(r+n)]}function h(e){if("bigint"===typeof e&&wp<=e&&e<n)return e;throw new Error("Expected valid scalar 0 < scalar < CURVE.P")}const d=(t.a-BigInt(2))/BigInt(4);function f(e){return Lf(i(e),o)}function p(e,t){const r=function(e){const t=Mf("u coordinate",e,o);return 32===a&&(t[31]&=127),Bf(t)}(t),n=function(e){const t=Mf("scalar",e),r=t.length;if(r!==o&&r!==a)throw new Error(`Expected ${o} or ${a} bytes, got ${r}`);return Bf(c(t))}(e),p=function(e,t){const r=h(e),n=h(t),o=r;let a,c=vp,f=wp,p=r,g=vp,b=wp;for(let u=BigInt(s-1);u>=wp;u--){const e=n>>u&vp;b^=e,a=l(b,c,p),c=a[0],p=a[1],a=l(b,f,g),f=a[0],g=a[1],b=e;const t=c+f,r=i(t*t),s=c-f,h=i(s*s),y=r-h,m=p+g,w=i((p-g)*t),v=i(m*s),_=w+v,E=w-v;p=i(_*_),g=i(o*i(E*E)),c=i(r*h),f=i(y*(r+i(d*y)))}a=l(b,c,p),c=a[0],p=a[1],a=l(b,f,g),f=a[0],g=a[1];const y=u(f);return i(c*y)}(r,n);if(p===wp)throw new Error("Invalid private or public key received");return f(p)}const g=f(t.Gu);function b(e){return p(e,g)}return{scalarMult:p,scalarMultBase:b,getSharedSecret:(e,t)=>p(e,t),getPublicKey:e=>b(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:g}}const Ep=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Sp=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),Ap=(BigInt(0),BigInt(1)),kp=BigInt(2),xp=BigInt(5),Ip=BigInt(10),Cp=BigInt(20),Tp=BigInt(40),Rp=BigInt(80);function Pp(e){const t=Ep,r=e*e%t*e%t,n=ep(r,kp,t)*r%t,i=ep(n,Ap,t)*e%t,s=ep(i,xp,t)*i%t,o=ep(s,Ip,t)*s%t,a=ep(o,Cp,t)*o%t,c=ep(a,Tp,t)*a%t,u=ep(c,Rp,t)*c%t,l=ep(u,Rp,t)*c%t,h=ep(l,Ip,t)*s%t;return{pow_p_5_8:ep(h,kp,t)*e%t,b2:r}}function Dp(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Np(e,t){const r=Ep,n=Xf(t*t*t,r),i=Xf(n*n*t,r);let s=Xf(e*n*Pp(e*i).pow_p_5_8,r);const o=Xf(t*s*s,r),a=s,c=Xf(s*Sp,r),u=o===e,l=o===Xf(-e,r),h=o===Xf(-e*Sp,r);return u&&(s=a),(l||h)&&(s=c),np(s,r)&&(s=Xf(-s,r)),{isValid:u||l,value:s}}const Bp=op(Ep,void 0,!0),Up={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Bp,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:BigInt(8),Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ef,randomBytes:Cc,adjustScalarBytes:Dp,uvRatio:Np},Lp=mp(Up);function Mp(e,t,r){if(t.length>255)throw new Error("Context is too big");return Ac(Ec("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}const Op=(()=>_p({P:Ep,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Ep,{pow_p_5_8:r,b2:n}=Pp(e);return Xf(ep(r,BigInt(3),t)*n,t)},adjustScalarBytes:Dp,randomBytes:Cc}))();const qp=(Bp.ORDER+BigInt(3))/BigInt(8);Bp.pow(kp,qp),Bp.sqrt(Bp.neg(Bp.ONE)),Bp.ORDER,BigInt(5),BigInt(8),BigInt(486662);!function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const r=e.sqrt(t);e.isOdd(r)&&e.neg(r)}(Bp,Bp.neg(BigInt(486664)));BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Kp extends kc{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,pc(e);const r=Sc(t);if(this.iHash=e.create(),"function"!==typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?e.create().update(r).digest():r);for(let s=0;s<i.length;s++)i[s]^=54;this.iHash.update(i),this.oHash=e.create();for(let s=0;s<i.length;s++)i[s]^=106;this.oHash.update(i),i.fill(0)}update(e){return gc(this),this.iHash.update(e),this}digestInto(e){gc(this),fc(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:n,destroyed:i,blockLen:s,outputLen:o}=this;return e.finished=n,e.destroyed=i,e.blockLen=s,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Fp=(e,t,r)=>new Kp(e,t).update(r).digest();function Vp(e,t,r){return pc(e),void 0===r&&(r=new Uint8Array(e.outputLen)),Fp(e,Sc(r),Sc(t))}Fp.create=(e,t)=>new Kp(e,t);const zp=new Uint8Array([0]),$p=new Uint8Array;function Hp(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;if(pc(e),dc(n),n>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(n/e.outputLen);void 0===r&&(r=$p);const s=new Uint8Array(i*e.outputLen),o=Fp.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let u=0;u<i;u++)zp[0]=u+1,a.update(0===u?$p:c).update(r).update(zp).digestInto(c),s.set(c,e.outputLen*u),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),zp.fill(0),s.slice(0,n)}const jp={hashSHA256:e=>Uc(e.subarray()),getHKDF(e,t){const r=Vp(Uc,t,e),n=Hp(Uc,r,void 0,96);return[n.subarray(0,32),n.subarray(32,64),n.subarray(64,96)]},generateX25519KeyPair(){const e=Op.utils.randomPrivateKey();return{publicKey:Op.getPublicKey(e),privateKey:e}},generateX25519KeyPairFromSeed:e=>({publicKey:Op.getPublicKey(e),privateKey:e}),generateX25519SharedKey:(e,t)=>Op.getSharedSecret(e.subarray(),t.subarray()),chaCha20Poly1305Encrypt:(e,t,r,n)=>df(n,t,r).encrypt(e.subarray()),chaCha20Poly1305Decrypt:(e,t,r,n,i)=>df(n,t,r).decrypt(e.subarray(),i)},Gp=e=>{const t=xd(2);return new DataView(t.buffer,t.byteOffset,t.byteLength).setUint16(0,e,!1),t};Gp.bytes=2;const Wp=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");return e instanceof Uint8Array?new DataView(e.buffer,e.byteOffset,e.byteLength).getUint16(0,!1):e.getUint16(0)};Wp.bytes=2;class Yp extends Error{code;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected Peer"),this.code=Yp.code}static code="ERR_UNEXPECTED_PEER"}class Qp extends Error{code;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto exchange"),this.code=Qp.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"}__webpack_require__(5465),__webpack_require__(3555);class Jp extends Error{code;type;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The operation was aborted"),this.name="AbortError",this.code=Jp.code,this.type=Jp.type}static code="ABORT_ERR";static type="aborted"}class Xp extends Error{code;props;constructor(e,t,r){super(e),this.code=t,this.name=r?.name??"CodeError",this.props=r??{}}}class Zp extends AggregateError{code;props;constructor(e,t,r,n){super(e,t),this.code=r,this.name=n?.name??"AggregateCodeError",this.props=n??{}}}Error;Error;Error;const eg="ERR_TIMEOUT";var tg=__webpack_require__(45);new Uint8Array(0);function rg(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var ng=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const ig=ng;class sg{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class og{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return cg(this,e)}}class ag{decoders;constructor(e){this.decoders=e}or(e){return cg(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function cg(e,t){return new ag({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class ug{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new sg(e,t,r),this.decoder=new og(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function lg(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new ug(t,r,n,i)}function hg(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=ig(n,t);return lg({prefix:r,name:t,encode:i,decode:e=>rg(s(e))})}function dg(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return lg({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const fg=hg({prefix:"9",name:"base10",alphabet:"0123456789"}),pg=dg({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),gg=dg({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),bg=dg({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),yg=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),mg=yg.reduce(((e,t,r)=>(e[r]=t,e)),[]),wg=yg.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const vg=lg({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=mg[t]),"")},decode:function(e){const t=[];for(const r of e){const e=wg[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),_g=dg({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Eg=dg({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Sg=dg({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ag=dg({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kg=dg({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xg=dg({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ig=dg({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cg=dg({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Tg=dg({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Rg=hg({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Pg=hg({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Dg=hg({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ng=hg({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Bg=dg({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ug=dg({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Lg=dg({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Mg=dg({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Og=dg({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),qg=lg({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Kg=new TextEncoder,Fg=new TextDecoder,Vg="json",zg=512;function $g(e){return Kg.encode(JSON.stringify(e))}function Hg(e){return JSON.parse(Fg.decode(e))}const jg="raw",Gg=85;function Wg(e){return rg(e)}function Yg(e){return rg(e)}var Qg=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Zg;)r[n++]=255&t|Jg,t/=128;for(;t&Xg;)r[n++]=255&t|Jg,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Jg=128,Xg=-128,Zg=Math.pow(2,31);var eb=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&rb)<<s:(n&rb)*Math.pow(2,s),s+=7}while(n>=tb);return e.bytes=o-r,i},tb=128,rb=127;var nb=Math.pow(2,7),ib=Math.pow(2,14),sb=Math.pow(2,21),ob=Math.pow(2,28),ab=Math.pow(2,35),cb=Math.pow(2,42),ub=Math.pow(2,49),lb=Math.pow(2,56),hb=Math.pow(2,63);const db={encode:Qg,decode:eb,encodingLength:function(e){return e<nb?1:e<ib?2:e<sb?3:e<ob?4:e<ab?5:e<cb?6:e<ub?7:e<lb?8:e<hb?9:10}};function fb(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return db.encode(e,t,r),t}function pb(e){return db.encodingLength(e)}function gb(e,t){const r=t.byteLength,n=pb(e),i=n+pb(r),s=new Uint8Array(i+r);return fb(e,s,0),fb(r,s,n),s.set(t,i),new bb(e,r,t,s)}class bb{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const yb=rg;const mb={code:0,name:"identity",encode:yb,digest:function(e){return gb(0,yb(e))}};function wb(e){let{name:t,code:r,encode:n}=e;return new vb(t,r,n)}class vb{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?gb(this.code,t):t.then((e=>gb(this.code,e)))}throw Error("Unknown type, must be binary type")}}function _b(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Eb=wb({name:"sha2-256",code:18,encode:_b("SHA-256")}),Sb=wb({name:"sha2-512",code:19,encode:_b("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Ab={...O,...P,...M,...T,...R,...N,...B,...U,...L,...D};function kb(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function xb(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Ib=xb("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Cb=xb("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=kb((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Tb={utf8:Ib,"utf-8":Ib,hex:Ab.base16,latin1:Cb,ascii:Cb,binary:Cb,...Ab};function Rb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Tb[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function Pb(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}__webpack_require__(3900),__webpack_require__(9463);function Db(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=kb(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function Nb(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Tb[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function Bb(e,t){let r=Uint8Array.from(e.abs().toByteArray());if(r=0===r[0]?r.subarray(1):r,null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=Db([new Uint8Array(t-r.length),r])}return Nb(r,"base64url")}function Ub(e){const t=function(e,t){let r=Rb(e,"base64urlpad");if(null!=t){if(r.length>t)throw new Error("byte array longer than desired length");r=Db([new Uint8Array(t-r.length),r])}return r}(e);return new tg.jsbn.BigInteger(Nb(t,"base16"),16)}function Lb(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const Mb=32,Ob=64,qb=32;function Kb(e,t){const r=new Uint8Array(Ob);for(let n=0;n<qb;n++)r[n]=e[n],r[qb+n]=t[n];return r}const Fb={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)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}},Vb={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function zb(e,t){const r=function(e){const t=e?.algorithm??"AES-GCM";let r=e?.keyLength??16;const n=e?.nonceLength??12,i=e?.digest??"SHA-256",s=e?.saltLength??16,o=e?.iterations??32767,a=Fb.get();return r*=8,{encrypt:async function(e,c){const u=a.getRandomValues(new Uint8Array(s)),l=a.getRandomValues(new Uint8Array(n)),h={name:t,iv:l};let d;if("string"===typeof c&&(c=Rb(c)),0===c.length){d=await a.subtle.importKey("jwk",Vb,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",Vb,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}const f=await a.subtle.encrypt(h,d,e);return Db([u,h.iv,new Uint8Array(f)])},decrypt:async function(e,c){const u=e.subarray(0,s),l=e.subarray(s,s+n),h=e.subarray(s+n),d={name:t,iv:l};let f;if("string"===typeof c&&(c=Rb(c)),0===c.length)try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}catch{f=await a.subtle.importKey("jwk",Vb,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}const p=await a.subtle.decrypt(d,f,h);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return Bg.encode(n)}const $b=new Float32Array([-0]),Hb=new Uint8Array($b.buffer);function jb(e,t,r){$b[0]=e,t[r]=Hb[0],t[r+1]=Hb[1],t[r+2]=Hb[2],t[r+3]=Hb[3]}const Gb=new Float64Array([-0]),Wb=new Uint8Array(Gb.buffer);function Yb(e,t,r){Gb[0]=e,t[r]=Wb[0],t[r+1]=Wb[1],t[r+2]=Wb[2],t[r+3]=Wb[3],t[r+4]=Wb[4],t[r+5]=Wb[5],t[r+6]=Wb[6],t[r+7]=Wb[7]}const Qb=BigInt(Number.MAX_SAFE_INTEGER),Jb=BigInt(Number.MIN_SAFE_INTEGER);class Xb{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return Zb;if(e<Qb&&e>Jb)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>ey&&(n=0n,++r>ey&&(r=0n))),new Xb(Number(n),Number(r))}static fromNumber(e){if(0===e)return Zb;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new Xb(r,n)}static from(e){return"number"===typeof e?Xb.fromNumber(e):"bigint"===typeof e?Xb.fromBigInt(e):"string"===typeof e?Xb.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new Xb(e.low>>>0,e.high>>>0):Zb}}const Zb=new Xb(0,0);Zb.toBigInt=function(){return 0n},Zb.zzEncode=Zb.zzDecode=function(){return this},Zb.length=function(){return 1};const ey=4294967296n;function ty(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function ry(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function ny(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class iy{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,ry(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw ry(this,4);return ny(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw ry(this,4);return 0|ny(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw ry(this,4);const e=(t=this.buf,r=this.pos,Hb[0]=t[r],Hb[1]=t[r+1],Hb[2]=t[r+2],Hb[3]=t[r+3],$b[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw ry(this,4);const e=(t=this.buf,r=this.pos,Wb[0]=t[r],Wb[1]=t[r+1],Wb[2]=t[r+2],Wb[3]=t[r+3],Wb[4]=t[r+4],Wb[5]=t[r+5],Wb[6]=t[r+6],Wb[7]=t[r+7],Gb[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw ry(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw ry(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw ry(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new Xb(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw ry(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw ry(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw ry(this,8);const e=ny(this.buf,this.pos+=4),t=ny(this.buf,this.pos+=4);return new Xb(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 sy(e,t,r){const n=function(e){return new iy(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class oy{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function ay(){}class cy{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const uy=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return kb(e);i+e>t&&(n=kb(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class ly{len;head;tail;states;constructor(){this.len=0,this.head=new oy(ay,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new oy(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new fy((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(py,10,Xb.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=Xb.fromBigInt(e);return this._push(py,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=Xb.fromBigInt(e).zzEncode();return this._push(py,t.length(),t)}sint64Number(e){const t=Xb.fromNumber(e).zzEncode();return this._push(py,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(hy,1,e?1:0)}fixed32(e){return this._push(gy,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=Xb.fromBigInt(e);return this._push(gy,4,t.lo)._push(gy,4,t.hi)}fixed64Number(e){const t=Xb.fromNumber(e);return this._push(gy,4,t.lo)._push(gy,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(jb,4,e)}double(e){return this._push(Yb,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(hy,1,0):this.uint32(t)._push(by,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(ty,t,e):this._push(hy,1,0)}fork(){return this.states=new cy(this),this.head=this.tail=new oy(ay,0,0),this.len=0,this}reset(){return null!=this.states?(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 oy(ay,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?kb(r):uy(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function hy(e,t,r){t[r]=255&e}function dy(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class fy extends oy{next;constructor(e,t){super(dy,e,t),this.next=void 0}}function py(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function gy(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function by(e,t,r){t.set(e,r)}function yy(e,t,r){t.set(e,r)}function my(e,t,r){e.length<40?ty(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(Rb(e),r)}function wy(e,t){const r=new ly;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var vy,_y,Ey,Sy,Ay;function ky(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function xy(e,t){return ky("message",vy.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(ly.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(yy,t,e),this},ly.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(my,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(vy||(vy={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(_y||(_y={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(Ey||(Ey={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return ky("enum",vy.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(Ey)}(_y||(_y={})),function(e){let t;e.codec=()=>(null==t&&(t=xy((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),_y.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=_y.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>wy(t,e.codec()),e.decode=t=>sy(t,e.codec())}(Sy||(Sy={})),function(e){let t;e.codec=()=>(null==t&&(t=xy((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),_y.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=_y.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>wy(t,e.codec()),e.decode=t=>sy(t,e.codec())}(Ay||(Ay={}));class Iy{_key;constructor(e){this._key=Ny(e,Mb)}verify(e,t){return function(e,t,r){return Lp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return Sy.encode({Type:_y.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Pb(this.bytes,e.bytes)}hash(){const e=Eb.digest(this.bytes);return Lb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class Cy{_key;_publicKey;constructor(e,t){this._key=Ny(e,Ob),this._publicKey=Ny(t,Mb)}sign(e){return function(e,t){const r=e.subarray(0,qb);return Lp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new Iy(this._publicKey)}marshal(){return this._key}get bytes(){return Ay.encode({Type:_y.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Pb(this.bytes,e.bytes)}async hash(){const e=Eb.digest(this.bytes);let t;return Lb(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=mb.digest(this.public.bytes);return Dg.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return zb(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function Ty(e){if(e.length>Ob){const t=(e=Ny(e,Ob+Mb)).subarray(0,Ob),r=e.subarray(Ob,e.length);return new Cy(t,r)}const t=(e=Ny(e,Ob)).subarray(0,Ob),r=e.subarray(Mb);return new Cy(t,r)}function Ry(e){return e=Ny(e,Mb),new Iy(e)}async function Py(){const{privateKey:e,publicKey:t}=function(){const e=Lp.utils.randomPrivateKey(),t=Lp.getPublicKey(e);return{privateKey:Kb(e,t),publicKey:t}}();return new Cy(e,t)}async function Dy(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==qb)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Lp.getPublicKey(t);return{privateKey:Kb(t,r),publicKey:r}}(e);return new Cy(t,r)}function Ny(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new Xp(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}const By={"P-256":256,"P-384":384,"P-521":521};Object.keys(By).join(" / ");__webpack_require__(8138);__webpack_require__(9408);function Uy(e,t){return t.map((t=>Ub(e[t])))}async function Ly(e){const t=[await Fb.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Oy(e)],r=await My({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function My(e){if(null==e.privateKey||null==e.publicKey)throw new Xp("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Fb.get().subtle.exportKey("jwk",e.privateKey),Fb.get().subtle.exportKey("jwk",e.publicKey)])}async function Oy(e){return Fb.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function qy(e,t,r,n){const i=t?function(e){return tg.pki.setRsaPublicKey(...Uy(e,["n","e"]))}(e):function(e){return tg.pki.setRsaPrivateKey(...Uy(e,["n","e","d","p","q","dp","dq","qi"]))}(e);return Rb(n(Nb(r instanceof Uint8Array?r:r.subarray(),"ascii"),i),"ascii")}function Ky(e){if("RSA"!==e.kty)throw new Xp("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new Xp("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*Rb(e.n,"base64url").length}const Fy=8192;class Vy{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,r){const n=await Fb.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Fb.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=tg.pki.publicKeyToAsn1({n:Ub(e.n),e:Ub(e.e)});return Rb(tg.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return Sy.encode({Type:_y.RSA,Data:this.marshal()}).subarray()}encrypt(e){return qy(this._key,!0,e,((e,t)=>t.encrypt(e)))}equals(e){return Pb(this.bytes,e.bytes)}hash(){const e=Eb.digest(this.bytes);return Lb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class zy{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return function(e){if(isNaN(e)||e<=0)throw new Xp("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Cc(e)}(16)}sign(e){return async function(e,t){const r=await Fb.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Fb.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new Xp("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Vy(this._publicKey)}decrypt(e){return qy(this._key,!1,e,((e,t)=>t.decrypt(e)))}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=tg.pki.privateKeyToAsn1({n:Ub(e.n),e:Ub(e.e),d:Ub(e.d),p:Ub(e.p),q:Ub(e.q),dP:Ub(e.dp),dQ:Ub(e.dq),qInv:Ub(e.qi)});return Rb(tg.asn1.toDer(t).getBytes(),"ascii")}(this._key)}get bytes(){return Ay.encode({Type:_y.RSA,Data:this.marshal()}).subarray()}equals(e){return Pb(this.bytes,e.bytes)}hash(){const e=Eb.digest(this.bytes);return Lb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Nb(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t){const t=new tg.util.ByteBuffer(this.marshal()),r=tg.asn1.fromDer(t),n=tg.pki.privateKeyFromAsn1(r),i={algorithm:"aes256",count:1e4,saltSize:16,prfAlgorithm:"sha512"};return tg.pki.encryptRsaPrivateKey(n,e,i)}if("libp2p-key"===t)return zb(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function $y(e){const t=function(e){const t=tg.asn1.fromDer(Nb(e,"ascii")),r=tg.pki.privateKeyFromAsn1(t);return{kty:"RSA",n:Bb(r.n),e:Bb(r.e),d:Bb(r.d),p:Bb(r.p),q:Bb(r.q),dp:Bb(r.dP),dq:Bb(r.dQ),qi:Bb(r.qInv),alg:"RS256"}}(e);if(Ky(t)>Fy)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await Ly(t);return new zy(r.privateKey,r.publicKey)}function Hy(e){const t=function(e){const t=tg.asn1.fromDer(Nb(e,"ascii")),r=tg.pki.publicKeyFromAsn1(t);return{kty:"RSA",n:Bb(r.n),e:Bb(r.e)}}(e);if(Ky(t)>Fy)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Vy(t)}async function jy(e){if(Ky(e)>Fy)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await Ly(e);return new zy(t.privateKey,t.publicKey)}async function Gy(e){if(e>Fy)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await Fb.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await My(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new zy(t.privateKey,t.publicKey)}const{bytesToNumberBE:Wy,hexToBytes:Yy}=C,Qy={Err:class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}},_parseInt(e){const{Err:t}=Qy;if(e.length<2||2!==e[0])throw new t("Invalid signature integer tag");const r=e[1],n=e.subarray(2,r+2);if(!r||n.length!==r)throw new t("Invalid signature integer: wrong length");if(128&n[0])throw new t("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new t("Invalid signature integer: unnecessary leading zero");return{d:Wy(n),l:e.subarray(r+2)}},toSig(e){const{Err:t}=Qy,r="string"===typeof e?Yy(e):e;xf(r);let n=r.length;if(n<2||48!=r[0])throw new t("Invalid signature tag");if(r[1]!==n-2)throw new t("Invalid signature: incorrect length");const{d:i,l:s}=Qy._parseInt(r.subarray(2)),{d:o,l:a}=Qy._parseInt(s);if(a.length)throw new t("Invalid signature: left bytes after parsing");return{r:i,s:o}},hexFromSig(e){const t=e=>8&Number.parseInt(e[0],16)?"00"+e:e,r=e=>{const t=e.toString(16);return 1&t.length?`0${t}`:t},n=t(r(e.s)),i=t(r(e.r)),s=n.length/2,o=i.length/2,a=r(s),c=r(o);return`30${r(o+s+4)}02${c}${i}02${a}${n}`}},Jy=BigInt(0),Xy=BigInt(1),Zy=(BigInt(2),BigInt(3));BigInt(4);function em(e){const t=function(e){const t=dp(e);$f(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=t;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!==typeof r||"bigint"!==typeof r.beta||"function"!==typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:r}=t,n=t.toBytes||((e,t,n)=>{const i=t.toAffine();return Of(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function s(e){const{a:n,b:i}=t,s=r.sqr(e),o=r.mul(s,e);return r.add(r.add(o,r.mul(e,n)),i)}if(!r.eql(r.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function o(e){return"bigint"===typeof e&&Jy<e&&e<t.n}function a(e){if(!o(e))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function c(e){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:s}=t;if(r&&"bigint"!==typeof e){if(kf(e)&&(e=Cf(e)),"string"!==typeof e||!r.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*n,"0")}let o;try{o="bigint"===typeof e?e:Nf(Mf("private key",e,n))}catch(c){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof e}`)}return i&&(o=Xf(o,s)),a(o),o}const u=new Map;function l(e){if(!(e instanceof h))throw new Error("ProjectivePoint expected")}class h{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!r.isValid(t)||!r.isValid(n))throw new Error("invalid affine point");if(e instanceof h)throw new Error("projective point not allowed");const i=e=>r.eql(e,r.ZERO);return i(t)&&i(n)?h.ZERO:new h(t,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(h.fromAffine)}static fromHex(e){const t=h.fromAffine(i(Mf("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return h.BASE.multiply(c(e))}_setWindowSize(e){this._WINDOW_SIZE=e,u.delete(this)}assertValidity(){if(this.is0()){if(t.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:e,y:n}=this.toAffine();if(!r.isValid(e)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),o=s(e);if(!r.eql(i,o))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:n,pz:i}=this,{px:s,py:o,pz:a}=e,c=r.eql(r.mul(t,a),r.mul(s,i)),u=r.eql(r.mul(n,a),r.mul(o,i));return c&&u}negate(){return new h(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:n}=t,i=r.mul(n,Zy),{px:s,py:o,pz:a}=this;let c=r.ZERO,u=r.ZERO,l=r.ZERO,d=r.mul(s,s),f=r.mul(o,o),p=r.mul(a,a),g=r.mul(s,o);return g=r.add(g,g),l=r.mul(s,a),l=r.add(l,l),c=r.mul(e,l),u=r.mul(i,p),u=r.add(c,u),c=r.sub(f,u),u=r.add(f,u),u=r.mul(c,u),c=r.mul(g,c),l=r.mul(i,l),p=r.mul(e,p),g=r.sub(d,p),g=r.mul(e,g),g=r.add(g,l),l=r.add(d,d),d=r.add(l,d),d=r.add(d,p),d=r.mul(d,g),u=r.add(u,d),p=r.mul(o,a),p=r.add(p,p),d=r.mul(p,g),c=r.sub(c,d),l=r.mul(p,f),l=r.add(l,l),l=r.add(l,l),new h(c,u,l)}add(e){l(e);const{px:n,py:i,pz:s}=this,{px:o,py:a,pz:c}=e;let u=r.ZERO,d=r.ZERO,f=r.ZERO;const p=t.a,g=r.mul(t.b,Zy);let b=r.mul(n,o),y=r.mul(i,a),m=r.mul(s,c),w=r.add(n,i),v=r.add(o,a);w=r.mul(w,v),v=r.add(b,y),w=r.sub(w,v),v=r.add(n,s);let _=r.add(o,c);return v=r.mul(v,_),_=r.add(b,m),v=r.sub(v,_),_=r.add(i,s),u=r.add(a,c),_=r.mul(_,u),u=r.add(y,m),_=r.sub(_,u),f=r.mul(p,v),u=r.mul(g,m),f=r.add(u,f),u=r.sub(y,f),f=r.add(y,f),d=r.mul(u,f),y=r.add(b,b),y=r.add(y,b),m=r.mul(p,m),v=r.mul(g,v),y=r.add(y,m),m=r.sub(b,m),m=r.mul(p,m),v=r.add(v,m),b=r.mul(y,v),d=r.add(d,b),b=r.mul(_,v),u=r.mul(w,u),u=r.sub(u,b),b=r.mul(w,y),f=r.mul(_,f),f=r.add(f,b),new h(u,d,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(h.ZERO)}wNAF(e){return f.wNAFCached(this,u,e,(e=>{const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(h.fromAffine)}))}multiplyUnsafe(e){const n=h.ZERO;if(e===Jy)return n;if(a(e),e===Xy)return this;const{endo:i}=t;if(!i)return f.unsafeLadder(this,e);let{k1neg:s,k1:o,k2neg:c,k2:u}=i.splitScalar(e),l=n,d=n,p=this;for(;o>Jy||u>Jy;)o&Xy&&(l=l.add(p)),u&Xy&&(d=d.add(p)),p=p.double(),o>>=Xy,u>>=Xy;return s&&(l=l.negate()),c&&(d=d.negate()),d=new h(r.mul(d.px,i.beta),d.py,d.pz),l.add(d)}multiply(e){a(e);let n,i,s=e;const{endo:o}=t;if(o){const{k1neg:e,k1:t,k2neg:a,k2:c}=o.splitScalar(s);let{p:u,f:l}=this.wNAF(t),{p:d,f:p}=this.wNAF(c);u=f.constTimeNegate(e,u),d=f.constTimeNegate(a,d),d=new h(r.mul(d.px,o.beta),d.py,d.pz),n=u.add(d),i=l.add(p)}else{const{p:e,f:t}=this.wNAF(s);n=e,i=t}return h.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(e,t,r){const n=h.BASE,i=(e,t)=>t!==Jy&&t!==Xy&&e.equals(n)?e.multiply(t):e.multiplyUnsafe(t),s=i(this,t).add(i(e,r));return s.is0()?void 0:s}toAffine(e){const{px:t,py:n,pz:i}=this,s=this.is0();null==e&&(e=s?r.ONE:r.inv(i));const o=r.mul(t,e),a=r.mul(n,e),c=r.mul(i,e);if(s)return{x:r.ZERO,y:r.ZERO};if(!r.eql(c,r.ONE))throw new Error("invZ was invalid");return{x:o,y:a}}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===Xy)return!0;if(r)return r(h,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===Xy?this:r?r(h,this):this.multiplyUnsafe(t.h)}toRawBytes(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.assertValidity(),n(h,this,e)}toHex(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Cf(this.toRawBytes(e))}}h.BASE=new h(t.Gx,t.Gy,r.ONE),h.ZERO=new h(r.ZERO,r.ONE,r.ZERO);const d=t.nBitLength,f=hp(h,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:h,normPrivateKeyToScalar:c,weierstrassEquation:s,isWithinCurveOrder:o}}function tm(e){const t=function(e){const t=dp(e);return $f(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:r,n:n}=t,i=r.BYTES+1,s=2*r.BYTES+1;function o(e){return Xf(e,n)}function a(e){return tp(e,n)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:l,isWithinCurveOrder:h}=em({...t,toBytes(e,t,n){const i=t.toAffine(),s=r.toBytes(i.x),o=Of;return n?o(Uint8Array.from([t.hasEvenY()?2:3]),s):o(Uint8Array.from([4]),s,r.toBytes(i.y))},fromBytes(e){const t=e.length,n=e[0],o=e.subarray(1);if(t!==i||2!==n&&3!==n){if(t===s&&4===n){return{x:r.fromBytes(o.subarray(0,r.BYTES)),y:r.fromBytes(o.subarray(r.BYTES,2*r.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`)}{const e=Nf(o);if(!(Jy<(a=e)&&a<r.ORDER))throw new Error("Point is not on curve");const t=l(e);let i;try{i=r.sqrt(t)}catch(c){const e=c instanceof Error?": "+c.message:"";throw new Error("Point is not on curve"+e)}return 1===(1&n)!==((i&Xy)===Xy)&&(i=r.neg(i)),{x:e,y:i}}var a}}),d=e=>Cf(Uf(e,t.nByteLength));function f(e){return e>n>>Xy}const p=(e,t,r)=>Nf(e.slice(t,r));class g{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const r=t.nByteLength;return e=Mf("compactSignature",e,2*r),new g(p(e,0,r),p(e,r,2*r))}static fromDER(e){const{r:t,s:r}=Qy.toSig(Mf("DER",e));return new g(t,r)}assertValidity(){if(!h(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!h(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:n,s:i,recovery:s}=this,u=w(Mf("msgHash",e));if(null==s||![0,1,2,3].includes(s))throw new Error("recovery id invalid");const l=2===s||3===s?n+t.n:n;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const h=0===(1&s)?"02":"03",f=c.fromHex(h+d(l)),p=a(l),g=o(-u*p),b=o(i*p),y=c.BASE.multiplyAndAddUnsafe(f,g,b);if(!y)throw new Error("point at infinify");return y.assertValidity(),y}hasHighS(){return f(this.s)}normalizeS(){return this.hasHighS()?new g(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Df(this.toDERHex())}toDERHex(){return Qy.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Df(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const b={isValidPrivateKey(e){try{return u(e),!0}catch(t){return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const e=cp(t.n);return function(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const n=e.length,i=ap(t),s=cp(t);if(n<16||n<s||n>1024)throw new Error(`expected ${s}-1024 bytes of input, got ${n}`);const o=Xf(r?Nf(e):Bf(e),t-jf)+jf;return r?Lf(o,i):Uf(o,i)}(t.randomBytes(e),t.n)},precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e){const t=kf(e),r="string"===typeof e,n=(t||r)&&e.length;return t?n===i||n===s:r?n===2*i||n===2*s:e instanceof c}const m=t.bits2int||function(e){const r=Nf(e),n=8*e.length-t.nBitLength;return n>0?r>>BigInt(n):r},w=t.bits2int_modN||function(e){return o(m(e))},v=qf(t.nBitLength);function _(e){if("bigint"!==typeof e)throw new Error("bigint expected");if(!(Jy<=e&&e<v))throw new Error(`bigint expected < 2^${t.nBitLength}`);return Uf(e,t.nByteLength)}function E(e,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S;if(["recovered","canonical"].some((e=>e in i)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:l}=t;let{lowS:d,prehash:p,extraEntropy:b}=i;null==d&&(d=!0),e=Mf("msgHash",e),p&&(e=Mf("prehashed msgHash",s(e)));const y=w(e),v=u(n),E=[_(v),_(y)];if(null!=b&&!1!==b){const e=!0===b?l(r.BYTES):b;E.push(Mf("extraEntropy",e))}const A=Of(...E),k=y;return{seed:A,k2sig:function(e){const t=m(e);if(!h(t))return;const r=a(t),n=c.BASE.multiply(t).toAffine(),i=o(n.x);if(i===Jy)return;const s=o(r*o(k+i*v));if(s===Jy)return;let u=(n.x===i?0:2)|Number(n.y&Xy),l=s;return d&&f(s)&&(l=function(e){return f(e)?o(-e):e}(s),u^=1),new g(i,l,u)}}}const S={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t){let r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(y(e))throw new Error("first arg must be private key");if(!y(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(u(e)).toRawBytes(r)},sign:function(e,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S;const{seed:i,k2sig:s}=E(e,r,n),o=t;return Vf(o.hash.outputLen,o.nByteLength,o.hmac)(i,s)},verify:function(e,r,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:A;const s=e;if(r=Mf("msgHash",r),n=Mf("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:u,prehash:l}=i;let h,d;try{if("string"===typeof s||kf(s))try{h=g.fromDER(s)}catch(E){if(!(E instanceof Qy.Err))throw E;h=g.fromCompact(s)}else{if("object"!==typeof s||"bigint"!==typeof s.r||"bigint"!==typeof s.s)throw new Error("PARSE");{const{r:e,s:t}=s;h=new g(e,t)}}d=c.fromHex(n)}catch(S){if("PARSE"===S.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(u&&h.hasHighS())return!1;l&&(r=t.hash(r));const{r:f,s:p}=h,b=w(r),y=a(p),m=o(b*y),v=o(f*y),_=c.BASE.multiplyAndAddUnsafe(d,m,v)?.toAffine();return!!_&&o(_.x)===f},ProjectivePoint:c,Signature:g,utils:b}}function rm(e){return{hash:e,hmac:function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return Fp(e,t,Ac(...n))},randomBytes:Cc}}const nm=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),im=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),sm=BigInt(1),om=BigInt(2),am=(e,t)=>(e+t/om)/t;function cm(e){const t=nm,r=BigInt(3),n=BigInt(6),i=BigInt(11),s=BigInt(22),o=BigInt(23),a=BigInt(44),c=BigInt(88),u=e*e*e%t,l=u*u*e%t,h=ep(l,r,t)*l%t,d=ep(h,r,t)*l%t,f=ep(d,om,t)*u%t,p=ep(f,i,t)*f%t,g=ep(p,s,t)*p%t,b=ep(g,a,t)*g%t,y=ep(b,c,t)*b%t,m=ep(y,a,t)*g%t,w=ep(m,r,t)*l%t,v=ep(w,o,t)*p%t,_=ep(v,n,t)*u%t,E=ep(_,om,t);if(!um.eql(um.sqr(E),e))throw new Error("Cannot find square root");return E}const um=op(nm,void 0,void 0,{sqrt:cm}),lm=function(e,t){const r=t=>tm({...e,...rm(t)});return Object.freeze({...r(t),create:r})}({a:BigInt(0),b:BigInt(7),Fp:um,n:im,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=im,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-sm*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=am(s*e,t),c=am(-n*e,t);let u=Xf(e-a*r-c*i,t),l=Xf(-a*n-c*s,t);const h=u>o,d=l>o;if(h&&(u=t-u),d&&(l=t-l),u>o||l>o)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:h,k1:u,k2neg:d,k2:l}}}},Uc);BigInt(0);lm.ProjectivePoint;function hm(e){try{lm.ProjectivePoint.fromHex(e)}catch(t){throw new Xp(String(t),"ERR_INVALID_PUBLIC_KEY")}}class dm{_key;constructor(e){hm(e),this._key=e}verify(e,t){return function(e,t,r){const n=Eb.digest(r instanceof Uint8Array?r:r.subarray());if(Lb(n))return n.then((r=>{let{digest:n}=r;return lm.verify(t,n,e)})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.verify(t,n.digest,e)}catch(i){throw new Xp(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,lm.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return Sy.encode({Type:_y.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Pb(this.bytes,e.bytes)}async hash(){const e=Eb.digest(this.bytes);let t;return Lb(e)?({bytes:t}=await e):t=e.bytes,t}}class fm{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),hm(this._publicKey)}sign(e){return function(e,t){const r=Eb.digest(t instanceof Uint8Array?t:t.subarray());if(Lb(r))return r.then((t=>{let{digest:r}=t;return lm.sign(r,e).toDERRawBytes()})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.sign(r.digest,e).toDERRawBytes()}catch(n){throw new Xp(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new dm(this._publicKey)}marshal(){return this._key}get bytes(){return Ay.encode({Type:_y.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Pb(this.bytes,e.bytes)}hash(){const e=Eb.digest(this.bytes);return Lb(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Nb(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return zb(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function pm(e){return new fm(e)}function gm(e){return new dm(e)}async function bm(){const e=lm.utils.randomPrivateKey();return new fm(e)}const ym={rsa:$,ed25519:z,secp256k1:H};function mm(e){const t=Object.keys(ym).join(" / ");return new Xp(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}async function wm(e){const t=Ay.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case _y.RSA:return ym.rsa.unmarshalRsaPrivateKey(r);case _y.Ed25519:return ym.ed25519.unmarshalEd25519PrivateKey(r);case _y.Secp256k1:return ym.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw mm(t.Type??"RSA")}}const vm=Symbol.for("@libp2p/peer-id");function _m(e){return null!=e&&Boolean(e[vm])}new Uint8Array(0);function Em(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Sm=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const Am=Sm;class km{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class xm{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return Cm(this,e)}}class Im{decoders;constructor(e){this.decoders=e}or(e){return Cm(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function Cm(e,t){return new Im({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class Tm{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new km(e,t,r),this.decoder=new xm(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Rm(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Tm(t,r,n,i)}function Pm(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=Am(n,t);return Rm({prefix:r,name:t,encode:i,decode:e=>Em(s(e))})}function Dm(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Rm({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const Nm=Pm({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Bm=Pm({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Um=Pm({prefix:"9",name:"base10",alphabet:"0123456789"}),Lm=Dm({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Mm=Dm({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Om=Dm({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),qm=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Km=qm.reduce(((e,t,r)=>(e[r]=t,e)),[]),Fm=qm.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Vm=Rm({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Km[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Fm[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),zm=Dm({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),$m=Dm({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Hm=Dm({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),jm=Dm({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Gm=Dm({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Wm=Dm({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ym=Dm({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Qm=Dm({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Jm=Dm({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Xm=Pm({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Zm=Pm({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),ew=Dm({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),tw=Dm({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),rw=Dm({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),nw=Dm({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),iw=Dm({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),sw=Rm({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),ow=new TextEncoder,aw=new TextDecoder,cw="json",uw=512;function lw(e){return ow.encode(JSON.stringify(e))}function hw(e){return JSON.parse(aw.decode(e))}const dw="raw",fw=85;function pw(e){return Em(e)}function gw(e){return Em(e)}var bw=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=ww;)r[n++]=255&t|yw,t/=128;for(;t&mw;)r[n++]=255&t|yw,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},yw=128,mw=-128,ww=Math.pow(2,31);var vw=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&Ew)<<s:(n&Ew)*Math.pow(2,s),s+=7}while(n>=_w);return e.bytes=o-r,i},_w=128,Ew=127;var Sw=Math.pow(2,7),Aw=Math.pow(2,14),kw=Math.pow(2,21),xw=Math.pow(2,28),Iw=Math.pow(2,35),Cw=Math.pow(2,42),Tw=Math.pow(2,49),Rw=Math.pow(2,56),Pw=Math.pow(2,63);const Dw={encode:bw,decode:vw,encodingLength:function(e){return e<Sw?1:e<Aw?2:e<kw?3:e<xw?4:e<Iw?5:e<Cw?6:e<Tw?7:e<Rw?8:e<Pw?9:10}};function Nw(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[Dw.decode(e,t),Dw.decode.bytes]}function Bw(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return Dw.encode(e,t,r),t}function Uw(e){return Dw.encodingLength(e)}function Lw(e,t){const r=t.byteLength,n=Uw(e),i=n+Uw(r),s=new Uint8Array(i+r);return Bw(e,s,0),Bw(r,s,n),s.set(t,i),new Ow(e,r,t,s)}function Mw(e){const t=Em(e),[r,n]=Nw(t),[i,s]=Nw(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new Ow(r,i,o,t)}class Ow{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const qw=Em;const Kw={code:0,name:"identity",encode:qw,digest:function(e){return Lw(0,qw(e))}};function Fw(e){let{name:t,code:r,encode:n}=e;return new Vw(t,r,n)}class Vw{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Lw(this.code,t):t.then((e=>Lw(this.code,e)))}throw Error("Unknown type, must be binary type")}}function zw(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const $w=Fw({name:"sha2-256",code:18,encode:zw("SHA-256")}),Hw=Fw({name:"sha2-512",code:19,encode:zw("SHA-512")});function jw(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==Nm.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,Ww(e),t??Nm.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,Ww(e),t??zm.encoder)}const Gw=new WeakMap;function Ww(e){const t=Gw.get(e);if(null==t){const t=new Map;return Gw.set(e,t),t}return t}class Yw{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==Qw)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==Jw)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return Yw.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:{const{code:e,digest:t}=this.multihash,r=Lw(e,t);return Yw.createV1(this.code,r)}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 Yw.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return jw(this,e)}toJSON(){return{"/":jw(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof Yw)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new Yw(e,r,n,i??Xw(e,r,n.bytes))}if(!0===t[Zw]){const{version:e,multihash:r,code:n}=t,i=Mw(r);return Yw.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==Qw)throw new Error(`Version 0 CID must use dag-pb (code: ${Qw}) block encoding`);return new Yw(e,t,r,r.bytes);case 1:{const n=Xw(e,t,r.bytes);return new Yw(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return Yw.create(0,Qw,e)}static createV1(e,t){return Yw.create(1,e,t)}static decode(e){const[t,r]=Yw.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=Yw.inspectBytes(e),r=t.size-t.multihashSize,n=Em(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new Ow(t.multihashCode,t.digestSize,i,n);return[0===t.version?Yw.createV0(s):Yw.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=Nw(e.subarray(t));return t+=n,r};let n=r(),i=Qw;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??Nm;return[Nm.prefix,r.decode(`${Nm.prefix}${e}`)]}case Nm.prefix:{const r=t??Nm;return[Nm.prefix,r.decode(e)]}case zm.prefix:{const r=t??zm;return[zm.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=Yw.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return Ww(i).set(r,e),i}}const Qw=112,Jw=18;function Xw(e,t,r){const n=Uw(e),i=n+Uw(t),s=new Uint8Array(i+r.byteLength);return Bw(e,s,0),Bw(t,s,n),s.set(r,i),s}const Zw=Symbol.for("@ipld/js-cid/CID"),ev={...te,...Y,...ee,...G,...W,...J,...X,...j,...Z,...Q};function tv(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const rv=Symbol.for("nodejs.util.inspect.custom"),nv=Object.values(ev).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),ev.identity.decoder),iv=114,sv=36,ov=37;class av{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=Nm.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Yw.createV1(iv,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return tv(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){if(t=t??nv,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=Mw(Nm.decode(`z${e}`));return e.startsWith("12D")?new uv({multihash:t}):e.startsWith("16U")?new lv({multihash:t}):new cv({multihash:t})}return function(e){try{const t=Mw(e);if(t.code===Kw.code){if(t.digest.length===sv)return new uv({multihash:t});if(t.digest.length===ov)return new lv({multihash:t})}if(t.code===$w.code)return new cv({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==iv)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===$w.code)return new cv({multihash:e.multihash});if(t.code===Kw.code){if(t.digest.length===sv)return new uv({multihash:e.multihash});if(t.digest.length===ov)return new lv({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(Yw.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(nv.decode(e))}(e).equals(this);if(null!=e?.multihash?.bytes)return tv(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[rv](){return`PeerId(${this.toString()})`}}class cv extends av{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class uv extends av{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class lv extends av{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}async function hv(e,t){return e.length===sv?new uv({multihash:Lw(Kw.code,e),privateKey:t}):e.length===ov?new lv({multihash:Lw(Kw.code,e),privateKey:t}):new cv({multihash:await $w.digest(e),publicKey:e,privateKey:t})}function dv(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const fv=dv("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),pv=dv("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=xd((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),gv={utf8:fv,"utf-8":fv,hex:ev.base16,latin1:pv,ascii:pv,binary:pv,...ev};function bv(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=gv[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}const yv=new Float32Array([-0]),mv=new Uint8Array(yv.buffer);function wv(e,t,r){yv[0]=e,t[r]=mv[0],t[r+1]=mv[1],t[r+2]=mv[2],t[r+3]=mv[3]}const vv=new Float64Array([-0]),_v=new Uint8Array(vv.buffer);function Ev(e,t,r){vv[0]=e,t[r]=_v[0],t[r+1]=_v[1],t[r+2]=_v[2],t[r+3]=_v[3],t[r+4]=_v[4],t[r+5]=_v[5],t[r+6]=_v[6],t[r+7]=_v[7]}const Sv=BigInt(Number.MAX_SAFE_INTEGER),Av=BigInt(Number.MIN_SAFE_INTEGER);class kv{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return xv;if(e<Sv&&e>Av)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>Iv&&(n=0n,++r>Iv&&(r=0n))),new kv(Number(n),Number(r))}static fromNumber(e){if(0===e)return xv;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new kv(r,n)}static from(e){return"number"===typeof e?kv.fromNumber(e):"bigint"===typeof e?kv.fromBigInt(e):"string"===typeof e?kv.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new kv(e.low>>>0,e.high>>>0):xv}}const xv=new kv(0,0);xv.toBigInt=function(){return 0n},xv.zzEncode=xv.zzDecode=function(){return this},xv.length=function(){return 1};const Iv=4294967296n;function Cv(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function Tv(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Rv(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Pv{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Tv(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw Tv(this,4);return Rv(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Tv(this,4);return 0|Rv(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw Tv(this,4);const e=(t=this.buf,r=this.pos,mv[0]=t[r],mv[1]=t[r+1],mv[2]=t[r+2],mv[3]=t[r+3],yv[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Tv(this,4);const e=(t=this.buf,r=this.pos,_v[0]=t[r],_v[1]=t[r+1],_v[2]=t[r+2],_v[3]=t[r+3],_v[4]=t[r+4],_v[5]=t[r+5],_v[6]=t[r+6],_v[7]=t[r+7],vv[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw Tv(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw Tv(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Tv(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new kv(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Tv(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Tv(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Tv(this,8);const e=Rv(this.buf,this.pos+=4),t=Rv(this.buf,this.pos+=4);return new kv(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 Dv(e,t,r){const n=function(e){return new Pv(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class Nv{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function Bv(){}class Uv{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const Lv=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return xd(e);i+e>t&&(n=xd(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class Mv{len;head;tail;states;constructor(){this.len=0,this.head=new Nv(Bv,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new Nv(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new Kv((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Fv,10,kv.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=kv.fromBigInt(e);return this._push(Fv,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=kv.fromBigInt(e).zzEncode();return this._push(Fv,t.length(),t)}sint64Number(e){const t=kv.fromNumber(e).zzEncode();return this._push(Fv,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ov,1,e?1:0)}fixed32(e){return this._push(Vv,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=kv.fromBigInt(e);return this._push(Vv,4,t.lo)._push(Vv,4,t.hi)}fixed64Number(e){const t=kv.fromNumber(e);return this._push(Vv,4,t.lo)._push(Vv,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(wv,4,e)}double(e){return this._push(Ev,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Ov,1,0):this.uint32(t)._push(zv,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(Cv,t,e):this._push(Ov,1,0)}fork(){return this.states=new Uv(this),this.head=this.tail=new Nv(Bv,0,0),this.len=0,this}reset(){return null!=this.states?(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 Nv(Bv,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?xd(r):Lv(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function Ov(e,t,r){t[r]=255&e}function qv(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class Kv extends Nv{next;constructor(e,t){super(qv,e,t),this.next=void 0}}function Fv(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function Vv(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function zv(e,t,r){t.set(e,r)}function $v(e,t,r){t.set(e,r)}function Hv(e,t,r){e.length<40?Cv(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(bv(e),r)}function jv(e,t){const r=new Mv;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var Gv,Wv,Yv;function Qv(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",Gv.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(Mv.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push($v,t,e),this},Mv.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Hv,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(Gv||(Gv={}));Error;async function Jv(e,t,r){const n=await async function(e,t){if(null==e.privateKey)throw new Error("PrivateKey was missing from PeerId");const r=await wm(e.privateKey);return r.sign(t)}(e,e_(t));if(null==e.publicKey)throw new Error("PublicKey was missing from local PeerId");return function(e,t,r){return Yv.encode({identityKey:e,identitySig:t,extensions:r??{webtransportCerthashes:[]}}).subarray()}(e.publicKey,n,r)}async function Xv(e){return hv(e.identityKey)}function Zv(e){return Yv.decode(e)}function e_(e){const t=bv("noise-libp2p-static-key:");return e instanceof Uint8Array?function(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=xd(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}([t,e],t.length+e.length):(e.prepend(t),e)}async function t_(e,t,r){const n=await hv(t.identityKey);if(!n.equals(r))throw new Error(`Payload identity key ${n.toString()} does not match expected remote peer ${r.toString()}`);const i=e_(e);if(null==n.publicKey)throw new Error("PublicKey was missing from PeerId");if(null==t.identitySig)throw new Error("Signature was missing from message");const s=function(e){const t=Sy.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case _y.RSA:return ym.rsa.unmarshalRsaPublicKey(r);case _y.Ed25519:return ym.ed25519.unmarshalEd25519PublicKey(r);case _y.Secp256k1:return ym.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw mm(t.Type??"unknown")}}(n.publicKey);if(!await s.verify(i,t.identitySig))throw new Error("Static key doesn't match to peer that signed payload!");return n}function r_(e){return!!(e instanceof Uint8Array||Xl(e))&&32===e.byteLength}function n_(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=gv[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}!function(e){let t;e.codec=()=>(null==t&&(t=Qv((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.webtransportCerthashes)for(const n of e.webtransportCerthashes)t.uint32(10),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={webtransportCerthashes:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.webtransportCerthashes.push(e.bytes());else e.skipType(7&t)}return r}))),t),e.encode=t=>jv(t,e.codec()),e.decode=t=>Dv(t,e.codec())}(Wv||(Wv={})),function(e){let t;e.codec=()=>(null==t&&(t=Qv((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.identityKey&&e.identityKey.byteLength>0&&(t.uint32(10),t.bytes(e.identityKey)),null!=e.identitySig&&e.identitySig.byteLength>0&&(t.uint32(18),t.bytes(e.identitySig)),null!=e.extensions&&(t.uint32(34),Wv.codec().encode(e.extensions,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={identityKey:kd(0),identitySig:kd(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.identityKey=e.bytes();break;case 2:r.identitySig=e.bytes();break;case 4:r.extensions=Wv.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>jv(t,e.codec()),e.decode=t=>Dv(t,e.codec())}(Yv||(Yv={}));class i_{n;bytes;view;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.n=e,this.bytes=kd(12),this.view=new DataView(this.bytes.buffer,this.bytes.byteOffset,this.bytes.byteLength),this.view.setUint32(4,e,!0)}increment(){this.n++,this.view.setUint32(4,this.n,!0)}getBytes(){return this.bytes}getUint64(){return this.n}assertValue(){if(this.n>4294967295)throw new Error("Cipherstate has reached maximum n, a new handshake must be performed")}}class s_{crypto;log;constructor(e,t){this.log=e.logger.forComponent("libp2p:noise:abstract-handshake"),this.crypto=t}encryptWithAd(e,t,r){const n=this.encrypt(e.k,e.n,t,r);return e.n.increment(),n}decryptWithAd(e,t,r,n){const{plaintext:i,valid:s}=this.decrypt(e.k,e.n,t,r,n);return s&&e.n.increment(),{plaintext:i,valid:s}}hasKey(e){return!this.isEmptyKey(e.k)}createEmptyKey(){return kd(32)}isEmptyKey(e){return tv(this.createEmptyKey(),e)}encrypt(e,t,r,n){return t.assertValue(),this.crypto.chaCha20Poly1305Encrypt(n,t.getBytes(),r,e)}encryptAndHash(e,t){let r;return r=this.hasKey(e.cs)?this.encryptWithAd(e.cs,e.h,t):t,this.mixHash(e,r),r}decrypt(e,t,r,n,i){t.assertValue();const s=this.crypto.chaCha20Poly1305Decrypt(n,t.getBytes(),r,e,i);return s?{plaintext:s,valid:!0}:{plaintext:kd(0),valid:!1}}decryptAndHash(e,t){let r,n=!0;return this.hasKey(e.cs)?({plaintext:r,valid:n}=this.decryptWithAd(e.cs,e.h,t)):r=t,this.mixHash(e,t),{plaintext:r,valid:n}}dh(e,t){try{const r=this.crypto.generateX25519SharedKey(e,t);return 32===r.length?r:r.subarray(0,32)}catch(r){const e=r;return this.log.error("error deriving shared key",e),kd(32)}}mixHash(e,t){e.h=this.getHash(e.h,t)}getHash(e,t){return this.crypto.hashSHA256(new Zl(e,t))}mixKey(e,t){const[r,n]=this.crypto.getHKDF(e.ck,t);e.cs=this.initializeKey(n),e.ck=r}initializeKey(e){return{k:e,n:new i_}}initializeSymmetric(e){const t=bv(e,"utf-8"),r=this.hashProtocolName(t),n=r,i=this.createEmptyKey();return{cs:this.initializeKey(i),ck:n,h:r}}hashProtocolName(e){if(e.length<=32){const t=kd(32);return t.set(e),t}return this.getHash(e,kd(0))}split(e){const[t,r]=this.crypto.getHKDF(e.ck,kd(0));return{cs1:this.initializeKey(t),cs2:this.initializeKey(r)}}writeMessageRegular(e,t){const r=this.encryptWithAd(e,kd(0),t);return{ne:this.createEmptyKey(),ns:kd(0),ciphertext:r}}readMessageRegular(e,t){return this.decryptWithAd(e,kd(0),t.ciphertext)}}class o_ extends s_{initializeInitiator(e,t,r,n){const i=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(i,e);return{ss:i,s:t,rs:r,psk:n,re:kd(32)}}initializeResponder(e,t,r,n){const i=this.initializeSymmetric("Noise_XX_25519_ChaChaPoly_SHA256");this.mixHash(i,e);return{ss:i,s:t,rs:r,psk:n,re:kd(32)}}writeMessageA(e,t,r){const n=kd(0);e.e=void 0!==r?r:this.crypto.generateX25519KeyPair();const i=e.e.publicKey;this.mixHash(e.ss,i);return{ne:i,ns:n,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageB(e,t){e.e=this.crypto.generateX25519KeyPair();const r=e.e.publicKey;this.mixHash(e.ss,r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const n=e.s.publicKey,i=this.encryptAndHash(e.ss,n);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));return{ne:r,ns:i,ciphertext:this.encryptAndHash(e.ss,t)}}writeMessageC(e,t){const r=e.s.publicKey,n=this.encryptAndHash(e.ss,r);this.mixKey(e.ss,this.dh(e.s.privateKey,e.re));const i=this.encryptAndHash(e.ss,t),s={ne:this.createEmptyKey(),ns:n,ciphertext:i},{cs1:o,cs2:a}=this.split(e.ss);return{h:e.ss.h,messageBuffer:s,cs1:o,cs2:a}}readMessageA(e,t){return r_(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),this.decryptAndHash(e.ss,t.ciphertext)}readMessageB(e,t){if(r_(t.ne)&&(e.re=t.ne),this.mixHash(e.ss,e.re),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.re));const{plaintext:r,valid:n}=this.decryptAndHash(e.ss,t.ns);n&&r_(r)&&(e.rs=r),this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:i,valid:s}=this.decryptAndHash(e.ss,t.ciphertext);return{plaintext:i,valid:n&&s}}readMessageC(e,t){const{plaintext:r,valid:n}=this.decryptAndHash(e.ss,t.ns);if(n&&r_(r)&&(e.rs=r),!e.e)throw new Error("Handshake state `e` param is missing.");this.mixKey(e.ss,this.dh(e.e.privateKey,e.rs));const{plaintext:i,valid:s}=this.decryptAndHash(e.ss,t.ciphertext),{cs1:o,cs2:a}=this.split(e.ss);return{h:e.ss.h,plaintext:i,valid:n&&s,cs1:o,cs2:a}}initSession(e,t,r){const n=this.createEmptyKey(),i=kd(32);let s;return s=e?this.initializeInitiator(t,r,i,n):this.initializeResponder(t,r,i,n),{hs:s,i:e,mc:0}}sendMessage(e,t,r){let n;if(0===e.mc)n=this.writeMessageA(e.hs,t,r);else if(1===e.mc)n=this.writeMessageB(e.hs,t);else if(2===e.mc){const{h:r,messageBuffer:i,cs1:s,cs2:o}=this.writeMessageC(e.hs,t);n=i,e.h=r,e.cs1=s,e.cs2=o}else{if(!(e.mc>2))throw new Error("Session invalid.");if(e.i){if(!e.cs1)throw new Error("CS1 (cipher state) is not defined");n=this.writeMessageRegular(e.cs1,t)}else{if(!e.cs2)throw new Error("CS2 (cipher state) is not defined");n=this.writeMessageRegular(e.cs2,t)}}return e.mc++,n}recvMessage(e,t){let r=kd(0),n=!1;if(0===e.mc)({plaintext:r,valid:n}=this.readMessageA(e.hs,t));else if(1===e.mc)({plaintext:r,valid:n}=this.readMessageB(e.hs,t));else if(2===e.mc){const{h:i,plaintext:s,valid:o,cs1:a,cs2:c}=this.readMessageC(e.hs,t);r=s,n=o,e.h=i,e.cs1=a,e.cs2=c}return e.mc++,{plaintext:r,valid:n}}}function a_(e,t){t.enabled&&Cd&&(e?(t(`LOCAL_PUBLIC_EPHEMERAL_KEY ${n_(e.publicKey,"hex")}`),t(`LOCAL_PRIVATE_EPHEMERAL_KEY ${n_(e.privateKey,"hex")}`)):t("Missing local ephemeral keys."))}function c_(e,t){t.enabled&&Cd&&t(`REMOTE_EPHEMERAL_PUBLIC_KEY ${n_(e.subarray(),"hex")}`)}class u_{isInitiator;session;remotePeer;remoteExtensions={webtransportCerthashes:[]};payload;connection;xx;staticKeypair;prologue;log;constructor(e,t,r,n,i,s,o,a,c){this.log=e.logger.forComponent("libp2p:noise:xxhandshake"),this.isInitiator=t,this.payload=r,this.prologue=n,this.staticKeypair=s,this.connection=o,a&&(this.remotePeer=a),this.xx=c??new o_(e,i),this.session=this.xx.initSession(this.isInitiator,this.prologue,this.staticKeypair)}async propose(){var e,t;if(e=this.session.hs.s,(t=this.log).enabled&&Cd&&(t(`LOCAL_STATIC_PUBLIC_KEY ${n_(e.publicKey,"hex")}`),t(`LOCAL_STATIC_PRIVATE_KEY ${n_(e.privateKey,"hex")}`)),this.isInitiator){this.log.trace("Stage 0 - Initiator starting to send first message.");const e=this.xx.sendMessage(this.session,kd(0));await this.connection.write(function(e){return new Zl(e.ne,e.ciphertext)}(e)),this.log.trace("Stage 0 - Initiator finished sending first message."),a_(this.session.hs.e,this.log)}else{this.log.trace("Stage 0 - Responder waiting to receive first message...");const e=function(e){if(e.length<32)throw new Error("Cannot decode stage 0 MessageBuffer: length less than 32 bytes.");return{ne:e.subarray(0,32),ciphertext:e.subarray(32,e.length),ns:kd(0)}}((await this.connection.read()).subarray()),{valid:t}=this.xx.recvMessage(this.session,e);if(!t)throw new Qp("xx handshake stage 0 validation fail");this.log.trace("Stage 0 - Responder received first message."),c_(this.session.hs.re,this.log)}}async exchange(){if(this.isInitiator){this.log.trace("Stage 1 - Initiator waiting to receive first message from responder...");const n=function(e){if(e.length<80)throw new Error("Cannot decode stage 1 MessageBuffer: length less than 80 bytes.");return{ne:e.subarray(0,32),ns:e.subarray(32,80),ciphertext:e.subarray(80,e.length)}}((await this.connection.read()).subarray()),{plaintext:i,valid:s}=this.xx.recvMessage(this.session,n);if(!s)throw new Qp("xx handshake stage 1 validation fail");this.log.trace("Stage 1 - Initiator received the message."),c_(this.session.hs.re,this.log),e=this.session.hs.rs,(t=this.log).enabled&&Cd&&t(`REMOTE_STATIC_PUBLIC_KEY ${n_(e.subarray(),"hex")}`),this.log.trace("Initiator going to check remote's signature...");try{const e=Zv(i);this.remotePeer=this.remotePeer||await Xv(e),await t_(this.session.hs.rs,e,this.remotePeer),this.setRemoteNoiseExtension(e.extensions)}catch(r){throw new Yp(`Error occurred while verifying signed payload: ${r.message}`)}this.log.trace("All good with the signature!")}else{this.log.trace("Stage 1 - Responder sending out first message with signed payload and static key.");const e=this.xx.sendMessage(this.session,this.payload);await this.connection.write(function(e){return new Zl(e.ne,e.ns,e.ciphertext)}(e)),this.log.trace("Stage 1 - Responder sent the second handshake message with signed payload."),a_(this.session.hs.e,this.log)}var e,t}async finish(){if(this.isInitiator){this.log.trace("Stage 2 - Initiator sending third handshake message.");const e=this.xx.sendMessage(this.session,this.payload);await this.connection.write(function(e){return new Zl(e.ns,e.ciphertext)}(e)),this.log.trace("Stage 2 - Initiator sent message with signed payload.")}else{this.log.trace("Stage 2 - Responder waiting for third handshake message...");const e=function(e){if(e.length<48)throw new Error("Cannot decode stage 2 MessageBuffer: length less than 48 bytes.");return{ne:kd(0),ns:e.subarray(0,48),ciphertext:e.subarray(48,e.length)}}((await this.connection.read()).subarray()),{plaintext:t,valid:n}=this.xx.recvMessage(this.session,e);if(!n)throw new Qp("xx handshake stage 2 validation fail");this.log.trace("Stage 2 - Responder received the message, finished handshake.");try{const e=Zv(t);this.remotePeer=this.remotePeer||await Xv(e),await t_(this.session.hs.rs,e,this.remotePeer),this.setRemoteNoiseExtension(e.extensions)}catch(r){throw new Yp(`Error occurred while verifying signed payload: ${r.message}`)}}var e,t;e=this.session,(t=this.log).enabled&&Cd&&(e.cs1&&e.cs2?(t(`CIPHER_STATE_1 ${e.cs1.n.getUint64()} ${n_(e.cs1.k,"hex")}`),t(`CIPHER_STATE_2 ${e.cs2.n.getUint64()} ${n_(e.cs2.k,"hex")}`)):t("Missing cipher state."))}encrypt(e,t){const r=this.getCS(t);return this.xx.encryptWithAd(r,kd(0),e)}decrypt(e,t,r){const n=this.getCS(t,!1);return this.xx.decryptWithAd(n,kd(0),e,r)}getRemoteStaticKey(){return this.session.hs.rs}getCS(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(!e.cs1||!e.cs2)throw new Qp("Handshake not completed properly, cipher state does not exist.");return this.isInitiator?t?e.cs1:e.cs2:t?e.cs2:e.cs1}setRemoteNoiseExtension(e){e&&(this.remoteExtensions=e)}}class l_{protocol="/noise";crypto;prologue;staticKeys;extensions;metrics;components;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{staticNoiseKey:r,extensions:n,crypto:i,prologueBytes:s}=t,{metrics:o}=e;this.components=e,this.crypto=i??jp,this.extensions=n,this.metrics=o?function(e){return{xxHandshakeSuccesses:e.registerCounter("libp2p_noise_xxhandshake_successes_total",{help:"Total count of noise xxHandshakes successes_"}),xxHandshakeErrors:e.registerCounter("libp2p_noise_xxhandshake_error_total",{help:"Total count of noise xxHandshakes errors"}),encryptedPackets:e.registerCounter("libp2p_noise_encrypted_packets_total",{help:"Total count of noise encrypted packets successfully"}),decryptedPackets:e.registerCounter("libp2p_noise_decrypted_packets_total",{help:"Total count of noise decrypted packets"}),decryptErrors:e.registerCounter("libp2p_noise_decrypt_errors_total",{help:"Total count of noise decrypt errors"})}}(o):void 0,this.staticKeys=r?this.crypto.generateX25519KeyPairFromSeed(r):this.crypto.generateX25519KeyPair(),this.prologue=s??kd(0)}async secureOutbound(e,t,r){const n=Sd(t,{lengthEncoder:Gp,lengthDecoder:Wp,maxDataLength:Id}),i=await this.performHandshake({connection:n,isInitiator:!0,localPeer:e,remotePeer:r}),s=await this.createSecureConnection(n,i);return t.source=s.source,t.sink=s.sink,{conn:t,remoteExtensions:i.remoteExtensions,remotePeer:i.remotePeer}}async secureInbound(e,t,r){const n=Sd(t,{lengthEncoder:Gp,lengthDecoder:Wp,maxDataLength:Id}),i=await this.performHandshake({connection:n,isInitiator:!1,localPeer:e,remotePeer:r}),s=await this.createSecureConnection(n,i);return t.source=s.source,t.sink=s.sink,{conn:t,remotePeer:i.remotePeer,remoteExtensions:i.remoteExtensions}}async performHandshake(e){const t=await Jv(e.localPeer,this.staticKeys.publicKey,this.extensions);return this.performXXHandshake(e,t)}async performXXHandshake(e,t){const{isInitiator:r,remotePeer:n,connection:i}=e,s=new u_(this.components,r,t,this.prologue,this.crypto,this.staticKeys,i,n);try{await s.propose(),await s.exchange(),await s.finish(),this.metrics?.xxHandshakeSuccesses.increment()}catch(o){if(this.metrics?.xxHandshakeErrors.increment(),o instanceof Error)throw o.message=`Error occurred during XX handshake: ${o.message}`,o}return s}async createSecureConnection(e,t){const[r,n]=function(){const e=Ad(),t=Ad();return[{source:e.source,sink:t.sink},{source:t.source,sink:e.sink}]}(),i=e.unwrap();return await ph(r,function(e,t){return async function*(r){for await(const n of r)for(let r=0;r<n.length;r+=65519){let i,s=r+65519;s>n.length&&(s=n.length),i=n instanceof Uint8Array?e.encrypt(n.subarray(r,s),e.session):e.encrypt(n.sublist(r,s),e.session),t?.encryptedPackets.increment(),yield new Zl(Gp(i.byteLength),i)}}}(t,this.metrics),i,(e=>oh(e,{lengthDecoder:Wp})),function(e,t){return async function*(r){for await(const n of r)for(let r=0;r<n.length;r+=Id){let i=r+Id;if(i>n.length&&(i=n.length),i-16<r)throw new Error("Invalid chunk");const s=n.sublist(r,i),o=n.subarray(r,i-16),{plaintext:a,valid:c}=e.decrypt(s,e.session,o);if(!c)throw t?.decryptErrors.increment(),new Error("Failed to validate decrypted chunk");t?.decryptedPackets.increment(),yield a}}}(t,this.metrics),r),n}}function h_(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new l_(t,e)}const d_=Symbol.for("@libp2p/peer-discovery");new Uint8Array(0);function f_(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var p_=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const g_=p_;class b_{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class y_{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return w_(this,e)}}class m_{decoders;constructor(e){this.decoders=e}or(e){return w_(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function w_(e,t){return new m_({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class v_{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new b_(e,t,r),this.decoder=new y_(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function __(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new v_(t,r,n,i)}function E_(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=g_(n,t);return __({prefix:r,name:t,encode:i,decode:e=>f_(s(e))})}function S_(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return __({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const A_=E_({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),k_=E_({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),x_=E_({prefix:"9",name:"base10",alphabet:"0123456789"}),I_=S_({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),C_=S_({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),T_=S_({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),R_=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),P_=R_.reduce(((e,t,r)=>(e[r]=t,e)),[]),D_=R_.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const N_=__({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=P_[t]),"")},decode:function(e){const t=[];for(const r of e){const e=D_[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),B_=S_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),U_=S_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),L_=S_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),M_=S_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),O_=S_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),q_=S_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),K_=S_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),F_=S_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),V_=S_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),z_=E_({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$_=E_({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),H_=S_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j_=S_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),G_=S_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),W_=S_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Y_=S_({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Q_=__({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),J_=new TextEncoder,X_=new TextDecoder,Z_="json",eE=512;function tE(e){return J_.encode(JSON.stringify(e))}function rE(e){return JSON.parse(X_.decode(e))}const nE="raw",iE=85;function sE(e){return f_(e)}function oE(e){return f_(e)}var aE=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=lE;)r[n++]=255&t|cE,t/=128;for(;t&uE;)r[n++]=255&t|cE,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},cE=128,uE=-128,lE=Math.pow(2,31);var hE=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&fE)<<s:(n&fE)*Math.pow(2,s),s+=7}while(n>=dE);return e.bytes=o-r,i},dE=128,fE=127;var pE=Math.pow(2,7),gE=Math.pow(2,14),bE=Math.pow(2,21),yE=Math.pow(2,28),mE=Math.pow(2,35),wE=Math.pow(2,42),vE=Math.pow(2,49),_E=Math.pow(2,56),EE=Math.pow(2,63);const SE={encode:aE,decode:hE,encodingLength:function(e){return e<pE?1:e<gE?2:e<bE?3:e<yE?4:e<mE?5:e<wE?6:e<vE?7:e<_E?8:e<EE?9:10}};function AE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[SE.decode(e,t),SE.decode.bytes]}function kE(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return SE.encode(e,t,r),t}function xE(e){return SE.encodingLength(e)}function IE(e,t){const r=t.byteLength,n=xE(e),i=n+xE(r),s=new Uint8Array(i+r);return kE(e,s,0),kE(r,s,n),s.set(t,i),new TE(e,r,t,s)}function CE(e){const t=f_(e),[r,n]=AE(t),[i,s]=AE(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new TE(r,i,o,t)}class TE{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const RE=f_;const PE={code:0,name:"identity",encode:RE,digest:function(e){return IE(0,RE(e))}};function DE(e){let{name:t,code:r,encode:n}=e;return new NE(t,r,n)}class NE{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?IE(this.code,t):t.then((e=>IE(this.code,e)))}throw Error("Unknown type, must be binary type")}}function BE(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const UE=DE({name:"sha2-256",code:18,encode:BE("SHA-256")}),LE=DE({name:"sha2-512",code:19,encode:BE("SHA-512")});function ME(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==A_.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,qE(e),t??A_.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,qE(e),t??B_.encoder)}const OE=new WeakMap;function qE(e){const t=OE.get(e);if(null==t){const t=new Map;return OE.set(e,t),t}return t}class KE{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==FE)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==VE)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return KE.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:{const{code:e,digest:t}=this.multihash,r=IE(e,t);return KE.createV1(this.code,r)}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 KE.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return ME(this,e)}toJSON(){return{"/":ME(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof KE)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new KE(e,r,n,i??zE(e,r,n.bytes))}if(!0===t[$E]){const{version:e,multihash:r,code:n}=t,i=CE(r);return KE.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==FE)throw new Error(`Version 0 CID must use dag-pb (code: ${FE}) block encoding`);return new KE(e,t,r,r.bytes);case 1:{const n=zE(e,t,r.bytes);return new KE(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return KE.create(0,FE,e)}static createV1(e,t){return KE.create(1,e,t)}static decode(e){const[t,r]=KE.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=KE.inspectBytes(e),r=t.size-t.multihashSize,n=f_(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new TE(t.multihashCode,t.digestSize,i,n);return[0===t.version?KE.createV0(s):KE.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=AE(e.subarray(t));return t+=n,r};let n=r(),i=FE;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??A_;return[A_.prefix,r.decode(`${A_.prefix}${e}`)]}case A_.prefix:{const r=t??A_;return[A_.prefix,r.decode(e)]}case B_.prefix:{const r=t??B_;return[B_.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=KE.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return qE(i).set(r,e),i}}const FE=112,VE=18;function zE(e,t,r){const n=xE(e),i=n+xE(t),s=new Uint8Array(i+r.byteLength);return kE(e,s,0),kE(t,s,n),s.set(r,i),s}const $E=Symbol.for("@ipld/js-cid/CID"),HE={...ge,...ue,...pe,...ae,...ce,...he,...de,...oe,...fe,...le};function jE(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const GE=Symbol.for("nodejs.util.inspect.custom"),WE=Object.values(HE).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),HE.identity.decoder),YE=114,QE=36,JE=37;class XE{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=A_.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return KE.createV1(YE,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return jE(this.multihash.bytes,e);if("string"===typeof e)return rS(e).equals(this);if(null!=e?.multihash?.bytes)return jE(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[GE](){return`PeerId(${this.toString()})`}}class ZE extends XE{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class eS extends XE{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class tS extends XE{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function rS(e,t){if(t=t??WE,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=CE(A_.decode(`z${e}`));return e.startsWith("12D")?new eS({multihash:t}):e.startsWith("16U")?new tS({multihash:t}):new ZE({multihash:t})}return function(e){try{const t=CE(e);if(t.code===PE.code){if(t.digest.length===QE)return new eS({multihash:t});if(t.digest.length===JE)return new tS({multihash:t})}if(t.code===UE.code)return new ZE({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==YE)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===UE.code)return new ZE({multihash:e.multihash});if(t.code===PE.code){if(t.digest.length===QE)return new eS({multihash:e.multihash});if(t.digest.length===JE)return new tS({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(KE.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(WE.decode(e))}Error;class nS extends Error{code;props;constructor(e,t,r){super(e),this.code=t,this.name=r?.name??"CodeError",this.props=r??{}}}var iS=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const sS=iS,oS=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")});class aS{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class cS{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return lS(this,e)}}class uS{constructor(e){this.decoders=e}or(e){return lS(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const lS=(e,t)=>new uS({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class hS{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new aS(e,t,r),this.decoder=new cS(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const dS=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new hS(t,r,n,i)},fS=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:s}=sS(n,r);return dS({prefix:t,name:r,encode:i,decode:e=>oS(s(e))})},pS=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return dS({prefix:r,name:t,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,i,n),decode:e=>((e,t,r,n)=>{const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(e,i,n,t)})},gS=fS({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),bS=fS({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),yS=pS({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mS=pS({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wS=pS({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vS=pS({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_S=pS({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),ES=pS({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),SS=pS({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),AS=pS({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kS=pS({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xS=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=TS;)r[n++]=255&t|IS,t/=128;for(;t&CS;)r[n++]=255&t|IS,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},IS=128,CS=-128,TS=Math.pow(2,31);var RS=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&DS)<<s:(n&DS)*Math.pow(2,s),s+=7}while(n>=PS);return e.bytes=o-r,i},PS=128,DS=127;var NS=Math.pow(2,7),BS=Math.pow(2,14),US=Math.pow(2,21),LS=Math.pow(2,28),MS=Math.pow(2,35),OS=Math.pow(2,42),qS=Math.pow(2,49),KS=Math.pow(2,56),FS=Math.pow(2,63);const VS={encode:xS,decode:RS,encodingLength:function(e){return e<NS?1:e<BS?2:e<US?3:e<LS?4:e<MS?5:e<OS?6:e<qS?7:e<KS?8:e<FS?9:10}},zS=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[VS.decode(e,t),VS.decode.bytes]},$S=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return VS.encode(e,t,r),t},HS=e=>VS.encodingLength(e),jS=(e,t)=>{const r=t.byteLength,n=HS(e),i=n+HS(r),s=new Uint8Array(i+r);return $S(e,s,0),$S(r,s,n),s.set(t,i),new WS(e,r,t,s)},GS=e=>{const t=oS(e),[r,n]=zS(t),[i,s]=zS(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new WS(r,i,o,t)};class WS{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const YS=(e,t)=>{const{bytes:r,version:n}=e;return 0===n?eA(r,JS(e),t||gS.encoder):tA(r,JS(e),t||yS.encoder)},QS=new WeakMap,JS=e=>{const t=QS.get(e);if(null==t){const t=new Map;return QS.set(e,t),t}return t};class XS{constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==rA)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==nA)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return XS.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:{const{code:e,digest:t}=this.multihash,r=jS(e,t);return XS.createV1(this.code,r)}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 XS.equals(this,e)}static equals(e,t){const r=t;return r&&e.code===r.code&&e.version===r.version&&((e,t)=>{if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&((e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0})(e.bytes,r.bytes)}})(e.multihash,r.multihash)}toString(e){return YS(this,e)}toJSON(){return{"/":YS(this)}}link(){return this}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof XS)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new XS(e,r,n,i||iA(e,r,n.bytes))}if(!0===t[sA]){const{version:e,multihash:r,code:n}=t,i=GS(r);return XS.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==rA)throw new Error(`Version 0 CID must use dag-pb (code: ${rA}) block encoding`);return new XS(e,t,r,r.bytes);case 1:{const n=iA(e,t,r.bytes);return new XS(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return XS.create(0,rA,e)}static createV1(e,t){return XS.create(1,e,t)}static decode(e){const[t,r]=XS.decodeFirst(e);if(r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=XS.inspectBytes(e),r=t.size-t.multihashSize,n=oS(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new WS(t.multihashCode,t.digestSize,i,n);return[0===t.version?XS.createV0(s):XS.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=zS(e.subarray(t));return t+=n,r};let n=r(),i=rA;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=ZS(e,t),i=XS.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return JS(i).set(r,e),i}}const ZS=(e,t)=>{switch(e[0]){case"Q":{const r=t||gS;return[gS.prefix,r.decode(`${gS.prefix}${e}`)]}case gS.prefix:{const r=t||gS;return[gS.prefix,r.decode(e)]}case yS.prefix:{const r=t||yS;return[yS.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}},eA=(e,t,r)=>{const{prefix:n}=r;if(n!==gS.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i},tA=(e,t,r)=>{const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i},rA=112,nA=18,iA=(e,t,r)=>{const n=HS(e),i=n+HS(t),s=new Uint8Array(i+r.byteLength);return $S(e,s,0),$S(t,s,n),s.set(r,i),s},sA=Symbol.for("@ipld/js-cid/CID");var oA=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const aA=oA,cA=(new Uint8Array(0),e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")});class uA{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class lA{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return dA(this,e)}}class hA{constructor(e){this.decoders=e}or(e){return dA(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const dA=(e,t)=>new hA({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class fA{constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new uA(e,t,r),this.decoder=new lA(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pA=e=>{let{name:t,prefix:r,encode:n,decode:i}=e;return new fA(t,r,n,i)},gA=e=>{let{prefix:t,name:r,alphabet:n}=e;const{encode:i,decode:s}=aA(n,r);return pA({prefix:t,name:r,encode:i,decode:e=>cA(s(e))})},bA=e=>{let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return pA({prefix:r,name:t,encode:e=>((e,t,r)=>{const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s})(e,i,n),decode:e=>((e,t,r,n)=>{const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(e,i,n,t)})},yA=gA({prefix:"9",name:"base10",alphabet:"0123456789"}),mA=bA({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),wA=bA({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),vA=bA({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),_A=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),EA=_A.reduce(((e,t,r)=>(e[r]=t,e)),[]),SA=_A.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const AA=pA({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=EA[t]),"")},decode:function(e){const t=[];for(const r of e){const e=SA[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),kA=bA({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),xA=bA({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),IA=bA({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),CA=bA({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),TA=bA({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),RA=bA({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),PA=bA({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),DA=bA({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),NA=bA({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),BA=gA({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),UA=gA({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),LA=gA({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),MA=gA({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),OA=bA({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qA=bA({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),KA=bA({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),FA=bA({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),VA=bA({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),zA=pA({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),$A=new TextEncoder,HA=new TextDecoder,jA="json",GA=512,WA=e=>$A.encode(JSON.stringify(e)),YA=e=>JSON.parse(HA.decode(e)),QA="raw",JA=85,XA=e=>cA(e),ZA=e=>cA(e);var ek=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=nk;)r[n++]=255&t|tk,t/=128;for(;t&rk;)r[n++]=255&t|tk,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},tk=128,rk=-128,nk=Math.pow(2,31);var ik=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&ok)<<s:(n&ok)*Math.pow(2,s),s+=7}while(n>=sk);return e.bytes=o-r,i},sk=128,ok=127;var ak=Math.pow(2,7),ck=Math.pow(2,14),uk=Math.pow(2,21),lk=Math.pow(2,28),hk=Math.pow(2,35),dk=Math.pow(2,42),fk=Math.pow(2,49),pk=Math.pow(2,56),gk=Math.pow(2,63);const bk={encode:ek,decode:ik,encodingLength:function(e){return e<ak?1:e<ck?2:e<uk?3:e<lk?4:e<hk?5:e<dk?6:e<fk?7:e<pk?8:e<gk?9:10}},yk=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return bk.encode(e,t,r),t},mk=e=>bk.encodingLength(e),wk=(e,t)=>{const r=t.byteLength,n=mk(e),i=n+mk(r),s=new Uint8Array(i+r);return yk(e,s,0),yk(r,s,n),s.set(t,i),new vk(e,r,t,s)};class vk{constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const _k=cA,Ek={code:0,name:"identity",encode:_k,digest:e=>wk(0,_k(e))},Sk=e=>{let{name:t,code:r,encode:n}=e;return new Ak(t,r,n)};class Ak{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?wk(this.code,t):t.then((e=>wk(this.code,e)))}throw Error("Unknown type, must be binary type")}}const kk=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),xk=Sk({name:"sha2-256",code:18,encode:kk("SHA-256")}),Ik=Sk({name:"sha2-512",code:19,encode:kk("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Ck={...Pe,...Ae,...Re,...Ee,...Se,...xe,...Ie,...Ce,...Te,...ke};function Tk(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Rk(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return null!=globalThis.Buffer?.allocUnsafe?Tk(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Pk(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Dk=Pk("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Nk=Pk("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Rk((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Bk={utf8:Dk,"utf-8":Dk,hex:Ck.base16,latin1:Nk,ascii:Nk,binary:Nk,...Ck};function Uk(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Bk[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.encoder.encode(e).substring(1):globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8")}function Lk(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=Rk(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return Tk(r)}var Mk=__webpack_require__(1870);const Ok=45,qk=15,Kk=new class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){const t=this.index,r=e();return void 0===r&&(this.index=t),r}parseWith(e){const t=e();if(this.index===this.input.length)return t}peekChar(){if(!(this.index>=this.input.length))return this.input[this.index]}readChar(){if(!(this.index>=this.input.length))return this.input[this.index++]}readGivenChar(e){return this.readAtomically((()=>{const t=this.readChar();if(t===e)return t}))}readSeparator(e,t,r){return this.readAtomically((()=>{if(!(t>0&&void 0===this.readGivenChar(e)))return r()}))}readNumber(e,t,r,n){return this.readAtomically((()=>{let i=0,s=0;const o=this.peekChar();if(void 0===o)return;const a="0"===o,c=2**(8*n)-1;for(;;){const r=this.readAtomically((()=>{const t=this.readChar();if(void 0===t)return;const r=Number.parseInt(t,e);return Number.isNaN(r)?void 0:r}));if(void 0===r)break;if(i*=e,i+=r,i>c)return;if(s+=1,void 0!==t&&s>t)return}return 0===s||!r&&a&&s>1?void 0:i}))}readIPv4Addr(){return this.readAtomically((()=>{const e=new Uint8Array(4);for(let t=0;t<e.length;t++){const r=this.readSeparator(".",t,(()=>this.readNumber(10,3,!1,1)));if(void 0===r)return;e[t]=r}return e}))}readIPv6Addr(){const e=e=>{for(let t=0;t<e.length/2;t++){const r=2*t;if(t<e.length-3){const n=this.readSeparator(":",t,(()=>this.readIPv4Addr()));if(void 0!==n)return e[r]=n[0],e[r+1]=n[1],e[r+2]=n[2],e[r+3]=n[3],[r+4,!0]}const n=this.readSeparator(":",t,(()=>this.readNumber(16,4,!0,2)));if(void 0===n)return[r,!1];e[r]=n>>8,e[r+1]=255&n}return[e.length,!1]};return this.readAtomically((()=>{const t=new Uint8Array(16),[r,n]=e(t);if(16===r)return t;if(n)return;if(void 0===this.readGivenChar(":"))return;if(void 0===this.readGivenChar(":"))return;const i=new Uint8Array(14),s=16-(r+2),[o]=e(i.subarray(0,s));return t.set(i.subarray(0,o),16-o),t}))}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};parseInt("0xFFFF",16),new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);const Fk=fS({prefix:"9",name:"base10",alphabet:"0123456789"}),Vk=pS({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zk=pS({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),$k=pS({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Hk=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),jk=Hk.reduce(((e,t,r)=>(e[r]=t,e)),[]),Gk=Hk.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Wk=dS({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=jk[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Gk[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),Yk=fS({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Qk=fS({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Jk=pS({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Xk=pS({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zk=pS({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ex=pS({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),tx=pS({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),rx=dS({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>(e=>(new TextEncoder).encode(e))(e)}),nx=new TextEncoder,ix=new TextDecoder,sx="json",ox=512,ax=e=>nx.encode(JSON.stringify(e)),cx=e=>JSON.parse(ix.decode(e)),ux="raw",lx=85,hx=e=>oS(e),dx=e=>oS(e),fx=oS,px={code:0,name:"identity",encode:fx,digest:e=>jS(0,fx(e))},gx=e=>{let{name:t,code:r,encode:n}=e;return new bx(t,r,n)};class bx{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?jS(this.code,t):t.then((e=>jS(this.code,e)))}throw Error("Unknown type, must be binary type")}}const yx=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),mx=gx({name:"sha2-256",code:18,encode:yx("SHA-256")}),wx=gx({name:"sha2-512",code:19,encode:yx("SHA-512")}),vx={...ze,...Oe,...Ve,...Le,...Me,..._e,...Ke,...ve,...Fe,...qe};function _x(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Bk[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):Tk(globalThis.Buffer.from(e,"utf-8"))}function Ex(e){return Boolean(function(e){if(!(e.length>qk))return Kk.new(e).parseWith((()=>Kk.readIPv4Addr()))}(e))}function Sx(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Ok))return Kk.new(e).parseWith((()=>Kk.readIPv6Addr()))}(e))}function Ax(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>Ok))return Kk.new(e).parseWith((()=>Kk.readIPAddr()))}(e))}const kx=Ex,xx=Sx,Ix=function(e){let t=0;if(e=e.toString().trim(),kx(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(xx(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;kx(r[n])&&(e=Ix(r[n]),r[n]=Uk(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,Uk(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},Cx=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(4===r){const n=[];for(let i=0;i<r;i++)n.push(e[t+i]);return n.join(".")}if(16===r){const e=[];for(let i=0;i<r;i+=2)e.push(n.getUint16(t+i).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},Tx=-1,Rx={},Px={};function Dx(e){if("number"===typeof e){if(null!=Px[e])return Px[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=Rx[e])return Rx[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,Tx,"ip6zone"],[43,8,"ipcidr"],[53,Tx,"dns",!0],[54,Tx,"dns4",!0],[55,Tx,"dns6",!0],[56,Tx,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,Tx,"unix",!1,!0],[421,Tx,"ipfs"],[421,Tx,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,Tx,"garlic64"],[448,0,"tls"],[449,Tx,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,Tx,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,Tx,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);Px[t.code]=t,Rx[t.name]=t}));Dx("ip4"),Dx("ip6"),Dx("ipcidr");function Nx(e,t){switch(Dx(e).code){case 4:case 41:return function(e){const t=Cx(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Ax(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Fx(t);case 6:case 273:case 33:case 132:return qx(t).toString();case 421:return function(e){const t=Mk.decode(e),r=e.slice(Mk.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return Uk(r,"base58btc")}(t);case 444:case 445:return Vx(t);case 466:return function(e){const t=Mk.decode(e),r=e.slice(Mk.decode.bytes);if(r.length!==t)throw new Error("inconsistent lengths");return"u"+Uk(r,"base64url")}(t);default:return Uk(t,"base16")}}function Bx(e,t){switch(Dx(e).code){case 4:case 41:return Mx(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return Kx(t);case 6:case 273:case 33:case 132:return Ox(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?GS(gS.decode(`z${e}`)).bytes:XS.parse(e).multihash.bytes;const r=Uint8Array.from(Mk.encode(t.length));return Lk([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(16!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=yS.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=Ox(n);return Lk([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(56!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=yS.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=Ox(n);return Lk([r,i],r.length+i.length)}(t);case 466:return function(e){const t=Lx.decode(e),r=Uint8Array.from(Mk.encode(t.length));return Lk([r,t],r.length+t.length)}(t);default:return _x(t,"base16")}}const Ux=Object.values(vx).map((e=>e.decoder)),Lx=function(){let e=Ux[0].or(Ux[1]);return Ux.slice(2).forEach((t=>e=e.or(t))),e}();function Mx(e){if(!Ax(e))throw new Error("invalid ip address");return Ix(e)}function Ox(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function qx(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function Kx(e){const t=_x(e),r=Uint8Array.from(Mk.encode(t.length));return Lk([r,t],r.length+t.length)}function Fx(e){const t=Mk.decode(e);if((e=e.slice(Mk.decode.bytes)).length!==t)throw new Error("inconsistent lengths");return Uk(e)}function Vx(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return`${Uk(t,"base32")}:${qx(r)}`}function zx(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const s=Mk.decode(e,i),o=Mk.decode.bytes??0,a=Dx(s),c=jx(a,e.slice(i+o));if(0===c){t.push([s]),r.push([s]),i+=o;continue}const u=e.slice(i+o,i+o+c);if(i+=c+o,i>e.length)throw Wx("Invalid address Uint8Array: "+Uk(e,"base16"));t.push([s,u]);const l=Nx(s,u);if(r.push([s,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:$x(r),tuples:t,stringTuples:r,path:n}}function $x(e){const t=[];return e.map((e=>{const r=Dx(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),Gx(t.join("/"))}function Hx(e){return Lk(e.map((e=>{const t=Dx(e[0]);let r=Uint8Array.from(Mk.encode(t.code));return e.length>1&&null!=e[1]&&(r=Lk([r,e[1]])),r})))}function jx(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;return Mk.decode(t)+(Mk.decode.bytes??0)}function Gx(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function Wx(e){return new Error("Error parsing address: "+e)}const Yx=Symbol.for("nodejs.util.inspect.custom"),Qx=[Dx("dns").code,Dx("dns4").code,Dx("dns6").code,Dx("dnsaddr").code],Jx=new Map,Xx=Symbol.for("@multiformats/js-multiaddr/multiaddr");function Zx(e){return Boolean(e?.[Xx])}class eI{bytes;#t;#r;#n;#i;[Xx]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=zx(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);t=function(e){const t=[],r=[];let n=null;const i=(e=Gx(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){const o=Dx(i[s]);if(0===o.size){t.push([o.code]),r.push([o.code]);continue}if(s++,s>=i.length)throw Wx("invalid address: "+e);if(!0===o.path){n=Gx(i.slice(s).join("/")),t.push([o.code,Bx(o.code,n)]),r.push([o.code,n]);break}const a=Bx(o.code,i[s]);t.push([o.code,a]),r.push([o.code,Nx(o.code,a)])}return{string:$x(r),bytes:Hx(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!Zx(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=zx(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#r=t.tuples,this.#n=t.stringTuples,this.#i=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const s=Dx("tcp"),o=Dx("udp"),a=Dx("ip4"),c=Dx("ip6"),u=Dx("dns6"),l=Dx("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i=`%${d??""}`),Qx.includes(h)&&(t=s.name,n=443,r=`${d??""}${i}`,e=h===u.code?6:4),h!==s.code&&h!==o.code||(t=Dx(h).name,n=parseInt(d??"")),h!==a.code&&h!==c.code||(t=Dx(h).name,r=`${d??""}${i}`,e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return this.#r.map((e=>{let[t]=e;return Object.assign({},Dx(t))}))}protoCodes(){return this.#r.map((e=>{let[t]=e;return t}))}protoNames(){return this.#r.map((e=>{let[t]=e;return Dx(t).name}))}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new eI(e),new eI(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new eI(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new eI(Hx(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===Rx.p2p.code&&e.push([r,n]),r===Rx["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?Uk(gS.decode(`z${e}`),"base58btc"):Uk(XS.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#i}equals(e){return function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=Jx.get(t.name);if(null==r)throw new nS(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>new eI(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(e??this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[Yx](){return`Multiaddr(${this.#t})`}}function tI(e){return new eI(e)}const rI=NI("dns4"),nI=NI("dns6"),iI=NI("dnsaddr"),sI=DI(NI("dns"),iI,rI,nI),oI=DI(NI("ip4"),NI("ip6")),aI=DI(PI(oI,NI("tcp")),PI(sI,NI("tcp"))),cI=PI(oI,NI("udp")),uI=PI(cI,NI("utp")),lI=PI(cI,NI("quic")),hI=PI(cI,NI("quic-v1")),dI=DI(PI(aI,NI("ws")),PI(sI,NI("ws"))),fI=DI(PI(dI,NI("p2p")),dI),pI=DI(PI(aI,NI("wss")),PI(sI,NI("wss")),PI(aI,NI("tls"),NI("ws")),PI(sI,NI("tls"),NI("ws"))),gI=DI(PI(pI,NI("p2p")),pI),bI=DI(PI(aI,NI("http")),PI(oI,NI("http")),PI(sI,NI("http"))),yI=DI(PI(aI,NI("https")),PI(oI,NI("https")),PI(sI,NI("https"))),mI=PI(cI,NI("webrtc-direct"),NI("certhash")),wI=DI(PI(mI,NI("p2p")),mI),vI=PI(hI,NI("webtransport"),NI("certhash"),NI("certhash")),_I=DI(PI(vI,NI("p2p")),vI),EI=DI(PI(fI,NI("p2p-webrtc-star"),NI("p2p")),PI(gI,NI("p2p-webrtc-star"),NI("p2p")),PI(fI,NI("p2p-webrtc-star")),PI(gI,NI("p2p-webrtc-star"))),SI=(DI(PI(fI,NI("p2p-websocket-star"),NI("p2p")),PI(gI,NI("p2p-websocket-star"),NI("p2p")),PI(fI,NI("p2p-websocket-star")),PI(gI,NI("p2p-websocket-star"))),DI(PI(bI,NI("p2p-webrtc-direct"),NI("p2p")),PI(yI,NI("p2p-webrtc-direct"),NI("p2p")),PI(bI,NI("p2p-webrtc-direct")),PI(yI,NI("p2p-webrtc-direct")))),AI=DI(dI,pI,bI,yI,EI,SI,aI,uI,lI,sI,wI,_I),kI=(DI(PI(AI,NI("p2p-stardust"),NI("p2p")),PI(AI,NI("p2p-stardust"))),DI(PI(AI,NI("p2p")),EI,SI,wI,_I,NI("p2p"))),xI=DI(PI(kI,NI("p2p-circuit"),kI),PI(kI,NI("p2p-circuit")),PI(NI("p2p-circuit"),kI),PI(AI,NI("p2p-circuit")),PI(NI("p2p-circuit"),AI),NI("p2p-circuit")),II=()=>DI(PI(xI,II),xI),CI=II(),TI=DI(PI(CI,kI,CI),PI(kI,CI),PI(CI,kI),CI,kI);DI(PI(CI,NI("webrtc"),NI("p2p")),PI(CI,NI("webrtc")),PI(AI,NI("webrtc"),NI("p2p")),PI(AI,NI("webrtc")),NI("webrtc"));function RI(e){return function(t){let r;try{r=tI(t)}catch(i){return!1}const n=e(r.protoNames());return null!==n&&(!0===n||!1===n?n:0===n.length)}}function PI(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];function n(e){if(e.length<t.length)return null;let r=e;return t.some((t=>(r="function"===typeof t?t().partialMatch(e):t.partialMatch(e),Array.isArray(r)&&(e=r),null===r))),r}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:RI(n),partialMatch:n}}function DI(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];function n(e){let r=null;return t.some((t=>{const n="function"===typeof t?t().partialMatch(e):t.partialMatch(e);return null!=n&&(r=n,!0)})),r}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:RI(n),partialMatch:n}}function NI(e){const t=e;return{toString:function(){return t},matches:function(e){let r;try{r=tI(e)}catch(i){return!1}const n=r.protoNames();return 1===n.length&&n[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}function BI(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function UI(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const LI=UI("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),MI=UI("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=BI((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),OI={utf8:LI,"utf-8":LI,hex:HE.base16,latin1:MI,ascii:MI,binary:MI,...HE};function qI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=OI[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function KI(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=BI(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function FI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=OI[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}const VI=Ex,zI=Sx,$I=function(e){let t=0;if(e=e.toString().trim(),VI(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(zI(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;VI(r[n])&&(e=$I(r[n]),r[n]=qI(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,qI(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},HI=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(4===r){const n=[];for(let i=0;i<r;i++)n.push(e[t+i]);return n.join(".")}if(16===r){const e=[];for(let i=0;i<r;i+=2)e.push(n.getUint16(t+i).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},jI=-1,GI={},WI={};function YI(e){if("number"===typeof e){if(null!=WI[e])return WI[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=GI[e])return GI[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,jI,"ip6zone"],[43,8,"ipcidr"],[53,jI,"dns",!0],[54,jI,"dns4",!0],[55,jI,"dns6",!0],[56,jI,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,jI,"unix",!1,!0],[421,jI,"ipfs"],[421,jI,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,jI,"garlic64"],[448,0,"tls"],[449,jI,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,jI,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,jI,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);WI[t.code]=t,GI[t.name]=t}));YI("ip4"),YI("ip6"),YI("ipcidr");function QI(e,t){switch(YI(e).code){case 4:case 41:return function(e){const t=HI(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Ax(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return iC(t);case 6:case 273:case 33:case 132:return rC(t).toString();case 421:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return qI(r,"base58btc")}(t);case 444:case 445:return sC(t);case 466:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+qI(r,"base64url")}(t);default:return qI(t,"base16")}}function JI(e,t){switch(YI(e).code){case 4:case 41:return eC(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return nC(t);case 6:case 273:case 33:case 132:return tC(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?CE(A_.decode(`z${e}`)).bytes:KE.parse(e).multihash.bytes;const r=Uint8Array.from(ms(t.length));return KI([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(16!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=B_.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=tC(n);return KI([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(56!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=B_.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=tC(n);return KI([r,i],r.length+i.length)}(t);case 466:return function(e){const t=ZI.decode(e),r=Uint8Array.from(ms(t.length));return KI([r,t],r.length+t.length)}(t);default:return FI(t,"base16")}}const XI=Object.values(HE).map((e=>e.decoder)),ZI=function(){let e=XI[0].or(XI[1]);return XI.slice(2).forEach((t=>e=e.or(t))),e}();function eC(e){if(!Ax(e))throw new Error("invalid ip address");return $I(e)}function tC(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function rC(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function nC(e){const t=FI(e),r=Uint8Array.from(ms(t.length));return KI([r,t],r.length+t.length)}function iC(e){const t=ws(e);if((e=e.slice(gs(t))).length!==t)throw new Error("inconsistent lengths");return qI(e)}function sC(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return`${qI(t,"base32")}:${rC(r)}`}function oC(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const s=ws(e,i),o=gs(s),a=YI(s),c=uC(a,e.slice(i+o));if(0===c){t.push([s]),r.push([s]),i+=o;continue}const u=e.slice(i+o,i+o+c);if(i+=c+o,i>e.length)throw hC("Invalid address Uint8Array: "+qI(e,"base16"));t.push([s,u]);const l=QI(s,u);if(r.push([s,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:aC(r),tuples:t,stringTuples:r,path:n}}function aC(e){const t=[];return e.map((e=>{const r=YI(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),lC(t.join("/"))}function cC(e){return KI(e.map((e=>{const t=YI(e[0]);let r=Uint8Array.from(ms(t.code));return e.length>1&&null!=e[1]&&(r=KI([r,e[1]])),r})))}function uC(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=ws(t instanceof Uint8Array?t:Uint8Array.from(t));return e+gs(e)}}function lC(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function hC(e){return new Error("Error parsing address: "+e)}const dC=Symbol.for("nodejs.util.inspect.custom"),fC=Symbol.for("@multiformats/js-multiaddr/multiaddr"),pC=[YI("dns").code,YI("dns4").code,YI("dns6").code,YI("dnsaddr").code];class gC{bytes;#t;#r;#n;#i;[fC]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=oC(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);t=function(e){const t=[],r=[];let n=null;const i=(e=lC(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){const o=YI(i[s]);if(0===o.size){t.push([o.code]),r.push([o.code]);continue}if(s++,s>=i.length)throw hC("invalid address: "+e);if(!0===o.path){n=lC(i.slice(s).join("/")),t.push([o.code,JI(o.code,n)]),r.push([o.code,n]);break}const a=JI(o.code,i[s]);t.push([o.code,a]),r.push([o.code,QI(o.code,a)])}return{string:aC(r),bytes:cC(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!yC(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=oC(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#r=t.tuples,this.#n=t.stringTuples,this.#i=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const s=YI("tcp"),o=YI("udp"),a=YI("ip4"),c=YI("ip6"),u=YI("dns6"),l=YI("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i=`%${d??""}`),pC.includes(h)&&(t=s.name,n=443,r=`${d??""}${i}`,e=h===u.code?6:4),h!==s.code&&h!==o.code||(t=YI(h).name,n=parseInt(d??"")),h!==a.code&&h!==c.code||(t=YI(h).name,r=`${d??""}${i}`,e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return this.#r.map((e=>{let[t]=e;return Object.assign({},YI(t))}))}protoCodes(){return this.#r.map((e=>{let[t]=e;return t}))}protoNames(){return this.#r.map((e=>{let[t]=e;return YI(t).name}))}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new gC(e),new gC(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new gC(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new gC(cC(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===GI.p2p.code&&e.push([r,n]),r===GI["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?qI(A_.decode(`z${e}`),"base58btc"):qI(KE.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#i}equals(e){return jE(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=bC.get(t.name);if(null==r)throw new Xp(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>mC(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(e??this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[dC](){return`Multiaddr(${this.#t})`}}const bC=new Map;function yC(e){return Boolean(e?.[fC])}function mC(e){return new gC(e)}class wC extends sd{static tag="bootstrap";log;timer;list;timeout;components;_init;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{list:[]};if(null==t.list||0===t.list.length)throw new Error("Bootstrap requires a list of peer addresses");super(),this.components=e,this.log=e.logger.forComponent("libp2p:bootstrap"),this.timeout=t.timeout??1e3,this.list=[];for(const r of t.list){if(!TI.matches(r)){this.log.error("Invalid multiaddr");continue}const e=mC(r),t=e.getPeerId();if(null==t){this.log.error("Invalid bootstrap multiaddr without peer id");continue}const n={id:rS(t),multiaddrs:[e]};this.list.push(n)}this._init=t}[d_]=this;[Symbol.toStringTag]="@libp2p/bootstrap";isStarted(){return Boolean(this.timer)}start(){this.isStarted()||(this.log("Starting bootstrap node discovery, discovering peers after %s ms",this.timeout),this.timer=setTimeout((()=>{this._discoverBootstrapPeers().catch((e=>{this.log.error(e)}))}),this.timeout))}async _discoverBootstrapPeers(){if(null!=this.timer)for(const e of this.list){if(await this.components.peerStore.merge(e.id,{tags:{[this._init.tagName??"bootstrap"]:{value:this._init.tagValue??50,ttl:this._init.tagTTL??12e4}}}),null==this.timer)return;this.safeDispatchEvent("peer",{detail:e})}}stop(){null!=this.timer&&clearTimeout(this.timer),this.timer=void 0}}new Uint8Array(0);function vC(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var _C=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const EC=_C;class SC{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class AC{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return xC(this,e)}}class kC{decoders;constructor(e){this.decoders=e}or(e){return xC(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function xC(e,t){return new kC({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class IC{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new SC(e,t,r),this.decoder=new AC(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function CC(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new IC(t,r,n,i)}function TC(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=EC(n,t);return CC({prefix:r,name:t,encode:i,decode:e=>vC(s(e))})}function RC(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return CC({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const PC=TC({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),DC=TC({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),NC=TC({prefix:"9",name:"base10",alphabet:"0123456789"}),BC=RC({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),UC=RC({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),LC=RC({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),MC=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),OC=MC.reduce(((e,t,r)=>(e[r]=t,e)),[]),qC=MC.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const KC=CC({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=OC[t]),"")},decode:function(e){const t=[];for(const r of e){const e=qC[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),FC=RC({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),VC=RC({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zC=RC({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$C=RC({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HC=RC({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jC=RC({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),GC=RC({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),WC=RC({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),YC=RC({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),QC=TC({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),JC=TC({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),XC=RC({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ZC=RC({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),eT=RC({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),tT=RC({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),rT=RC({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),nT=CC({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),iT=new TextEncoder,sT=new TextDecoder,oT="json",aT=512;function cT(e){return iT.encode(JSON.stringify(e))}function uT(e){return JSON.parse(sT.decode(e))}const lT="raw",hT=85;function dT(e){return vC(e)}function fT(e){return vC(e)}var pT=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=yT;)r[n++]=255&t|gT,t/=128;for(;t&bT;)r[n++]=255&t|gT,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},gT=128,bT=-128,yT=Math.pow(2,31);var mT=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&vT)<<s:(n&vT)*Math.pow(2,s),s+=7}while(n>=wT);return e.bytes=o-r,i},wT=128,vT=127;var _T=Math.pow(2,7),ET=Math.pow(2,14),ST=Math.pow(2,21),AT=Math.pow(2,28),kT=Math.pow(2,35),xT=Math.pow(2,42),IT=Math.pow(2,49),CT=Math.pow(2,56),TT=Math.pow(2,63);const RT={encode:pT,decode:mT,encodingLength:function(e){return e<_T?1:e<ET?2:e<ST?3:e<AT?4:e<kT?5:e<xT?6:e<IT?7:e<CT?8:e<TT?9:10}};function PT(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[RT.decode(e,t),RT.decode.bytes]}function DT(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return RT.encode(e,t,r),t}function NT(e){return RT.encodingLength(e)}function BT(e,t){const r=t.byteLength,n=NT(e),i=n+NT(r),s=new Uint8Array(i+r);return DT(e,s,0),DT(r,s,n),s.set(t,i),new LT(e,r,t,s)}function UT(e){const t=vC(e),[r,n]=PT(t),[i,s]=PT(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new LT(r,i,o,t)}class LT{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const MT=vC;const OT={code:0,name:"identity",encode:MT,digest:function(e){return BT(0,MT(e))}};function qT(e){let{name:t,code:r,encode:n}=e;return new KT(t,r,n)}class KT{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?BT(this.code,t):t.then((e=>BT(this.code,e)))}throw Error("Unknown type, must be binary type")}}function FT(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const VT=qT({name:"sha2-256",code:18,encode:FT("SHA-256")}),zT=qT({name:"sha2-512",code:19,encode:FT("SHA-512")});function $T(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==PC.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,jT(e),t??PC.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,jT(e),t??FC.encoder)}const HT=new WeakMap;function jT(e){const t=HT.get(e);if(null==t){const t=new Map;return HT.set(e,t),t}return t}class GT{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==WT)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==YT)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return GT.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:{const{code:e,digest:t}=this.multihash,r=BT(e,t);return GT.createV1(this.code,r)}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 GT.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return $T(this,e)}toJSON(){return{"/":$T(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof GT)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new GT(e,r,n,i??QT(e,r,n.bytes))}if(!0===t[JT]){const{version:e,multihash:r,code:n}=t,i=UT(r);return GT.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==WT)throw new Error(`Version 0 CID must use dag-pb (code: ${WT}) block encoding`);return new GT(e,t,r,r.bytes);case 1:{const n=QT(e,t,r.bytes);return new GT(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return GT.create(0,WT,e)}static createV1(e,t){return GT.create(1,e,t)}static decode(e){const[t,r]=GT.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=GT.inspectBytes(e),r=t.size-t.multihashSize,n=vC(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new LT(t.multihashCode,t.digestSize,i,n);return[0===t.version?GT.createV0(s):GT.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=PT(e.subarray(t));return t+=n,r};let n=r(),i=WT;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??PC;return[PC.prefix,r.decode(`${PC.prefix}${e}`)]}case PC.prefix:{const r=t??PC;return[PC.prefix,r.decode(e)]}case FC.prefix:{const r=t??FC;return[FC.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=GT.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return jT(i).set(r,e),i}}const WT=112,YT=18;function QT(e,t,r){const n=NT(e),i=n+NT(t),s=new Uint8Array(i+r.byteLength);return DT(e,s,0),DT(t,s,n),s.set(r,i),s}const JT=Symbol.for("@ipld/js-cid/CID"),XT={...nt,...Je,...rt,...Ye,...Qe,...Ze,...et,...We,...tt,...Xe};function ZT(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const eR=Symbol.for("nodejs.util.inspect.custom"),tR=Object.values(XT).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),XT.identity.decoder),rR=114,nR=36,iR=37;class sR{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=PC.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return GT.createV1(rR,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return ZT(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){if(t=t??tR,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=UT(PC.decode(`z${e}`));return e.startsWith("12D")?new aR({multihash:t}):e.startsWith("16U")?new cR({multihash:t}):new oR({multihash:t})}return function(e){try{const t=UT(e);if(t.code===OT.code){if(t.digest.length===nR)return new aR({multihash:t});if(t.digest.length===iR)return new cR({multihash:t})}if(t.code===VT.code)return new oR({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==rR)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===VT.code)return new oR({multihash:e.multihash});if(t.code===OT.code){if(t.digest.length===nR)return new aR({multihash:e.multihash});if(t.digest.length===iR)return new cR({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(GT.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(tR.decode(e))}(e).equals(this);if(null!=e?.multihash?.bytes)return ZT(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[eR](){return`PeerId(${this.toString()})`}}class oR extends sR{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class aR extends sR{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class cR extends sR{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}async function uR(e,t){return e.length===nR?new aR({multihash:BT(OT.code,e),privateKey:t}):e.length===iR?new cR({multihash:BT(OT.code,e),privateKey:t}):new oR({multihash:await VT.digest(e),publicKey:e,privateKey:t})}new Uint8Array(0);function lR(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var hR=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const dR=hR;class fR{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class pR{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return bR(this,e)}}class gR{decoders;constructor(e){this.decoders=e}or(e){return bR(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function bR(e,t){return new gR({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class yR{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new fR(e,t,r),this.decoder=new pR(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function mR(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new yR(t,r,n,i)}function wR(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=dR(n,t);return mR({prefix:r,name:t,encode:i,decode:e=>lR(s(e))})}function vR(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return mR({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const _R=wR({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ER=wR({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),SR=wR({prefix:"9",name:"base10",alphabet:"0123456789"}),AR=vR({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),kR=vR({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),xR=vR({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),IR=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),CR=IR.reduce(((e,t,r)=>(e[r]=t,e)),[]),TR=IR.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const RR=mR({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=CR[t]),"")},decode:function(e){const t=[];for(const r of e){const e=TR[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),PR=vR({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),DR=vR({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),NR=vR({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),BR=vR({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),UR=vR({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),LR=vR({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),MR=vR({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),OR=vR({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),qR=vR({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),KR=wR({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),FR=wR({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),VR=vR({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),zR=vR({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),$R=vR({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),HR=vR({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),jR=vR({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),GR=mR({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),WR=new TextEncoder,YR=new TextDecoder,QR="json",JR=512;function XR(e){return WR.encode(JSON.stringify(e))}function ZR(e){return JSON.parse(YR.decode(e))}const eP="raw",tP=85;function rP(e){return lR(e)}function nP(e){return lR(e)}var iP=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=aP;)r[n++]=255&t|sP,t/=128;for(;t&oP;)r[n++]=255&t|sP,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},sP=128,oP=-128,aP=Math.pow(2,31);var cP=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&lP)<<s:(n&lP)*Math.pow(2,s),s+=7}while(n>=uP);return e.bytes=o-r,i},uP=128,lP=127;var hP=Math.pow(2,7),dP=Math.pow(2,14),fP=Math.pow(2,21),pP=Math.pow(2,28),gP=Math.pow(2,35),bP=Math.pow(2,42),yP=Math.pow(2,49),mP=Math.pow(2,56),wP=Math.pow(2,63);const vP={encode:iP,decode:cP,encodingLength:function(e){return e<hP?1:e<dP?2:e<fP?3:e<pP?4:e<gP?5:e<bP?6:e<yP?7:e<mP?8:e<wP?9:10}};function _P(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[vP.decode(e,t),vP.decode.bytes]}function EP(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return vP.encode(e,t,r),t}function SP(e){return vP.encodingLength(e)}function AP(e,t){const r=t.byteLength,n=SP(e),i=n+SP(r),s=new Uint8Array(i+r);return EP(e,s,0),EP(r,s,n),s.set(t,i),new xP(e,r,t,s)}function kP(e){const t=lR(e),[r,n]=_P(t),[i,s]=_P(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new xP(r,i,o,t)}class xP{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const IP=lR;const CP={code:0,name:"identity",encode:IP,digest:function(e){return AP(0,IP(e))}};function TP(e){let{name:t,code:r,encode:n}=e;return new RP(t,r,n)}class RP{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?AP(this.code,t):t.then((e=>AP(this.code,e)))}throw Error("Unknown type, must be binary type")}}function PP(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const DP=TP({name:"sha2-256",code:18,encode:PP("SHA-256")}),NP=TP({name:"sha2-512",code:19,encode:PP("SHA-512")});function BP(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==_R.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,LP(e),t??_R.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,LP(e),t??PR.encoder)}const UP=new WeakMap;function LP(e){const t=UP.get(e);if(null==t){const t=new Map;return UP.set(e,t),t}return t}class MP{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==OP)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==qP)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return MP.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:{const{code:e,digest:t}=this.multihash,r=AP(e,t);return MP.createV1(this.code,r)}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 MP.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return BP(this,e)}toJSON(){return{"/":BP(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof MP)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new MP(e,r,n,i??KP(e,r,n.bytes))}if(!0===t[FP]){const{version:e,multihash:r,code:n}=t,i=kP(r);return MP.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==OP)throw new Error(`Version 0 CID must use dag-pb (code: ${OP}) block encoding`);return new MP(e,t,r,r.bytes);case 1:{const n=KP(e,t,r.bytes);return new MP(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return MP.create(0,OP,e)}static createV1(e,t){return MP.create(1,e,t)}static decode(e){const[t,r]=MP.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=MP.inspectBytes(e),r=t.size-t.multihashSize,n=lR(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new xP(t.multihashCode,t.digestSize,i,n);return[0===t.version?MP.createV0(s):MP.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=_P(e.subarray(t));return t+=n,r};let n=r(),i=OP;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??_R;return[_R.prefix,r.decode(`${_R.prefix}${e}`)]}case _R.prefix:{const r=t??_R;return[_R.prefix,r.decode(e)]}case PR.prefix:{const r=t??PR;return[PR.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=MP.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return LP(i).set(r,e),i}}const OP=112,qP=18;function KP(e,t,r){const n=SP(e),i=n+SP(t),s=new Uint8Array(i+r.byteLength);return EP(e,s,0),EP(t,s,n),s.set(r,i),s}const FP=Symbol.for("@ipld/js-cid/CID"),VP={...yt,...ht,...bt,...ut,...lt,...ft,...pt,...ct,...gt,...dt};function zP(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const $P=Symbol.for("nodejs.util.inspect.custom"),HP=Object.values(VP).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),VP.identity.decoder),jP=114,GP=36,WP=37;class YP{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=_R.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return MP.createV1(jP,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return zP(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){if(t=t??HP,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=kP(_R.decode(`z${e}`));return e.startsWith("12D")?new JP({multihash:t}):e.startsWith("16U")?new XP({multihash:t}):new QP({multihash:t})}return ZP(HP.decode(e))}(e).equals(this);if(null!=e?.multihash?.bytes)return zP(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[$P](){return`PeerId(${this.toString()})`}}class QP extends YP{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class JP extends YP{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class XP extends YP{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function ZP(e){try{const t=kP(e);if(t.code===CP.code){if(t.digest.length===GP)return new JP({multihash:t});if(t.digest.length===WP)return new XP({multihash:t})}if(t.code===DP.code)return new QP({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==jP)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===DP.code)return new QP({multihash:e.multihash});if(t.code===CP.code){if(t.digest.length===GP)return new JP({multihash:e.multihash});if(t.digest.length===WP)return new XP({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(MP.decode(e))}throw new Error("Supplied PeerID CID is invalid")}function eD(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function tD(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const rD=tD("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),nD=tD("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=eD((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),iD={utf8:rD,"utf-8":rD,hex:VP.base16,latin1:nD,ascii:nD,binary:nD,...VP};function sD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=iD[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function oD(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=eD(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function aD(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=iD[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}const cD=Ex,uD=Sx,lD=function(e){let t=0;if(e=e.toString().trim(),cD(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(uD(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;cD(r[n])&&(e=lD(r[n]),r[n]=sD(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,sD(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},hD=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(4===r){const n=[];for(let i=0;i<r;i++)n.push(e[t+i]);return n.join(".")}if(16===r){const e=[];for(let i=0;i<r;i+=2)e.push(n.getUint16(t+i).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},dD=-1,fD={},pD={};function gD(e){if("number"===typeof e){if(null!=pD[e])return pD[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=fD[e])return fD[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,dD,"ip6zone"],[43,8,"ipcidr"],[53,dD,"dns",!0],[54,dD,"dns4",!0],[55,dD,"dns6",!0],[56,dD,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,dD,"unix",!1,!0],[421,dD,"ipfs"],[421,dD,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,dD,"garlic64"],[448,0,"tls"],[449,dD,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,dD,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,dD,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);pD[t.code]=t,fD[t.name]=t}));gD("ip4"),gD("ip6"),gD("ipcidr");function bD(e,t){switch(gD(e).code){case 4:case 41:return function(e){const t=hD(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Ax(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return AD(t);case 6:case 273:case 33:case 132:return ED(t).toString();case 421:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return sD(r,"base58btc")}(t);case 444:case 445:return kD(t);case 466:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+sD(r,"base64url")}(t);default:return sD(t,"base16")}}function yD(e,t){switch(gD(e).code){case 4:case 41:return vD(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return SD(t);case 6:case 273:case 33:case 132:return _D(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?kP(_R.decode(`z${e}`)).bytes:MP.parse(e).multihash.bytes;const r=Uint8Array.from(ms(t.length));return oD([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(16!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=PR.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=_D(n);return oD([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(56!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=PR.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=_D(n);return oD([r,i],r.length+i.length)}(t);case 466:return function(e){const t=wD.decode(e),r=Uint8Array.from(ms(t.length));return oD([r,t],r.length+t.length)}(t);default:return aD(t,"base16")}}const mD=Object.values(VP).map((e=>e.decoder)),wD=function(){let e=mD[0].or(mD[1]);return mD.slice(2).forEach((t=>e=e.or(t))),e}();function vD(e){if(!Ax(e))throw new Error("invalid ip address");return lD(e)}function _D(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function ED(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function SD(e){const t=aD(e),r=Uint8Array.from(ms(t.length));return oD([r,t],r.length+t.length)}function AD(e){const t=ws(e);if((e=e.slice(gs(t))).length!==t)throw new Error("inconsistent lengths");return sD(e)}function kD(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return`${sD(t,"base32")}:${ED(r)}`}function xD(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const s=ws(e,i),o=gs(s),a=gD(s),c=TD(a,e.slice(i+o));if(0===c){t.push([s]),r.push([s]),i+=o;continue}const u=e.slice(i+o,i+o+c);if(i+=c+o,i>e.length)throw PD("Invalid address Uint8Array: "+sD(e,"base16"));t.push([s,u]);const l=bD(s,u);if(r.push([s,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:ID(r),tuples:t,stringTuples:r,path:n}}function ID(e){const t=[];return e.map((e=>{const r=gD(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),RD(t.join("/"))}function CD(e){return oD(e.map((e=>{const t=gD(e[0]);let r=Uint8Array.from(ms(t.code));return e.length>1&&null!=e[1]&&(r=oD([r,e[1]])),r})))}function TD(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=ws(t instanceof Uint8Array?t:Uint8Array.from(t));return e+gs(e)}}function RD(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function PD(e){return new Error("Error parsing address: "+e)}const DD=Symbol.for("nodejs.util.inspect.custom"),ND=Symbol.for("@multiformats/js-multiaddr/multiaddr"),BD=[gD("dns").code,gD("dns4").code,gD("dns6").code,gD("dnsaddr").code];class UD{bytes;#t;#r;#n;#i;[ND]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=xD(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);t=function(e){const t=[],r=[];let n=null;const i=(e=RD(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){const o=gD(i[s]);if(0===o.size){t.push([o.code]),r.push([o.code]);continue}if(s++,s>=i.length)throw PD("invalid address: "+e);if(!0===o.path){n=RD(i.slice(s).join("/")),t.push([o.code,yD(o.code,n)]),r.push([o.code,n]);break}const a=yD(o.code,i[s]);t.push([o.code,a]),r.push([o.code,bD(o.code,a)])}return{string:ID(r),bytes:CD(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!MD(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=xD(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#r=t.tuples,this.#n=t.stringTuples,this.#i=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const s=gD("tcp"),o=gD("udp"),a=gD("ip4"),c=gD("ip6"),u=gD("dns6"),l=gD("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i=`%${d??""}`),BD.includes(h)&&(t=s.name,n=443,r=`${d??""}${i}`,e=h===u.code?6:4),h!==s.code&&h!==o.code||(t=gD(h).name,n=parseInt(d??"")),h!==a.code&&h!==c.code||(t=gD(h).name,r=`${d??""}${i}`,e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return this.#r.map((e=>{let[t]=e;return Object.assign({},gD(t))}))}protoCodes(){return this.#r.map((e=>{let[t]=e;return t}))}protoNames(){return this.#r.map((e=>{let[t]=e;return gD(t).name}))}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new UD(e),new UD(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new UD(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new UD(CD(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===fD.p2p.code&&e.push([r,n]),r===fD["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?sD(_R.decode(`z${e}`),"base58btc"):sD(MP.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#i}equals(e){return zP(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=LD.get(t.name);if(null==r)throw new Xp(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>OD(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(e??this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[DD](){return`Multiaddr(${this.#t})`}}const LD=new Map;function MD(e){return Boolean(e?.[ND])}function OD(e){return new UD(e)}const qD=Uint8Array.from([3,1]),KD=new Float32Array([-0]),FD=new Uint8Array(KD.buffer);function VD(e,t,r){KD[0]=e,t[r]=FD[0],t[r+1]=FD[1],t[r+2]=FD[2],t[r+3]=FD[3]}const zD=new Float64Array([-0]),$D=new Uint8Array(zD.buffer);function HD(e,t,r){zD[0]=e,t[r]=$D[0],t[r+1]=$D[1],t[r+2]=$D[2],t[r+3]=$D[3],t[r+4]=$D[4],t[r+5]=$D[5],t[r+6]=$D[6],t[r+7]=$D[7]}const jD=BigInt(Number.MAX_SAFE_INTEGER),GD=BigInt(Number.MIN_SAFE_INTEGER);class WD{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return YD;if(e<jD&&e>GD)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>QD&&(n=0n,++r>QD&&(r=0n))),new WD(Number(n),Number(r))}static fromNumber(e){if(0===e)return YD;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new WD(r,n)}static from(e){return"number"===typeof e?WD.fromNumber(e):"bigint"===typeof e?WD.fromBigInt(e):"string"===typeof e?WD.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new WD(e.low>>>0,e.high>>>0):YD}}const YD=new WD(0,0);YD.toBigInt=function(){return 0n},YD.zzEncode=YD.zzDecode=function(){return this},YD.length=function(){return 1};const QD=4294967296n;function JD(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function XD(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function ZD(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class eN{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,XD(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw XD(this,4);return ZD(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw XD(this,4);return 0|ZD(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw XD(this,4);const e=(t=this.buf,r=this.pos,FD[0]=t[r],FD[1]=t[r+1],FD[2]=t[r+2],FD[3]=t[r+3],KD[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw XD(this,4);const e=(t=this.buf,r=this.pos,$D[0]=t[r],$D[1]=t[r+1],$D[2]=t[r+2],$D[3]=t[r+3],$D[4]=t[r+4],$D[5]=t[r+5],$D[6]=t[r+6],$D[7]=t[r+7],zD[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw XD(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw XD(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw XD(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new WD(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw XD(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw XD(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw XD(this,8);const e=ZD(this.buf,this.pos+=4),t=ZD(this.buf,this.pos+=4);return new WD(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 tN(e,t,r){const n=function(e){return new eN(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class rN{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function nN(){}class iN{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const sN=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return eD(e);i+e>t&&(n=eD(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class oN{len;head;tail;states;constructor(){this.len=0,this.head=new rN(nN,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new rN(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new uN((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(lN,10,WD.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=WD.fromBigInt(e);return this._push(lN,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=WD.fromBigInt(e).zzEncode();return this._push(lN,t.length(),t)}sint64Number(e){const t=WD.fromNumber(e).zzEncode();return this._push(lN,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(aN,1,e?1:0)}fixed32(e){return this._push(hN,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=WD.fromBigInt(e);return this._push(hN,4,t.lo)._push(hN,4,t.hi)}fixed64Number(e){const t=WD.fromNumber(e);return this._push(hN,4,t.lo)._push(hN,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(VD,4,e)}double(e){return this._push(HD,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(aN,1,0):this.uint32(t)._push(dN,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(JD,t,e):this._push(aN,1,0)}fork(){return this.states=new iN(this),this.head=this.tail=new rN(nN,0,0),this.len=0,this}reset(){return null!=this.states?(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 rN(nN,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?eD(r):sN(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function aN(e,t,r){t[r]=255&e}function cN(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class uN extends rN{next;constructor(e,t){super(cN,e,t),this.next=void 0}}function lN(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function hN(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function dN(e,t,r){t.set(e,r)}function fN(e,t,r){t.set(e,r)}function pN(e,t,r){e.length<40?JD(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(aD(e),r)}function gN(e,t){const r=new oN;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var bN,yN;function mN(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function wN(e,t){return mN("message",bN.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(oN.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(fN,t,e),this},oN.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(pN,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(bN||(bN={}));Error;!function(e){let t,r;!function(e){let t;e.codec=()=>(null==t&&(t=wN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.multiaddr&&e.multiaddr.byteLength>0&&(t.uint32(10),t.bytes(e.multiaddr)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={multiaddr:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.multiaddr=e.bytes();else e.skipType(7&t)}return r}))),t),e.encode=t=>gN(t,e.codec()),e.decode=t=>tN(t,e.codec())}(t=e.AddressInfo||(e.AddressInfo={})),e.codec=()=>(null==r&&(r=wN((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.peerId&&t.peerId.byteLength>0&&(r.uint32(10),r.bytes(t.peerId)),null!=t.seq&&0n!==t.seq&&(r.uint32(16),r.uint64(t.seq)),null!=t.addresses)for(const i of t.addresses)r.uint32(26),e.AddressInfo.codec().encode(i,r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={peerId:new Uint8Array(0),seq:0n,addresses:[]},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.peerId=t.bytes();break;case 2:n.seq=t.uint64();break;case 3:n.addresses.push(e.AddressInfo.codec().decode(t,t.uint32()));break;default:t.skipType(7&r)}}return n}))),r),e.encode=t=>gN(t,e.codec()),e.decode=t=>tN(t,e.codec())}(yN||(yN={}));class vN{static createFromProtobuf=e=>{const t=yN.decode(e),r=ZP(t.peerId),n=(t.addresses??[]).map((e=>OD(e.multiaddr))),i=t.seq;return new vN({peerId:r,multiaddrs:n,seqNumber:i})};static DOMAIN="libp2p-peer-record";static CODEC=qD;peerId;multiaddrs;seqNumber;domain=vN.DOMAIN;codec=vN.CODEC;marshaled;constructor(e){const{peerId:t,multiaddrs:r,seqNumber:n}=e;this.peerId=t,this.multiaddrs=r??[],this.seqNumber=n??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=yN.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))})),this.marshaled}equals(e){return e instanceof vN&&(!!this.peerId.equals(e.peerId)&&(this.seqNumber===e.seqNumber&&!!function(e,t){const r=(e,t)=>e.toString().localeCompare(t.toString());return e.length===t.length&&(t.sort(r),e.sort(r).every(((e,r)=>t[r].equals(e))))}(this.multiaddrs,e.multiaddrs)))}}function _N(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const EN=32,SN=64,AN=32;function kN(e,t){const r=new Uint8Array(SN);for(let n=0;n<AN;n++)r[n]=e[n],r[AN+n]=t[n];return r}const xN={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)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}},IN={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function CN(e,t){const r=function(e){const t=e?.algorithm??"AES-GCM";let r=e?.keyLength??16;const n=e?.nonceLength??12,i=e?.digest??"SHA-256",s=e?.saltLength??16,o=e?.iterations??32767,a=xN.get();return r*=8,{encrypt:async function(e,c){const u=a.getRandomValues(new Uint8Array(s)),l=a.getRandomValues(new Uint8Array(n)),h={name:t,iv:l};let d;if("string"===typeof c&&(c=aD(c)),0===c.length){d=await a.subtle.importKey("jwk",IN,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",IN,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}const f=await a.subtle.encrypt(h,d,e);return oD([u,h.iv,new Uint8Array(f)])},decrypt:async function(e,c){const u=e.subarray(0,s),l=e.subarray(s,s+n),h=e.subarray(s+n),d={name:t,iv:l};let f;if("string"===typeof c&&(c=aD(c)),0===c.length)try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}catch{f=await a.subtle.importKey("jwk",IN,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}const p=await a.subtle.decrypt(d,f,h);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return VR.encode(n)}var TN,RN,PN,DN;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(TN||(TN={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(RN||(RN={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return mN("enum",bN.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(RN)}(TN||(TN={})),function(e){let t;e.codec=()=>(null==t&&(t=wN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),TN.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=TN.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gN(t,e.codec()),e.decode=t=>tN(t,e.codec())}(PN||(PN={})),function(e){let t;e.codec=()=>(null==t&&(t=wN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),TN.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=TN.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gN(t,e.codec()),e.decode=t=>tN(t,e.codec())}(DN||(DN={}));class NN{_key;constructor(e){this._key=qN(e,EN)}verify(e,t){return function(e,t,r){return Lp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return PN.encode({Type:TN.Ed25519,Data:this.marshal()}).subarray()}equals(e){return zP(this.bytes,e.bytes)}hash(){const e=DP.digest(this.bytes);return _N(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class BN{_key;_publicKey;constructor(e,t){this._key=qN(e,SN),this._publicKey=qN(t,EN)}sign(e){return function(e,t){const r=e.subarray(0,AN);return Lp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new NN(this._publicKey)}marshal(){return this._key}get bytes(){return DN.encode({Type:TN.Ed25519,Data:this.marshal()}).subarray()}equals(e){return zP(this.bytes,e.bytes)}async hash(){const e=DP.digest(this.bytes);let t;return _N(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=CP.digest(this.public.bytes);return _R.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return CN(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function UN(e){if(e.length>SN){const t=(e=qN(e,SN+EN)).subarray(0,SN),r=e.subarray(SN,e.length);return new BN(t,r)}const t=(e=qN(e,SN)).subarray(0,SN),r=e.subarray(EN);return new BN(t,r)}function LN(e){return e=qN(e,EN),new NN(e)}async function MN(){const{privateKey:e,publicKey:t}=function(){const e=Lp.utils.randomPrivateKey(),t=Lp.getPublicKey(e);return{privateKey:kN(e,t),publicKey:t}}();return new BN(e,t)}async function ON(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==AN)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Lp.getPublicKey(t);return{privateKey:kN(t,r),publicKey:r}}(e);return new BN(t,r)}function qN(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new Xp(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}async function KN(e){const t=[await xN.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await VN(e)],r=await FN({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function FN(e){if(null==e.privateKey||null==e.publicKey)throw new Xp("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([xN.get().subtle.exportKey("jwk",e.privateKey),xN.get().subtle.exportKey("jwk",e.publicKey)])}async function VN(e){return xN.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function zN(e){if("RSA"!==e.kty)throw new Xp("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new Xp("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*aD(e.n,"base64url").length}function $N(e,t,r,n){pc(e);const i=function(e,t){if(void 0!==t&&"[object Object]"!==xc.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)}({dkLen:32,asyncTick:10},n),{c:s,dkLen:o,asyncTick:a}=i;if(dc(s),dc(o),dc(a),s<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const c=Sc(t),u=Sc(r),l=new Uint8Array(o),h=Fp.create(e,c),d=h._cloneInto().update(u);return{c:s,dkLen:o,asyncTick:a,DK:l,PRF:h,PRFSalt:d}}function HN(e,t,r,n,i){return e.destroy(),t.destroy(),n&&n.destroy(),i.fill(0),r}async function jN(e,t,r,n){const{c:i,dkLen:s,asyncTick:o,DK:a,PRF:c,PRFSalt:u}=$N(e,t,r,n);let l;const h=new Uint8Array(4),d=mc(h),f=new Uint8Array(c.outputLen);for(let p=1,g=0;g<s;p++,g+=c.outputLen){const e=a.subarray(g,g+c.outputLen);d.setInt32(0,p,!1),(l=u._cloneInto(l)).update(h).digestInto(f),e.set(f.subarray(0,e.length)),await _c(i-1,o,(()=>{c._cloneInto(l).update(f).digestInto(f);for(let t=0;t<e.length;t++)e[t]^=f[t]}))}return HN(c,u,a,l,f)}var GN=__webpack_require__(8275);function WN(e,t){let r=0;if(1===e.length)return e[0];for(let n=e.length-1;n>=0;n--)r+=e[e.length-1-n]*Math.pow(2,t*n);return r}function YN(e,t){const r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;let n=e,i=0,s=Math.pow(2,t);for(let o=1;o<8;o++){if(e<s){let e;if(r<0)e=new ArrayBuffer(o),i=o;else{if(r<o)return new ArrayBuffer(0);e=new ArrayBuffer(r),i=r}const s=new Uint8Array(e);for(let r=o-1;r>=0;r--){const e=Math.pow(2,r*t);s[i-r-1]=Math.floor(n/e),n-=s[i-r-1]*e}return e}s*=Math.pow(2,t)}return new ArrayBuffer(0)}function QN(){let e=0,t=0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];for(const a of n)e+=a.length;const s=new ArrayBuffer(e),o=new Uint8Array(s);for(const a of n)o.set(a,t),t+=a.length;return o}function JN(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],r=0===e[0]&&0===(128&e[1]);(t||r)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),r=new Uint8Array(t);for(let o=0;o<this.valueHex.byteLength;o++)r[o]=0;r[0]=128&e[0];const n=WN(r,8),i=new ArrayBuffer(this.valueHex.byteLength),s=new Uint8Array(i);for(let o=0;o<this.valueHex.byteLength;o++)s[o]=e[o];s[0]&=127;return WN(s,8)-n}function XN(e,t){const r=e.toString(10);if(t<r.length)return"";const n=t-r.length,i=new Array(n);for(let s=0;s<n;s++)i[s]="0";return i.join("").concat(r)}Math.log(2);function ZN(){if("undefined"===typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function eB(e){let t=0,r=0;for(let i=0;i<e.length;i++){t+=e[i].byteLength}const n=new Uint8Array(t);for(let i=0;i<e.length;i++){const t=e[i];n.set(new Uint8Array(t),r),r+=t.byteLength}return n.buffer}function tB(e,t,r,n){return t instanceof Uint8Array?t.byteLength?r<0?(e.error="Wrong parameter: inputOffset less than zero",!1):n<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-r-n<0)||(e.error="End of input reached before message was fully decoded (inconsistent offset and length values)",!1):(e.error="Wrong parameter: inputBuffer has zero length",!1):(e.error="Wrong parameter: inputBuffer must be 'Uint8Array'",!1)}class rB{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return eB(this.items)}}const nB=[new Uint8Array([1])],iB="0123456789",sB="",oB=new ArrayBuffer(0),aB=new Uint8Array(0),cB="EndOfContent",uB="OCTET STRING",lB="BIT STRING";function hB(e){var t;return t=class extends e{constructor(){var e;super(...arguments);const t=(arguments.length<=0?void 0:arguments[0])||{};this.isHexOnly=null!==(e=t.isHexOnly)&&void 0!==e&&e,this.valueHexView=t.valueHex?GN._H.toUint8Array(t.valueHex):aB}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}fromBER(e,t,r){const n=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!tB(this,n,t,r))return-1;const i=t+r;return this.valueHexView=n.subarray(t,i),this.valueHexView.length?(this.blockLength=r,i):(this.warnings.push("Zero buffer length"),t)}toBER(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.isHexOnly?e?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",oB)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:GN.U$.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}class dB{constructor(){let{blockLength:e=0,error:t=sB,warnings:r=[],valueBeforeDecode:n=aB}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.blockLength=e,this.error=t,this.warnings=r,this.valueBeforeDecodeView=GN._H.toUint8Array(n)}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:GN.U$.ToHex(this.valueBeforeDecodeView)}}}dB.NAME="baseBlock";class fB extends dB{fromBER(e,t,r){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'")}}fB.NAME="valueBlock";class pB extends(hB(dB)){constructor(){let{idBlock:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,r,n,i;super(),e?(this.isHexOnly=null!==(t=e.isHexOnly)&&void 0!==t&&t,this.valueHexView=e.valueHex?GN._H.toUint8Array(e.valueHex):aB,this.tagClass=null!==(r=e.tagClass)&&void 0!==r?r:-1,this.tagNumber=null!==(n=e.tagNumber)&&void 0!==n?n:-1,this.isConstructed=null!==(i=e.isConstructed)&&void 0!==i&&i):(this.tagClass=-1,this.tagNumber=-1,this.isConstructed=!1)}toBER(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],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",oB}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const r=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,r[0]=t}return r.buffer}if(!this.isHexOnly){const r=YN(this.tagNumber,7),n=new Uint8Array(r),i=r.byteLength,s=new Uint8Array(i+1);if(s[0]=31|t,!e){for(let e=0;e<i-1;e++)s[e+1]=128|n[e];s[i]=n[i-1]}return s.buffer}const r=new Uint8Array(this.valueHexView.byteLength+1);if(r[0]=31|t,!e){const e=this.valueHexView;for(let t=0;t<e.length-1;t++)r[t+1]=128|e[t];r[this.valueHexView.byteLength]=e[e.length-1]}return r.buffer}fromBER(e,t,r){const n=GN._H.toUint8Array(e);if(!tB(this,n,t,r))return-1;const i=n.subarray(t,t+r);if(0===i.length)return this.error="Zero buffer length",-1;switch(192&i[0]){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=32===(32&i[0]),this.isHexOnly=!1;const s=31&i[0];if(31!==s)this.tagNumber=s,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),r=255;for(;128&i[e];){if(t[e-1]=127&i[e],e++,e>=i.length)return this.error="End of input reached before message was fully decoded",-1;if(e===r){r+=255;const e=new Uint8Array(r);for(let r=0;r<t.length;r++)e[r]=t[r];t=this.valueHexView=new Uint8Array(r)}}this.blockLength=e+1,t[e-1]=127&i[e];const n=new Uint8Array(e);for(let i=0;i<e;i++)n[i]=t[i];t=this.valueHexView=new Uint8Array(e),t.set(n),this.blockLength<=9?this.tagNumber=WN(t,7):(this.isHexOnly=!0,this.warnings.push("Tag too long, represented as hex-coded"))}if(1===this.tagClass&&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}}}pB.NAME="identificationBlock";class gB extends dB{constructor(){let{lenBlock:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,r,n;super(),this.isIndefiniteForm=null!==(t=e.isIndefiniteForm)&&void 0!==t&&t,this.longFormUsed=null!==(r=e.longFormUsed)&&void 0!==r&&r,this.length=null!==(n=e.length)&&void 0!==n?n:0}fromBER(e,t,r){const n=GN._H.toUint8Array(e);if(!tB(this,n,t,r))return-1;const i=n.subarray(t,t+r);if(0===i.length)return this.error="Zero buffer length",-1;if(255===i[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===i[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&i[0]),!1===this.longFormUsed)return this.length=i[0],this.blockLength=1,t+this.blockLength;const s=127&i[0];if(s>8)return this.error="Too big integer",-1;if(s+1>i.length)return this.error="End of input reached before message was fully decoded",-1;const o=t+1,a=n.subarray(o,o+s);return 0===a[s-1]&&this.warnings.push("Needlessly long encoded length"),this.length=WN(a,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=s+1,t+this.blockLength}toBER(){let e,t,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),!1===r&&(t=new Uint8Array(e),t[0]=128),e;if(this.longFormUsed){const n=YN(this.length,8);if(n.byteLength>127)return this.error="Too big length",oB;if(e=new ArrayBuffer(n.byteLength+1),r)return e;const i=new Uint8Array(n);t=new Uint8Array(e),t[0]=128|n.byteLength;for(let e=0;e<n.byteLength;e++)t[e+1]=i[e];return e}return e=new ArrayBuffer(1),!1===r&&(t=new Uint8Array(e),t[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}gB.NAME="lengthBlock";const bB={};class yB extends dB{constructor(){let{name:e=sB,optional:t=!1,primitiveSchema:r,...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;super(n),this.name=e,this.optional=t,r&&(this.primitiveSchema=r),this.idBlock=new pB(n),this.lenBlock=new gB(n),this.valueBlock=i?new i(n):new fB(n)}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(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),n)}toBER(e,t){const r=t||new rB;t||mB(this);const n=this.idBlock.toBER(e);if(r.write(n),this.lenBlock.isIndefiniteForm)r.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,r),r.write(new ArrayBuffer(2));else{const t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;const n=this.lenBlock.toBER(e);r.write(n),r.write(t)}return t?oB:r.final()}toJSON(){const 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(){return"ascii"===(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"ascii")?this.onAsciiEncoding():GN.U$.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${GN.U$.ToHex(this.valueBlock.valueBeforeDecodeView)}`}isEqual(e){if(this===e)return!0;if(!(e instanceof this.constructor))return!1;return function(e,t){if(e.byteLength!==t.byteLength)return!1;const r=new Uint8Array(e),n=new Uint8Array(t);for(let i=0;i<r.length;i++)if(r[i]!==n[i])return!1;return!0}(this.toBER(),e.toBER())}}function mB(e){if(e instanceof bB.Constructed)for(const t of e.valueBlock.value)mB(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock.isIndefiniteForm}yB.NAME="BaseBlock";class wB extends yB{constructor(){let{value:e=sB,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t,arguments.length>1?arguments[1]:void 0),e&&this.fromString(e)}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}fromBER(e,t,r){const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(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),n)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}wB.NAME="BaseStringBlock";class vB extends(hB(fB)){constructor(){let{isHexOnly:e=!0,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.isHexOnly=e}}var _B,EB,SB,AB,kB,xB,IB,CB,TB,RB,PB,DB,NB,BB,UB,LB,MB,OB,qB,KB,FB,VB,zB,$B,HB,jB,GB,WB,YB,QB,JB,XB,ZB;vB.NAME="PrimitiveValueBlock";class eU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},vB),this.idBlock.isConstructed=!1}}function tU(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length;const n=t;let i=new yB({},fB);const s=new dB;if(!tB(s,e,t,r))return i.error=s.error,{offset:-1,result:i};if(!e.subarray(t,t+r).length)return i.error="Zero buffer length",{offset:-1,result:i};let o=i.idBlock.fromBER(e,t,r);if(i.idBlock.warnings.length&&i.warnings.concat(i.idBlock.warnings),-1===o)return i.error=i.idBlock.error,{offset:-1,result:i};if(t=o,r-=i.idBlock.blockLength,o=i.lenBlock.fromBER(e,t,r),i.lenBlock.warnings.length&&i.warnings.concat(i.lenBlock.warnings),-1===o)return i.error=i.lenBlock.error,{offset:-1,result:i};if(t=o,r-=i.lenBlock.blockLength,!i.idBlock.isConstructed&&i.lenBlock.isIndefiniteForm)return i.error="Indefinite length form used for primitive encoding form",{offset:-1,result:i};let a=yB;if(1===i.idBlock.tagClass){if(i.idBlock.tagNumber>=37&&!1===i.idBlock.isHexOnly)return i.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:i};switch(i.idBlock.tagNumber){case 0:if(i.idBlock.isConstructed&&i.lenBlock.length>0)return i.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:i};a=bB.EndOfContent;break;case 1:a=bB.Boolean;break;case 2:a=bB.Integer;break;case 3:a=bB.BitString;break;case 4:a=bB.OctetString;break;case 5:a=bB.Null;break;case 6:a=bB.ObjectIdentifier;break;case 10:a=bB.Enumerated;break;case 12:a=bB.Utf8String;break;case 13:a=bB.RelativeObjectIdentifier;break;case 14:a=bB.TIME;break;case 15:return i.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:i};case 16:a=bB.Sequence;break;case 17:a=bB.Set;break;case 18:a=bB.NumericString;break;case 19:a=bB.PrintableString;break;case 20:a=bB.TeletexString;break;case 21:a=bB.VideotexString;break;case 22:a=bB.IA5String;break;case 23:a=bB.UTCTime;break;case 24:a=bB.GeneralizedTime;break;case 25:a=bB.GraphicString;break;case 26:a=bB.VisibleString;break;case 27:a=bB.GeneralString;break;case 28:a=bB.UniversalString;break;case 29:a=bB.CharacterString;break;case 30:a=bB.BmpString;break;case 31:a=bB.DATE;break;case 32:a=bB.TimeOfDay;break;case 33:a=bB.DateTime;break;case 34:a=bB.Duration;break;default:{const e=i.idBlock.isConstructed?new bB.Constructed:new bB.Primitive;e.idBlock=i.idBlock,e.lenBlock=i.lenBlock,e.warnings=i.warnings,i=e}}}else a=i.idBlock.isConstructed?bB.Constructed:bB.Primitive;return i=function(e,t){if(e instanceof t)return e;const r=new t;return r.idBlock=e.idBlock,r.lenBlock=e.lenBlock,r.warnings=e.warnings,r.valueBeforeDecodeView=e.valueBeforeDecodeView,r}(i,a),o=i.fromBER(e,t,i.lenBlock.isIndefiniteForm?r:i.lenBlock.length),i.valueBeforeDecodeView=e.subarray(n,n+i.blockLength),{offset:o,result:i}}function rU(e){if(!e.byteLength){const e=new yB({},fB);return e.error="Input buffer has zero length",{offset:-1,result:e}}return tU(GN._H.toUint8Array(e).slice(),0,e.byteLength)}_B=eU,bB.Primitive=_B,eU.NAME="PRIMITIVE";class nU extends fB{constructor(){let{value:e=[],isIndefiniteForm:t=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(r),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,r){const n=GN._H.toUint8Array(e);if(!tB(this,n,t,r))return-1;if(this.valueBeforeDecodeView=n.subarray(t,t+r),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let i=t;for(;s=this.isIndefiniteForm,o=r,(s?1:o)>0;){const e=tU(n,i,r);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(i=e.offset,this.blockLength+=e.result.blockLength,r-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===cB)break}var s,o;return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===cB?this.value.pop():this.warnings.push("No EndOfContent block encoded")),i}toBER(e,t){const r=t||new rB;for(let n=0;n<this.value.length;n++)this.value[n].toBER(e,r);return t?oB:r.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}nU.NAME="ConstructedValueBlock";class iU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},nU),this.idBlock.isConstructed=!0}fromBER(e,t,r){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const n=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?r:this.lenBlock.length);return-1===n?(this.error=this.valueBlock.error,n):(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),n)}onAsciiEncoding(){const e=[];for(const r of this.valueBlock.value)e.push(r.toString("ascii").split("\n").map((e=>` ${e}`)).join("\n"));const t=3===this.idBlock.tagClass?`[${this.idBlock.tagNumber}]`:this.constructor.NAME;return e.length?`${t} :\n${e.join("\n")}`:`${t} :`}}EB=iU,bB.Constructed=EB,iU.NAME="CONSTRUCTED";class sU extends fB{fromBER(e,t,r){return t}toBER(e){return oB}}sU.override="EndOfContentValueBlock";class oU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},sU),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}SB=oU,bB.EndOfContent=SB,oU.NAME=cB;class aU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},fB),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,r){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=r,t+r>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+r}toBER(e,t){const r=new ArrayBuffer(2);if(!e){const e=new Uint8Array(r);e[0]=5,e[1]=0}return t&&t.write(r),r}onAsciiEncoding(){return`${this.constructor.NAME}`}}AB=aU,bB.Null=AB,aU.NAME="NULL";class cU extends(hB(fB)){constructor(){let{value:e,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),t.valueHex?this.valueHexView=GN._H.toUint8Array(t.valueHex):this.valueHexView=new Uint8Array(1),e&&(this.value=e)}get value(){for(const e of this.valueHexView)if(e>0)return!0;return!1}set value(e){this.valueHexView[0]=e?255:0}fromBER(e,t,r){const n=GN._H.toUint8Array(e);return tB(this,n,t,r)?(this.valueHexView=n.subarray(t,t+r),r>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,JN.call(this),this.blockLength=r,t+r):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}cU.NAME="BooleanValueBlock";class uU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},cU),this.idBlock.tagClass=1,this.idBlock.tagNumber=1}getValue(){return this.valueBlock.value}setValue(e){this.valueBlock.value=e}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.getValue}`}}kB=uU,bB.Boolean=kB,uU.NAME="BOOLEAN";class lU extends(hB(nU)){constructor(){let{isConstructed:e=!1,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.isConstructed=e}fromBER(e,t,r){let n=0;if(this.isConstructed){if(this.isHexOnly=!1,n=nU.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(let e=0;e<this.value.length;e++){const t=this.value[e].constructor.NAME;if(t===cB){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==uB)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,n=super.fromBER(e,t,r),this.blockLength=r;return n}toBER(e,t){return this.isConstructed?nU.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}lU.NAME="OctetStringValueBlock";class hU extends yB{constructor(){let{idBlock:e={},lenBlock:t={},...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var n,i;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(i=r.value)||void 0===i?void 0:i.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},lU),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,r){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===r)return 0===this.idBlock.error.length&&(this.blockLength+=this.idBlock.blockLength),0===this.lenBlock.error.length&&(this.blockLength+=this.lenBlock.blockLength),t;if(!this.valueBlock.isConstructed){const i=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+r);try{if(i.byteLength){const e=tU(i,0,i.byteLength);-1!==e.offset&&e.offset===r&&(this.valueBlock.value=[e.result])}}catch(n){}}return super.fromBER(e,t,r)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?iU.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${GN.U$.ToHex(this.valueBlock.valueHexView)}`}getValue(){if(!this.idBlock.isConstructed)return this.valueBlock.valueHexView.slice().buffer;const e=[];for(const t of this.valueBlock.value)t instanceof hU&&e.push(t.valueBlock.valueHexView);return GN._H.concat(e)}}xB=hU,bB.OctetString=xB,hU.NAME=uB;class dU extends(hB(nU)){constructor(){let{unusedBits:e=0,isConstructed:t=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(r),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,r){if(!r)return t;let n=-1;if(this.isConstructed){if(n=nU.prototype.fromBER.call(this,e,t,r),-1===n)return n;for(const e of this.value){const t=e.constructor.NAME;if(t===cB){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==lB)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const r=e.valueBlock;if(this.unusedBits>0&&r.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=r.unusedBits}return n}const i=GN._H.toUint8Array(e);if(!tB(this,i,t,r))return-1;const s=i.subarray(t,t+r);if(this.unusedBits=s[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=s.subarray(1);try{if(e.byteLength){const t=tU(e,0,e.byteLength);-1!==t.offset&&t.offset===r-1&&(this.value=[t.result])}}catch(o){}}return this.valueHexView=s.subarray(1),this.blockLength=s.length,t+r}toBER(e,t){if(this.isConstructed)return nU.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return oB;const r=new Uint8Array(this.valueHexView.length+1);return r[0]=this.unusedBits,r.set(this.valueHexView,1),r.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}dU.NAME="BitStringValueBlock";class fU extends yB{constructor(){let{idBlock:e={},lenBlock:t={},...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var n,i;null!==(n=r.isConstructed)&&void 0!==n||(r.isConstructed=!!(null===(i=r.value)||void 0===i?void 0:i.length)),super({idBlock:{isConstructed:r.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!r.isIndefiniteForm},...r},dU),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,r){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,r)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return iU.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const n of t)e.push(n.toString(2).padStart(8,"0"));const r=e.join("");return`${this.constructor.NAME} : ${r.substring(0,r.length-this.valueBlock.unusedBits)}`}}}function pU(e,t){const r=new Uint8Array([0]),n=new Uint8Array(e),i=new Uint8Array(t);let s=n.slice(0);const o=s.length-1,a=i.slice(0),c=a.length-1;let u=0;let l=0;for(let h=c<o?o:c;h>=0;h--,l++){if(!0===l<a.length)u=s[o-l]+a[c-l]+r[0];else u=s[o-l]+r[0];if(r[0]=u/10,!0===l>=s.length)s=QN(new Uint8Array([u%10]),s);else s[o-l]=u%10}return r[0]>0&&(s=QN(r,s)),s}function gU(e){if(e>=nB.length)for(let t=nB.length;t<=e;t++){const e=new Uint8Array([0]);let r=nB[t-1].slice(0);for(let t=r.length-1;t>=0;t--){const n=new Uint8Array([(r[t]<<1)+e[0]]);e[0]=n[0]/10,r[t]=n[0]%10}e[0]>0&&(r=QN(e,r)),nB.push(r)}return nB[e]}function bU(e,t){let r=0;const n=new Uint8Array(e),i=new Uint8Array(t),s=n.slice(0),o=s.length-1,a=i.slice(0),c=a.length-1;let u,l=0;for(let h=c;h>=0;h--,l++)if(u=s[o-l]-a[c-l]-r,!0===u<0)r=1,s[o-l]=u+10;else r=0,s[o-l]=u;if(r>0)for(let h=o-c+1;h>=0;h--,l++){if(u=s[o-l]-r,!(u<0)){r=0,s[o-l]=u;break}r=1,s[o-l]=u+10}return s.slice()}IB=fU,bB.BitString=IB,fU.NAME=lB;class yU extends(hB(fB)){constructor(){let{value:e,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this._valueDec=0,t.valueHex&&this.setValueHex(),void 0!==e&&(this.valueDec=e)}setValueHex(){this.valueHexView.length>=4?(this.warnings.push("Too big Integer for decoding, hex only"),this.isHexOnly=!0,this._valueDec=0):(this.isHexOnly=!1,this.valueHexView.length>0&&(this._valueDec=JN.call(this)))}set valueDec(e){this._valueDec=e,this.isHexOnly=!1,this.valueHexView=new Uint8Array(function(e){const t=e<0?-1*e:e;let r=128;for(let n=1;n<8;n++){if(t<=r){if(e<0){const e=YN(r-t,8,n);return new Uint8Array(e)[0]|=128,e}let i=YN(t,8,n),s=new Uint8Array(i);if(128&s[0]){const e=i.slice(0),t=new Uint8Array(e);i=new ArrayBuffer(i.byteLength+1),s=new Uint8Array(i);for(let r=0;r<e.byteLength;r++)s[r+1]=t[r];s[0]=0}return i}r*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const i=this.fromBER(e,t,r);if(-1===i)return i;const s=this.valueHexView;return 0===s[0]&&0!==(128&s[1])?this.valueHexView=s.subarray(1):0!==n&&s.length<n&&(n-s.length>1&&(n=s.length+1),this.valueHexView=s.subarray(n-s.length)),i}toDER(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=this.valueHexView;switch(!0){case 0!==(128&t[0]):{const e=new Uint8Array(this.valueHexView.length+1);e[0]=0,e.set(t,1),this.valueHexView=e}break;case 0===t[0]&&0===(128&t[1]):this.valueHexView=this.valueHexView.subarray(1)}return this.toBER(e)}fromBER(e,t,r){const n=super.fromBER(e,t,r);return-1===n||this.setValueHex(),n}toBER(e){return e?new ArrayBuffer(this.valueHexView.length):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}toString(){const e=8*this.valueHexView.length-1;let t,r=new Uint8Array(8*this.valueHexView.length/3),n=0;const i=this.valueHexView;let s="",o=!1;for(let a=i.byteLength-1;a>=0;a--){t=i[a];for(let i=0;i<8;i++){if(1===(1&t))if(n===e)r=bU(gU(n),r),s="-";else r=pU(r,gU(n));n++,t>>=1}}for(let a=0;a<r.length;a++)r[a]&&(o=!0),o&&(s+=iB.charAt(r[a]));return!1===o&&(s+=iB.charAt(0)),s}}CB=yU,yU.NAME="IntegerValueBlock",Object.defineProperty(CB.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class mU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},yU),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return ZN(),BigInt(this.valueBlock.toString())}static fromBigInt(e){ZN();const t=BigInt(e),r=new rB,n=t.toString(16).replace(/^-/,""),i=new Uint8Array(GN.U$.FromHex(n));if(t<0){const e=new Uint8Array(i.length+(128&i[0]?1:0));e[0]|=128;const n=BigInt(`0x${GN.U$.ToHex(e)}`)+t,s=GN._H.toUint8Array(GN.U$.FromHex(n.toString(16)));s[0]|=128,r.write(s)}else 128&i[0]&&r.write(new Uint8Array([0])),r.write(i);return new mU({valueHex:r.final()})}convertToDER(){const e=new mU({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new mU({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}TB=mU,bB.Integer=TB,mU.NAME="INTEGER";class wU extends mU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}RB=wU,bB.Enumerated=RB,wU.NAME="ENUMERATED";class vU extends(hB(fB)){constructor(){let{valueDec:e=-1,isFirstSid:t=!1,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(r),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,r){if(!r)return t;const n=GN._H.toUint8Array(e);if(!tB(this,n,t,r))return-1;const i=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let o=0;o<r&&(this.valueHexView[o]=127&i[o],this.blockLength++,0!==(128&i[o]));o++);const s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)s[o]=this.valueHexView[o];return this.valueHexView=s,0!==(128&i[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=WN(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){ZN();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const r=new Uint8Array(t.length/7);for(let n=0;n<r.length;n++)r[n]=parseInt(t.slice(7*n,7*n+7),2)+(n+1<r.length?128:0);this.fromBER(r.buffer,0,r.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=YN(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",oB;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r}toString(){let e="";if(this.isHexOnly)e=GN.U$.ToHex(this.valueHexView);else if(this.isFirstSid){let t=this.valueDec;this.valueDec<=39?e="0.":this.valueDec<=79?(e="1.",t-=40):(e="2.",t-=80),e+=t.toString()}else e=this.valueDec.toString();return e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec,isFirstSid:this.isFirstSid}}}vU.NAME="sidBlock";class _U extends fB{constructor(){let{value:e=sB,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new vU;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e){const t=[];for(let r=0;r<this.value.length;r++){const n=this.value[r].toBER(e);if(0===n.byteLength)return this.error=this.value[r].error,oB;t.push(n)}return eB(t)}fromString(e){this.value=[];let t=0,r=0,n="",i=!1;do{if(r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1,i){const e=this.value[0];let t=0;switch(e.valueDec){case 0:break;case 1:t=40;break;case 2:t=80;break;default:return void(this.value=[])}const r=parseInt(n,10);if(isNaN(r))return;e.valueDec=r+t,i=!1}else{const e=new vU;if(n>Number.MAX_SAFE_INTEGER){ZN();const t=BigInt(n);e.valueBigInt=t}else if(e.valueDec=parseInt(n,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,i=!0),this.value.push(e)}}while(-1!==r)}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e=`${e}.`),t?(n=`{${n}}`,this.value[r].isFirstSid?e=`2.{${n} - 80}`:e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}_U.NAME="ObjectIdentifierValueBlock";class EU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},_U),this.idBlock.tagClass=1,this.idBlock.tagNumber=6}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}PB=EU,bB.ObjectIdentifier=PB,EU.NAME="OBJECT IDENTIFIER";class SU extends(hB(dB)){constructor(){let{valueDec:e=0,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.valueDec=e}fromBER(e,t,r){if(0===r)return t;const n=GN._H.toUint8Array(e);if(!tB(this,n,t,r))return-1;const i=n.subarray(t,t+r);this.valueHexView=new Uint8Array(r);for(let o=0;o<r&&(this.valueHexView[o]=127&i[o],this.blockLength++,0!==(128&i[o]));o++);const s=new Uint8Array(this.blockLength);for(let o=0;o<this.blockLength;o++)s[o]=this.valueHexView[o];return this.valueHexView=s,0!==(128&i[this.blockLength-1])?(this.error="End of input reached before message was fully decoded",-1):(0===this.valueHexView[0]&&this.warnings.push("Needlessly long format of SID encoding"),this.blockLength<=8?this.valueDec=WN(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,r=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)r[e]=128|t[e];return r[this.blockLength-1]=t[this.blockLength-1],r.buffer}const t=YN(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",oB;const r=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),n=t.byteLength-1;for(let t=0;t<n;t++)r[t]=128|e[t];r[n]=e[n]}return r.buffer}toString(){let e="";return e=this.isHexOnly?GN.U$.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}SU.NAME="relativeSidBlock";class AU extends fB{constructor(){let{value:e=sB,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,r){let n=t;for(;r>0;){const t=new SU;if(n=t.fromBER(e,n,r),-1===n)return this.blockLength=0,this.error=t.error,n;this.blockLength+=t.blockLength,r-=t.blockLength,this.value.push(t)}return n}toBER(e,t){const r=[];for(let n=0;n<this.value.length;n++){const t=this.value[n].toBER(e);if(0===t.byteLength)return this.error=this.value[n].error,oB;r.push(t)}return eB(r)}fromString(e){this.value=[];let t=0,r=0,n="";do{r=e.indexOf(".",t),n=-1===r?e.substring(t):e.substring(t,r),t=r+1;const i=new SU;if(i.valueDec=parseInt(n,10),isNaN(i.valueDec))return!0;this.value.push(i)}while(-1!==r);return!0}toString(){let e="",t=!1;for(let r=0;r<this.value.length;r++){t=this.value[r].isHexOnly;let n=this.value[r].toString();0!==r&&(e=`${e}.`),t?(n=`{${n}}`,e+=n):e+=n}return e}toJSON(){const e={...super.toJSON(),value:this.toString(),sidArray:[]};for(let t=0;t<this.value.length;t++)e.sidArray.push(this.value[t].toJSON());return e}}AU.NAME="RelativeObjectIdentifierValueBlock";class kU extends yB{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},AU),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}DB=kU,bB.RelativeObjectIdentifier=DB,kU.NAME="RelativeObjectIdentifier";class xU extends iU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}NB=xU,bB.Sequence=NB,xU.NAME="SEQUENCE";class IU extends iU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}BB=IU,bB.Set=BB,IU.NAME="SET";class CU extends(hB(fB)){constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.isHexOnly=!0,this.value=sB}toJSON(){return{...super.toJSON(),value:this.value}}}CU.NAME="StringValueBlock";class TU extends CU{}TU.NAME="SimpleStringValueBlock";class RU extends wB{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e,TU)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,GN._H.toUint8Array(e))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(t);for(let n=0;n<t;n++)r[n]=e.charCodeAt(n);this.valueBlock.value=e}}RU.NAME="SIMPLE STRING";class PU extends RU{fromBuffer(e){this.valueBlock.valueHexView=GN._H.toUint8Array(e);try{this.valueBlock.value=GN.U$.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=GN.U$.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(GN.U$.FromUtf8String(e)),this.valueBlock.value=e}}PU.NAME="Utf8StringValueBlock";class DU extends PU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}UB=DU,bB.Utf8String=UB,DU.NAME="UTF8String";class NU extends RU{fromBuffer(e){this.valueBlock.value=GN.U$.ToUtf16String(e),this.valueBlock.valueHexView=GN._H.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(GN.U$.FromUtf16String(e))}}NU.NAME="BmpStringValueBlock";class BU extends NU{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}LB=BU,bB.BmpString=LB,BU.NAME="BMPString";class UU extends RU{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),r=new Uint8Array(t);for(let n=0;n<r.length;n+=4)r[n]=r[n+3],r[n+1]=r[n+2],r[n+2]=0,r[n+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,r=this.valueBlock.valueHexView=new Uint8Array(4*t);for(let n=0;n<t;n++){const t=YN(e.charCodeAt(n),8),i=new Uint8Array(t);if(i.length>4)continue;const s=4-i.length;for(let e=i.length-1;e>=0;e--)r[4*n+e+s]=i[e]}this.valueBlock.value=e}}UU.NAME="UniversalStringValueBlock";class LU extends UU{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}MB=LU,bB.UniversalString=MB,LU.NAME="UniversalString";class MU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}OB=MU,bB.NumericString=OB,MU.NAME="NumericString";class OU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}qB=OU,bB.PrintableString=qB,OU.NAME="PrintableString";class qU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}KB=qU,bB.TeletexString=KB,qU.NAME="TeletexString";class KU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}FB=KU,bB.VideotexString=FB,KU.NAME="VideotexString";class FU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}VB=FU,bB.IA5String=VB,FU.NAME="IA5String";class VU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}zB=VU,bB.GraphicString=zB,VU.NAME="GraphicString";class zU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}$B=zU,bB.VisibleString=$B,zU.NAME="VisibleString";class $U extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}HB=$U,bB.GeneralString=HB,$U.NAME="GeneralString";class HU extends RU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}jB=HU,bB.CharacterString=jB,HU.NAME="CharacterString";class jU extends zU{constructor(){let{value:e,valueDate:t,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(super(r),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let t=0;t<e.length;t++)this.valueBlock.valueHexView[t]=e.charCodeAt(t)}t&&(this.fromDate(t),this.valueBlock.valueHexView=new Uint8Array(this.toBuffer())),this.idBlock.tagClass=1,this.idBlock.tagNumber=23}fromBuffer(e){this.fromString(String.fromCharCode.apply(null,GN._H.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),r=new Uint8Array(t);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return t}fromDate(e){this.year=e.getUTCFullYear(),this.month=e.getUTCMonth()+1,this.day=e.getUTCDate(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second))}fromString(e){const t=/(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})Z/gi.exec(e);if(null===t)return void(this.error="Wrong input string for conversion");const r=parseInt(t[1],10);this.year=r>=50?1900+r:2e3+r,this.month=parseInt(t[2],10),this.day=parseInt(t[3],10),this.hour=parseInt(t[4],10),this.minute=parseInt(t[5],10),this.second=parseInt(t[6],10)}toString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"iso";if("iso"===e){const e=new Array(7);return e[0]=XN(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=XN(this.month,2),e[2]=XN(this.day,2),e[3]=XN(this.hour,2),e[4]=XN(this.minute,2),e[5]=XN(this.second,2),e[6]="Z",e.join("")}return super.toString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.toDate().toISOString()}`}toJSON(){return{...super.toJSON(),year:this.year,month:this.month,day:this.day,hour:this.hour,minute:this.minute,second:this.second}}}GB=jU,bB.UTCTime=GB,jU.NAME="UTCTime";class GU extends jU{constructor(){var e;super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),null!==(e=this.millisecond)&&void 0!==e||(this.millisecond=0),this.idBlock.tagClass=1,this.idBlock.tagNumber=24}fromDate(e){super.fromDate(e),this.millisecond=e.getUTCMilliseconds()}toDate(){return new Date(Date.UTC(this.year,this.month-1,this.day,this.hour,this.minute,this.second,this.millisecond))}fromString(e){let t,r=!1,n="",i="",s=0,o=0,a=0;if("Z"===e[e.length-1])n=e.substring(0,e.length-1),r=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");n=e}if(r){if(-1!==n.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==n.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=n.indexOf("+"),r="";if(-1===t&&(t=n.indexOf("-"),e=-1),-1!==t){if(r=n.substring(t+1),n=n.substring(0,t),2!==r.length&&4!==r.length)throw new Error("Wrong input string for conversion");let i=parseInt(r.substring(0,2),10);if(isNaN(i.valueOf()))throw new Error("Wrong input string for conversion");if(o=e*i,4===r.length){if(i=parseInt(r.substring(2,4),10),isNaN(i.valueOf()))throw new Error("Wrong input string for conversion");a=e*i}}}let c=n.indexOf(".");if(-1===c&&(c=n.indexOf(",")),-1!==c){const e=new Number(`0${n.substring(c)}`);if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");s=e.valueOf(),i=n.substring(0,c)}else i=n;switch(!0){case 8===i.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==c)throw new Error("Wrong input string for conversion");break;case 10===i.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.minute=Math.floor(e),e=60*(e-this.minute),this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 12===i.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){let e=60*s;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===i.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==c){const e=1e3*s;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const u=t.exec(i);if(null===u)throw new Error("Wrong input string for conversion");for(let l=1;l<u.length;l++)switch(l){case 1:this.year=parseInt(u[l],10);break;case 2:this.month=parseInt(u[l],10);break;case 3:this.day=parseInt(u[l],10);break;case 4:this.hour=parseInt(u[l],10)+o;break;case 5:this.minute=parseInt(u[l],10)+a;break;case 6:this.second=parseInt(u[l],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===r){const e=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond);this.year=e.getUTCFullYear(),this.month=e.getUTCMonth(),this.day=e.getUTCDay(),this.hour=e.getUTCHours(),this.minute=e.getUTCMinutes(),this.second=e.getUTCSeconds(),this.millisecond=e.getUTCMilliseconds()}}toString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"iso";if("iso"===e){const e=[];return e.push(XN(this.year,4)),e.push(XN(this.month,2)),e.push(XN(this.day,2)),e.push(XN(this.hour,2)),e.push(XN(this.minute,2)),e.push(XN(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(XN(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}WB=GU,bB.GeneralizedTime=WB,GU.NAME="GeneralizedTime";class WU extends DU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}YB=WU,bB.DATE=YB,WU.NAME="DATE";class YU extends DU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}QB=YU,bB.TimeOfDay=QB,YU.NAME="TimeOfDay";class QU extends DU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}JB=QU,bB.DateTime=JB,QU.NAME="DateTime";class JU extends DU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}XB=JU,bB.Duration=XB,JU.NAME="Duration";class XU extends DU{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}ZB=XU,bB.TIME=ZB,XU.NAME="TIME";function ZU(e){if(isNaN(e)||e<=0)throw new Xp("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Cc(e)}function eL(e){let t=e.toString(16);t.length%2>0&&(t=`0${t}`);const r=t.length/2,n=new Uint8Array(r);let i=0,s=0;for(;i<r;)n[i]=parseInt(t.slice(s,s+2),16),i+=1,s+=2;return n}function tL(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r=`0${r}`),t.push(r)})),BigInt("0x"+t.join(""))}const rL=32,nL=1e4;const iL=8192;class sL{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,r){const n=await xN.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return xN.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new fU({valueHex:new xU({value:[mU.fromBigInt(tL(aD(e.n,"base64url"))),mU.fromBigInt(tL(aD(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return PN.encode({Type:TN.RSA,Data:this.marshal()}).subarray()}equals(e){return zP(this.bytes,e.bytes)}hash(){const e=DP.digest(this.bytes);return _N(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class oL{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return ZU(16)}sign(e){return async function(e,t){const r=await xN.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await xN.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new Xp("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new sL(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new mU({value:0}),mU.fromBigInt(tL(aD(e.n,"base64url"))),mU.fromBigInt(tL(aD(e.e,"base64url"))),mU.fromBigInt(tL(aD(e.d,"base64url"))),mU.fromBigInt(tL(aD(e.p,"base64url"))),mU.fromBigInt(tL(aD(e.q,"base64url"))),mU.fromBigInt(tL(aD(e.dp,"base64url"))),mU.fromBigInt(tL(aD(e.dq,"base64url"))),mU.fromBigInt(tL(aD(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return DN.encode({Type:TN.RSA,Data:this.marshal()}).subarray()}equals(e){return zP(this.bytes,e.bytes)}hash(){const e=DP.digest(this.bytes);return _N(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return sD(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=xN.get(),n=new xU({value:[new mU({value:0}),new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new hU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),s=ZU(16),o=await jN(Ef,t,s,{c:nL,dkLen:rL}),a=ZU(16),c=await r.subtle.importKey("raw",o,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new xU({value:[new hU({valueHex:s}),new mU({value:nL}),new mU({value:rL}),new xU({value:[new EU({value:"1.2.840.113549.2.11"}),new aU]})]}),h=new xU({value:[new EU({value:"1.2.840.113549.1.5.13"}),new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.5.12"}),l]}),new xU({value:[new EU({value:"2.16.840.1.101.3.4.1.42"}),new hU({valueHex:a})]})]})]}),d=new xU({value:[h,new hU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...sD(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return CN(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function aL(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value;return{n:sD(eL(r[1].toBigInt()),"base64url"),e:sD(eL(r[2].toBigInt()),"base64url"),d:sD(eL(r[3].toBigInt()),"base64url"),p:sD(eL(r[4].toBigInt()),"base64url"),q:sD(eL(r[5].toBigInt()),"base64url"),dp:sD(eL(r[6].toBigInt()),"base64url"),dq:sD(eL(r[7].toBigInt()),"base64url"),qi:sD(eL(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(zN(t)>iL)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await KN(t);return new oL(r.privateKey,r.publicKey)}function cL(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:sD(eL(r[0].toBigInt()),"base64url"),e:sD(eL(r[1].toBigInt()),"base64url")}}(e);if(zN(t)>iL)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new sL(t)}async function uL(e){if(zN(e)>iL)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await KN(e);return new oL(t.privateKey,t.publicKey)}async function lL(e){if(e>iL)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await xN.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await FN(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new oL(t.privateKey,t.publicKey)}function hL(e){try{lm.ProjectivePoint.fromHex(e)}catch(t){throw new Xp(String(t),"ERR_INVALID_PUBLIC_KEY")}}class dL{_key;constructor(e){hL(e),this._key=e}verify(e,t){return function(e,t,r){const n=DP.digest(r instanceof Uint8Array?r:r.subarray());if(_N(n))return n.then((r=>{let{digest:n}=r;return lm.verify(t,n,e)})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.verify(t,n.digest,e)}catch(i){throw new Xp(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,lm.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return PN.encode({Type:TN.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return zP(this.bytes,e.bytes)}async hash(){const e=DP.digest(this.bytes);let t;return _N(e)?({bytes:t}=await e):t=e.bytes,t}}class fL{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),hL(this._publicKey)}sign(e){return function(e,t){const r=DP.digest(t instanceof Uint8Array?t:t.subarray());if(_N(r))return r.then((t=>{let{digest:r}=t;return lm.sign(r,e).toDERRawBytes()})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.sign(r.digest,e).toDERRawBytes()}catch(n){throw new Xp(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new dL(this._publicKey)}marshal(){return this._key}get bytes(){return DN.encode({Type:TN.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return zP(this.bytes,e.bytes)}hash(){const e=DP.digest(this.bytes);return _N(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return sD(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return CN(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function pL(e){return new fL(e)}function gL(e){return new dL(e)}async function bL(){const e=lm.utils.randomPrivateKey();return new fL(e)}const yL={rsa:St,ed25519:Et,secp256k1:At};function mL(e){const t=Object.keys(yL).join(" / ");return new Xp(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}async function wL(e){const t=DN.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case TN.RSA:return yL.rsa.unmarshalRsaPrivateKey(r);case TN.Ed25519:return yL.ed25519.unmarshalEd25519PrivateKey(r);case TN.Secp256k1:return yL.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw mL(t.Type??"RSA")}}const vL="ERR_SIGNATURE_NOT_VALID";var _L;!function(e){let t;e.codec=()=>(null==t&&(t=wN((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.publicKey&&e.publicKey.byteLength>0&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.payloadType&&e.payloadType.byteLength>0&&(t.uint32(18),t.bytes(e.payloadType)),null!=e.payload&&e.payload.byteLength>0&&(t.uint32(26),t.bytes(e.payload)),null!=e.signature&&e.signature.byteLength>0&&(t.uint32(42),t.bytes(e.signature)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.publicKey=e.bytes();break;case 2:r.payloadType=e.bytes();break;case 3:r.payload=e.bytes();break;case 5:r.signature=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>gN(t,e.codec()),e.decode=t=>tN(t,e.codec())}(_L||(_L={}));class EL{static createFromProtobuf=async e=>{const t=_L.decode(e),r=await async function(e,t){return e.length===GP?new JP({multihash:AP(CP.code,e),privateKey:t}):e.length===WP?new XP({multihash:AP(CP.code,e),privateKey:t}):new QP({multihash:await DP.digest(e),publicKey:e,privateKey:t})}(t.publicKey);return new EL({peerId:r,payloadType:t.payloadType,payload:t.payload,signature:t.signature})};static seal=async(e,t)=>{if(null==t.privateKey)throw new Error("Missing private key");const r=e.domain,n=e.codec,i=e.marshal(),s=SL(r,n,i),o=await wL(t.privateKey),a=await o.sign(s.subarray());return new EL({peerId:t,payloadType:n,payload:i,signature:a})};static openAndCertify=async(e,t)=>{const r=await EL.createFromProtobuf(e);if(!await r.validate(t))throw new Xp("envelope signature is not valid for the given domain",vL);return r};peerId;payloadType;payload;signature;marshaled;constructor(e){const{peerId:t,payloadType:r,payload:n,signature:i}=e;this.peerId=t,this.payloadType=r,this.payload=n,this.signature=i}marshal(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=_L.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return zP(this.marshal(),e.marshal())}async validate(e){const t=SL(e,this.payloadType,this.payload);if(null==this.peerId.publicKey)throw new Error("Missing public key");return function(e){const t=PN.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case TN.RSA:return yL.rsa.unmarshalRsaPublicKey(r);case TN.Ed25519:return yL.ed25519.unmarshalEd25519PublicKey(r);case TN.Secp256k1:return yL.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw mL(t.Type??"unknown")}}(this.peerId.publicKey).verify(t.subarray(),this.signature)}}const SL=(e,t,r)=>{const n=aD(e),i=ms(n.byteLength),s=ms(t.length),o=ms(r.length);return new Zl(i,n,s,t,o,r)};function AL(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function kL(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const xL=kL("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),IL=kL("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=AL((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),CL={utf8:xL,"utf-8":xL,hex:XT.base16,latin1:IL,ascii:IL,binary:IL,...XT};function TL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=CL[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function RL(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=AL(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}function PL(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=CL[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}const DL=Ex,NL=Sx,BL=function(e){let t=0;if(e=e.toString().trim(),DL(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(NL(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;DL(r[n])&&(e=BL(r[n]),r[n]=TL(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,TL(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},UL=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(4===r){const n=[];for(let i=0;i<r;i++)n.push(e[t+i]);return n.join(".")}if(16===r){const e=[];for(let i=0;i<r;i+=2)e.push(n.getUint16(t+i).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},LL=-1,ML={},OL={};function qL(e){if("number"===typeof e){if(null!=OL[e])return OL[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=ML[e])return ML[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,LL,"ip6zone"],[43,8,"ipcidr"],[53,LL,"dns",!0],[54,LL,"dns4",!0],[55,LL,"dns6",!0],[56,LL,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,LL,"unix",!1,!0],[421,LL,"ipfs"],[421,LL,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,LL,"garlic64"],[448,0,"tls"],[449,LL,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,LL,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,LL,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);OL[t.code]=t,ML[t.name]=t}));qL("ip4"),qL("ip6"),qL("ipcidr");function KL(e,t){switch(qL(e).code){case 4:case 41:return function(e){const t=UL(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Ax(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return WL(t);case 6:case 273:case 33:case 132:return jL(t).toString();case 421:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return TL(r,"base58btc")}(t);case 444:case 445:return YL(t);case 466:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+TL(r,"base64url")}(t);default:return TL(t,"base16")}}function FL(e,t){switch(qL(e).code){case 4:case 41:return $L(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return GL(t);case 6:case 273:case 33:case 132:return HL(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?UT(PC.decode(`z${e}`)).bytes:GT.parse(e).multihash.bytes;const r=Uint8Array.from(ms(t.length));return RL([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(16!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=FC.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=HL(n);return RL([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(56!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=FC.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=HL(n);return RL([r,i],r.length+i.length)}(t);case 466:return function(e){const t=zL.decode(e),r=Uint8Array.from(ms(t.length));return RL([r,t],r.length+t.length)}(t);default:return PL(t,"base16")}}const VL=Object.values(XT).map((e=>e.decoder)),zL=function(){let e=VL[0].or(VL[1]);return VL.slice(2).forEach((t=>e=e.or(t))),e}();function $L(e){if(!Ax(e))throw new Error("invalid ip address");return BL(e)}function HL(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function jL(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function GL(e){const t=PL(e),r=Uint8Array.from(ms(t.length));return RL([r,t],r.length+t.length)}function WL(e){const t=ws(e);if((e=e.slice(gs(t))).length!==t)throw new Error("inconsistent lengths");return TL(e)}function YL(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return`${TL(t,"base32")}:${jL(r)}`}function QL(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const s=ws(e,i),o=gs(s),a=qL(s),c=ZL(a,e.slice(i+o));if(0===c){t.push([s]),r.push([s]),i+=o;continue}const u=e.slice(i+o,i+o+c);if(i+=c+o,i>e.length)throw tM("Invalid address Uint8Array: "+TL(e,"base16"));t.push([s,u]);const l=KL(s,u);if(r.push([s,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:JL(r),tuples:t,stringTuples:r,path:n}}function JL(e){const t=[];return e.map((e=>{const r=qL(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),eM(t.join("/"))}function XL(e){return RL(e.map((e=>{const t=qL(e[0]);let r=Uint8Array.from(ms(t.code));return e.length>1&&null!=e[1]&&(r=RL([r,e[1]])),r})))}function ZL(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=ws(t instanceof Uint8Array?t:Uint8Array.from(t));return e+gs(e)}}function eM(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function tM(e){return new Error("Error parsing address: "+e)}const rM=Symbol.for("nodejs.util.inspect.custom"),nM=Symbol.for("@multiformats/js-multiaddr/multiaddr"),iM=[qL("dns").code,qL("dns4").code,qL("dns6").code,qL("dnsaddr").code];class sM{bytes;#t;#r;#n;#i;[nM]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=QL(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);t=function(e){const t=[],r=[];let n=null;const i=(e=eM(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){const o=qL(i[s]);if(0===o.size){t.push([o.code]),r.push([o.code]);continue}if(s++,s>=i.length)throw tM("invalid address: "+e);if(!0===o.path){n=eM(i.slice(s).join("/")),t.push([o.code,FL(o.code,n)]),r.push([o.code,n]);break}const a=FL(o.code,i[s]);t.push([o.code,a]),r.push([o.code,KL(o.code,a)])}return{string:JL(r),bytes:XL(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!aM(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=QL(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#r=t.tuples,this.#n=t.stringTuples,this.#i=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const s=qL("tcp"),o=qL("udp"),a=qL("ip4"),c=qL("ip6"),u=qL("dns6"),l=qL("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i=`%${d??""}`),iM.includes(h)&&(t=s.name,n=443,r=`${d??""}${i}`,e=h===u.code?6:4),h!==s.code&&h!==o.code||(t=qL(h).name,n=parseInt(d??"")),h!==a.code&&h!==c.code||(t=qL(h).name,r=`${d??""}${i}`,e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return this.#r.map((e=>{let[t]=e;return Object.assign({},qL(t))}))}protoCodes(){return this.#r.map((e=>{let[t]=e;return t}))}protoNames(){return this.#r.map((e=>{let[t]=e;return qL(t).name}))}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new sM(e),new sM(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new sM(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new sM(XL(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===ML.p2p.code&&e.push([r,n]),r===ML["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?TL(PC.decode(`z${e}`),"base58btc"):TL(GT.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#i}equals(e){return ZT(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=oM.get(t.name);if(null==r)throw new Xp(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>cM(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(e??this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[rM](){return`Multiaddr(${this.#t})`}}const oM=new Map;function aM(e){return Boolean(e?.[nM])}function cM(e){return new sM(e)}new Uint8Array(0);var uM=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const lM=uM;class hM{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class dM{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return pM(this,e)}}class fM{decoders;constructor(e){this.decoders=e}or(e){return pM(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function pM(e,t){return new fM({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class gM{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new hM(e,t,r),this.decoder=new dM(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function bM(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new gM(t,r,n,i)}function yM(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=lM(n,t);return bM({prefix:r,name:t,encode:i,decode:e=>function(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}(s(e))})}function mM(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return bM({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const wM=yM({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),vM=(yM({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),mM({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),mM({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),mM({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6})),_M=(mM({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),e=>({match:t=>!(t.length<1)&&(!!e(t[0])&&t.slice(1)),pattern:"fn"})),EM=e=>({match:t=>_M((t=>t===e)).match(t),pattern:e}),SM=()=>({match:e=>_M((e=>"string"===typeof e)).match(e),pattern:"{string}"}),AM=()=>({match:e=>_M((e=>!isNaN(parseInt(e)))).match(e),pattern:"{number}"}),kM=()=>({match:e=>{if(e.length<2)return!1;if("p2p"!==e[0]&&"ipfs"!==e[0])return!1;if(!e[1].startsWith("Q")&&!e[1].startsWith("1"))return!1;try{wM.decode(`z${e[1]}`)}catch(t){return!1}return e.slice(2)},pattern:"/p2p/{peerid}"}),xM=()=>({match:e=>{if(e.length<2)return!1;if("certhash"!==e[0])return!1;try{vM.decode(e[1])}catch{return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),IM=e=>({match:t=>{const r=e.match(t);return!1===r?t:r},pattern:`optional(${e.pattern})`}),CM=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return{match:e=>{let r;for(const n of t){const t=n.match(e);!1!==t&&((null==r||t.length<r.length)&&(r=t))}return null!=r&&r},pattern:`or(${t.map((e=>e.pattern)).join(", ")})`}},TM=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return{match:e=>{for(const r of t){const t=r.match(e);if(!1===t)return!1;e=t}return e},pattern:`and(${t.map((e=>e.pattern)).join(", ")})`}};function RM(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];function n(e){let r=(e=>e.toString().split("/").slice(1))(e);for(const n of t){const e=n.match(r);if(!1===e)return!1;r=e}return r}return{matches:function(e){return!1!==n(e)},exactMatch:function(e){const t=n(e);return!1!==t&&0===t.length}}}const PM=TM(EM("dns4"),SM()),DM=TM(EM("dns6"),SM()),NM=TM(EM("dnsaddr"),SM()),BM=TM(EM("dns"),SM()),UM=(RM(PM),RM(DM),RM(NM),RM(CM(BM,NM,PM,DM)),TM(EM("ip4"),_M(Ex))),LM=TM(EM("ip6"),_M(Sx)),MM=CM(UM,LM),OM=CM(MM,BM,PM,DM,NM),qM=RM(OM),KM=(RM(UM),RM(LM),RM(MM),TM(OM,EM("tcp"),AM())),FM=TM(OM,EM("udp"),AM()),VM=CM(KM,FM),zM=(RM(KM),RM(FM),TM(FM,EM("quic"))),$M=TM(FM,EM("quic-v1")),HM=CM(zM,$M),jM=(RM(zM),RM($M),CM(OM,KM,FM,zM,$M)),GM=CM(TM(jM,EM("ws"),IM(kM()))),WM=(RM(GM),CM(TM(jM,EM("wss"),IM(kM())),TM(jM,EM("tls"),EM("ws"),IM(kM())))),YM=(RM(WM),TM(VM,EM("webrtc-direct"),xM(),IM(xM()),IM(kM()))),QM=(RM(YM),TM($M,EM("webtransport"),xM(),xM(),IM(kM()))),JM=(RM(QM),CM(GM,WM,TM(KM,IM(kM())),TM(HM,IM(kM())),TM(OM,IM(kM())),YM,QM,kM())),XM=(RM(JM),RM(TM(JM,EM("p2p-circuit"),kM())));RM(CM(TM(JM,EM("p2p-circuit"),EM("webrtc"),kM()),TM(JM,EM("webrtc"),IM(kM())),EM("webrtc"))),RM(CM(TM(OM,EM("tcp"),AM(),EM("http"),IM(kM())),TM(OM,EM("http"),IM(kM())))),RM(CM(TM(OM,EM("tcp"),CM(TM(EM("443"),EM("http")),TM(AM(),EM("https"))),IM(kM())),TM(OM,EM("tls"),EM("http"),IM(kM())),TM(OM,EM("https"),IM(kM()))));function ZM(e,t){const r=Sd(e,t),n={read:async(e,t)=>{const n=await r.read(t);return e.decode(n)},write:async(e,t,n)=>{await r.write(t.encode(e),n)},writeV:async(e,t,n)=>{await r.writeV(e.map((e=>t.encode(e))),n)},pb:e=>({read:async t=>n.read(e,t),write:async(t,r)=>n.write(t,e,r),writeV:async(t,r)=>n.writeV(t,e,r),unwrap:()=>n}),unwrap:()=>r.unwrap()};return n}var eO=__webpack_require__(4053);const tO="object"===typeof window&&"object"===typeof document&&9===document.nodeType,rO=eO(),nO=tO&&!rO,iO=rO&&!tO,sO=rO&&tO,oO="undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.release&&"node"===globalThis.process.release.name&&!rO,aO="function"===typeof importScripts&&"undefined"!==typeof self&&"undefined"!==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,cO=("undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.env&&globalThis.process.env.NODE_ENV,"undefined"!==typeof navigator&&"ReactNative"===navigator.product),uO=new Float32Array([-0]),lO=new Uint8Array(uO.buffer);function hO(e,t,r){uO[0]=e,t[r]=lO[0],t[r+1]=lO[1],t[r+2]=lO[2],t[r+3]=lO[3]}const dO=new Float64Array([-0]),fO=new Uint8Array(dO.buffer);function pO(e,t,r){dO[0]=e,t[r]=fO[0],t[r+1]=fO[1],t[r+2]=fO[2],t[r+3]=fO[3],t[r+4]=fO[4],t[r+5]=fO[5],t[r+6]=fO[6],t[r+7]=fO[7]}const gO=BigInt(Number.MAX_SAFE_INTEGER),bO=BigInt(Number.MIN_SAFE_INTEGER);class yO{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return mO;if(e<gO&&e>bO)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>wO&&(n=0n,++r>wO&&(r=0n))),new yO(Number(n),Number(r))}static fromNumber(e){if(0===e)return mO;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new yO(r,n)}static from(e){return"number"===typeof e?yO.fromNumber(e):"bigint"===typeof e?yO.fromBigInt(e):"string"===typeof e?yO.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new yO(e.low>>>0,e.high>>>0):mO}}const mO=new yO(0,0);mO.toBigInt=function(){return 0n},mO.zzEncode=mO.zzDecode=function(){return this},mO.length=function(){return 1};const wO=4294967296n;function vO(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function _O(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function EO(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class SO{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,_O(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw _O(this,4);return EO(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw _O(this,4);return 0|EO(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw _O(this,4);const e=(t=this.buf,r=this.pos,lO[0]=t[r],lO[1]=t[r+1],lO[2]=t[r+2],lO[3]=t[r+3],uO[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw _O(this,4);const e=(t=this.buf,r=this.pos,fO[0]=t[r],fO[1]=t[r+1],fO[2]=t[r+2],fO[3]=t[r+3],fO[4]=t[r+4],fO[5]=t[r+5],fO[6]=t[r+6],fO[7]=t[r+7],dO[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw _O(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw _O(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw _O(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new yO(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw _O(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw _O(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw _O(this,8);const e=EO(this.buf,this.pos+=4),t=EO(this.buf,this.pos+=4);return new yO(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 AO(e,t,r){const n=function(e){return new SO(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class kO{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function xO(){}class IO{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const CO=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return AL(e);i+e>t&&(n=AL(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class TO{len;head;tail;states;constructor(){this.len=0,this.head=new kO(xO,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new kO(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new DO((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(NO,10,yO.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=yO.fromBigInt(e);return this._push(NO,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=yO.fromBigInt(e).zzEncode();return this._push(NO,t.length(),t)}sint64Number(e){const t=yO.fromNumber(e).zzEncode();return this._push(NO,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(RO,1,e?1:0)}fixed32(e){return this._push(BO,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=yO.fromBigInt(e);return this._push(BO,4,t.lo)._push(BO,4,t.hi)}fixed64Number(e){const t=yO.fromNumber(e);return this._push(BO,4,t.lo)._push(BO,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(hO,4,e)}double(e){return this._push(pO,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(RO,1,0):this.uint32(t)._push(UO,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(vO,t,e):this._push(RO,1,0)}fork(){return this.states=new IO(this),this.head=this.tail=new kO(xO,0,0),this.len=0,this}reset(){return null!=this.states?(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 kO(xO,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?AL(r):CO(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function RO(e,t,r){t[r]=255&e}function PO(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class DO extends kO{next;constructor(e,t){super(PO,e,t),this.next=void 0}}function NO(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function BO(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function UO(e,t,r){t.set(e,r)}function LO(e,t,r){t.set(e,r)}function MO(e,t,r){e.length<40?vO(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(PL(e),r)}function OO(e,t){const r=new TO;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var qO,KO;null!=globalThis.Buffer&&(TO.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(LO,t,e),this},TO.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(MO,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(qO||(qO={}));Error;!function(e){let t;e.codec=()=>(null==t&&(t=function(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",qO.LENGTH_DELIMITED,e,t)}((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.protocolVersion&&(t.uint32(42),t.string(e.protocolVersion)),null!=e.agentVersion&&(t.uint32(50),t.string(e.agentVersion)),null!=e.publicKey&&(t.uint32(10),t.bytes(e.publicKey)),null!=e.listenAddrs)for(const n of e.listenAddrs)t.uint32(18),t.bytes(n);if(null!=e.observedAddr&&(t.uint32(34),t.bytes(e.observedAddr)),null!=e.protocols)for(const n of e.protocols)t.uint32(26),t.string(n);null!=e.signedPeerRecord&&(t.uint32(66),t.bytes(e.signedPeerRecord)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={listenAddrs:[],protocols:[]},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 5:r.protocolVersion=e.string();break;case 6:r.agentVersion=e.string();break;case 1:r.publicKey=e.bytes();break;case 2:r.listenAddrs.push(e.bytes());break;case 4:r.observedAddr=e.bytes();break;case 3:r.protocols.push(e.string());break;case 8:r.signedPeerRecord=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>OO(t,e.codec()),e.decode=t=>AO(t,e.codec())}(KO||(KO={}));const FO=8192,VO="ipfs",zO=6e4,$O=1,HO=1,jO=1,GO=1,WO=10,YO=8192,QO=!0,JO=!0;class XO{identifyProtocolStr;identifyPushProtocolStr;host;started;timeout;peerId;peerStore;registrar;connectionManager;addressManager;maxInboundStreams;maxOutboundStreams;maxPushIncomingStreams;maxPushOutgoingStreams;maxIdentifyMessageSize;maxObservedAddresses;events;runOnTransientConnection;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.started=!1,this.peerId=e.peerId,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.connectionManager=e.connectionManager,this.events=e.events,this.log=e.logger.forComponent("libp2p:identify"),this.identifyProtocolStr=`/${t.protocolPrefix??VO}/id/1.0.0`,this.identifyPushProtocolStr=`/${t.protocolPrefix??VO}/id/push/1.0.0`,this.timeout=t.timeout??zO,this.maxInboundStreams=t.maxInboundStreams??$O,this.maxOutboundStreams=t.maxOutboundStreams??HO,this.maxPushIncomingStreams=t.maxPushIncomingStreams??jO,this.maxPushOutgoingStreams=t.maxPushOutgoingStreams??GO,this.maxIdentifyMessageSize=t.maxIdentifyMessageSize??YO,this.maxObservedAddresses=t.maxObservedAddresses??WO,this.runOnTransientConnection=t.runOnTransientConnection??JO,this.host={protocolVersion:`${t.protocolPrefix??VO}/0.1.0`,agentVersion:t.agentVersion??`${e.nodeInfo.name}/${e.nodeInfo.version}`},(t.runOnConnectionOpen??QO)&&e.events.addEventListener("connection:open",(e=>{const t=e.detail;this.identify(t).catch((e=>{this.log.error("error during identify trigged by connection:open",e)}))})),e.events.addEventListener("self:peer:update",(e=>{this.push().catch((e=>{this.log.error(e)}))})),this.host.agentVersion===`${e.nodeInfo.name}/${e.nodeInfo.version}`&&(oO||iO?this.host.agentVersion+=` UserAgent=${globalThis.process.version}`:(nO||aO||sO||cO)&&(this.host.agentVersion+=` UserAgent=${globalThis.navigator.userAgent}`))}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:PL(this.host.agentVersion),ProtocolVersion:PL(this.host.protocolVersion)}}),await this.registrar.handle(this.identifyProtocolStr,(e=>{this._handleIdentify(e).catch((e=>{this.log.error(e)}))}),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),await this.registrar.handle(this.identifyPushProtocolStr,(e=>{this._handlePush(e).catch((e=>{this.log.error(e)}))}),{maxInboundStreams:this.maxPushIncomingStreams,maxOutboundStreams:this.maxPushOutgoingStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.identifyProtocolStr),await this.registrar.unhandle(this.identifyPushProtocolStr),this.started=!1}async pushToConnections(e){const t=this.addressManager.getAddresses().map((e=>e.decapsulateCode(qL("p2p").code))),r=new vN({peerId:this.peerId,multiaddrs:t}),n=await EL.seal(r,this.peerId),i=this.registrar.getProtocols(),s=await this.peerStore.get(this.peerId),o=TL(s.metadata.get("AgentVersion")??PL(this.host.agentVersion)),a=TL(s.metadata.get("ProtocolVersion")??PL(this.host.protocolVersion)),c=e.map((async e=>{let r;const s=AbortSignal.timeout(this.timeout);id(1/0,s);try{r=await e.newStream(this.identifyPushProtocolStr,{signal:s,runOnTransientConnection:this.runOnTransientConnection});const c=ZM(r,{maxDataLength:this.maxIdentifyMessageSize??FO}).pb(KO);await c.write({listenAddrs:t.map((e=>e.bytes)),signedPeerRecord:n.marshal(),protocols:i,agentVersion:o,protocolVersion:a},{signal:s}),await r.close({signal:s})}catch(c){this.log.error("could not push identify update to peer",c),r?.abort(c)}}));await Promise.all(c)}async push(){if(!this.isStarted())return;const e=[];await Promise.all(this.connectionManager.getConnections().map((async t=>{try{if(!(await this.peerStore.get(t.remotePeer)).protocols.includes(this.identifyPushProtocolStr))return;e.push(t)}catch(r){if("ERR_NOT_FOUND"!==r.code)throw r}}))),await this.pushToConnections(e)}async _identify(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==r.signal){const e=AbortSignal.timeout(this.timeout);id(1/0,e),r={...r,signal:e}}try{t=await e.newStream(this.identifyProtocolStr,{...r,runOnTransientConnection:this.runOnTransientConnection});const n=ZM(t,{maxDataLength:this.maxIdentifyMessageSize??FO}).pb(KO),i=await n.read(r);return await t.close(r),i}catch(n){throw this.log.error("error while reading identify message",n),t?.abort(n),n}}async identify(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=await this._identify(e,t),{publicKey:n,protocols:i,observedAddr:s}=r;if(null==n)throw new Xp("public key was missing from identify message","ERR_MISSING_PUBLIC_KEY");const o=await uR(n);if(!e.remotePeer.equals(o))throw new Xp("identified peer does not match the expected peer","ERR_INVALID_PEER");if(this.peerId.equals(o))throw new Xp("identified peer is our own peer id?","ERR_INVALID_PEER");const a=function(e){if(null!=e&&e.length>0)try{return cM(e)}catch{}}(s);return this.log("identify completed for peer %p and protocols %o",o,i),this.log("our observed address is %a",a),null!=a&&this.addressManager.getObservedAddrs().length<(this.maxObservedAddresses??1/0)&&(this.log("storing our observed address %a",a),this.addressManager.addObservedAddr(a)),this.#s(e,r)}async _handleIdentify(e){const{connection:t,stream:r}=e,n=AbortSignal.timeout(this.timeout);id(1/0,n);try{const e=this.peerId.publicKey??new Uint8Array(0),i=await this.peerStore.get(this.peerId),s=this.addressManager.getAddresses().map((e=>e.decapsulateCode(qL("p2p").code)));let o=i.peerRecordEnvelope;if(s.length>0&&null==o){const e=new vN({peerId:this.peerId,multiaddrs:s});o=(await EL.seal(e,this.peerId)).marshal().subarray()}let a=t.remoteAddr.bytes;qM.matches(t.remoteAddr)||(a=void 0);const c=ZM(r).pb(KO);await c.write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:e,listenAddrs:s.map((e=>e.bytes)),signedPeerRecord:o,observedAddr:a,protocols:i.protocols},{signal:n}),await r.close({signal:n})}catch(i){this.log.error("could not respond to identify request",i),r.abort(i)}}async _handlePush(e){const{connection:t,stream:r}=e;try{if(this.peerId.equals(t.remotePeer))throw new Error("received push from ourselves?");const e={signal:AbortSignal.timeout(this.timeout)},n=ZM(r,{maxDataLength:this.maxIdentifyMessageSize??FO}).pb(KO),i=await n.read(e);await r.close(e),await this.#s(t,i)}catch(n){return this.log.error("received invalid message",n),void r.abort(n)}this.log("handled push from %p",t.remotePeer)}async#s(e,t){if(this.log("received identify from %p",e.remotePeer),null==t)throw new Xp("message was null or undefined","ERR_INVALID_MESSAGE");const r={};if(t.listenAddrs.length>0&&(r.addresses=t.listenAddrs.map((e=>({isCertified:!1,multiaddr:cM(e)})))),t.protocols.length>0&&(r.protocols=t.protocols),null!=t.publicKey){r.publicKey=t.publicKey;if(!(await uR(t.publicKey)).equals(e.remotePeer))throw new Xp("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY")}let n;if(null!=t.signedPeerRecord){this.log("received signedPeerRecord from %p",e.remotePeer);let i=t.signedPeerRecord;const o=await EL.openAndCertify(i,vN.DOMAIN);let a,c=vN.createFromProtobuf(o.payload);if(!c.peerId.equals(o.peerId))throw new Xp("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!e.remotePeer.equals(c.peerId))throw new Xp("signing key does not match remote PeerId","ERR_INVALID_PEER_RECORD_KEY");try{a=await this.peerStore.get(c.peerId)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}if(null!=a&&(r.metadata=a.metadata,null!=a.peerRecordEnvelope)){const e=await EL.createFromProtobuf(a.peerRecordEnvelope),t=vN.createFromProtobuf(e.payload);t.seqNumber>=c.seqNumber&&(this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",t.seqNumber,c.seqNumber),c=t,i=a.peerRecordEnvelope)}r.peerRecordEnvelope=i,r.addresses=c.multiaddrs.map((e=>({isCertified:!0,multiaddr:e}))),n={seq:c.seqNumber,addresses:c.multiaddrs}}else this.log("%p did not send a signed peer record",e.remotePeer);if(this.log("patching %p with",e.remotePeer,r),await this.peerStore.patch(e.remotePeer,r),null!=t.agentVersion||null!=t.protocolVersion){const r={};null!=t.agentVersion&&(r.AgentVersion=PL(t.agentVersion)),null!=t.protocolVersion&&(r.ProtocolVersion=PL(t.protocolVersion)),this.log("merging %p metadata",e.remotePeer,r),await this.peerStore.merge(e.remotePeer,{metadata:r})}const i={peerId:e.remotePeer,protocolVersion:t.protocolVersion,agentVersion:t.agentVersion,publicKey:t.publicKey,listenAddrs:t.listenAddrs.map((e=>cM(e))),observedAddr:null==t.observedAddr?void 0:cM(t.observedAddr),protocols:t.protocols,signedPeerRecord:n,connection:e};return this.events.safeDispatchEvent("peer:identify",{detail:i}),i}}function ZO(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new XO(t,e)}function eq(e,t){const r=function(e){if(null!=e){if("function"===typeof e[Symbol.iterator])return e[Symbol.iterator]();if("function"===typeof e[Symbol.asyncIterator])return e[Symbol.asyncIterator]();if("function"===typeof e.next)return e}throw new Error("argument is not an iterator or iterable")}(e).return?.();var n;null!=(n=r)&&"function"===typeof n.then&&"function"===typeof n.catch&&"function"===typeof n.finally&&r.catch((e=>{t.error("could not cause iterator to return",e)}))}const tq=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},rq=new WeakMap;const nq=function(){let{clearTimeout:e,setTimeout:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(r){let n,i,s,{value:o,signal:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(a?.aborted)return Promise.reject(tq());const c=e??clearTimeout,u=()=>{c(n),s(tq())},l=new Promise(((e,c)=>{i=()=>{a&&a.removeEventListener("abort",u),e(o)},s=c,n=(t??setTimeout)(i,r)}));return a&&a.addEventListener("abort",u,{once:!0}),rq.set(l,(()=>{c(n),n=null,i()})),l}}(),iq=nq;class sq{memoryStorage;points;duration;blockDuration;execEvenly;execEvenlyMinDelayMs;keyPrefix;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.points=e.points??4,this.duration=e.duration??1,this.blockDuration=e.blockDuration??0,this.execEvenly=e.execEvenly??!1,this.execEvenlyMinDelayMs=e.execEvenlyMinDelayMs??1e3*this.duration/this.points,this.keyPrefix=e.keyPrefix??"rlflx",this.memoryStorage=new oq}async consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e),i=this._getKeySecDuration(r);let s=this.memoryStorage.incrby(n,t,i);if(s.remainingPoints=Math.max(this.points-s.consumedPoints,0),s.consumedPoints>this.points)throw this.blockDuration>0&&s.consumedPoints<=this.points+t&&(s=this.memoryStorage.set(n,s.consumedPoints,this.blockDuration)),new Xp("Rate limit exceeded","ERR_RATE_LIMIT_EXCEEDED",s);if(this.execEvenly&&s.msBeforeNext>0&&!s.isFirstInDuration){let e=Math.ceil(s.msBeforeNext/(s.remainingPoints+2));e<this.execEvenlyMinDelayMs&&(e=s.consumedPoints*this.execEvenlyMinDelayMs),await iq(e)}return s}penalty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e),i=this._getKeySecDuration(r),s=this.memoryStorage.incrby(n,t,i);return s.remainingPoints=Math.max(this.points-s.consumedPoints,0),s}reward(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=this.getKey(e),i=this._getKeySecDuration(r),s=this.memoryStorage.incrby(n,-t,i);return s.remainingPoints=Math.max(this.points-s.consumedPoints,0),s}block(e,t){const r=1e3*t,n=this.points+1;return this.memoryStorage.set(this.getKey(e),n,t),{remainingPoints:0,msBeforeNext:0===r?-1:r,consumedPoints:n,isFirstInDuration:!1}}set(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=1e3*(r>=0?r:this.duration);return this.memoryStorage.set(this.getKey(e),t,r),{remainingPoints:0,msBeforeNext:0===n?-1:n,consumedPoints:t,isFirstInDuration:!1}}get(e){const t=this.memoryStorage.get(this.getKey(e));return null!=t&&(t.remainingPoints=Math.max(this.points-t.consumedPoints,0)),t}delete(e){this.memoryStorage.delete(this.getKey(e))}_getKeySecDuration(e){return null!=e?.customDuration&&e.customDuration>=0?e.customDuration:this.duration}getKey(e){return this.keyPrefix.length>0?`${this.keyPrefix}:${e}`:e}parseKey(e){return e.substring(this.keyPrefix.length)}}class oq{storage;constructor(){this.storage=new Map}incrby(e,t,r){const n=this.storage.get(e);if(null!=n){const i=null!=n.expiresAt?n.expiresAt.getTime()-(new Date).getTime():-1;return null==n.expiresAt||i>0?(n.value+=t,{remainingPoints:0,msBeforeNext:i,consumedPoints:n.value,isFirstInDuration:!1}):this.set(e,t,r)}return this.set(e,t,r)}set(e,t,r){const n=1e3*r,i=this.storage.get(e);null!=i&&clearTimeout(i.timeoutId);const s={value:t,expiresAt:n>0?new Date(Date.now()+n):void 0};return this.storage.set(e,s),n>0&&(s.timeoutId=setTimeout((()=>{this.storage.delete(e)}),n),null!=s.timeoutId.unref&&s.timeoutId.unref()),{remainingPoints:0,msBeforeNext:0===n?-1:n,consumedPoints:s.value,isFirstInDuration:!0}}get(e){const t=this.storage.get(e);if(null!=t){return{remainingPoints:0,msBeforeNext:null!=t.expiresAt?t.expiresAt.getTime()-(new Date).getTime():-1,consumedPoints:t.value,isFirstInDuration:!1}}}delete(e){const t=this.storage.get(e);return null!=t&&(null!=t.timeoutId&&clearTimeout(t.timeoutId),this.storage.delete(e),!0)}}new Uint8Array(0);function aq(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var cq=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const uq=cq;class lq{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class hq{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return fq(this,e)}}class dq{decoders;constructor(e){this.decoders=e}or(e){return fq(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function fq(e,t){return new dq({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class pq{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new lq(e,t,r),this.decoder=new hq(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function gq(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new pq(t,r,n,i)}function bq(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=uq(n,t);return gq({prefix:r,name:t,encode:i,decode:e=>aq(s(e))})}function yq(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return gq({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const mq=bq({prefix:"9",name:"base10",alphabet:"0123456789"}),wq=yq({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),vq=yq({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),_q=yq({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Eq=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Sq=Eq.reduce(((e,t,r)=>(e[r]=t,e)),[]),Aq=Eq.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const kq=gq({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Sq[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Aq[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),xq=yq({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Iq=yq({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Cq=yq({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Tq=yq({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Rq=yq({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Pq=yq({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Dq=yq({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nq=yq({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bq=yq({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Uq=bq({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Lq=bq({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Mq=bq({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Oq=bq({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),qq=yq({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Kq=yq({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Fq=yq({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vq=yq({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),zq=yq({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),$q=gq({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Hq=new TextEncoder,jq=new TextDecoder,Gq="json",Wq=512;function Yq(e){return Hq.encode(JSON.stringify(e))}function Qq(e){return JSON.parse(jq.decode(e))}const Jq="raw",Xq=85;function Zq(e){return aq(e)}function eK(e){return aq(e)}var tK=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=iK;)r[n++]=255&t|rK,t/=128;for(;t&nK;)r[n++]=255&t|rK,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},rK=128,nK=-128,iK=Math.pow(2,31);var sK=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&aK)<<s:(n&aK)*Math.pow(2,s),s+=7}while(n>=oK);return e.bytes=o-r,i},oK=128,aK=127;var cK=Math.pow(2,7),uK=Math.pow(2,14),lK=Math.pow(2,21),hK=Math.pow(2,28),dK=Math.pow(2,35),fK=Math.pow(2,42),pK=Math.pow(2,49),gK=Math.pow(2,56),bK=Math.pow(2,63);const yK={encode:tK,decode:sK,encodingLength:function(e){return e<cK?1:e<uK?2:e<lK?3:e<hK?4:e<dK?5:e<fK?6:e<pK?7:e<gK?8:e<bK?9:10}};function mK(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return yK.encode(e,t,r),t}function wK(e){return yK.encodingLength(e)}function vK(e,t){const r=t.byteLength,n=wK(e),i=n+wK(r),s=new Uint8Array(i+r);return mK(e,s,0),mK(r,s,n),s.set(t,i),new _K(e,r,t,s)}class _K{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const EK=aq;const SK={code:0,name:"identity",encode:EK,digest:function(e){return vK(0,EK(e))}};function AK(e){let{name:t,code:r,encode:n}=e;return new kK(t,r,n)}class kK{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?vK(this.code,t):t.then((e=>vK(this.code,e)))}throw Error("Unknown type, must be binary type")}}function xK(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const IK=AK({name:"sha2-256",code:18,encode:xK("SHA-256")}),CK=AK({name:"sha2-512",code:19,encode:xK("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const TK={...Bt,...It,...Nt,...kt,...xt,...Tt,...Rt,...Pt,...Dt,...Ct};function RK(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function PK(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const DK=PK("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),NK=PK("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=RK((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),BK={utf8:DK,"utf-8":DK,hex:TK.base16,latin1:NK,ascii:NK,binary:NK,...TK};function UK(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=BK[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function LK(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=BK[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}var MK;!function(e){e[e.NEW_STREAM=0]="NEW_STREAM",e[e.MESSAGE_RECEIVER=1]="MESSAGE_RECEIVER",e[e.MESSAGE_INITIATOR=2]="MESSAGE_INITIATOR",e[e.CLOSE_RECEIVER=3]="CLOSE_RECEIVER",e[e.CLOSE_INITIATOR=4]="CLOSE_INITIATOR",e[e.RESET_RECEIVER=5]="RESET_RECEIVER",e[e.RESET_INITIATOR=6]="RESET_INITIATOR"}(MK||(MK={}));const OK=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),qK=Object.freeze({NEW_STREAM:MK.NEW_STREAM,MESSAGE:MK.MESSAGE_INITIATOR,CLOSE:MK.CLOSE_INITIATOR,RESET:MK.RESET_INITIATOR}),KK=Object.freeze({MESSAGE:MK.MESSAGE_RECEIVER,CLOSE:MK.CLOSE_RECEIVER,RESET:MK.RESET_RECEIVER}),FK=1<<20;class VK{_buffer;_headerInfo;_maxMessageSize;_maxUnprocessedMessageQueueSize;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:FK,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4194304;this._buffer=new Zl,this._headerInfo=null,this._maxMessageSize=e,this._maxUnprocessedMessageQueueSize=t}write(e){if(null==e||0===e.length)return[];if(this._buffer.append(e),this._buffer.byteLength>this._maxUnprocessedMessageQueueSize)throw Object.assign(new Error("unprocessed message queue size too large!"),{code:"ERR_MSG_QUEUE_TOO_BIG"});const t=[];for(;0!==this._buffer.length;){if(null==this._headerInfo)try{this._headerInfo=this._decodeHeader(this._buffer)}catch(r){if("ERR_MSG_TOO_BIG"===r.code)throw r;break}const{id:e,type:n,length:i,offset:s}=this._headerInfo;if(this._buffer.length-s<i)break;const o={id:e,type:n};n!==MK.NEW_STREAM&&n!==MK.MESSAGE_INITIATOR&&n!==MK.MESSAGE_RECEIVER||(o.data=this._buffer.sublist(s,s+i)),t.push(o),this._buffer.consume(s+i),this._headerInfo=null}return t}_decodeHeader(e){const{value:t,offset:r}=HK(e),{value:n,offset:i}=HK(e,r),s=7&t;if(null==OK[s])throw new Error(`Invalid type received: ${s}`);if(n>this._maxMessageSize)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"});return{id:t>>3,type:s,offset:r+i,length:n}}}const zK=128,$K=127;function HK(e){let t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=0,i=0,s=r;const o=e.length;do{if(s>=o||i>49)throw r=0,new RangeError("Could not decode varint");t=e.get(s++),n+=i<28?(t&$K)<<i:(t&$K)*Math.pow(2,i),i+=7}while(t>=zK);return r=s-r,{value:n,offset:r}}const jK=10240;const GK=new class{_pool;_poolOffset;constructor(){this._pool=RK(jK),this._poolOffset=0}write(e,t){const r=this._pool;let n=this._poolOffset;ms(e.id<<3|e.type,r,n),n+=gs(e.id<<3|e.type),e.type!==MK.NEW_STREAM&&e.type!==MK.MESSAGE_INITIATOR&&e.type!==MK.MESSAGE_RECEIVER||null==e.data?(ms(0,r,n),n+=gs(0)):(ms(e.data.length,r,n),n+=gs(e.data.length));const i=r.subarray(this._poolOffset,n);jK-n<100?(this._pool=RK(jK),this._poolOffset=0):this._poolOffset=n,t.append(i),e.type!==MK.NEW_STREAM&&e.type!==MK.MESSAGE_INITIATOR&&e.type!==MK.MESSAGE_RECEIVER||null==e.data||t.append(e.data)}};function WK(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}class YK{id;direction;timeline;protocol;metadata;source;status;readStatus;writeStatus;log;sinkController;sinkEnd;closed;endErr;streamSource;onEnd;onCloseRead;onCloseWrite;onReset;onAbort;sendCloseWriteTimeout;sendingData;constructor(e){this.sinkController=new AbortController,this.sinkEnd=ah(),this.closed=ah(),this.log=e.log,this.status="open",this.readStatus="ready",this.writeStatus="ready",this.id=e.id,this.metadata=e.metadata??{},this.direction=e.direction,this.timeline={open:Date.now()},this.sendCloseWriteTimeout=e.sendCloseWriteTimeout??5e3,this.onEnd=e.onEnd,this.onCloseRead=e?.onCloseRead,this.onCloseWrite=e?.onCloseWrite,this.onReset=e?.onReset,this.onAbort=e?.onAbort,this.source=this.streamSource=hh({onEnd:e=>{null!=e?this.log.trace("source ended with error",e):this.log.trace("source ended"),this.onSourceEnd(e)}}),this.sink=this.sink.bind(this)}async sink(e){if("ready"!==this.writeStatus)throw new Xp(`writable end state is "${this.writeStatus}" not "ready"`,"ERR_SINK_INVALID_STATE");try{this.writeStatus="writing";const t={signal:this.sinkController.signal};if("outbound"===this.direction){const e=this.sendNewStream(t);WK(e)&&await e}const r=()=>{eq(e,this.log)};try{this.sinkController.signal.addEventListener("abort",r),this.log.trace("sink reading from source");for await(let r of e){r=r instanceof Uint8Array?new Zl(r):r;const e=this.sendData(r,t);WK(e)&&(this.sendingData=ah(),await e,this.sendingData.resolve(),this.sendingData=void 0)}}finally{this.sinkController.signal.removeEventListener("abort",r)}this.log.trace('sink finished reading from source, write status is "%s"',this.writeStatus),"writing"===this.writeStatus&&(this.writeStatus="closing",this.log.trace("send close write to remote"),await this.sendCloseWrite({signal:AbortSignal.timeout(this.sendCloseWriteTimeout)}),this.writeStatus="closed"),this.onSinkEnd()}catch(t){throw this.log.trace("sink ended with error, calling abort with error",t),this.abort(t),t}finally{this.log.trace("resolve sink end"),this.sinkEnd.resolve()}}onSourceEnd(e){null==this.timeline.closeRead&&(this.timeline.closeRead=Date.now(),this.readStatus="closed",null!=e&&null==this.endErr&&(this.endErr=e),this.onCloseRead?.(),null!=this.timeline.closeWrite?(this.log.trace("source and sink ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("source ended, waiting for sink to end"))}onSinkEnd(e){null==this.timeline.closeWrite&&(this.timeline.closeWrite=Date.now(),this.writeStatus="closed",null!=e&&null==this.endErr&&(this.endErr=e),this.onCloseWrite?.(),null!=this.timeline.closeRead?(this.log.trace("sink and source ended"),this.timeline.close=Date.now(),"aborted"!==this.status&&"reset"!==this.status&&(this.status="closed"),null!=this.onEnd&&this.onEnd(this.endErr),this.closed.resolve()):this.log.trace("sink ended, waiting for source to end"))}async close(e){this.log.trace("closing gracefully"),this.status="closing",await yd(Promise.all([this.closeWrite(e),this.closeRead(e),this.closed.promise]),e?.signal),this.status="closed",this.log.trace("closed gracefully")}async closeRead(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("closing"===this.readStatus||"closed"===this.readStatus)return;this.log.trace('closing readable end of stream with starting read status "%s"',this.readStatus);const t=this.readStatus;this.readStatus="closing","reset"!==this.status&&"aborted"!==this.status&&null==this.timeline.closeRead&&(this.log.trace("send close read to remote"),await this.sendCloseRead(e)),"ready"===t&&(this.log.trace("ending internal source queue with %d queued bytes",this.streamSource.readableLength),this.streamSource.end()),this.log.trace("closed readable end of stream")}async closeWrite(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};"closing"!==this.writeStatus&&"closed"!==this.writeStatus&&(this.log.trace('closing writable end of stream with starting write status "%s"',this.writeStatus),"ready"===this.writeStatus&&(this.log.trace("sink was never sunk, sink an empty array"),await yd(this.sink([]),e.signal)),"writing"===this.writeStatus&&(null!=this.sendingData&&await yd(this.sendingData.promise,e.signal),this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),await yd(this.sinkEnd.promise,e.signal)),this.writeStatus="closed",this.log.trace("closed writable end of stream"))}abort(e){if("closed"===this.status||"aborted"===this.status||"reset"===this.status)return;this.log("abort with error",e),this.log("try to send reset to remote");const t=this.sendReset();WK(t)&&t.catch((e=>{this.log.error("error sending reset message",e)})),this.status="aborted",this.timeline.abort=Date.now(),this._closeSinkAndSource(e),this.onAbort?.(e)}reset(){if("closed"===this.status||"aborted"===this.status||"reset"===this.status)return;const e=new Xp("stream reset","ERR_STREAM_RESET");this.status="reset",this.timeline.reset=Date.now(),this._closeSinkAndSource(e),this.onReset?.()}_closeSinkAndSource(e){this._closeSink(e),this._closeSource(e)}_closeSink(e){"writing"===this.writeStatus&&(this.log.trace("end sink source"),this.sinkController.abort()),this.onSinkEnd(e)}_closeSource(e){"closing"!==this.readStatus&&"closed"!==this.readStatus&&(this.log.trace("ending source with %d bytes to be read by consumer",this.streamSource.readableLength),this.readStatus="closing",this.streamSource.end(e))}remoteCloseWrite(){"closing"!==this.readStatus&&"closed"!==this.readStatus?(this.log.trace("remote close write"),this._closeSource()):this.log("received remote close write but local source is already closed")}remoteCloseRead(){"closing"!==this.writeStatus&&"closed"!==this.writeStatus?(this.log.trace("remote close read"),this._closeSink()):this.log("received remote close read but local sink is already closed")}destroy(){"closed"!==this.status&&"aborted"!==this.status&&"reset"!==this.status?(this.log.trace("stream destroyed"),this._closeSinkAndSource()):this.log("received destroy but we are already closed")}sourcePush(e){this.streamSource.push(e)}sourceReadableLength(){return this.streamSource.readableLength}}class QK extends YK{name;streamId;send;types;maxDataSize;constructor(e){super(e),this.types="outbound"===e.direction?qK:KK,this.send=e.send,this.name=e.name,this.streamId=e.streamId,this.maxDataSize=e.maxDataSize}async sendNewStream(){await this.send({id:this.streamId,type:qK.NEW_STREAM,data:new Zl(UK(this.name))})}async sendData(e){for(e=e.sublist();e.byteLength>0;){const t=Math.min(e.byteLength,this.maxDataSize);await this.send({id:this.streamId,type:this.types.MESSAGE,data:e.sublist(0,t)}),e.consume(t)}}async sendReset(){await this.send({id:this.streamId,type:this.types.RESET})}async sendCloseWrite(){await this.send({id:this.streamId,type:this.types.CLOSE})}async sendCloseRead(){}}function JK(e){const t={...e,type:`${OK[e.type]} (${e.type})`};return e.type===MK.NEW_STREAM&&(t.data=LK(e.data instanceof Uint8Array?e.data:e.data.subarray())),e.type!==MK.MESSAGE_INITIATOR&&e.type!==MK.MESSAGE_RECEIVER||(t.data=LK(e.data instanceof Uint8Array?e.data:e.data.subarray(),"base16")),t}class XK{protocol="/mplex/6.7.0";sink;source;log;_streamId;_streams;_init;_source;closeController;rateLimiter;closeTimeout;logger;constructor(e,t){t=t??{},this.log=e.logger.forComponent("libp2p:mplex"),this.logger=e.logger,this._streamId=0,this._streams={initiators:new Map,receivers:new Map},this._init=t,this.closeTimeout=t.closeTimeout??500,this.sink=this._createSink(),this._source=hh({objectMode:!0,onEnd:()=>{for(const e of this._streams.initiators.values())e.destroy();for(const e of this._streams.receivers.values())e.destroy()}}),this.source=ph(this._source,(e=>async function*(e){for await(const t of e){const e=new Zl;GK.write(t,e),yield e}}(e))),this.closeController=new AbortController,this.rateLimiter=new sq({points:t.disconnectThreshold??5,duration:1})}get streams(){const e=[];for(const t of this._streams.initiators.values())e.push(t);for(const t of this._streams.receivers.values())e.push(t);return e}newStream(e){if(this.closeController.signal.aborted)throw new Error("Muxer already closed");const t=this._streamId++;e=null==e?t.toString():e.toString();const r=this._streams.initiators;return this._newStream({id:t,name:e,type:"initiator",registry:r})}async close(e){if(this.closeController.signal.aborted)return;const t=e?.signal??AbortSignal.timeout(this.closeTimeout);try{await Promise.all(this.streams.map((async e=>e.close({signal:t})))),this._source.end(),await this._source.onEmpty({signal:t}),this.closeController.abort()}catch(r){this.abort(r)}}abort(e){this.closeController.signal.aborted||(this.streams.forEach((t=>{t.abort(e)})),this.closeController.abort(e))}_newReceiverStream(e){const{id:t,name:r}=e,n=this._streams.receivers;return this._newStream({id:t,name:r,type:"receiver",registry:n})}_newStream(e){const{id:t,name:r,type:n,registry:i}=e;if(this.log("new %s stream %s",n,t),"initiator"===n&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw new Xp("Too many outbound streams open","ERR_TOO_MANY_OUTBOUND_STREAMS");if(i.has(t))throw new Error(`${n} stream ${t} already exists!`);const s=function(e){const{id:t,name:r,send:n,onEnd:i,type:s="initiator",maxMsgSize:o=FK}=e;return new QK({id:"initiator"===s?`i${t}`:`r${t}`,streamId:t,name:`${null==r?t:r}`,direction:"initiator"===s?"outbound":"inbound",maxDataSize:o,onEnd:i,send:n,log:e.logger.forComponent(`libp2p:mplex:stream:${s}:${t}`)})}({id:t,name:r,send:async e=>{this.log.enabled&&this.log.trace("%s stream %s send",n,t,JK(e)),this._source.push(e)},type:n,onEnd:()=>{this.log("%s stream with id %s and protocol %s ended",n,t,s.protocol),i.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(s)},maxMsgSize:this._init.maxMsgSize,logger:this.logger});return i.set(t,s),s}_createSink(){return async e=>{const t=()=>{eq(e,this.log)};this.closeController.signal.addEventListener("abort",t);try{const t=new VK(this._init.maxMsgSize,this._init.maxUnprocessedMessageQueueSize);for await(const r of e)for(const e of t.write(r))await this._handleIncoming(e);this._source.end()}catch(r){this.log("error in sink",r),this._source.end(r)}finally{this.closeController.signal.removeEventListener("abort",t)}}}async _handleIncoming(e){const{id:t,type:r}=e;if(this.log.enabled&&this.log.trace("incoming message",JK(e)),e.type===MK.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??1024)){this.log("too many inbound streams open"),this._source.push({id:t,type:MK.RESET_RECEIVER});try{await this.rateLimiter.consume("new-stream",1)}catch{return this.log("rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection"),void this.abort(new Error("Too many open streams"))}return}const r=this._newReceiverStream({id:t,name:LK(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=this._init.onIncomingStream&&this._init.onIncomingStream(r))}const n=(1===(1&r)?this._streams.initiators:this._streams.receivers).get(t);if(null==n){this.log("missing stream %s for message type %s",t,OK[r]);try{await this.rateLimiter.consume("missing-stream",1)}catch{return this.log("rate limit hit when receiving messages for streams that do not exist - closing remote connection"),void this.abort(new Error("Too many messages for missing streams"))}return}const i=this._init.maxStreamBufferSize??4194304;try{switch(r){case MK.MESSAGE_INITIATOR:case MK.MESSAGE_RECEIVER:if(n.sourceReadableLength()>i)throw this._source.push({id:e.id,type:r===MK.MESSAGE_INITIATOR?MK.RESET_RECEIVER:MK.RESET_INITIATOR}),new Xp("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers","ERR_STREAM_INPUT_BUFFER_FULL");n.sourcePush(e.data);break;case MK.CLOSE_INITIATOR:case MK.CLOSE_RECEIVER:n.remoteCloseWrite();break;case MK.RESET_INITIATOR:case MK.RESET_RECEIVER:n.reset();break;default:this.log("unknown message type %s",r)}}catch(s){this.log.error("error while processing message",s),n.abort(s)}}}class ZK{protocol="/mplex/6.7.0";_init;components;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.components=e,this._init=t}createStreamMuxer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new XK(this.components,{...e,...this._init})}}function eF(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new ZK(t,e)}const tF=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e)return t})();for(const t of e)return t};const rF="ERR_WRONG_PING_ACK";class nF{protocol;components;started;timeout;maxInboundStreams;maxOutboundStreams;runOnTransientConnection;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.components=e,this.log=e.logger.forComponent("libp2p:ping"),this.started=!1,this.protocol=`/${t.protocolPrefix??"ipfs"}/ping/1.0.0`,this.timeout=t.timeout??1e4,this.maxInboundStreams=t.maxInboundStreams??2,this.maxOutboundStreams=t.maxOutboundStreams??1,this.runOnTransientConnection=t.runOnTransientConnection??!0,this.handleMessage=this.handleMessage.bind(this)}async start(){await this.components.registrar.handle(this.protocol,this.handleMessage,{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0}async stop(){await this.components.registrar.unhandle(this.protocol),this.started=!1}isStarted(){return this.started}handleMessage(e){this.log("incoming ping from %p",e.connection.remotePeer);const{stream:t}=e,r=Date.now();ph(t,t).catch((t=>{this.log.error("incoming ping from %p failed with error",e.connection.remotePeer,t)})).finally((()=>{const t=Date.now()-r;this.log("incoming ping from %p complete in %dms",e.connection.remotePeer,t)}))}async ping(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.log("pinging %p",e);const r=Date.now(),n=function(e){if(isNaN(e)||e<=0)throw new Xp("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Cc(e)}(32),i=await this.components.connectionManager.openConnection(e,t);let s,o=()=>{};if(null==t.signal){const e=AbortSignal.timeout(this.timeout);t={...t,signal:e}}try{s=await i.newStream(this.protocol,{...t,runOnTransientConnection:this.runOnTransientConnection}),o=()=>{s?.abort(new Xp("ping timeout",eg))},t.signal?.addEventListener("abort",o,{once:!0});const e=await ph([n],s,(async e=>tF(e))),a=Date.now()-r;if(null==e)throw new Xp(`Did not receive a ping ack after ${a}ms`,rF);if(!function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(n,e.subarray()))throw new Xp(`Received wrong ping ack after ${a}ms`,rF);return this.log("ping %p complete in %dms",i.remotePeer,a),a}catch(a){throw this.log.error("error while pinging %p",i.remotePeer,a),s?.abort(a),a}finally{t.signal?.removeEventListener("abort",o),null!=s&&await s.close()}}}function iF(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new nF(t,e)}const sF=Symbol.for("@libp2p/transport");var oF;!function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"}(oF||(oF={}));const aF=[Dx("tcp").code,Dx("dns").code,Dx("dnsaddr").code,Dx("dns4").code,Dx("dns6").code];function cF(e){let t;try{t=Dx("sni").code}catch(r){return null}for(const[n,i]of e)if(n===t&&void 0!==i)return i;return null}function uF(e){return e.some((e=>{let[t,r]=e;return t===Dx("tls").code}))}function lF(e,t,r){const n=hF[Dx(e).name];if(void 0===n)throw new Error(`Can't interpret protocol ${Dx(e).name}`);const i=n(t,r);return e===Dx("ip6").code?`[${i}]`:i}const hF={ip4:(e,t)=>e,ip6:(e,t)=>0===t.length?e:`[${e}]`,tcp:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return`tcp://${lF(r[0],r[1]??"",t)}:${e}`},udp:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return`udp://${lF(r[0],r[1]??"",t)}:${e}`},dnsaddr:(e,t)=>e,dns4:(e,t)=>e,dns6:(e,t)=>e,dns:(e,t)=>e,ipfs:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return`${lF(r[0],r[1]??"",t)}/ipfs/${e}`},p2p:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return`${lF(r[0],r[1]??"",t)}/p2p/${e}`},http:(e,t)=>{const r=uF(t),n=cF(t);if(r&&null!==n)return`https://${n}`;const i=r?"https://":"http://",s=t.pop();if(void 0===s)throw new Error("Unexpected end of multiaddr");let o=lF(s[0],s[1]??"",t);return o=o.replace("tcp://",""),`${i}${o}`},tls:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return lF(r[0],r[1]??"",t)},sni:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return lF(r[0],r[1]??"",t)},https:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");let n=lF(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`https://${n}`},ws:(e,t)=>{const r=uF(t),n=cF(t);if(r&&null!==n)return`wss://${n}`;const i=r?"wss://":"ws://",s=t.pop();if(void 0===s)throw new Error("Unexpected end of multiaddr");let o=lF(s[0],s[1]??"",t);return o=o.replace("tcp://",""),`${i}${o}`},wss:(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");let n=lF(r[0],r[1]??"",t);return n=n.replace("tcp://",""),`wss://${n}`},"p2p-websocket-star":(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return`${lF(r[0],r[1]??"",t)}/p2p-websocket-star`},"p2p-webrtc-star":(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return`${lF(r[0],r[1]??"",t)}/p2p-webrtc-star`},"p2p-webrtc-direct":(e,t)=>{const r=t.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");return`${lF(r[0],r[1]??"",t)}/p2p-webrtc-direct`}};const dF=async e=>{if(e.readyState>=2)throw new Error("socket closed");1!==e.readyState&&await new Promise(((t,r)=>{function n(){e.removeEventListener("open",i),e.removeEventListener("error",s)}function i(){n(),t()}function s(t){n(),r(t.error??new Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener("open",i),e.addEventListener("error",s)}))},fF=(e,t)=>{(t=t??{}).closeOnEnd=!1!==t.closeOnEnd;return async r=>{for await(const t of r){try{await dF(e)}catch(n){if("socket closed"===n.message)break;throw n}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(t)}null!=t.closeOnEnd&&e.readyState<=1&&await new Promise(((t,r)=>{e.addEventListener("close",(e=>{if(e.wasClean||1006===e.code)t();else{const t=Object.assign(new Error("ws error"),{event:e});r(t)}})),setTimeout((()=>{e.close()}))}))}};var pF=__webpack_require__(2605);new Uint8Array(0);function gF(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var bF=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const yF=bF;class mF{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class wF{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return _F(this,e)}}class vF{decoders;constructor(e){this.decoders=e}or(e){return _F(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function _F(e,t){return new vF({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class EF{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new mF(e,t,r),this.decoder=new wF(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function SF(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new EF(t,r,n,i)}function AF(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=yF(n,t);return SF({prefix:r,name:t,encode:i,decode:e=>gF(s(e))})}function kF(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return SF({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const xF=AF({prefix:"9",name:"base10",alphabet:"0123456789"}),IF=kF({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),CF=kF({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),TF=kF({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),RF=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),PF=RF.reduce(((e,t,r)=>(e[r]=t,e)),[]),DF=RF.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const NF=SF({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=PF[t]),"")},decode:function(e){const t=[];for(const r of e){const e=DF[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),BF=kF({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),UF=kF({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),LF=kF({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),MF=kF({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),OF=kF({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qF=kF({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),KF=kF({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),FF=kF({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),VF=kF({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),zF=AF({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),$F=AF({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),HF=AF({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),jF=AF({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),GF=kF({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),WF=kF({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),YF=kF({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),QF=kF({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),JF=kF({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),XF=SF({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),ZF=new TextEncoder,eV=new TextDecoder,tV="json",rV=512;function nV(e){return ZF.encode(JSON.stringify(e))}function iV(e){return JSON.parse(eV.decode(e))}const sV="raw",oV=85;function aV(e){return gF(e)}function cV(e){return gF(e)}var uV=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=dV;)r[n++]=255&t|lV,t/=128;for(;t&hV;)r[n++]=255&t|lV,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},lV=128,hV=-128,dV=Math.pow(2,31);var fV=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&gV)<<s:(n&gV)*Math.pow(2,s),s+=7}while(n>=pV);return e.bytes=o-r,i},pV=128,gV=127;var bV=Math.pow(2,7),yV=Math.pow(2,14),mV=Math.pow(2,21),wV=Math.pow(2,28),vV=Math.pow(2,35),_V=Math.pow(2,42),EV=Math.pow(2,49),SV=Math.pow(2,56),AV=Math.pow(2,63);const kV={encode:uV,decode:fV,encodingLength:function(e){return e<bV?1:e<yV?2:e<mV?3:e<wV?4:e<vV?5:e<_V?6:e<EV?7:e<SV?8:e<AV?9:10}};function xV(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return kV.encode(e,t,r),t}function IV(e){return kV.encodingLength(e)}function CV(e,t){const r=t.byteLength,n=IV(e),i=n+IV(r),s=new Uint8Array(i+r);return xV(e,s,0),xV(r,s,n),s.set(t,i),new TV(e,r,t,s)}class TV{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const RV=gF;const PV={code:0,name:"identity",encode:RV,digest:function(e){return CV(0,RV(e))}};function DV(e){let{name:t,code:r,encode:n}=e;return new NV(t,r,n)}class NV{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?CV(this.code,t):t.then((e=>CV(this.code,e)))}throw Error("Unknown type, must be binary type")}}function BV(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const UV=DV({name:"sha2-256",code:18,encode:BV("SHA-256")}),LV=DV({name:"sha2-512",code:19,encode:BV("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const MV={...Wt,...Ft,...Gt,...qt,...Kt,...zt,...$t,...Ht,...jt,...Vt};function OV(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const qV=OV("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),KV=OV("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),FV={utf8:qV,"utf-8":qV,hex:MV.base16,latin1:KV,ascii:KV,binary:KV,...MV};function VV(e){return e instanceof ArrayBuffer||"ArrayBuffer"===e?.constructor?.name&&"number"===typeof e?.byteLength}const zV=e=>{e.binaryType="arraybuffer";const t=async()=>{await new Promise(((t,r)=>{if(i)return void t();if(null!=n)return void r(n);const s=t=>{e.removeEventListener("open",o),e.removeEventListener("error",a),t()},o=()=>{s(t)},a=t=>{s((()=>{r(t.error??new Error(`connect ECONNREFUSED ${e.url}`))}))};e.addEventListener("open",o),e.addEventListener("error",a)}))},r=async function*(){const r=new pF.PP((t=>{let{push:r,stop:n,fail:i}=t;const s=e=>{let t=null;"string"===typeof e.data&&(t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=FV[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}(e.data)),VV(e.data)&&(t=new Uint8Array(e.data)),e.data instanceof Uint8Array&&(t=e.data),null!=t&&r(t)},o=e=>{i(e.error??new Error("Socket error"))};return e.addEventListener("message",s),e.addEventListener("error",o),e.addEventListener("close",n),()=>{e.removeEventListener("message",s),e.removeEventListener("error",o),e.removeEventListener("close",n)}}),{highWaterMark:1/0});await t();for await(const e of r)yield VV(e)?new Uint8Array(e):e}();let n,i=1===e.readyState;return e.addEventListener("open",(()=>{i=!0,n=null})),e.addEventListener("close",(()=>{i=!1,n=null})),e.addEventListener("error",(t=>{i||(n=t.error??new Error(`connect ECONNREFUSED ${e.url}`))})),Object.assign(r,{connected:t})},$V=WebSocket,HV={"http:":"ws:","https:":"wss:"};function jV(e,t){t=t??{};const r=((e,t)=>{if(e.startsWith("//")&&(e=`${t?.protocol??"ws:"}${e}`),e.startsWith("/")&&null!=t){const r=t.protocol??"ws:",n=t.host,i=null!=t.port&&!0!==n?.endsWith(`:${t.port}`)?`:${t.port}`:"";e=`${r}//${n}${i}${e}`}const r=new URL(e);for(const[n,i]of Object.entries(HV))r.protocol===n&&(r.protocol=i);return r})(e,"undefined"===typeof window?void 0:window.location);return((e,t)=>{t=t??{};const r=zV(e);let n=t.remoteAddress,i=t.remotePort;if(null!=e.url)try{const t=new URL(e.url);n=t.hostname,i=parseInt(t.port,10)}catch{}if(null==n||null==i)throw new Error("Remote connection did not have address and/or port");return{sink:fF(e,t),source:r,connected:async()=>{await r.connected()},close:async()=>{e.readyState!==e.CONNECTING&&e.readyState!==e.OPEN||await new Promise((t=>{e.addEventListener("close",(()=>{t()})),e.close()}))},destroy:()=>{null!=e.terminate?e.terminate():e.close()},remoteAddress:n,remotePort:i,socket:e}})(new $V(r.toString(),t.websocket),t)}const GV=421,WV=290;function YV(e){return e.filter((e=>{if(e.protoCodes().includes(WV))return!1;const t=e.decapsulateCode(GV);return fI.matches(t)||gI.matches(t)}))}class QV{log;init;logger;constructor(e,t){this.log=e.logger.forComponent("libp2p:websockets"),this.logger=e.logger,this.init=t}[Symbol.toStringTag]="@libp2p/websockets";[sF]=!0;async dial(e,t){this.log("dialing %s",e),t=t??{};const r=function(e,t,r){const n=r.logger.forComponent("libp2p:websockets:maconn"),i={log:n,async sink(t){try{await e.sink(async function*(){for await(const e of t)e instanceof Uint8Array?yield e:yield e.subarray()}())}catch(r){"aborted"!==r.type&&n.error(r)}},source:e.source,remoteAddr:t,timeline:{open:Date.now()},async close(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=Date.now();if(null==t.signal){const e=AbortSignal.timeout(500);t={...t,signal:e}}const s=()=>{const{host:e,port:t}=i.remoteAddr.toOptions();n("timeout closing stream to %s:%s after %dms, destroying it manually",e,t,Date.now()-r),this.abort(new Xp("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};t.signal?.addEventListener("abort",s);try{await e.close()}catch(o){n.error("error closing WebSocket gracefully",o),this.abort(o)}finally{t.signal?.removeEventListener("abort",s),i.timeline.close=Date.now()}},abort(t){const{host:r,port:s}=i.remoteAddr.toOptions();n("timeout closing stream to %s:%s due to error",r,s,t),e.destroy(),i.timeline.close=Date.now()}};return e.socket.addEventListener("close",(()=>{null==i.timeline.close&&(i.timeline.close=Date.now())}),{once:!0}),i}(await this._connect(e,t),e,{logger:this.logger});this.log("new outbound connection %s",r.remoteAddr);const n=await t.upgrader.upgradeOutbound(r);return this.log("outbound connection %s upgraded",r.remoteAddr),n}async _connect(e,t){if(!0===t?.signal?.aborted)throw new Jp;const r=e.toOptions();this.log("dialing %s:%s",r.host,r.port);const n=ah(),i=jV(function(e,t){const r=tI(e).stringTuples(),n=r.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");const i=Dx(n[0]),s=hF[i.name];if(null==s)throw new Error(`No interpreter found for ${i.name}`);let o=s(n[1]??"",r);return!1!==t?.assumeHttp&&aF.includes(n[0])&&(o=o.replace(/^.*:\/\//,""),o="443"===n[1]?`https://${o}`:`http://${o}`),(o.startsWith("http://")||o.startsWith("https://"))&&(o=new URL(o).toString(),o.endsWith("/")&&(o=o.substring(0,o.length-1))),o}(e),this.init);if(i.socket.addEventListener("error",(()=>{const t=new Xp(`Could not connect to ${e.toString()}`,"ERR_CONNECTION_FAILED");this.log.error("connection error:",t),n.reject(t)})),null==t.signal)return await Promise.race([i.connected(),n.promise]),this.log("connected %s",e),i;let s;const o=new Promise(((e,r)=>{s=()=>{r(new Jp),i.close().catch((e=>{this.log.error("error closing raw socket",e)}))},!0!==t?.signal?.aborted?t?.signal?.addEventListener("abort",s):s()}));try{await Promise.race([o,n.promise,i.connected()])}finally{null!=s&&t?.signal?.removeEventListener("abort",s)}return this.log("connected %s",e),i}createListener(e){return function(){throw new Error("WebSocket Servers can not be created in the browser!")}(this.logger,this.init)}filter(e){return e=Array.isArray(e)?e:[e],null!=this.init?.filter?this.init?.filter(e):nO||aO?function(e){return e.filter((e=>{if(e.protoCodes().includes(WV))return!1;const t=e.decapsulateCode(GV);return gI.matches(t)}))}(e):YV(e)}}function JV(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new QV(t,e)}const XV="StrictSign",ZV="StrictNoSign";var ez;!function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"}(ez||(ez={}));new Uint8Array(0);function tz(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var rz=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const nz=rz;class iz{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class sz{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return az(this,e)}}class oz{decoders;constructor(e){this.decoders=e}or(e){return az(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function az(e,t){return new oz({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class cz{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new iz(e,t,r),this.decoder=new sz(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function uz(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new cz(t,r,n,i)}function lz(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=nz(n,t);return uz({prefix:r,name:t,encode:i,decode:e=>tz(s(e))})}function hz(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return uz({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const dz=lz({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fz=lz({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),pz=lz({prefix:"9",name:"base10",alphabet:"0123456789"}),gz=hz({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bz=hz({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),yz=hz({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),mz=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),wz=mz.reduce(((e,t,r)=>(e[r]=t,e)),[]),vz=mz.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const _z=uz({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=wz[t]),"")},decode:function(e){const t=[];for(const r of e){const e=vz[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),Ez=hz({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Sz=hz({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Az=hz({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),kz=hz({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),xz=hz({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Iz=hz({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Cz=hz({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Tz=hz({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Rz=hz({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Pz=lz({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Dz=lz({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Nz=hz({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Bz=hz({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Uz=hz({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Lz=hz({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Mz=hz({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Oz=uz({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),qz=new TextEncoder,Kz=new TextDecoder,Fz="json",Vz=512;function zz(e){return qz.encode(JSON.stringify(e))}function $z(e){return JSON.parse(Kz.decode(e))}const Hz="raw",jz=85;function Gz(e){return tz(e)}function Wz(e){return tz(e)}var Yz=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Xz;)r[n++]=255&t|Qz,t/=128;for(;t&Jz;)r[n++]=255&t|Qz,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Qz=128,Jz=-128,Xz=Math.pow(2,31);var Zz=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&t$)<<s:(n&t$)*Math.pow(2,s),s+=7}while(n>=e$);return e.bytes=o-r,i},e$=128,t$=127;var r$=Math.pow(2,7),n$=Math.pow(2,14),i$=Math.pow(2,21),s$=Math.pow(2,28),o$=Math.pow(2,35),a$=Math.pow(2,42),c$=Math.pow(2,49),u$=Math.pow(2,56),l$=Math.pow(2,63);const h$={encode:Yz,decode:Zz,encodingLength:function(e){return e<r$?1:e<n$?2:e<i$?3:e<s$?4:e<o$?5:e<a$?6:e<c$?7:e<u$?8:e<l$?9:10}};function d$(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[h$.decode(e,t),h$.decode.bytes]}function f$(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return h$.encode(e,t,r),t}function p$(e){return h$.encodingLength(e)}function g$(e,t){const r=t.byteLength,n=p$(e),i=n+p$(r),s=new Uint8Array(i+r);return f$(e,s,0),f$(r,s,n),s.set(t,i),new y$(e,r,t,s)}function b$(e){const t=tz(e),[r,n]=d$(t),[i,s]=d$(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new y$(r,i,o,t)}class y${code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const m$=tz;const w$={code:0,name:"identity",encode:m$,digest:function(e){return g$(0,m$(e))}};function v$(e){let{name:t,code:r,encode:n}=e;return new _$(t,r,n)}class _${name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?g$(this.code,t):t.then((e=>g$(this.code,e)))}throw Error("Unknown type, must be binary type")}}function E$(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const S$=v$({name:"sha2-256",code:18,encode:E$("SHA-256")}),A$=v$({name:"sha2-512",code:19,encode:E$("SHA-512")});function k$(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==dz.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,I$(e),t??dz.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,I$(e),t??Ez.encoder)}const x$=new WeakMap;function I$(e){const t=x$.get(e);if(null==t){const t=new Map;return x$.set(e,t),t}return t}class C${code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==T$)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==R$)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return C$.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:{const{code:e,digest:t}=this.multihash,r=g$(e,t);return C$.createV1(this.code,r)}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 C$.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return k$(this,e)}toJSON(){return{"/":k$(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof C$)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new C$(e,r,n,i??P$(e,r,n.bytes))}if(!0===t[D$]){const{version:e,multihash:r,code:n}=t,i=b$(r);return C$.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==T$)throw new Error(`Version 0 CID must use dag-pb (code: ${T$}) block encoding`);return new C$(e,t,r,r.bytes);case 1:{const n=P$(e,t,r.bytes);return new C$(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return C$.create(0,T$,e)}static createV1(e,t){return C$.create(1,e,t)}static decode(e){const[t,r]=C$.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=C$.inspectBytes(e),r=t.size-t.multihashSize,n=tz(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new y$(t.multihashCode,t.digestSize,i,n);return[0===t.version?C$.createV0(s):C$.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=d$(e.subarray(t));return t+=n,r};let n=r(),i=T$;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??dz;return[dz.prefix,r.decode(`${dz.prefix}${e}`)]}case dz.prefix:{const r=t??dz;return[dz.prefix,r.decode(e)]}case Ez.prefix:{const r=t??Ez;return[Ez.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=C$.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return I$(i).set(r,e),i}}const T$=112,R$=18;function P$(e,t,r){const n=p$(e),i=n+p$(t),s=new Uint8Array(i+r.byteLength);return f$(e,s,0),f$(t,s,n),s.set(r,i),s}const D$=Symbol.for("@ipld/js-cid/CID"),N$={...cr,...rr,...ar,...er,...tr,...ir,...sr,...Zt,...or,...nr};function B$(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const U$=Symbol.for("nodejs.util.inspect.custom"),L$=Object.values(N$).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),N$.identity.decoder),M$=114,O$=36,q$=37;class K${type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=dz.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return C$.createV1(M$,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return B$(this.multihash.bytes,e);if("string"===typeof e)return $$(e).equals(this);if(null!=e?.multihash?.bytes)return B$(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[U$](){return`PeerId(${this.toString()})`}}class F$ extends K${type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class V$ extends K${type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class z$ extends K${type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function $$(e,t){if(t=t??L$,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=b$(dz.decode(`z${e}`));return e.startsWith("12D")?new V$({multihash:t}):e.startsWith("16U")?new z$({multihash:t}):new F$({multihash:t})}return H$(L$.decode(e))}function H$(e){try{const t=b$(e);if(t.code===w$.code){if(t.digest.length===O$)return new V$({multihash:t});if(t.digest.length===q$)return new z$({multihash:t})}if(t.code===S$.code)return new F$({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==M$)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===S$.code)return new F$({multihash:e.multihash});if(t.code===w$.code){if(t.digest.length===O$)return new V$({multihash:e.multihash});if(t.digest.length===q$)return new z$({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(C$.decode(e))}throw new Error("Supplied PeerID CID is invalid")}const j$="/floodsub/1.0.0",G$="/meshsub/1.0.0",W$="/meshsub/1.1.0",Y$=5e3,Q$={maxSubscriptions:1/0,maxMessages:1/0,maxIhaveMessageIDs:1/0,maxIwantMessageIDs:1/0,maxControlMessages:1/0,maxPeerInfos:1/0},J$=new Float32Array([-0]),X$=new Uint8Array(J$.buffer);function Z$(e,t,r){J$[0]=e,t[r]=X$[0],t[r+1]=X$[1],t[r+2]=X$[2],t[r+3]=X$[3]}const eH=new Float64Array([-0]),tH=new Uint8Array(eH.buffer);function rH(e,t,r){eH[0]=e,t[r]=tH[0],t[r+1]=tH[1],t[r+2]=tH[2],t[r+3]=tH[3],t[r+4]=tH[4],t[r+5]=tH[5],t[r+6]=tH[6],t[r+7]=tH[7]}const nH=BigInt(Number.MAX_SAFE_INTEGER),iH=BigInt(Number.MIN_SAFE_INTEGER);class sH{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return oH;if(e<nH&&e>iH)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>aH&&(n=0n,++r>aH&&(r=0n))),new sH(Number(n),Number(r))}static fromNumber(e){if(0===e)return oH;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new sH(r,n)}static from(e){return"number"===typeof e?sH.fromNumber(e):"bigint"===typeof e?sH.fromBigInt(e):"string"===typeof e?sH.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new sH(e.low>>>0,e.high>>>0):oH}}const oH=new sH(0,0);oH.toBigInt=function(){return 0n},oH.zzEncode=oH.zzDecode=function(){return this},oH.length=function(){return 1};const aH=4294967296n;function cH(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function uH(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function lH(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class hH{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,uH(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw uH(this,4);return lH(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw uH(this,4);return 0|lH(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw uH(this,4);const e=(t=this.buf,r=this.pos,X$[0]=t[r],X$[1]=t[r+1],X$[2]=t[r+2],X$[3]=t[r+3],J$[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw uH(this,4);const e=(t=this.buf,r=this.pos,tH[0]=t[r],tH[1]=t[r+1],tH[2]=t[r+2],tH[3]=t[r+3],tH[4]=t[r+4],tH[5]=t[r+5],tH[6]=t[r+6],tH[7]=t[r+7],eH[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw uH(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw uH(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw uH(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new sH(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw uH(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw uH(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw uH(this,8);const e=lH(this.buf,this.pos+=4),t=lH(this.buf,this.pos+=4);return new sH(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 dH(e,t,r){const n=function(e){return new hH(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function fH(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function pH(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const gH=pH("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),bH=pH("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=fH((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),yH={utf8:gH,"utf-8":gH,hex:N$.base16,latin1:bH,ascii:bH,binary:bH,...N$};function mH(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=yH[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}class wH{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function vH(){}class _H{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const EH=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return fH(e);i+e>t&&(n=fH(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class SH{len;head;tail;states;constructor(){this.len=0,this.head=new wH(vH,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new wH(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new xH((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(IH,10,sH.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=sH.fromBigInt(e);return this._push(IH,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=sH.fromBigInt(e).zzEncode();return this._push(IH,t.length(),t)}sint64Number(e){const t=sH.fromNumber(e).zzEncode();return this._push(IH,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(AH,1,e?1:0)}fixed32(e){return this._push(CH,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=sH.fromBigInt(e);return this._push(CH,4,t.lo)._push(CH,4,t.hi)}fixed64Number(e){const t=sH.fromNumber(e);return this._push(CH,4,t.lo)._push(CH,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(Z$,4,e)}double(e){return this._push(rH,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(AH,1,0):this.uint32(t)._push(TH,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(cH,t,e):this._push(AH,1,0)}fork(){return this.states=new _H(this),this.head=this.tail=new wH(vH,0,0),this.len=0,this}reset(){return null!=this.states?(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 wH(vH,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?fH(r):EH(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function AH(e,t,r){t[r]=255&e}function kH(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class xH extends wH{next;constructor(e,t){super(kH,e,t),this.next=void 0}}function IH(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function CH(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function TH(e,t,r){t.set(e,r)}function RH(e,t,r){t.set(e,r)}function PH(e,t,r){e.length<40?cH(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(mH(e),r)}function DH(e,t){const r=new SH;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var NH,BH,UH,LH,MH,OH,qH,KH,FH,VH,zH,$H,HH;function jH(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function GH(e,t){return jH("message",NH.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(SH.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(RH,t,e),this},SH.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(PH,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(NH||(NH={}));class WH extends Error{code;constructor(e,t,r){super(e,r),this.code=t}}!function(e){let t,r,n,i,s,o,a,c,u;!function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.subscribe&&(t.uint32(8),t.bool(e.subscribe)),null!=e.topic&&(t.uint32(18),t.string(e.topic)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.subscribe=e.bool();break;case 2:r.topic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>DH(t,e.codec()),e.decode=(t,r)=>dH(t,e.codec(),r)}(t=e.SubOpts||(e.SubOpts={})),function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.from&&(t.uint32(10),t.bytes(e.from)),null!=e.data&&(t.uint32(18),t.bytes(e.data)),null!=e.seqno&&(t.uint32(26),t.bytes(e.seqno)),null!=e.topic&&""!==e.topic&&(t.uint32(34),t.string(e.topic)),null!=e.signature&&(t.uint32(42),t.bytes(e.signature)),null!=e.key&&(t.uint32(50),t.bytes(e.key)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={topic:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.from=e.bytes();break;case 2:r.data=e.bytes();break;case 3:r.seqno=e.bytes();break;case 4:r.topic=e.string();break;case 5:r.signature=e.bytes();break;case 6:r.key=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>DH(t,e.codec()),e.decode=(t,r)=>dH(t,e.codec(),r)}(r=e.Message||(e.Message={})),function(t){let r;t.codec=()=>(null==r&&(r=GH((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.ihave)for(const i of t.ihave)r.uint32(10),e.ControlIHave.codec().encode(i,r);if(null!=t.iwant)for(const i of t.iwant)r.uint32(18),e.ControlIWant.codec().encode(i,r);if(null!=t.graft)for(const i of t.graft)r.uint32(26),e.ControlGraft.codec().encode(i,r);if(null!=t.prune)for(const i of t.prune)r.uint32(34),e.ControlPrune.codec().encode(i,r);!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={ihave:[],iwant:[],graft:[],prune:[]},s=null==r?t.len:t.pos+r;for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(null!=n.limits?.ihave&&i.ihave.length===n.limits.ihave)throw new WH('decode error - map field "ihave" had too many elements',"ERR_MAX_LENGTH");i.ihave.push(e.ControlIHave.codec().decode(t,t.uint32()));break;case 2:if(null!=n.limits?.iwant&&i.iwant.length===n.limits.iwant)throw new WH('decode error - map field "iwant" had too many elements',"ERR_MAX_LENGTH");i.iwant.push(e.ControlIWant.codec().decode(t,t.uint32()));break;case 3:if(null!=n.limits?.graft&&i.graft.length===n.limits.graft)throw new WH('decode error - map field "graft" had too many elements',"ERR_MAX_LENGTH");i.graft.push(e.ControlGraft.codec().decode(t,t.uint32()));break;case 4:if(null!=n.limits?.prune&&i.prune.length===n.limits.prune)throw new WH('decode error - map field "prune" had too many elements',"ERR_MAX_LENGTH");i.prune.push(e.ControlPrune.codec().decode(t,t.uint32()));break;default:t.skipType(7&r)}}return i}))),r),t.encode=e=>DH(e,t.codec()),t.decode=(e,r)=>dH(e,t.codec(),r)}(n=e.ControlMessage||(e.ControlMessage={})),function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.topicID&&(t.uint32(10),t.string(e.topicID)),null!=e.messageIDs)for(const n of e.messageIDs)t.uint32(18),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n={messageIDs:[]},i=null==t?e.len:e.pos+t;for(;e.pos<i;){const t=e.uint32();switch(t>>>3){case 1:n.topicID=e.string();break;case 2:if(null!=r.limits?.messageIDs&&n.messageIDs.length===r.limits.messageIDs)throw new WH('decode error - map field "messageIDs" had too many elements',"ERR_MAX_LENGTH");n.messageIDs.push(e.bytes());break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>DH(t,e.codec()),e.decode=(t,r)=>dH(t,e.codec(),r)}(i=e.ControlIHave||(e.ControlIHave={})),function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null!=e.messageIDs)for(const n of e.messageIDs)t.uint32(10),t.bytes(n);!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n={messageIDs:[]},i=null==t?e.len:e.pos+t;for(;e.pos<i;){const t=e.uint32();if(t>>>3===1){if(null!=r.limits?.messageIDs&&n.messageIDs.length===r.limits.messageIDs)throw new WH('decode error - map field "messageIDs" had too many elements',"ERR_MAX_LENGTH");n.messageIDs.push(e.bytes())}else e.skipType(7&t)}return n}))),t),e.encode=t=>DH(t,e.codec()),e.decode=(t,r)=>dH(t,e.codec(),r)}(s=e.ControlIWant||(e.ControlIWant={})),function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.topicID&&(t.uint32(10),t.string(e.topicID)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();if(t>>>3===1)r.topicID=e.string();else e.skipType(7&t)}return r}))),t),e.encode=t=>DH(t,e.codec()),e.decode=(t,r)=>dH(t,e.codec(),r)}(o=e.ControlGraft||(e.ControlGraft={})),function(t){let r;t.codec=()=>(null==r&&(r=GH((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.topicID&&(r.uint32(10),r.string(t.topicID)),null!=t.peers)for(const i of t.peers)r.uint32(18),e.PeerInfo.codec().encode(i,r);null!=t.backoff&&(r.uint32(24),r.uint64Number(t.backoff)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={peers:[]},s=null==r?t.len:t.pos+r;for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:i.topicID=t.string();break;case 2:if(null!=n.limits?.peers&&i.peers.length===n.limits.peers)throw new WH('decode error - map field "peers" had too many elements',"ERR_MAX_LENGTH");i.peers.push(e.PeerInfo.codec().decode(t,t.uint32()));break;case 3:i.backoff=t.uint64Number();break;default:t.skipType(7&r)}}return i}))),r),t.encode=e=>DH(e,t.codec()),t.decode=(e,r)=>dH(e,t.codec(),r)}(a=e.ControlPrune||(e.ControlPrune={})),function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.peerID&&(t.uint32(10),t.bytes(e.peerID)),null!=e.signedPeerRecord&&(t.uint32(18),t.bytes(e.signedPeerRecord)),!1!==r.lengthDelimited&&t.ldelim()}),(function(e,t){const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.peerID=e.bytes();break;case 2:r.signedPeerRecord=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>DH(t,e.codec()),e.decode=(t,r)=>dH(t,e.codec(),r)}(c=e.PeerInfo||(e.PeerInfo={})),e.codec=()=>(null==u&&(u=GH((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.subscriptions)for(const i of t.subscriptions)r.uint32(10),e.SubOpts.codec().encode(i,r);if(null!=t.messages)for(const i of t.messages)r.uint32(18),e.Message.codec().encode(i,r);null!=t.control&&(r.uint32(26),e.ControlMessage.codec().encode(t.control,r)),!1!==n.lengthDelimited&&r.ldelim()}),(function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={subscriptions:[],messages:[]},s=null==r?t.len:t.pos+r;for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(null!=n.limits?.subscriptions&&i.subscriptions.length===n.limits.subscriptions)throw new WH('decode error - map field "subscriptions" had too many elements',"ERR_MAX_LENGTH");i.subscriptions.push(e.SubOpts.codec().decode(t,t.uint32()));break;case 2:if(null!=n.limits?.messages&&i.messages.length===n.limits.messages)throw new WH('decode error - map field "messages" had too many elements',"ERR_MAX_LENGTH");i.messages.push(e.Message.codec().decode(t,t.uint32()));break;case 3:i.control=e.ControlMessage.codec().decode(t,t.uint32());break;default:t.skipType(7&r)}}return i}))),u),e.encode=t=>DH(t,e.codec()),e.decode=(t,r)=>dH(t,e.codec(),r)}(BH||(BH={}));class YH{gossip;msgs=new Map;msgIdToStrFn;history=[];notValidatedCount=0;constructor(e,t,r){this.gossip=e,this.msgIdToStrFn=r;for(let n=0;n<t;n++)this.history[n]=[]}get size(){return this.msgs.size}put(e,t){let r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const{msgIdStr:n}=e;return!this.msgs.has(n)&&(this.msgs.set(n,{message:t,validated:r,originatingPeers:new Set,iwantCounts:new Map}),this.history[0].push({...e,topic:t.topic}),r||this.notValidatedCount++,!0)}observeDuplicate(e,t){const r=this.msgs.get(e);null==r||r.validated||r.originatingPeers.add(t)}get(e){return this.msgs.get(this.msgIdToStrFn(e))?.message}getWithIWantCount(e,t){const r=this.msgs.get(e);if(null==r)return null;const n=(r.iwantCounts.get(t)??0)+1;return r.iwantCounts.set(t,n),{msg:r.message,count:n}}getGossipIDs(e){const t=new Map;for(let r=0;r<this.gossip;r++)this.history[r].forEach((r=>{const n=this.msgs.get(r.msgIdStr);if(n?.validated&&e.has(r.topic)){let e=t.get(r.topic);null==e&&(e=[],t.set(r.topic,e)),e.push(r.msgId)}}));return t}validate(e){const t=this.msgs.get(e);if(null==t)return null;t.validated||this.notValidatedCount--;const{message:r,originatingPeers:n}=t;return t.validated=!0,t.originatingPeers=new Set,{message:r,originatingPeers:n}}shift(){this.history[this.history.length-1].forEach((e=>{const t=this.msgs.get(e.msgIdStr);null!=t&&(this.msgs.delete(e.msgIdStr),t.validated||this.notValidatedCount--)})),this.history.pop(),this.history.unshift([])}remove(e){const t=this.msgs.get(e);return null==t?null:(this.msgs.delete(e),t)}}function QH(e){switch(e){case ez.Ignore:return MH.Ignore;case ez.Reject:return MH.Reject;default:throw new Error("Unreachable")}}!function(e){e.StrictSign="StrictSign",e.StrictNoSign="StrictNoSign"}(UH||(UH={})),function(e){e[e.Signing=0]="Signing",e[e.Anonymous=1]="Anonymous"}(LH||(LH={})),function(e){e.Error="error",e.Ignore="ignore",e.Reject="reject",e.Blacklisted="blacklisted"}(MH||(MH={})),function(e){e.InvalidSignature="invalid_signature",e.InvalidSeqno="invalid_seqno",e.InvalidPeerId="invalid_peerid",e.SignaturePresent="signature_present",e.SeqnoPresent="seqno_present",e.FromPresent="from_present",e.TransformFailed="transform_failed"}(OH||(OH={})),function(e){e.duplicate="duplicate",e.invalid="invalid",e.valid="valid"}(qH||(qH={})),function(e){e.forward="forward",e.publish="publish"}(KH||(KH={})),function(e){e.Fanout="fanout",e.Random="random",e.Subscribed="subscribed",e.Outbound="outbound",e.NotEnough="not_enough",e.Opportunistic="opportunistic"}(FH||(FH={})),function(e){e.Dc="disconnected",e.BadScore="bad_score",e.Prune="prune",e.Excess="excess"}(VH||(VH={})),function(e){e.GraftBackoff="graft_backoff",e.BrokenPromise="broken_promise",e.MessageDeficit="message_deficit",e.IPColocation="IP_colocation"}(zH||(zH={})),function(e){e.LowScore="low_score",e.MaxIhave="max_ihave",e.MaxIasked="max_iasked"}($H||($H={})),function(e){e.graylist="graylist",e.publish="publish",e.gossip="gossip",e.mesh="mesh"}(HH||(HH={}));const JH="ERR_INVALID_PEER_SCORE_PARAMS",XH={topics:{},topicScoreCap:10,appSpecificScore:()=>0,appSpecificWeight:10,IPColocationFactorWeight:-5,IPColocationFactorThreshold:10,IPColocationFactorWhitelist:new Set,behaviourPenaltyWeight:-10,behaviourPenaltyThreshold:0,behaviourPenaltyDecay:.2,decayInterval:1e3,decayToZero:.1,retainScore:36e5},ZH={topicWeight:.5,timeInMeshWeight:1,timeInMeshQuantum:1,timeInMeshCap:3600,firstMessageDeliveriesWeight:1,firstMessageDeliveriesDecay:.5,firstMessageDeliveriesCap:2e3,meshMessageDeliveriesWeight:-1,meshMessageDeliveriesDecay:.5,meshMessageDeliveriesCap:100,meshMessageDeliveriesThreshold:20,meshMessageDeliveriesWindow:10,meshMessageDeliveriesActivation:5e3,meshFailurePenaltyWeight:-1,meshFailurePenaltyDecay:.5,invalidMessageDeliveriesWeight:-1,invalidMessageDeliveriesDecay:.3};function ej(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{...XH,...e,topics:null!=e.topics?Object.entries(e.topics).reduce(((e,t)=>{let[r,n]=t;return e[r]=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{...ZH,...e}}(n),e}),{}):{}}}function tj(e){if(e.topicWeight<0)throw new Xp("invalid topic weight; must be >= 0",JH);if(0===e.timeInMeshQuantum)throw new Xp("invalid TimeInMeshQuantum; must be non zero",JH);if(e.timeInMeshWeight<0)throw new Xp("invalid TimeInMeshWeight; must be positive (or 0 to disable)",JH);if(0!==e.timeInMeshWeight&&e.timeInMeshQuantum<=0)throw new Xp("invalid TimeInMeshQuantum; must be positive",JH);if(0!==e.timeInMeshWeight&&e.timeInMeshCap<=0)throw new Xp("invalid TimeInMeshCap; must be positive",JH);if(e.firstMessageDeliveriesWeight<0)throw new Xp("invallid FirstMessageDeliveriesWeight; must be positive (or 0 to disable)",JH);if(0!==e.firstMessageDeliveriesWeight&&(e.firstMessageDeliveriesDecay<=0||e.firstMessageDeliveriesDecay>=1))throw new Xp("invalid FirstMessageDeliveriesDecay; must be between 0 and 1",JH);if(0!==e.firstMessageDeliveriesWeight&&e.firstMessageDeliveriesCap<=0)throw new Xp("invalid FirstMessageDeliveriesCap; must be positive",JH);if(e.meshMessageDeliveriesWeight>0)throw new Xp("invalid MeshMessageDeliveriesWeight; must be negative (or 0 to disable)",JH);if(0!==e.meshMessageDeliveriesWeight&&(e.meshMessageDeliveriesDecay<=0||e.meshMessageDeliveriesDecay>=1))throw new Xp("invalid MeshMessageDeliveriesDecay; must be between 0 and 1",JH);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesCap<=0)throw new Xp("invalid MeshMessageDeliveriesCap; must be positive",JH);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesThreshold<=0)throw new Xp("invalid MeshMessageDeliveriesThreshold; must be positive",JH);if(e.meshMessageDeliveriesWindow<0)throw new Xp("invalid MeshMessageDeliveriesWindow; must be non-negative",JH);if(0!==e.meshMessageDeliveriesWeight&&e.meshMessageDeliveriesActivation<1e3)throw new Xp("invalid MeshMessageDeliveriesActivation; must be at least 1s",JH);if(e.meshFailurePenaltyWeight>0)throw new Xp("invalid MeshFailurePenaltyWeight; must be negative (or 0 to disable)",JH);if(0!==e.meshFailurePenaltyWeight&&(e.meshFailurePenaltyDecay<=0||e.meshFailurePenaltyDecay>=1))throw new Xp("invalid MeshFailurePenaltyDecay; must be between 0 and 1",JH);if(e.invalidMessageDeliveriesWeight>0)throw new Xp("invalid InvalidMessageDeliveriesWeight; must be negative (or 0 to disable)",JH);if(e.invalidMessageDeliveriesDecay<=0||e.invalidMessageDeliveriesDecay>=1)throw new Xp("invalid InvalidMessageDeliveriesDecay; must be between 0 and 1",JH)}const rj={gossipThreshold:-10,publishThreshold:-50,graylistThreshold:-80,acceptPXThreshold:10,opportunisticGraftThreshold:20};function nj(){return{...rj,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}function ij(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0;const n=new Set;if(t<=0)return n;for(const i of e){if(n.size>=t)break;r(i)&&(n.add(i),e.delete(i))}return n}class sj extends Map{getDefault;constructor(e){super(),this.getDefault=e}getOrDefault(e){let t=super.get(e);return void 0===t&&(t=this.getDefault(),this.set(e,t)),t}}function oj(e,t,r,n){let i=0;Object.entries(t.topics).forEach((e=>{let[t,n]=e;const s=r.topics[t];if(void 0===s)return;let o=0;if(n.inMesh){let e=n.meshTime/s.timeInMeshQuantum;e>s.timeInMeshCap&&(e=s.timeInMeshCap),o+=e*s.timeInMeshWeight}let a=n.firstMessageDeliveries;if(a>s.firstMessageDeliveriesCap&&(a=s.firstMessageDeliveriesCap),o+=a*s.firstMessageDeliveriesWeight,n.meshMessageDeliveriesActive&&n.meshMessageDeliveries<s.meshMessageDeliveriesThreshold){const e=s.meshMessageDeliveriesThreshold-n.meshMessageDeliveries;o+=e*e*s.meshMessageDeliveriesWeight}o+=n.meshFailurePenalty*s.meshFailurePenaltyWeight;o+=n.invalidMessageDeliveries*n.invalidMessageDeliveries*s.invalidMessageDeliveriesWeight,i+=o*s.topicWeight})),r.topicScoreCap>0&&i>r.topicScoreCap&&(i=r.topicScoreCap);const s=r.appSpecificScore(e);if(i+=s*r.appSpecificWeight,t.knownIPs.forEach((e=>{if(r.IPColocationFactorWhitelist.has(e))return;const t=n.get(e),s=null!=t?t.size:0;if(s>r.IPColocationFactorThreshold){const e=s-r.IPColocationFactorThreshold;i+=e*e*r.IPColocationFactorWeight}})),t.behaviourPenalty>r.behaviourPenaltyThreshold){const e=t.behaviourPenalty-r.behaviourPenaltyThreshold;i+=e*e*r.behaviourPenaltyWeight}return i}var aj,cj=__webpack_require__(80);!function(e){e[e.unknown=0]="unknown",e[e.valid=1]="valid",e[e.invalid=2]="invalid",e[e.ignored=3]="ignored"}(aj||(aj={}));class uj{records;queue;constructor(){this.records=new Map,this.queue=new cj}getRecord(e){return this.records.get(e)}ensureRecord(e){let t=this.records.get(e);if(null!=t)return t;t={status:aj.unknown,firstSeenTsMs:Date.now(),validated:0,peers:new Set},this.records.set(e,t);const r={msgId:e,expire:Date.now()+12e4};return this.queue.push(r),t}gc(){const e=Date.now();let t=this.queue.peekFront();for(;null!=t&&t.expire<e;)this.records.delete(t.msgId),this.queue.shift(),t=this.queue.peekFront()}clear(){this.records.clear(),this.queue.clear()}}class lj{params;metrics;peerStats=new Map;peerIPs=new sj((()=>new Set));scoreCache=new Map;deliveryRecords=new uj;_backgroundInterval;scoreCacheValidityMs;computeScore;log;constructor(e,t,r,n){this.params=e,this.metrics=t,function(e){for(const[r,n]of Object.entries(e.topics))try{tj(n)}catch(t){throw new Xp(`invalid score parameters for topic ${r}: ${t.message}`,JH)}if(e.topicScoreCap<0)throw new Xp("invalid topic score cap; must be positive (or 0 for no cap)",JH);if(null===e.appSpecificScore||void 0===e.appSpecificScore)throw new Xp("missing application specific score function",JH);if(e.IPColocationFactorWeight>0)throw new Xp("invalid IPColocationFactorWeight; must be negative (or 0 to disable)",JH);if(0!==e.IPColocationFactorWeight&&e.IPColocationFactorThreshold<1)throw new Xp("invalid IPColocationFactorThreshold; must be at least 1",JH);if(e.behaviourPenaltyWeight>0)throw new Xp("invalid BehaviourPenaltyWeight; must be negative (or 0 to disable)",JH);if(0!==e.behaviourPenaltyWeight&&(e.behaviourPenaltyDecay<=0||e.behaviourPenaltyDecay>=1))throw new Xp("invalid BehaviourPenaltyDecay; must be between 0 and 1",JH);if(e.decayInterval<1e3)throw new Xp("invalid DecayInterval; must be at least 1s",JH);if(e.decayToZero<=0||e.decayToZero>=1)throw new Xp("invalid DecayToZero; must be between 0 and 1",JH)}(e),this.scoreCacheValidityMs=n.scoreCacheValidityMs,this.computeScore=n.computeScore??oj,this.log=r.forComponent("libp2p:gossipsub:score")}get size(){return this.peerStats.size}start(){null==this._backgroundInterval?(this._backgroundInterval=setInterval((()=>{this.background()}),this.params.decayInterval),this.log("started")):this.log("Peer score already running")}stop(){null!=this._backgroundInterval?(clearInterval(this._backgroundInterval),delete this._backgroundInterval,this.peerIPs.clear(),this.peerStats.clear(),this.deliveryRecords.clear(),this.log("stopped")):this.log("Peer score already stopped")}background(){this.refreshScores(),this.deliveryRecords.gc()}dumpPeerScoreStats(){return Object.fromEntries(Array.from(this.peerStats.entries()).map((e=>{let[t,r]=e;return[t,r]})))}messageFirstSeenTimestampMs(e){const t=this.deliveryRecords.getRecord(e);return null!=t?t.firstSeenTsMs:null}refreshScores(){const e=Date.now(),t=this.params.decayToZero;this.peerStats.forEach(((r,n)=>{r.connected?(Object.entries(r.topics).forEach((r=>{let[n,i]=r;const s=this.params.topics[n];void 0!==s&&(i.firstMessageDeliveries*=s.firstMessageDeliveriesDecay,i.firstMessageDeliveries<t&&(i.firstMessageDeliveries=0),i.meshMessageDeliveries*=s.meshMessageDeliveriesDecay,i.meshMessageDeliveries<t&&(i.meshMessageDeliveries=0),i.meshFailurePenalty*=s.meshFailurePenaltyDecay,i.meshFailurePenalty<t&&(i.meshFailurePenalty=0),i.invalidMessageDeliveries*=s.invalidMessageDeliveriesDecay,i.invalidMessageDeliveries<t&&(i.invalidMessageDeliveries=0),i.inMesh&&(i.meshTime=e-i.graftTime,i.meshTime>s.meshMessageDeliveriesActivation&&(i.meshMessageDeliveriesActive=!0)))})),r.behaviourPenalty*=this.params.behaviourPenaltyDecay,r.behaviourPenalty<t&&(r.behaviourPenalty=0)):e>r.expire&&(this.removeIPsForPeer(n,r.knownIPs),this.peerStats.delete(n),this.scoreCache.delete(n))}))}score(e){this.metrics?.scoreFnCalls.inc();const t=this.peerStats.get(e);if(null==t)return 0;const r=Date.now(),n=this.scoreCache.get(e);if(null!=n&&n.cacheUntil>r)return n.score;this.metrics?.scoreFnRuns.inc();const i=this.computeScore(e,t,this.params,this.peerIPs),s=r+this.scoreCacheValidityMs;return null!=n?(this.metrics?.scoreCachedDelta.observe(Math.abs(i-n.score)),n.score=i,n.cacheUntil=s):this.scoreCache.set(e,{score:i,cacheUntil:s}),i}addPenalty(e,t,r){const n=this.peerStats.get(e);null!=n&&(n.behaviourPenalty+=t,this.metrics?.onScorePenalty(r))}addPeer(e){const t={connected:!0,expire:0,topics:{},knownIPs:new Set,behaviourPenalty:0};this.peerStats.set(e,t)}addIP(e,t){const r=this.peerStats.get(e);null!=r&&r.knownIPs.add(t),this.peerIPs.getOrDefault(t).add(e)}removeIP(e,t){const r=this.peerStats.get(e);null!=r&&r.knownIPs.delete(t);const n=this.peerIPs.get(t);null!=n&&(n.delete(e),0===n.size&&this.peerIPs.delete(t))}removePeer(e){const t=this.peerStats.get(e);if(null!=t){if(this.score(e)>0)return this.removeIPsForPeer(e,t.knownIPs),void this.peerStats.delete(e);Object.entries(t.topics).forEach((e=>{let[t,r]=e;r.firstMessageDeliveries=0;const n=this.params.topics[t].meshMessageDeliveriesThreshold;if(r.inMesh&&r.meshMessageDeliveriesActive&&r.meshMessageDeliveries<n){const e=n-r.meshMessageDeliveries;r.meshFailurePenalty+=e*e}r.inMesh=!1,r.meshMessageDeliveriesActive=!1})),t.connected=!1,t.expire=Date.now()+this.params.retainScore}}graft(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);null!=e&&(e.inMesh=!0,e.graftTime=Date.now(),e.meshTime=0,e.meshMessageDeliveriesActive=!1)}}prune(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);if(null!=e){const r=this.params.topics[t].meshMessageDeliveriesThreshold;if(e.meshMessageDeliveriesActive&&e.meshMessageDeliveries<r){const t=r-e.meshMessageDeliveries;e.meshFailurePenalty+=t*t}e.meshMessageDeliveriesActive=!1,e.inMesh=!1}}}validateMessage(e){this.deliveryRecords.ensureRecord(e)}deliverMessage(e,t,r){this.markFirstMessageDelivery(e,r);const n=this.deliveryRecords.ensureRecord(t),i=Date.now();n.status===aj.unknown?(n.status=aj.valid,n.validated=i,n.peers.forEach((t=>{t!==e.toString()&&this.markDuplicateMessageDelivery(t,r)}))):this.log("unexpected delivery: message from %s was first seen %s ago and has delivery status %s",e,i-n.firstSeenTsMs,aj[n.status])}rejectInvalidMessage(e,t){this.markInvalidMessageDelivery(e,t)}rejectMessage(e,t,r,n){switch(n){case MH.Error:return void this.markInvalidMessageDelivery(e,r);case MH.Blacklisted:return}const i=this.deliveryRecords.ensureRecord(t);if(i.status===aj.unknown){if(n===MH.Ignore)return i.status=aj.ignored,void i.peers.clear();i.status=aj.invalid,this.markInvalidMessageDelivery(e,r),i.peers.forEach((e=>{this.markInvalidMessageDelivery(e,r)})),i.peers.clear()}else this.log("unexpected rejection: message from %s was first seen %s ago and has delivery status %d",e,Date.now()-i.firstSeenTsMs,aj[i.status])}duplicateMessage(e,t,r){const n=this.deliveryRecords.ensureRecord(t);if(!n.peers.has(e))switch(n.status){case aj.unknown:n.peers.add(e);break;case aj.valid:n.peers.add(e),this.markDuplicateMessageDelivery(e,r,n.validated);break;case aj.invalid:this.markInvalidMessageDelivery(e,r);case aj.ignored:}}markInvalidMessageDelivery(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);null!=e&&(e.invalidMessageDeliveries+=1)}}markFirstMessageDelivery(e,t){const r=this.peerStats.get(e);if(null!=r){const e=this.getPtopicStats(r,t);if(null!=e){let r=this.params.topics[t].firstMessageDeliveriesCap;e.firstMessageDeliveries=Math.min(r,e.firstMessageDeliveries+1),e.inMesh&&(r=this.params.topics[t].meshMessageDeliveriesCap,e.meshMessageDeliveries=Math.min(r,e.meshMessageDeliveries+1))}}}markDuplicateMessageDelivery(e,t,r){const n=this.peerStats.get(e);if(null!=n){const e=void 0!==r?Date.now():0,i=this.getPtopicStats(n,t);if(null!=i&&i.inMesh){const n=this.params.topics[t];if(void 0!==r){const i=e-r,s=i>n.meshMessageDeliveriesWindow;if(this.metrics?.onDuplicateMsgDelivery(t,i,s),s)return}const s=n.meshMessageDeliveriesCap;i.meshMessageDeliveries=Math.min(s,i.meshMessageDeliveries+1)}}}removeIPsForPeer(e,t){for(const r of t){const t=this.peerIPs.get(r);null!=t&&(t.delete(e),0===t.size&&this.peerIPs.delete(r))}}getPtopicStats(e,t){let r=e.topics[t];return void 0!==r?r:void 0!==this.params.topics[t]?(r={inMesh:!1,graftTime:0,meshTime:0,firstMessageDeliveries:0,meshMessageDeliveries:0,meshMessageDeliveriesActive:!1,meshFailurePenalty:0,invalidMessageDeliveries:0},e.topics[t]=r,r):null}}function hj(e,t,r,n,i){let s=0;const o=new Map;if(Object.entries(t.topics).forEach((e=>{let[t,n]=e;const a=i.get(t)??"unknown",c=r.topics[t];if(void 0===c)return;let u=o.get(a);null==u&&(u={p1w:0,p2w:0,p3w:0,p3bw:0,p4w:0},o.set(a,u));let l=0,h=0,d=0,f=0,p=0;if(n.inMesh){l+=Math.max(n.meshTime/c.timeInMeshQuantum,c.timeInMeshCap)*c.timeInMeshWeight}let g=n.firstMessageDeliveries;if(g>c.firstMessageDeliveriesCap&&(g=c.firstMessageDeliveriesCap),h+=g*c.firstMessageDeliveriesWeight,n.meshMessageDeliveriesActive&&n.meshMessageDeliveries<c.meshMessageDeliveriesThreshold){const e=c.meshMessageDeliveriesThreshold-n.meshMessageDeliveries;d+=e*e*c.meshMessageDeliveriesWeight}f+=n.meshFailurePenalty*c.meshFailurePenaltyWeight;p+=n.invalidMessageDeliveries*n.invalidMessageDeliveries*c.invalidMessageDeliveriesWeight,s+=(l+h+d+f+p)*c.topicWeight,u.p1w+=l,u.p2w+=h,u.p3w+=d,u.p3bw+=f,u.p4w+=p})),r.topicScoreCap>0&&s>r.topicScoreCap){s=r.topicScoreCap;const e=r.topicScoreCap/s;for(const t of o.values())t.p1w*=e,t.p2w*=e,t.p3w*=e,t.p3bw*=e,t.p4w*=e}let a=0,c=0,u=0;a+=r.appSpecificScore(e)*r.appSpecificWeight,t.knownIPs.forEach((e=>{if(r.IPColocationFactorWhitelist.has(e))return;const t=n.get(e),i=null!=t?t.size:0;if(i>r.IPColocationFactorThreshold){const e=i-r.IPColocationFactorThreshold;c+=e*e*r.IPColocationFactorWeight}}));return u+=t.behaviourPenalty*t.behaviourPenalty*r.behaviourPenaltyWeight,s+=a+c+u,{byTopic:o,p5w:a,p6w:c,p7w:u,score:s}}class dj{rawStream;pushable;closeController;maxBufferSize;constructor(e,t,r){this.rawStream=e,this.pushable=hh(),this.closeController=new AbortController,this.maxBufferSize=r.maxBufferSize??1/0,this.closeController.signal.addEventListener("abort",(()=>{e.close().catch((t=>{e.abort(t)}))})),ph(this.pushable,this.rawStream).catch(t)}get protocol(){return this.rawStream.protocol}push(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(rh.single(e))}pushPrefixed(e){if(this.pushable.readableLength>this.maxBufferSize)throw Error(`OutboundStream buffer full, size > ${this.maxBufferSize}`);this.pushable.push(e)}async close(){this.closeController.abort(),await this.pushable.return()}}class fj{source;rawStream;closeController;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.rawStream=e,this.closeController=new AbortController,this.closeController.signal.addEventListener("abort",(()=>{e.close().catch((t=>{e.abort(t)}))})),this.source=ph(this.rawStream,(e=>oh(e,t)))}async close(){this.closeController.abort()}}class pj{gossipsubIWantFollowupMs;msgIdToStrFn;metrics;promises=new Map;requestMsByMsg=new Map;requestMsByMsgExpire;constructor(e,t,r){this.gossipsubIWantFollowupMs=e,this.msgIdToStrFn=t,this.metrics=r,this.requestMsByMsgExpire=10*e}get size(){return this.promises.size}get requestMsByMsgSize(){return this.requestMsByMsg.size}addPromise(e,t){const r=t[Math.floor(Math.random()*t.length)],n=this.msgIdToStrFn(r);let i=this.promises.get(n);null==i&&(i=new Map,this.promises.set(n,i));const s=Date.now();i.has(e)||(i.set(e,s+this.gossipsubIWantFollowupMs),null!=this.metrics&&(this.metrics.iwantPromiseStarted.inc(1),this.requestMsByMsg.has(n)||this.requestMsByMsg.set(n,s)))}getBrokenPromises(){const e=Date.now(),t=new Map;let r=0;return this.promises.forEach(((n,i)=>{n.forEach(((i,s)=>{i<e&&(t.set(s,(t.get(s)??0)+1),n.delete(s),r++)})),0===n.size&&this.promises.delete(i)})),this.metrics?.iwantPromiseBroken.inc(r),t}deliverMessage(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.trackMessage(e);const r=this.promises.get(e);null!=r&&(this.promises.delete(e),null!=this.metrics&&(this.metrics.iwantPromiseResolved.inc(1),t&&this.metrics.iwantPromiseResolvedFromDuplicate.inc(1),this.metrics.iwantPromiseResolvedPeers.inc(r.size)))}rejectMessage(e,t){this.trackMessage(e),t!==MH.Error&&this.promises.delete(e)}clear(){this.promises.clear()}prune(){const e=Date.now()-this.requestMsByMsgExpire;let t=0;for(const[r,n]of this.requestMsByMsg.entries()){if(!(n<e))break;this.requestMsByMsg.delete(r),t++}this.metrics?.iwantMessagePruned.inc(t)}trackMessage(e){if(null!=this.metrics){const t=this.requestMsByMsg.get(e);void 0!==t&&(this.metrics.iwantPromiseDeliveryTime.observe((Date.now()-t)/1e3),this.requestMsByMsg.delete(e))}}}function gj(e){if(isNaN(e)||e<=0)throw new Xp("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Cc(e)}function bj(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const yj=32,mj=64,wj=32;function vj(e,t){const r=new Uint8Array(mj);for(let n=0;n<wj;n++)r[n]=e[n],r[wj+n]=t[n];return r}function _j(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=fH(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}const Ej={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)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}},Sj={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function Aj(e,t){const r=function(e){const t=e?.algorithm??"AES-GCM";let r=e?.keyLength??16;const n=e?.nonceLength??12,i=e?.digest??"SHA-256",s=e?.saltLength??16,o=e?.iterations??32767,a=Ej.get();return r*=8,{encrypt:async function(e,c){const u=a.getRandomValues(new Uint8Array(s)),l=a.getRandomValues(new Uint8Array(n)),h={name:t,iv:l};let d;if("string"===typeof c&&(c=mH(c)),0===c.length){d=await a.subtle.importKey("jwk",Sj,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",Sj,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}const f=await a.subtle.encrypt(h,d,e);return _j([u,h.iv,new Uint8Array(f)])},decrypt:async function(e,c){const u=e.subarray(0,s),l=e.subarray(s,s+n),h=e.subarray(s+n),d={name:t,iv:l};let f;if("string"===typeof c&&(c=mH(c)),0===c.length)try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}catch{f=await a.subtle.importKey("jwk",Sj,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}const p=await a.subtle.decrypt(d,f,h);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return Nz.encode(n)}var kj,xj,Ij,Cj;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(kj||(kj={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(xj||(xj={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return jH("enum",NH.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(xj)}(kj||(kj={})),function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),kj.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=kj.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>DH(t,e.codec()),e.decode=t=>dH(t,e.codec())}(Ij||(Ij={})),function(e){let t;e.codec=()=>(null==t&&(t=GH((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),kj.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=kj.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>DH(t,e.codec()),e.decode=t=>dH(t,e.codec())}(Cj||(Cj={}));class Tj{_key;constructor(e){this._key=Uj(e,yj)}verify(e,t){return function(e,t,r){return Lp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return Ij.encode({Type:kj.Ed25519,Data:this.marshal()}).subarray()}equals(e){return B$(this.bytes,e.bytes)}hash(){const e=S$.digest(this.bytes);return bj(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class Rj{_key;_publicKey;constructor(e,t){this._key=Uj(e,mj),this._publicKey=Uj(t,yj)}sign(e){return function(e,t){const r=e.subarray(0,wj);return Lp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new Tj(this._publicKey)}marshal(){return this._key}get bytes(){return Cj.encode({Type:kj.Ed25519,Data:this.marshal()}).subarray()}equals(e){return B$(this.bytes,e.bytes)}async hash(){const e=S$.digest(this.bytes);let t;return bj(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=w$.digest(this.public.bytes);return dz.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return Aj(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function Pj(e){if(e.length>mj){const t=(e=Uj(e,mj+yj)).subarray(0,mj),r=e.subarray(mj,e.length);return new Rj(t,r)}const t=(e=Uj(e,mj)).subarray(0,mj),r=e.subarray(yj);return new Rj(t,r)}function Dj(e){return e=Uj(e,yj),new Tj(e)}async function Nj(){const{privateKey:e,publicKey:t}=function(){const e=Lp.utils.randomPrivateKey(),t=Lp.getPublicKey(e);return{privateKey:vj(e,t),publicKey:t}}();return new Rj(e,t)}async function Bj(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==wj)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Lp.getPublicKey(t);return{privateKey:vj(t,r),publicKey:r}}(e);return new Rj(t,r)}function Uj(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new Xp(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}function Lj(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=yH[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}async function Mj(e){const t=[await Ej.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await qj(e)],r=await Oj({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function Oj(e){if(null==e.privateKey||null==e.publicKey)throw new Xp("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Ej.get().subtle.exportKey("jwk",e.privateKey),Ej.get().subtle.exportKey("jwk",e.publicKey)])}async function qj(e){return Ej.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function Kj(e){if("RSA"!==e.kty)throw new Xp("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new Xp("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*mH(e.n,"base64url").length}function Fj(e){let t=e.toString(16);t.length%2>0&&(t=`0${t}`);const r=t.length/2,n=new Uint8Array(r);let i=0,s=0;for(;i<r;)n[i]=parseInt(t.slice(s,s+2),16),i+=1,s+=2;return n}function Vj(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r=`0${r}`),t.push(r)})),BigInt("0x"+t.join(""))}const zj=32,$j=1e4;const Hj=8192;class jj{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,r){const n=await Ej.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Ej.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new fU({valueHex:new xU({value:[mU.fromBigInt(Vj(mH(e.n,"base64url"))),mU.fromBigInt(Vj(mH(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return Ij.encode({Type:kj.RSA,Data:this.marshal()}).subarray()}equals(e){return B$(this.bytes,e.bytes)}hash(){const e=S$.digest(this.bytes);return bj(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class Gj{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return gj(16)}sign(e){return async function(e,t){const r=await Ej.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Ej.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new Xp("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new jj(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new mU({value:0}),mU.fromBigInt(Vj(mH(e.n,"base64url"))),mU.fromBigInt(Vj(mH(e.e,"base64url"))),mU.fromBigInt(Vj(mH(e.d,"base64url"))),mU.fromBigInt(Vj(mH(e.p,"base64url"))),mU.fromBigInt(Vj(mH(e.q,"base64url"))),mU.fromBigInt(Vj(mH(e.dp,"base64url"))),mU.fromBigInt(Vj(mH(e.dq,"base64url"))),mU.fromBigInt(Vj(mH(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return Cj.encode({Type:kj.RSA,Data:this.marshal()}).subarray()}equals(e){return B$(this.bytes,e.bytes)}hash(){const e=S$.digest(this.bytes);return bj(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Lj(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=Ej.get(),n=new xU({value:[new mU({value:0}),new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new hU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),s=gj(16),o=await jN(Ef,t,s,{c:$j,dkLen:zj}),a=gj(16),c=await r.subtle.importKey("raw",o,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new xU({value:[new hU({valueHex:s}),new mU({value:$j}),new mU({value:zj}),new xU({value:[new EU({value:"1.2.840.113549.2.11"}),new aU]})]}),h=new xU({value:[new EU({value:"1.2.840.113549.1.5.13"}),new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.5.12"}),l]}),new xU({value:[new EU({value:"2.16.840.1.101.3.4.1.42"}),new hU({valueHex:a})]})]})]}),d=new xU({value:[h,new hU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...Lj(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return Aj(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function Wj(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value;return{n:Lj(Fj(r[1].toBigInt()),"base64url"),e:Lj(Fj(r[2].toBigInt()),"base64url"),d:Lj(Fj(r[3].toBigInt()),"base64url"),p:Lj(Fj(r[4].toBigInt()),"base64url"),q:Lj(Fj(r[5].toBigInt()),"base64url"),dp:Lj(Fj(r[6].toBigInt()),"base64url"),dq:Lj(Fj(r[7].toBigInt()),"base64url"),qi:Lj(Fj(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(Kj(t)>Hj)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await Mj(t);return new Gj(r.privateKey,r.publicKey)}function Yj(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:Lj(Fj(r[0].toBigInt()),"base64url"),e:Lj(Fj(r[1].toBigInt()),"base64url")}}(e);if(Kj(t)>Hj)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new jj(t)}async function Qj(e){if(Kj(e)>Hj)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await Mj(e);return new Gj(t.privateKey,t.publicKey)}async function Jj(e){if(e>Hj)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await Ej.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await Oj(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new Gj(t.privateKey,t.publicKey)}function Xj(e){try{lm.ProjectivePoint.fromHex(e)}catch(t){throw new Xp(String(t),"ERR_INVALID_PUBLIC_KEY")}}class Zj{_key;constructor(e){Xj(e),this._key=e}verify(e,t){return function(e,t,r){const n=S$.digest(r instanceof Uint8Array?r:r.subarray());if(bj(n))return n.then((r=>{let{digest:n}=r;return lm.verify(t,n,e)})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.verify(t,n.digest,e)}catch(i){throw new Xp(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,lm.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return Ij.encode({Type:kj.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return B$(this.bytes,e.bytes)}async hash(){const e=S$.digest(this.bytes);let t;return bj(e)?({bytes:t}=await e):t=e.bytes,t}}class eG{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),Xj(this._publicKey)}sign(e){return function(e,t){const r=S$.digest(t instanceof Uint8Array?t:t.subarray());if(bj(r))return r.then((t=>{let{digest:r}=t;return lm.sign(r,e).toDERRawBytes()})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.sign(r.digest,e).toDERRawBytes()}catch(n){throw new Xp(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new Zj(this._publicKey)}marshal(){return this._key}get bytes(){return Cj.encode({Type:kj.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return B$(this.bytes,e.bytes)}hash(){const e=S$.digest(this.bytes);return bj(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Lj(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return Aj(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function tG(e){return new eG(e)}function rG(e){return new Zj(e)}async function nG(){const e=lm.utils.randomPrivateKey();return new eG(e)}const iG={rsa:pr,ed25519:fr,secp256k1:gr};function sG(e){const t=Object.keys(iG).join(" / ");return new Xp(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function oG(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return iG[e];throw sG(e)}function aG(e){const t=Ij.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case kj.RSA:return iG.rsa.unmarshalRsaPublicKey(r);case kj.Ed25519:return iG.ed25519.unmarshalEd25519PublicKey(r);case kj.Secp256k1:return iG.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw sG(t.Type??"unknown")}}async function cG(e){const t=Cj.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case kj.RSA:return iG.rsa.unmarshalRsaPrivateKey(r);case kj.Ed25519:return iG.ed25519.unmarshalEd25519PrivateKey(r);case kj.Secp256k1:return iG.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw sG(t.Type??"RSA")}}const uG=mH("libp2p-pubsub:");function lG(){let e=arguments.length>1?arguments[1]:void 0;return{subscriptions:[],messages:arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],control:void 0!==e?{graft:e.graft??[],prune:e.prune??[],ihave:e.ihave??[],iwant:e.iwant??[]}:void 0}}function hG(e){return void 0===e.control&&(e.control={graft:[],prune:[],ihave:[],iwant:[]}),e}function dG(e){return Lj(e,"base64")}function fG(e){if(e.length<=1)return e;for(let t=0;t<e.length;t++){const r=Math.floor(Math.random()*Math.floor(e.length)),n=e[t];e[t]=e[r],e[r]=n}return e}new Uint8Array(0);function pG(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var gG=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=mG;)r[n++]=255&t|bG,t/=128;for(;t&yG;)r[n++]=255&t|bG,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},bG=128,yG=-128,mG=Math.pow(2,31);var wG=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&_G)<<s:(n&_G)*Math.pow(2,s),s+=7}while(n>=vG);return e.bytes=o-r,i},vG=128,_G=127;var EG=Math.pow(2,7),SG=Math.pow(2,14),AG=Math.pow(2,21),kG=Math.pow(2,28),xG=Math.pow(2,35),IG=Math.pow(2,42),CG=Math.pow(2,49),TG=Math.pow(2,56),RG=Math.pow(2,63);const PG={encode:gG,decode:wG,encodingLength:function(e){return e<EG?1:e<SG?2:e<AG?3:e<kG?4:e<xG?5:e<IG?6:e<CG?7:e<TG?8:e<RG?9:10}};function DG(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return PG.encode(e,t,r),t}function NG(e){return PG.encodingLength(e)}function BG(e,t){const r=t.byteLength,n=NG(e),i=n+NG(r),s=new Uint8Array(i+r);return DG(e,s,0),DG(r,s,n),s.set(t,i),new UG(e,r,t,s)}class UG{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}function LG(e){let{name:t,code:r,encode:n}=e;return new MG(t,r,n)}class MG{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?BG(this.code,t):t.then((e=>BG(this.code,e)))}throw Error("Unknown type, must be binary type")}}function OG(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const qG=LG({name:"sha2-256",code:18,encode:OG("SHA-256")}),KG=LG({name:"sha2-512",code:19,encode:OG("SHA-512")});var FG=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const VG=FG;class zG{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class $G{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return jG(this,e)}}class HG{decoders;constructor(e){this.decoders=e}or(e){return jG(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function jG(e,t){return new HG({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class GG{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new zG(e,t,r),this.decoder=new $G(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function WG(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new GG(t,r,n,i)}function YG(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=VG(n,t);return WG({prefix:r,name:t,encode:i,decode:e=>pG(s(e))})}function QG(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return WG({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const JG=YG({prefix:"9",name:"base10",alphabet:"0123456789"}),XG=QG({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ZG=QG({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),eW=QG({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),tW=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),rW=tW.reduce(((e,t,r)=>(e[r]=t,e)),[]),nW=tW.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const iW=WG({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=rW[t]),"")},decode:function(e){const t=[];for(const r of e){const e=nW[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),sW=QG({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),oW=QG({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),aW=QG({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),cW=QG({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),uW=QG({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),lW=QG({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),hW=QG({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),dW=QG({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),fW=QG({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),pW=YG({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),gW=YG({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),bW=YG({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),yW=YG({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),mW=QG({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),wW=QG({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vW=QG({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_W=QG({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),EW=QG({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),SW=WG({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),AW=new TextEncoder,kW=new TextDecoder,xW="json",IW=512;function CW(e){return AW.encode(JSON.stringify(e))}function TW(e){return JSON.parse(kW.decode(e))}const RW="raw",PW=85;function DW(e){return pG(e)}function NW(e){return pG(e)}const BW=pG;const UW={code:0,name:"identity",encode:BW,digest:function(e){return BG(0,BW(e))}};new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const LW={...xr,...wr,...kr,...yr,...mr,..._r,...Er,...Sr,...Ar,...vr};function MW(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const OW=MW("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),qW=MW("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),KW={utf8:OW,"utf-8":OW,hex:LW.base16,latin1:qW,ascii:qW,binary:qW,...LW};const FW=(e,t)=>{const r=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=KW[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}(t.toString(16).padStart(16,"0"),"base16"),n=new Uint8Array(e.length+r.length);return n.set(e,0),n.set(r,e.length),n};function VW(e){if("signed"!==e.type)throw new Error("expected signed message type");if(null==e.sequenceNumber)throw Error("missing seqno field");return FW(e.from.toBytes(),e.sequenceNumber)}async function zW(e){return S$.encode(e.data)}const $W=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(4===r){const n=[];for(let i=0;i<r;i++)n.push(e[t+i]);return n.join(".")}if(16===r){const e=[];for(let i=0;i<r;i+=2)e.push(n.getUint16(t+i).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},HW=-1,jW={},GW={};function WW(e){if("number"===typeof e){if(null!=GW[e])return GW[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=jW[e])return jW[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,HW,"ip6zone"],[43,8,"ipcidr"],[53,HW,"dns",!0],[54,HW,"dns4",!0],[55,HW,"dns6",!0],[56,HW,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,HW,"unix",!1,!0],[421,HW,"ipfs"],[421,HW,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,HW,"garlic64"],[448,0,"tls"],[449,HW,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,HW,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,HW,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);GW[t.code]=t,jW[t.name]=t}));WW("ip4"),WW("ip6"),WW("ipcidr");function YW(e,t){switch(WW(e).code){case 4:case 41:return function(e){const t=$W(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Ax(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return XW(t);case 6:case 273:case 33:case 132:return JW(t).toString();case 421:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return Lj(r,"base58btc")}(t);case 444:case 445:return ZW(t);case 466:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+Lj(r,"base64url")}(t);default:return Lj(t,"base16")}}const QW=Object.values(N$).map((e=>e.decoder));!function(){let e=QW[0].or(QW[1]);QW.slice(2).forEach((t=>e=e.or(t)))}();function JW(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function XW(e){const t=ws(e);if((e=e.slice(gs(t))).length!==t)throw new Error("inconsistent lengths");return Lj(e)}function ZW(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return`${Lj(t,"base32")}:${JW(r)}`}var eY;!function(e){e[e.ip4=4]="ip4",e[e.ip6=41]="ip6"}(eY||(eY={}));class tY{entries=new Map;validityMs;constructor(e){this.validityMs=e.validityMs}get size(){return this.entries.size}put(e,t){return!!this.entries.has(e)||(this.entries.set(e,{value:t,validUntilMs:Date.now()+this.validityMs}),!1)}prune(){const e=Date.now();for(const[t,r]of this.entries.entries()){if(!(r.validUntilMs<e))break;this.entries.delete(t)}}has(e){return this.entries.has(e)}get(e){const t=this.entries.get(e);return null!=t&&t.validUntilMs>=Date.now()?t.value:void 0}clear(){this.entries.clear()}}var rY;!function(e){e[e.started=0]="started",e[e.stopped=1]="stopped"}(rY||(rY={}));class nY extends sd{globalSignaturePolicy;multicodecs=[W$,G$];publishConfig;dataTransform;peers=new Set;streamsInbound=new Map;streamsOutbound=new Map;outboundInflightQueue=hh({objectMode:!0});direct=new Set;floodsubPeers=new Set;seenCache;acceptFromWhitelist=new Map;topics=new Map;subscriptions=new Set;mesh=new Map;fanout=new Map;fanoutLastpub=new Map;gossip=new Map;control=new Map;peerhave=new Map;iasked=new Map;backoff=new Map;outbound=new Map;msgIdFn;fastMsgIdFn;msgIdToStrFn;fastMsgIdCache;publishedMessageIds;mcache;score;topicValidators=new Map;log;heartbeatTicks=0;gossipTracer;components;directPeerInitial=null;static multicodec=W$;opts;decodeRpcLimits;metrics;status={code:rY.stopped};maxInboundStreams;maxOutboundStreams;runOnTransientConnection;allowedTopics;heartbeatTimer=null;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super();const r={fallbackToFloodsub:!0,floodPublish:!0,batchPublish:!1,doPX:!1,directPeers:[],D:6,Dlo:4,Dhi:12,Dscore:4,Dout:2,Dlazy:6,heartbeatInterval:1e3,fanoutTTL:6e4,mcacheLength:5,mcacheGossip:3,seenTTL:12e4,gossipsubIWantFollowupMs:3e3,prunePeers:16,pruneBackoff:6e4,unsubcribeBackoff:1e4,graftFloodThreshold:1e4,opportunisticGraftPeers:2,opportunisticGraftTicks:60,directConnectTicks:300,...t,scoreParams:ej(t.scoreParams),scoreThresholds:nj(t.scoreThresholds)};if(this.components=e,this.decodeRpcLimits=r.decodeRpcLimits??Q$,this.globalSignaturePolicy=r.globalSignaturePolicy??XV,r.fallbackToFloodsub&&this.multicodecs.push(j$),this.log=e.logger.forComponent(r.debugName??"libp2p:gossipsub"),this.opts=r,this.direct=new Set(r.directPeers.map((e=>e.id.toString()))),this.seenCache=new tY({validityMs:r.seenTTL}),this.publishedMessageIds=new tY({validityMs:r.seenTTL}),null!=t.msgIdFn)this.msgIdFn=t.msgIdFn;else switch(this.globalSignaturePolicy){case XV:this.msgIdFn=VW;break;case ZV:this.msgIdFn=zW;break;default:throw new Error(`Invalid globalSignaturePolicy: ${this.globalSignaturePolicy}`)}if(null!=t.fastMsgIdFn&&(this.fastMsgIdFn=t.fastMsgIdFn,this.fastMsgIdCache=new tY({validityMs:r.seenTTL})),this.msgIdToStrFn=t.msgIdToStrFn??dG,this.mcache=t.messageCache??new YH(r.mcacheGossip,r.mcacheLength,this.msgIdToStrFn),null!=t.dataTransform&&(this.dataTransform=t.dataTransform),null!=t.metricsRegister){if(null==t.metricsTopicStrToLabel)throw Error("Must set metricsTopicStrToLabel with metrics");const e=Math.max(...Object.values(r.scoreParams.topics).map((e=>e.meshMessageDeliveriesWindow)),1e3),n=function(e,t,r){return{protocolsEnabled:e.gauge({name:"gossipsub_protocol",help:"Status of enabled protocols",labelNames:["protocol"]}),topicSubscriptionStatus:e.gauge({name:"gossipsub_topic_subscription_status",help:"Status of our subscription to this topic",labelNames:["topicStr"]}),topicPeersCount:e.gauge({name:"gossipsub_topic_peer_count",help:"Number of peers subscribed to each topic",labelNames:["topicStr"]}),meshPeerCounts:e.gauge({name:"gossipsub_mesh_peer_count",help:"Number of peers in our mesh",labelNames:["topicStr"]}),meshPeerInclusionEventsFanout:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_fanout_total",help:"Number of times we include peers in a topic mesh for fanout reasons",labelNames:["topic"]}),meshPeerInclusionEventsRandom:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_random_total",help:"Number of times we include peers in a topic mesh for random reasons",labelNames:["topic"]}),meshPeerInclusionEventsSubscribed:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_subscribed_total",help:"Number of times we include peers in a topic mesh for subscribed reasons",labelNames:["topic"]}),meshPeerInclusionEventsOutbound:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_outbound_total",help:"Number of times we include peers in a topic mesh for outbound reasons",labelNames:["topic"]}),meshPeerInclusionEventsNotEnough:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_not_enough_total",help:"Number of times we include peers in a topic mesh for not_enough reasons",labelNames:["topic"]}),meshPeerInclusionEventsOpportunistic:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_opportunistic_total",help:"Number of times we include peers in a topic mesh for opportunistic reasons",labelNames:["topic"]}),meshPeerInclusionEventsUnknown:e.gauge({name:"gossipsub_mesh_peer_inclusion_events_unknown_total",help:"Number of times we include peers in a topic mesh for unknown reasons",labelNames:["topic"]}),meshPeerChurnEventsDisconnected:e.gauge({name:"gossipsub_peer_churn_events_disconnected_total",help:"Number of times we remove peers in a topic mesh for disconnected reasons",labelNames:["topic"]}),meshPeerChurnEventsBadScore:e.gauge({name:"gossipsub_peer_churn_events_bad_score_total",help:"Number of times we remove peers in a topic mesh for bad_score reasons",labelNames:["topic"]}),meshPeerChurnEventsPrune:e.gauge({name:"gossipsub_peer_churn_events_prune_total",help:"Number of times we remove peers in a topic mesh for prune reasons",labelNames:["topic"]}),meshPeerChurnEventsExcess:e.gauge({name:"gossipsub_peer_churn_events_excess_total",help:"Number of times we remove peers in a topic mesh for excess reasons",labelNames:["topic"]}),meshPeerChurnEventsUnknown:e.gauge({name:"gossipsub_peer_churn_events_unknown_total",help:"Number of times we remove peers in a topic mesh for unknown reasons",labelNames:["topic"]}),peersPerProtocol:e.gauge({name:"gossipsub_peers_per_protocol_count",help:"Peers connected for each topic",labelNames:["protocol"]}),heartbeatDuration:e.histogram({name:"gossipsub_heartbeat_duration_seconds",help:"The time it takes to complete one iteration of the heartbeat",buckets:[.01,.1,1]}),heartbeatSkipped:e.gauge({name:"gossipsub_heartbeat_skipped",help:"Heartbeat run took longer than heartbeat interval so next is skipped"}),acceptedMessagesTotal:e.gauge({name:"gossipsub_accepted_messages_total",help:"Total accepted messages for each topic",labelNames:["topic"]}),ignoredMessagesTotal:e.gauge({name:"gossipsub_ignored_messages_total",help:"Total ignored messages for each topic",labelNames:["topic"]}),rejectedMessagesTotal:e.gauge({name:"gossipsub_rejected_messages_total",help:"Total rejected messages for each topic",labelNames:["topic"]}),unknownValidationResultsTotal:e.gauge({name:"gossipsub_unknown_validation_results_total",help:"Total unknown validation results for each topic",labelNames:["topic"]}),asyncValidationMcacheHit:e.gauge({name:"gossipsub_async_validation_mcache_hit_total",help:"Async validation result reported by the user layer",labelNames:["hit"]}),asyncValidationDelayFromFirstSeenSec:e.histogram({name:"gossipsub_async_validation_delay_from_first_seen",help:"Async validation report delay from first seen in second",buckets:[.01,.03,.1,.3,1,3,10]}),asyncValidationUnknownFirstSeen:e.gauge({name:"gossipsub_async_validation_unknown_first_seen_count_total",help:"Async validation report unknown first seen value for message"}),peerReadStreamError:e.gauge({name:"gossipsub_peer_read_stream_err_count_total",help:"Peer read stream error"}),rpcRecvBytes:e.gauge({name:"gossipsub_rpc_recv_bytes_total",help:"RPC recv"}),rpcRecvCount:e.gauge({name:"gossipsub_rpc_recv_count_total",help:"RPC recv"}),rpcRecvSubscription:e.gauge({name:"gossipsub_rpc_recv_subscription_total",help:"RPC recv"}),rpcRecvMessage:e.gauge({name:"gossipsub_rpc_recv_message_total",help:"RPC recv"}),rpcRecvControl:e.gauge({name:"gossipsub_rpc_recv_control_total",help:"RPC recv"}),rpcRecvIHave:e.gauge({name:"gossipsub_rpc_recv_ihave_total",help:"RPC recv"}),rpcRecvIWant:e.gauge({name:"gossipsub_rpc_recv_iwant_total",help:"RPC recv"}),rpcRecvGraft:e.gauge({name:"gossipsub_rpc_recv_graft_total",help:"RPC recv"}),rpcRecvPrune:e.gauge({name:"gossipsub_rpc_recv_prune_total",help:"RPC recv"}),rpcDataError:e.gauge({name:"gossipsub_rpc_data_err_count_total",help:"RPC data error"}),rpcRecvError:e.gauge({name:"gossipsub_rpc_recv_err_count_total",help:"RPC recv error"}),rpcRecvNotAccepted:e.gauge({name:"gossipsub_rpc_rcv_not_accepted_total",help:"Total count of RPC dropped because acceptFrom() == false"}),rpcSentBytes:e.gauge({name:"gossipsub_rpc_sent_bytes_total",help:"RPC sent"}),rpcSentCount:e.gauge({name:"gossipsub_rpc_sent_count_total",help:"RPC sent"}),rpcSentSubscription:e.gauge({name:"gossipsub_rpc_sent_subscription_total",help:"RPC sent"}),rpcSentMessage:e.gauge({name:"gossipsub_rpc_sent_message_total",help:"RPC sent"}),rpcSentControl:e.gauge({name:"gossipsub_rpc_sent_control_total",help:"RPC sent"}),rpcSentIHave:e.gauge({name:"gossipsub_rpc_sent_ihave_total",help:"RPC sent"}),rpcSentIWant:e.gauge({name:"gossipsub_rpc_sent_iwant_total",help:"RPC sent"}),rpcSentGraft:e.gauge({name:"gossipsub_rpc_sent_graft_total",help:"RPC sent"}),rpcSentPrune:e.gauge({name:"gossipsub_rpc_sent_prune_total",help:"RPC sent"}),msgPublishCount:e.gauge({name:"gossipsub_msg_publish_count_total",help:"Total count of msg published by topic",labelNames:["topic"]}),msgPublishPeersByTopic:e.gauge({name:"gossipsub_msg_publish_peers_total",help:"Total count of peers that we publish a msg to",labelNames:["topic"]}),directPeersPublishedTotal:e.gauge({name:"gossipsub_direct_peers_published_total",help:"Total direct peers that we publish a msg to",labelNames:["topic"]}),floodsubPeersPublishedTotal:e.gauge({name:"gossipsub_floodsub_peers_published_total",help:"Total floodsub peers that we publish a msg to",labelNames:["topic"]}),meshPeersPublishedTotal:e.gauge({name:"gossipsub_mesh_peers_published_total",help:"Total mesh peers that we publish a msg to",labelNames:["topic"]}),fanoutPeersPublishedTotal:e.gauge({name:"gossipsub_fanout_peers_published_total",help:"Total fanout peers that we publish a msg to",labelNames:["topic"]}),msgPublishBytes:e.gauge({name:"gossipsub_msg_publish_bytes_total",help:"Total count of msg publish data.length bytes",labelNames:["topic"]}),msgPublishTime:e.histogram({name:"gossipsub_msg_publish_seconds",help:"Total time in seconds to publish a message",buckets:[.001,.002,.005,.01,.1,.5,1],labelNames:["topic"]}),msgForwardCount:e.gauge({name:"gossipsub_msg_forward_count_total",help:"Total count of msg forwarded by topic",labelNames:["topic"]}),msgForwardPeers:e.gauge({name:"gossipsub_msg_forward_peers_total",help:"Total count of peers that we forward a msg to",labelNames:["topic"]}),msgReceivedPreValidation:e.gauge({name:"gossipsub_msg_received_prevalidation_total",help:"Total count of recv msgs before any validation",labelNames:["topic"]}),msgReceivedError:e.gauge({name:"gossipsub_msg_received_error_total",help:"Total count of recv msgs error",labelNames:["topic"]}),prevalidationInvalidTotal:e.gauge({name:"gossipsub_pre_validation_invalid_total",help:"Total count of invalid messages received",labelNames:["topic"]}),prevalidationValidTotal:e.gauge({name:"gossipsub_pre_validation_valid_total",help:"Total count of valid messages received",labelNames:["topic"]}),prevalidationDuplicateTotal:e.gauge({name:"gossipsub_pre_validation_duplicate_total",help:"Total count of duplicate messages received",labelNames:["topic"]}),prevalidationUnknownTotal:e.gauge({name:"gossipsub_pre_validation_unknown_status_total",help:"Total count of unknown_status messages received",labelNames:["topic"]}),msgReceivedInvalid:e.gauge({name:"gossipsub_msg_received_invalid_total",help:"Tracks specific reason of invalid",labelNames:["error"]}),msgReceivedInvalidByTopic:e.gauge({name:"gossipsub_msg_received_invalid_by_topic_total",help:"Tracks specific invalid message by topic",labelNames:["topic"]}),duplicateMsgDeliveryDelay:e.histogram({name:"gossisub_duplicate_msg_delivery_delay_seconds",help:"Time since the 1st duplicated message validated",labelNames:["topic"],buckets:[.25*r.maxMeshMessageDeliveriesWindowSec,.5*r.maxMeshMessageDeliveriesWindowSec,Number(r.maxMeshMessageDeliveriesWindowSec),2*r.maxMeshMessageDeliveriesWindowSec,4*r.maxMeshMessageDeliveriesWindowSec]}),duplicateMsgLateDelivery:e.gauge({name:"gossisub_duplicate_msg_late_delivery_total",help:"Total count of late duplicate message delivery by topic, which triggers P3 penalty",labelNames:["topic"]}),duplicateMsgIgnored:e.gauge({name:"gossisub_ignored_published_duplicate_msgs_total",help:"Total count of published duplicate message ignored by topic",labelNames:["topic"]}),scoreFnCalls:e.gauge({name:"gossipsub_score_fn_calls_total",help:"Total times score() is called"}),scoreFnRuns:e.gauge({name:"gossipsub_score_fn_runs_total",help:"Total times score() call actually computed computeScore(), no cache"}),scoreCachedDelta:e.histogram({name:"gossipsub_score_cache_delta",help:"Delta of score between cached values that expired",buckets:[10,100,1e3]}),peersByScoreThreshold:e.gauge({name:"gossipsub_peers_by_score_threshold_count",help:"Current count of peers by score threshold",labelNames:["threshold"]}),score:e.avgMinMax({name:"gossipsub_score",help:"Avg min max of gossip scores"}),scoreWeights:e.avgMinMax({name:"gossipsub_score_weights",help:"Separate score weights",labelNames:["topic","p"]}),scorePerMesh:e.avgMinMax({name:"gossipsub_score_per_mesh",help:"Histogram of the scores for each mesh topic",labelNames:["topic"]}),scoringPenalties:e.gauge({name:"gossipsub_scoring_penalties_total",help:"A counter of the kind of penalties being applied to peers",labelNames:["penalty"]}),behaviourPenalty:e.histogram({name:"gossipsub_peer_stat_behaviour_penalty",help:"Current peer stat behaviour_penalty at each scrape",buckets:[.25*r.behaviourPenaltyThreshold,.5*r.behaviourPenaltyThreshold,Number(r.behaviourPenaltyThreshold),2*r.behaviourPenaltyThreshold,4*r.behaviourPenaltyThreshold]}),ihaveRcvIgnored:e.gauge({name:"gossipsub_ihave_rcv_ignored_total",help:"Total received IHAVE messages that we ignore for some reason",labelNames:["reason"]}),ihaveRcvMsgids:e.gauge({name:"gossipsub_ihave_rcv_msgids_total",help:"Total received IHAVE messages by topic",labelNames:["topic"]}),ihaveRcvNotSeenMsgids:e.gauge({name:"gossipsub_ihave_rcv_not_seen_msgids_total",help:"Total messages per topic we do not have, not actual requests",labelNames:["topic"]}),iwantRcvMsgids:e.gauge({name:"gossipsub_iwant_rcv_msgids_total",help:"Total received IWANT messages by topic",labelNames:["topic"]}),iwantRcvDonthaveMsgids:e.gauge({name:"gossipsub_iwant_rcv_dont_have_msgids_total",help:"Total requested messageIDs that we do not have"}),iwantPromiseStarted:e.gauge({name:"gossipsub_iwant_promise_sent_total",help:"Total count of started IWANT promises"}),iwantPromiseResolved:e.gauge({name:"gossipsub_iwant_promise_resolved_total",help:"Total count of resolved IWANT promises"}),iwantPromiseResolvedFromDuplicate:e.gauge({name:"gossipsub_iwant_promise_resolved_from_duplicate_total",help:"Total count of resolved IWANT promises from duplicate messages"}),iwantPromiseResolvedPeers:e.gauge({name:"gossipsub_iwant_promise_resolved_peers",help:"Total count of peers we have asked IWANT promises that are resolved"}),iwantPromiseBroken:e.gauge({name:"gossipsub_iwant_promise_broken",help:"Total count of broken IWANT promises"}),iwantMessagePruned:e.gauge({name:"gossipsub_iwant_message_pruned",help:"Total count of pruned IWANT messages"}),iwantPromiseDeliveryTime:e.histogram({name:"gossipsub_iwant_promise_delivery_seconds",help:"Histogram of delivery time of resolved IWANT promises",buckets:[.5*r.gossipPromiseExpireSec,Number(r.gossipPromiseExpireSec),2*r.gossipPromiseExpireSec,4*r.gossipPromiseExpireSec]}),iwantPromiseUntracked:e.gauge({name:"gossip_iwant_promise_untracked",help:"Total count of untracked IWANT promise"}),connectedPeersBackoffSec:e.histogram({name:"gossipsub_connected_peers_backoff_seconds",help:"Backoff time in seconds",buckets:[1,2,4,10,20,60,120]}),cacheSize:e.gauge({name:"gossipsub_cache_size",help:"Unbounded cache sizes",labelNames:["cache"]}),mcacheSize:e.gauge({name:"gossipsub_mcache_size",help:"Current mcache msg count"}),mcacheNotValidatedCount:e.gauge({name:"gossipsub_mcache_not_validated_count",help:"Current mcache msg count not validated"}),fastMsgIdCacheCollision:e.gauge({name:"gossipsub_fastmsgid_cache_collision_total",help:"Total count of key collisions on fastmsgid cache put"}),newConnectionCount:e.gauge({name:"gossipsub_new_connection_total",help:"Total new connection by status",labelNames:["status"]}),topicStrToLabel:t,toTopic(e){return this.topicStrToLabel.get(e)??e},onJoin(e){this.topicSubscriptionStatus.set({topicStr:e},1),this.meshPeerCounts.set({topicStr:e},0)},onLeave(e){this.topicSubscriptionStatus.set({topicStr:e},0),this.meshPeerCounts.set({topicStr:e},0)},onAddToMesh(e,t,r){const n=this.toTopic(e);switch(t){case FH.Fanout:this.meshPeerInclusionEventsFanout.inc({topic:n},r);break;case FH.Random:this.meshPeerInclusionEventsRandom.inc({topic:n},r);break;case FH.Subscribed:this.meshPeerInclusionEventsSubscribed.inc({topic:n},r);break;case FH.Outbound:this.meshPeerInclusionEventsOutbound.inc({topic:n},r);break;case FH.NotEnough:this.meshPeerInclusionEventsNotEnough.inc({topic:n},r);break;case FH.Opportunistic:this.meshPeerInclusionEventsOpportunistic.inc({topic:n},r);break;default:this.meshPeerInclusionEventsUnknown.inc({topic:n},r)}},onRemoveFromMesh(e,t,r){const n=this.toTopic(e);switch(t){case VH.Dc:this.meshPeerChurnEventsDisconnected.inc({topic:n},r);break;case VH.BadScore:this.meshPeerChurnEventsBadScore.inc({topic:n},r);break;case VH.Prune:this.meshPeerChurnEventsPrune.inc({topic:n},r);break;case VH.Excess:this.meshPeerChurnEventsExcess.inc({topic:n},r);break;default:this.meshPeerChurnEventsUnknown.inc({topic:n},r)}},onReportValidation(e,t,r){if(this.asyncValidationMcacheHit.inc({hit:null!=e?"hit":"miss"}),null!=e){const r=this.toTopic(e.message.topic);switch(t){case ez.Accept:this.acceptedMessagesTotal.inc({topic:r});break;case ez.Ignore:this.ignoredMessagesTotal.inc({topic:r});break;case ez.Reject:this.rejectedMessagesTotal.inc({topic:r});break;default:this.unknownValidationResultsTotal.inc({topic:r})}}null!=r?this.asyncValidationDelayFromFirstSeenSec.observe((Date.now()-r)/1e3):this.asyncValidationUnknownFirstSeen.inc()},onScorePenalty(e){this.scoringPenalties.inc({penalty:e},1)},onIhaveRcv(e,t,r){const n=this.toTopic(e);this.ihaveRcvMsgids.inc({topic:n},t),this.ihaveRcvNotSeenMsgids.inc({topic:n},r)},onIwantRcv(e,t){for(const[r,n]of e){const e=this.toTopic(r);this.iwantRcvMsgids.inc({topic:e},n)}this.iwantRcvDonthaveMsgids.inc(t)},onForwardMsg(e,t){const r=this.toTopic(e);this.msgForwardCount.inc({topic:r},1),this.msgForwardPeers.inc({topic:r},t)},onPublishMsg(e,t,r,n,i){const s=this.toTopic(e);this.msgPublishCount.inc({topic:s},1),this.msgPublishBytes.inc({topic:s},r*n),this.msgPublishPeersByTopic.inc({topic:s},r),this.directPeersPublishedTotal.inc({topic:s},t.direct),this.floodsubPeersPublishedTotal.inc({topic:s},t.floodsub),this.meshPeersPublishedTotal.inc({topic:s},t.mesh),this.fanoutPeersPublishedTotal.inc({topic:s},t.fanout),this.msgPublishTime.observe({topic:s},i/1e3)},onMsgRecvPreValidation(e){const t=this.toTopic(e);this.msgReceivedPreValidation.inc({topic:t},1)},onMsgRecvError(e){const t=this.toTopic(e);this.msgReceivedError.inc({topic:t},1)},onPrevalidationResult(e,t){const r=this.toTopic(e);switch(t){case qH.duplicate:this.prevalidationDuplicateTotal.inc({topic:r});break;case qH.invalid:this.prevalidationInvalidTotal.inc({topic:r});break;case qH.valid:this.prevalidationValidTotal.inc({topic:r});break;default:this.prevalidationUnknownTotal.inc({topic:r})}},onMsgRecvInvalid(e,t){const r=this.toTopic(e),n=t.reason===MH.Error?t.error:t.reason;this.msgReceivedInvalid.inc({error:n},1),this.msgReceivedInvalidByTopic.inc({topic:r},1)},onDuplicateMsgDelivery(e,t,r){const n=this.toTopic(e);this.duplicateMsgDeliveryDelay.observe({topic:n},t/1e3),r&&this.duplicateMsgLateDelivery.inc({topic:n},1)},onPublishDuplicateMsg(e){const t=this.toTopic(e);this.duplicateMsgIgnored.inc({topic:t},1)},onPeerReadStreamError(){this.peerReadStreamError.inc(1)},onRpcRecvError(){this.rpcRecvError.inc(1)},onRpcDataError(){this.rpcDataError.inc(1)},onRpcRecv(e,t){this.rpcRecvBytes.inc(t),this.rpcRecvCount.inc(1),null!=e.subscriptions&&this.rpcRecvSubscription.inc(e.subscriptions.length),null!=e.messages&&this.rpcRecvMessage.inc(e.messages.length),null!=e.control&&(this.rpcRecvControl.inc(1),null!=e.control.ihave&&this.rpcRecvIHave.inc(e.control.ihave.length),null!=e.control.iwant&&this.rpcRecvIWant.inc(e.control.iwant.length),null!=e.control.graft&&this.rpcRecvGraft.inc(e.control.graft.length),null!=e.control.prune&&this.rpcRecvPrune.inc(e.control.prune.length))},onRpcSent(e,t){if(this.rpcSentBytes.inc(t),this.rpcSentCount.inc(1),null!=e.subscriptions&&this.rpcSentSubscription.inc(e.subscriptions.length),null!=e.messages&&this.rpcSentMessage.inc(e.messages.length),null!=e.control){const t=e.control.ihave?.length??0,r=e.control.iwant?.length??0,n=e.control.graft?.length??0,i=e.control.prune?.length??0;t>0&&this.rpcSentIHave.inc(t),r>0&&this.rpcSentIWant.inc(r),n>0&&this.rpcSentGraft.inc(n),i>0&&this.rpcSentPrune.inc(i),(t>0||r>0||n>0||i>0)&&this.rpcSentControl.inc(1)}},registerScores(e,t){let r=0,n=0,i=0,s=0;for(const o of e)o>=t.graylistThreshold&&r++,o>=t.publishThreshold&&n++,o>=t.gossipThreshold&&i++,o>=0&&s++;this.peersByScoreThreshold.set({threshold:HH.graylist},r),this.peersByScoreThreshold.set({threshold:HH.publish},n),this.peersByScoreThreshold.set({threshold:HH.gossip},i),this.peersByScoreThreshold.set({threshold:HH.mesh},s),this.score.set(e)},registerScoreWeights(e){for(const[t,r]of e.byTopic)this.scoreWeights.set({topic:t,p:"p1"},r.p1w),this.scoreWeights.set({topic:t,p:"p2"},r.p2w),this.scoreWeights.set({topic:t,p:"p3"},r.p3w),this.scoreWeights.set({topic:t,p:"p3b"},r.p3bw),this.scoreWeights.set({topic:t,p:"p4"},r.p4w);this.scoreWeights.set({p:"p5"},e.p5w),this.scoreWeights.set({p:"p6"},e.p6w),this.scoreWeights.set({p:"p7"},e.p7w)},registerScorePerMesh(e,t){const r=new Map;e.forEach(((e,t)=>{const n=this.topicStrToLabel.get(t)??"unknown";let i=r.get(n);null==i&&(i=new Set,r.set(n,i)),e.forEach((e=>i?.add(e)))}));for(const[n,i]of r){const e=[];i.forEach((r=>{e.push(t.get(r)??0)})),this.scorePerMesh.set({topic:n},e)}}}}(t.metricsRegister,t.metricsTopicStrToLabel,{gossipPromiseExpireSec:this.opts.gossipsubIWantFollowupMs/1e3,behaviourPenaltyThreshold:r.scoreParams.behaviourPenaltyThreshold,maxMeshMessageDeliveriesWindowSec:e/1e3});n.mcacheSize.addCollect((()=>{this.onScrapeMetrics(n)}));for(const t of this.multicodecs)n.protocolsEnabled.set({protocol:t},1);this.metrics=n}else this.metrics=null;this.gossipTracer=new pj(this.opts.gossipsubIWantFollowupMs,this.msgIdToStrFn,this.metrics),this.score=new lj(this.opts.scoreParams,this.metrics,this.components.logger,{scoreCacheValidityMs:r.heartbeatInterval}),this.maxInboundStreams=t.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams,this.runOnTransientConnection=t.runOnTransientConnection,this.allowedTopics=null!=r.allowedTopics?new Set(r.allowedTopics):null}getPeers(){return[...this.peers.keys()].map((e=>$$(e)))}isStarted(){return this.status.code===rY.started}async start(){if(this.isStarted())return;this.log("starting"),this.publishConfig=await async function(e,t){switch(e){case XV:{if(null==t)throw Error("Must provide PeerId");if(null==t.privateKey)throw Error("Cannot sign message, no private key present");if(null==t.publicKey)throw Error("Cannot sign message, no public key present");const e=await cG(t.privateKey);return{type:LH.Signing,author:t,key:t.publicKey,privateKey:e}}case ZV:return{type:LH.Anonymous};default:throw new Error(`Unknown signature policy "${e}"`)}}(this.globalSignaturePolicy,this.components.peerId),this.outboundInflightQueue=hh({objectMode:!0}),ph(this.outboundInflightQueue,(async e=>{for await(const{peerId:t,connection:r}of e)await this.createOutboundStream(t,r)})).catch((e=>{this.log.error("outbound inflight queue error",e)})),await Promise.all(this.opts.directPeers.map((async e=>{await this.components.peerStore.merge(e.id,{multiaddrs:e.addrs})})));const e=this.components.registrar;await Promise.all(this.multicodecs.map((async t=>e.handle(t,this.onIncomingStream.bind(this),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}))));const t={onConnect:this.onPeerConnected.bind(this),onDisconnect:this.onPeerDisconnected.bind(this),notifyOnTransient:this.runOnTransientConnection},r=await Promise.all(this.multicodecs.map((async r=>e.register(r,t)))),n=setTimeout(this.runHeartbeat,100);this.status={code:rY.started,registrarTopologyIds:r,heartbeatTimeout:n,hearbeatStartMs:Date.now()+100},this.score.start(),this.directPeerInitial=setTimeout((()=>{Promise.resolve().then((async()=>{await Promise.all(Array.from(this.direct).map((async e=>this.connect(e))))})).catch((e=>{this.log(e)}))}),1e3),this.log("started")}async stop(){if(this.log("stopping"),this.status.code!==rY.started)return;const{registrarTopologyIds:e}=this.status;this.status={code:rY.stopped};const t=this.components.registrar;await Promise.all(this.multicodecs.map((async e=>t.unhandle(e)))),e.forEach((e=>{t.unregister(e)})),this.outboundInflightQueue.end();const r=[];for(const n of this.streamsOutbound.values())r.push(n.close());this.streamsOutbound.clear();for(const n of this.streamsInbound.values())r.push(n.close());this.streamsInbound.clear(),await Promise.all(r),this.peers.clear(),this.subscriptions.clear(),null!=this.heartbeatTimer&&(this.heartbeatTimer.cancel(),this.heartbeatTimer=null),this.score.stop(),this.mesh.clear(),this.fanout.clear(),this.fanoutLastpub.clear(),this.gossip.clear(),this.control.clear(),this.peerhave.clear(),this.iasked.clear(),this.backoff.clear(),this.outbound.clear(),this.gossipTracer.clear(),this.seenCache.clear(),null!=this.fastMsgIdCache&&this.fastMsgIdCache.clear(),null!=this.directPeerInitial&&clearTimeout(this.directPeerInitial),this.log("stopped")}dumpPeerScoreStats(){return this.score.dumpPeerScoreStats()}onIncomingStream(e){let{stream:t,connection:r}=e;if(!this.isStarted())return;const n=r.remotePeer;this.addPeer(n,r.direction,r.remoteAddr),this.createInboundStream(n,t),this.outboundInflightQueue.push({peerId:n,connection:r})}onPeerConnected(e,t){this.metrics?.newConnectionCount.inc({status:t.status}),this.isStarted()&&"open"===t.status&&(this.addPeer(e,t.direction,t.remoteAddr),this.outboundInflightQueue.push({peerId:e,connection:t}))}onPeerDisconnected(e){this.log("connection ended %p",e),this.removePeer(e)}async createOutboundStream(e,t){if(!this.isStarted())return;const r=e.toString();if(this.peers.has(r)&&!this.streamsOutbound.has(r))try{const n=new dj(await t.newStream(this.multicodecs,{runOnTransientConnection:this.runOnTransientConnection}),(e=>{this.log.error("outbound pipe error",e)}),{maxBufferSize:this.opts.maxOutboundBufferSize});this.log("create outbound stream %p",e),this.streamsOutbound.set(r,n);const i=n.protocol;i===j$&&this.floodsubPeers.add(r),this.metrics?.peersPerProtocol.inc({protocol:i},1),this.subscriptions.size>0&&(this.log("send subscriptions to",r),this.sendSubscriptions(r,Array.from(this.subscriptions),!0))}catch(n){this.log.error("createOutboundStream error",n)}}createInboundStream(e,t){if(!this.isStarted())return;const r=e.toString();if(!this.peers.has(r))return;const n=this.streamsInbound.get(r);void 0!==n&&(this.log("replacing existing inbound steam %s",r),n.close().catch((e=>{this.log.error(e)}))),this.log("create inbound stream %s",r);const i=new fj(t,{maxDataLength:this.opts.maxInboundDataLength});this.streamsInbound.set(r,i),this.pipePeerReadStream(e,i.source).catch((e=>{this.log(e)}))}addPeer(e,t,r){const n=e.toString();if(!this.peers.has(n)){this.log("new peer %p",e),this.peers.add(n),this.score.addPeer(n);const i=function(e){for(const t of e.tuples())switch(t[0]){case eY.ip4:case eY.ip6:return YW(t[0],t[1])}return null}(r);null!==i?this.score.addIP(n,i):this.log("Added peer has no IP in current address %s %s",n,r.toString()),this.outbound.has(n)||this.outbound.set(n,"outbound"===t)}}removePeer(e){const t=e.toString();if(!this.peers.has(t))return;this.log("delete peer %p",e),this.peers.delete(t);const r=this.streamsOutbound.get(t),n=this.streamsInbound.get(t);null!=r&&this.metrics?.peersPerProtocol.inc({protocol:r.protocol},-1),r?.close().catch((e=>{this.log.error(e)})),n?.close().catch((e=>{this.log.error(e)})),this.streamsOutbound.delete(t),this.streamsInbound.delete(t);for(const i of this.topics.values())i.delete(t);for(const[i,s]of this.mesh)s.delete(t)&&this.metrics?.onRemoveFromMesh(i,VH.Dc,1);for(const i of this.fanout.values())i.delete(t);this.floodsubPeers.delete(t),this.gossip.delete(t),this.control.delete(t),this.outbound.delete(t),this.score.removePeer(t),this.acceptFromWhitelist.delete(t)}get started(){return this.status.code===rY.started}getMeshPeers(e){const t=this.mesh.get(e);return null!=t?Array.from(t):[]}getSubscribers(e){const t=this.topics.get(e);return(null!=t?Array.from(t):[]).map((e=>$$(e)))}getTopics(){return Array.from(this.subscriptions)}async pipePeerReadStream(e,t){try{await ph(t,(async t=>{for await(const i of t)try{const t=i.subarray(),n=BH.decode(t,{limits:{subscriptions:this.decodeRpcLimits.maxSubscriptions,messages:this.decodeRpcLimits.maxMessages,control$:{ihave:this.decodeRpcLimits.maxIhaveMessageIDs,iwant:this.decodeRpcLimits.maxIwantMessageIDs,graft:this.decodeRpcLimits.maxControlMessages,prune:this.decodeRpcLimits.maxControlMessages,prune$:{peers:this.decodeRpcLimits.maxPeerInfos}}}});if(this.metrics?.onRpcRecv(n,t.length),this.opts.awaitRpcHandler)try{await this.handleReceivedRpc(e,n)}catch(r){this.metrics?.onRpcRecvError(),this.log(r)}else this.handleReceivedRpc(e,n).catch((e=>{this.metrics?.onRpcRecvError(),this.log(e)}))}catch(n){this.metrics?.onRpcDataError(),this.log(n)}}))}catch(r){this.metrics?.onPeerReadStreamError(),this.handlePeerReadStreamError(r,e)}}handlePeerReadStreamError(e,t){this.log.error(e),this.onPeerDisconnected(t)}async handleReceivedRpc(e,t){if(!this.acceptFrom(e.toString()))return this.log("received message from unacceptable peer %p",e),void this.metrics?.rpcRecvNotAccepted.inc();const r=null!=t.subscriptions?t.subscriptions.length:0,n=null!=t.messages?t.messages.length:0;let i=0,s=0,o=0,a=0;if(null!=t.control&&(null!=t.control.ihave&&(i=t.control.ihave.length),null!=t.control.iwant&&(s=t.control.iwant.length),null!=t.control.graft&&(o=t.control.graft.length),null!=t.control.prune&&(a=t.control.prune.length)),this.log(`rpc.from ${e.toString()} subscriptions ${r} messages ${n} ihave ${i} iwant ${s} graft ${o} prune ${a}`),null!=t.subscriptions&&t.subscriptions.length>0){const r=[];t.subscriptions.forEach((t=>{const n=t.topic,i=!0===t.subscribe;if(null!=n){if(null!=this.allowedTopics&&!this.allowedTopics.has(n))return;this.handleReceivedSubscription(e,n,i),r.push({topic:n,subscribe:i})}})),this.safeDispatchEvent("subscription-change",{detail:{peerId:e,subscriptions:r}})}for(const c of t.messages){if(null!=this.allowedTopics&&!this.allowedTopics.has(c.topic))continue;const t=this.handleReceivedMessage(e,c).catch((e=>{this.metrics?.onMsgRecvError(c.topic),this.log(e)}));this.opts.awaitRpcMessageHandler&&await t}null!=t.control&&await this.handleControlMessage(e.toString(),t.control)}handleReceivedSubscription(e,t,r){this.log("subscription update from %p topic %s",e,t);let n=this.topics.get(t);null==n&&(n=new Set,this.topics.set(t,n)),r?n.add(e.toString()):n.delete(e.toString())}async handleReceivedMessage(e,t){this.metrics?.onMsgRecvPreValidation(t.topic);const r=await this.validateReceivedMessage(e,t);this.metrics?.onPrevalidationResult(t.topic,r.code);const n=r.code;switch(n){case qH.duplicate:return this.score.duplicateMessage(e.toString(),r.msgIdStr,t.topic),this.gossipTracer.deliverMessage(r.msgIdStr,!0),void this.mcache.observeDuplicate(r.msgIdStr,e.toString());case qH.invalid:if(null!=r.msgIdStr){const n=r.msgIdStr;this.score.rejectMessage(e.toString(),n,t.topic,r.reason),this.gossipTracer.rejectMessage(n,r.reason)}else this.score.rejectInvalidMessage(e.toString(),t.topic);return void this.metrics?.onMsgRecvInvalid(t.topic,r);case qH.valid:if(this.score.validateMessage(r.messageId.msgIdStr),this.gossipTracer.deliverMessage(r.messageId.msgIdStr),this.mcache.put(r.messageId,t,!this.opts.asyncValidation),this.subscriptions.has(t.topic)){this.components.peerId.equals(e)&&!this.opts.emitSelf||(super.dispatchEvent(new ad("gossipsub:message",{detail:{propagationSource:e,msgId:r.messageId.msgIdStr,msg:r.msg}})),super.dispatchEvent(new ad("message",{detail:r.msg})))}this.opts.asyncValidation||this.forwardMessage(r.messageId.msgIdStr,t,e.toString());break;default:throw new Error(`Invalid validation result: ${n}`)}}async validateReceivedMessage(e,t){const r=this.fastMsgIdFn?.(t),n=void 0!==r?this.fastMsgIdCache?.get(r):void 0;if(null!=n)return{code:qH.duplicate,msgIdStr:n};const i=await async function(e,t){switch(e){case ZV:return null!=t.signature?{valid:!1,error:OH.SignaturePresent}:null!=t.seqno?{valid:!1,error:OH.SeqnoPresent}:null!=t.key?{valid:!1,error:OH.FromPresent}:{valid:!0,message:{type:"unsigned",topic:t.topic,data:t.data??new Uint8Array(0)}};case XV:{if(null==t.seqno)return{valid:!1,error:OH.InvalidSeqno};if(8!==t.seqno.length)return{valid:!1,error:OH.InvalidSeqno};if(null==t.signature)return{valid:!1,error:OH.InvalidSignature};if(null==t.from)return{valid:!1,error:OH.InvalidPeerId};let e,s;try{e=H$(t.from)}catch(i){return{valid:!1,error:OH.InvalidPeerId}}if(null!=t.key){if(s=aG(t.key),void 0!==e.publicKey&&!B$(s.bytes,e.publicKey))return{valid:!1,error:OH.InvalidPeerId}}else{if(null==e.publicKey)return{valid:!1,error:OH.InvalidPeerId};s=aG(e.publicKey)}const o={from:t.from,data:t.data,seqno:t.seqno,topic:t.topic,signature:void 0,key:void 0},a=_j([uG,BH.Message.encode(o)]);return await s.verify(a,t.signature)?{valid:!0,message:{type:"signed",from:e,data:t.data??new Uint8Array(0),sequenceNumber:BigInt(`0x${Lj(t.seqno,"base16")}`),topic:t.topic,signature:t.signature,key:t.key??(r=s,oG(n=(n??"rsa").toLowerCase()),r.bytes)}}:{valid:!1,error:OH.InvalidSignature}}default:throw new Error("Unreachable")}var r,n}(this.globalSignaturePolicy,t);if(!i.valid)return{code:qH.invalid,reason:MH.Error,error:i.error};const s=i.message;try{null!=this.dataTransform&&(s.data=this.dataTransform.inboundTransform(t.topic,s.data))}catch(l){return this.log("Invalid message, transform failed",l),{code:qH.invalid,reason:MH.Error,error:OH.TransformFailed}}const o=await this.msgIdFn(s),a=this.msgIdToStrFn(o),c={msgId:o,msgIdStr:a};if(void 0!==r&&null!=this.fastMsgIdCache){this.fastMsgIdCache.put(r,a)&&this.metrics?.fastMsgIdCacheCollision.inc()}if(this.seenCache.has(a))return{code:qH.duplicate,msgIdStr:a};this.seenCache.put(a);const u=this.topicValidators.get(t.topic);if(null!=u){let t;try{t=await u(e,s)}catch(l){const e=l.code;"ERR_TOPIC_VALIDATOR_IGNORE"===e&&(t=ez.Ignore),t="ERR_TOPIC_VALIDATOR_REJECT"===e?ez.Reject:ez.Ignore}if(t!==ez.Accept)return{code:qH.invalid,reason:QH(t),msgIdStr:a}}return{code:qH.valid,messageId:c,msg:s}}getScore(e){return this.score.score(e)}sendSubscriptions(e,t,r){this.sendRpc(e,{subscriptions:t.map((e=>({topic:e,subscribe:r}))),messages:[]})}async handleControlMessage(e,t){if(void 0===t)return;const r=null!=t.ihave?this.handleIHave(e,t.ihave):[],n=null!=t.iwant?this.handleIWant(e,t.iwant):[],i=null!=t.graft?await this.handleGraft(e,t.graft):[];if(null!=t.prune&&await this.handlePrune(e,t.prune),0===r.length&&0===n.length&&0===i.length)return;const s=this.sendRpc(e,lG(n,{iwant:r,prune:i})),o=r[0]?.messageIDs;null!=o&&(s?this.gossipTracer.addPromise(e,o):this.metrics?.iwantPromiseUntracked.inc(1))}acceptFrom(e){if(this.direct.has(e))return!0;const t=Date.now(),r=this.acceptFromWhitelist.get(e);if(null!=r&&r.messagesAccepted<128&&r.acceptUntil>=t)return r.messagesAccepted+=1,!0;const n=this.score.score(e);return n>=0?this.acceptFromWhitelist.set(e,{messagesAccepted:0,acceptUntil:t+1e3}):this.acceptFromWhitelist.delete(e),n>=this.opts.scoreThresholds.graylistThreshold}handleIHave(e,t){if(0===t.length)return[];const r=this.score.score(e);if(r<this.opts.scoreThresholds.gossipThreshold)return this.log("IHAVE: ignoring peer %s with score below threshold [ score = %d ]",e,r),this.metrics?.ihaveRcvIgnored.inc({reason:$H.LowScore}),[];const n=(this.peerhave.get(e)??0)+1;if(this.peerhave.set(e,n),n>10)return this.log("IHAVE: peer %s has advertised too many times (%d) within this heartbeat interval; ignoring",e,n),this.metrics?.ihaveRcvIgnored.inc({reason:$H.MaxIhave}),[];const i=this.iasked.get(e)??0;if(i>=Y$)return this.log("IHAVE: peer %s has already advertised too many messages (%d); ignoring",e,i),this.metrics?.ihaveRcvIgnored.inc({reason:$H.MaxIasked}),[];const s=new Map;if(t.forEach((e=>{let{topicID:t,messageIDs:r}=e;if(null==t||null==r||!this.mesh.has(t))return;let n=0;r.forEach((e=>{const t=this.msgIdToStrFn(e);this.seenCache.has(t)||(s.set(t,e),n++)})),this.metrics?.onIhaveRcv(t,r.length,n)})),0===s.size)return[];let o=s.size;o+i>Y$&&(o=Y$-i),this.log("IHAVE: Asking for %d out of %d messages from %s",o,s.size,e);let a=Array.from(s.values());return fG(a),a=a.slice(0,o),this.iasked.set(e,i+o),[{messageIDs:a}]}handleIWant(e,t){if(0===t.length)return[];const r=this.score.score(e);if(r<this.opts.scoreThresholds.gossipThreshold)return this.log("IWANT: ignoring peer %s with score below threshold [score = %d]",e,r),[];const n=new Map,i=new Map;let s=0;return t.forEach((t=>{let{messageIDs:r}=t;r?.forEach((t=>{const r=this.msgIdToStrFn(t),o=this.mcache.getWithIWantCount(r,e);null!=o?(i.set(o.msg.topic,1+(i.get(o.msg.topic)??0)),o.count>3?this.log("IWANT: Peer %s has asked for message %s too many times: ignoring request",e,t):n.set(r,o.msg)):s++}))})),this.metrics?.onIwantRcv(i,s),0===n.size?(this.log("IWANT: Could not provide any wanted messages to %s",e),[]):(this.log("IWANT: Sending %d messages to %s",n.size,e),Array.from(n.values()))}async handleGraft(e,t){const r=[],n=this.score.score(e),i=Date.now();let s=this.opts.doPX;if(t.forEach((t=>{let{topicID:o}=t;if(null==o)return;const a=this.mesh.get(o);if(null==a)return void(s=!1);if(a.has(e))return;if(this.direct.has(e))return this.log("GRAFT: ignoring request from direct peer %s",e),r.push(o),void(s=!1);const c=this.backoff.get(o)?.get(e);if("number"===typeof c&&i<c){this.log("GRAFT: ignoring backed off peer %s",e),this.score.addPenalty(e,1,zH.GraftBackoff),s=!1;const t=c+this.opts.graftFloodThreshold-this.opts.pruneBackoff;return i<t&&this.score.addPenalty(e,1,zH.GraftBackoff),this.addBackoff(e,o),void r.push(o)}return n<0?(this.log("GRAFT: ignoring peer %s with negative score: score=%d, topic=%s",e,n,o),r.push(o),s=!1,void this.addBackoff(e,o)):a.size>=this.opts.Dhi&&!this.outbound.get(e)?(r.push(o),void this.addBackoff(e,o)):(this.log("GRAFT: Add mesh link from %s in %s",e,o),this.score.graft(e,o),a.add(e),void this.metrics?.onAddToMesh(o,FH.Subscribed,1))})),0===r.length)return[];return Promise.all(r.map((async t=>this.makePrune(e,t,s,false))))}async handlePrune(e,t){const r=this.score.score(e);for(const{topicID:n,backoff:i,peers:s}of t){if(null==n)continue;const t=this.mesh.get(n);if(null==t)return;if(this.log("PRUNE: Remove mesh link to %s in %s",e,n),this.score.prune(e,n),t.has(e)&&(t.delete(e),this.metrics?.onRemoveFromMesh(n,VH.Prune,1)),"number"===typeof i&&i>0?this.doAddBackoff(e,n,1e3*i):this.addBackoff(e,n),null!=s&&s.length>0){if(r<this.opts.scoreThresholds.acceptPXThreshold){this.log("PRUNE: ignoring PX from peer %s with insufficient score [score = %d, topic = %s]",e,r,n);continue}await this.pxConnect(s)}}}addBackoff(e,t){this.doAddBackoff(e,t,this.opts.pruneBackoff)}doAddBackoff(e,t,r){let n=this.backoff.get(t);null==n&&(n=new Map,this.backoff.set(t,n));const i=Date.now()+r;(n.get(e)??0)<i&&n.set(e,i)}applyIwantPenalties(){this.gossipTracer.getBrokenPromises().forEach(((e,t)=>{this.log("peer %s didn't follow up in %d IWANT requests; adding penalty",t,e),this.score.addPenalty(t,e,zH.BrokenPromise)}))}clearBackoff(){if(this.heartbeatTicks%15!==0)return;const e=Date.now();this.backoff.forEach(((t,r)=>{t.forEach(((r,n)=>{r+1*this.opts.heartbeatInterval<e&&t.delete(n)})),0===t.size&&this.backoff.delete(r)}))}async directConnect(){const e=[];this.direct.forEach((t=>{this.streamsOutbound.has(t)||e.push(t)})),await Promise.all(e.map((async e=>this.connect(e))))}async pxConnect(e){e.length>this.opts.prunePeers&&(fG(e),e=e.slice(0,this.opts.prunePeers));const t=[];await Promise.all(e.map((async e=>{if(null==e.peerID)return;const r=H$(e.peerID),n=r.toString();if(!this.peers.has(n))if(null!=e.signedPeerRecord)try{if(!await this.components.peerStore.consumePeerRecord(e.signedPeerRecord,r))return void this.log("bogus peer record obtained through px: could not add peer record to address book");t.push(n)}catch(i){this.log("bogus peer record obtained through px: invalid signature or not a peer record")}else t.push(n)}))),0!==t.length&&await Promise.all(t.map((async e=>this.connect(e))))}async connect(e){this.log("Initiating connection with %s",e);const t=$$(e),r=await this.components.connectionManager.openConnection(t);for(const n of this.multicodecs)for(const e of this.components.registrar.getTopologies(n))e.onConnect?.(t,r)}subscribe(e){if(this.status.code!==rY.started)throw new Error("Pubsub has not started");if(!this.subscriptions.has(e)){this.subscriptions.add(e);for(const t of this.peers.keys())this.sendSubscriptions(t,[e],!0)}this.join(e)}unsubscribe(e){if(this.status.code!==rY.started)throw new Error("Pubsub is not started");const t=this.subscriptions.delete(e);if(this.log("unsubscribe from %s - am subscribed %s",e,t),t)for(const r of this.peers.keys())this.sendSubscriptions(r,[e],!1);this.leave(e)}join(e){if(this.status.code!==rY.started)throw new Error("Gossipsub has not started");if(this.mesh.has(e))return;this.log("JOIN %s",e),this.metrics?.onJoin(e);const t=new Set,r=this.backoff.get(e),n=this.fanout.get(e);if(null!=n&&(this.fanout.delete(e),this.fanoutLastpub.delete(e),n.forEach((e=>{this.direct.has(e)||!(this.score.score(e)>=0)||null!=r&&r.has(e)||t.add(e)})),this.metrics?.onAddToMesh(e,FH.Fanout,t.size)),t.size<this.opts.D){const n=t.size;this.getRandomGossipPeers(e,this.opts.D,(e=>!t.has(e)&&!this.direct.has(e)&&this.score.score(e)>=0&&(null==r||!r.has(e)))).forEach((e=>{t.add(e)})),this.metrics?.onAddToMesh(e,FH.Random,t.size-n)}this.mesh.set(e,t),t.forEach((t=>{this.log("JOIN: Add mesh link to %s in %s",t,e),this.sendGraft(t,e)}))}leave(e){if(this.status.code!==rY.started)throw new Error("Gossipsub has not started");this.log("LEAVE %s",e),this.metrics?.onLeave(e);const t=this.mesh.get(e);null!=t&&(Promise.all(Array.from(t).map((async t=>{this.log("LEAVE: Remove mesh link to %s in %s",t,e),await this.sendPrune(t,e)}))).catch((e=>{this.log("Error sending prunes to mesh peers",e)})),this.mesh.delete(e))}selectPeersToForward(e,t,r){const n=new Set,i=this.topics.get(e);null!=i&&(this.direct.forEach((e=>{i.has(e)&&t!==e&&!r?.has(e)&&n.add(e)})),this.floodsubPeers.forEach((e=>{i.has(e)&&t!==e&&!r?.has(e)&&this.score.score(e)>=this.opts.scoreThresholds.publishThreshold&&n.add(e)})));const s=this.mesh.get(e);return null!=s&&s.size>0&&s.forEach((e=>{t===e||r?.has(e)||n.add(e)})),n}selectPeersToPublish(e){const t=new Set,r={direct:0,floodsub:0,mesh:0,fanout:0},n=this.topics.get(e);if(null!=n)if(this.opts.floodPublish)n.forEach((e=>{this.direct.has(e)?(t.add(e),r.direct++):this.score.score(e)>=this.opts.scoreThresholds.publishThreshold&&(t.add(e),r.floodsub++)}));else{this.direct.forEach((e=>{n.has(e)&&(t.add(e),r.direct++)})),this.floodsubPeers.forEach((e=>{n.has(e)&&this.score.score(e)>=this.opts.scoreThresholds.publishThreshold&&(t.add(e),r.floodsub++)}));const i=this.mesh.get(e);if(null!=i&&i.size>0)i.forEach((e=>{t.add(e),r.mesh++}));else{const n=this.fanout.get(e);if(null!=n&&n.size>0)n.forEach((e=>{t.add(e),r.fanout++}));else{const n=this.getRandomGossipPeers(e,this.opts.D,(e=>this.score.score(e)>=this.opts.scoreThresholds.publishThreshold));n.size>0&&(this.fanout.set(e,n),n.forEach((e=>{t.add(e),r.fanout++})))}this.fanoutLastpub.set(e,Date.now())}}return{tosend:t,tosendCount:r}}forwardMessage(e,t,r,n){null!=r&&this.score.deliverMessage(r,e,t.topic);const i=this.selectPeersToForward(t.topic,r,n);i.forEach((e=>{this.sendRpc(e,lG([t]))})),this.metrics?.onForwardMsg(t.topic,i.size)}async publish(e,t,r){const n=Date.now(),i=null!=this.dataTransform?this.dataTransform.outboundTransform(e,t):t;if(null==this.publishConfig)throw Error("PublishError.Uninitialized");const{raw:s,msg:o}=await async function(e,t,r,n){switch(e.type){case LH.Signing:{const i={from:e.author.toBytes(),data:n,seqno:gj(8),topic:t,signature:void 0,key:void 0},s=_j([uG,BH.Message.encode(i)]);return i.signature=await e.privateKey.sign(s),i.key=e.key,{raw:i,msg:{type:"signed",from:e.author,data:r,sequenceNumber:BigInt(`0x${Lj(i.seqno,"base16")}`),topic:t,signature:i.signature,key:i.key}}}case LH.Anonymous:return{raw:{from:void 0,data:n,seqno:void 0,topic:t,signature:void 0,key:void 0},msg:{type:"unsigned",data:r,topic:t}};default:throw new Error("Unreachable")}}(this.publishConfig,e,t,i),a=await this.msgIdFn(o),c=this.msgIdToStrFn(a),u=r?.ignoreDuplicatePublishError??this.opts.ignoreDuplicatePublishError;if(this.seenCache.has(c)){if(u)return this.metrics?.onPublishDuplicateMsg(e),{recipients:[]};throw Error("PublishError.Duplicate")}const{tosend:l,tosendCount:h}=this.selectPeersToPublish(e),d=this.opts.emitSelf&&this.subscriptions.has(e),f=r?.allowPublishToZeroPeers??this.opts.allowPublishToZeroPeers;if(0===l.size&&!f&&!d)throw Error("PublishError.InsufficientPeers");this.seenCache.put(c),this.mcache.put({msgId:a,msgIdStr:c},s,!0),this.publishedMessageIds.put(c);const p=r?.batchPublish??this.opts.batchPublish,g=lG([s]);if(p)this.sendRpcInBatch(l,g);else for(const y of l){this.sendRpc(y,g)||l.delete(y)}const b=Date.now()-n;return this.metrics?.onPublishMsg(e,h,l.size,null!=s.data?s.data.length:0,b),d&&(l.add(this.components.peerId.toString()),super.dispatchEvent(new ad("gossipsub:message",{detail:{propagationSource:this.components.peerId,msgId:c,msg:o}})),super.dispatchEvent(new ad("message",{detail:o}))),{recipients:Array.from(l.values()).map((e=>$$(e)))}}sendRpcInBatch(e,t){const r=BH.encode(t),n=rh.single(r);for(const s of e){const o=this.streamsOutbound.get(s);if(null!=o){try{o.pushPrefixed(n)}catch(i){e.delete(s),this.log.error(`Cannot send rpc to ${s}`,i)}this.metrics?.onRpcSent(t,r.length)}else this.log(`Cannot send RPC to ${s} as there is no open stream to it available`),e.delete(s)}}reportMessageValidationResult(e,t,r){let n;if(r===ez.Accept){if(n=this.mcache.validate(e),null!=n){const{message:r,originatingPeers:i}=n;this.score.deliverMessage(t,e,r.topic),this.forwardMessage(e,n.message,t,i)}}else if(n=this.mcache.remove(e),null!=n){const i=QH(r),{message:s,originatingPeers:o}=n;this.score.rejectMessage(t,e,s.topic,i);for(const t of o)this.score.rejectMessage(t,e,s.topic,i)}const i=this.score.messageFirstSeenTimestampMs(e);this.metrics?.onReportValidation(n,r,i)}sendGraft(e,t){const r=lG([],{graft:[{topicID:t}]});this.sendRpc(e,r)}async sendPrune(e,t){const r=lG([],{prune:[await this.makePrune(e,t,this.opts.doPX,!0)]});this.sendRpc(e,r)}sendRpc(e,t){const r=this.streamsOutbound.get(e);if(null==r)return this.log(`Cannot send RPC to ${e} as there is no open stream to it available`),!1;const n=this.control.get(e);null!=n&&(this.piggybackControl(e,t,n),this.control.delete(e));const i=this.gossip.get(e);null!=i&&(this.piggybackGossip(e,t,i),this.gossip.delete(e));const s=BH.encode(t);try{r.push(s)}catch(o){return this.log.error(`Cannot send rpc to ${e}`,o),null!=n&&this.control.set(e,n),null!=i&&this.gossip.set(e,i),!1}return this.metrics?.onRpcSent(t,s.length),!0}piggybackControl(e,t,r){const n=hG(t);for(const i of r.graft)null!=i.topicID&&this.mesh.get(i.topicID)?.has(e)&&n.control.graft.push(i);for(const i of r.prune)null==i.topicID||this.mesh.get(i.topicID)?.has(e)||n.control.prune.push(i)}piggybackGossip(e,t,r){hG(t).control.ihave=r}async sendGraftPrune(e,t,r){const n=this.opts.doPX,i=!1;for(const[s,o]of e){const e=o.map((e=>({topicID:e})));let a=[];const c=t.get(s);null!=c&&(a=await Promise.all(c.map((async e=>this.makePrune(s,e,n&&!r.get(s),i)))),t.delete(s)),this.sendRpc(s,lG([],{graft:e,prune:a}))}for(const[s,o]of t){const e=await Promise.all(o.map((async e=>this.makePrune(s,e,n&&!r.get(s),i))));this.sendRpc(s,lG([],{prune:e}))}}emitGossip(e){const t=this.mcache.getGossipIDs(new Set(e.keys()));for(const[r,n]of e)this.doEmitGossip(r,n,t.get(r)??[])}doEmitGossip(e,t,r){if(0===r.length)return;if(fG(r),r.length>Y$&&this.log("too many messages for gossip; will truncate IHAVE list (%d messages)",r.length),0===t.size)return;let n=this.opts.Dlazy;const i=.25*t.size;let s=t;i>n&&(n=i),n>s.size?n=s.size:s=fG(Array.from(s)).slice(0,n),s.forEach((t=>{let n=r;r.length>Y$&&(n=fG(n.slice()).slice(0,Y$)),this.pushGossip(t,{topicID:e,messageIDs:n})}))}flush(){for(const[e,t]of this.gossip.entries())this.gossip.delete(e),this.sendRpc(e,lG([],{ihave:t}));for(const[e,t]of this.control.entries()){this.control.delete(e);const r=lG([],{graft:t.graft,prune:t.prune});this.sendRpc(e,r)}}pushGossip(e,t){this.log("Add gossip to %s",e);const r=this.gossip.get(e)??[];this.gossip.set(e,r.concat(t))}async makePrune(e,t,r,n){if(this.score.prune(e,t),this.streamsOutbound.get(e)?.protocol===G$)return{topicID:t,peers:[]};const i=n?this.opts.unsubcribeBackoff:this.opts.pruneBackoff,s=i/1e3;if(this.doAddBackoff(e,t,i),!r)return{topicID:t,peers:[],backoff:s};const o=this.getRandomGossipPeers(t,this.opts.prunePeers,(t=>t!==e&&this.score.score(t)>=0)),a=await Promise.all(Array.from(o).map((async e=>{const t=$$(e);let r;try{r=await this.components.peerStore.get(t)}catch(n){if("ERR_NOT_FOUND"!==n.code)throw n}return{peerID:t.toBytes(),signedPeerRecord:r?.peerRecordEnvelope}})));return{topicID:t,peers:a,backoff:s}}runHeartbeat=()=>{const e=this.metrics?.heartbeatDuration.startTimer();this.heartbeat().catch((e=>{this.log("Error running heartbeat",e)})).finally((()=>{if(null!=e&&e(),this.status.code===rY.started){clearTimeout(this.status.heartbeatTimeout);let e=this.opts.heartbeatInterval-(Date.now()-this.status.hearbeatStartMs)%this.opts.heartbeatInterval;e<.25*this.opts.heartbeatInterval&&(e+=this.opts.heartbeatInterval,this.metrics?.heartbeatSkipped.inc()),this.status.heartbeatTimeout=setTimeout(this.runHeartbeat,e)}}))};async heartbeat(){const{D:e,Dlo:t,Dhi:r,Dscore:n,Dout:i,fanoutTTL:s}=this.opts;this.heartbeatTicks++;const o=new Map,a=e=>{let t=o.get(e);return void 0===t&&(t=this.score.score(e),o.set(e,t)),t},c=new Map,u=new Map,l=new Map;this.clearBackoff(),this.peerhave.clear(),this.metrics?.cacheSize.set({cache:"iasked"},this.iasked.size),this.iasked.clear(),this.applyIwantPenalties(),this.heartbeatTicks%this.opts.directConnectTicks===0&&await this.directConnect(),this.fastMsgIdCache?.prune(),this.seenCache.prune(),this.gossipTracer.prune(),this.publishedMessageIds.prune();const h=new Map;this.mesh.forEach(((s,o)=>{const d=this.topics.get(o),f=new Set,p=new Set;if(h.set(o,p),null!=d){const e=fG(Array.from(d)),t=this.backoff.get(o);for(const r of e){const e=this.streamsOutbound.get(r);if(null!=e&&this.multicodecs.includes(e.protocol)&&!s.has(r)&&!this.direct.has(r)){const e=a(r);(null==t||!t.has(r))&&e>=0&&f.add(r),e>=this.opts.scoreThresholds.gossipThreshold&&p.add(r)}}}const g=(e,t)=>{this.log("HEARTBEAT: Remove mesh link to %s in %s",e,o),this.addBackoff(e,o),s.delete(e),a(e)>=this.opts.scoreThresholds.gossipThreshold&&p.add(e),this.metrics?.onRemoveFromMesh(o,t,1);const r=u.get(e);null==r?u.set(e,[o]):r.push(o)},b=(e,t)=>{this.log("HEARTBEAT: Add mesh link to %s in %s",e,o),this.score.graft(e,o),s.add(e),p.delete(e),this.metrics?.onAddToMesh(o,t,1);const r=c.get(e);null==r?c.set(e,[o]):r.push(o)};if(s.forEach((e=>{const t=a(e);t<0&&(this.log("HEARTBEAT: Prune peer %s with negative score: score=%d, topic=%s",e,t,o),g(e,VH.BadScore),l.set(e,!0))})),s.size<t){const t=function(e,t){return ij(e,t,(()=>!0))}(f,e-s.size);t.forEach((e=>{b(e,FH.NotEnough)}))}if(s.size>r){let t=Array.from(s);t.sort(((e,t)=>a(t)-a(e))),t=t.slice(0,n).concat(fG(t.slice(n)));let r=0;if(t.slice(0,e).forEach((e=>{this.outbound.get(e)&&r++})),r<i){const n=e=>{const r=t[e];for(let n=e;n>0;n--)t[n]=t[n-1];t[0]=r};if(r>0){let i=r;for(let r=1;r<e&&i>0;r++)this.outbound.get(t[r])&&(n(r),i--)}let i=e-r;for(let r=e;r<t.length&&i>0;r++)this.outbound.get(t[r])&&(n(r),i--)}t.slice(e).forEach((e=>{g(e,VH.Excess)}))}if(s.size>=t){let e=0;if(s.forEach((t=>{this.outbound.get(t)&&e++})),e<i){ij(f,i-e,(e=>!0===this.outbound.get(e))).forEach((e=>{b(e,FH.Outbound)}))}}if(this.heartbeatTicks%this.opts.opportunisticGraftTicks===0&&s.size>1){const e=Array.from(s).sort(((e,t)=>a(e)-a(t))),t=Math.floor(s.size/2),r=a(e[t]);if(r<this.opts.scoreThresholds.opportunisticGraftThreshold){const e=ij(f,this.opts.opportunisticGraftPeers,(e=>a(e)>r));for(const t of e)this.log("HEARTBEAT: Opportunistically graft peer %s on topic %s",t,o),b(t,FH.Opportunistic)}}}));const d=Date.now();this.fanoutLastpub.forEach(((e,t)=>{e+s<d&&(this.fanout.delete(t),this.fanoutLastpub.delete(t))})),this.fanout.forEach(((t,r)=>{const n=this.topics.get(r);t.forEach((e=>{(!n?.has(e)||a(e)<this.opts.scoreThresholds.publishThreshold)&&t.delete(e)}));const i=this.topics.get(r),s=[],o=new Set;if(h.set(r,o),null!=i){const e=fG(Array.from(i));for(const r of e){const e=this.streamsOutbound.get(r);if(null!=e&&this.multicodecs.includes(e.protocol)&&!t.has(r)&&!this.direct.has(r)){const e=a(r);e>=this.opts.scoreThresholds.publishThreshold&&s.push(r),e>=this.opts.scoreThresholds.gossipThreshold&&o.add(r)}}}if(t.size<e){const r=e-t.size;s.slice(0,r).forEach((e=>{t.add(e),o?.delete(e)}))}})),this.emitGossip(h),await this.sendGraftPrune(c,u,l),this.flush(),this.mcache.shift(),this.dispatchEvent(new ad("gossipsub:heartbeat"))}getRandomGossipPeers(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:()=>!0;const n=this.topics.get(e);if(null==n)return new Set;let i=[];return n.forEach((e=>{const t=this.streamsOutbound.get(e);null!=t&&this.multicodecs.includes(t.protocol)&&r(e)&&i.push(e)})),i=fG(i),t>0&&i.length>t&&(i=i.slice(0,t)),new Set(i)}onScrapeMetrics(e){e.mcacheSize.set(this.mcache.size),e.mcacheNotValidatedCount.set(this.mcache.notValidatedCount),e.cacheSize.set({cache:"direct"},this.direct.size),e.cacheSize.set({cache:"seenCache"},this.seenCache.size),e.cacheSize.set({cache:"fastMsgIdCache"},this.fastMsgIdCache?.size??0),e.cacheSize.set({cache:"publishedMessageIds"},this.publishedMessageIds.size),e.cacheSize.set({cache:"mcache"},this.mcache.size),e.cacheSize.set({cache:"score"},this.score.size),e.cacheSize.set({cache:"gossipTracer.promises"},this.gossipTracer.size),e.cacheSize.set({cache:"gossipTracer.requests"},this.gossipTracer.requestMsByMsgSize),e.cacheSize.set({cache:"topics"},this.topics.size),e.cacheSize.set({cache:"subscriptions"},this.subscriptions.size),e.cacheSize.set({cache:"mesh"},this.mesh.size),e.cacheSize.set({cache:"fanout"},this.fanout.size),e.cacheSize.set({cache:"peers"},this.peers.size),e.cacheSize.set({cache:"streamsOutbound"},this.streamsOutbound.size),e.cacheSize.set({cache:"streamsInbound"},this.streamsInbound.size),e.cacheSize.set({cache:"acceptFromWhitelist"},this.acceptFromWhitelist.size),e.cacheSize.set({cache:"gossip"},this.gossip.size),e.cacheSize.set({cache:"control"},this.control.size),e.cacheSize.set({cache:"peerhave"},this.peerhave.size),e.cacheSize.set({cache:"outbound"},this.outbound.size);let t=0;const r=Date.now();e.connectedPeersBackoffSec.reset();for(const o of this.backoff.values()){t+=o.size;for(const[t,n]of o.entries())this.peers.has(t)&&e.connectedPeersBackoffSec.observe(Math.max(0,n-r)/1e3)}e.cacheSize.set({cache:"backoff"},t);for(const[o,a]of this.topics)e.topicPeersCount.set({topicStr:o},a.size);for(const[o,a]of this.mesh)e.meshPeerCounts.set({topicStr:o},a.size);const n=[],i=new Map;e.behaviourPenalty.reset();for(const o of this.peers.keys()){const t=this.score.score(o);n.push(t),i.set(o,t),e.behaviourPenalty.observe(this.score.peerStats.get(o)?.behaviourPenalty??0)}e.registerScores(n,this.opts.scoreThresholds),e.registerScorePerMesh(this.mesh,i);const s=function(e,t,r,n,i){const s={byTopic:new Map,p5w:[],p6w:[],p7w:[],score:[]};for(const o of e){const e=t.get(o);if(null!=e){const t=hj(o,e,r,n,i);for(const[e,r]of t.byTopic){let t=s.byTopic.get(e);null==t&&(t={p1w:[],p2w:[],p3w:[],p3bw:[],p4w:[]},s.byTopic.set(e,t)),t.p1w.push(r.p1w),t.p2w.push(r.p2w),t.p3w.push(r.p3w),t.p3bw.push(r.p3bw),t.p4w.push(r.p4w)}s.p5w.push(t.p5w),s.p6w.push(t.p6w),s.p7w.push(t.p7w),s.score.push(t.score)}else s.p5w.push(0),s.p6w.push(0),s.p7w.push(0),s.score.push(0)}return s}(this.peers.keys(),this.score.peerStats,this.score.params,this.score.peerIPs,e.topicStrToLabel);e.registerScoreWeights(s)}}const iY=["/vac/waku/relay/2.0.0"];new Ll("relay");new Ll("relay");iY[0];new Uint8Array(0);function sY(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var oY=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const aY=oY;class cY{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class uY{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return hY(this,e)}}class lY{decoders;constructor(e){this.decoders=e}or(e){return hY(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function hY(e,t){return new lY({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class dY{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new cY(e,t,r),this.decoder=new uY(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function fY(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new dY(t,r,n,i)}function pY(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=aY(n,t);return fY({prefix:r,name:t,encode:i,decode:e=>sY(s(e))})}function gY(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return fY({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const bY=pY({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),yY=pY({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var mY=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=_Y;)r[n++]=255&t|wY,t/=128;for(;t&vY;)r[n++]=255&t|wY,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},wY=128,vY=-128,_Y=Math.pow(2,31);var EY=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&AY)<<s:(n&AY)*Math.pow(2,s),s+=7}while(n>=SY);return e.bytes=o-r,i},SY=128,AY=127;var kY=Math.pow(2,7),xY=Math.pow(2,14),IY=Math.pow(2,21),CY=Math.pow(2,28),TY=Math.pow(2,35),RY=Math.pow(2,42),PY=Math.pow(2,49),DY=Math.pow(2,56),NY=Math.pow(2,63);const BY={encode:mY,decode:EY,encodingLength:function(e){return e<kY?1:e<xY?2:e<IY?3:e<CY?4:e<TY?5:e<RY?6:e<PY?7:e<DY?8:e<NY?9:10}};function UY(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[BY.decode(e,t),BY.decode.bytes]}function LY(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return BY.encode(e,t,r),t}function MY(e){return BY.encodingLength(e)}function OY(e,t){const r=t.byteLength,n=MY(e),i=n+MY(r),s=new Uint8Array(i+r);return LY(e,s,0),LY(r,s,n),s.set(t,i),new KY(e,r,t,s)}function qY(e){const t=sY(e),[r,n]=UY(t),[i,s]=UY(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new KY(r,i,o,t)}class KY{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const FY=sY;const VY={code:0,name:"identity",encode:FY,digest:function(e){return OY(0,FY(e))}};function zY(e){let{name:t,code:r,encode:n}=e;return new $Y(t,r,n)}class $Y{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?OY(this.code,t):t.then((e=>OY(this.code,e)))}throw Error("Unknown type, must be binary type")}}function HY(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const jY=zY({name:"sha2-256",code:18,encode:HY("SHA-256")}),GY=zY({name:"sha2-512",code:19,encode:HY("SHA-512")});function WY(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const YY=pY({prefix:"9",name:"base10",alphabet:"0123456789"}),QY=gY({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),JY=gY({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),XY=gY({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),ZY=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),eQ=ZY.reduce(((e,t,r)=>(e[r]=t,e)),[]),tQ=ZY.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const rQ=fY({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=eQ[t]),"")},decode:function(e){const t=[];for(const r of e){const e=tQ[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),nQ=gY({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),iQ=gY({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),sQ=gY({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),oQ=gY({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),aQ=gY({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),cQ=gY({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),uQ=gY({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),lQ=gY({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),hQ=gY({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),dQ=pY({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),fQ=pY({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),pQ=gY({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),gQ=gY({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),bQ=gY({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yQ=gY({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),mQ=gY({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),wQ=fY({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),vQ=new TextEncoder,_Q=new TextDecoder,EQ="json",SQ=512;function AQ(e){return vQ.encode(JSON.stringify(e))}function kQ(e){return JSON.parse(_Q.decode(e))}const xQ="raw",IQ=85;function CQ(e){return sY(e)}function TQ(e){return sY(e)}function RQ(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==bY.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,DQ(e),t??bY.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,DQ(e),t??nQ.encoder)}const PQ=new WeakMap;function DQ(e){const t=PQ.get(e);if(null==t){const t=new Map;return PQ.set(e,t),t}return t}class NQ{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==BQ)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==UQ)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return NQ.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:{const{code:e,digest:t}=this.multihash,r=OY(e,t);return NQ.createV1(this.code,r)}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 NQ.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return RQ(this,e)}toJSON(){return{"/":RQ(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof NQ)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new NQ(e,r,n,i??LQ(e,r,n.bytes))}if(!0===t[MQ]){const{version:e,multihash:r,code:n}=t,i=qY(r);return NQ.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==BQ)throw new Error(`Version 0 CID must use dag-pb (code: ${BQ}) block encoding`);return new NQ(e,t,r,r.bytes);case 1:{const n=LQ(e,t,r.bytes);return new NQ(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return NQ.create(0,BQ,e)}static createV1(e,t){return NQ.create(1,e,t)}static decode(e){const[t,r]=NQ.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=NQ.inspectBytes(e),r=t.size-t.multihashSize,n=sY(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new KY(t.multihashCode,t.digestSize,i,n);return[0===t.version?NQ.createV0(s):NQ.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=UY(e.subarray(t));return t+=n,r};let n=r(),i=BQ;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??bY;return[bY.prefix,r.decode(`${bY.prefix}${e}`)]}case bY.prefix:{const r=t??bY;return[bY.prefix,r.decode(e)]}case nQ.prefix:{const r=t??nQ;return[nQ.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=NQ.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return DQ(i).set(r,e),i}}const BQ=112,UQ=18;function LQ(e,t,r){const n=MY(e),i=n+MY(t),s=new Uint8Array(i+r.byteLength);return LY(e,s,0),LY(t,s,n),s.set(r,i),s}const MQ=Symbol.for("@ipld/js-cid/CID"),OQ={...Fr,...Ur,...Kr,...Nr,...Br,...Mr,...Or,...Rr,...qr,...Lr};function qQ(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function KQ(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const FQ=KQ("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),VQ=KQ("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=qQ((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),zQ={utf8:FQ,"utf-8":FQ,hex:OQ.base16,latin1:VQ,ascii:VQ,binary:VQ,...OQ};function $Q(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=zQ[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function HQ(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const jQ=32,GQ=64,WQ=32;function YQ(e,t){const r=new Uint8Array(GQ);for(let n=0;n<WQ;n++)r[n]=e[n],r[WQ+n]=t[n];return r}function QQ(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=qQ(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}const JQ={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)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}},XQ={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function ZQ(e,t){const r=function(e){const t=e?.algorithm??"AES-GCM";let r=e?.keyLength??16;const n=e?.nonceLength??12,i=e?.digest??"SHA-256",s=e?.saltLength??16,o=e?.iterations??32767,a=JQ.get();return r*=8,{encrypt:async function(e,c){const u=a.getRandomValues(new Uint8Array(s)),l=a.getRandomValues(new Uint8Array(n)),h={name:t,iv:l};let d;if("string"===typeof c&&(c=$Q(c)),0===c.length){d=await a.subtle.importKey("jwk",XQ,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",XQ,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}const f=await a.subtle.encrypt(h,d,e);return QQ([u,h.iv,new Uint8Array(f)])},decrypt:async function(e,c){const u=e.subarray(0,s),l=e.subarray(s,s+n),h=e.subarray(s+n),d={name:t,iv:l};let f;if("string"===typeof c&&(c=$Q(c)),0===c.length)try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}catch{f=await a.subtle.importKey("jwk",XQ,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}const p=await a.subtle.decrypt(d,f,h);return new Uint8Array(p)}}}(),n=await r.encrypt(e,t);return pQ.encode(n)}const eJ=new Float32Array([-0]),tJ=new Uint8Array(eJ.buffer);function rJ(e,t,r){eJ[0]=e,t[r]=tJ[0],t[r+1]=tJ[1],t[r+2]=tJ[2],t[r+3]=tJ[3]}const nJ=new Float64Array([-0]),iJ=new Uint8Array(nJ.buffer);function sJ(e,t,r){nJ[0]=e,t[r]=iJ[0],t[r+1]=iJ[1],t[r+2]=iJ[2],t[r+3]=iJ[3],t[r+4]=iJ[4],t[r+5]=iJ[5],t[r+6]=iJ[6],t[r+7]=iJ[7]}const oJ=BigInt(Number.MAX_SAFE_INTEGER),aJ=BigInt(Number.MIN_SAFE_INTEGER);class cJ{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return uJ;if(e<oJ&&e>aJ)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>lJ&&(n=0n,++r>lJ&&(r=0n))),new cJ(Number(n),Number(r))}static fromNumber(e){if(0===e)return uJ;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new cJ(r,n)}static from(e){return"number"===typeof e?cJ.fromNumber(e):"bigint"===typeof e?cJ.fromBigInt(e):"string"===typeof e?cJ.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new cJ(e.low>>>0,e.high>>>0):uJ}}const uJ=new cJ(0,0);uJ.toBigInt=function(){return 0n},uJ.zzEncode=uJ.zzDecode=function(){return this},uJ.length=function(){return 1};const lJ=4294967296n;function hJ(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function dJ(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function fJ(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class pJ{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,dJ(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw dJ(this,4);return fJ(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw dJ(this,4);return 0|fJ(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw dJ(this,4);const e=(t=this.buf,r=this.pos,tJ[0]=t[r],tJ[1]=t[r+1],tJ[2]=t[r+2],tJ[3]=t[r+3],eJ[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw dJ(this,4);const e=(t=this.buf,r=this.pos,iJ[0]=t[r],iJ[1]=t[r+1],iJ[2]=t[r+2],iJ[3]=t[r+3],iJ[4]=t[r+4],iJ[5]=t[r+5],iJ[6]=t[r+6],iJ[7]=t[r+7],nJ[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw dJ(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw dJ(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw dJ(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new cJ(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw dJ(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw dJ(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw dJ(this,8);const e=fJ(this.buf,this.pos+=4),t=fJ(this.buf,this.pos+=4);return new cJ(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 gJ(e,t,r){const n=function(e){return new pJ(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class bJ{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function yJ(){}class mJ{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const wJ=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return qQ(e);i+e>t&&(n=qQ(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class vJ{len;head;tail;states;constructor(){this.len=0,this.head=new bJ(yJ,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new bJ(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new SJ((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(AJ,10,cJ.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=cJ.fromBigInt(e);return this._push(AJ,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=cJ.fromBigInt(e).zzEncode();return this._push(AJ,t.length(),t)}sint64Number(e){const t=cJ.fromNumber(e).zzEncode();return this._push(AJ,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(_J,1,e?1:0)}fixed32(e){return this._push(kJ,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=cJ.fromBigInt(e);return this._push(kJ,4,t.lo)._push(kJ,4,t.hi)}fixed64Number(e){const t=cJ.fromNumber(e);return this._push(kJ,4,t.lo)._push(kJ,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(rJ,4,e)}double(e){return this._push(sJ,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(_J,1,0):this.uint32(t)._push(xJ,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(hJ,t,e):this._push(_J,1,0)}fork(){return this.states=new mJ(this),this.head=this.tail=new bJ(yJ,0,0),this.len=0,this}reset(){return null!=this.states?(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 bJ(yJ,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?qQ(r):wJ(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function _J(e,t,r){t[r]=255&e}function EJ(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class SJ extends bJ{next;constructor(e,t){super(EJ,e,t),this.next=void 0}}function AJ(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function kJ(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function xJ(e,t,r){t.set(e,r)}function IJ(e,t,r){t.set(e,r)}function CJ(e,t,r){e.length<40?hJ(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set($Q(e),r)}function TJ(e,t){const r=new vJ;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var RJ,PJ,DJ,NJ,BJ;function UJ(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function LJ(e,t){return UJ("message",RJ.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(vJ.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(IJ,t,e),this},vJ.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(CJ,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(RJ||(RJ={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(PJ||(PJ={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(DJ||(DJ={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return UJ("enum",RJ.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(DJ)}(PJ||(PJ={})),function(e){let t;e.codec=()=>(null==t&&(t=LJ((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),PJ.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=PJ.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>TJ(t,e.codec()),e.decode=t=>gJ(t,e.codec())}(NJ||(NJ={})),function(e){let t;e.codec=()=>(null==t&&(t=LJ((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),PJ.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=PJ.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>TJ(t,e.codec()),e.decode=t=>gJ(t,e.codec())}(BJ||(BJ={}));class MJ{_key;constructor(e){this._key=zJ(e,jQ)}verify(e,t){return function(e,t,r){return Lp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return NJ.encode({Type:PJ.Ed25519,Data:this.marshal()}).subarray()}equals(e){return WY(this.bytes,e.bytes)}hash(){const e=jY.digest(this.bytes);return HQ(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class OJ{_key;_publicKey;constructor(e,t){this._key=zJ(e,GQ),this._publicKey=zJ(t,jQ)}sign(e){return function(e,t){const r=e.subarray(0,WQ);return Lp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new MJ(this._publicKey)}marshal(){return this._key}get bytes(){return BJ.encode({Type:PJ.Ed25519,Data:this.marshal()}).subarray()}equals(e){return WY(this.bytes,e.bytes)}async hash(){const e=jY.digest(this.bytes);let t;return HQ(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=VY.digest(this.public.bytes);return bY.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return ZQ(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function qJ(e){if(e.length>GQ){const t=(e=zJ(e,GQ+jQ)).subarray(0,GQ),r=e.subarray(GQ,e.length);return new OJ(t,r)}const t=(e=zJ(e,GQ)).subarray(0,GQ),r=e.subarray(jQ);return new OJ(t,r)}function KJ(e){return e=zJ(e,jQ),new MJ(e)}async function FJ(){const{privateKey:e,publicKey:t}=function(){const e=Lp.utils.randomPrivateKey(),t=Lp.getPublicKey(e);return{privateKey:YQ(e,t),publicKey:t}}();return new OJ(e,t)}async function VJ(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==WQ)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Lp.getPublicKey(t);return{privateKey:YQ(t,r),publicKey:r}}(e);return new OJ(t,r)}function zJ(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new Xp(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}function $J(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=zQ[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}async function HJ(e){const t=[await JQ.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await GJ(e)],r=await jJ({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function jJ(e){if(null==e.privateKey||null==e.publicKey)throw new Xp("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([JQ.get().subtle.exportKey("jwk",e.privateKey),JQ.get().subtle.exportKey("jwk",e.publicKey)])}async function GJ(e){return JQ.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function WJ(e){if("RSA"!==e.kty)throw new Xp("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new Xp("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*$Q(e.n,"base64url").length}function YJ(e){if(isNaN(e)||e<=0)throw new Xp("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Cc(e)}function QJ(e){let t=e.toString(16);t.length%2>0&&(t=`0${t}`);const r=t.length/2,n=new Uint8Array(r);let i=0,s=0;for(;i<r;)n[i]=parseInt(t.slice(s,s+2),16),i+=1,s+=2;return n}function JJ(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r=`0${r}`),t.push(r)})),BigInt("0x"+t.join(""))}const XJ=32,ZJ=1e4;const eX=8192;class tX{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,r){const n=await JQ.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return JQ.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new fU({valueHex:new xU({value:[mU.fromBigInt(JJ($Q(e.n,"base64url"))),mU.fromBigInt(JJ($Q(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return NJ.encode({Type:PJ.RSA,Data:this.marshal()}).subarray()}equals(e){return WY(this.bytes,e.bytes)}hash(){const e=jY.digest(this.bytes);return HQ(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class rX{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return YJ(16)}sign(e){return async function(e,t){const r=await JQ.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await JQ.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new Xp("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new tX(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new mU({value:0}),mU.fromBigInt(JJ($Q(e.n,"base64url"))),mU.fromBigInt(JJ($Q(e.e,"base64url"))),mU.fromBigInt(JJ($Q(e.d,"base64url"))),mU.fromBigInt(JJ($Q(e.p,"base64url"))),mU.fromBigInt(JJ($Q(e.q,"base64url"))),mU.fromBigInt(JJ($Q(e.dp,"base64url"))),mU.fromBigInt(JJ($Q(e.dq,"base64url"))),mU.fromBigInt(JJ($Q(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return BJ.encode({Type:PJ.RSA,Data:this.marshal()}).subarray()}equals(e){return WY(this.bytes,e.bytes)}hash(){const e=jY.digest(this.bytes);return HQ(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return $J(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=JQ.get(),n=new xU({value:[new mU({value:0}),new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new hU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),s=YJ(16),o=await jN(Ef,t,s,{c:ZJ,dkLen:XJ}),a=YJ(16),c=await r.subtle.importKey("raw",o,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new xU({value:[new hU({valueHex:s}),new mU({value:ZJ}),new mU({value:XJ}),new xU({value:[new EU({value:"1.2.840.113549.2.11"}),new aU]})]}),h=new xU({value:[new EU({value:"1.2.840.113549.1.5.13"}),new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.5.12"}),l]}),new xU({value:[new EU({value:"2.16.840.1.101.3.4.1.42"}),new hU({valueHex:a})]})]})]}),d=new xU({value:[h,new hU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...$J(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return ZQ(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function nX(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value;return{n:$J(QJ(r[1].toBigInt()),"base64url"),e:$J(QJ(r[2].toBigInt()),"base64url"),d:$J(QJ(r[3].toBigInt()),"base64url"),p:$J(QJ(r[4].toBigInt()),"base64url"),q:$J(QJ(r[5].toBigInt()),"base64url"),dp:$J(QJ(r[6].toBigInt()),"base64url"),dq:$J(QJ(r[7].toBigInt()),"base64url"),qi:$J(QJ(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(WJ(t)>eX)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await HJ(t);return new rX(r.privateKey,r.publicKey)}function iX(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:$J(QJ(r[0].toBigInt()),"base64url"),e:$J(QJ(r[1].toBigInt()),"base64url")}}(e);if(WJ(t)>eX)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new tX(t)}async function sX(e){if(WJ(e)>eX)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await HJ(e);return new rX(t.privateKey,t.publicKey)}async function oX(e){if(e>eX)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await JQ.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await jJ(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new rX(t.privateKey,t.publicKey)}function aX(e){try{lm.ProjectivePoint.fromHex(e)}catch(t){throw new Xp(String(t),"ERR_INVALID_PUBLIC_KEY")}}class cX{_key;constructor(e){aX(e),this._key=e}verify(e,t){return function(e,t,r){const n=jY.digest(r instanceof Uint8Array?r:r.subarray());if(HQ(n))return n.then((r=>{let{digest:n}=r;return lm.verify(t,n,e)})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.verify(t,n.digest,e)}catch(i){throw new Xp(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,lm.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return NJ.encode({Type:PJ.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return WY(this.bytes,e.bytes)}async hash(){const e=jY.digest(this.bytes);let t;return HQ(e)?({bytes:t}=await e):t=e.bytes,t}}class uX{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),aX(this._publicKey)}sign(e){return function(e,t){const r=jY.digest(t instanceof Uint8Array?t:t.subarray());if(HQ(r))return r.then((t=>{let{digest:r}=t;return lm.sign(r,e).toDERRawBytes()})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.sign(r.digest,e).toDERRawBytes()}catch(n){throw new Xp(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new cX(this._publicKey)}marshal(){return this._key}get bytes(){return BJ.encode({Type:PJ.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return WY(this.bytes,e.bytes)}hash(){const e=jY.digest(this.bytes);return HQ(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return $J(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return ZQ(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function lX(e){return new uX(e)}function hX(e){return new cX(e)}async function dX(){const e=lm.utils.randomPrivateKey();return new uX(e)}const fX={rsa:Hr,ed25519:$r,secp256k1:jr};function pX(e){const t=Object.keys(fX).join(" / ");return new Xp(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}async function gX(e){const t=BJ.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case PJ.RSA:return fX.rsa.unmarshalRsaPrivateKey(r);case PJ.Ed25519:return fX.ed25519.unmarshalEd25519PrivateKey(r);case PJ.Secp256k1:return fX.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw pX(t.Type??"RSA")}}const bX=Symbol.for("@libp2p/content-routing"),yX=Symbol.for("@libp2p/peer-routing");function mX(){return{forComponent:e=>wX(e)}}function wX(e){let t=function(e){const t=()=>{};return t.enabled=!1,t.color="",t.diff=0,t.log=()=>{},t.namespace=e,t.destroy=()=>!0,t.extend=()=>t,t}(`${e}:trace`);return Bl.enabled(`${e}:trace`)&&null!=Bl.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=Bl(`${e}:trace`)),Object.assign(Bl(e),{error:Bl(`${e}:error`),trace:t})}Bl.formatters.b=e=>null==e?"undefined":bY.baseEncode(e),Bl.formatters.t=e=>null==e?"undefined":nQ.baseEncode(e),Bl.formatters.m=e=>null==e?"undefined":pQ.baseEncode(e),Bl.formatters.p=e=>null==e?"undefined":e.toString(),Bl.formatters.c=e=>null==e?"undefined":e.toString(),Bl.formatters.k=e=>null==e?"undefined":e.toString(),Bl.formatters.a=e=>null==e?"undefined":e.toString();new Uint8Array(0);function vX(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var _X=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const EX=_X;class SX{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class AX{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return xX(this,e)}}class kX{decoders;constructor(e){this.decoders=e}or(e){return xX(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function xX(e,t){return new kX({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class IX{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new SX(e,t,r),this.decoder=new AX(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function CX(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new IX(t,r,n,i)}function TX(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=EX(n,t);return CX({prefix:r,name:t,encode:i,decode:e=>vX(s(e))})}function RX(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return CX({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const PX=TX({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),DX=TX({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),NX=TX({prefix:"9",name:"base10",alphabet:"0123456789"}),BX=RX({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),UX=RX({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),LX=RX({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),MX=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),OX=MX.reduce(((e,t,r)=>(e[r]=t,e)),[]),qX=MX.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const KX=CX({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=OX[t]),"")},decode:function(e){const t=[];for(const r of e){const e=qX[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),FX=RX({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),VX=RX({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),zX=RX({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),$X=RX({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HX=RX({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),jX=RX({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),GX=RX({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),WX=RX({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),YX=RX({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),QX=TX({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),JX=TX({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),XX=RX({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),ZX=RX({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),eZ=RX({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),tZ=RX({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),rZ=RX({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),nZ=CX({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),iZ=new TextEncoder,sZ=new TextDecoder,oZ="json",aZ=512;function cZ(e){return iZ.encode(JSON.stringify(e))}function uZ(e){return JSON.parse(sZ.decode(e))}const lZ="raw",hZ=85;function dZ(e){return vX(e)}function fZ(e){return vX(e)}var pZ=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=yZ;)r[n++]=255&t|gZ,t/=128;for(;t&bZ;)r[n++]=255&t|gZ,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},gZ=128,bZ=-128,yZ=Math.pow(2,31);var mZ=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&vZ)<<s:(n&vZ)*Math.pow(2,s),s+=7}while(n>=wZ);return e.bytes=o-r,i},wZ=128,vZ=127;var _Z=Math.pow(2,7),EZ=Math.pow(2,14),SZ=Math.pow(2,21),AZ=Math.pow(2,28),kZ=Math.pow(2,35),xZ=Math.pow(2,42),IZ=Math.pow(2,49),CZ=Math.pow(2,56),TZ=Math.pow(2,63);const RZ={encode:pZ,decode:mZ,encodingLength:function(e){return e<_Z?1:e<EZ?2:e<SZ?3:e<AZ?4:e<kZ?5:e<xZ?6:e<IZ?7:e<CZ?8:e<TZ?9:10}};function PZ(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[RZ.decode(e,t),RZ.decode.bytes]}function DZ(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return RZ.encode(e,t,r),t}function NZ(e){return RZ.encodingLength(e)}function BZ(e,t){const r=t.byteLength,n=NZ(e),i=n+NZ(r),s=new Uint8Array(i+r);return DZ(e,s,0),DZ(r,s,n),s.set(t,i),new LZ(e,r,t,s)}function UZ(e){const t=vX(e),[r,n]=PZ(t),[i,s]=PZ(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new LZ(r,i,o,t)}class LZ{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const MZ=vX;const OZ={code:0,name:"identity",encode:MZ,digest:function(e){return BZ(0,MZ(e))}};function qZ(e){let{name:t,code:r,encode:n}=e;return new KZ(t,r,n)}class KZ{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?BZ(this.code,t):t.then((e=>BZ(this.code,e)))}throw Error("Unknown type, must be binary type")}}function FZ(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const VZ=qZ({name:"sha2-256",code:18,encode:FZ("SHA-256")}),zZ=qZ({name:"sha2-512",code:19,encode:FZ("SHA-512")});function $Z(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==PX.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,jZ(e),t??PX.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,jZ(e),t??FX.encoder)}const HZ=new WeakMap;function jZ(e){const t=HZ.get(e);if(null==t){const t=new Map;return HZ.set(e,t),t}return t}class GZ{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==WZ)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==YZ)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return GZ.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:{const{code:e,digest:t}=this.multihash,r=BZ(e,t);return GZ.createV1(this.code,r)}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 GZ.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return $Z(this,e)}toJSON(){return{"/":$Z(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof GZ)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new GZ(e,r,n,i??QZ(e,r,n.bytes))}if(!0===t[JZ]){const{version:e,multihash:r,code:n}=t,i=UZ(r);return GZ.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==WZ)throw new Error(`Version 0 CID must use dag-pb (code: ${WZ}) block encoding`);return new GZ(e,t,r,r.bytes);case 1:{const n=QZ(e,t,r.bytes);return new GZ(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return GZ.create(0,WZ,e)}static createV1(e,t){return GZ.create(1,e,t)}static decode(e){const[t,r]=GZ.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=GZ.inspectBytes(e),r=t.size-t.multihashSize,n=vX(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new LZ(t.multihashCode,t.digestSize,i,n);return[0===t.version?GZ.createV0(s):GZ.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=PZ(e.subarray(t));return t+=n,r};let n=r(),i=WZ;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??PX;return[PX.prefix,r.decode(`${PX.prefix}${e}`)]}case PX.prefix:{const r=t??PX;return[PX.prefix,r.decode(e)]}case FX.prefix:{const r=t??FX;return[FX.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=GZ.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return jZ(i).set(r,e),i}}const WZ=112,YZ=18;function QZ(e,t,r){const n=NZ(e),i=n+NZ(t),s=new Uint8Array(i+r.byteLength);return DZ(e,s,0),DZ(t,s,n),s.set(r,i),s}const JZ=Symbol.for("@ipld/js-cid/CID"),XZ={...rn,...Qr,...tn,...Wr,...Yr,...Xr,...Zr,...Gr,...en,...Jr};function ZZ(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const e0=Symbol.for("nodejs.util.inspect.custom"),t0=Object.values(XZ).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),XZ.identity.decoder),r0=114,n0=36,i0=37;class s0{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=PX.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return GZ.createV1(r0,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return ZZ(this.multihash.bytes,e);if("string"===typeof e)return u0(e).equals(this);if(null!=e?.multihash?.bytes)return ZZ(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[e0](){return`PeerId(${this.toString()})`}}class o0 extends s0{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class a0 extends s0{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class c0 extends s0{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function u0(e,t){if(t=t??t0,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=UZ(PX.decode(`z${e}`));return e.startsWith("12D")?new a0({multihash:t}):e.startsWith("16U")?new c0({multihash:t}):new o0({multihash:t})}return function(e){try{const t=UZ(e);if(t.code===OZ.code){if(t.digest.length===n0)return new a0({multihash:t});if(t.digest.length===i0)return new c0({multihash:t})}if(t.code===VZ.code)return new o0({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==r0)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===VZ.code)return new o0({multihash:e.multihash});if(t.code===OZ.code){if(t.digest.length===n0)return new a0({multihash:e.multihash});if(t.digest.length===i0)return new c0({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(GZ.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(t0.decode(e))}function l0(e,t){const r={[Symbol.iterator]:()=>r,next:()=>{const r=e.next(),n=r.value;if(!0===r.done||null==n){return{done:!0,value:void 0}}return{done:!1,value:t(n)}}};return r}class h0{set;constructor(e){if(this.set=new Set,null!=e)for(const t of e)this.set.add(t.toString())}get size(){return this.set.size}[Symbol.iterator](){return this.values()}add(e){this.set.add(e.toString())}clear(){this.set.clear()}delete(e){this.set.delete(e.toString())}entries(){return l0(this.set.entries(),(e=>{const t=u0(e[0]);return[t,t]}))}forEach(e){this.set.forEach((t=>{const r=u0(t);e(r,r,this)}))}has(e){return this.set.has(e.toString())}values(){return l0(this.set.values(),(e=>u0(e)))}intersection(e){const t=new h0;for(const r of e)this.has(r)&&t.add(r);return t}difference(e){const t=new h0;for(const r of this)e.has(r)||t.add(r);return t}union(e){const t=new h0;for(const r of e)t.add(r);for(const r of this)t.add(r);return t}}const d0=Symbol.for("nodejs.util.inspect.custom"),f0=Object.values(OQ).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),OQ.identity.decoder),p0=114,g0=36,b0=37;class y0{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=bY.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return NQ.createV1(p0,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return WY(this.multihash.bytes,e);if("string"===typeof e)return _0(e).equals(this);if(null!=e?.multihash?.bytes)return WY(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[d0](){return`PeerId(${this.toString()})`}}class m0 extends y0{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class w0 extends y0{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class v0 extends y0{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function _0(e,t){if(t=t??f0,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=qY(bY.decode(`z${e}`));return e.startsWith("12D")?new w0({multihash:t}):e.startsWith("16U")?new v0({multihash:t}):new m0({multihash:t})}return function(e){try{const t=qY(e);if(t.code===VY.code){if(t.digest.length===g0)return new w0({multihash:t});if(t.digest.length===b0)return new v0({multihash:t})}if(t.code===jY.code)return new m0({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==p0)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===jY.code)return new m0({multihash:e.multihash});if(t.code===VY.code){if(t.digest.length===g0)return new w0({multihash:e.multihash});if(t.digest.length===b0)return new v0({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(NQ.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(f0.decode(e))}new Uint8Array(0);function E0(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var S0=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const A0=S0;class k0{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class x0{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return C0(this,e)}}class I0{decoders;constructor(e){this.decoders=e}or(e){return C0(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function C0(e,t){return new I0({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class T0{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new k0(e,t,r),this.decoder=new x0(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function R0(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new T0(t,r,n,i)}function P0(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=A0(n,t);return R0({prefix:r,name:t,encode:i,decode:e=>E0(s(e))})}function D0(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return R0({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const N0=P0({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),B0=P0({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var U0=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=O0;)r[n++]=255&t|L0,t/=128;for(;t&M0;)r[n++]=255&t|L0,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},L0=128,M0=-128,O0=Math.pow(2,31);var q0=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&F0)<<s:(n&F0)*Math.pow(2,s),s+=7}while(n>=K0);return e.bytes=o-r,i},K0=128,F0=127;var V0=Math.pow(2,7),z0=Math.pow(2,14),$0=Math.pow(2,21),H0=Math.pow(2,28),j0=Math.pow(2,35),G0=Math.pow(2,42),W0=Math.pow(2,49),Y0=Math.pow(2,56),Q0=Math.pow(2,63);const J0={encode:U0,decode:q0,encodingLength:function(e){return e<V0?1:e<z0?2:e<$0?3:e<H0?4:e<j0?5:e<G0?6:e<W0?7:e<Y0?8:e<Q0?9:10}};function X0(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[J0.decode(e,t),J0.decode.bytes]}function Z0(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return J0.encode(e,t,r),t}function e1(e){return J0.encodingLength(e)}function t1(e,t){const r=t.byteLength,n=e1(e),i=n+e1(r),s=new Uint8Array(i+r);return Z0(e,s,0),Z0(r,s,n),s.set(t,i),new n1(e,r,t,s)}function r1(e){const t=E0(e),[r,n]=X0(t),[i,s]=X0(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new n1(r,i,o,t)}class n1{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const i1=E0;const s1={code:0,name:"identity",encode:i1,digest:function(e){return t1(0,i1(e))}};function o1(e){let{name:t,code:r,encode:n}=e;return new a1(t,r,n)}class a1{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?t1(this.code,t):t.then((e=>t1(this.code,e)))}throw Error("Unknown type, must be binary type")}}function c1(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const u1=o1({name:"sha2-256",code:18,encode:c1("SHA-256")}),l1=o1({name:"sha2-512",code:19,encode:c1("SHA-512")});function h1(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const d1=P0({prefix:"9",name:"base10",alphabet:"0123456789"}),f1=D0({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),p1=D0({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),g1=D0({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),b1=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),y1=b1.reduce(((e,t,r)=>(e[r]=t,e)),[]),m1=b1.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const w1=R0({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=y1[t]),"")},decode:function(e){const t=[];for(const r of e){const e=m1[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),v1=D0({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_1=D0({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),E1=D0({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),S1=D0({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),A1=D0({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),k1=D0({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),x1=D0({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),I1=D0({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),C1=D0({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),T1=P0({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),R1=P0({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),P1=D0({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),D1=D0({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),N1=D0({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),B1=D0({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),U1=D0({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),L1=R0({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),M1=new TextEncoder,O1=new TextDecoder,q1="json",K1=512;function F1(e){return M1.encode(JSON.stringify(e))}function V1(e){return JSON.parse(O1.decode(e))}const z1="raw",$1=85;function H1(e){return E0(e)}function j1(e){return E0(e)}function G1(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==N0.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,Y1(e),t??N0.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,Y1(e),t??v1.encoder)}const W1=new WeakMap;function Y1(e){const t=W1.get(e);if(null==t){const t=new Map;return W1.set(e,t),t}return t}class Q1{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==J1)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==X1)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return Q1.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:{const{code:e,digest:t}=this.multihash,r=t1(e,t);return Q1.createV1(this.code,r)}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 Q1.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return G1(this,e)}toJSON(){return{"/":G1(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof Q1)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new Q1(e,r,n,i??Z1(e,r,n.bytes))}if(!0===t[e2]){const{version:e,multihash:r,code:n}=t,i=r1(r);return Q1.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==J1)throw new Error(`Version 0 CID must use dag-pb (code: ${J1}) block encoding`);return new Q1(e,t,r,r.bytes);case 1:{const n=Z1(e,t,r.bytes);return new Q1(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return Q1.create(0,J1,e)}static createV1(e,t){return Q1.create(1,e,t)}static decode(e){const[t,r]=Q1.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=Q1.inspectBytes(e),r=t.size-t.multihashSize,n=E0(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new n1(t.multihashCode,t.digestSize,i,n);return[0===t.version?Q1.createV0(s):Q1.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=X0(e.subarray(t));return t+=n,r};let n=r(),i=J1;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??N0;return[N0.prefix,r.decode(`${N0.prefix}${e}`)]}case N0.prefix:{const r=t??N0;return[N0.prefix,r.decode(e)]}case v1.prefix:{const r=t??v1;return[v1.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=Q1.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return Y1(i).set(r,e),i}}const J1=112,X1=18;function Z1(e,t,r){const n=e1(e),i=n+e1(t),s=new Uint8Array(i+r.byteLength);return Z0(e,s,0),Z0(t,s,n),s.set(r,i),s}const e2=Symbol.for("@ipld/js-cid/CID"),t2={...wn,...fn,...mn,...hn,...dn,...gn,...bn,...cn,...yn,...pn};function r2(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function n2(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const i2=n2("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),s2=n2("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=r2((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),o2={utf8:i2,"utf-8":i2,hex:t2.base16,latin1:s2,ascii:s2,binary:s2,...t2};function a2(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=o2[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function c2(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const u2=32,l2=64,h2=32;function d2(e,t){const r=new Uint8Array(l2);for(let n=0;n<h2;n++)r[n]=e[n],r[h2+n]=t[n];return r}const f2={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)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}},p2={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function g2(e){const t=e?.algorithm??"AES-GCM";let r=e?.keyLength??16;const n=e?.nonceLength??12,i=e?.digest??"SHA-256",s=e?.saltLength??16,o=e?.iterations??32767,a=f2.get();r*=8;const c={encrypt:async function(e,c){const u=a.getRandomValues(new Uint8Array(s)),l=a.getRandomValues(new Uint8Array(n)),h={name:t,iv:l};let d;if("string"===typeof c&&(c=a2(c)),0===c.length){d=await a.subtle.importKey("jwk",p2,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",p2,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}const f=await a.subtle.encrypt(h,d,e);return function(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=r2(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}([u,h.iv,new Uint8Array(f)])},decrypt:async function(e,c){const u=e.subarray(0,s),l=e.subarray(s,s+n),h=e.subarray(s+n),d={name:t,iv:l};let f;if("string"===typeof c&&(c=a2(c)),0===c.length)try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}catch{f=await a.subtle.importKey("jwk",p2,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}const p=await a.subtle.decrypt(d,f,h);return new Uint8Array(p)}};return c}async function b2(e,t){const r=g2(),n=await r.encrypt(e,t);return P1.encode(n)}const y2=new Float32Array([-0]),m2=new Uint8Array(y2.buffer);function w2(e,t,r){y2[0]=e,t[r]=m2[0],t[r+1]=m2[1],t[r+2]=m2[2],t[r+3]=m2[3]}const v2=new Float64Array([-0]),_2=new Uint8Array(v2.buffer);function E2(e,t,r){v2[0]=e,t[r]=_2[0],t[r+1]=_2[1],t[r+2]=_2[2],t[r+3]=_2[3],t[r+4]=_2[4],t[r+5]=_2[5],t[r+6]=_2[6],t[r+7]=_2[7]}const S2=BigInt(Number.MAX_SAFE_INTEGER),A2=BigInt(Number.MIN_SAFE_INTEGER);class k2{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return x2;if(e<S2&&e>A2)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>I2&&(n=0n,++r>I2&&(r=0n))),new k2(Number(n),Number(r))}static fromNumber(e){if(0===e)return x2;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new k2(r,n)}static from(e){return"number"===typeof e?k2.fromNumber(e):"bigint"===typeof e?k2.fromBigInt(e):"string"===typeof e?k2.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new k2(e.low>>>0,e.high>>>0):x2}}const x2=new k2(0,0);x2.toBigInt=function(){return 0n},x2.zzEncode=x2.zzDecode=function(){return this},x2.length=function(){return 1};const I2=4294967296n;function C2(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function T2(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function R2(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class P2{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,T2(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw T2(this,4);return R2(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw T2(this,4);return 0|R2(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw T2(this,4);const e=(t=this.buf,r=this.pos,m2[0]=t[r],m2[1]=t[r+1],m2[2]=t[r+2],m2[3]=t[r+3],y2[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw T2(this,4);const e=(t=this.buf,r=this.pos,_2[0]=t[r],_2[1]=t[r+1],_2[2]=t[r+2],_2[3]=t[r+3],_2[4]=t[r+4],_2[5]=t[r+5],_2[6]=t[r+6],_2[7]=t[r+7],v2[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw T2(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw T2(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw T2(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new k2(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw T2(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw T2(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw T2(this,8);const e=R2(this.buf,this.pos+=4),t=R2(this.buf,this.pos+=4);return new k2(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 D2(e,t,r){const n=function(e){return new P2(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class N2{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function B2(){}class U2{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const L2=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return r2(e);i+e>t&&(n=r2(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class M2{len;head;tail;states;constructor(){this.len=0,this.head=new N2(B2,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new N2(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new K2((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(F2,10,k2.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=k2.fromBigInt(e);return this._push(F2,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=k2.fromBigInt(e).zzEncode();return this._push(F2,t.length(),t)}sint64Number(e){const t=k2.fromNumber(e).zzEncode();return this._push(F2,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(O2,1,e?1:0)}fixed32(e){return this._push(V2,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=k2.fromBigInt(e);return this._push(V2,4,t.lo)._push(V2,4,t.hi)}fixed64Number(e){const t=k2.fromNumber(e);return this._push(V2,4,t.lo)._push(V2,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(w2,4,e)}double(e){return this._push(E2,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(O2,1,0):this.uint32(t)._push(z2,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(C2,t,e):this._push(O2,1,0)}fork(){return this.states=new U2(this),this.head=this.tail=new N2(B2,0,0),this.len=0,this}reset(){return null!=this.states?(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 N2(B2,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?r2(r):L2(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function O2(e,t,r){t[r]=255&e}function q2(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class K2 extends N2{next;constructor(e,t){super(q2,e,t),this.next=void 0}}function F2(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function V2(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function z2(e,t,r){t.set(e,r)}function $2(e,t,r){t.set(e,r)}function H2(e,t,r){e.length<40?C2(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(a2(e),r)}function j2(e,t){const r=new M2;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var G2,W2,Y2,Q2,J2;function X2(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function Z2(e,t){return X2("message",G2.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(M2.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push($2,t,e),this},M2.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(H2,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(G2||(G2={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(W2||(W2={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(Y2||(Y2={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return X2("enum",G2.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(Y2)}(W2||(W2={})),function(e){let t;e.codec=()=>(null==t&&(t=Z2((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),W2.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=W2.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>j2(t,e.codec()),e.decode=t=>D2(t,e.codec())}(Q2||(Q2={})),function(e){let t;e.codec=()=>(null==t&&(t=Z2((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),W2.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=W2.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>j2(t,e.codec()),e.decode=t=>D2(t,e.codec())}(J2||(J2={}));class e3{_key;constructor(e){this._key=o3(e,u2)}verify(e,t){return function(e,t,r){return Lp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return Q2.encode({Type:W2.Ed25519,Data:this.marshal()}).subarray()}equals(e){return h1(this.bytes,e.bytes)}hash(){const e=u1.digest(this.bytes);return c2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class t3{_key;_publicKey;constructor(e,t){this._key=o3(e,l2),this._publicKey=o3(t,u2)}sign(e){return function(e,t){const r=e.subarray(0,h2);return Lp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new e3(this._publicKey)}marshal(){return this._key}get bytes(){return J2.encode({Type:W2.Ed25519,Data:this.marshal()}).subarray()}equals(e){return h1(this.bytes,e.bytes)}async hash(){const e=u1.digest(this.bytes);let t;return c2(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=s1.digest(this.public.bytes);return N0.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return b2(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function r3(e){if(e.length>l2){const t=(e=o3(e,l2+u2)).subarray(0,l2),r=e.subarray(l2,e.length);return new t3(t,r)}const t=(e=o3(e,l2)).subarray(0,l2),r=e.subarray(u2);return new t3(t,r)}function n3(e){return e=o3(e,u2),new e3(e)}async function i3(){const{privateKey:e,publicKey:t}=function(){const e=Lp.utils.randomPrivateKey(),t=Lp.getPublicKey(e);return{privateKey:d2(e,t),publicKey:t}}();return new t3(e,t)}async function s3(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==h2)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Lp.getPublicKey(t);return{privateKey:d2(t,r),publicKey:r}}(e);return new t3(t,r)}function o3(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new Xp(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}function a3(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=o2[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}async function c3(e){const t=[await f2.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await l3(e)],r=await u3({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function u3(e){if(null==e.privateKey||null==e.publicKey)throw new Xp("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([f2.get().subtle.exportKey("jwk",e.privateKey),f2.get().subtle.exportKey("jwk",e.publicKey)])}async function l3(e){return f2.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function h3(e){if("RSA"!==e.kty)throw new Xp("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new Xp("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*a2(e.n,"base64url").length}function d3(e){if(isNaN(e)||e<=0)throw new Xp("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Cc(e)}function f3(e){let t=e.toString(16);t.length%2>0&&(t=`0${t}`);const r=t.length/2,n=new Uint8Array(r);let i=0,s=0;for(;i<r;)n[i]=parseInt(t.slice(s,s+2),16),i+=1,s+=2;return n}function p3(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r=`0${r}`),t.push(r)})),BigInt("0x"+t.join(""))}const g3=32,b3=1e4;const y3=8192;class m3{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,r){const n=await f2.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return f2.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new fU({valueHex:new xU({value:[mU.fromBigInt(p3(a2(e.n,"base64url"))),mU.fromBigInt(p3(a2(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return Q2.encode({Type:W2.RSA,Data:this.marshal()}).subarray()}equals(e){return h1(this.bytes,e.bytes)}hash(){const e=u1.digest(this.bytes);return c2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class w3{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return d3(16)}sign(e){return async function(e,t){const r=await f2.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await f2.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new Xp("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new m3(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new mU({value:0}),mU.fromBigInt(p3(a2(e.n,"base64url"))),mU.fromBigInt(p3(a2(e.e,"base64url"))),mU.fromBigInt(p3(a2(e.d,"base64url"))),mU.fromBigInt(p3(a2(e.p,"base64url"))),mU.fromBigInt(p3(a2(e.q,"base64url"))),mU.fromBigInt(p3(a2(e.dp,"base64url"))),mU.fromBigInt(p3(a2(e.dq,"base64url"))),mU.fromBigInt(p3(a2(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return J2.encode({Type:W2.RSA,Data:this.marshal()}).subarray()}equals(e){return h1(this.bytes,e.bytes)}hash(){const e=u1.digest(this.bytes);return c2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return a3(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=f2.get(),n=new xU({value:[new mU({value:0}),new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new hU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),s=d3(16),o=await jN(Ef,t,s,{c:b3,dkLen:g3}),a=d3(16),c=await r.subtle.importKey("raw",o,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new xU({value:[new hU({valueHex:s}),new mU({value:b3}),new mU({value:g3}),new xU({value:[new EU({value:"1.2.840.113549.2.11"}),new aU]})]}),h=new xU({value:[new EU({value:"1.2.840.113549.1.5.13"}),new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.5.12"}),l]}),new xU({value:[new EU({value:"2.16.840.1.101.3.4.1.42"}),new hU({valueHex:a})]})]})]}),d=new xU({value:[h,new hU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...a3(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return b2(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function v3(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value;return{n:a3(f3(r[1].toBigInt()),"base64url"),e:a3(f3(r[2].toBigInt()),"base64url"),d:a3(f3(r[3].toBigInt()),"base64url"),p:a3(f3(r[4].toBigInt()),"base64url"),q:a3(f3(r[5].toBigInt()),"base64url"),dp:a3(f3(r[6].toBigInt()),"base64url"),dq:a3(f3(r[7].toBigInt()),"base64url"),qi:a3(f3(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(h3(t)>y3)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await c3(t);return new w3(r.privateKey,r.publicKey)}function _3(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:a3(f3(r[0].toBigInt()),"base64url"),e:a3(f3(r[1].toBigInt()),"base64url")}}(e);if(h3(t)>y3)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new m3(t)}async function E3(e){if(h3(e)>y3)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await c3(e);return new w3(t.privateKey,t.publicKey)}async function S3(e){if(e>y3)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await f2.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await u3(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new w3(t.privateKey,t.publicKey)}function A3(e){try{lm.ProjectivePoint.fromHex(e)}catch(t){throw new Xp(String(t),"ERR_INVALID_PUBLIC_KEY")}}class k3{_key;constructor(e){A3(e),this._key=e}verify(e,t){return function(e,t,r){const n=u1.digest(r instanceof Uint8Array?r:r.subarray());if(c2(n))return n.then((r=>{let{digest:n}=r;return lm.verify(t,n,e)})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.verify(t,n.digest,e)}catch(i){throw new Xp(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,lm.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return Q2.encode({Type:W2.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return h1(this.bytes,e.bytes)}async hash(){const e=u1.digest(this.bytes);let t;return c2(e)?({bytes:t}=await e):t=e.bytes,t}}class x3{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),A3(this._publicKey)}sign(e){return function(e,t){const r=u1.digest(t instanceof Uint8Array?t:t.subarray());if(c2(r))return r.then((t=>{let{digest:r}=t;return lm.sign(r,e).toDERRawBytes()})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.sign(r.digest,e).toDERRawBytes()}catch(n){throw new Xp(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new k3(this._publicKey)}marshal(){return this._key}get bytes(){return J2.encode({Type:W2.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return h1(this.bytes,e.bytes)}hash(){const e=u1.digest(this.bytes);return c2(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return a3(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return b2(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function I3(e){return new x3(e)}function C3(e){return new k3(e)}async function T3(){const e=lm.utils.randomPrivateKey();return new x3(e)}const R3={rsa:Sn,ed25519:En,secp256k1:An};function P3(e){const t=Object.keys(R3).join(" / ");return new Xp(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function D3(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return R3[e];throw P3(e)}function N3(e,t){return D3(t=(t??"rsa").toLowerCase()),e.bytes}async function B3(e){const t=J2.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case W2.RSA:return R3.rsa.unmarshalRsaPrivateKey(r);case W2.Ed25519:return R3.ed25519.unmarshalEd25519PrivateKey(r);case W2.Secp256k1:return R3.secp256k1.unmarshalSecp256k1PrivateKey(r);default:throw P3(t.Type??"RSA")}}const U3=Symbol.for("nodejs.util.inspect.custom"),L3=Object.values(t2).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),t2.identity.decoder),M3=114,O3=36,q3=37;class K3{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=N0.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return Q1.createV1(M3,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return h1(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){if(t=t??L3,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=r1(N0.decode(`z${e}`));return e.startsWith("12D")?new V3({multihash:t}):e.startsWith("16U")?new z3({multihash:t}):new F3({multihash:t})}return $3(L3.decode(e))}(e).equals(this);if(null!=e?.multihash?.bytes)return h1(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[U3](){return`PeerId(${this.toString()})`}}class F3 extends K3{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class V3 extends K3{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class z3 extends K3{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function $3(e){try{const t=r1(e);if(t.code===s1.code){if(t.digest.length===O3)return new V3({multihash:t});if(t.digest.length===q3)return new z3({multihash:t})}if(t.code===u1.code)return new F3({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==M3)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===u1.code)return new F3({multihash:e.multihash});if(t.code===s1.code){if(t.digest.length===O3)return new V3({multihash:e.multihash});if(t.digest.length===q3)return new z3({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(Q1.decode(e))}throw new Error("Supplied PeerID CID is invalid")}async function H3(e,t){return e.length===O3?new V3({multihash:t1(s1.code,e),privateKey:t}):e.length===q3?new z3({multihash:t1(s1.code,e),privateKey:t}):new F3({multihash:await u1.digest(e),publicKey:e,privateKey:t})}const j3=async()=>{const e=await async function(e,t){return D3(e).generateKeyPair(t??2048)}("Ed25519"),t=await G3(e);if("Ed25519"===t.type)return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function G3(e){return H3(N3(e.public),(t=e,D3(r=(r??"rsa").toLowerCase()),t.bytes));var t,r}async function W3(e){return Y3(a2(e.id,"base58btc"),null!=e.privKey?a2(e.privKey,"base64pad"):void 0,null!=e.pubKey?a2(e.pubKey,"base64pad"):void 0)}async function Y3(e,t,r){if(null!=t){return G3(await B3(t))}if(null!=r){return async function(e){return H3(N3(e))}(function(e){const t=Q2.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case W2.RSA:return R3.rsa.unmarshalRsaPublicKey(r);case W2.Ed25519:return R3.ed25519.unmarshalEd25519PublicKey(r);case W2.Secp256k1:return R3.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw P3(t.Type??"unknown")}}(r))}return $3(e)}class Q3{map;constructor(e){if(this.map=new Map,null!=e)for(const[t,r]of e.entries())this.map.set(t.toString(),r)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){return this.map.delete(e.toString())}entries(){return l0(this.map.entries(),(e=>[u0(e[0]),e[1]]))}forEach(e){this.map.forEach(((t,r)=>{e(t,u0(r),this)}))}get(e){return this.map.get(e.toString())}has(e){return this.map.has(e.toString())}set(e,t){this.map.set(e.toString(),t)}keys(){return l0(this.map.keys(),(e=>u0(e)))}values(){return this.map.values()}get size(){return this.map.size}}new Uint8Array(0);function J3(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var X3=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const Z3=X3;class e6{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class t6{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return n6(this,e)}}class r6{decoders;constructor(e){this.decoders=e}or(e){return n6(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function n6(e,t){return new r6({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class i6{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new e6(e,t,r),this.decoder=new t6(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function s6(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new i6(t,r,n,i)}function o6(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=Z3(n,t);return s6({prefix:r,name:t,encode:i,decode:e=>J3(s(e))})}function a6(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return s6({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const c6=o6({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),u6=o6({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),l6=o6({prefix:"9",name:"base10",alphabet:"0123456789"}),h6=a6({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),d6=a6({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),f6=a6({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),p6=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),g6=p6.reduce(((e,t,r)=>(e[r]=t,e)),[]),b6=p6.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const y6=s6({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=g6[t]),"")},decode:function(e){const t=[];for(const r of e){const e=b6[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),m6=a6({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),w6=a6({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),v6=a6({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_6=a6({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),E6=a6({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),S6=a6({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),A6=a6({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),k6=a6({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),x6=a6({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),I6=o6({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),C6=o6({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),T6=a6({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),R6=a6({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),P6=a6({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),D6=a6({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),N6=a6({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),B6=s6({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),U6=new TextEncoder,L6=new TextDecoder,M6="json",O6=512;function q6(e){return U6.encode(JSON.stringify(e))}function K6(e){return JSON.parse(L6.decode(e))}const F6="raw",V6=85;function z6(e){return J3(e)}function $6(e){return J3(e)}var H6=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=W6;)r[n++]=255&t|j6,t/=128;for(;t&G6;)r[n++]=255&t|j6,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},j6=128,G6=-128,W6=Math.pow(2,31);var Y6=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&J6)<<s:(n&J6)*Math.pow(2,s),s+=7}while(n>=Q6);return e.bytes=o-r,i},Q6=128,J6=127;var X6=Math.pow(2,7),Z6=Math.pow(2,14),e4=Math.pow(2,21),t4=Math.pow(2,28),r4=Math.pow(2,35),n4=Math.pow(2,42),i4=Math.pow(2,49),s4=Math.pow(2,56),o4=Math.pow(2,63);const a4={encode:H6,decode:Y6,encodingLength:function(e){return e<X6?1:e<Z6?2:e<e4?3:e<t4?4:e<r4?5:e<n4?6:e<i4?7:e<s4?8:e<o4?9:10}};function c4(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[a4.decode(e,t),a4.decode.bytes]}function u4(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return a4.encode(e,t,r),t}function l4(e){return a4.encodingLength(e)}function h4(e,t){const r=t.byteLength,n=l4(e),i=n+l4(r),s=new Uint8Array(i+r);return u4(e,s,0),u4(r,s,n),s.set(t,i),new f4(e,r,t,s)}function d4(e){const t=J3(e),[r,n]=c4(t),[i,s]=c4(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new f4(r,i,o,t)}class f4{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const p4=J3;const g4={code:0,name:"identity",encode:p4,digest:function(e){return h4(0,p4(e))}};function b4(e){let{name:t,code:r,encode:n}=e;return new y4(t,r,n)}class y4{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?h4(this.code,t):t.then((e=>h4(this.code,e)))}throw Error("Unknown type, must be binary type")}}function m4(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const w4=b4({name:"sha2-256",code:18,encode:m4("SHA-256")}),v4=b4({name:"sha2-512",code:19,encode:m4("SHA-512")});function _4(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==c6.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,S4(e),t??c6.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,S4(e),t??m6.encoder)}const E4=new WeakMap;function S4(e){const t=E4.get(e);if(null==t){const t=new Map;return E4.set(e,t),t}return t}class A4{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==k4)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==x4)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return A4.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:{const{code:e,digest:t}=this.multihash,r=h4(e,t);return A4.createV1(this.code,r)}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 A4.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return _4(this,e)}toJSON(){return{"/":_4(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof A4)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new A4(e,r,n,i??I4(e,r,n.bytes))}if(!0===t[C4]){const{version:e,multihash:r,code:n}=t,i=d4(r);return A4.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==k4)throw new Error(`Version 0 CID must use dag-pb (code: ${k4}) block encoding`);return new A4(e,t,r,r.bytes);case 1:{const n=I4(e,t,r.bytes);return new A4(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return A4.create(0,k4,e)}static createV1(e,t){return A4.create(1,e,t)}static decode(e){const[t,r]=A4.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=A4.inspectBytes(e),r=t.size-t.multihashSize,n=J3(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new f4(t.multihashCode,t.digestSize,i,n);return[0===t.version?A4.createV0(s):A4.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=c4(e.subarray(t));return t+=n,r};let n=r(),i=k4;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??c6;return[c6.prefix,r.decode(`${c6.prefix}${e}`)]}case c6.prefix:{const r=t??c6;return[c6.prefix,r.decode(e)]}case m6.prefix:{const r=t??m6;return[m6.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=A4.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return S4(i).set(r,e),i}}const k4=112,x4=18;function I4(e,t,r){const n=l4(e),i=n+l4(t),s=new Uint8Array(i+r.byteLength);return u4(e,s,0),u4(t,s,n),s.set(r,i),s}const C4=Symbol.for("@ipld/js-cid/CID"),T4={...Bn,...Cn,...Nn,...xn,...In,...Rn,...Pn,...kn,...Dn,...Tn};function R4(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const P4=Symbol.for("nodejs.util.inspect.custom"),D4=Object.values(T4).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),T4.identity.decoder),N4=114,B4=36,U4=37;class L4{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=c6.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return A4.createV1(N4,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return R4(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){if(t=t??D4,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=d4(c6.decode(`z${e}`));return e.startsWith("12D")?new O4({multihash:t}):e.startsWith("16U")?new q4({multihash:t}):new M4({multihash:t})}return K4(D4.decode(e))}(e).equals(this);if(null!=e?.multihash?.bytes)return R4(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[P4](){return`PeerId(${this.toString()})`}}class M4 extends L4{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class O4 extends L4{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class q4 extends L4{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function K4(e){try{const t=d4(e);if(t.code===g4.code){if(t.digest.length===B4)return new O4({multihash:t});if(t.digest.length===U4)return new q4({multihash:t})}if(t.code===w4.code)return new M4({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==N4)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===w4.code)return new M4({multihash:e.multihash});if(t.code===g4.code){if(t.digest.length===B4)return new O4({multihash:e.multihash});if(t.digest.length===U4)return new q4({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(A4.decode(e))}throw new Error("Supplied PeerID CID is invalid")}var F4=__webpack_require__(7283);class V4{#o=[];enqueue(e,t){const r={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&this.#o[this.size-1].priority>=t.priority)return void this.#o.push(r);const n=function(e,t,r){let n=0,i=e.length;for(;i>0;){const s=Math.trunc(i/2);let o=n+s;r(e[o],t)<=0?(n=++o,i-=s+1):i=s}return n}(this.#o,r,((e,t)=>t.priority-e.priority));this.#o.splice(n,0,r)}dequeue(){const e=this.#o.shift();return e?.run}filter(e){return this.#o.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this.#o.length}}class z4 extends F4{#a;#c;#u=0;#l;#h;#d=0;#f;#p;#o;#g;#b=0;#y;#m;#w;timeout;constructor(e){if(super(),!("number"===typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:V4,...e}).intervalCap&&e.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??""}\` (${typeof e.intervalCap})`);if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??""}\` (${typeof e.interval})`);this.#a=e.carryoverConcurrencyCount,this.#c=e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,this.#l=e.intervalCap,this.#h=e.interval,this.#o=new e.queueClass,this.#g=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#w=!0===e.throwOnTimeout,this.#m=!1===e.autoStart}get#v(){return this.#c||this.#u<this.#l}get#_(){return this.#b<this.#y}#E(){this.#b--,this.#S(),this.emit("next")}#A(){this.#k(),this.#x(),this.#p=void 0}get#I(){const e=Date.now();if(void 0===this.#f){const t=this.#d-e;if(!(t<0))return void 0===this.#p&&(this.#p=setTimeout((()=>{this.#A()}),t)),!0;this.#u=this.#a?this.#b:0}return!1}#S(){if(0===this.#o.size)return this.#f&&clearInterval(this.#f),this.#f=void 0,this.emit("empty"),0===this.#b&&this.emit("idle"),!1;if(!this.#m){const e=!this.#I;if(this.#v&&this.#_){const t=this.#o.dequeue();return!!t&&(this.emit("active"),t(),e&&this.#x(),!0)}}return!1}#x(){this.#c||void 0!==this.#f||(this.#f=setInterval((()=>{this.#k()}),this.#h),this.#d=Date.now()+this.#h)}#k(){0===this.#u&&0===this.#b&&this.#f&&(clearInterval(this.#f),this.#f=void 0),this.#u=this.#a?this.#b:0,this.#C()}#C(){for(;this.#S(););}get concurrency(){return this.#y}set concurrency(e){if(!("number"===typeof e&&e>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#y=e,this.#C()}async#T(e){return new Promise(((t,r)=>{e.addEventListener("abort",(()=>{r(e.reason)}),{once:!0})}))}async add(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return t={timeout:this.timeout,throwOnTimeout:this.#w,...t},new Promise(((r,n)=>{this.#o.enqueue((async()=>{this.#b++,this.#u++;try{t.signal?.throwIfAborted();let n=e({signal:t.signal});t.timeout&&(n=Jh(Promise.resolve(n),{milliseconds:t.timeout})),t.signal&&(n=Promise.race([n,this.#T(t.signal)]));const i=await n;r(i),this.emit("completed",i)}catch(i){if(i instanceof Gh&&!t.throwOnTimeout)return void r();n(i),this.emit("error",i)}finally{this.#E()}}),t),this.emit("add"),this.#S()}))}async addAll(e,t){return Promise.all(e.map((async e=>this.add(e,t))))}start(){return this.#m?(this.#m=!1,this.#C(),this):this}pause(){this.#m=!0}clear(){this.#o=new this.#g}async onEmpty(){0!==this.#o.size&&await this.#R("empty")}async onSizeLessThan(e){this.#o.size<e||await this.#R("next",(()=>this.#o.size<e))}async onIdle(){0===this.#b&&0===this.#o.size||await this.#R("idle")}async#R(e,t){return new Promise((r=>{const n=()=>{t&&!t()||(this.off(e,n),r())};this.on(e,n)}))}get size(){return this.#o.size}sizeBy(e){return this.#o.filter(e).length}get pending(){return this.#b}get isPaused(){return this.#m}}const $4={},H4=e=>{e.addEventListener("message",(t=>{H4.dispatchEvent("message",e,t)})),null!=e.port&&e.port.addEventListener("message",(t=>{H4.dispatchEvent("message",e,t)}))};H4.addEventListener=(e,t)=>{null==$4[e]&&($4[e]=[]),$4[e].push(t)},H4.removeEventListener=(e,t)=>{null!=$4[e]&&($4[e]=$4[e].filter((e=>e===t)))},H4.dispatchEvent=function(e,t,r){null!=$4[e]&&$4[e].forEach((e=>e(t,r)))};const j4=H4,G4="lock:worker:request-read",W4="lock:worker:release-read",Y4="lock:master:grant-read",Q4="lock:worker:request-write",J4="lock:worker:release-write",X4="lock:master:grant-write",Z4=(e,t,r,n,i)=>(s,o)=>{if(o.data.type!==r)return;const a={type:o.data.type,name:o.data.name,identifier:o.data.identifier};e.dispatchEvent(new MessageEvent(t,{data:{name:a.name,handler:async()=>{s.postMessage({type:i,name:a.name,identifier:a.identifier}),await new Promise((e=>{const t=r=>{if(null==r||null==r.data)return;const i=r.data.type,o=(r.data.name,r.data.identifier);i===n&&o===a.identifier&&(s.removeEventListener("message",t),e())};s.addEventListener("message",t)}))}}}))},e5=(e,t,r,n)=>async()=>{const i=Math.random().toString().substring(2);return globalThis.postMessage({type:t,identifier:i,name:e}),new Promise((t=>{const s=o=>{if(null==o||null==o.data)return;const a=o.data.type,c=o.data.identifier;a===r&&c===i&&(globalThis.removeEventListener("message",s),t((()=>{globalThis.postMessage({type:n,identifier:i,name:e})})))};globalThis.addEventListener("message",s)}))},t5={singleProcess:!1},r5={};let n5;async function i5(e,t){let r;const n=new Promise((e=>{r=e}));return e.add((async()=>Jh((async()=>{await new Promise((e=>{r((()=>{e()}))}))})(),{milliseconds:t.timeout}))),n}const s5={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function o5(e){const t=Object.assign({},s5,e);return null==n5&&(n5=(e=>{if(e=Object.assign({},t5,e),Boolean(globalThis.document)||e.singleProcess){const e=new EventTarget;return j4.addEventListener("message",Z4(e,"requestReadLock",G4,W4,Y4)),j4.addEventListener("message",Z4(e,"requestWriteLock",Q4,J4,X4)),e}return{isWorker:!0,readLock:e=>e5(e,G4,Y4,W4),writeLock:e=>e5(e,Q4,X4,J4)}})(t),!0!==n5.isWorker&&(n5.addEventListener("requestReadLock",(e=>{null!=r5[e.data.name]&&r5[e.data.name].readLock().then((async t=>e.data.handler().finally((()=>{t()}))))})),n5.addEventListener("requestWriteLock",(async e=>{null!=r5[e.data.name]&&r5[e.data.name].writeLock().then((async t=>e.data.handler().finally((()=>{t()}))))})))),null==r5[t.name]&&(r5[t.name]=((e,t)=>{if(!0===n5.isWorker)return{readLock:n5.readLock(e,t),writeLock:n5.writeLock(e,t)};const r=new z4({concurrency:1});let n;return{async readLock(){if(null!=n)return i5(n,t);n=new z4({concurrency:t.concurrency,autoStart:!1});const e=n,i=i5(n,t);return r.add((async()=>{e.start(),await e.onIdle().then((()=>{n===e&&(n=null)}))})),i},writeLock:async()=>(n=null,i5(r,t))}})(t.name,t)),r5[t.name]}const a5={ERR_INVALID_PARAMETERS:"ERR_INVALID_PARAMETERS"},c5=new Float32Array([-0]),u5=new Uint8Array(c5.buffer);function l5(e,t,r){c5[0]=e,t[r]=u5[0],t[r+1]=u5[1],t[r+2]=u5[2],t[r+3]=u5[3]}const h5=new Float64Array([-0]),d5=new Uint8Array(h5.buffer);function f5(e,t,r){h5[0]=e,t[r]=d5[0],t[r+1]=d5[1],t[r+2]=d5[2],t[r+3]=d5[3],t[r+4]=d5[4],t[r+5]=d5[5],t[r+6]=d5[6],t[r+7]=d5[7]}const p5=BigInt(Number.MAX_SAFE_INTEGER),g5=BigInt(Number.MIN_SAFE_INTEGER);class b5{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return y5;if(e<p5&&e>g5)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>m5&&(n=0n,++r>m5&&(r=0n))),new b5(Number(n),Number(r))}static fromNumber(e){if(0===e)return y5;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new b5(r,n)}static from(e){return"number"===typeof e?b5.fromNumber(e):"bigint"===typeof e?b5.fromBigInt(e):"string"===typeof e?b5.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new b5(e.low>>>0,e.high>>>0):y5}}const y5=new b5(0,0);y5.toBigInt=function(){return 0n},y5.zzEncode=y5.zzDecode=function(){return this},y5.length=function(){return 1};const m5=4294967296n;function w5(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function v5(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function _5(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class E5{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,v5(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw v5(this,4);return _5(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw v5(this,4);return 0|_5(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw v5(this,4);const e=(t=this.buf,r=this.pos,u5[0]=t[r],u5[1]=t[r+1],u5[2]=t[r+2],u5[3]=t[r+3],c5[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw v5(this,4);const e=(t=this.buf,r=this.pos,d5[0]=t[r],d5[1]=t[r+1],d5[2]=t[r+2],d5[3]=t[r+3],d5[4]=t[r+4],d5[5]=t[r+5],d5[6]=t[r+6],d5[7]=t[r+7],h5[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw v5(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw v5(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw v5(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new b5(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw v5(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw v5(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw v5(this,8);const e=_5(this.buf,this.pos+=4),t=_5(this.buf,this.pos+=4);return new b5(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 S5(e,t,r){const n=function(e){return new E5(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}function A5(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function k5(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const x5=k5("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),I5=k5("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=A5((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),C5={utf8:x5,"utf-8":x5,hex:T4.base16,latin1:I5,ascii:I5,binary:I5,...T4};function T5(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=C5[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}class R5{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function P5(){}class D5{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const N5=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return A5(e);i+e>t&&(n=A5(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class B5{len;head;tail;states;constructor(){this.len=0,this.head=new R5(P5,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new R5(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new M5((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(O5,10,b5.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=b5.fromBigInt(e);return this._push(O5,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=b5.fromBigInt(e).zzEncode();return this._push(O5,t.length(),t)}sint64Number(e){const t=b5.fromNumber(e).zzEncode();return this._push(O5,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(U5,1,e?1:0)}fixed32(e){return this._push(q5,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=b5.fromBigInt(e);return this._push(q5,4,t.lo)._push(q5,4,t.hi)}fixed64Number(e){const t=b5.fromNumber(e);return this._push(q5,4,t.lo)._push(q5,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(l5,4,e)}double(e){return this._push(f5,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(U5,1,0):this.uint32(t)._push(K5,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(w5,t,e):this._push(U5,1,0)}fork(){return this.states=new D5(this),this.head=this.tail=new R5(P5,0,0),this.len=0,this}reset(){return null!=this.states?(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 R5(P5,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?A5(r):N5(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function U5(e,t,r){t[r]=255&e}function L5(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class M5 extends R5{next;constructor(e,t){super(L5,e,t),this.next=void 0}}function O5(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function q5(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function K5(e,t,r){t.set(e,r)}function F5(e,t,r){t.set(e,r)}function V5(e,t,r){e.length<40?w5(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(T5(e),r)}function z5(e,t){const r=new B5;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var $5,H5,j5,G5;function W5(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",$5.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(B5.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(F5,t,e),this},B5.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(V5,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}($5||($5={}));Error;function Y5(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=C5[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}function Q5(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=A5(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}!function(e){let t,r,n;!function(e){let t;e.codec=()=>(null==t&&(t=W5((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.key&&""!==e.key&&(t.uint32(10),t.string(e.key)),null!=e.value&&e.value.byteLength>0&&(t.uint32(18),t.bytes(e.value)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={key:"",value:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.key=e.string();break;case 2:r.value=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>z5(t,e.codec()),e.decode=t=>S5(t,e.codec())}(t=e.Peer$metadataEntry||(e.Peer$metadataEntry={})),function(e){let t;e.codec=()=>(null==t&&(t=W5((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.key&&""!==e.key&&(t.uint32(10),t.string(e.key)),null!=e.value&&(t.uint32(18),G5.codec().encode(e.value,t)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={key:""},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.key=e.string();break;case 2:r.value=G5.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>z5(t,e.codec()),e.decode=t=>S5(t,e.codec())}(r=e.Peer$tagsEntry||(e.Peer$tagsEntry={})),e.codec=()=>(null==n&&(n=W5((function(t,r){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&r.fork(),null!=t.addresses)for(const e of t.addresses)r.uint32(10),j5.codec().encode(e,r);if(null!=t.protocols)for(const e of t.protocols)r.uint32(18),r.string(e);if(null!=t.publicKey&&(r.uint32(34),r.bytes(t.publicKey)),null!=t.peerRecordEnvelope&&(r.uint32(42),r.bytes(t.peerRecordEnvelope)),null!=t.metadata&&0!==t.metadata.size)for(const[i,s]of t.metadata.entries())r.uint32(50),e.Peer$metadataEntry.codec().encode({key:i,value:s},r);if(null!=t.tags&&0!==t.tags.size)for(const[i,s]of t.tags.entries())r.uint32(58),e.Peer$tagsEntry.codec().encode({key:i,value:s},r);!1!==n.lengthDelimited&&r.ldelim()}),((t,r)=>{const n={addresses:[],protocols:[],metadata:new Map,tags:new Map},i=null==r?t.len:t.pos+r;for(;t.pos<i;){const r=t.uint32();switch(r>>>3){case 1:n.addresses.push(j5.codec().decode(t,t.uint32()));break;case 2:n.protocols.push(t.string());break;case 4:n.publicKey=t.bytes();break;case 5:n.peerRecordEnvelope=t.bytes();break;case 6:{const r=e.Peer$metadataEntry.codec().decode(t,t.uint32());n.metadata.set(r.key,r.value);break}case 7:{const r=e.Peer$tagsEntry.codec().decode(t,t.uint32());n.tags.set(r.key,r.value);break}default:t.skipType(7&r)}}return n}))),n),e.encode=t=>z5(t,e.codec()),e.decode=t=>S5(t,e.codec())}(H5||(H5={})),function(e){let t;e.codec=()=>(null==t&&(t=W5((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.multiaddr&&e.multiaddr.byteLength>0&&(t.uint32(10),t.bytes(e.multiaddr)),null!=e.isCertified&&(t.uint32(16),t.bool(e.isCertified)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={multiaddr:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.multiaddr=e.bytes();break;case 2:r.isCertified=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>z5(t,e.codec()),e.decode=t=>S5(t,e.codec())}(j5||(j5={})),function(e){let t;e.codec=()=>(null==t&&(t=W5((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.value&&0!==e.value&&(t.uint32(8),t.uint32(e.value)),null!=e.expiry&&(t.uint32(16),t.uint64(e.expiry)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={value:0},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.value=e.uint32();break;case 2:r.expiry=e.uint64();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>z5(t,e.codec()),e.decode=t=>S5(t,e.codec())}(G5||(G5={}));const J5=Ex,X5=Sx,Z5=function(e){let t=0;if(e=e.toString().trim(),J5(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(X5(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;J5(r[n])&&(e=Z5(r[n]),r[n]=Y5(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,Y5(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},e8=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(4===r){const n=[];for(let i=0;i<r;i++)n.push(e[t+i]);return n.join(".")}if(16===r){const e=[];for(let i=0;i<r;i+=2)e.push(n.getUint16(t+i).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},t8=-1,r8={},n8={};function i8(e){if("number"===typeof e){if(null!=n8[e])return n8[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=r8[e])return r8[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,t8,"ip6zone"],[43,8,"ipcidr"],[53,t8,"dns",!0],[54,t8,"dns4",!0],[55,t8,"dns6",!0],[56,t8,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,t8,"unix",!1,!0],[421,t8,"ipfs"],[421,t8,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,t8,"garlic64"],[448,0,"tls"],[449,t8,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,t8,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,t8,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);n8[t.code]=t,r8[t.name]=t}));i8("ip4"),i8("ip6"),i8("ipcidr");function s8(e,t){switch(i8(e).code){case 4:case 41:return function(e){const t=e8(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Ax(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return f8(t);case 6:case 273:case 33:case 132:return h8(t).toString();case 421:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return Y5(r,"base58btc")}(t);case 444:case 445:return p8(t);case 466:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+Y5(r,"base64url")}(t);default:return Y5(t,"base16")}}function o8(e,t){switch(i8(e).code){case 4:case 41:return u8(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return d8(t);case 6:case 273:case 33:case 132:return l8(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?d4(c6.decode(`z${e}`)).bytes:A4.parse(e).multihash.bytes;const r=Uint8Array.from(ms(t.length));return Q5([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(16!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=m6.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=l8(n);return Q5([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(56!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=m6.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=l8(n);return Q5([r,i],r.length+i.length)}(t);case 466:return function(e){const t=c8.decode(e),r=Uint8Array.from(ms(t.length));return Q5([r,t],r.length+t.length)}(t);default:return T5(t,"base16")}}const a8=Object.values(T4).map((e=>e.decoder)),c8=function(){let e=a8[0].or(a8[1]);return a8.slice(2).forEach((t=>e=e.or(t))),e}();function u8(e){if(!Ax(e))throw new Error("invalid ip address");return Z5(e)}function l8(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function h8(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function d8(e){const t=T5(e),r=Uint8Array.from(ms(t.length));return Q5([r,t],r.length+t.length)}function f8(e){const t=ws(e);if((e=e.slice(gs(t))).length!==t)throw new Error("inconsistent lengths");return Y5(e)}function p8(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return`${Y5(t,"base32")}:${h8(r)}`}function g8(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const s=ws(e,i),o=gs(s),a=i8(s),c=m8(a,e.slice(i+o));if(0===c){t.push([s]),r.push([s]),i+=o;continue}const u=e.slice(i+o,i+o+c);if(i+=c+o,i>e.length)throw v8("Invalid address Uint8Array: "+Y5(e,"base16"));t.push([s,u]);const l=s8(s,u);if(r.push([s,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:b8(r),tuples:t,stringTuples:r,path:n}}function b8(e){const t=[];return e.map((e=>{const r=i8(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),w8(t.join("/"))}function y8(e){return Q5(e.map((e=>{const t=i8(e[0]);let r=Uint8Array.from(ms(t.code));return e.length>1&&null!=e[1]&&(r=Q5([r,e[1]])),r})))}function m8(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=ws(t instanceof Uint8Array?t:Uint8Array.from(t));return e+gs(e)}}function w8(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function v8(e){return new Error("Error parsing address: "+e)}const _8=Symbol.for("nodejs.util.inspect.custom"),E8=Symbol.for("@multiformats/js-multiaddr/multiaddr"),S8=[i8("dns").code,i8("dns4").code,i8("dns6").code,i8("dnsaddr").code];class A8{bytes;#t;#r;#n;#i;[E8]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=g8(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);t=function(e){const t=[],r=[];let n=null;const i=(e=w8(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){const o=i8(i[s]);if(0===o.size){t.push([o.code]),r.push([o.code]);continue}if(s++,s>=i.length)throw v8("invalid address: "+e);if(!0===o.path){n=w8(i.slice(s).join("/")),t.push([o.code,o8(o.code,n)]),r.push([o.code,n]);break}const a=o8(o.code,i[s]);t.push([o.code,a]),r.push([o.code,s8(o.code,a)])}return{string:b8(r),bytes:y8(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!x8(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=g8(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#r=t.tuples,this.#n=t.stringTuples,this.#i=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const s=i8("tcp"),o=i8("udp"),a=i8("ip4"),c=i8("ip6"),u=i8("dns6"),l=i8("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i=`%${d??""}`),S8.includes(h)&&(t=s.name,n=443,r=`${d??""}${i}`,e=h===u.code?6:4),h!==s.code&&h!==o.code||(t=i8(h).name,n=parseInt(d??"")),h!==a.code&&h!==c.code||(t=i8(h).name,r=`${d??""}${i}`,e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return this.#r.map((e=>{let[t]=e;return Object.assign({},i8(t))}))}protoCodes(){return this.#r.map((e=>{let[t]=e;return t}))}protoNames(){return this.#r.map((e=>{let[t]=e;return i8(t).name}))}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new A8(e),new A8(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new A8(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new A8(y8(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===r8.p2p.code&&e.push([r,n]),r===r8["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?Y5(c6.decode(`z${e}`),"base58btc"):Y5(A4.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#i}equals(e){return R4(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=k8.get(t.name);if(null==r)throw new Xp(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>I8(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(e??this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[_8](){return`Multiaddr(${this.#t})`}}const k8=new Map;function x8(e){return Boolean(e?.[E8])}function I8(e){return new A8(e)}function C8(e,t){const r=H5.decode(t);null!=r.publicKey&&null==e.publicKey&&(e=function(e){if("RSA"===e.type)return new M4(e);if("Ed25519"===e.type)return new O4(e);if("secp256k1"===e.type)return new q4(e);throw new Xp("Not a PeerId","ERR_INVALID_PARAMETERS")}({...e,publicKey:e.publicKey}));const n=new Map,i=BigInt(Date.now());for(const[s,o]of r.tags.entries())null!=o.expiry&&o.expiry<i||n.set(s,o);return{...r,id:e,addresses:r.addresses.map((e=>{let{multiaddr:t,isCertified:r}=e;return{multiaddr:I8(t),isCertified:r??!1}})),metadata:r.metadata,peerRecordEnvelope:r.peerRecordEnvelope??void 0,tags:n}}new Uint8Array(0);function T8(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var R8=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const P8=R8;class D8{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class N8{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return U8(this,e)}}class B8{decoders;constructor(e){this.decoders=e}or(e){return U8(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function U8(e,t){return new B8({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class L8{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new D8(e,t,r),this.decoder=new N8(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function M8(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new L8(t,r,n,i)}function O8(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=P8(n,t);return M8({prefix:r,name:t,encode:i,decode:e=>T8(s(e))})}function q8(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return M8({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const K8=O8({prefix:"9",name:"base10",alphabet:"0123456789"}),F8=q8({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),V8=q8({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),z8=q8({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),$8=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),H8=$8.reduce(((e,t,r)=>(e[r]=t,e)),[]),j8=$8.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const G8=M8({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=H8[t]),"")},decode:function(e){const t=[];for(const r of e){const e=j8[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),W8=q8({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Y8=q8({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Q8=q8({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),J8=q8({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),X8=q8({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Z8=q8({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),e7=q8({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),t7=q8({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),r7=q8({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),n7=O8({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),i7=O8({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),s7=O8({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),o7=O8({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),a7=q8({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c7=q8({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),u7=q8({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),l7=q8({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),h7=q8({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),d7=M8({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),f7=new TextEncoder,p7=new TextDecoder,g7="json",b7=512;function y7(e){return f7.encode(JSON.stringify(e))}function m7(e){return JSON.parse(p7.decode(e))}const w7="raw",v7=85;function _7(e){return T8(e)}function E7(e){return T8(e)}var S7=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=x7;)r[n++]=255&t|A7,t/=128;for(;t&k7;)r[n++]=255&t|A7,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},A7=128,k7=-128,x7=Math.pow(2,31);var I7=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&T7)<<s:(n&T7)*Math.pow(2,s),s+=7}while(n>=C7);return e.bytes=o-r,i},C7=128,T7=127;var R7=Math.pow(2,7),P7=Math.pow(2,14),D7=Math.pow(2,21),N7=Math.pow(2,28),B7=Math.pow(2,35),U7=Math.pow(2,42),L7=Math.pow(2,49),M7=Math.pow(2,56),O7=Math.pow(2,63);const q7={encode:S7,decode:I7,encodingLength:function(e){return e<R7?1:e<P7?2:e<D7?3:e<N7?4:e<B7?5:e<U7?6:e<L7?7:e<M7?8:e<O7?9:10}};function K7(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return q7.encode(e,t,r),t}function F7(e){return q7.encodingLength(e)}function V7(e,t){const r=t.byteLength,n=F7(e),i=n+F7(r),s=new Uint8Array(i+r);return K7(e,s,0),K7(r,s,n),s.set(t,i),new z7(e,r,t,s)}class z7{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const $7=T8;const H7={code:0,name:"identity",encode:$7,digest:function(e){return V7(0,$7(e))}};function j7(e){let{name:t,code:r,encode:n}=e;return new G7(t,r,n)}class G7{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?V7(this.code,t):t.then((e=>V7(this.code,e)))}throw Error("Unknown type, must be binary type")}}function W7(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Y7=j7({name:"sha2-256",code:18,encode:W7("SHA-256")}),Q7=j7({name:"sha2-512",code:19,encode:W7("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const J7={...Wn,...Fn,...Gn,...qn,...Kn,...zn,...$n,...Hn,...jn,...Vn};function X7(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Z7=X7("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),e9=X7("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),t9={utf8:Z7,"utf-8":Z7,hex:J7.base16,latin1:e9,ascii:e9,binary:e9,...J7};const r9="/",n9=(new TextEncoder).encode(r9),i9=n9[0];class s9{_buf;constructor(e,t){if("string"===typeof e)this._buf=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=t9[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}(e);else{if(!(e instanceof Uint8Array))throw new Error("Invalid key, should be String of Uint8Array");this._buf=e}if(null==t&&(t=!0),t&&this.clean(),0===this._buf.byteLength||this._buf[0]!==i9)throw new Error("Invalid key")}toString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf8";return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=t9[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new s9(e.join(r9))}static random(){return new s9(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||"string"===typeof e?new s9(e):"function"===typeof e.uint8Array?new s9(e.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=n9),this._buf[0]!==i9){const e=new Uint8Array(this._buf.byteLength+1);e.fill(i9,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===i9;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),r=e.list();for(let n=0;n<t.length;n++){if(r.length<n+1)return!1;const e=t[n],i=r[n];if(e<i)return!0;if(e>i)return!1}return t.length<r.length}reverse(){return s9.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(r9).slice(1)}type(){return function(e){const t=e.split(":");if(t.length<2)return"";return t.slice(0,-1).join(":")}(this.baseNamespace())}name(){return function(e){const t=e.split(":");return t[t.length-1]}(this.baseNamespace())}instance(e){return new s9(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(r9)||(e+=r9),e+=this.type(),new s9(e)}parent(){const e=this.list();return 1===e.length?new s9(r9):new s9(e.slice(0,-1).join(r9))}child(e){return this.toString()===r9?e:e.toString()===r9?this:new s9(this.toString()+e.toString(),!1)}isAncestorOf(e){return e.toString()!==this.toString()&&e.toString().startsWith(this.toString())}isDecendantOf(e){return e.toString()!==this.toString()&&this.toString().startsWith(e.toString())}isTopLevel(){return 1===this.list().length}concat(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return s9.withNamespaces([...this.namespaces(),...(n=t.map((e=>e.namespaces())),[].concat(...n))]);var n}}const o9="/peers/";function a9(e){if(!_m(e)||null==e.type)throw new Xp("Invalid PeerId",a5.ERR_INVALID_PARAMETERS);const t=e.toCID().toString();return new s9(`${o9}${t}`)}async function c9(e,t,r){const n=new Map;for(const i of r){if(null==i)continue;if(i.multiaddr instanceof Uint8Array&&(i.multiaddr=I8(i.multiaddr)),!x8(i.multiaddr))throw new Xp("Multiaddr was invalid",a5.ERR_INVALID_PARAMETERS);if(!await t(e,i.multiaddr))continue;const r=i.isCertified??!1,s=i.multiaddr.toString(),o=n.get(s);null!=o?i.isCertified=o.isCertified||r:n.set(s,{multiaddr:i.multiaddr,isCertified:r})}return[...n.values()].sort(((e,t)=>e.multiaddr.toString().localeCompare(t.multiaddr.toString()))).map((e=>{let{isCertified:t,multiaddr:r}=e;return{isCertified:t,multiaddr:r.bytes}}))}async function u9(e,t,r,n){if(null==t)throw new Xp("Invalid PeerData",a5.ERR_INVALID_PARAMETERS);if(null!=t.publicKey&&null!=e.publicKey&&!R4(t.publicKey,e.publicKey))throw new Xp("publicKey bytes do not match peer id publicKey bytes",a5.ERR_INVALID_PARAMETERS);const i=n.existingPeer;if(null!=i&&!e.equals(i.id))throw new Xp("peer id did not match existing peer id",a5.ERR_INVALID_PARAMETERS);let s=i?.addresses??[],o=new Set(i?.protocols??[]),a=i?.metadata??new Map,c=i?.tags??new Map,u=i?.peerRecordEnvelope;if("patch"===r){if(null==t.multiaddrs&&null==t.addresses||(s=[],null!=t.multiaddrs&&s.push(...t.multiaddrs.map((e=>({isCertified:!1,multiaddr:e})))),null!=t.addresses&&s.push(...t.addresses)),null!=t.protocols&&(o=new Set(t.protocols)),null!=t.metadata){a=l9(t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata),{validate:h9})}if(null!=t.tags){c=l9(t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),{validate:d9,map:f9})}null!=t.peerRecordEnvelope&&(u=t.peerRecordEnvelope)}if("merge"===r){if(null!=t.multiaddrs&&s.push(...t.multiaddrs.map((e=>({isCertified:!1,multiaddr:e})))),null!=t.addresses&&s.push(...t.addresses),null!=t.protocols&&(o=new Set([...o,...t.protocols])),null!=t.metadata){const e=t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata);for(const[t,r]of e)null==r?a.delete(t):a.set(t,r);a=l9([...a.entries()],{validate:h9})}if(null!=t.tags){const e=t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),r=new Map(c);for(const[t,n]of e)null==n?r.delete(t):r.set(t,n);c=l9([...r.entries()],{validate:d9,map:f9})}null!=t.peerRecordEnvelope&&(u=t.peerRecordEnvelope)}const l={addresses:await c9(e,n.addressFilter??(async()=>!0),s),protocols:[...o.values()].sort(((e,t)=>e.localeCompare(t))),metadata:a,tags:c,publicKey:i?.id.publicKey??t.publicKey??e.publicKey,peerRecordEnvelope:u};return"RSA"!==e.type&&delete l.publicKey,l}function l9(e,t){const r=new Map;for(const[n,i]of e)null!=i&&t.validate(n,i);for(const[n,i]of e.sort(((e,t)=>{let[r]=e,[n]=t;return r.localeCompare(n)})))null!=i&&r.set(n,t.map?.(n,i)??i);return r}function h9(e,t){if("string"!==typeof e)throw new Xp("Metadata key must be a string",a5.ERR_INVALID_PARAMETERS);if(!(t instanceof Uint8Array))throw new Xp("Metadata value must be a Uint8Array",a5.ERR_INVALID_PARAMETERS)}function d9(e,t){if("string"!==typeof e)throw new Xp("Tag name must be a string",a5.ERR_INVALID_PARAMETERS);if(null!=t.value){if(parseInt(`${t.value}`,10)!==t.value)throw new Xp("Tag value must be an integer",a5.ERR_INVALID_PARAMETERS);if(t.value<0||t.value>100)throw new Xp("Tag value must be between 0-100",a5.ERR_INVALID_PARAMETERS)}if(null!=t.ttl){if(parseInt(`${t.ttl}`,10)!==t.ttl)throw new Xp("Tag ttl must be an integer",a5.ERR_INVALID_PARAMETERS);if(t.ttl<0)throw new Xp("Tag ttl must be between greater than 0",a5.ERR_INVALID_PARAMETERS)}}function f9(e,t){let r;return null!=t.expiry&&(r=t.expiry),null!=t.ttl&&(r=BigInt(Date.now()+Number(t.ttl))),{value:t.value??0,expiry:r}}function p9(e,t,r){const n=e.toString().split("/")[2],i=K4(m6.decode(n)),s=r.get(i);if(null!=s)return s;const o=C8(i,t);return r.set(i,o),o}class g9{peerId;datastore;lock;addressFilter;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.peerId=e.peerId,this.datastore=e.datastore,this.addressFilter=t.addressFilter,this.lock=o5({name:"peer-store",singleProcess:!0})}async has(e){return this.datastore.has(a9(e))}async delete(e){if(this.peerId.equals(e))throw new Xp("Cannot delete self peer",a5.ERR_INVALID_PARAMETERS);await this.datastore.delete(a9(e))}async load(e){return C8(e,await this.datastore.get(a9(e)))}async save(e,t){const{existingBuf:r,existingPeer:n}=await this.#P(e),i=await u9(e,t,"patch",{addressFilter:this.addressFilter});return this.#D(e,i,r,n)}async patch(e,t){const{existingBuf:r,existingPeer:n}=await this.#P(e),i=await u9(e,t,"patch",{addressFilter:this.addressFilter,existingPeer:n});return this.#D(e,i,r,n)}async merge(e,t){const{existingBuf:r,existingPeer:n}=await this.#P(e),i=await u9(e,t,"merge",{addressFilter:this.addressFilter,existingPeer:n});return this.#D(e,i,r,n)}async*all(e){const t=new Q3;for await(const{key:r,value:n}of this.datastore.query(function(e,t){return null==e?{}:{prefix:o9,filters:(e.filters??[]).map((e=>r=>{let{key:n,value:i}=r;return e(p9(n,i,t))})),orders:(e.orders??[]).map((e=>(r,n)=>e(p9(r.key,r.value,t),p9(n.key,n.value,t))))}}(e??{},t))){const e=p9(r,n,t);e.id.equals(this.peerId)||(yield e)}}async#P(e){try{const t=await this.datastore.get(a9(e));return{existingBuf:t,existingPeer:C8(e,t)}}catch(t){if("ERR_NOT_FOUND"!==t.code)throw t}return{}}async#D(e,t,r,n){const i=H5.encode(t);return null!=r&&R4(i,r)?{peer:C8(e,i),previous:n,updated:!1}:(await this.datastore.put(a9(e),i),{peer:C8(e,i),previous:n,updated:!0})}}class b9{store;events;peerId;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.log=e.logger.forComponent("libp2p:peer-store"),this.events=e.events,this.peerId=e.peerId,this.store=new g9(e,t)}async forEach(e,t){this.log.trace("forEach await read lock");const r=await this.store.lock.readLock();this.log.trace("forEach got read lock");try{for await(const r of this.store.all(t))e(r)}finally{this.log.trace("forEach release read lock"),r()}}async all(e){this.log.trace("all await read lock");const t=await this.store.lock.readLock();this.log.trace("all got read lock");try{return await Hl(this.store.all(e))}finally{this.log.trace("all release read lock"),t()}}async delete(e){this.log.trace("delete await write lock");const t=await this.store.lock.writeLock();this.log.trace("delete got write lock");try{await this.store.delete(e)}finally{this.log.trace("delete release write lock"),t()}}async has(e){this.log.trace("has await read lock");const t=await this.store.lock.readLock();this.log.trace("has got read lock");try{return await this.store.has(e)}finally{this.log.trace("has release read lock"),t()}}async get(e){this.log.trace("get await read lock");const t=await this.store.lock.readLock();this.log.trace("get got read lock");try{return await this.store.load(e)}finally{this.log.trace("get release read lock"),t()}}async save(e,t){this.log.trace("save await write lock");const r=await this.store.lock.writeLock();this.log.trace("save got write lock");try{const r=await this.store.save(e,t);return this.#N(e,r),r.peer}finally{this.log.trace("save release write lock"),r()}}async patch(e,t){this.log.trace("patch await write lock");const r=await this.store.lock.writeLock();this.log.trace("patch got write lock");try{const r=await this.store.patch(e,t);return this.#N(e,r),r.peer}finally{this.log.trace("patch release write lock"),r()}}async merge(e,t){this.log.trace("merge await write lock");const r=await this.store.lock.writeLock();this.log.trace("merge got write lock");try{const r=await this.store.merge(e,t);return this.#N(e,r),r.peer}finally{this.log.trace("merge release write lock"),r()}}async consumePeerRecord(e,t){const r=await EL.openAndCertify(e,vN.DOMAIN);if(!1===t?.equals(r.peerId))return this.log("envelope peer id was not the expected peer id - expected: %p received: %p",t,r.peerId),!1;const n=vN.createFromProtobuf(r.payload);let i;try{i=await this.get(r.peerId)}catch(s){if("ERR_NOT_FOUND"!==s.code)throw s}if(null!=i?.peerRecordEnvelope){const e=await EL.createFromProtobuf(i.peerRecordEnvelope),t=vN.createFromProtobuf(e.payload);if(t.seqNumber>=n.seqNumber)return this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",t.seqNumber,n.seqNumber),!1}return await this.patch(n.peerId,{peerRecordEnvelope:e,addresses:n.multiaddrs.map((e=>({isCertified:!0,multiaddr:e})))}),!0}#N(e,t){t.updated&&(this.peerId.equals(e)?this.events.safeDispatchEvent("self:peer:update",{detail:t}):this.events.safeDispatchEvent("peer:update",{detail:t}))}}const y9=Ex,m9=Sx,w9=function(e){let t=0;if(e=e.toString().trim(),y9(e)){const r=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{r[t++]=255&parseInt(e,10)})),r}if(m9(e)){const r=e.split(":",8);let n;for(n=0;n<r.length;n++){let e;y9(r[n])&&(e=w9(r[n]),r[n]=$J(e.slice(0,2),"base16")),null!=e&&++n<8&&r.splice(n,0,$J(e.slice(2,4),"base16"))}if(""===r[0])for(;r.length<8;)r.unshift("0");else if(""===r[r.length-1])for(;r.length<8;)r.push("0");else if(r.length<8){for(n=0;n<r.length&&""!==r[n];n++);const e=[n,1];for(n=9-r.length;n>0;n--)e.push("0");r.splice.apply(r,e)}const i=new Uint8Array(t+16);for(n=0;n<r.length;n++){const e=parseInt(r[n],16);i[t++]=e>>8&255,i[t++]=255&e}return i}throw new Error("invalid ip address")},v9=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2?arguments[2]:void 0;t=~~t,r=r??e.length-t;const n=new DataView(e.buffer);if(4===r){const n=[];for(let i=0;i<r;i++)n.push(e[t+i]);return n.join(".")}if(16===r){const e=[];for(let i=0;i<r;i+=2)e.push(n.getUint16(t+i).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""},_9=-1,E9={},S9={};function A9(e){if("number"===typeof e){if(null!=S9[e])return S9[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=E9[e])return E9[e];throw new Error(`no protocol with name: ${e}`)}throw new Error("invalid protocol id type: "+typeof e)}[[4,32,"ip4"],[6,16,"tcp"],[33,16,"dccp"],[41,128,"ip6"],[42,_9,"ip6zone"],[43,8,"ipcidr"],[53,_9,"dns",!0],[54,_9,"dns4",!0],[55,_9,"dns6",!0],[56,_9,"dnsaddr",!0],[132,16,"sctp"],[273,16,"udp"],[275,0,"p2p-webrtc-star"],[276,0,"p2p-webrtc-direct"],[277,0,"p2p-stardust"],[280,0,"webrtc-direct"],[281,0,"webrtc"],[290,0,"p2p-circuit"],[301,0,"udt"],[302,0,"utp"],[400,_9,"unix",!1,!0],[421,_9,"ipfs"],[421,_9,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,_9,"garlic64"],[448,0,"tls"],[449,_9,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,_9,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[777,_9,"memory"]].forEach((e=>{const t=function(e,t,r,n,i){return{code:e,size:t,name:r,resolvable:Boolean(n),path:Boolean(i)}}(...e);S9[t.code]=t,E9[t.name]=t}));A9("ip4"),A9("ip6"),A9("ipcidr");function k9(e,t){switch(A9(e).code){case 4:case 41:return function(e){const t=v9(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!Ax(t))throw new Error("invalid ip address");return t}(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return N9(t);case 6:case 273:case 33:case 132:return P9(t).toString();case 421:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return $J(r,"base58btc")}(t);case 444:case 445:return B9(t);case 466:return function(e){const t=ws(e),r=e.slice(gs(t));if(r.length!==t)throw new Error("inconsistent lengths");return"u"+$J(r,"base64url")}(t);default:return $J(t,"base16")}}function x9(e,t){switch(A9(e).code){case 4:case 41:return T9(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return D9(t);case 6:case 273:case 33:case 132:return R9(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?qY(bY.decode(`z${e}`)).bytes:NQ.parse(e).multihash.bytes;const r=Uint8Array.from(ms(t.length));return QQ([r,t],r.length+t.length)}(t);case 444:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(16!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion address.`);const r=nQ.decode("b"+t[0]),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=R9(n);return QQ([r,i],r.length+i.length)}(t);case 445:return function(e){const t=e.split(":");if(2!==t.length)throw new Error(`failed to parse onion addr: ["'${t.join('", "')}'"]' does not contain a port number`);if(56!==t[0].length)throw new Error(`failed to parse onion addr: ${t[0]} not a Tor onion3 address.`);const r=nQ.decode(`b${t[0]}`),n=parseInt(t[1],10);if(n<1||n>65536)throw new Error("Port number is not in range(1, 65536)");const i=R9(n);return QQ([r,i],r.length+i.length)}(t);case 466:return function(e){const t=C9.decode(e),r=Uint8Array.from(ms(t.length));return QQ([r,t],r.length+t.length)}(t);default:return $Q(t,"base16")}}const I9=Object.values(OQ).map((e=>e.decoder)),C9=function(){let e=I9[0].or(I9[1]);return I9.slice(2).forEach((t=>e=e.or(t))),e}();function T9(e){if(!Ax(e))throw new Error("invalid ip address");return w9(e)}function R9(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function P9(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function D9(e){const t=$Q(e),r=Uint8Array.from(ms(t.length));return QQ([r,t],r.length+t.length)}function N9(e){const t=ws(e);if((e=e.slice(gs(t))).length!==t)throw new Error("inconsistent lengths");return $J(e)}function B9(e){const t=e.slice(0,e.length-2),r=e.slice(e.length-2);return`${$J(t,"base32")}:${P9(r)}`}function U9(e){const t=[],r=[];let n=null,i=0;for(;i<e.length;){const s=ws(e,i),o=gs(s),a=A9(s),c=O9(a,e.slice(i+o));if(0===c){t.push([s]),r.push([s]),i+=o;continue}const u=e.slice(i+o,i+o+c);if(i+=c+o,i>e.length)throw K9("Invalid address Uint8Array: "+$J(e,"base16"));t.push([s,u]);const l=k9(s,u);if(r.push([s,l]),!0===a.path){n=l;break}}return{bytes:Uint8Array.from(e),string:L9(r),tuples:t,stringTuples:r,path:n}}function L9(e){const t=[];return e.map((e=>{const r=A9(e[0]);return t.push(r.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),q9(t.join("/"))}function M9(e){return QQ(e.map((e=>{const t=A9(e[0]);let r=Uint8Array.from(ms(t.code));return e.length>1&&null!=e[1]&&(r=QQ([r,e[1]])),r})))}function O9(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=ws(t instanceof Uint8Array?t:Uint8Array.from(t));return e+gs(e)}}function q9(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function K9(e){return new Error("Error parsing address: "+e)}const F9=Symbol.for("nodejs.util.inspect.custom"),V9=Symbol.for("@multiformats/js-multiaddr/multiaddr"),z9=[A9("dns").code,A9("dns4").code,A9("dns6").code,A9("dnsaddr").code];class $9{bytes;#t;#r;#n;#i;[V9]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=U9(e);else if("string"===typeof e){if(e.length>0&&"/"!==e.charAt(0))throw new Error(`multiaddr "${e}" must start with a "/"`);t=function(e){const t=[],r=[];let n=null;const i=(e=q9(e)).split("/").slice(1);if(1===i.length&&""===i[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let s=0;s<i.length;s++){const o=A9(i[s]);if(0===o.size){t.push([o.code]),r.push([o.code]);continue}if(s++,s>=i.length)throw K9("invalid address: "+e);if(!0===o.path){n=q9(i.slice(s).join("/")),t.push([o.code,x9(o.code,n)]),r.push([o.code,n]);break}const a=x9(o.code,i[s]);t.push([o.code,a]),r.push([o.code,k9(o.code,a)])}return{string:L9(r),bytes:M9(t),tuples:t,stringTuples:r,path:n}}(e)}else{if(!j9(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=U9(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#r=t.tuples,this.#n=t.stringTuples,this.#i=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,r,n,i="";const s=A9("tcp"),o=A9("udp"),a=A9("ip4"),c=A9("ip6"),u=A9("dns6"),l=A9("ip6zone");for(const[h,d]of this.stringTuples())h===l.code&&(i=`%${d??""}`),z9.includes(h)&&(t=s.name,n=443,r=`${d??""}${i}`,e=h===u.code?6:4),h!==s.code&&h!==o.code||(t=A9(h).name,n=parseInt(d??"")),h!==a.code&&h!==c.code||(t=A9(h).name,r=`${d??""}${i}`,e=h===c.code?6:4);if(null==e||null==t||null==r||null==n)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:r,transport:t,port:n}}protos(){return this.#r.map((e=>{let[t]=e;return Object.assign({},A9(t))}))}protoCodes(){return this.#r.map((e=>{let[t]=e;return t}))}protoNames(){return this.#r.map((e=>{let[t]=e;return A9(t).name}))}tuples(){return this.#r}stringTuples(){return this.#n}encapsulate(e){return e=new $9(e),new $9(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),r=this.toString(),n=r.lastIndexOf(t);if(n<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new $9(r.slice(0,n))}decapsulateCode(e){const t=this.tuples();for(let r=t.length-1;r>=0;r--)if(t[r][0]===e)return new $9(M9(t.slice(0,r)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[r,n]=t;r===E9.p2p.code&&e.push([r,n]),r===E9["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?$J(bY.decode(`z${e}`),"base58btc"):$J(NQ.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#i}equals(e){return WY(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const r=H9.get(t.name);if(null==r)throw new Xp(`no available resolver for ${t.name}`,"ERR_NO_AVAILABLE_RESOLVER");return(await r(this,e)).map((e=>G9(e)))}nodeAddress(){const e=this.toOptions();if("tcp"!==e.transport&&"udp"!==e.transport)throw new Error(`multiaddr must have a valid format - no protocol with name: "${e.transport}". Must have a valid transport protocol: "{tcp, udp}"`);return{family:e.family,address:e.host,port:e.port}}isThinWaistAddress(e){const t=(e??this).protos();return 2===t.length&&((4===t[0].code||41===t[0].code)&&(6===t[1].code||273===t[1].code))}[F9](){return`Multiaddr(${this.#t})`}}const H9=new Map;function j9(e){return Boolean(e?.[V9])}function G9(e){return new $9(e)}const W9=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e);})();for(const t of e);};const Y9=function(e){const[t,r]=null!=e[Symbol.asyncIterator]?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>t.next(),push:e=>{n.push(e)},next:()=>n.length>0?{done:!1,value:n.shift()}:t.next(),[r](){return this}}};const Q9=function(e,t){if(null!=e[Symbol.asyncIterator])return async function*(){for await(const r of e)await t(r)&&(yield r)}();const r=Y9(e),{value:n,done:i}=r.next();if(!0===i)return function*(){}();const s=t(n);if("function"===typeof s.then)return async function*(){await s&&(yield n);for await(const e of r)await t(e)&&(yield e)}();const o=t;return function*(){!0===s&&(yield n);for(const e of r)o(e)&&(yield e)}()};const J9=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(){const r=await Hl(e);yield*r.sort(t)}():function*(){const r=Hl(e);yield*r.sort(t)}()};const X9=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(){let r=0;if(!(t<1))for await(const n of e)if(yield n,r++,r===t)return}():function*(){let r=0;if(!(t<1))for(const n of e)if(yield n,r++,r===t)return}()};class Z9{put(e,t,r){return Promise.reject(new Error(".put is not implemented"))}get(e,t){return Promise.reject(new Error(".get is not implemented"))}has(e,t){return Promise.reject(new Error(".has is not implemented"))}delete(e,t){return Promise.reject(new Error(".delete is not implemented"))}putMany(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const{key:n,value:i}of e)await t.put(n,i,r),yield n}()}catch(r){return Promise.reject(r)}}getMany(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const n of e)yield{key:n,value:await t.get(n,r)}}()}catch(r){return Promise.reject(r)}}deleteMany(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const n of e)await t.delete(n,r),yield n}()}catch(r){return Promise.reject(r)}}batch(){let e=[],t=[];return{put(t,r){e.push({key:t,value:r})},delete(e){t.push(e)},commit:async r=>{await W9(this.putMany(e,r)),e=[],await W9(this.deleteMany(t,r)),t=[]}}}async*_all(e,t){throw new Error("._all is not implemented")}async*_allKeys(e,t){throw new Error("._allKeys is not implemented")}query(e,t){let r=this._all(e,t);if(null!=e.prefix){const t=e.prefix;r=Q9(r,(e=>e.key.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>Q9(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>J9(e,t)),r)),null!=e.offset){let t=0;const n=e.offset;r=Q9(r,(()=>t++>=n))}return null!=e.limit&&(r=X9(r,e.limit)),r}queryKeys(e,t){let r=this._allKeys(e,t);if(null!=e.prefix){const t=e.prefix;r=Q9(r,(e=>e.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(r=e.filters.reduce(((e,t)=>Q9(e,t)),r)),Array.isArray(e.orders)&&(r=e.orders.reduce(((e,t)=>J9(e,t)),r)),null!=e.offset){const t=e.offset;let n=0;r=Q9(r,(()=>n++>=t))}return null!=e.limit&&(r=X9(r,e.limit)),r}}class eee extends Z9{data;constructor(){super(),this.data=new Map}put(e,t){return this.data.set(e.toString(),t),e}get(e){const t=this.data.get(e.toString());if(null==t)throw r=r??new Error("Not Found"),nh(r,"ERR_NOT_FOUND");var r;return t}has(e){return this.data.has(e.toString())}delete(e){this.data.delete(e.toString())}*_all(){for(const[e,t]of this.data.entries())yield{key:new s9(e),value:t}}*_allKeys(){for(const e of this.data.keys())yield new s9(e)}}const tee=e=>e;function ree(e,t){const r=e.getPeerId();if(null!=r){_0(r).equals(t)&&(e=e.decapsulate(G9(`/p2p/${t.toString()}`)))}return e}class nee{log;components;listen;announce;observed;announceFilter;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{listen:r=[],announce:n=[]}=t;this.components=e,this.log=e.logger.forComponent("libp2p:address-manager"),this.listen=r.map((e=>e.toString())),this.announce=new Set(n.map((e=>e.toString()))),this.observed=new Map,this.announceFilter=t.announceFilter??tee,this._updatePeerStoreAddresses=function(e,t){let r;return function(){clearTimeout(r),r=setTimeout((function(){r=void 0,e()}),t)}}(this._updatePeerStoreAddresses.bind(this),1e3),e.events.addEventListener("transport:listening",(()=>{this._updatePeerStoreAddresses()})),e.events.addEventListener("transport:close",(()=>{this._updatePeerStoreAddresses()}))}_updatePeerStoreAddresses(){const e=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter((e=>{let[t,r]=e;return r.confident})).map((e=>{let[t]=e;return G9(t)}))).map((e=>e.getPeerId()===this.components.peerId.toString()?e.decapsulate(`/p2p/${this.components.peerId.toString()}`):e));this.components.peerStore.patch(this.components.peerId,{multiaddrs:e}).catch((e=>{this.log.error("error updating addresses",e)}))}getListenAddrs(){return Array.from(this.listen).map((e=>G9(e)))}getAnnounceAddrs(){return Array.from(this.announce).map((e=>G9(e)))}getObservedAddrs(){return Array.from(this.observed).map((e=>{let[t]=e;return G9(t)}))}addObservedAddr(e){const t=(e=ree(e,this.components.peerId)).toString();this.observed.has(t)||this.observed.set(t,{confident:!1})}confirmObservedAddr(e){const t=(e=ree(e,this.components.peerId)).toString(),r=(this.observed.get(t)??{confident:!1}).confident;this.observed.set(t,{confident:!0}),r||this._updatePeerStoreAddresses()}removeObservedAddr(e){const t=(e=ree(e,this.components.peerId)).toString();this.observed.delete(t)}getAddresses(){let e=this.getAnnounceAddrs().map((e=>e.toString()));0===e.length&&(e=this.components.transportManager.getAddrs().map((e=>e.toString()))),e=e.concat(Array.from(this.observed).filter((e=>{let[t,r]=e;return r.confident})).map((e=>{let[t]=e;return t})));const t=new Set(e);return this.announceFilter(Array.from(t).map((e=>G9(e)))).map((e=>!0===e.protos().pop()?.path||e.getPeerId()===this.components.peerId.toString()?e:e.encapsulate(`/p2p/${this.components.peerId.toString()}`)))}}function iee(e){return null!=e&&"function"===typeof e.start&&"function"===typeof e.stop}class see{components={};_started=!1;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.components={};for(const[t,r]of Object.entries(e))this.components[t]=r;null==this.components.logger&&(this.components.logger=mX())}isStarted(){return this._started}async _invokeStartableMethod(e){await Promise.all(Object.values(this.components).filter((e=>iee(e))).map((async t=>{await(t[e]?.())})))}async beforeStart(){await this._invokeStartableMethod("beforeStart")}async start(){await this._invokeStartableMethod("start"),this._started=!0}async afterStart(){await this._invokeStartableMethod("afterStart")}async beforeStop(){await this._invokeStartableMethod("beforeStop")}async stop(){await this._invokeStartableMethod("stop"),this._started=!1}async afterStop(){await this._invokeStartableMethod("afterStop")}}const oee=["metrics","connectionProtector","dns"],aee=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];var cee=__webpack_require__(7364);const uee=["0.0.0.0/8","10.0.0.0/8","100.64.0.0/10","127.0.0.0/8","169.254.0.0/16","172.16.0.0/12","192.0.0.0/24","192.0.0.0/29","192.0.0.8/32","192.0.0.9/32","192.0.0.10/32","192.0.0.170/32","192.0.0.171/32","192.0.2.0/24","192.31.196.0/24","192.52.193.0/24","192.88.99.0/24","192.168.0.0/16","192.175.48.0/24","198.18.0.0/15","198.51.100.0/24","203.0.113.0/24","240.0.0.0/4","255.255.255.255/32"].map((e=>new cee.Netmask(e)));function lee(e){return Ex(e)?function(e){for(const t of uee)if(t.contains(e))return!0;return!1}(e):Sx(e)?/^::$/.test(t=e)||/^::1$/.test(t)||/^::f{4}:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^::f{4}:0.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(t)||/^100::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001::([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:2[0-9a-fA-F]:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2001:db8:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^2002:([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4}):?([0-9a-fA-F]{0,4})$/.test(t)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(t)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(t)||/^ff([0-9a-fA-F]{2,2}):/i.test(t):void 0;var t}function hee(){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async e=>{const t=e.stringTuples();return(4===t[0][0]||41===t[0][0])&&Boolean(lee(`${t[0][1]}`))},denyInboundConnection:async()=>!1,denyOutboundConnection:async()=>!1,denyInboundEncryptedConnection:async()=>!1,denyOutboundEncryptedConnection:async()=>!1,denyInboundUpgradedConnection:async()=>!1,denyOutboundUpgradedConnection:async()=>!1,filterMultiaddrForPeer:async()=>!0,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}}}function dee(e){try{const{address:t}=e.nodeAddress();return Boolean(lee(t))}catch{return!0}}function fee(e,t){const r=function(e,t){const r=dee(e.multiaddr),n=dee(t.multiaddr);return r&&!n?1:!r&&n?-1:0}(e,t);if(0!==r)return r;const n=function(e,t){const r=XM.exactMatch(e.multiaddr),n=XM.exactMatch(t.multiaddr);return r&&!n?1:!r&&n?-1:0}(e,t);if(0!==n)return n;const i=function(e,t){return e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}(e,t);return i}class pee extends Event{constructor(e,t){super(e),this.detail=t}}function gee(e){const t=[Jte.A];return null==e?t:Array.isArray(e)?0===e.length?t:e:[e]}new Uint8Array(0);function bee(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var yee=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const mee=yee;class wee{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class vee{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return Eee(this,e)}}class _ee{decoders;constructor(e){this.decoders=e}or(e){return Eee(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function Eee(e,t){return new _ee({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class See{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new wee(e,t,r),this.decoder=new vee(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Aee(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new See(t,r,n,i)}function kee(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=mee(n,t);return Aee({prefix:r,name:t,encode:i,decode:e=>bee(s(e))})}function xee(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Aee({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const Iee=kee({prefix:"9",name:"base10",alphabet:"0123456789"}),Cee=xee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Tee=xee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Ree=xee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Pee=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Dee=Pee.reduce(((e,t,r)=>(e[r]=t,e)),[]),Nee=Pee.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Bee=Aee({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Dee[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Nee[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),Uee=xee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Lee=xee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Mee=xee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Oee=xee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),qee=xee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Kee=xee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fee=xee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Vee=xee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),zee=xee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),$ee=kee({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Hee=kee({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),jee=kee({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Gee=kee({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Wee=xee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Yee=xee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Qee=xee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jee=xee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Xee=xee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Zee=Aee({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),ete=new TextEncoder,tte=new TextDecoder,rte="json",nte=512;function ite(e){return ete.encode(JSON.stringify(e))}function ste(e){return JSON.parse(tte.decode(e))}const ote="raw",ate=85;function cte(e){return bee(e)}function ute(e){return bee(e)}var lte=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=fte;)r[n++]=255&t|hte,t/=128;for(;t&dte;)r[n++]=255&t|hte,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},hte=128,dte=-128,fte=Math.pow(2,31);var pte=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&bte)<<s:(n&bte)*Math.pow(2,s),s+=7}while(n>=gte);return e.bytes=o-r,i},gte=128,bte=127;var yte=Math.pow(2,7),mte=Math.pow(2,14),wte=Math.pow(2,21),vte=Math.pow(2,28),_te=Math.pow(2,35),Ete=Math.pow(2,42),Ste=Math.pow(2,49),Ate=Math.pow(2,56),kte=Math.pow(2,63);const xte={encode:lte,decode:pte,encodingLength:function(e){return e<yte?1:e<mte?2:e<wte?3:e<vte?4:e<_te?5:e<Ete?6:e<Ste?7:e<Ate?8:e<kte?9:10}};function Ite(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return xte.encode(e,t,r),t}function Cte(e){return xte.encodingLength(e)}function Tte(e,t){const r=t.byteLength,n=Cte(e),i=n+Cte(r),s=new Uint8Array(i+r);return Ite(e,s,0),Ite(r,s,n),s.set(t,i),new Rte(e,r,t,s)}class Rte{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Pte=bee;const Dte={code:0,name:"identity",encode:Pte,digest:function(e){return Tte(0,Pte(e))}};function Nte(e){let{name:t,code:r,encode:n}=e;return new Bte(t,r,n)}class Bte{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Tte(this.code,t):t.then((e=>Tte(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Ute(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Lte=Nte({name:"sha2-256",code:18,encode:Ute("SHA-256")}),Mte=Nte({name:"sha2-512",code:19,encode:Ute("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const Ote={...ci,...ti,...ai,...Zn,...ei,...ni,...ii,...si,...oi,...ri};function qte(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Kte=qte("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Fte=qte("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Vte={utf8:Kte,"utf-8":Kte,hex:Ote.base16,latin1:Fte,ascii:Fte,binary:Fte,...Ote};function zte(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Vte[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}const $te=60;function Hte(e){return{Status:e.Status??0,TC:e.TC??e.flag_tc??!1,RD:e.RD??e.flag_rd??!1,RA:e.RA??e.flag_ra??!1,AD:e.AD??e.flag_ad??!1,CD:e.CD??e.flag_cd??!1,Question:(e.Question??e.questions??[]).map((e=>({name:e.name,type:Jte[e.type]}))),Answer:(e.Answer??e.answers??[]).map((e=>({name:e.name,type:Jte[e.type],TTL:e.TTL??e.ttl??$te,data:e.data instanceof Uint8Array?zte(e.data):e.data})))}}const jte=4;function Gte(e){const t=new z4({concurrency:(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).queryConcurrency??jte});return async function(r){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=new URLSearchParams;i.set("name",r),gee(n.types).forEach((e=>{i.append("type",Jte[e])})),n.onProgress?.(new pee("dns:query",{detail:r}));const s=await t.add((async()=>{const t=await fetch(`${e}?${i}`,{headers:{accept:"application/dns-json"},signal:n?.signal});if(200!==t.status)throw new Error(`Unexpected HTTP status: ${t.status} - ${t.statusText}`);const r=Hte(await t.json());return n.onProgress?.(new pee("dns:response",{detail:r})),r}),{signal:n.signal});if(null==s)throw new Error("No DNS response received");return s}}var Wte=__webpack_require__(101);class Yte{lru;constructor(e){this.lru=Wte(e)}get(e,t){let r=!0;const n=[];for(const i of t){const t=this.getAnswers(e,i);if(0===t.length){r=!1;break}n.push(...t)}if(r)return Hte({answers:n})}getAnswers(e,t){const r=`${e.toLowerCase()}-${t}`,n=this.lru.get(r);if(null!=n){const e=n.filter((e=>e.expires>Date.now())).map((e=>{let{expires:t,value:r}=e;return{...r,TTL:Math.round((t-Date.now())/1e3),type:Jte[r.type]}}));return 0===e.length&&this.lru.remove(r),e}return[]}add(e,t){const r=`${e.toLowerCase()}-${t.type}`,n=this.lru.get(r)??[];n.push({expires:Date.now()+1e3*(t.TTL??$te),value:t}),this.lru.set(r,n)}remove(e,t){const r=`${e.toLowerCase()}-${t}`;this.lru.remove(r)}clear(){this.lru.clear()}}class Qte{resolvers;cache;constructor(e){var t;this.resolvers={},this.cache=(t=e.cacheSize??1e3,new Yte(t)),Object.entries(e.resolvers??{}).forEach((e=>{let[t,r]=e;Array.isArray(r)||(r=[r]),t.endsWith(".")||(t=`${t}.`),this.resolvers[t]=r})),null==this.resolvers["."]&&(this.resolvers["."]=[Gte("https://cloudflare-dns.com/dns-query"),Gte("https://dns.google/resolve")])}async query(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=gee(t.types),n=!1!==t.cached?this.cache.get(e,r):void 0;if(null!=n)return t.onProgress?.(new pee("dns:cache",{detail:n})),n;const i=`${e.split(".").pop()}.`,s=(this.resolvers[i]??this.resolvers["."]).sort((()=>Math.random()>.5?-1:1)),o=[];for(const c of s){if(!0===t.signal?.aborted)break;try{const n=await c(e,{...t,types:r});for(const t of n.Answer)this.cache.add(e,t);return n}catch(a){o.push(a),t.onProgress?.(new pee("dns:error",{detail:a}))}}if(1===o.length)throw o[0];throw new AggregateError(o,`DNS lookup of ${e} ${r} failed`)}}var Jte;!function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"}(Jte||(Jte={}));const{code:Xte}=A9("dnsaddr"),Zte=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=t.maxRecursiveDepth??32;if(0===r)throw new Xp("Max recursive depth reached","ERR_MAX_RECURSIVE_DEPTH_REACHED");const[,n]=e.stringTuples().find((e=>{let[t]=e;return t===Xte}))??[],i=t?.dns??function(){return new Qte(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}(),s=await i.query(`_dnsaddr.${n}`,{signal:t?.signal,types:[Jte.TXT]}),o=e.getPeerId(),a=[];for(const c of s.Answer){const e=c.data.split("=")[1];if(null==e)continue;if(null!=o&&!e.includes(o))continue;const n=G9(e);if(e.startsWith("/dnsaddr")){const e=await n.resolve({...t,maxRecursiveDepth:r-1});a.push(...e.map((e=>e.toString())))}else a.push(n.toString())}return a};const ere=__webpack_require__(8355);var tre,rre;!function(e){e.NOT_STARTED_YET="The libp2p node is not started yet",e.ERR_PROTECTOR_REQUIRED="Private network is enforced, but no protector was provided",e.NOT_FOUND="Not found"}(tre||(tre={})),function(e){e.ERR_PROTECTOR_REQUIRED="ERR_PROTECTOR_REQUIRED",e.ERR_PEER_DIAL_INTERCEPTED="ERR_PEER_DIAL_INTERCEPTED",e.ERR_CONNECTION_INTERCEPTED="ERR_CONNECTION_INTERCEPTED",e.ERR_INVALID_PROTOCOLS_FOR_STREAM="ERR_INVALID_PROTOCOLS_FOR_STREAM",e.ERR_CONNECTION_ENDED="ERR_CONNECTION_ENDED",e.ERR_CONNECTION_FAILED="ERR_CONNECTION_FAILED",e.ERR_NODE_NOT_STARTED="ERR_NODE_NOT_STARTED",e.ERR_ALREADY_ABORTED="ERR_ALREADY_ABORTED",e.ERR_TOO_MANY_ADDRESSES="ERR_TOO_MANY_ADDRESSES",e.ERR_NO_VALID_ADDRESSES="ERR_NO_VALID_ADDRESSES",e.ERR_RELAYED_DIAL="ERR_RELAYED_DIAL",e.ERR_DIALED_SELF="ERR_DIALED_SELF",e.ERR_DISCOVERED_SELF="ERR_DISCOVERED_SELF",e.ERR_DUPLICATE_TRANSPORT="ERR_DUPLICATE_TRANSPORT",e.ERR_ENCRYPTION_FAILED="ERR_ENCRYPTION_FAILED",e.ERR_HOP_REQUEST_FAILED="ERR_HOP_REQUEST_FAILED",e.ERR_INVALID_KEY="ERR_INVALID_KEY",e.ERR_INVALID_MESSAGE="ERR_INVALID_MESSAGE",e.ERR_INVALID_PARAMETERS="ERR_INVALID_PARAMETERS",e.ERR_INVALID_PEER="ERR_INVALID_PEER",e.ERR_MUXER_UNAVAILABLE="ERR_MUXER_UNAVAILABLE",e.ERR_NOT_FOUND="ERR_NOT_FOUND",e.ERR_TRANSPORT_UNAVAILABLE="ERR_TRANSPORT_UNAVAILABLE",e.ERR_TRANSPORT_DIAL_FAILED="ERR_TRANSPORT_DIAL_FAILED",e.ERR_UNSUPPORTED_PROTOCOL="ERR_UNSUPPORTED_PROTOCOL",e.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED="ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED",e.ERR_INVALID_MULTIADDR="ERR_INVALID_MULTIADDR",e.ERR_SIGNATURE_NOT_VALID="ERR_SIGNATURE_NOT_VALID",e.ERR_FIND_SELF="ERR_FIND_SELF",e.ERR_NO_ROUTERS_AVAILABLE="ERR_NO_ROUTERS_AVAILABLE",e.ERR_CONNECTION_NOT_MULTIPLEXED="ERR_CONNECTION_NOT_MULTIPLEXED",e.ERR_NO_DIAL_TOKENS="ERR_NO_DIAL_TOKENS",e.ERR_INVALID_CMS="ERR_INVALID_CMS",e.ERR_MISSING_KEYS="ERR_MISSING_KEYS",e.ERR_NO_KEY="ERR_NO_KEY",e.ERR_INVALID_KEY_NAME="ERR_INVALID_KEY_NAME",e.ERR_INVALID_KEY_TYPE="ERR_INVALID_KEY_TYPE",e.ERR_KEY_ALREADY_EXISTS="ERR_KEY_ALREADY_EXISTS",e.ERR_INVALID_KEY_SIZE="ERR_INVALID_KEY_SIZE",e.ERR_KEY_NOT_FOUND="ERR_KEY_NOT_FOUND",e.ERR_OLD_KEY_NAME_INVALID="ERR_OLD_KEY_NAME_INVALID",e.ERR_NEW_KEY_NAME_INVALID="ERR_NEW_KEY_NAME_INVALID",e.ERR_PASSWORD_REQUIRED="ERR_PASSWORD_REQUIRED",e.ERR_PEM_REQUIRED="ERR_PEM_REQUIRED",e.ERR_CANNOT_READ_KEY="ERR_CANNOT_READ_KEY",e.ERR_MISSING_PRIVATE_KEY="ERR_MISSING_PRIVATE_KEY",e.ERR_MISSING_PUBLIC_KEY="ERR_MISSING_PUBLIC_KEY",e.ERR_INVALID_OLD_PASS_TYPE="ERR_INVALID_OLD_PASS_TYPE",e.ERR_INVALID_NEW_PASS_TYPE="ERR_INVALID_NEW_PASS_TYPE",e.ERR_INVALID_PASS_LENGTH="ERR_INVALID_PASS_LENGTH",e.ERR_NOT_IMPLEMENTED="ERR_NOT_IMPLEMENTED",e.ERR_WRONG_PING_ACK="ERR_WRONG_PING_ACK",e.ERR_INVALID_RECORD="ERR_INVALID_RECORD",e.ERR_ALREADY_SUCCEEDED="ERR_ALREADY_SUCCEEDED",e.ERR_NO_HANDLER_FOR_PROTOCOL="ERR_NO_HANDLER_FOR_PROTOCOL",e.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS",e.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS="ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",e.ERR_CONNECTION_DENIED="ERR_CONNECTION_DENIED",e.ERR_TRANSFER_LIMIT_EXCEEDED="ERR_TRANSFER_LIMIT_EXCEEDED"}(rre||(rre={}));const nre={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{resolvers:{dnsaddr:Zte},addressSorter:fee},transportManager:{faultTolerance:oF.FATAL_ALL}};async function ire(e){const t=ere(nre,e);if(null===t.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw new Xp(tre.ERR_PROTECTOR_REQUIRED,rre.ERR_PROTECTOR_REQUIRED);if(!(await async function(e,t){return e.length===g0?new w0({multihash:OY(VY.code,e),privateKey:t}):e.length===b0?new v0({multihash:OY(VY.code,e),privateKey:t}):new m0({multihash:await jY.digest(e),publicKey:e,privateKey:t})}(t.privateKey.public.bytes,t.privateKey.bytes)).equals(t.peerId))throw new Xp("Private key doesn't match peer id",rre.ERR_INVALID_KEY);return t}function sre(e){if(_m(e))return{peerId:e,multiaddrs:[]};let t;if(Array.isArray(e)||(e=[e]),e.length>0){const r=e[0].getPeerId();t=null==r?void 0:_0(r),e.forEach((e=>{if(!j9(e))throw new Xp("Invalid Multiaddr",rre.ERR_INVALID_MULTIADDR);const r=e.getPeerId();if(null==r){if(null!=t)throw new Xp("Multiaddrs must all have the same peer id or have no peer id",rre.ERR_INVALID_PARAMETERS)}else{const e=_0(r);if(null==t||!t.equals(e))throw new Xp("Multiaddrs must all have the same peer id or have no peer id",rre.ERR_INVALID_PARAMETERS)}}))}return{peerId:t,multiaddrs:e}}class ore extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.name="AbortError",this.code=t??"ABORT_ERR"}}async function are(e,t,r,n){const i=new ore(n?.errorMessage,n?.errorCode);return!0===r?.aborted?Promise.reject(i):new Promise(((s,o)=>{const a=i=>{try{if(!1===n?.filter?.(i))return}catch(u){return e.removeEventListener(t,a),r?.removeEventListener("abort",c),void o(u)}e.removeEventListener(t,a),r?.removeEventListener("abort",c),s(i)},c=()=>{e.removeEventListener(t,a),r?.removeEventListener("abort",c),o(i)};e.addEventListener(t,a),r?.addEventListener("abort",c)}))}class cre{deferred;signal;where;constructor(e,t){this.signal=t,this.deferred=ah(),this.where=e,this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(new Jp)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}}class ure{id;fn;options;priority;recipients;status;timeline;controller;constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.id=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,this.status="queued",this.fn=e,this.priority=r,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,id(1/0,this.controller.signal),this.onAbort=this.onAbort.bind(this)}abort(e){this.controller.abort(e)}onAbort(){this.recipients.reduce(((e,t)=>e&&!0===t.signal?.aborted),!0)&&this.controller.abort(new Jp)}async join(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=new cre(new Error("where").stack,e.signal);return this.recipients.push(t),e.signal?.addEventListener("abort",this.onAbort),t.deferred.promise}async run(){this.status="running",this.timeline.started=Date.now();try{this.controller.signal.throwIfAborted();const e=await yd(this.fn({...this.options??{},signal:this.controller.signal}),this.controller.signal);this.recipients.forEach((t=>{t.deferred.resolve(e)})),this.status="complete"}catch(e){this.recipients.forEach((t=>{t.deferred.reject(e)})),this.status="errored"}finally{this.timeline.finished=Date.now(),this.cleanup()}}cleanup(){this.recipients.forEach((e=>{e.signal?.removeEventListener("abort",this.onAbort)}))}}class lre extends sd{concurrency;queue;pending;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(),this.concurrency=e.concurrency??Number.POSITIVE_INFINITY,this.pending=0,null!=e.metricName&&e.metrics?.registerMetricGroup(e.metricName,{calculate:()=>({size:this.queue.length,running:this.pending,queued:this.queue.length-this.pending})}),this.queue=[]}tryToStartAnother(){if(0===this.size)return queueMicrotask((()=>{this.safeDispatchEvent("empty")})),0===this.running&&queueMicrotask((()=>{this.safeDispatchEvent("idle")})),!1;if(this.pending<this.concurrency){let e;for(const t of this.queue)if("queued"===t.status){e=t;break}return null!=e&&(this.safeDispatchEvent("active"),this.pending++,e.run().finally((()=>{for(let t=0;t<this.queue.length;t++)if(this.queue[t]===e){this.queue.splice(t,1);break}this.pending--,this.tryToStartAnother(),this.safeDispatchEvent("next")})),!0)}return!1}enqueue(e){if(this.queue[this.size-1]?.priority>=e.priority)return void this.queue.push(e);const t=function(e,t,r){let n=0,i=e.length;for(;i>0;){const s=Math.trunc(i/2);let o=n+s;r(e[o],t)<=0?(n=++o,i-=s+1):i=s}return n}(this.queue,e,((e,t)=>t.priority-e.priority));this.queue.splice(t,0,e)}async add(e,t){t?.signal?.throwIfAborted();const r=new ure(e,t,t?.priority),n=r.join(t).then((e=>(this.safeDispatchEvent("completed",{detail:e}),e))).catch((e=>{throw this.safeDispatchEvent("error",{detail:e}),e}));return this.enqueue(r),this.safeDispatchEvent("add"),this.tryToStartAnother(),n}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach((e=>{e.abort(new Jp)})),this.clear()}async onEmpty(e){0!==this.size&&await are(this,"empty",e?.signal)}async onSizeLessThan(e,t){this.size<e||await are(this,"next",t?.signal,{filter:()=>this.size<e})}async onIdle(e){0===this.pending&&0===this.size||await are(this,"idle",e?.signal)}get size(){return this.queue.length}get queued(){return this.queue.length-this.pending}get running(){return this.pending}async*toGenerator(e){e?.signal?.throwIfAborted();const t=hh({objectMode:!0}),r=e=>{null!=e?this.abort():this.clear(),t.end(e)},n=e=>{null!=e.detail&&t.push(e.detail)},i=e=>{r(e.detail)},s=()=>{r()},o=()=>{r(new Xp("Queue aborted","ERR_QUEUE_ABORTED"))};this.addEventListener("completed",n),this.addEventListener("error",i),this.addEventListener("idle",s),e?.signal?.addEventListener("abort",o);try{yield*t}finally{this.removeEventListener("completed",n),this.removeEventListener("error",i),this.removeEventListener("idle",s),e?.signal?.removeEventListener("abort",o),r()}}}class hre extends lre{has(e){return null!=this.find(e)}find(e){return this.queue.find((t=>e.equals(t.options.peerId)))}}const dre="last-dial-failure",fre={minConnections:5,maxQueueLength:100,autoDialConcurrency:25,autoDialPriority:0,autoDialInterval:5e3,autoDialPeerRetryThreshold:42e4,autoDialDiscoveredPeersDebounce:10};class pre{connectionManager;peerStore;queue;minConnections;autoDialPriority;autoDialIntervalMs;autoDialMaxQueueLength;autoDialPeerRetryThresholdMs;autoDialDiscoveredPeersDebounce;autoDialInterval;started;running;log;constructor(e,t){let r;this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.minConnections=t.minConnections??fre.minConnections,this.autoDialPriority=t.autoDialPriority??fre.autoDialPriority,this.autoDialIntervalMs=t.autoDialInterval??fre.autoDialInterval,this.autoDialMaxQueueLength=t.maxQueueLength??fre.maxQueueLength,this.autoDialPeerRetryThresholdMs=t.autoDialPeerRetryThreshold??fre.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=t.autoDialDiscoveredPeersDebounce??fre.autoDialDiscoveredPeersDebounce,this.log=e.logger.forComponent("libp2p:connection-manager:auto-dial"),this.started=!1,this.running=!1,this.queue=new hre({concurrency:t.autoDialConcurrency??fre.autoDialConcurrency,metricName:"libp2p_autodial_queue",metrics:e.metrics}),this.queue.addEventListener("error",(e=>{this.log.error("error during auto-dial",e.detail)})),e.events.addEventListener("connection:close",(()=>{this.autoDial().catch((e=>{this.log.error(e)}))})),e.events.addEventListener("peer:discovery",(()=>{clearTimeout(r),r=setTimeout((()=>{this.autoDial().catch((e=>{this.log.error(e)}))}),this.autoDialDiscoveredPeersDebounce)}))}isStarted(){return this.started}start(){this.started=!0}afterStart(){this.autoDial().catch((e=>{this.log.error("error while autodialing",e)}))}stop(){this.queue.clear(),clearTimeout(this.autoDialInterval),this.started=!1,this.running=!1}async autoDial(){if(!this.started||this.running)return;const e=this.connectionManager.getConnectionsMap(),t=e.size;if(t>=this.minConnections)return void(this.minConnections>0&&this.log.trace("have enough connections %d/%d",t,this.minConnections));if(this.queue.size>this.autoDialMaxQueueLength)return this.log("not enough connections %d/%d but auto dial queue is full",t,this.minConnections),void this.sheduleNextAutodial();this.running=!0,this.log("not enough connections %d/%d - will dial peers to increase the number of connections",t,this.minConnections);const r=new h0(this.connectionManager.getDialQueue().map((e=>e.peerId)).filter(Boolean)),n=await this.peerStore.all({filters:[t=>0===t.addresses.length?(this.log.trace("not autodialing %p because they have no addresses",t.id),!1):e.has(t.id)?(this.log.trace("not autodialing %p because they are already connected",t.id),!1):r.has(t.id)?(this.log.trace("not autodialing %p because they are already being dialed",t.id),!1):!this.queue.has(t.id)||(this.log.trace("not autodialing %p because they are already being autodialed",t.id),!1)]}),i=n.sort((()=>Math.random()>.5?1:-1)),s=new Q3;for(const a of i)s.has(a.id)||s.set(a.id,[...a.tags.values()].reduce(((e,t)=>e+t.value),0));const o=i.sort(((e,t)=>{const r=s.get(e.id)??0,n=s.get(t.id)??0;return r>n?-1:r<n?1:0})).filter((e=>{const t=e.metadata.get(dre);if(null==t)return!0;const r=parseInt($J(t));return!!isNaN(r)||Date.now()-r>this.autoDialPeerRetryThresholdMs}));this.log("selected %d/%d peers to dial",o.length,n.length);for(const a of o)this.queue.add((async()=>{const e=this.connectionManager.getConnectionsMap().size;if(e>=this.minConnections)return this.log("got enough connections now %d/%d",e,this.minConnections),void this.queue.clear();this.log("connecting to a peerStore stored peer %p",a.id),await this.connectionManager.openConnection(a.id,{priority:this.autoDialPriority})}),{peerId:a.id}).catch((e=>{this.log.error("could not connect to peerStore stored peer",e)}));this.running=!1,this.sheduleNextAutodial()}sheduleNextAutodial(){this.started&&(this.autoDialInterval=setTimeout((()=>{this.autoDial().catch((e=>{this.log.error("error while autodialing",e)}))}),this.autoDialIntervalMs))}}const gre={maxConnections:100,allow:[]};class bre{maxConnections;connectionManager;peerStore;allow;events;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.maxConnections=t.maxConnections??gre.maxConnections,this.allow=t.allow??gre.allow,this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.events=e.events,this.log=e.logger.forComponent("libp2p:connection-manager:connection-pruner"),e.events.addEventListener("connection:open",(()=>{this.maybePruneConnections().catch((e=>{this.log.error(e)}))}))}async maybePruneConnections(){const e=this.connectionManager.getConnections(),t=e.length,r=Math.max(t-this.maxConnections,0);if(this.log("checking max connections limit %d/%d",t,this.maxConnections),t<=this.maxConnections)return;this.log("max connections limit exceeded %d/%d, pruning %d connection(s)",t,this.maxConnections,r);const n=new Q3;for(const a of e){const e=a.remotePeer;if(!n.has(e)){n.set(e,0);try{const t=await this.peerStore.get(e);n.set(e,[...t.tags.values()].reduce(((e,t)=>e+t.value),0))}catch(o){"ERR_NOT_FOUND"!==o.code&&this.log.error("error loading peer tags",o)}}}const i=e.sort(((e,t)=>{const r=n.get(e.remotePeer)??0,i=n.get(t.remotePeer)??0;if(r>i)return 1;if(r<i)return-1;const s=e.timeline.open,o=t.timeline.open;return s<o?1:s>o?-1:0})),s=[];for(const a of i){this.log("too many connections open - closing a connection to %p",a.remotePeer);if(this.allow.some((e=>a.remoteAddr.toString().startsWith(e.toString())))||s.push(a),s.length===r)break}await Promise.all(s.map((async e=>{try{await e.close()}catch(o){this.log.error(o)}}))),this.events.safeDispatchEvent("connection:prune",{detail:s})}}const yre={addressSorter:fee,maxParallelDials:50,maxDialQueueLength:500,maxPeerAddrsToDial:25,dialTimeout:5e3,resolvers:{dnsaddr:Zte}};class mre{queue;components;addressSorter;maxPeerAddrsToDial;maxDialQueueLength;dialTimeout;shutDownController;connections;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.addressSorter=t.addressSorter??yre.addressSorter,this.maxPeerAddrsToDial=t.maxPeerAddrsToDial??yre.maxPeerAddrsToDial,this.maxDialQueueLength=t.maxDialQueueLength??yre.maxDialQueueLength,this.dialTimeout=t.dialTimeout??yre.dialTimeout,this.connections=t.connections??new Q3,this.log=e.logger.forComponent("libp2p:connection-manager:dial-queue"),this.components=e,this.shutDownController=new AbortController,id(1/0,this.shutDownController.signal);for(const[r,n]of Object.entries(t.resolvers??{}))H9.set(r,n);this.queue=new lre({concurrency:t.maxParallelDials??yre.maxParallelDials,metricName:"libp2p_dial_queue",metrics:e.metrics}),this.queue.addEventListener("error",(e=>{this.log.error("error in dial queue",e.detail)}))}start(){this.shutDownController=new AbortController,id(1/0,this.shutDownController.signal)}stop(){this.shutDownController.abort(),this.queue.abort()}async dial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{peerId:r,multiaddrs:n}=sre(e),i=Array.from(this.connections.values()).flat().find((e=>!0!==t.force&&(!!e.remotePeer.equals(r)||n.find((t=>t.equals(e.remoteAddr))))));if(null!=i)return this.log("already connected to %a",i.remoteAddr),i;const s=this.queue.queue.find((e=>{if(!0===r?.equals(e.options.peerId))return!0;const t=e.options.multiaddrs;if(null==t)return!1;for(const r of n)if(t.has(r.toString()))return!0;return!1}));if(null!=s){this.log("joining existing dial target for %p",r);for(const e of n)s.options.multiaddrs.add(e.toString());return s.join(t)}if(this.queue.size>=this.maxDialQueueLength)throw new Xp("Dial queue is full","ERR_DIAL_QUEUE_FULL");return this.log("creating dial target for %p",r,n.map((e=>e.toString()))),this.queue.add((async e=>{const t=this.createDialAbortController(e?.signal);let n;try{n=await this.calculateMultiaddrs(r,e?.multiaddrs,{...e,signal:t}),n.map((e=>{let{multiaddr:t}=e;return t.toString()})).forEach((t=>{e?.multiaddrs.add(t)}))}catch(i){throw t.clear(),i}try{let s=0;const o=[];for(const a of n){if(s===this.maxPeerAddrsToDial)throw this.log("dialed maxPeerAddrsToDial (%d) addresses for %p, not trying any others",s,r),new Xp("Peer had more than maxPeerAddrsToDial",rre.ERR_TOO_MANY_ADDRESSES);s++;try{const r=await this.components.transportManager.dial(a.multiaddr,{...e,signal:t});return this.log("dial to %a succeeded",a.multiaddr),r}catch(i){if(this.log.error("dial failed to %a",a.multiaddr,i),null!=r)try{await this.components.peerStore.patch(r,{metadata:{[dre]:$Q(Date.now().toString())}})}catch(i){this.log.error("could not update last dial failure key for %p",r,i)}if(t.aborted)throw new Xp(i.message,eg);o.push(i)}}if(1===o.length)throw o[0];throw new Zp(o,"All multiaddr dials failed",rre.ERR_TRANSPORT_DIAL_FAILED)}finally{t.clear()}}),{peerId:r,priority:t.priority,multiaddrs:new Set(n.map((e=>e.toString()))),signal:t.signal})}createDialAbortController(e){const t=function(e){const t=new globalThis.AbortController;function r(){t.abort();for(const t of e)null!=t?.removeEventListener&&t.removeEventListener("abort",r)}for(const i of e){if(!0===i?.aborted){r();break}null!=i?.addEventListener&&i.addEventListener("abort",r)}const n=t.signal;return n.clear=function(){for(const t of e)null!=t?.removeEventListener&&t.removeEventListener("abort",r)},n}([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,e]);return id(1/0,t),t}async calculateMultiaddrs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=[...t].map((e=>({multiaddr:G9(e),isCertified:!1})));if(null!=e){if(this.components.peerId.equals(e))throw new Xp("Tried to dial self",rre.ERR_DIALED_SELF);if(!0===await(this.components.connectionGater.denyDialPeer?.(e)))throw new Xp("The dial request is blocked by gater.allowDialPeer",rre.ERR_PEER_DIAL_INTERCEPTED);if(0===n.length){this.log("loading multiaddrs for %p",e);try{const t=await this.components.peerStore.get(e);n.push(...t.addresses),this.log("loaded multiaddrs for %p",e,n.map((e=>{let{multiaddr:t}=e;return t.toString()})))}catch(l){if(l.code!==rre.ERR_NOT_FOUND)throw l}}if(0===n.length){this.log("looking up multiaddrs for %p in the peer routing",e);try{const t=await this.components.peerRouting.findPeer(e);this.log("found multiaddrs for %p in the peer routing",e,n.map((e=>{let{multiaddr:t}=e;return t.toString()}))),n.push(...t.multiaddrs.map((e=>({multiaddr:e,isCertified:!1}))))}catch(l){l.code!==rre.ERR_NO_ROUTERS_AVAILABLE&&this.log.error("looking up multiaddrs for %p in the peer routing failed",e,l)}}}let i=(await Promise.all(n.map((async e=>{const t=await async function(e,t){let r=!1;for(const i of H9.keys())if(r=e.protoNames().includes(i),r)break;if(!r)return[e];const n=await e.resolve(t);return t.log("resolved %s to",e,n.map((e=>e.toString()))),n}(e.multiaddr,{dns:this.components.dns,...r,log:this.log});return 1===t.length&&t[0].equals(e.multiaddr)?e:t.map((e=>({multiaddr:e,isCertified:!1})))})))).flat();if(null!=e){const t=`/p2p/${e.toString()}`;i=i.map((e=>{const r=e.multiaddr.protos().pop();return!0===r?.path?e:null==e.multiaddr.getPeerId()?{multiaddr:e.multiaddr.encapsulate(t),isCertified:e.isCertified}:e}))}const s=i.filter((t=>{if(null==this.components.transportManager.transportForMultiaddr(t.multiaddr))return!1;const r=t.multiaddr.getPeerId();return null==e||null==r||e.equals(r)})),o=new Map;for(const h of s){const e=h.multiaddr.toString(),t=o.get(e);null==t?o.set(e,h):t.isCertified=t.isCertified||h.isCertified||!1}const a=[...o.values()];if(0===a.length)throw new Xp("The dial request has no valid addresses",rre.ERR_NO_VALID_ADDRESSES);const c=[];for(const h of a)null!=this.components.connectionGater.denyDialMultiaddr&&await this.components.connectionGater.denyDialMultiaddr(h.multiaddr)||c.push(h);const u=c.sort(this.addressSorter);if(0===u.length)throw new Xp("The connection gater denied all addresses in the dial request",rre.ERR_NO_VALID_ADDRESSES);return this.log.trace("addresses for %p before filtering",e??"unknown peer",i.map((e=>{let{multiaddr:t}=e;return t.toString()}))),this.log.trace("addresses for %p after filtering",e??"unknown peer",u.map((e=>{let{multiaddr:t}=e;return t.toString()}))),u}}const wre=5,vre=100,_re=5,Ere=10,Sre=25,Are=0,kre=100;class xre{started;connections;allow;deny;maxIncomingPendingConnections;incomingPendingConnections;maxConnections;dialQueue;autoDial;connectionPruner;inboundConnectionRateLimiter;peerStore;metrics;events;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.maxConnections=t.maxConnections??vre;const r=t.minConnections??wre;if(this.maxConnections<r)throw new Xp("Connection Manager maxConnections must be greater than minConnections",rre.ERR_INVALID_PARAMETERS);this.connections=new Q3,this.started=!1,this.peerStore=e.peerStore,this.metrics=e.metrics,this.events=e.events,this.log=e.logger.forComponent("libp2p:connection-manager"),this.onConnect=this.onConnect.bind(this),this.onDisconnect=this.onDisconnect.bind(this),this.events.addEventListener("connection:open",this.onConnect),this.events.addEventListener("connection:close",this.onDisconnect),this.allow=(t.allow??[]).map((e=>G9(e))),this.deny=(t.deny??[]).map((e=>G9(e))),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=t.maxIncomingPendingConnections??Ere,this.inboundConnectionRateLimiter=new sq({points:t.inboundConnectionThreshold??_re,duration:1}),this.autoDial=new pre({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{minConnections:r,autoDialConcurrency:t.autoDialConcurrency??Sre,autoDialPriority:t.autoDialPriority??Are,maxQueueLength:t.autoDialMaxQueueLength??kre}),this.connectionPruner=new bre({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new mre(e,{addressSorter:t.addressSorter??fee,maxParallelDials:t.maxParallelDials??50,maxDialQueueLength:t.maxDialQueueLength??500,maxPeerAddrsToDial:t.maxPeerAddrsToDial??25,dialTimeout:t.dialTimeout??5e3,resolvers:t.resolvers??{dnsaddr:Zte},connections:this.connections})}isStarted(){return this.started}async start(){this.metrics?.registerMetricGroup("libp2p_connection_manager_connections",{calculate:()=>{const e={inbound:0,outbound:0};for(const t of this.connections.values())for(const r of t)"inbound"===r.direction?e.inbound++:e.outbound++;return e}}),this.metrics?.registerMetricGroup("libp2p_protocol_streams_total",{label:"protocol",calculate:()=>{const e={};for(const t of this.connections.values())for(const r of t)for(const t of r.streams){const r=`${t.direction} ${t.protocol??"unnegotiated"}`;e[r]=(e[r]??0)+1}return e}}),this.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{const e={};for(const r of this.connections.values())for(const t of r){const r={};for(const e of t.streams){const t=`${e.direction} ${e.protocol??"unnegotiated"}`;r[t]=(r[t]??0)+1}for(const[t,n]of Object.entries(r))e[t]=e[t]??[],e[t].push(n)}const t={};for(let[r,n]of Object.entries(e)){n=n.sort(((e,t)=>e-t));const e=Math.floor(.9*n.length);t[r]=n[e]}return t}}),this.dialQueue.start(),this.autoDial.start(),this.started=!0,this.log("started")}async afterStart(){Promise.resolve().then((async()=>{const e=await this.peerStore.all({filters:[e=>e.tags.has("keep-alive")]});await Promise.all(e.map((async e=>{await this.openConnection(e.id).catch((e=>{this.log.error(e)}))})))})).catch((e=>{this.log.error(e)})),this.autoDial.afterStart()}async stop(){this.dialQueue.stop(),this.autoDial.stop();const e=[];for(const t of this.connections.values())for(const r of t)e.push((async()=>{try{await r.close()}catch(e){this.log.error(e)}})());this.log("closing %d connections",e.length),await Promise.all(e),this.connections.clear(),this.log("stopped")}onConnect(e){this._onConnect(e).catch((e=>{this.log.error(e)}))}async _onConnect(e){const{detail:t}=e;if(!this.started)return void await t.close();const r=t.remotePeer,n=this.connections.get(r);let i=!1;null!=n?n.push(t):(i=!0,this.connections.set(r,[t])),null!=r.publicKey&&"RSA"===r.type&&await this.peerStore.patch(r,{publicKey:r.publicKey}),i&&this.events.safeDispatchEvent("peer:connect",{detail:t.remotePeer})}onDisconnect(e){const{detail:t}=e;if(!this.started)return;const r=t.remotePeer;let n=this.connections.get(r);null!=n&&n.length>1?(n=n.filter((e=>e.id!==t.id)),this.connections.set(r,n)):null!=n&&(this.connections.delete(r),this.events.safeDispatchEvent("peer:disconnect",{detail:t.remotePeer}))}getConnections(e){if(null!=e)return this.connections.get(e)??[];let t=[];for(const r of this.connections.values())t=t.concat(r);return t}getConnectionsMap(){return this.connections}async openConnection(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!this.isStarted())throw new Xp("Not started",rre.ERR_NODE_NOT_STARTED);t.signal?.throwIfAborted();const{peerId:r}=sre(e);if(null!=r&&!0!==t.force){this.log("dial %p",r);const e=this.getConnections(r).find((e=>!e.transient));if(null!=e)return this.log("had an existing non-transient connection to %p",r),e}const n=await this.dialQueue.dial(e,{...t,priority:t.priority??50});let i=this.connections.get(n.remotePeer);null==i&&(i=[],this.connections.set(n.remotePeer,i));let s=!1;for(const o of i)o.id===n.id&&(s=!0);return s||i.push(n),n}async closeConnections(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=this.connections.get(e)??[];await Promise.all(r.map((async e=>{try{await e.close(t)}catch(r){e.abort(r)}})))}async acceptIncomingConnection(e){if(this.deny.some((t=>e.remoteAddr.toString().startsWith(t.toString()))))return this.log("connection from %a refused - connection remote address was in deny list",e.remoteAddr),!1;if(this.allow.some((t=>e.remoteAddr.toString().startsWith(t.toString()))))return this.incomingPendingConnections++,!0;if(this.incomingPendingConnections===this.maxIncomingPendingConnections)return this.log("connection from %a refused - incomingPendingConnections exceeded by host",e.remoteAddr),!1;if(e.remoteAddr.isThinWaistAddress()){const t=e.remoteAddr.nodeAddress().address;try{await this.inboundConnectionRateLimiter.consume(t,1)}catch{return this.log("connection from %a refused - inboundConnectionThreshold exceeded by host %s",e.remoteAddr,t),!1}}return this.getConnections().length<this.maxConnections?(this.incomingPendingConnections++,!0):(this.log("connection from %a refused - maxConnections exceeded",e.remoteAddr),!1)}afterUpgradeInbound(){this.incomingPendingConnections--}getDialQueue(){const e={queued:"queued",running:"active",errored:"error",complete:"success"};return this.dialQueue.queue.queue.map((t=>({id:t.id,status:e[t.status],peerId:t.options.peerId,multiaddrs:[...t.options.multiaddrs].map((e=>G9(e)))})))}}class Ire{routers;started;components;constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}findProviders(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){if(0===t.routers.length)throw new Xp("No content routers available",rre.ERR_NO_ROUTERS_AVAILABLE);const n=t,i=new h0;for await(const s of fh(...n.routers.map((t=>t.findProviders(e,r)))))null!=s&&(s.multiaddrs.length>0&&await t.components.peerStore.merge(s.id,{multiaddrs:s.multiaddrs}),i.has(s.id)||(i.add(s.id),yield s))}()}catch(r){return Promise.reject(r)}}async provide(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(0===this.routers.length)throw new Xp("No content routers available",rre.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map((async r=>{await r.provide(e,t)})))}async put(e,t,r){if(!this.isStarted())throw new Xp(tre.NOT_STARTED_YET,rre.ERR_NODE_NOT_STARTED);await Promise.all(this.routers.map((async n=>{await n.put(e,t,r)})))}async get(e,t){if(!this.isStarted())throw new Xp(tre.NOT_STARTED_YET,rre.ERR_NODE_NOT_STARTED);return Promise.any(this.routers.map((async r=>r.get(e,t))))}}const Cre=globalThis.CustomEvent??Event;class Tre{log;peerId;peerStore;routers;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.log=e.logger.forComponent("libp2p:peer-routing"),this.peerId=e.peerId,this.peerStore=e.peerStore,this.routers=t.routers??[]}async findPeer(e,t){if(0===this.routers.length)throw new Xp("No peer routers available",rre.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.peerId.toString())throw new Xp("Should not try to find self",rre.ERR_FIND_SELF);const r=this,n=fh(...this.routers.map((n=>async function*(){try{yield await n.findPeer(e,t)}catch(i){r.log.error(i)}}())));for await(const i of n)if(null!=i)return i.multiaddrs.length>0&&await this.peerStore.merge(i.id,{multiaddrs:i.multiaddrs}),i;throw new Xp(tre.NOT_FOUND,rre.ERR_NOT_FOUND)}getClosestPeers(e){try{var t=this;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){if(0===t.routers.length)throw new Xp("No peer routers available",rre.ERR_NO_ROUTERS_AVAILABLE);const n=t,i=new h0;for await(const s of function(e){try{let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){let r=t.concurrency??1/0;r<1&&(r=1/0);const n=null!=t.ordered&&t.ordered,i=new EventTarget,s=[];let o,a=ah(),c=ah(),u=!1,l=!1;function h(){return n?s[0]?.done:Boolean(s.find((e=>e.done)))}function*d(){for(;s.length>0&&s[0].done;){const e=s[0];if(s.shift(),!e.ok)throw l=!0,a.resolve(),e.err;yield e.value,a.resolve()}}function*f(){for(;h();)for(let e=0;e<s.length;e++)if(s[e].done){const t=s[e];if(s.splice(e,1),e--,!t.ok)throw l=!0,a.resolve(),t.err;yield t.value,a.resolve()}}for(i.addEventListener("task-complete",(()=>{c.resolve()})),Promise.resolve().then((async()=>{try{for await(const t of e){if(s.length===r&&(a=ah(),await a.promise),l)break;const e={done:!1};s.push(e),t().then((t=>{e.done=!0,e.ok=!0,e.value=t,i.dispatchEvent(new Cre("task-complete"))}),(t=>{e.done=!0,e.err=t,i.dispatchEvent(new Cre("task-complete"))}))}u=!0,i.dispatchEvent(new Cre("task-complete"))}catch(t){o=t,i.dispatchEvent(new Cre("task-complete"))}}));;){if(h()||(c=ah(),await c.promise),null!=o)throw o;if(n?yield*d():yield*f(),u&&0===s.length)break}}()}catch(t){return Promise.reject(t)}}(async function*(){const t=fh(...n.routers.map((t=>t.getClosestPeers(e,r))));for await(let e of t)yield async()=>{if(0===e.multiaddrs.length)try{e=await n.findPeer(e.id,{...r,useCache:!1})}catch(t){return void n.log.error("could not find peer multiaddrs",t)}return e}}()))null!=s&&(s.multiaddrs.length>0&&await t.peerStore.merge(s.id,{multiaddrs:s.multiaddrs}),i.has(s.id)||(i.add(s.id),yield s))}()}catch(r){return Promise.reject(r)}}}class Rre{log;topologies;handlers;components;constructor(e){this.log=e.logger.forComponent("libp2p:registrar"),this.topologies=new Map,this.handlers=new Map,this.components=e,this._onDisconnect=this._onDisconnect.bind(this),this._onPeerUpdate=this._onPeerUpdate.bind(this),this._onPeerIdentify=this._onPeerIdentify.bind(this),this.components.events.addEventListener("peer:disconnect",this._onDisconnect),this.components.events.addEventListener("peer:update",this._onPeerUpdate),this.components.events.addEventListener("peer:identify",this._onPeerIdentify)}getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(e){const t=this.handlers.get(e);if(null==t)throw new Xp(`No handler registered for protocol ${e}`,rre.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}async handle(e,t,r){if(this.handlers.has(e))throw new Xp(`Handler already registered for protocol ${e}`,rre.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const n=ere.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},r);this.handlers.set(e,{handler:t,options:n}),await this.components.peerStore.merge(this.components.peerId,{protocols:[e]})}async unhandle(e){(Array.isArray(e)?e:[e]).forEach((e=>{this.handlers.delete(e)})),await this.components.peerStore.patch(this.components.peerId,{protocols:this.getProtocols()})}async register(e,t){if(null==t)throw new Xp("invalid topology",rre.ERR_INVALID_PARAMETERS);const r=`${(1e9*Math.random()).toString(36)}${Date.now()}`;let n=this.topologies.get(e);return null==n&&(n=new Map,this.topologies.set(e,n)),n.set(r,t),r}unregister(e){for(const[t,r]of this.topologies.entries())r.has(e)&&(r.delete(e),0===r.size&&this.topologies.delete(t))}_onDisconnect(e){const t=e.detail;this.components.peerStore.get(t).then((e=>{for(const r of e.protocols){const e=this.topologies.get(r);if(null!=e)for(const r of e.values())r.onDisconnect?.(t)}})).catch((e=>{e.code!==rre.ERR_NOT_FOUND&&this.log.error("could not inform topologies of disconnecting peer %p",t,e)}))}_onPeerUpdate(e){const{peer:t,previous:r}=e.detail,n=(r?.protocols??[]).filter((e=>!t.protocols.includes(e)));for(const i of n){const e=this.topologies.get(i);if(null!=e)for(const r of e.values())r.onDisconnect?.(t.id)}}_onPeerIdentify(e){const t=e.detail.protocols,r=e.detail.connection,n=e.detail.peerId;for(const i of t){const e=this.topologies.get(i);if(null!=e)for(const t of e.values())r.transient&&!0!==t.notifyOnTransient||t.onConnect?.(n,r)}}}class Pre extends Map{metric;constructor(e){super();const{name:t,metrics:r}=e;this.metric=r.registerMetric(t),this.updateComponentMetric()}set(e,t){return super.set(e,t),this.updateComponentMetric(),this}delete(e){const t=super.delete(e);return this.updateComponentMetric(),t}clear(){super.clear(),this.updateComponentMetric()}updateComponentMetric(){this.metric.update(this.size)}}class Dre{log;components;transports;listeners;faultTolerance;started;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.log=e.logger.forComponent("libp2p:transports"),this.components=e,this.started=!1,this.transports=new Map,this.listeners=function(e){const{name:t,metrics:r}=e;let n;return n=null!=r?new Pre({name:t,metrics:r}):new Map,n}({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=t.faultTolerance??oF.FATAL_ALL}add(e){const t=e[Symbol.toStringTag];if(null==t)throw new Xp("Transport must have a valid tag",rre.ERR_INVALID_KEY);if(this.transports.has(t))throw new Xp(`There is already a transport with the tag ${t}`,rre.ERR_DUPLICATE_TRANSPORT);this.log("adding transport %s",t),this.transports.set(t,e),this.listeners.has(t)||this.listeners.set(t,[])}isStarted(){return this.started}start(){this.started=!0}async afterStart(){const e=this.components.addressManager.getListenAddrs();await this.listen(e)}async stop(){const e=[];for(const[t,r]of this.listeners)for(this.log("closing listeners for %s",t);r.length>0;){const t=r.pop();null!=t&&e.push(t.close())}await Promise.all(e),this.log("all listeners closed");for(const t of this.listeners.keys())this.listeners.set(t,[]);this.started=!1}async dial(e,t){const r=this.transportForMultiaddr(e);if(null==r)throw new Xp(`No transport available for address ${String(e)}`,rre.ERR_TRANSPORT_UNAVAILABLE);try{return await r.dial(e,{...t,upgrader:this.components.upgrader})}catch(n){throw null==n.code&&(n.code=rre.ERR_TRANSPORT_DIAL_FAILED),n}}getAddrs(){let e=[];for(const t of this.listeners.values())for(const r of t)e=[...e,...r.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}transportForMultiaddr(e){for(const t of this.transports.values()){if(t.filter([e]).length>0)return t}}async listen(e){if(!this.isStarted())throw new Xp("Not started",rre.ERR_NODE_NOT_STARTED);if(null==e||0===e.length)return void this.log("no addresses were provided for listening, this node is dial only");const t=[];for(const[r,n]of this.transports.entries()){const i=n.filter(e),s=[];for(const e of i){this.log("creating listener for %s on %a",r,e);const t=n.createListener({upgrader:this.components.upgrader});let i=this.listeners.get(r)??[];null==i&&(i=[],this.listeners.set(r,i)),i.push(t),t.addEventListener("listening",(()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:t})})),t.addEventListener("close",(()=>{const e=i.findIndex((e=>e===t));i.splice(e,1),this.components.events.safeDispatchEvent("transport:close",{detail:t})})),s.push(t.listen(e))}if(0===s.length){t.push(r);continue}if(null==(await Promise.allSettled(s)).find((e=>"fulfilled"===e.status))&&this.faultTolerance!==oF.NO_FATAL)throw new Xp(`Transport (${r}) could not listen on any available address`,rre.ERR_NO_VALID_ADDRESSES)}if(t.length===this.transports.size){const e=`no valid addresses were provided for transports [${t.join(", ")}]`;if(this.faultTolerance===oF.FATAL_ALL)throw new Xp(e,rre.ERR_NO_VALID_ADDRESSES);this.log(`libp2p in dial mode only: ${e}`)}}async remove(e){const t=this.listeners.get(e)??[];this.log.trace("removing transport %s",e);const r=[];for(this.log.trace("closing listeners for %s",e);t.length>0;){const e=t.pop();null!=e&&r.push(e.close())}await Promise.all(r),this.transports.delete(e),this.listeners.delete(e)}async removeAll(){const e=[];for(const t of this.transports.keys())e.push(this.remove(t));await Promise.all(e)}}new Uint8Array(0);function Nre(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Bre=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const Ure=Bre;class Lre{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Mre{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return qre(this,e)}}class Ore{decoders;constructor(e){this.decoders=e}or(e){return qre(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function qre(e,t){return new Ore({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class Kre{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Lre(e,t,r),this.decoder=new Mre(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Fre(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Kre(t,r,n,i)}function Vre(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=Ure(n,t);return Fre({prefix:r,name:t,encode:i,decode:e=>Nre(s(e))})}function zre(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Fre({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const $re=Vre({prefix:"9",name:"base10",alphabet:"0123456789"}),Hre=zre({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),jre=zre({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Gre=zre({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Wre=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Yre=Wre.reduce(((e,t,r)=>(e[r]=t,e)),[]),Qre=Wre.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Jre=Fre({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Yre[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Qre[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),Xre=zre({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Zre=zre({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ene=zre({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tne=zre({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),rne=zre({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),nne=zre({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ine=zre({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),sne=zre({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),one=zre({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),ane=Vre({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),cne=Vre({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),une=Vre({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),lne=Vre({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),hne=zre({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),dne=zre({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),fne=zre({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),pne=zre({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),gne=zre({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),bne=Fre({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),yne=new TextEncoder,mne=new TextDecoder,wne="json",vne=512;function _ne(e){return yne.encode(JSON.stringify(e))}function Ene(e){return JSON.parse(mne.decode(e))}const Sne="raw",Ane=85;function kne(e){return Nre(e)}function xne(e){return Nre(e)}var Ine=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Rne;)r[n++]=255&t|Cne,t/=128;for(;t&Tne;)r[n++]=255&t|Cne,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Cne=128,Tne=-128,Rne=Math.pow(2,31);var Pne=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&Nne)<<s:(n&Nne)*Math.pow(2,s),s+=7}while(n>=Dne);return e.bytes=o-r,i},Dne=128,Nne=127;var Bne=Math.pow(2,7),Une=Math.pow(2,14),Lne=Math.pow(2,21),Mne=Math.pow(2,28),One=Math.pow(2,35),qne=Math.pow(2,42),Kne=Math.pow(2,49),Fne=Math.pow(2,56),Vne=Math.pow(2,63);const zne={encode:Ine,decode:Pne,encodingLength:function(e){return e<Bne?1:e<Une?2:e<Lne?3:e<Mne?4:e<One?5:e<qne?6:e<Kne?7:e<Fne?8:e<Vne?9:10}};function $ne(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return zne.encode(e,t,r),t}function Hne(e){return zne.encodingLength(e)}function jne(e,t){const r=t.byteLength,n=Hne(e),i=n+Hne(r),s=new Uint8Array(i+r);return $ne(e,s,0),$ne(r,s,n),s.set(t,i),new Gne(e,r,t,s)}class Gne{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const Wne=Nre;const Yne={code:0,name:"identity",encode:Wne,digest:function(e){return jne(0,Wne(e))}};function Qne(e){let{name:t,code:r,encode:n}=e;return new Jne(t,r,n)}class Jne{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?jne(this.code,t):t.then((e=>jne(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Xne(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Zne=Qne({name:"sha2-256",code:18,encode:Xne("SHA-256")}),eie=Qne({name:"sha2-512",code:19,encode:Xne("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const tie={...Ei,...gi,..._i,...fi,...pi,...yi,...mi,...wi,...vi,...bi};function rie(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const nie=rie("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),iie=rie("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),sie={utf8:nie,"utf-8":nie,hex:tie.base16,latin1:iie,ascii:iie,binary:iie,...tie};function oie(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=sie[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}const aie="/multistream/1.0.0",cie=1024;const uie=oie("\n");async function lie(e,t,r){await e.write(t,r)}async function hie(e,t){const r=await async function(e,t){const r=await e.read(t);if(0===r.byteLength||r.get(r.byteLength-1)!==uie[0])throw t.log.error("Invalid mss message - missing newline",r),new Xp("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return r.sublist(0,-1)}(e,t);return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=sie[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}(r.subarray())}async function die(e,t,r){t=Array.isArray(t)?t:[t],r.log.trace("handle: available protocols %s",t);const n=Sd(e,{...r,maxDataLength:cie,maxLengthLength:2});for(;;){r.log.trace("handle: reading incoming string");const e=await hie(n,r);if(r.log.trace('handle: read "%s"',e),e!==aie){if(t.includes(e))return r.log.trace('handle: respond with "%s" for "%s"',e,e),await lie(n,oie(`${e}\n`),r),r.log.trace('handle: responded with "%s" for "%s"',e,e),{stream:n.unwrap(),protocol:e};if("ls"!==e)r.log('handle: respond with "na" for "%s"',e),await lie(n,oie("na\n"),r),r.log('handle: responded with "na" for "%s"',e);else{const i=new Zl(...t.map((e=>rh.single(oie(`${e}\n`)))),oie("\n"));r.log.trace('handle: respond with "%s" for %s',t,e),await lie(n,i,r),r.log.trace('handle: responded with "%s" for %s',t,e)}}else r.log.trace('handle: respond with "%s" for "%s"',aie,e),await lie(n,oie(`${aie}\n`),r),r.log.trace('handle: responded with "%s" for "%s"',aie,e)}}async function fie(e,t,r){if(1===(t=Array.isArray(t)?[...t]:[t]).length&&!1===r.negotiateFully)return function(e,t,r){const n=e.sink.bind(e),i=e.source;let s=!1,o=!1;const a=ah();let c=!1,u=!1;const l=ah();let h=!1,d=!1;const f=ah(),p=Sd({sink:n,source:i},{...r,maxDataLength:cie});async function g(){if(o)return r.log.trace("optimistic: already negotiating %s stream",t),void await a.promise;o=!0;try{c||(r.log.trace("optimistic: doing send protocol for %s stream",t),await b()),h||(r.log.trace("optimistic: doing read protocol for %s stream",t),await y())}finally{o=!1,s=!0,a.resolve()}}async function b(){if(u)await l.promise;else{u=!0;try{r.log.trace('optimistic: write ["%s", "%s", data] in source',aie,t),await p.writeV([oie(`${aie}\n`),oie(`${t}\n`)]),r.log.trace('optimistic: wrote ["%s", "%s", data] in source',aie,t)}finally{c=!0,u=!1,l.resolve()}}}async function y(){if(d)await f.promise;else{d=!0;try{r.log.trace("optimistic: reading multistream select header");let e=await hie(p,r);if(r.log.trace('optimistic: read multistream select header "%s"',e),e===aie&&(e=await hie(p,r)),r.log.trace('optimistic: read protocol "%s", expecting "%s"',e,t),e!==t)throw new Xp("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}finally{h=!0,d=!1,f.resolve()}}}if(e.sink=async e=>{const{sink:n}=p.unwrap();await n(async function*(){let n=!1;for await(const i of e){if(u&&await l.promise,c)yield i;else{u=!0,r.log.trace('optimistic: write ["%s", "%s", data(%d)] in sink',aie,t,i.byteLength);const e=`${t}\n`;yield new Zl(Uint8Array.from([19]),oie(`${aie}\n`),ms(e.length),oie(e),i).subarray(),r.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink',aie,t,i.byteLength),c=!0,u=!1,l.resolve(),g().catch((e=>{r.log.error("could not finish optimistic protocol negotiation of %s",t,e)}))}n=!0}n||await g()}())},e.source=async function*(){await g(),r.log.trace('optimistic: reading data from "%s" stream',t),yield*p.unwrap().source}(),null!=e.closeRead){const t=e.closeRead.bind(e);e.closeRead=async e=>{s||await g().catch((e=>{r.log.error("could not negotiate protocol before close read",e)})),await t(e)}}if(null!=e.closeWrite){const t=e.closeWrite.bind(e);e.closeWrite=async e=>{s||await g().catch((e=>{r.log.error("could not negotiate protocol before close write",e)})),await t(e)}}if(null!=e.close){const t=e.close.bind(e);e.close=async e=>{const r=[];u&&r.push(l.promise),d&&r.push(f.promise),r.length>0?await yd(Promise.all(r),e?.signal):(s=!0,o=!1,a.resolve()),await t(e)}}return{stream:e,protocol:t}}(e,t[0],r);const n=Sd(e,{...r,maxDataLength:cie}),i=t.shift();if(null==i)throw new Error("At least one protocol must be specified");r.log.trace('select: write ["%s", "%s"]',aie,i);const s=oie(`${aie}\n`),o=oie(`${i}\n`);await async function(e,t,r){await e.writeV(t,r)}(n,[s,o],r),r.log.trace("select: reading multistream-select header");let a=await hie(n,r);if(r.log.trace('select: read "%s"',a),a===aie&&(r.log.trace("select: reading protocol response"),a=await hie(n,r),r.log.trace('select: read "%s"',a)),a===i)return{stream:n.unwrap(),protocol:i};for(const c of t){r.log.trace('select: write "%s"',c),await lie(n,oie(`${c}\n`),r),r.log.trace("select: reading protocol response");const e=await hie(n,r);if(r.log.trace('select: read "%s" for "%s"',e,c),e===c)return{stream:n.unwrap(),protocol:c}}throw new Xp("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}const pie=Symbol.for("@libp2p/connection");class gie{id;remoteAddr;remotePeer;direction;timeline;multiplexer;encryption;status;transient;log;tags;_newStream;_close;_abort;_getStreams;constructor(e){const{remoteAddr:t,remotePeer:r,newStream:n,close:i,abort:s,getStreams:o}=e;this.id=`${parseInt(String(1e9*Math.random())).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=r,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}`),null==this.remoteAddr.getPeerId()&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=n,this._close=i,this._abort=s,this._getStreams=o,this.tags=[]}[Symbol.toStringTag]="Connection";[pie]=!0;get streams(){return this._getStreams()}async newStream(e,t){if("closing"===this.status)throw new Xp("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if("closed"===this.status)throw new Xp("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&!0!==t?.runOnTransientConnection)throw new Xp("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");const r=await this._newStream(e,t);return r.direction="outbound",r}async close(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if("closed"!==this.status&&"closing"!==this.status){if(this.log("closing connection to %a",this.remoteAddr),this.status="closing",null==e.signal){const t=AbortSignal.timeout(500);id(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 bie(e,t,r){let n=0;return r.streams.forEach((r=>{r.direction===t&&r.protocol===e&&n++})),n}class yie{components;connectionEncryption;muxers;inboundUpgradeTimeout;events;constructor(e,t){this.components=e,this.connectionEncryption=new Map,t.connectionEncryption.forEach((e=>{this.connectionEncryption.set(e.protocol,e)})),this.muxers=new Map,t.muxers.forEach((e=>{this.muxers.set(e.protocol,e)})),this.inboundUpgradeTimeout=t.inboundUpgradeTimeout??2e3,this.events=e.events}async shouldBlockConnection(e,t,r){const n=this.components.connectionGater[r];if(void 0!==n&&await n(e,t))throw new Xp(`The multiaddr connection is blocked by gater.${r}`,rre.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new Xp("connection denied",rre.ERR_CONNECTION_DENIED);let r,n,i,s,o;const a=AbortSignal.timeout(this.inboundUpgradeTimeout),c=()=>{e.abort(new Xp("inbound upgrade timeout",eg))};a.addEventListener("abort",c,{once:!0}),id(1/0,a);try{if(!0===await(this.components.connectionGater.denyInboundConnection?.(e)))throw new Xp("The multiaddr connection is blocked by gater.acceptConnection",rre.ERR_CONNECTION_INTERCEPTED);this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the inbound connection upgrade");let a=e;if(!0!==t?.skipProtection){const t=this.components.connectionProtector;null!=t&&(e.log("protecting the inbound connection"),a=await t.protect(e))}try{if(r=a,!0!==t?.skipEncryption){({conn:r,remotePeer:n,protocol:o}=await this._encryptInbound(a));const e={...a,...r};await this.shouldBlockConnection(n,e,"denyInboundEncryptedConnection")}else{const t=e.remoteAddr.getPeerId();if(null==t)throw new Xp("inbound connection that skipped encryption must have a peer id",rre.ERR_INVALID_MULTIADDR);const r=_0(t);o="native",n=r}if(i=r,null!=t?.muxerFactory)s=t.muxerFactory;else if(this.muxers.size>0){const e=await this._multiplexInbound({...a,...r},this.muxers);s=e.muxerFactory,i=e.stream}}catch(u){throw e.log.error("failed to upgrade inbound connection",u),u}return await this.shouldBlockConnection(n,e,"denyInboundUpgradedConnection"),e.log("successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:o,direction:"inbound",maConn:e,upgradedConn:i,muxerFactory:s,remotePeer:n,transient:t?.transient})}finally{a.removeEventListener("abort",c),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(e,t){const r=e.remoteAddr.getPeerId();let n,i,s,o,a,c;null!=r&&(n=_0(r),await this.shouldBlockConnection(n,e,"denyOutboundConnection")),this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the outbound connection upgrade");let u=e;if(!0!==t?.skipProtection){const t=this.components.connectionProtector;null!=t&&(u=await t.protect(e))}try{if(i=u,!0!==t?.skipEncryption){({conn:i,remotePeer:s,protocol:a}=await this._encryptOutbound(u,n));const e={...u,...i};await this.shouldBlockConnection(s,e,"denyOutboundEncryptedConnection")}else{if(null==n)throw new Xp("Encryption was skipped but no peer id was passed",rre.ERR_INVALID_PEER);a="native",s=n}if(o=i,null!=t?.muxerFactory)c=t.muxerFactory;else if(this.muxers.size>0){const e=await this._multiplexOutbound({...u,...i},this.muxers);c=e.muxerFactory,o=e.stream}}catch(l){throw e.log.error("failed to upgrade outbound connection",l),await e.close(l),l}return await this.shouldBlockConnection(s,e,"denyOutboundUpgradedConnection"),e.log("successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:a,direction:"outbound",maConn:e,upgradedConn:o,muxerFactory:c,remotePeer:s,transient:t?.transient})}_createConnection(e){var t=this;const{cryptoProtocol:r,direction:n,maConn:i,upgradedConn:s,remotePeer:o,muxerFactory:a,transient:c}=e;let u,l,h;null!=a&&(u=a.createStreamMuxer({direction:n,onIncomingStream:e=>{null!=h&&Promise.resolve().then((async()=>{const t=this.components.registrar.getProtocols(),{stream:r,protocol:n}=await die(e,t,{log:e.log,yieldBytes:!1});if(null==h)return;h.log("incoming stream opened on %s",n);const i=function(e,t){try{const{options:r}=t.getHandler(e);return r.maxInboundStreams}catch(r){if(r.code!==rre.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return 32}(n,this.components.registrar);if(bie(n,"inbound",h)===i){const t=new Xp(`Too many inbound protocol streams for protocol "${n}" - limit ${i}`,rre.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw e.abort(t),t}e.source=r.source,e.sink=r.sink,e.protocol=n,null!=r.closeWrite&&(e.closeWrite=r.closeWrite),null!=r.closeRead&&(e.closeRead=r.closeRead),null!=r.close&&(e.close=r.close),await this.components.peerStore.merge(o,{protocols:[n]}),this.components.metrics?.trackProtocolStream(e,h),this._onStream({connection:h,stream:e,protocol:n})})).catch((async t=>{h.log.error("error handling incoming stream id %s",e.id,t.message,t.code,t.stack),null==e.timeline.close&&await e.close()}))}}),l=async function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==u)throw new Xp("Stream is not multiplexed",rre.ERR_MUXER_UNAVAILABLE);h.log("starting new stream for protocols %s",e);const n=await u.newStream();h.log.trace("started new stream %s for protocols %s",n.id,e);try{if(null==r.signal){n.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",e);const t=AbortSignal.timeout(3e4);id(1/0,t),r={...r,signal:t}}n.log.trace("selecting protocol from protocols %s",e);const{stream:i,protocol:s}=await fie(n,e,{...r,log:n.log,yieldBytes:!0});n.log("selected protocol %s",s);const a=function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{const{options:r}=t.getHandler(e);if(null!=r.maxOutboundStreams)return r.maxOutboundStreams}catch(n){if(n.code!==rre.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return r.maxOutboundStreams??64}(s,t.components.registrar,r);if(bie(s,"outbound",h)>=a){const e=new Xp(`Too many outbound protocol streams for protocol "${s}" - limit ${a}`,rre.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw n.abort(e),e}return await t.components.peerStore.merge(o,{protocols:[s]}),n.source=i.source,n.sink=i.sink,n.protocol=s,null!=i.closeWrite&&(n.closeWrite=i.closeWrite),null!=i.closeRead&&(n.closeRead=i.closeRead),null!=i.close&&(n.close=i.close),t.components.metrics?.trackProtocolStream(n,h),n}catch(i){if(h.log.error("could not create new stream for protocols %s",e,i),null==n.timeline.close&&n.abort(i),null!=i.code)throw i;throw new Xp(String(i),rre.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([u.sink(s.source),s.sink(u.source)]).catch((e=>{h.log.error("error piping data through muxer",e)})));const d=i.timeline;i.timeline=new Proxy(d,{set:function(){return null!=h&&"close"===(arguments.length<=1?void 0:arguments[1])&&null!=(arguments.length<=2?void 0:arguments[2])&&null==d.close&&(async()=>{try{"open"===h.status&&await h.close()}catch(e){h.log.error("error closing connection after timeline close",e)}finally{t.events.safeDispatchEvent("connection:close",{detail:h})}})().catch((e=>{h.log.error("error thrown while dispatching connection:close event",e)})),Reflect.set(...arguments)}}),i.timeline.upgraded=Date.now();var f;return f={remoteAddr:i.remoteAddr,remotePeer:o,status:"open",direction:n,timeline:i.timeline,multiplexer:u?.protocol,encryption:r,transient:c,logger:this.components.logger,newStream:l??(()=>{throw new Xp("connection is not multiplexed",rre.ERR_CONNECTION_NOT_MULTIPLEXED)}),getStreams:()=>null!=u?u.streams:[],close:async e=>{null!=u&&(h.log.trace("close muxer"),await u.close(e)),h.log.trace("close maconn"),await i.close(e),h.log.trace("closed maconn")},abort:e=>{i.abort(e),null!=u&&u.abort(e)}},h=new gie(f),this.events.safeDispatchEvent("connection:open",{detail:h}),h}_onStream(e){const{connection:t,stream:r,protocol:n}=e,{handler:i,options:s}=this.components.registrar.getHandler(n);if(t.transient&&!0!==s.runOnTransientConnection)throw new Xp("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");i({connection:t,stream:r})}async _encryptInbound(e){const t=Array.from(this.connectionEncryption.keys());e.log("handling inbound crypto protocol selection",t);try{const{stream:r,protocol:n}=await die(e,t,{log:e.log}),i=this.connectionEncryption.get(n);if(null==i)throw new Error(`no crypto module found for ${n}`);return e.log("encrypting inbound connection using",n),{...await i.secureInbound(this.components.peerId,r),protocol:n}}catch(r){throw e.log.error("encrypting inbound connection to %p failed",r),new Xp(r.message,rre.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){const r=Array.from(this.connectionEncryption.keys());e.log("selecting outbound crypto protocol",r);try{e.log.trace("selecting encrypter from %s",r);const{stream:n,protocol:i}=await fie(e,r,{log:e.log,yieldBytes:!0}),s=this.connectionEncryption.get(i);if(null==s)throw new Error(`no crypto module found for ${i}`);return e.log("encrypting outbound connection to %p using %s",t,s),{...await s.secureOutbound(this.components.peerId,n,t),protocol:i}}catch(n){throw e.log.error("encrypting outbound connection to %p failed",n),new Xp(n.message,rre.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){const r=Array.from(t.keys());e.log("outbound selecting muxer %s",r);try{e.log.trace("selecting stream muxer from %s",r);const{stream:n,protocol:i}=await fie(e,r,{log:e.log,yieldBytes:!0});e.log("selected %s as muxer protocol",i);return{stream:n,muxerFactory:t.get(i)}}catch(n){throw e.log.error("error multiplexing outbound connection",n),new Xp(String(n),rre.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){const r=Array.from(t.keys());e.log("inbound handling muxers %s",r);try{const{stream:n,protocol:i}=await die(e,r,{log:e.log});return{stream:n,muxerFactory:t.get(i)}}catch(n){throw e.log.error("error multiplexing inbound connection",n),new Xp(String(n),rre.ERR_MUXER_UNAVAILABLE)}}}class mie extends sd{peerId;peerStore;contentRouting;peerRouting;metrics;services;logger;status;components;log;constructor(e){super(),this.status="stopped";const t=new sd,r=t.dispatchEvent.bind(t);t.dispatchEvent=e=>{const t=r(e),n=this.dispatchEvent(new ad(e.type,{detail:e.detail}));return t||n},id(1/0,t),this.peerId=e.peerId,this.logger=e.logger??mX(),this.log=this.logger.forComponent("libp2p"),this.services={};const n=this.components=function(){const e=new see(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return new Proxy(e,{get(t,r,n){if("string"===typeof r&&!aee.includes(r)){const t=e.components[r];if(null==t&&!oee.includes(r))throw new Xp(`${r} not set`,"ERR_SERVICE_MISSING");return t}return Reflect.get(t,r,n)},set:(t,r,n)=>("string"===typeof r?e.components[r]=n:Reflect.set(t,r,n),!0)})}({peerId:e.peerId,privateKey:e.privateKey,nodeInfo:e.nodeInfo??{name:"libp2p",version:"1.3.3"},logger:this.logger,events:t,datastore:e.datastore??new eee,connectionGater:hee(e.connectionGater),dns:e.dns});this.peerStore=this.configureComponent("peerStore",new b9(n,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),null!=e.metrics&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),n.events.addEventListener("peer:update",(e=>{if(null==e.detail.previous){const t={id:e.detail.peer.id,multiaddrs:e.detail.peer.addresses.map((e=>e.multiaddr))};n.events.safeDispatchEvent("peer:discovery",{detail:t})}})),null!=e.connectionProtector&&this.configureComponent("connectionProtector",e.connectionProtector(n)),this.components.upgrader=new yie(this.components,{connectionEncryption:(e.connectionEncryption??[]).map(((e,t)=>this.configureComponent(`connection-encryption-${t}`,e(this.components)))),muxers:(e.streamMuxers??[]).map(((e,t)=>this.configureComponent(`stream-muxers-${t}`,e(this.components)))),inboundUpgradeTimeout:e.connectionManager.inboundUpgradeTimeout}),this.configureComponent("transportManager",new Dre(this.components,e.transportManager)),this.configureComponent("connectionManager",new xre(this.components,e.connectionManager)),this.configureComponent("registrar",new Rre(this.components)),this.configureComponent("addressManager",new nee(this.components,e.addresses));const i=(e.peerRouters??[]).map(((e,t)=>this.configureComponent(`peer-router-${t}`,e(this.components))));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new Tre(this.components,{routers:i}));const s=(e.contentRouters??[]).map(((e,t)=>this.configureComponent(`content-router-${t}`,e(this.components))));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new Ire(this.components,{routers:s})),(e.peerDiscovery??[]).forEach(((e,t)=>{this.configureComponent(`peer-discovery-${t}`,e(this.components)).addEventListener("peer",(e=>{this.#B(e)}))})),e.transports?.forEach(((e,t)=>{this.components.transportManager.add(this.configureComponent(`transport-${t}`,e(this.components)))})),null!=e.services)for(const o of Object.keys(e.services)){const t=(0,e.services[o])(this.components);null!=t?(this.services[o]=t,this.configureComponent(o,t),null!=t[bX]&&(this.log("registering service %s for content routing",o),s.push(t[bX])),null!=t[yX]&&(this.log("registering service %s for peer routing",o),i.push(t[yX])),null!=t[d_]&&(this.log("registering service %s for peer discovery",o),t[d_].addEventListener?.("peer",(e=>{this.#B(e)})))):this.log.error("service factory %s returned null or undefined instance",o)}}configureComponent(e,t){return null==t&&this.log.error("component %s was null or undefined",e),this.components[e]=t,t}async start(){if("stopped"===this.status){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(){"started"===this.status&&(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(){const e=new h0;for(const t of this.components.connectionManager.getConnections())e.add(t.remotePeer);return Array.from(e)}async dial(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.components.connectionManager.openConnection(e,{priority:75,...t})}async dialProtocol(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null==t)throw new Xp("no protocols were provided to open a stream",rre.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw new Xp("no protocols were provided to open a stream",rre.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,r)).newStream(t,r)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};j9(e)&&(e=_0(e.getPeerId()??"")),await this.components.connectionManager.closeConnections(e,t)}async getPublicKey(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.log("getPublicKey %p",e),null!=e.publicKey)return e.publicKey;try{const t=await this.peerStore.get(e);if(null!=t.id.publicKey)return t.id.publicKey}catch(i){if(i.code!==rre.ERR_NOT_FOUND)throw i}const r=QQ([$Q("/pk/"),e.multihash.digest]),n=await this.contentRouting.get(r,t);return function(e){const t=NJ.decode(e),r=t.Data??new Uint8Array;switch(t.Type){case PJ.RSA:return fX.rsa.unmarshalRsaPublicKey(r);case PJ.Ed25519:return fX.ed25519.unmarshalEd25519PublicKey(r);case PJ.Secp256k1:return fX.secp256k1.unmarshalSecp256k1PublicKey(r);default:throw pX(t.Type??"unknown")}}(n),await this.peerStore.patch(e,{publicKey:n}),n}async handle(e,t,r){Array.isArray(e)||(e=[e]),await Promise.all(e.map((async e=>{await this.components.registrar.handle(e,t,r)})))}async unhandle(e){Array.isArray(e)||(e=[e]),await Promise.all(e.map((async e=>{await this.components.registrar.unhandle(e)})))}async register(e,t){return this.components.registrar.register(e,t)}unregister(e){this.components.registrar.unregister(e)}#B(e){const{detail:t}=e;t.id.toString()!==this.peerId.toString()?this.components.peerStore.merge(t.id,{multiaddrs:t.multiaddrs}).catch((e=>{this.log.error(e)})):this.log.error(new Error(rre.ERR_DISCOVERED_SELF))}}async function wie(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.peerId??=await j3();if(null==t.privateKey)throw new Xp("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return e.privateKey??=await gX(t.privateKey),new mie(await ire(e))}(e);return!1!==e.start&&await t.start(),t}class vie{numPeers;constructor(e){this.numPeers=e?.numPeersToUse??3}}const _ie=new Ll("sdk:light-push");class Eie extends vie{protocol;constructor(e,t){super({numPeersToUse:t?.numPeersToUse??3}),this.protocol=new qh(e,t)}async send(e,t){const r=[],n=[],{pubsubTopic:i}=e;try{Il(i,this.protocol.pubsubTopics)}catch(c){return _ie.error("Failed to send waku light push: pubsub topic not configured"),{failures:[{error:Mc.TOPIC_NOT_CONFIGURED}],successes:[]}}const s=await this.protocol.getPeers();if(!s.length)return{successes:r,failures:[{error:Mc.NO_PEER_AVAILABLE}]};const o=s.map((r=>this.protocol.send(e,t,r))),a=await Promise.allSettled(o);for(const u of a)if("fulfilled"===u.status){const{failure:e,success:t}=u.value;t&&r.push(t),e&&n.push(e)}else _ie.error("Failed to send message to peer",u.reason),n.push({error:Mc.GENERIC_FAIL});return{successes:r,failures:n}}}const Sie=new Ll("waku:store:protocol");class Aie extends vie{protocol;constructor(e,t){super({numPeersToUse:1}),this.protocol=new jh(e,t)}async*queryGenerator(e,t){const{pubsubTopic:r,contentTopics:n,decodersAsMap:i}=this.validateDecodersAndPubsubTopic(e,t),s=this.constructOptions(r,n,t),o=(await this.protocol.getPeers({numPeers:this.numPeers,maxBootstrapPeers:1}))[0];if(!o)throw new Error("No peers available to query");const a=this.protocol.queryPerPage(s,i,o);for await(const c of a)yield c}async queryWithOrderedCallback(e,t,r){for await(const n of this.queryGenerator(e,r))if(await this.processMessages(n,t,r))break}async queryWithPromiseCallback(e,t,r){let n=!1;for await(const i of this.queryGenerator(e,r)){const e=i.map((async e=>{n||(n=Boolean(await t(e)))}));if(await Promise.all(e),n)break}}createCursor(e){if(!e||!e.timestamp||!e.payload||!e.contentTopic)throw new Error("Message is missing required fields");const t=El(e.contentTopic),r=Uc(Sl([t,e.payload])),n=BigInt(e.timestamp.getTime())*BigInt(1e6);return{digest:r,pubsubTopic:e.pubsubTopic,senderTime:n,receiverTime:n}}validateDecodersAndPubsubTopic(e,t){if(0===e.length)throw new Error("No decoders provided");const r=Array.from(new Set(e.map((e=>e.pubsubTopic))));if(r.length>1)throw new Error("API does not support querying multiple pubsub topics at once");const n=r[0];if(Il(n,this.protocol.pubsubTopics),t?.cursor?.pubsubTopic&&t.cursor.pubsubTopic!==n)throw new Error(`Cursor pubsub topic (${t?.cursor?.pubsubTopic}) does not match decoder pubsub topic (${n})`);const i=new Map;e.forEach((e=>{if(i.has(e.contentTopic))throw new Error("API does not support different decoder per content topic");i.set(e.contentTopic,e)}));const s=e.filter((e=>e.pubsubTopic===n)).map((e=>e.contentTopic));if(0===s.length)throw new Error("No decoders found for topic "+n);return{pubsubTopic:n,contentTopics:s,decodersAsMap:i}}constructOptions(e,t){let r,n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};i?.timeFilter&&(r=i.timeFilter.startTime,n=i.timeFilter.endTime),r||Sie.warn("No start time provided"),n||Sie.warn("No end time provided");return Object.assign({pubsubTopic:e,pageDirection:Oc.BACKWARD,pageSize:10},i,{contentTopics:t,startTime:r,endTime:n})}async processMessages(e,t,r){let n=!1;let i=(await Promise.all(e)).filter(ac);return this.shouldReverseOrder(r)&&(i=i.reverse()),await Promise.all(i.map((async e=>{e&&!n&&(n=Boolean(await t(e)))}))),n}shouldReverseOrder(e){return"undefined"===typeof e?.pageDirection||e?.pageDirection===Oc.BACKWARD}}async function kie(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await async function(e){const t=e.shardInfo?Pl(e.shardInfo):void 0;e.pubsubTopics=t?.pubsubTopics??e.pubsubTopics??[Vc];const r=e?.libp2p??{},n=r.peerDiscovery??[];e?.defaultBootstrap&&n.push(...(i=e.pubsubTopics,[Ufe([Rie.SANDBOX],Jfe),Qfe(),Hfe(i)]));var i;e?.bootstrapPeers&&n.push((s={list:e.bootstrapPeers},e=>new wC(e,s)));var s;r.peerDiscovery=n;const o=await async function(e,t,r,n){r?.hideWebSocketInfo||(console.info("%cIgnore WebSocket connection failures","background: gray; color: white; font-size: x-large"),console.info("%cWaku tries to discover peers and some of them are expected to fail","background: gray; color: white; font-size: x-large"));const i=t?{pubsub:t}:{},s=e?{metadata:gd(e)}:{};return wie({connectionManager:{minConnections:1},transports:[JV({filter:YV})],streamMuxers:[eF()],connectionEncryption:[h_()],...r,services:{identify:ZO({agentVersion:n??Iie}),ping:iF(),...s,...i,...r?.services}})}(t?.shardInfo,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>{e={...e,msgIdFn:e=>{let{data:t}=e;return Uc(t)},globalSignaturePolicy:UH.StrictNoSign,fallbackToFloodsub:!1};const r=new nY(t,e);return r.multicodecs=iY,r}}(e),r,e?.userAgent);return o}(e),r=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Aie(t,e)}(e),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Eie(t,e)}(e),i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{pubsubTopics:[]};return t=>new Lh(t,e)}(e);return new Tie(e,t,r,n,i)}async function xie(e,t,r){if(!e.filter)throw new Error("Filter protocol missing from Waku node");const{shardInfo:n}=e.libp2p.components.metadata;if(!n)throw new Error("Shard info missing from Waku node.");const i=kl(n),s=Tl(t);if(!i.includes(s))throw new Error("Content topic does not match any pubsub topic in shard info.");await e.dial(r),await td(e,[Lc.Filter]);let o=zl(t,s);o&&(o=o??o);return{decoder:o,subscription:await e.filter.createSubscription(s)}}const Iie="js-waku",Cie=new Ll("waku");class Tie{libp2p;relay;store;filter;lightPush;connectionManager;pubsubTopics;constructor(e,t,r,n,i,s){if(0==e.pubsubTopics.length)throw new Error("At least one pubsub topic must be provided");this.pubsubTopics=e.pubsubTopics,this.libp2p=t,r&&(this.store=r(t)),i&&(this.filter=i(t)),n&&(this.lightPush=n(t)),s&&(this.relay=s(t));const o=e.pingKeepAlive||300,a=this.relay?e.relayKeepAlive||300:0,c=this.libp2p.peerId.toString();this.connectionManager=hd.create(c,t,{pingKeepAlive:o,relayKeepAlive:a},this.pubsubTopics,this.relay),Cie.info("Waku node created",c,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}async dial(e,t){const r=t??[],n=function(e){return _m(e)?e:mC(e)}(e);"undefined"===typeof t&&(this.relay&&r.push(Lc.Relay),this.store&&r.push(Lc.Store),this.filter&&r.push(Lc.Filter),this.lightPush&&r.push(Lc.LightPush));const i=[];return r.includes(Lc.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach((e=>i.push(e))):Cie.error("Relay codec not included in dial codec: protocol not mounted locally")),r.includes(Lc.Store)&&(this.store?i.push(this.store.protocol.multicodec):Cie.error("Store codec not included in dial codec: protocol not mounted locally")),r.includes(Lc.LightPush)&&(this.lightPush?i.push(this.lightPush.protocol.multicodec):Cie.error("Light Push codec not included in dial codec: protocol not mounted locally")),r.includes(Lc.Filter)&&(this.filter?i.push(this.filter.multicodec):Cie.error("Filter codec not included in dial codec: protocol not mounted locally")),Cie.info(`Dialing to ${n.toString()} with protocols ${r}`),this.libp2p.dialProtocol(n,i)}async start(){await this.libp2p.start()}async stop(){this.connectionManager.stop(),await this.libp2p.stop()}async subscribeToContentTopic(e,t,r){return(await async function(e,t,r){r.waku=r.waku??await kie({shardInfo:{contentTopics:[e]}});const{decoder:n,subscription:i}=await xie(r.waku,e,r.peer);return await i.subscribe(n,t),{subscription:i,waku:r.waku}}(e,r,{waku:this,peer:t})).subscription}isStarted(){return"started"==this.libp2p.status}isConnected(){return this.connectionManager.isConnected()}getLocalMultiaddrWithID(){const e=this.libp2p.getMultiaddrs().find((e=>e.toString().match(/127\.0\.0\.1/)));if(!e||""===e.toString())throw"Not listening on localhost";return e+"/p2p/"+this.libp2p.peerId.toString()}}const Rie={TEST:"enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im",SANDBOX:"enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im"},Pie="bootstrap",Die={store:2,filter:1,lightPush:1};var Nie=__webpack_require__(495),Bie=__webpack_require__.t(Nie,2);const Uie=BigInt(0),Lie=BigInt(1),Mie=BigInt(2),Oie=BigInt(3),qie=BigInt(8),Kie=Object.freeze({a:Uie,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Lie,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),Fie=(e,t)=>(e+t/Mie)/t,Vie={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=Kie,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Lie*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,o=BigInt("0x100000000000000000000000000000000"),a=Fie(s*e,t),c=Fie(-n*e,t);let u=yse(e-a*r-c*i,t),l=yse(-a*n-c*s,t);const h=u>o,d=l>o;if(h&&(u=t-u),d&&(l=t-l),u>o||l>o)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:h,k1:u,k2neg:d,k2:l}}},zie=32,$ie=32,Hie=32,jie=zie+1,Gie=2*zie+1;function Wie(e){const{a:t,b:r}=Kie,n=yse(e*e),i=yse(n*e);return yse(i+t*e+r)}const Yie=Kie.a===Uie;class Qie extends Error{constructor(e){super(e)}}function Jie(e){if(!(e instanceof Xie))throw new TypeError("JacobianPoint expected")}class Xie{constructor(e,t,r){this.x=e,this.y=t,this.z=r}static fromAffine(e){if(!(e instanceof tse))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(tse.ZERO)?Xie.ZERO:new Xie(e.x,e.y,Lie)}static toAffineBatch(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Kie.P;const r=new Array(e.length),n=wse(e.reduce(((e,n,i)=>n===Uie?e:(r[i]=e,yse(e*n,t))),Lie),t);return e.reduceRight(((e,n,i)=>n===Uie?e:(r[i]=yse(e*r[i],t),yse(e*n,t))),n),r}(e.map((e=>e.z)));return e.map(((e,r)=>e.toAffine(t[r])))}static normalizeZ(e){return Xie.toAffineBatch(e).map(Xie.fromAffine)}equals(e){Jie(e);const{x:t,y:r,z:n}=this,{x:i,y:s,z:o}=e,a=yse(n*n),c=yse(o*o),u=yse(t*c),l=yse(i*a),h=yse(yse(r*o)*c),d=yse(yse(s*n)*a);return u===l&&h===d}negate(){return new Xie(this.x,yse(-this.y),this.z)}double(){const{x:e,y:t,z:r}=this,n=yse(e*e),i=yse(t*t),s=yse(i*i),o=e+i,a=yse(Mie*(yse(o*o)-n-s)),c=yse(Oie*n),u=yse(c*c),l=yse(u-Mie*a),h=yse(c*(a-l)-qie*s),d=yse(Mie*t*r);return new Xie(l,h,d)}add(e){Jie(e);const{x:t,y:r,z:n}=this,{x:i,y:s,z:o}=e;if(i===Uie||s===Uie)return this;if(t===Uie||r===Uie)return e;const a=yse(n*n),c=yse(o*o),u=yse(t*c),l=yse(i*a),h=yse(yse(r*o)*c),d=yse(yse(s*n)*a),f=yse(l-u),p=yse(d-h);if(f===Uie)return p===Uie?this.double():Xie.ZERO;const g=yse(f*f),b=yse(f*g),y=yse(u*g),m=yse(p*p-b-Mie*y),w=yse(p*(y-m)-h*b),v=yse(n*o*f);return new Xie(m,w,v)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Xie.ZERO;if("bigint"===typeof e&&e===Uie)return t;let r=bse(e);if(r===Lie)return this;if(!Yie){let e=t,n=this;for(;r>Uie;)r&Lie&&(e=e.add(n)),n=n.double(),r>>=Lie;return e}let{k1neg:n,k1:i,k2neg:s,k2:o}=Vie.splitScalar(r),a=t,c=t,u=this;for(;i>Uie||o>Uie;)i&Lie&&(a=a.add(u)),o&Lie&&(c=c.add(u)),u=u.double(),i>>=Lie,o>>=Lie;return n&&(a=a.negate()),s&&(c=c.negate()),c=new Xie(yse(c.x*Vie.beta),c.y,c.z),a.add(c)}precomputeWindow(e){const t=Yie?128/e+1:256/e+1,r=[];let n=this,i=n;for(let s=0;s<t;s++){i=n,r.push(i);for(let t=1;t<2**(e-1);t++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(e,t){!t&&this.equals(Xie.BASE)&&(t=tse.BASE);const r=t&&t._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=t&&ese.get(t);n||(n=this.precomputeWindow(r),t&&1!==r&&(n=Xie.normalizeZ(n),ese.set(t,n)));let i=Xie.ZERO,s=Xie.BASE;const o=1+(Yie?128/r:256/r),a=2**(r-1),c=BigInt(2**r-1),u=2**r,l=BigInt(r);for(let h=0;h<o;h++){const t=h*a;let r=Number(e&c);e>>=l,r>a&&(r-=u,e+=Lie);const o=t,d=t+Math.abs(r)-1,f=h%2!==0,p=r<0;0===r?s=s.add(Zie(f,n[o])):i=i.add(Zie(p,n[d]))}return{p:i,f:s}}multiply(e,t){let r,n,i=bse(e);if(Yie){const{k1neg:e,k1:s,k2neg:o,k2:a}=Vie.splitScalar(i);let{p:c,f:u}=this.wNAF(s,t),{p:l,f:h}=this.wNAF(a,t);c=Zie(e,c),l=Zie(o,l),l=new Xie(yse(l.x*Vie.beta),l.y,l.z),r=c.add(l),n=u.add(h)}else{const{p:e,f:s}=this.wNAF(i,t);r=e,n=s}return Xie.normalizeZ([r,n])[0]}toAffine(e){const{x:t,y:r,z:n}=this,i=this.equals(Xie.ZERO);null==e&&(e=i?qie:wse(n));const s=e,o=yse(s*s),a=yse(o*s),c=yse(t*o),u=yse(r*a),l=yse(n*s);if(i)return tse.ZERO;if(l!==Lie)throw new Error("invZ was invalid");return new tse(c,u)}}function Zie(e,t){const r=t.negate();return e?r:t}Xie.BASE=new Xie(Kie.Gx,Kie.Gy,Lie),Xie.ZERO=new Xie(Uie,Lie,Uie);const ese=new WeakMap;class tse{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,ese.delete(this)}hasEvenY(){return this.y%Mie===Uie}static fromCompressedHex(e){const t=32===e.length,r=pse(t?e:e.subarray(1));if(!kse(r))throw new Error("Point is not on curve");let n=function(e){const{P:t}=Kie,r=BigInt(6),n=BigInt(11),i=BigInt(22),s=BigInt(23),o=BigInt(44),a=BigInt(88),c=e*e*e%t,u=c*c*e%t,l=mse(u,Oie)*u%t,h=mse(l,Oie)*u%t,d=mse(h,Mie)*c%t,f=mse(d,n)*d%t,p=mse(f,i)*f%t,g=mse(p,o)*p%t,b=mse(g,a)*g%t,y=mse(b,o)*p%t,m=mse(y,Oie)*u%t,w=mse(m,s)*f%t,v=mse(w,r)*c%t,_=mse(v,Mie);if(_*_%t!==e)throw new Error("Cannot find square root");return _}(Wie(r));const i=(n&Lie)===Lie;if(t)i&&(n=yse(-n));else{1===(1&e[0])!==i&&(n=yse(-n))}const s=new tse(r,n);return s.assertValidity(),s}static fromUncompressedHex(e){const t=pse(e.subarray(1,zie+1)),r=pse(e.subarray(zie+1,2*zie+1)),n=new tse(t,r);return n.assertValidity(),n}static fromHex(e){const t=gse(e),r=t.length,n=t[0];if(r===zie)return this.fromCompressedHex(t);if(r===jie&&(2===n||3===n))return this.fromCompressedHex(t);if(r===Gie&&4===n)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-${jie} compressed bytes or ${Gie} uncompressed bytes, not ${r}`)}static fromPrivateKey(e){return tse.BASE.multiply(Ise(e))}static fromSignature(e,t,r){const{r:n,s:i}=Tse(t);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const s=vse(gse(e)),{n:o}=Kie,a=2===r||3===r?n+o:n,c=wse(a,o),u=yse(-s*c,o),l=yse(i*c,o),h=1&r?"03":"02",d=tse.fromHex(h+use(a)),f=tse.BASE.multiplyAndAddUnsafe(d,u,l);if(!f)throw new Error("Cannot recover signature: point at infinify");return f.assertValidity(),f}toRawBytes(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return fse(this.toHex(e))}toHex(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=use(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${use(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const e="Point is not on elliptic curve",{x:t,y:r}=this;if(!kse(t)||!kse(r))throw new Error(e);const n=yse(r*r);if(yse(n-Wie(t))!==Uie)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new tse(this.x,yse(-this.y))}double(){return Xie.fromAffine(this).double().toAffine()}add(e){return Xie.fromAffine(this).add(Xie.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Xie.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,r){const n=Xie.fromAffine(this),i=t===Uie||t===Lie||this!==tse.BASE?n.multiplyUnsafe(t):n.multiply(t),s=Xie.fromAffine(e).multiplyUnsafe(r),o=i.add(s);return o.equals(Xie.ZERO)?void 0:o.toAffine()}}function rse(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function nse(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${ase(e)}`);const t=e[1],r=e.subarray(2,t+2);if(!t||r.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:pse(r),left:e.subarray(t+2)}}tse.BASE=new tse(Kie.Gx,Kie.Gy),tse.ZERO=new tse(Uie,Uie);class ise{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,r="Signature.fromCompact";if("string"!==typeof e&&!t)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=t?ase(e):e;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new ise(dse(n.slice(0,64)),dse(n.slice(64,128)))}static fromDER(e){const t=e instanceof Uint8Array;if("string"!==typeof e&&!t)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r:r,s:n}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${ase(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:r}=nse(e.subarray(2)),{data:n,left:i}=nse(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${ase(i)}`);return{r:t,s:n}}(t?e:fse(e));return new ise(r,n)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Ase(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Ase(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=Kie.n>>Lie;return this.s>e}normalizeS(){return this.hasHighS()?new ise(this.r,yse(-this.s,Kie.n)):this}toDERRawBytes(){return fse(this.toDERHex())}toDERHex(){const e=rse(hse(this.s)),t=rse(hse(this.r)),r=e.length/2,n=t.length/2,i=hse(r),s=hse(n);return`30${hse(n+r+4)}02${s}${t}02${i}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return fse(this.toCompactHex())}toCompactHex(){return use(this.r)+use(this.s)}}function sse(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(!t.every((e=>e instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const n=t.reduce(((e,t)=>e+t.length),0),i=new Uint8Array(n);for(let s=0,o=0;s<t.length;s++){const e=t[s];i.set(e,o),o+=e.length}return i}const ose=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function ase(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let r=0;r<e.length;r++)t+=ose[e[r]];return t}const cse=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function use(e){if("bigint"!==typeof e)throw new Error("Expected bigint");if(!(Uie<=e&&e<cse))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function lse(e){const t=fse(use(e));if(32!==t.length)throw new Error("Error: expected 32 bytes");return t}function hse(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function dse(e){if("string"!==typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function fse(e){if("string"!==typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+e.length);const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r,i=e.slice(n,n+2),s=Number.parseInt(i,16);if(Number.isNaN(s)||s<0)throw new Error("Invalid byte sequence");t[r]=s}return t}function pse(e){return dse(ase(e))}function gse(e){return e instanceof Uint8Array?Uint8Array.from(e):fse(e)}function bse(e){if("number"===typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"===typeof e&&Ase(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function yse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Kie.P;const r=e%t;return r>=Uie?r:t+r}function mse(e,t){const{P:r}=Kie;let n=e;for(;t-- >Uie;)n*=n,n%=r;return n}function wse(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Kie.P;if(e===Uie||t<=Uie)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let r=yse(e,t),n=t,i=Uie,s=Lie,o=Lie,a=Uie;for(;r!==Uie;){const e=n/r,t=n%r,c=i-o*e,u=s-a*e;n=r,r=t,i=o,s=a,o=c,a=u}if(n!==Lie)throw new Error("invert: does not exist");return yse(i,t)}function vse(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=function(e){const t=8*e.length-8*$ie,r=pse(e);return t>0?r>>BigInt(t):r}(e);if(t)return r;const{n:n}=Kie;return r>=n?r-n:r}let _se,Ese;class Sse{constructor(e,t){if(this.hashLen=e,this.qByteLen=t,"number"!==typeof e||e<2)throw new Error("hashLen must be a number");if("number"!==typeof t||t<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(e).fill(1),this.k=new Uint8Array(e).fill(0),this.counter=0}hmac(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Ose.hmacSha256(this.k,...t)}hmacSync(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Ese(this.k,...t)}checkSync(){if("function"!==typeof Ese)throw new Qie("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;this.k=await this.hmac(this.v,Uint8Array.from([0]),e),this.v=await this.hmac(this.v),0!==e.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),e),this.v=await this.hmac(this.v))}reseedSync(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),e),this.v=this.hmacSync(this.v),0!==e.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),e),this.v=this.hmacSync(this.v))}async generate(){this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=await this.hmac(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return sse(...t)}generateSync(){this.checkSync(),this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const r=this.v.slice();t.push(r),e+=this.v.length}return sse(...t)}}function Ase(e){return Uie<e&&e<Kie.n}function kse(e){return Uie<e&&e<Kie.P}function xse(e,t,r){let n=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const{n:i}=Kie,s=vse(e,!0);if(!Ase(s))return;const o=wse(s,i),a=tse.BASE.multiply(s),c=yse(a.x,i);if(c===Uie)return;const u=yse(o*yse(t+r*c,i),i);if(u===Uie)return;let l=new ise(c,u),h=(a.x===l.r?0:2)|Number(a.y&Lie);return n&&l.hasHighS()&&(l=l.normalizeS(),h^=1),{sig:l,recovery:h}}function Ise(e){let t;if("bigint"===typeof e)t=e;else if("number"===typeof e&&Number.isSafeInteger(e)&&e>0)t=BigInt(e);else if("string"===typeof e){if(e.length!==2*$ie)throw new Error("Expected 32 bytes of private key");t=dse(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(e.length!==$ie)throw new Error("Expected 32 bytes of private key");t=pse(e)}if(!Ase(t))throw new Error("Expected private key: 0 < key < n");return t}function Cse(e){return e instanceof tse?(e.assertValidity(),e):tse.fromHex(e)}function Tse(e){if(e instanceof ise)return e.assertValidity(),e;try{return ise.fromDER(e)}catch(t){return ise.fromCompact(e)}}function Rse(e){return pse(e.length>zie?e.slice(0,zie):e)}function Pse(e){const t=Rse(e),r=yse(t,Kie.n);return Dse(r<Uie?t:r)}function Dse(e){return lse(e)}function Nse(e,t,r){if(null==e)throw new Error(`sign: expected valid message hash, not "${e}"`);const n=gse(e),i=Ise(t),s=[Dse(i),Pse(n)];if(null!=r){!0===r&&(r=Ose.randomBytes(zie));const e=gse(r);if(e.length!==zie)throw new Error(`sign: Expected ${zie} bytes of extra data`);s.push(e)}return{seed:sse(...s),m:Rse(n),d:i}}function Bse(e,t){const{sig:r,recovery:n}=e,{der:i,recovered:s}=Object.assign({canonical:!0,der:!0},t),o=i?r.toDERRawBytes():r.toCompactRawBytes();return s?[o,n]:o}const Use={strict:!0};tse.BASE._setWindowSize(8);const Lse={node:Bie,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0},Mse={},Ose={bytesToHex:ase,hexToBytes:fse,concatBytes:sse,mod:yse,invert:wse,isValidPrivateKey(e){try{return Ise(e),!0}catch(t){return!1}},_bigintTo32Bytes:lse,_normalizePrivateKey:Ise,hashToPrivateKey:e=>{e=gse(e);const t=$ie+8;if(e.length<t||e.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return lse(yse(pse(e),Kie.n-Lie)+Lie)},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(Lse.web)return Lse.web.getRandomValues(new Uint8Array(e));if(Lse.node){const{randomBytes:t}=Lse.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Ose.hashToPrivateKey(Ose.randomBytes($ie+8)),precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:tse.BASE;const r=t===tse.BASE?t:new tse(t.x,t.y);return r._setWindowSize(e),r.multiply(Oie),r},sha256:async function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];if(Lse.web){const e=await Lse.web.subtle.digest("SHA-256",sse(...t));return new Uint8Array(e)}if(Lse.node){const{createHash:e}=Lse.node,r=e("sha256");return t.forEach((e=>r.update(e))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];if(Lse.web){const t=await Lse.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=sse(...r),i=await Lse.web.subtle.sign("HMAC",t,n);return new Uint8Array(i)}if(Lse.node){const{createHmac:t}=Lse.node,n=t("sha256",e);return r.forEach((e=>n.update(e))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async function(e){let t=Mse[e];if(void 0===t){const r=await Ose.sha256(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=sse(r,r),Mse[e]=t}for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return Ose.sha256(t,...n)},taggedHashSync:function(e){if("function"!==typeof _se)throw new Qie("sha256Sync is undefined, you need to set it");let t=Mse[e];if(void 0===t){const r=_se(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=sse(r,r),Mse[e]=t}for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return _se(t,...n)},_JacobianPoint:Xie};Object.defineProperties(Ose,{sha256Sync:{configurable:!1,get:()=>_se,set(e){_se||(_se=e)}},hmacSha256Sync:{configurable:!1,get:()=>Ese,set(e){Ese||(Ese=e)}}});var qse=__webpack_require__(2161);function Kse(e){return new Uint8Array(qse.keccak256.arrayBuffer(e))}function Fse(e,t,r){try{return function(e,t,r){let n,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Use;try{n=Tse(e),t=gse(t)}catch(p){return!1}const{r:s,s:o}=n;if(i.strict&&n.hasHighS())return!1;const a=vse(t);let c;try{c=Cse(r)}catch(p){return!1}const{n:u}=Kie,l=wse(o,u),h=yse(a*l,u),d=yse(s*l,u),f=tse.BASE.multiplyAndAddUnsafe(c,h,d);return!!f&&yse(f.x,u)===s}(ise.fromCompact(e.slice(0,64)),t,r)}catch{return!1}}const Vse="Invalid record id";function zse(e,t){switch(t){case"udp":return zse(e,"udp4")||zse(e,"udp6");case"tcp":return zse(e,"tcp4")||zse(e,"tcp6")}const r=t.endsWith("6"),n=e.get(r?"ip6":"ip");if(!n)return;const i=t.slice(0,3);let s;switch(i){case"udp":s=r?e.get("udp6"):e.get("udp");break;case"tcp":s=r?e.get("tcp6"):e.get("tcp");break;default:return}return s?function(e,t,r,n){let i=tI("/"+e+"/"+Nx(e,r));return i=i.encapsulate(tI("/"+t+"/"+Nx(t,n))),i}(r?"ip6":"ip4",i,n,s):void 0}new Uint8Array(0);function $se(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Hse=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const jse=Hse;class Gse{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Wse{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return Qse(this,e)}}class Yse{decoders;constructor(e){this.decoders=e}or(e){return Qse(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function Qse(e,t){return new Yse({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class Jse{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new Gse(e,t,r),this.decoder=new Wse(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function Xse(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new Jse(t,r,n,i)}function Zse(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=jse(n,t);return Xse({prefix:r,name:t,encode:i,decode:e=>$se(s(e))})}function eoe(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return Xse({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const toe=Zse({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),roe=Zse({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var noe=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=ooe;)r[n++]=255&t|ioe,t/=128;for(;t&soe;)r[n++]=255&t|ioe,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},ioe=128,soe=-128,ooe=Math.pow(2,31);var aoe=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&uoe)<<s:(n&uoe)*Math.pow(2,s),s+=7}while(n>=coe);return e.bytes=o-r,i},coe=128,uoe=127;var loe=Math.pow(2,7),hoe=Math.pow(2,14),doe=Math.pow(2,21),foe=Math.pow(2,28),poe=Math.pow(2,35),goe=Math.pow(2,42),boe=Math.pow(2,49),yoe=Math.pow(2,56),moe=Math.pow(2,63);const woe={encode:noe,decode:aoe,encodingLength:function(e){return e<loe?1:e<hoe?2:e<doe?3:e<foe?4:e<poe?5:e<goe?6:e<boe?7:e<yoe?8:e<moe?9:10}};function voe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[woe.decode(e,t),woe.decode.bytes]}function _oe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return woe.encode(e,t,r),t}function Eoe(e){return woe.encodingLength(e)}function Soe(e,t){const r=t.byteLength,n=Eoe(e),i=n+Eoe(r),s=new Uint8Array(i+r);return _oe(e,s,0),_oe(r,s,n),s.set(t,i),new koe(e,r,t,s)}function Aoe(e){const t=$se(e),[r,n]=voe(t),[i,s]=voe(t.subarray(n)),o=t.subarray(n+s);if(o.byteLength!==i)throw new Error("Incorrect length");return new koe(r,i,o,t)}class koe{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const xoe=$se;const Ioe={code:0,name:"identity",encode:xoe,digest:function(e){return Soe(0,xoe(e))}};function Coe(e){let{name:t,code:r,encode:n}=e;return new Toe(t,r,n)}class Toe{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Soe(this.code,t):t.then((e=>Soe(this.code,e)))}throw Error("Unknown type, must be binary type")}}function Roe(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const Poe=Coe({name:"sha2-256",code:18,encode:Roe("SHA-256")}),Doe=Coe({name:"sha2-512",code:19,encode:Roe("SHA-512")});function Noe(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}const Boe=Zse({prefix:"9",name:"base10",alphabet:"0123456789"}),Uoe=eoe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Loe=eoe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Moe=eoe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Ooe=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),qoe=Ooe.reduce(((e,t,r)=>(e[r]=t,e)),[]),Koe=Ooe.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Foe=Xse({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=qoe[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Koe[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),Voe=eoe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),zoe=eoe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),$oe=eoe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Hoe=eoe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),joe=eoe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Goe=eoe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Woe=eoe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Yoe=eoe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Qoe=eoe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Joe=Zse({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xoe=Zse({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Zoe=eoe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),eae=eoe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),tae=eoe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),rae=eoe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),nae=eoe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),iae=Xse({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),sae=new TextEncoder,oae=new TextDecoder,aae="json",cae=512;function uae(e){return sae.encode(JSON.stringify(e))}function lae(e){return JSON.parse(oae.decode(e))}const hae="raw",dae=85;function fae(e){return $se(e)}function pae(e){return $se(e)}function gae(e,t){const{bytes:r,version:n}=e;return 0===n?function(e,t,r){const{prefix:n}=r;if(n!==toe.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);const i=t.get(n);if(null==i){const i=r.encode(e).slice(1);return t.set(n,i),i}return i}(r,yae(e),t??toe.encoder):function(e,t,r){const{prefix:n}=r,i=t.get(n);if(null==i){const i=r.encode(e);return t.set(n,i),i}return i}(r,yae(e),t??Voe.encoder)}const bae=new WeakMap;function yae(e){const t=bae.get(e);if(null==t){const t=new Map;return bae.set(e,t),t}return t}class mae{code;version;multihash;bytes;"/";constructor(e,t,r,n){this.code=t,this.version=e,this.multihash=r,this.bytes=n,this["/"]=n}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:{const{code:e,multihash:t}=this;if(e!==wae)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==vae)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return mae.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:{const{code:e,digest:t}=this.multihash,r=Soe(e,t);return mae.createV1(this.code,r)}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 mae.equals(this,e)}static equals(e,t){const r=t;return null!=r&&e.code===r.code&&e.version===r.version&&function(e,t){if(e===t)return!0;{const r=t;return e.code===r.code&&e.size===r.size&&r.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}(e.bytes,r.bytes)}}(e.multihash,r.multihash)}toString(e){return gae(this,e)}toJSON(){return{"/":gae(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(null==e)return null;const t=e;if(t instanceof mae)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:r,multihash:n,bytes:i}=t;return new mae(e,r,n,i??_ae(e,r,n.bytes))}if(!0===t[Eae]){const{version:e,multihash:r,code:n}=t,i=Aoe(r);return mae.create(e,n,i)}return null}static create(e,t,r){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(r.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==wae)throw new Error(`Version 0 CID must use dag-pb (code: ${wae}) block encoding`);return new mae(e,t,r,r.bytes);case 1:{const n=_ae(e,t,r.bytes);return new mae(e,t,r,n)}default:throw new Error("Invalid version")}}static createV0(e){return mae.create(0,wae,e)}static createV1(e,t){return mae.create(1,e,t)}static decode(e){const[t,r]=mae.decodeFirst(e);if(0!==r.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=mae.inspectBytes(e),r=t.size-t.multihashSize,n=$se(e.subarray(r,r+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");const i=n.subarray(t.multihashSize-t.digestSize),s=new koe(t.multihashCode,t.digestSize,i,n);return[0===t.version?mae.createV0(s):mae.createV1(t.codec,s),e.subarray(t.size)]}static inspectBytes(e){let t=0;const r=()=>{const[r,n]=voe(e.subarray(t));return t+=n,r};let n=r(),i=wae;if(18===n?(n=0,t=0):i=r(),0!==n&&1!==n)throw new RangeError(`Invalid CID version ${n}`);const s=t,o=r(),a=r(),c=t+a;return{version:n,codec:i,multihashCode:o,digestSize:a,multihashSize:c-s,size:c}}static parse(e,t){const[r,n]=function(e,t){switch(e[0]){case"Q":{const r=t??toe;return[toe.prefix,r.decode(`${toe.prefix}${e}`)]}case toe.prefix:{const r=t??toe;return[toe.prefix,r.decode(e)]}case Voe.prefix:{const r=t??Voe;return[Voe.prefix,r.decode(e)]}default:if(null==t)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),i=mae.decode(n);if(0===i.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return yae(i).set(r,e),i}}const wae=112,vae=18;function _ae(e,t,r){const n=Eoe(e),i=n+Eoe(t),s=new Uint8Array(i+r.byteLength);return _oe(e,s,0),_oe(t,s,n),s.set(r,i),s}const Eae=Symbol.for("@ipld/js-cid/CID"),Sae={...Oi,...Di,...Mi,...Ri,...Pi,...Bi,...Ui,...Ii,...Li,...Ni};function Aae(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function kae(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const xae=kae("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Iae=kae("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=Aae((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Cae={utf8:xae,"utf-8":xae,hex:Sae.base16,latin1:Iae,ascii:Iae,binary:Iae,...Sae};function Tae(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Cae[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}function Rae(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const Pae=32,Dae=64,Nae=32;function Bae(e,t){const r=new Uint8Array(Dae);for(let n=0;n<Nae;n++)r[n]=e[n],r[Nae+n]=t[n];return r}const Uae={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(null==e||null==e.subtle)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}},Lae={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};function Mae(e){const t=e?.algorithm??"AES-GCM";let r=e?.keyLength??16;const n=e?.nonceLength??12,i=e?.digest??"SHA-256",s=e?.saltLength??16,o=e?.iterations??32767,a=Uae.get();r*=8;const c={encrypt:async function(e,c){const u=a.getRandomValues(new Uint8Array(s)),l=a.getRandomValues(new Uint8Array(n)),h={name:t,iv:l};let d;if("string"===typeof c&&(c=Tae(c)),0===c.length){d=await a.subtle.importKey("jwk",Lae,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}catch{d=await a.subtle.importKey("jwk",Lae,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);d=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["encrypt"])}const f=await a.subtle.encrypt(h,d,e);return function(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const r=Aae(t);let n=0;for(const i of e)r.set(i,n),n+=i.length;return r}([u,h.iv,new Uint8Array(f)])},decrypt:async function(e,c){const u=e.subarray(0,s),l=e.subarray(s,s+n),h=e.subarray(s+n),d={name:t,iv:l};let f;if("string"===typeof c&&(c=Tae(c)),0===c.length)try{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}catch{f=await a.subtle.importKey("jwk",Lae,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:u,iterations:o,hash:{name:i}},n=await a.subtle.importKey("raw",c,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,n,{name:t,length:r},!0,["decrypt"])}const p=await a.subtle.decrypt(d,f,h);return new Uint8Array(p)}};return c}async function Oae(e,t){const r=Mae(),n=await r.encrypt(e,t);return Zoe.encode(n)}const qae=new Float32Array([-0]),Kae=new Uint8Array(qae.buffer);function Fae(e,t,r){qae[0]=e,t[r]=Kae[0],t[r+1]=Kae[1],t[r+2]=Kae[2],t[r+3]=Kae[3]}const Vae=new Float64Array([-0]),zae=new Uint8Array(Vae.buffer);function $ae(e,t,r){Vae[0]=e,t[r]=zae[0],t[r+1]=zae[1],t[r+2]=zae[2],t[r+3]=zae[3],t[r+4]=zae[4],t[r+5]=zae[5],t[r+6]=zae[6],t[r+7]=zae[7]}const Hae=BigInt(Number.MAX_SAFE_INTEGER),jae=BigInt(Number.MIN_SAFE_INTEGER);class Gae{lo;hi;constructor(e,t){this.lo=0|e,this.hi=0|t}toNumber(){if(!(arguments.length>0&&void 0!==arguments[0]&&arguments[0])&&this.hi>>>31>0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(e+4294967296*t)}return this.lo+4294967296*this.hi}toBigInt(){if(arguments.length>0&&void 0!==arguments[0]&&arguments[0])return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n);if(this.hi>>>31!==0){const e=1+~this.lo>>>0;let t=~this.hi>>>0;return 0===e&&(t=t+1>>>0),-(BigInt(e)+(BigInt(t)<<32n))}return BigInt(this.lo>>>0)+(BigInt(this.hi>>>0)<<32n)}toString(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.toBigInt(e).toString()}zzEncode(){const e=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^e)>>>0,this.lo=(this.lo<<1^e)>>>0,this}zzDecode(){const e=-(1&this.lo);return this.lo=((this.lo>>>1|this.hi<<31)^e)>>>0,this.hi=(this.hi>>>1^e)>>>0,this}length(){const e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,r=this.hi>>>24;return 0===r?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:r<128?9:10}static fromBigInt(e){if(0n===e)return Wae;if(e<Hae&&e>jae)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let r=e>>32n,n=e-(r<<32n);return t&&(r=0n|~r,n=0n|~n,++n>Yae&&(n=0n,++r>Yae&&(r=0n))),new Gae(Number(n),Number(r))}static fromNumber(e){if(0===e)return Wae;const t=e<0;t&&(e=-e);let r=e>>>0,n=(e-r)/4294967296>>>0;return t&&(n=~n>>>0,r=~r>>>0,++r>4294967295&&(r=0,++n>4294967295&&(n=0))),new Gae(r,n)}static from(e){return"number"===typeof e?Gae.fromNumber(e):"bigint"===typeof e?Gae.fromBigInt(e):"string"===typeof e?Gae.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new Gae(e.low>>>0,e.high>>>0):Wae}}const Wae=new Gae(0,0);Wae.toBigInt=function(){return 0n},Wae.zzEncode=Wae.zzDecode=function(){return this},Wae.length=function(){return 1};const Yae=4294967296n;function Qae(e,t,r){const n=r;let i,s;for(let o=0;o<e.length;++o)i=e.charCodeAt(o),i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):55296===(64512&i)&&56320===(64512&(s=e.charCodeAt(o+1)))?(i=65536+((1023&i)<<10)+(1023&s),++o,t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128);return r-n}function Jae(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Xae(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Zae{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=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return e;if(e=(e|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return e;if((this.pos+=5)>this.len)throw this.pos=this.len,Jae(this,10);return e}int32(){return 0|this.uint32()}sint32(){const e=this.uint32();return e>>>1^-(1&e)}bool(){return 0!==this.uint32()}fixed32(){if(this.pos+4>this.len)throw Jae(this,4);return Xae(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw Jae(this,4);return 0|Xae(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw Jae(this,4);const e=(t=this.buf,r=this.pos,Kae[0]=t[r],Kae[1]=t[r+1],Kae[2]=t[r+2],Kae[3]=t[r+3],qae[0]);var t,r;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw Jae(this,4);const e=(t=this.buf,r=this.pos,zae[0]=t[r],zae[1]=t[r+1],zae[2]=t[r+2],zae[3]=t[r+3],zae[4]=t[r+4],zae[5]=t[r+5],zae[6]=t[r+6],zae[7]=t[r+7],Vae[0]);var t,r;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,r=this.pos+e;if(r>this.len)throw Jae(this,e);return this.pos+=e,t===r?new Uint8Array(0):this.buf.subarray(t,r)}string(){const e=this.bytes();return function(e,t,r){if(r-t<1)return"";let n;const i=[];let s,o=0;for(;t<r;)s=e[t++],s<128?i[o++]=s:s>191&&s<224?i[o++]=(31&s)<<6|63&e[t++]:s>239&&s<365?(s=((7&s)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[o++]=55296+(s>>10),i[o++]=56320+(1023&s)):i[o++]=(15&s)<<12|(63&e[t++])<<6|63&e[t++],o>8191&&((n??(n=[])).push(String.fromCharCode.apply(String,i)),o=0);return null!=n?(o>0&&n.push(String.fromCharCode.apply(String,i.slice(0,o))),n.join("")):String.fromCharCode.apply(String,i.slice(0,o))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw Jae(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw Jae(this)}while(0!==(128&this.buf[this.pos++]));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(;4!==(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error(`invalid wire type ${e} at offset ${this.pos}`)}return this}readLongVarint(){const e=new Gae(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw Jae(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw Jae(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}readFixed64(){if(this.pos+8>this.len)throw Jae(this,8);const e=Xae(this.buf,this.pos+=4),t=Xae(this.buf,this.pos+=4);return new Gae(e,t)}int64(){return this.readLongVarint().toBigInt()}int64Number(){return this.readLongVarint().toNumber()}int64String(){return this.readLongVarint().toString()}uint64(){return this.readLongVarint().toBigInt(!0)}uint64Number(){const e=ys(this.buf,this.pos);return this.pos+=gs(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 ece(e,t,r){const n=function(e){return new Zae(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(n,void 0,r)}class tce{fn;len;next;val;constructor(e,t,r){this.fn=e,this.len=t,this.next=void 0,this.val=r}}function rce(){}class nce{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const ice=function(e){const t=e??8192,r=t>>>1;let n,i=t;return function(e){if(e<1||e>r)return Aae(e);i+e>t&&(n=Aae(t),i=0);const s=n.subarray(i,i+=e);return 0!==(7&i)&&(i=1+(7|i)),s}}();class sce{len;head;tail;states;constructor(){this.len=0,this.head=new tce(rce,0,0),this.tail=this.head,this.states=null}_push(e,t,r){return this.tail=this.tail.next=new tce(e,t,r),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new cce((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(uce,10,Gae.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=Gae.fromBigInt(e);return this._push(uce,t.length(),t)}uint64Number(e){return this._push(bs,gs(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){const t=Gae.fromBigInt(e).zzEncode();return this._push(uce,t.length(),t)}sint64Number(e){const t=Gae.fromNumber(e).zzEncode();return this._push(uce,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(oce,1,e?1:0)}fixed32(e){return this._push(lce,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=Gae.fromBigInt(e);return this._push(lce,4,t.lo)._push(lce,4,t.hi)}fixed64Number(e){const t=Gae.fromNumber(e);return this._push(lce,4,t.lo)._push(lce,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(Fae,4,e)}double(e){return this._push($ae,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(oce,1,0):this.uint32(t)._push(hce,t,e)}string(e){const t=function(e){let t=0,r=0;for(let n=0;n<e.length;++n)r=e.charCodeAt(n),r<128?t+=1:r<2048?t+=2:55296===(64512&r)&&56320===(64512&e.charCodeAt(n+1))?(++n,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(Qae,t,e):this._push(oce,1,0)}fork(){return this.states=new nce(this),this.head=this.tail=new tce(rce,0,0),this.len=0,this}reset(){return null!=this.states?(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 tce(rce,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,r=this.len;return this.reset().uint32(r),0!==r&&(this.tail.next=e.next,this.tail=t,this.len+=r),this}finish(){let e=this.head.next;const t=(r=this.len,null!=globalThis.Buffer?Aae(r):ice(r));var r;let n=0;for(;null!=e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t}}function oce(e,t,r){t[r]=255&e}function ace(e,t,r){for(;e>127;)t[r++]=127&e|128,e>>>=7;t[r]=e}class cce extends tce{next;constructor(e,t){super(ace,e,t),this.next=void 0}}function uce(e,t,r){for(;0!==e.hi;)t[r++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[r++]=127&e.lo|128,e.lo=e.lo>>>7;t[r++]=e.lo}function lce(e,t,r){t[r]=255&e,t[r+1]=e>>>8&255,t[r+2]=e>>>16&255,t[r+3]=e>>>24}function hce(e,t,r){t.set(e,r)}function dce(e,t,r){t.set(e,r)}function fce(e,t,r){e.length<40?Qae(e,t,r):null!=t.utf8Write?t.utf8Write(e,r):t.set(Tae(e),r)}function pce(e,t){const r=new sce;return t.encode(e,r,{lengthDelimited:!1}),r.finish()}var gce,bce,yce,mce,wce;function vce(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}function _ce(e,t){return vce("message",gce.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&(sce.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(dce,t,e),this},sce.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(fce,t,e),this}),function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(gce||(gce={}));Error;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(bce||(bce={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(yce||(yce={})),function(e){e.codec=()=>function(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return vce("enum",gce.VARINT,(function(e,r){const n=t(e);r.int32(n)}),(function(e){return t(e.int32())}))}(yce)}(bce||(bce={})),function(e){let t;e.codec=()=>(null==t&&(t=_ce((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),bce.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=bce.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>pce(t,e.codec()),e.decode=t=>ece(t,e.codec())}(mce||(mce={})),function(e){let t;e.codec=()=>(null==t&&(t=_ce((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==r.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),bce.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.Type=bce.codec().decode(e);break;case 2:r.Data=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>pce(t,e.codec()),e.decode=t=>ece(t,e.codec())}(wce||(wce={}));class Ece{_key;constructor(e){this._key=Cce(e,Pae)}verify(e,t){return function(e,t,r){return Lp.verify(t,r instanceof Uint8Array?r:r.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return mce.encode({Type:bce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Noe(this.bytes,e.bytes)}hash(){const e=Poe.digest(this.bytes);return Rae(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class Sce{_key;_publicKey;constructor(e,t){this._key=Cce(e,Dae),this._publicKey=Cce(t,Pae)}sign(e){return function(e,t){const r=e.subarray(0,Nae);return Lp.sign(t instanceof Uint8Array?t:t.subarray(),r)}(this._key,e)}get public(){return new Ece(this._publicKey)}marshal(){return this._key}get bytes(){return wce.encode({Type:bce.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Noe(this.bytes,e.bytes)}async hash(){const e=Poe.digest(this.bytes);let t;return Rae(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=Ioe.digest(this.public.bytes);return toe.encode(e.bytes).substring(1)}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return Oae(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function Ace(e){if(e.length>Dae){const t=(e=Cce(e,Dae+Pae)).subarray(0,Dae),r=e.subarray(Dae,e.length);return new Sce(t,r)}const t=(e=Cce(e,Dae)).subarray(0,Dae),r=e.subarray(Pae);return new Sce(t,r)}function kce(e){return e=Cce(e,Pae),new Ece(e)}async function xce(){const{privateKey:e,publicKey:t}=function(){const e=Lp.utils.randomPrivateKey(),t=Lp.getPublicKey(e);return{privateKey:Bae(e,t),publicKey:t}}();return new Sce(e,t)}async function Ice(e){const{privateKey:t,publicKey:r}=function(e){if(e.length!==Nae)throw new TypeError('"seed" must be 32 bytes in length.');if(!(e instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, or Uint8Array.');const t=e,r=Lp.getPublicKey(t);return{privateKey:Bae(t,r),publicKey:r}}(e);return new Sce(t,r)}function Cce(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new Xp(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}function Tce(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Cae[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.encoder.encode(e).substring(1)}async function Rce(e){const t=[await Uae.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await Dce(e)],r=await Pce({privateKey:t[0],publicKey:t[1]});return{privateKey:r[0],publicKey:r[1]}}async function Pce(e){if(null==e.privateKey||null==e.publicKey)throw new Xp("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([Uae.get().subtle.exportKey("jwk",e.privateKey),Uae.get().subtle.exportKey("jwk",e.publicKey)])}async function Dce(e){return Uae.get().subtle.importKey("jwk",{kty:e.kty,n:e.n,e:e.e},{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["verify"])}function Nce(e){if("RSA"!==e.kty)throw new Xp("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new Xp("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*Tae(e.n,"base64url").length}function Bce(e){if(isNaN(e)||e<=0)throw new Xp("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Cc(e)}function Uce(e){let t=e.toString(16);t.length%2>0&&(t=`0${t}`);const r=t.length/2,n=new Uint8Array(r);let i=0,s=0;for(;i<r;)n[i]=parseInt(t.slice(s,s+2),16),i+=1,s+=2;return n}function Lce(e){const t=[];return e.forEach((function(e){let r=e.toString(16);r.length%2>0&&(r=`0${r}`),t.push(r)})),BigInt("0x"+t.join(""))}const Mce=32,Oce=1e4;const qce=8192;class Kce{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,r){const n=await Uae.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return Uae.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},n,t,r instanceof Uint8Array?r:r.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new fU({valueHex:new xU({value:[mU.fromBigInt(Lce(Tae(e.n,"base64url"))),mU.fromBigInt(Lce(Tae(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return mce.encode({Type:bce.RSA,Data:this.marshal()}).subarray()}equals(e){return Noe(this.bytes,e.bytes)}hash(){const e=Poe.digest(this.bytes);return Rae(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class Fce{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Bce(16)}sign(e){return async function(e,t){const r=await Uae.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),n=await Uae.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},r,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(n,0,n.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new Xp("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Kce(this._publicKey)}marshal(){return function(e){if(null==e.n||null==e.e||null==e.d||null==e.p||null==e.q||null==e.dp||null==e.dq||null==e.qi)throw new Xp("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new xU({value:[new mU({value:0}),mU.fromBigInt(Lce(Tae(e.n,"base64url"))),mU.fromBigInt(Lce(Tae(e.e,"base64url"))),mU.fromBigInt(Lce(Tae(e.d,"base64url"))),mU.fromBigInt(Lce(Tae(e.p,"base64url"))),mU.fromBigInt(Lce(Tae(e.q,"base64url"))),mU.fromBigInt(Lce(Tae(e.dp,"base64url"))),mU.fromBigInt(Lce(Tae(e.dq,"base64url"))),mU.fromBigInt(Lce(Tae(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return wce.encode({Type:bce.RSA,Data:this.marshal()}).subarray()}equals(e){return Noe(this.bytes,e.bytes)}hash(){const e=Poe.digest(this.bytes);return Rae(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Tce(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pkcs-8";if("pkcs-8"===t)return async function(e,t){const r=Uae.get(),n=new xU({value:[new mU({value:0}),new xU({value:[new EU({value:"1.2.840.113549.1.1.1"}),new aU]}),new hU({valueHex:e.marshal()})]}).toBER(),i=new Uint8Array(n,0,n.byteLength),s=Bce(16),o=await jN(Ef,t,s,{c:Oce,dkLen:Mce}),a=Bce(16),c=await r.subtle.importKey("raw",o,"AES-CBC",!1,["encrypt"]),u=await r.subtle.encrypt({name:"AES-CBC",iv:a},c,i),l=new xU({value:[new hU({valueHex:s}),new mU({value:Oce}),new mU({value:Mce}),new xU({value:[new EU({value:"1.2.840.113549.2.11"}),new aU]})]}),h=new xU({value:[new EU({value:"1.2.840.113549.1.5.13"}),new xU({value:[new xU({value:[new EU({value:"1.2.840.113549.1.5.12"}),l]}),new xU({value:[new EU({value:"2.16.840.1.101.3.4.1.42"}),new hU({valueHex:a})]})]})]}),d=new xU({value:[h,new hU({valueHex:u})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...Tce(new Uint8Array(d,0,d.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}(this,e);if("libp2p-key"===t)return Oae(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function Vce(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value;return{n:Tce(Uce(r[1].toBigInt()),"base64url"),e:Tce(Uce(r[2].toBigInt()),"base64url"),d:Tce(Uce(r[3].toBigInt()),"base64url"),p:Tce(Uce(r[4].toBigInt()),"base64url"),q:Tce(Uce(r[5].toBigInt()),"base64url"),dp:Tce(Uce(r[6].toBigInt()),"base64url"),dq:Tce(Uce(r[7].toBigInt()),"base64url"),qi:Tce(Uce(r[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(Nce(t)>qce)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const r=await Rce(t);return new Fce(r.privateKey,r.publicKey)}function zce(e){const t=function(e){const{result:t}=rU(e),r=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:Tce(Uce(r[0].toBigInt()),"base64url"),e:Tce(Uce(r[1].toBigInt()),"base64url")}}(e);if(Nce(t)>qce)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Kce(t)}async function $ce(e){if(Nce(e)>qce)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await Rce(e);return new Fce(t.privateKey,t.publicKey)}async function Hce(e){if(e>qce)throw new Xp("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await Uae.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),r=await Pce(t);return{privateKey:r[0],publicKey:r[1]}}(e);return new Fce(t.privateKey,t.publicKey)}function jce(e){try{lm.ProjectivePoint.fromHex(e)}catch(t){throw new Xp(String(t),"ERR_INVALID_PUBLIC_KEY")}}class Gce{_key;constructor(e){jce(e),this._key=e}verify(e,t){return function(e,t,r){const n=Poe.digest(r instanceof Uint8Array?r:r.subarray());if(Rae(n))return n.then((r=>{let{digest:n}=r;return lm.verify(t,n,e)})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.verify(t,n.digest,e)}catch(i){throw new Xp(String(i),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,lm.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return mce.encode({Type:bce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Noe(this.bytes,e.bytes)}async hash(){const e=Poe.digest(this.bytes);let t;return Rae(e)?({bytes:t}=await e):t=e.bytes,t}}class Wce{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{lm.getPublicKey(e,!0)}catch(t){throw new Xp(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),jce(this._publicKey)}sign(e){return function(e,t){const r=Poe.digest(t instanceof Uint8Array?t:t.subarray());if(Rae(r))return r.then((t=>{let{digest:r}=t;return lm.sign(r,e).toDERRawBytes()})).catch((e=>{throw new Xp(String(e),"ERR_INVALID_INPUT")}));try{return lm.sign(r.digest,e).toDERRawBytes()}catch(n){throw new Xp(String(n),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new Gce(this._publicKey)}marshal(){return this._key}get bytes(){return wce.encode({Type:bce.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Noe(this.bytes,e.bytes)}hash(){const e=Poe.digest(this.bytes);return Rae(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return Tce(await this.public.hash(),"base58btc")}async export(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"libp2p-key";if("libp2p-key"===t)return Oae(this.bytes,e);throw new Xp(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function Yce(e){return new Wce(e)}function Qce(e){return new Gce(e)}async function Jce(){const e=lm.utils.randomPrivateKey();return new Wce(e)}const Xce={rsa:Vi,ed25519:Fi,secp256k1:zi};const Zce=Symbol.for("nodejs.util.inspect.custom"),eue=Object.values(Sae).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),Sae.identity.decoder),tue=114,rue=36,nue=37;class iue{type;multihash;privateKey;publicKey;string;constructor(e){this.type=e.type,this.multihash=e.multihash,this.privateKey=e.privateKey,Object.defineProperty(this,"string",{enumerable:!1,writable:!0})}get[Symbol.toStringTag](){return`PeerId(${this.toString()})`}[vm]=!0;toString(){return null==this.string&&(this.string=toe.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return mae.createV1(tue,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return Noe(this.multihash.bytes,e);if("string"===typeof e)return function(e,t){if(t=t??eue,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=Aoe(toe.decode(`z${e}`));return e.startsWith("12D")?new oue({multihash:t}):e.startsWith("16U")?new aue({multihash:t}):new sue({multihash:t})}return function(e){try{const t=Aoe(e);if(t.code===Ioe.code){if(t.digest.length===rue)return new oue({multihash:t});if(t.digest.length===nue)return new aue({multihash:t})}if(t.code===Poe.code)return new sue({multihash:t})}catch{return function(e){if(null==e||null==e.multihash||null==e.version||1===e.version&&e.code!==tue)throw new Error("Supplied PeerID CID is invalid");const t=e.multihash;if(t.code===Poe.code)return new sue({multihash:e.multihash});if(t.code===Ioe.code){if(t.digest.length===rue)return new oue({multihash:e.multihash});if(t.digest.length===nue)return new aue({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(mae.decode(e))}throw new Error("Supplied PeerID CID is invalid")}(eue.decode(e))}(e).equals(this);if(null!=e?.multihash?.bytes)return Noe(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[Zce](){return`PeerId(${this.toString()})`}}class sue extends iue{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class oue extends iue{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class aue extends iue{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}function cue(e){return async function(e,t){return e.length===rue?new oue({multihash:Soe(Ioe.code,e),privateKey:t}):e.length===nue?new aue({multihash:Soe(Ioe.code,e),privateKey:t}):new sue({multihash:await Poe.digest(e),publicKey:e,privateKey:t})}(new Xce.secp256k1.Secp256k1PublicKey(e).bytes,void 0)}function uue(e){const t=e.reduce(((e,t)=>e+2+t.bytes.length),0),r=new Uint8Array(t),n=new DataView(r.buffer);let i=0;return e.forEach((e=>{if(e.getPeerId())throw new Error("`multiaddr` field MUST not contain peer id");n.setUint16(i,e.bytes.length),i+=2,r.set(e.bytes,i),i+=e.bytes.length})),r}function lue(e){let t=0;return e.lightPush&&(t+=1),t<<=1,e.filter&&(t+=1),t<<=1,e.store&&(t+=1),t<<=1,e.relay&&(t+=1),t}class hue extends Map{seq;signature;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BigInt(1),r=arguments.length>2?arguments[2]:void 0;super(Object.entries(e)),this.seq=t,this.signature=r}set(e,t){return this.signature=void 0,this.seq++,super.set(e,t)}get id(){const e=this.get("id");if(!e)throw new Error("id not found.");return _l(e)}get publicKey(){if("v4"===this.id)return this.get("secp256k1");throw new Error(Vse)}get rs(){const e=this.get("rs");if(e)return Dl(e)}get rsv(){const e=this.get("rsv");if(e)return Dl(e)}get ip(){return due(this,"ip","ip4")}set ip(e){pue(this,"ip","ip4",e)}get tcp(){return fue(this,"tcp","tcp")}set tcp(e){gue(this,"tcp","tcp",e)}get udp(){return fue(this,"udp","udp")}set udp(e){gue(this,"udp","udp",e)}get ip6(){return due(this,"ip6","ip6")}set ip6(e){pue(this,"ip6","ip6",e)}get tcp6(){return fue(this,"tcp6","tcp")}set tcp6(e){gue(this,"tcp6","tcp",e)}get udp6(){return fue(this,"udp6","udp")}set udp6(e){gue(this,"udp6","udp",e)}get multiaddrs(){const e=this.get("multiaddrs");if(e)return function(e){const t=[];let r=0;for(;r<e.length;){const n=new DataView(e.buffer,r,2).getUint16(0);r+=2;const i=e.slice(r,r+n);r+=n,t.push(tI(i))}return t}(e)}set multiaddrs(e){bue(this,"multiaddrs",e,uue)}get waku2(){const e=this.get("waku2");if(e)return function(e){const t={relay:!1,store:!1,filter:!1,lightPush:!1};return e%2&&(t.relay=!0),(e>>=1)%2&&(t.store=!0),(e>>=1)%2&&(t.filter=!0),(e>>=1)%2&&(t.lightPush=!0),t}(e[0])}set waku2(e){bue(this,"waku2",e,(e=>new Uint8Array([lue(e)])))}}function due(e,t,r){const n=e.get(t);if(n)return Nx(r,n)}function fue(e,t,r){const n=e.get(t);if(n)return Number(Nx(r,n))}function pue(e,t,r,n){bue(e,t,n,Bx.bind({},r))}function gue(e,t,r,n){pue(e,t,r,n?.toString(10))}function bue(e,t,r,n){void 0!==r?e.set(t,n(r)):e.delete(t)}async function yue(e,t){return async function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{seed:n,m:i,d:s}=Nse(e,t,r.extraEntropy),o=new Sse(Hie,$ie);let a;for(await o.reseed(n);!(a=xse(await o.generate(),i,s,r.canonical));)await o.reseed();return Bse(a,r)}(Kse(t),e,{der:!1})}const mue=new Ll("enr");var wue,vue;!function(e){e.TCP="tcp",e.UDP="udp"}(wue||(wue={})),function(e){e.TCP4="tcp4",e.UDP4="udp4",e.TCP6="tcp6",e.UDP6="udp6"}(vue||(vue={}));class _ue extends hue{static RECORD_PREFIX="enr:";peerId;static async create(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:BigInt(1);const r=new _ue(e,t,arguments.length>2?arguments[2]:void 0);try{const e=r.publicKey;e&&(r.peerId=await cue(e))}catch(n){mue.error("Could not calculate peer id for ENR",n)}return r}get nodeId(){if("v4"===this.id)return this.publicKey?function(e){const t=tse.fromHex(e).toRawBytes(!1);return vl(Kse(t.slice(1)))}(this.publicKey):void 0;throw new Error(Vse)}getLocationMultiaddr=zse.bind({},this);get shardInfo(){return this.rs&&this.rsv&&mue.warn("ENR contains both `rs` and `rsv` fields."),this.rs||this.rsv}setLocationMultiaddr(e){const t=e.protoNames();if(2!==t.length&&"udp"!==t[1]&&"tcp"!==t[1])throw new Error("Invalid multiaddr");const r=e.tuples();if(!r[0][1]||!r[1][1])throw new Error("Invalid multiaddr");4===r[0][0]?(this.set("ip",r[0][1]),this.set(t[1],r[1][1])):(this.set("ip6",r[0][1]),this.set(t[1]+"6",r[1][1]))}getAllLocationMultiaddrs(){const e=[];for(const r of Object.values(vue)){const t=this.getLocationMultiaddr(r);t&&e.push(t)}const t=this.multiaddrs??[];return e.concat(t).map((e=>this.peerId?e.encapsulate(`/p2p/${this.peerId.toString()}`):e))}get peerInfo(){const e=this.peerId;if(e)return{id:e,multiaddrs:this.getAllLocationMultiaddrs()}}getFullMultiaddr(e){if(this.peerId){const t=this.getLocationMultiaddr(e);if(t)return t.encapsulate(`/p2p/${this.peerId.toString()}`)}}getFullMultiaddrs(){if(this.peerId&&this.multiaddrs){const e=this.peerId;return this.multiaddrs.map((t=>t.encapsulate(`/p2p/${e.toString()}`)))}return[]}verify(e,t){if(!this.get("id")||"v4"!==this.id)throw new Error(Vse);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return Fse(t,Kse(e),this.publicKey)}async sign(e,t){if("v4"!==this.id)throw new Error(Vse);return this.signature=await yue(t,e),this.signature}}let Eue=!1,Sue=!1;const Aue={debug:1,default:2,info:2,warning:3,error:4,off:5};let kue=Aue.default,xue=null;const Iue=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(r){e.push(t)}})),e.length)throw new Error("missing "+e.join(", "));if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken implementation")}catch(e){return e.message}return null}();var Cue,Tue;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(Cue||(Cue={})),function(e){e.UNKNOWN_ERROR="UNKNOWN_ERROR",e.NOT_IMPLEMENTED="NOT_IMPLEMENTED",e.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",e.NETWORK_ERROR="NETWORK_ERROR",e.SERVER_ERROR="SERVER_ERROR",e.TIMEOUT="TIMEOUT",e.BUFFER_OVERRUN="BUFFER_OVERRUN",e.NUMERIC_FAULT="NUMERIC_FAULT",e.MISSING_NEW="MISSING_NEW",e.INVALID_ARGUMENT="INVALID_ARGUMENT",e.MISSING_ARGUMENT="MISSING_ARGUMENT",e.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",e.CALL_EXCEPTION="CALL_EXCEPTION",e.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",e.NONCE_EXPIRED="NONCE_EXPIRED",e.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",e.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",e.TRANSACTION_REPLACED="TRANSACTION_REPLACED",e.ACTION_REJECTED="ACTION_REJECTED"}(Tue||(Tue={}));const Rue="0123456789abcdef";class Pue{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const r=e.toLowerCase();null==Aue[r]&&this.throwArgumentError("invalid log level name","logLevel",e),kue>Aue[r]||console.log.apply(console,t)}debug(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(Pue.levels.DEBUG,t)}info(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(Pue.levels.INFO,t)}warn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];this._log(Pue.levels.WARNING,t)}makeError(e,t,r){if(Sue)return this.makeError("censored error",t,{});t||(t=Pue.errors.UNKNOWN_ERROR),r||(r={});const n=[];Object.keys(r).forEach((e=>{const t=r[e];try{if(t instanceof Uint8Array){let r="";for(let e=0;e<t.length;e++)r+=Rue[t[e]>>4],r+=Rue[15&t[e]];n.push(e+"=Uint8Array(0x"+r+")")}else n.push(e+"="+JSON.stringify(t))}catch(o){n.push(e+"="+JSON.stringify(r[e].toString()))}})),n.push(`code=${t}`),n.push(`version=${this.version}`);const i=e;let s="";switch(t){case Tue.NUMERIC_FAULT:{s="NUMERIC_FAULT";const t=e;switch(t){case"overflow":case"underflow":case"division-by-zero":s+="-"+t;break;case"negative-power":case"negative-width":s+="-unsupported";break;case"unbound-bitwise-result":s+="-unbound-result"}break}case Tue.CALL_EXCEPTION:case Tue.INSUFFICIENT_FUNDS:case Tue.MISSING_NEW:case Tue.NONCE_EXPIRED:case Tue.REPLACEMENT_UNDERPRICED:case Tue.TRANSACTION_REPLACED:case Tue.UNPREDICTABLE_GAS_LIMIT:s=t}s&&(e+=" [ See: https://links.ethers.org/v5-errors-"+s+" ]"),n.length&&(e+=" ("+n.join(", ")+")");const o=new Error(e);return o.reason=i,o.code=t,Object.keys(r).forEach((function(e){o[e]=r[e]})),o}throwError(e,t,r){throw this.makeError(e,t,r)}throwArgumentError(e,t,r){return this.throwError(e,Pue.errors.INVALID_ARGUMENT,{argument:t,value:r})}assert(e,t,r,n){e||this.throwError(t,r,n)}assertArgument(e,t,r,n){e||this.throwArgumentError(t,r,n)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),Iue&&this.throwError("platform missing String.prototype.normalize",Pue.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Iue})}checkSafeUint53(e,t){"number"===typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,Pue.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,Pue.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,r){r=r?": "+r:"",e<t&&this.throwError("missing argument"+r,Pue.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+r,Pue.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",Pue.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",Pue.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",Pue.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return xue||(xue=new Pue("logger/5.7.0")),xue}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",Pue.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Eue){if(!e)return;this.globalLogger().throwError("error censorship permanent",Pue.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Sue=!!e,Eue=!!t}static setLogLevel(e){const t=Aue[e.toLowerCase()];null!=t?kue=t:Pue.globalLogger().warn("invalid log level - "+e)}static from(e){return new Pue(e)}}Pue.errors=Tue,Pue.levels=Cue;const Due=new Pue("bytes/5.7.0");function Nue(e){return!!e.toHexString}function Bue(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return Bue(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function Uue(e){return que(e)&&!(e.length%2)||Mue(e)}function Lue(e){return"number"===typeof e&&e==e&&e%1===0}function Mue(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"===typeof e)return!1;if(!Lue(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const r=e[t];if(!Lue(r)||r<0||r>=256)return!1}return!0}function Oue(e,t){if(t||(t={}),"number"===typeof e){Due.checkSafeUint53(e,"invalid arrayify value");const t=[];for(;e;)t.unshift(255&e),e=parseInt(String(e/256));return 0===t.length&&t.push(0),Bue(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),Nue(e)&&(e=e.toHexString()),que(e)){let r=e.substring(2);r.length%2&&("left"===t.hexPad?r="0"+r:"right"===t.hexPad?r+="0":Due.throwArgumentError("hex data is odd-length","value",e));const n=[];for(let e=0;e<r.length;e+=2)n.push(parseInt(r.substring(e,e+2),16));return Bue(new Uint8Array(n))}return Mue(e)?Bue(new Uint8Array(e)):Due.throwArgumentError("invalid arrayify value","value",e)}function que(e,t){return!("string"!==typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}const Kue="0123456789abcdef";function Fue(e,t){if(t||(t={}),"number"===typeof e){Due.checkSafeUint53(e,"invalid hexlify value");let t="";for(;e;)t=Kue[15&e]+t,e=Math.floor(e/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if("bigint"===typeof e)return(e=e.toString(16)).length%2?"0x0"+e:"0x"+e;if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),Nue(e))return e.toHexString();if(que(e))return e.length%2&&("left"===t.hexPad?e="0x0"+e.substring(2):"right"===t.hexPad?e+="0":Due.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(Mue(e)){let t="0x";for(let r=0;r<e.length;r++){let n=e[r];t+=Kue[(240&n)>>4]+Kue[15&n]}return t}return Due.throwArgumentError("invalid hexlify value","value",e)}const Vue=new Pue("rlp/5.7.0");function zue(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function $ue(e,t,r){let n=0;for(let i=0;i<r;i++)n=256*n+e[t+i];return n}function Hue(e){if(Array.isArray(e)){let t=[];if(e.forEach((function(e){t=t.concat(Hue(e))})),t.length<=55)return t.unshift(192+t.length),t;const r=zue(t.length);return r.unshift(247+r.length),r.concat(t)}Uue(e)||Vue.throwArgumentError("RLP object must be BytesLike","object",e);const t=Array.prototype.slice.call(Oue(e));if(1===t.length&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const r=zue(t.length);return r.unshift(183+r.length),r.concat(t)}function jue(e){return Fue(Hue(e))}function Gue(e,t,r,n){const i=[];for(;r<t+1+n;){const s=Wue(e,r);i.push(s.result),(r+=s.consumed)>t+1+n&&Vue.throwError("child data too short",Pue.errors.BUFFER_OVERRUN,{})}return{consumed:1+n,result:i}}function Wue(e,t){if(0===e.length&&Vue.throwError("data too short",Pue.errors.BUFFER_OVERRUN,{}),e[t]>=248){const r=e[t]-247;t+1+r>e.length&&Vue.throwError("data short segment too short",Pue.errors.BUFFER_OVERRUN,{});const n=$ue(e,t+1,r);return t+1+r+n>e.length&&Vue.throwError("data long segment too short",Pue.errors.BUFFER_OVERRUN,{}),Gue(e,t,t+1+r,r+n)}if(e[t]>=192){const r=e[t]-192;return t+1+r>e.length&&Vue.throwError("data array too short",Pue.errors.BUFFER_OVERRUN,{}),Gue(e,t,t+1,r)}if(e[t]>=184){const r=e[t]-183;t+1+r>e.length&&Vue.throwError("data array too short",Pue.errors.BUFFER_OVERRUN,{});const n=$ue(e,t+1,r);t+1+r+n>e.length&&Vue.throwError("data array too short",Pue.errors.BUFFER_OVERRUN,{});return{consumed:1+r+n,result:Fue(e.slice(t+1+r,t+1+r+n))}}if(e[t]>=128){const r=e[t]-128;t+1+r>e.length&&Vue.throwError("data too short",Pue.errors.BUFFER_OVERRUN,{});return{consumed:1+r,result:Fue(e.slice(t+1,t+1+r))}}return{consumed:1,result:Fue(e[t])}}const Yue=new Ll("enr:decoder");class Que{static fromString(e){if(!e.startsWith(_ue.RECORD_PREFIX))throw new Error(`"string encoded ENR must start with '${_ue.RECORD_PREFIX}'`);return Que.fromRLP(Tae(e.slice(4),"base64url"))}static fromRLP(e){const t=function(e){const t=Oue(e),r=Wue(t,0);return r.consumed!==t.length&&Vue.throwArgumentError("invalid rlp data","data",e),r.result}(e).map(wl);return async function(e){const{signature:t,seq:r,kvs:n}=function(e){if(!Array.isArray(e))throw new Error("Decoded ENR must be an array");if(e.length%2!==0)throw new Error("Decoded ENR must have an even number of elements");const[t,r,...n]=e;if(!t||Array.isArray(t))throw new Error("Decoded ENR invalid signature: must be a byte array");if(!r||Array.isArray(r))throw new Error("Decoded ENR invalid sequence number: must be a byte array");return{signature:t,seq:r,kvs:n}}(e),i={};for(let c=0;c<n.length;c+=2)try{i[_l(n[c])]=n[c+1]}catch(a){Yue.error("Failed to decode ENR key to UTF-8, skipping it",n[c],a)}const s=function(e){return e.length?BigInt("0x"+vl(e)):BigInt(0)}(r),o=await _ue.create(i,s,t);return function(e,t,r,n){const i=wl(jue([e,...t]));if(!r.verify(i,n))throw new Error("Unable to verify ENR signature")}(r,n,o,t),o}(t)}}const Jue=/^(\d{1,3}\.){3,3}\d{1,3}$/,Xue=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,Zue={name:"v4",size:4,isFormat:e=>Jue.test(e),encode(e,t,r){r=~~r,t=t||new Uint8Array(r+4);const n=e.length;let i=0;for(let s=0;s<n;){const n=e.charCodeAt(s++);46===n?(t[r++]=i,i=0):i=10*i+(n-48)}return t[r]=i,t},decode:(e,t)=>(t=~~t,`${e[t++]}.${e[t++]}.${e[t++]}.${e[t]}`)},ele={name:"v6",size:16,isFormat:e=>e.length>0&&Xue.test(e),encode(e,t,r){let n=(r=~~r)+16,i=-1,s=0,o=0,a=!0,c=!1;t=t||new Uint8Array(r+16);for(let u=0;u<e.length;u++){let l=e.charCodeAt(u);58===l?(a?-1!==i?(r<n&&(t[r]=0),r<n-1&&(t[r+1]=0),r+=2):r<n&&(i=r):(!0===c?(r<n&&(t[r]=o),r++):(r<n&&(t[r]=s>>8),r<n-1&&(t[r+1]=255&s),r+=2),s=0,o=0),a=!0,c=!1):46===l?(r<n&&(t[r]=o),r++,o=0,s=0,a=!1,c=!0):(a=!1,l>=97?l-=87:l>=65?l-=55:(l-=48,o=10*o+l),s=(s<<4)+l)}if(!1===a)!0===c?(r<n&&(t[r]=o),r++):(r<n&&(t[r]=s>>8),r<n-1&&(t[r+1]=255&s),r+=2);else if(0===i)r<n&&(t[r]=0),r<n-1&&(t[r+1]=0),r+=2;else if(-1!==i){r+=2;for(let e=Math.min(r-1,n-1);e>=i+2;e--)t[e]=t[e-2];t[i]=0,t[i+1]=0,i=r}if(i!==r&&-1!==i)for(r>n-2&&(r=n-2);n>i;)t[--n]=r<n&&r>i?t[--r]:0;else for(;r<n;)t[r++]=0;return t},decode(e,t){t=~~t;let r="";for(let n=0;n<16;n+=2)0!==n&&(r+=":"),r+=(e[t+n]<<8|e[t+n+1]).toString(16);return r.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};function tle(e){if(Zue.isFormat(e))return Zue.size;if(ele.isFormat(e))return ele.size;throw Error(`Invalid ip address: ${e}`)}function rle(e){switch(e){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+e}function nle(e){switch(e.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":case"*":return 255}return e.toUpperCase().startsWith("UNKNOWN_")?parseInt(e.slice(8)):0}function ile(e){switch(e){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+e}function sle(e){switch(e){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+e}function ole(e){switch(e){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+e}function ale(e){switch(e.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}function cle(e){if("number"===typeof e)return e;if(!e)return-1;switch(e.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}const t=e.match(/_(\d+)$/);return t?parseInt(t[1],10):-1}const ule=55296,lle=56320;function hle(e){let t=0;const r=e.length;for(let n=0;n<r;n+=1){const i=e.charCodeAt(n);if(i<=127)t+=1;else if(i<=2047)t+=2;else if((63488&i)!==ule)t+=3;else{const s=n+1;if(s===r||i>=lle)t+=3;else{(64512&e.charCodeAt(s))!==lle?t+=3:(n=s,t+=4)}}}return t}function dle(e,t,r){const n=e.length;void 0!==r&&null!==r||(r=0),void 0===t&&(t=new Uint8Array(hle(e)+r));let i=r;for(let s=0;s<n;s+=1){let r=e.charCodeAt(s);if(r<=127)t[i++]=r;else if(r<=2047)t[i++]=192|(1984&r)>>6,t[i++]=128|63&r;else if((63488&r)!==ule)t[i++]=224|(61440&r)>>12,t[i++]=128|(4032&r)>>6,t[i++]=128|63&r;else{const o=s+1;if(o===n||r>=lle)t[i++]=239,t[i++]=191,t[i++]=189;else{const n=e.charCodeAt(o);(64512&n)!==lle?(t[i++]=239,t[i++]=191,t[i++]=189):(s=o,r=65536|(1023&r)<<10|1023&n,t[i++]=240|(1835008&r)>>18,t[i++]=128|(258048&r)>>12,t[i++]=128|(4032&r)>>6,t[i++]=128|63&r)}}}return dle.bytes=i-r,t}function fle(e,t,r){let n="";void 0!==t&&null!==t||(t=0),void 0!==r&&null!==r||(r=e.length);for(let i=t;i<r;){const t=e[i++];let r;if(t<=128)r=t;else if(t>191&&t<224)r=(31&t)<<6|63&e[i++];else if(t>239&&t<365){r=((7&t)<<18|(63&e[i++])<<12|(63&e[i++])<<6|63&e[i++])-65536;const s=ule|r>>10&1023;n+=String.fromCharCode(s),r=lle|1023&r}else r=(15&t)<<12|(63&e[i++])<<6|63&e[i++];n+=String.fromCharCode(r)}return fle.bytes=r-t,n}dle.bytes=0,fle.bytes=0;const ple=e=>e instanceof Uint8Array;function gle(e){return"string"===typeof e?hle(e):e.byteLength}function ble(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):dle(e)}function yle(e,t,r){if("string"!==typeof t)throw new Error("unknown input type");return dle(t,e,r),dle.bytes}const mle=Math.pow(2,24),wle=Math.pow(2,16),vle=Math.pow(2,8),_le=(e,t)=>e[t]*mle+e[t+1]*wle+e[t+2]*vle+e[t+3],Ele=(e,t)=>e[t]<<8|e[t+1],Sle=(e,t,r)=>(t=+t,e[r+3]=t,t>>>=8,e[r+2]=t,t>>>=8,e[r+1]=t,t>>>=8,e[r]=t,r+4),Ale=(e,t,r)=>(e[r]=t>>8,e[r+1]=255&t,r+2);function kle(e,t,r,n,i){return r<0&&(n-=r,r=0),n<0&&(n=0),i<0?new Uint8Array(0):r>=t.length||n>=i?0:function(e,t,r,n,i){i-n>t.length-r&&(i=n+t.length-r);let s=i-n;const o=e.length-n;s>o&&(s=o);(0!==n||i<e.length)&&(e=new Uint8Array(e.buffer,e.byteOffset+n,s));return t.set(e,r),s}(e,t,r,n,i)}const xle=32768;function Ile(e){let{bytes:t=0,encode:r,decode:n,encodingLength:i}=e;return r.bytes=t,n.bytes=t,{encode:r,decode:n,encodingLength:i||(()=>t)}}const Cle=Ile({encode(e,t,r){t||(t=new Uint8Array(Cle.encodingLength(e))),r||(r=0);const n=r,i=e.replace(/^\.|\.$/gm,"");if(i.length){const e=i.split(".");for(let n=0;n<e.length;n++){const i=yle(t,e[n],r+1);t[r]=i,r+=i+1}}return t[r++]=0,Cle.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=[];let n=t,i=0,s=0,o=!1;for(;;){if(t>=e.length)throw new Error("Cannot decode name (buffer overflow)");const a=e[t++];if(s+=o?0:1,0===a)break;if(0===(192&a)){if(t+a>e.length)throw new Error("Cannot decode name (buffer overflow)");if(i+=a+1,i>254)throw new Error("Cannot decode name (name too long)");r.push(fle(e,t,t+a)),t+=a,s+=o?0:a}else{if(192!==(192&a))throw new Error("Cannot decode name (bad label)");{if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");const r=Ele(e,t-1)-49152;if(r>=n)throw new Error("Cannot decode name (bad pointer)");t=r,n=r,s+=o?0:1,o=!0}}}return Cle.decode.bytes=s,0===r.length?".":r.join(".")},encodingLength:e=>"."===e||".."===e?1:gle(e.replace(/^\.|\.$/gm,""))+2}),Tle=Ile({encode(e,t,r){t||(t=new Uint8Array(Tle.encodingLength(e))),r||(r=0);const n=yle(t,e,r+1);return t[r]=n,Tle.encode.bytes=n+1,t},decode(e,t){t||(t=0);const r=e[t],n=fle(e,t+1,t+1+r);return Tle.decode.bytes=r+1,n},encodingLength:e=>gle(e)+1}),Rle=Ile({bytes:12,encode(e,t,r){t||(t=new Uint8Array(Rle.encodingLength(e))),r||(r=0);const n=32767&(e.flags||0),i="response"===e.type?32768:0;return Ale(t,e.id||0,r),Ale(t,n|i,r+2),Ale(t,e.questions.length,r+4),Ale(t,e.answers.length,r+6),Ale(t,e.authorities.length,r+8),Ale(t,e.additionals.length,r+10),t},decode(e,t){if(t||(t=0),e.length<12)throw new Error("Header must be 12 bytes");const r=Ele(e,t+2);return{id:Ele(e,t),type:32768&r?"response":"query",flags:32767&r,flag_qr:1===(r>>15&1),opcode:sle(r>>11&15),flag_aa:1===(r>>10&1),flag_tc:1===(r>>9&1),flag_rd:1===(r>>8&1),flag_ra:1===(r>>7&1),flag_z:1===(r>>6&1),flag_ad:1===(r>>5&1),flag_cd:1===(r>>4&1),rcode:ile(15&r),questions:new Array(Ele(e,t+4)),answers:new Array(Ele(e,t+6)),authorities:new Array(Ele(e,t+8)),additionals:new Array(Ele(e,t+10))}},encodingLength:()=>12}),Ple=Ile({encode(e,t,r){t||(t=new Uint8Array(Ple.encodingLength(e))),r||(r=0);const n=e.length;return Ale(t,n,r),kle(e,t,r+2,0,n),Ple.encode.bytes=n+2,t},decode(e,t){t||(t=0);const r=Ele(e,t),n=e.slice(t+2,t+2+r);return Ple.decode.bytes=r+2,n},encodingLength:e=>e.length+2}),Dle=Ile({encode:(e,t,r)=>(t||(t=new Uint8Array(Dle.encodingLength(e))),r||(r=0),Cle.encode(e,t,r+2),Ale(t,Cle.encode.bytes,r),Dle.encode.bytes=Cle.encode.bytes+2,t),decode(e,t){t||(t=0);const r=Ele(e,t),n=Cle.decode(e,t+2);return Dle.decode.bytes=r+2,n},encodingLength:e=>Cle.encodingLength(e)+2}),Nle=Ile({encode(e,t,r){t||(t=new Uint8Array(Nle.encodingLength(e))),r||(r=0);const n=r;return r+=2,Cle.encode(e.mname,t,r),r+=Cle.encode.bytes,Cle.encode(e.rname,t,r),r+=Cle.encode.bytes,Sle(t,e.serial||0,r),r+=4,Sle(t,e.refresh||0,r),r+=4,Sle(t,e.retry||0,r),r+=4,Sle(t,e.expire||0,r),r+=4,Sle(t,e.minimum||0,r),Ale(t,(r+=4)-n-2,n),Nle.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.mname=Cle.decode(e,t),t+=Cle.decode.bytes,n.rname=Cle.decode(e,t),t+=Cle.decode.bytes,n.serial=_le(e,t),t+=4,n.refresh=_le(e,t),t+=4,n.retry=_le(e,t),t+=4,n.expire=_le(e,t),t+=4,n.minimum=_le(e,t),t+=4,Nle.decode.bytes=t-r,n},encodingLength:e=>22+Cle.encodingLength(e.mname)+Cle.encodingLength(e.rname)}),Ble=Ile({encode(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i<e.length;i++)if("string"===typeof e[i]&&(e[i]=ble(e[i])),!ple(e[i]))throw new Error("Must be a Buffer");t||(t=new Uint8Array(Ble.encodingLength(e))),r||(r=0);const n=r;return r+=2,e.forEach((function(e){t[r++]=e.length,kle(e,t,r,0,e.length),r+=e.length})),Ale(t,r-n-2,n),Ble.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t;let n=Ele(e,t);t+=2;const i=[];for(;n>0;){const r=e[t++];if(--n,n<r)throw new Error("Buffer overflow");i.push(e.slice(t,t+r)),t+=r,n-=r}return Ble.decode.bytes=t-r,i},encodingLength(e){Array.isArray(e)||(e=[e]);let t=2;return e.forEach((function(e){t+="string"===typeof e?gle(e)+1:e.length+1})),t}}),Ule=Ile({encode(e,t,r){t||(t=new Uint8Array(Ule.encodingLength(e))),r||(r=0),"string"===typeof e&&(e=ble(e)),e||(e=new Uint8Array(0));const n=r;r+=2;const i=e.length;return kle(e,t,r,0,i),Ale(t,(r+=i)-n-2,n),Ule.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n=Ele(e,t);t+=2;const i=e.slice(t,t+n);return t+=n,Ule.decode.bytes=t-r,i},encodingLength:e=>e?(ple(e)?e.length:gle(e))+2:2}),Lle=Ile({encode(e,t,r){t||(t=new Uint8Array(Lle.encodingLength(e))),r||(r=0);const n=r;return r+=2,Tle.encode(e.cpu,t,r),r+=Tle.encode.bytes,Tle.encode(e.os,t,r),r+=Tle.encode.bytes,Ale(t,r-n-2,n),Lle.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.cpu=Tle.decode(e,t),t+=Tle.decode.bytes,n.os=Tle.decode(e,t),t+=Tle.decode.bytes,Lle.decode.bytes=t-r,n},encodingLength:e=>Tle.encodingLength(e.cpu)+Tle.encodingLength(e.os)+2}),Mle=Ile({encode:(e,t,r)=>(t||(t=new Uint8Array(Mle.encodingLength(e))),r||(r=0),Cle.encode(e,t,r+2),Ale(t,Cle.encode.bytes,r),Mle.encode.bytes=Cle.encode.bytes+2,t),decode(e,t){t||(t=0);const r=Cle.decode(e,t+2);return Mle.decode.bytes=Cle.decode.bytes+2,r},encodingLength:e=>Cle.encodingLength(e)+2}),Ole=Ile({encode(e,t,r){t||(t=new Uint8Array(Ole.encodingLength(e))),r||(r=0),Ale(t,e.priority||0,r+2),Ale(t,e.weight||0,r+4),Ale(t,e.port||0,r+6),Cle.encode(e.target,t,r+8);const n=Cle.encode.bytes+6;return Ale(t,n,r),Ole.encode.bytes=n+2,t},decode(e,t){t||(t=0);const r=Ele(e,t),n={};return n.priority=Ele(e,t+2),n.weight=Ele(e,t+4),n.port=Ele(e,t+6),n.target=Cle.decode(e,t+8),Ole.decode.bytes=r+2,n},encodingLength:e=>8+Cle.encodingLength(e.target)}),qle=Ile({encode(e,t,r){const n=qle.encodingLength(e);return t||(t=new Uint8Array(qle.encodingLength(e))),r||(r=0),e.issuerCritical&&(e.flags=qle.ISSUER_CRITICAL),Ale(t,n-2,r),t[r+=2]=e.flags||0,r+=1,Tle.encode(e.tag,t,r),r+=Tle.encode.bytes,yle(t,e.value,r),r+=gle(e.value),qle.encode.bytes=n,t},decode(e,t){t||(t=0);const r=Ele(e,t),n=t+=2,i={};return i.flags=e[t],t+=1,i.tag=Tle.decode(e,t),t+=Tle.decode.bytes,i.value=fle(e,t,n+r),i.issuerCritical=!!(i.flags&qle.ISSUER_CRITICAL),qle.decode.bytes=r+2,i},encodingLength:e=>Tle.encodingLength(e.tag)+Tle.encodingLength(e.value)+2});qle.ISSUER_CRITICAL=128;const Kle=Ile({encode(e,t,r){t||(t=new Uint8Array(Kle.encodingLength(e))),r||(r=0);const n=r;return r+=2,Ale(t,e.preference||0,r),r+=2,Cle.encode(e.exchange,t,r),r+=Cle.encode.bytes,Ale(t,r-n-2,n),Kle.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.preference=Ele(e,t),t+=2,n.exchange=Cle.decode(e,t),t+=Cle.decode.bytes,Kle.decode.bytes=t-r,n},encodingLength:e=>4+Cle.encodingLength(e.exchange)}),Fle=Ile({encode:(e,t,r)=>(t||(t=new Uint8Array(Fle.encodingLength(e))),r||(r=0),Ale(t,4,r),r+=2,Zue.encode(e,t,r),t),decode(e,t){t||(t=0),t+=2;return Zue.decode(e,t)},bytes:6}),Vle=Ile({encode:(e,t,r)=>(t||(t=new Uint8Array(Vle.encodingLength(e))),r||(r=0),Ale(t,16,r),r+=2,ele.encode(e,t,r),Vle.encode.bytes=18,t),decode(e,t){t||(t=0),t+=2;const r=ele.decode(e,t);return Vle.decode.bytes=18,r},bytes:18}),zle=e=>new Uint8Array(e),$le=Ile({encode(e,t,r){t||(t=new Uint8Array($le.encodingLength(e))),r||(r=0);const n=r,i=cle(e.code);if(Ale(t,i,r),r+=2,e.data)Ale(t,e.data.length,r),r+=2,kle(e.data,t,r),r+=e.data.length;else switch(i){case 8:{const n=e.sourcePrefixLength||0,i=e.family||function(e){return tle(e)===Zue.size?1:2}(e.ip),s=function(e,t,r){r=~~r;const n=tle(e);return"function"===typeof t&&(t=t(r+n)),n===Zue.size?Zue.encode(e,t,r):ele.encode(e,t,r)}(e.ip,zle),o=Math.ceil(n/8);Ale(t,o+4,r),Ale(t,i,r+=2),r+=2,t[r++]=n,t[r++]=e.scopePrefixLength||0,kle(s,t,r,0,o),r+=o}break;case 11:e.timeout?(Ale(t,2,r),r+=2,Ale(t,e.timeout,r),r+=2):(Ale(t,0,r),r+=2);break;case 12:{const n=e.length||0;Ale(t,n,r),r+=2,t.fill(0,r,r+n),r+=n}break;case 14:{const n=2*e.tags.length;Ale(t,n,r),r+=2;for(const i of e.tags)Ale(t,i,r),r+=2}break;default:throw new Error(`Unknown roption code: ${e.code}`)}return $le.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r={};r.code=Ele(e,t),r.type=function(e){switch(e){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return e<0?null:`OPTION_${e}`}(r.code);const n=Ele(e,t+=2);switch(t+=2,r.data=e.slice(t,t+n),r.code){case 8:r.family=Ele(e,t),t+=2,r.sourcePrefixLength=e[t++],r.scopePrefixLength=e[t++];{const i=new Uint8Array(1===r.family?4:16);kle(e,i,0,t,t+n-4),r.ip=function(e,t,r){if(t=~~t,(r=r||e.length-t)===Zue.size)return Zue.decode(e,t,r);if(r===ele.size)return ele.decode(e,t,r);throw Error(`Invalid buffer size needs to be ${Zue.size} for v4 or ${ele.size} for v6.`)}(i)}break;case 11:n>0&&(r.timeout=Ele(e,t),t+=2);break;case 14:r.tags=[];for(let i=0;i<n;i+=2)r.tags.push(Ele(e,t)),t+=2}return $le.decode.bytes=n+4,r},encodingLength(e){if(e.data)return e.data.length+4;switch(cle(e.code)){case 8:{const t=e.sourcePrefixLength||0;return Math.ceil(t/8)+8}case 11:return"number"===typeof e.timeout?6:4;case 12:return e.length+4;case 14:return 4+2*e.tags.length}throw new Error(`Unknown roption code: ${e.code}`)}}),Hle=Ile({encode(e,t,r){t||(t=new Uint8Array(Hle.encodingLength(e))),r||(r=0);const n=r,i=lhe(e,$le);return Ale(t,i,r),r=hhe(e,$le,t,r+2),Hle.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r=t,n=[];let i=Ele(e,t);t+=2;let s=0;for(;i>0;)n[s++]=$le.decode(e,t),t+=$le.decode.bytes,i-=$le.decode.bytes;return Hle.decode.bytes=t-r,n},encodingLength:e=>2+lhe(e||[],$le)}),jle=Ile({encode(e,t,r){t||(t=new Uint8Array(jle.encodingLength(e))),r||(r=0);const n=r,i=e.key;if(!ple(i))throw new Error("Key must be a Buffer");return r+=2,Ale(t,e.flags,r),t[r+=2]=jle.PROTOCOL_DNSSEC,t[r+=1]=e.algorithm,kle(i,t,r+=1,0,i.length),r+=i.length,jle.encode.bytes=r-n,Ale(t,jle.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=Ele(e,t);if(t+=2,n.flags=Ele(e,t),e[t+=2]!==jle.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return t+=1,n.algorithm=e[t],t+=1,n.key=e.slice(t,r+i+2),t+=n.key.length,jle.decode.bytes=t-r,n},encodingLength:e=>6+gle(e.key)});jle.PROTOCOL_DNSSEC=3,jle.ZONE_KEY=128,jle.SECURE_ENTRYPOINT=32768;const Gle=Ile({encode(e,t,r){t||(t=new Uint8Array(Gle.encodingLength(e))),r||(r=0);const n=r,i=e.signature;if(!ple(i))throw new Error("Signature must be a Buffer");return r+=2,Ale(t,nle(e.typeCovered),r),t[r+=2]=e.algorithm,t[r+=1]=e.labels,r+=1,Sle(t,e.originalTTL,r),r+=4,Sle(t,e.expiration,r),r+=4,Sle(t,e.inception,r),r+=4,Ale(t,e.keyTag,r),r+=2,Cle.encode(e.signersName,t,r),kle(i,t,r+=Cle.encode.bytes,0,i.length),r+=i.length,Gle.encode.bytes=r-n,Ale(t,Gle.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=Ele(e,t);return t+=2,n.typeCovered=rle(Ele(e,t)),t+=2,n.algorithm=e[t],t+=1,n.labels=e[t],t+=1,n.originalTTL=_le(e,t),t+=4,n.expiration=_le(e,t),t+=4,n.inception=_le(e,t),t+=4,n.keyTag=Ele(e,t),t+=2,n.signersName=Cle.decode(e,t),t+=Cle.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,Gle.decode.bytes=t-r,n},encodingLength:e=>20+Cle.encodingLength(e.signersName)+gle(e.signature)}),Wle=Ile({encode(e,t,r){t||(t=new Uint8Array(Wle.encodingLength(e))),r||(r=0);const n=r;return r+=2,Cle.encode(e.mbox||".",t,r),r+=Cle.encode.bytes,Cle.encode(e.txt||".",t,r),r+=Cle.encode.bytes,Wle.encode.bytes=r-n,Ale(t,Wle.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={};return t+=2,n.mbox=Cle.decode(e,t)||".",t+=Cle.decode.bytes,n.txt=Cle.decode(e,t)||".",t+=Cle.decode.bytes,Wle.decode.bytes=t-r,n},encodingLength:e=>2+Cle.encodingLength(e.mbox||".")+Cle.encodingLength(e.txt||".")}),Yle=Ile({encode(e,t,r){t||(t=new Uint8Array(Yle.encodingLength(e))),r||(r=0);const n=r,i=[];for(let s=0;s<e.length;s++){const t=nle(e[s]);void 0===i[t>>8]&&(i[t>>8]=[]),i[t>>8][t>>3&31]|=1<<7-(7&t)}for(let s=0;s<i.length;s++)if(void 0!==i[s]){const e=ble(i[s]);t[r]=s,t[r+=1]=e.length,kle(e,t,r+=1,0,e.length),r+=e.length}return Yle.encode.bytes=r-n,t},decode(e,t,r){t||(t=0);const n=t,i=[];for(;t-n<r;){const r=e[t],n=e[t+=1];t+=1;for(let s=0;s<n;s++){const n=e[t+s];for(let e=0;e<8;e++)if(n&1<<7-e){const t=rle(r<<8|s<<3|e);i.push(t)}}t+=n}return Yle.decode.bytes=t-n,i},encodingLength(e){const t=[];for(let n=0;n<e.length;n++){const r=nle(e[n]);t[r>>8]=Math.max(t[r>>8]||0,255&r)}let r=0;for(let n=0;n<t.length;n++)void 0!==t[n]&&(r+=2+Math.ceil((t[n]+1)/8));return r}}),Qle=Ile({encode(e,t,r){t||(t=new Uint8Array(Qle.encodingLength(e))),r||(r=0);const n=r;return r+=2,Cle.encode(e.nextDomain,t,r),r+=Cle.encode.bytes,Yle.encode(e.rrtypes,t,r),r+=Yle.encode.bytes,Qle.encode.bytes=r-n,Ale(t,Qle.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=Ele(e,t);return t+=2,n.nextDomain=Cle.decode(e,t),t+=Cle.decode.bytes,n.rrtypes=Yle.decode(e,t,i-(t-r)),t+=Yle.decode.bytes,Qle.decode.bytes=t-r,n},encodingLength:e=>2+Cle.encodingLength(e.nextDomain)+Yle.encodingLength(e.rrtypes)}),Jle=Ile({encode(e,t,r){t||(t=new Uint8Array(Jle.encodingLength(e))),r||(r=0);const n=r,i=e.salt;if(!ple(i))throw new Error("salt must be a Buffer");const s=e.nextDomain;if(!ple(s))throw new Error("nextDomain must be a Buffer");return t[r+=2]=e.algorithm,t[r+=1]=e.flags,r+=1,Ale(t,e.iterations,r),t[r+=2]=i.length,kle(i,t,r+=1,0,i.length),t[r+=i.length]=s.length,kle(s,t,r+=1,0,s.length),r+=s.length,Yle.encode(e.rrtypes,t,r),r+=Yle.encode.bytes,Jle.encode.bytes=r-n,Ale(t,Jle.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=Ele(e,t);t+=2,n.algorithm=e[t],t+=1,n.flags=e[t],t+=1,n.iterations=Ele(e,t);const s=e[t+=2];t+=1,n.salt=e.slice(t,t+s);const o=e[t+=s];return t+=1,n.nextDomain=e.slice(t,t+o),t+=o,n.rrtypes=Yle.decode(e,t,i-(t-r)),t+=Yle.decode.bytes,Jle.decode.bytes=t-r,n},encodingLength:e=>8+e.salt.length+e.nextDomain.length+Yle.encodingLength(e.rrtypes)}),Xle=Ile({encode(e,t,r){t||(t=new Uint8Array(Xle.encodingLength(e))),r||(r=0);const n=r,i=e.digest;if(!ple(i))throw new Error("Digest must be a Buffer");return r+=2,Ale(t,e.keyTag,r),t[r+=2]=e.algorithm,t[r+=1]=e.digestType,kle(i,t,r+=1,0,i.length),r+=i.length,Xle.encode.bytes=r-n,Ale(t,Xle.encode.bytes-2,n),t},decode(e,t){t||(t=0);const r=t,n={},i=Ele(e,t);return t+=2,n.keyTag=Ele(e,t),t+=2,n.algorithm=e[t],t+=1,n.digestType=e[t],t+=1,n.digest=e.slice(t,r+i+2),t+=n.digest.length,Xle.decode.bytes=t-r,n},encodingLength:e=>6+gle(e.digest)});function Zle(e){switch(e.toUpperCase()){case"A":return Fle;case"PTR":case"CNAME":case"DNAME":return Mle;case"TXT":return Ble;case"NULL":return Ule;case"AAAA":return Vle;case"SRV":return Ole;case"HINFO":return Lle;case"CAA":return qle;case"NS":return Dle;case"SOA":return Nle;case"MX":return Kle;case"OPT":return Hle;case"DNSKEY":return jle;case"RRSIG":return Gle;case"RP":return Wle;case"NSEC":return Qle;case"NSEC3":return Jle;case"DS":return Xle}return Ple}const ehe=Ile({encode(e,t,r){t||(t=new Uint8Array(ehe.encodingLength(e))),r||(r=0);const n=r;if(Cle.encode(e.name,t,r),r+=Cle.encode.bytes,Ale(t,nle(e.type),r),"OPT"===e.type.toUpperCase()){if("."!==e.name)throw new Error("OPT name must be root.");Ale(t,e.udpPayloadSize||4096,r+2),t[r+4]=e.extendedRcode||0,t[r+5]=e.ednsVersion||0,Ale(t,e.flags||0,r+6),r+=8,Hle.encode(e.options||[],t,r),r+=Hle.encode.bytes}else{let n=ale(void 0===e.class?"IN":e.class);e.flush&&(n|=xle),Ale(t,n,r+2),Sle(t,e.ttl||0,r+4),r+=8;const i=Zle(e.type);i.encode(e.data,t,r),r+=i.encode.bytes}return ehe.encode.bytes=r-n,t},decode(e,t){t||(t=0);const r={},n=t;if(r.name=Cle.decode(e,t),t+=Cle.decode.bytes,r.type=rle(Ele(e,t)),"OPT"===r.type)r.udpPayloadSize=Ele(e,t+2),r.extendedRcode=e[t+4],r.ednsVersion=e[t+5],r.flags=Ele(e,t+6),r.flag_do=1===(r.flags>>15&1),r.options=Hle.decode(e,t+8),t+=8+Hle.decode.bytes;else{const n=Ele(e,t+2);r.ttl=_le(e,t+4),r.class=ole(-32769&n),r.flush=!!(n&xle);const i=Zle(r.type);r.data=i.decode(e,t+8),t+=8+i.decode.bytes}return ehe.decode.bytes=t-n,r},encodingLength(e){const t=null!==e.data&&void 0!==e.data?e.data:e.options;return Cle.encodingLength(e.name)+8+Zle(e.type).encodingLength(t)}}),the=Ile({encode(e,t,r){t||(t=new Uint8Array(the.encodingLength(e))),r||(r=0);const n=r;return Cle.encode(e.name,t,r),r+=Cle.encode.bytes,Ale(t,nle(e.type),r),r+=2,Ale(t,ale(void 0===e.class?"IN":e.class),r),r+=2,the.encode.bytes=r-n,e},decode(e,t){t||(t=0);const r=t,n={};n.name=Cle.decode(e,t),t+=Cle.decode.bytes,n.type=rle(Ele(e,t)),t+=2,n.class=ole(Ele(e,t)),t+=2;return!!(32768&n.class)&&(n.class&=-32769),the.decode.bytes=t-r,n},encodingLength:e=>Cle.encodingLength(e.name)+4}),rhe=256,nhe={encode:function(e,t,r){const n=!t;n&&(t=new Uint8Array(uhe(e))),r||(r=0);const i=r;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),Rle.encode(e,t,r),r+=Rle.encode.bytes,r=hhe(e.questions,the,t,r),r=hhe(e.answers,ehe,t,r),r=hhe(e.authorities,ehe,t,r),r=hhe(e.additionals,ehe,t,r),nhe.encode.bytes=r-i,n&&ahe.bytes!==t.length?t.slice(0,ahe.bytes):t},decode:function(e,t){t||(t=0);const r=t,n=Rle.decode(e,t);return t+=Rle.decode.bytes,t=dhe(n.questions,the,e,t),t=dhe(n.answers,ehe,e,t),t=dhe(n.authorities,ehe,e,t),t=dhe(n.additionals,ehe,e,t),nhe.decode.bytes=t-r,n},encodingLength:function(e){return Rle.encodingLength(e)+lhe(e.questions||[],the)+lhe(e.answers||[],ehe)+lhe(e.authorities||[],ehe)+lhe(e.additionals||[],ehe)}};function ihe(e,t){if(e.questions)throw new Error("Only one .question object expected instead of a .questions array!");const r=Object.assign({type:t},e);return r.question&&(r.questions=[r.question],delete r.question),r}nhe.encode.bytes=0,nhe.decode.bytes=0;const she={encode:function(e,t,r){return t=nhe.encode(ihe(e,"query"),t,r),she.encode.bytes=nhe.encode.bytes,t},decode:function(e,t){const r=nhe.decode(e,t);return she.decode.bytes=nhe.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(e){return nhe.encodingLength(ihe(e,"query"))}};she.encode.bytes=0,she.decode.bytes=0;const ohe={encode:function(e,t,r){return t=nhe.encode(ihe(e,"response"),t,r),ohe.encode.bytes=nhe.encode.bytes,t},decode:function(e,t){const r=nhe.decode(e,t);return ohe.decode.bytes=nhe.decode.bytes,r.questions&&(r.question=r.questions[0],delete r.questions),r},encodingLength:function(e){return nhe.encodingLength(ihe(e,"response"))}};ohe.encode.bytes=0,ohe.decode.bytes=0;const ahe=nhe.encode,che=nhe.decode,uhe=nhe.encodingLength;function lhe(e,t){let r=0;for(let n=0;n<e.length;n++)r+=t.encodingLength(e[n]);return r}function hhe(e,t,r,n){for(let i=0;i<e.length;i++)t.encode(e[i],r,n),n+=t.encode.bytes;return n}function dhe(e,t,r,n){for(let i=0;i<e.length;i++)e[i]=t.decode(r,n),n+=t.decode.bytes;return n}function fhe(e,t,r,n){if(64!==t.length)throw new Error(`Charset needs to be 64 characters long! (${t.length})`);const i=new Uint8Array(256),s=new Uint8Array(64);for(let c=0;c<64;c+=1){const e=t.charCodeAt(c);if(e>255)throw new Error(`Character #${c} in charset [code=${e}, char=${t.charAt(c)}] is too high! (max=255)`);if(0!==i[e])throw new Error(`Character [code=${e}, char=${t.charAt(c)}] is more than once in the charset!`);i[e]=c,s[c]=e}const o=r.charCodeAt(0),a={name:e,encodingLength(e){const t=e.length,r=.75*t|0;return e.charCodeAt(t-1)===o?e.charCodeAt(t-2)===o?r-2:r-1:r},encode(e,t,r){null!==t&&void 0!==t||(t=new Uint8Array(a.encodingLength(e))),null!==r&&void 0!==r||(r=0);let n=e.length;e.charCodeAt(n-1)===o&&(e.charCodeAt(n-2)===o?n-=2:n-=1);const s=n%4,c=n-s;let u=r,l=0;for(;l<c;){const r=i[e.charCodeAt(l)]<<18|i[e.charCodeAt(l+1)]<<12|i[e.charCodeAt(l+2)]<<6|i[e.charCodeAt(l+3)];t[u++]=r>>16,t[u++]=r>>8,t[u++]=r,l+=4}if(3===s){const r=i[e.charCodeAt(l)]<<10|i[e.charCodeAt(l+1)]<<4|i[e.charCodeAt(l+2)]>>2;t[u++]=r>>8,t[u++]=r}else 2===s&&(t[u++]=i[e.charCodeAt(l)]<<2|i[e.charCodeAt(l+1)]>>4);return a.encode.bytes=u-r,t},decode(e,t,r){null!==t&&void 0!==t||(t=0),null!==r&&void 0!==r||(r=e.length);const i=r-t,c=i%3,u=t+i-c,l=[];for(let n=t;n<u;n+=3){const t=e[n]<<16|e[n+1]<<8|e[n+2];l.push(s[t>>18&63],s[t>>12&63],s[t>>6&63],s[63&t])}if(2===c){const t=(e[r-2]<<8)+e[r-1];l.push(s[t>>10],s[t>>4&63],s[t<<2&63]),1===n&&l.push(o)}else if(1===c){const t=e[r-1];l.push(s[t>>2],s[t<<4&63]),1===n&&l.push(o,o)}return a.decode.bytes=i,String.fromCharCode.apply(String,l)}};return a}fhe("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",1);const phe=fhe("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",2);let ghe="undefined"!==typeof global?global.AbortError:"undefined"!==typeof window?window.AbortError:null;ghe||(ghe=class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Request aborted.")}}),ghe.prototype.name="AbortError",ghe.prototype.code="ABORT_ERR";const bhe="undefined"!==typeof globalThis&&globalThis.URL||require("url").URL;class yhe extends Error{constructor(e,t,r){super("status="+t+" while requesting "+e+" ["+r+"]"),this.uri=e,this.status=t,this.method=r}toJSON(){return{code:this.code,uri:this.uri,status:this.status,method:this.method,endpoint:this.endpoint}}}yhe.prototype.name="HTTPStatusError",yhe.prototype.code="HTTP_STATUS";class mhe extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:Ehe(this.cause)}}}mhe.prototype.name="ResponseError",mhe.prototype.code="RESPONSE_ERR";class whe extends Error{constructor(e){super("Timeout (t="+e+")."),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}whe.prototype.name="TimeoutError",whe.prototype.code="ETIMEOUT";const vhe=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,_he=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function Ehe(e){if("string"===typeof e)return{message:e};try{const t=JSON.stringify(e);if("{}"!==t)return JSON.parse(t)}catch(r){}const t={message:String(e.message||e)};return void 0!==e.code&&(t.code=String(e.code)),t}const She=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,Ahe=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,khe=/\[(((pk|name)=([^\]]+)))\]/gi;function xhe(e,t){t.lastIndex=0;const r={};for(;;){const n=t.exec(e);if(!n)break;n[2]?r[n[3].toLowerCase()]=n[4]:r[n[1].toLowerCase()]=!0}return r}class Ihe extends Error{constructor(e,t){super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${Che.join(", ")}`),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}Ihe.prototype.name="InvalidProtocolError",Ihe.prototype.code="EPROTOCOL";const Che=["http:","https:","udp4:","udp6:"];class The{constructor(e,t){this.name=e.name||null,this.protocol=e.protocol;const r="string"===typeof e.port?e.port=parseInt(e.port,10):e.port;if(void 0===r||null===r)this.port=t?"https:"===this.protocol?443:80:e.pk?443:53;else{if("number"!==typeof r&&!isNaN(r))throw new Error(`Invalid Endpoint: port "${e.port}" needs to be a number: ${JSON.stringify(e)}`);this.port=r}}toJSON(){return this.toString()}}class Rhe extends The{constructor(e){super(e,!1),this.pk=e.pk||null}toString(){const e=this.port!==(this.pk?443:53)?`:${this.port}`:"",t=this.pk?` [pk=${this.pk}]`:"",r=this.name?` [name=${this.name}]`:"";return`udp://${this.ipv4||`[${this.ipv6}]`}${e}${t}${r}`}}class Phe extends Rhe{constructor(e){if(super(Object.assign({protocol:"udp4:"},e)),!e.ipv4||"string"!==typeof e.ipv4)throw new Error(`Invalid Endpoint: .ipv4 "${e.ipv4}" needs to be set: ${JSON.stringify(e)}`);this.ipv4=e.ipv4}}class Dhe extends Rhe{constructor(e){if(super(Object.assign({protocol:"udp6:"},e)),!e.ipv6||"string"!==typeof e.ipv6)throw new Error(`Invalid Endpoint: .ipv6 "${e.ipv6}" needs to be set: ${JSON.stringify(e)}`);this.ipv6=e.ipv6}}function Nhe(e){return _he.test(e)&&!vhe.test(e)?`[${e}]`:e}class Bhe extends The{constructor(e){if(super(Object.assign({protocol:"https:"},e),!0),e.host||(e.ipv4&&(e.host=e.ipv4),e.ipv6&&(e.host=`[${e.ipv6}]`)),!e.host||"string"!==typeof e.host)throw new Error(`Invalid Endpoint: host "${e.path}" needs to be set: ${JSON.stringify(e)}`);if(this.host=e.host,this.path=e.path||"/dns-query",this.method=/^post$/i.test(e.method)?"POST":"GET",this.ipv4=e.ipv4,this.ipv6=e.ipv6,!this.ipv6){const e=_he.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||vhe.test(this.host)&&(this.ipv4=this.host);const t=`${this.protocol}//${Nhe(this.host)}:${this.port}${this.path}`;try{this.url=new bhe(t)}catch(r){throw new Error(r.message+` [${t}]`)}}toString(){const e="https:"===this.protocol?"":"http://",t=this.port!==("https:"===this.protocol?443:80)?`:${this.port}`:"",r="GET"!==this.method?" [post]":"",n="/dns-query"===this.path?"":this.path,i=this.name?` [name=${this.name}]`:"",s=this.ipv4&&this.ipv4!==this.host?` [ipv4=${this.ipv4}]`:"",o=this.ipv6&&this.ipv6!==this.host?` [ipv6=${this.ipv6}]`:"";return`${e}${Nhe(this.host)}${t}${n}${r}${s}${o}${i}`}}function Uhe(e){let t;if("string"===typeof e)t=function(e){const t=She.exec(e),r=t[2]||"https:",n=t[3],i=t[5],s=t[6],o=t[7];if("https:"===r||"http:"===r){const e=xhe(o,Ahe);return{name:e.name,protocol:r,ipv4:e.ipv4,ipv6:e.ipv6,host:n,port:i,path:s,method:e.post?"POST":"GET"}}if("udp:"===r||"udp4:"===r||"udp6:"===r){const t=xhe(o,khe),s=/^\[(.*)\]$/.exec(n);if(s&&"udp4:"===r)throw new Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${e})`);if(!s&&"udp6:"===r)throw new Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${e})`);return s?new Dhe({protocol:"udp6:",ipv6:s[1],port:i,pk:t.pk,name:t.name}):new Phe({protocol:"udp4:",ipv4:n,port:i,pk:t.pk,name:t.name})}throw new Ihe(r,e)}(e);else{if("object"!==typeof e||null===e||Array.isArray(e))throw new Error(`Can not convert ${e} to an endpoint`);if(e instanceof The)return e;t=e}null!==t.protocol&&void 0!==t.protocol||(t.protocol="https:");const r=t.protocol;if("udp4:"===r)return new Phe(t);if("udp6:"===r)return new Dhe(t);if("https:"===r||"http:"===r)return new Bhe(t);throw new Ihe(r,JSON.stringify(t))}const Lhe="application/dns-message";function Mhe(){}function Ohe(e,t,r,n,i){return new Promise(((s,o)=>{const a=new bhe(e);"GET"===t&&r&&(a.search="?dns="+phe.decode(r));const c=a.toString(),u=new XMLHttpRequest;u.open(t,c,!0),u.setRequestHeader("Accept",Lhe),"POST"===t&&u.setRequestHeader("Content-Type",Lhe),u.responseType="arraybuffer",u.timeout=n,u.ontimeout=function(){l(new whe(n));try{u.abort()}catch(e){}},u.onreadystatechange=function(){if(u.readyState>1&&200!==u.status&&0!==u.status){l(new yhe(c,u.status,t));try{u.abort()}catch(e){}}},u.onerror=function(){l(200===u.status?new Error("Inexplicable XHR Error"):new yhe(c,u.status,t))},u.onload=function(){if(200!==u.status)l(new yhe(c,u.status,t));else{let e;if("string"===typeof u.response)e=dle(u.response);else if(u.response instanceof Uint8Array)e=u.response;else{if(!(Array.isArray(u.response)||u.response instanceof ArrayBuffer))throw new Error("Unprocessable response "+u.response);e=new Uint8Array(u.response)}l(null,e)}},"POST"===t?u.send(r):u.send(),i&&i.addEventListener("abort",h);let l=function(e,t){l=Mhe,i&&i.removeEventListener("abort",h),s(e?{error:e,response:u}:{data:t,response:u})};function h(){l(new ghe);try{u.abort()}catch(e){}}}))}Error;function qhe(e){const t=null===e.time||void 0===e.time?Date.now():e.time,r=function(e){return e.filter((e=>e.cors||e.endpoint.cors))}(e.data.map((e=>(e.endpoint=Uhe(Object.assign({name:e.name},e.endpoint)),e)))),n=r.map((e=>e.endpoint));return{data:{resolvers:r,resolverByName:r.reduce(((e,t)=>(e[t.name]=t,e)),{}),endpoints:n,endpointByName:n.reduce(((e,t)=>(e[t.name]=t,e)),{})},time:t}}const Khe=qhe({data:[{name:"adfree.usableprivacy.net",endpoint:{protocol:"https:",host:"adfree.usableprivacy.net"},description:"Public updns DoH service with advertising, tracker and malware filters.\nHosted in Europe by @usableprivacy, details see: https://docs.usableprivacy.com",country:"Germany",location:{lat:51.2993,long:9.491},filter:!0},{name:"adguard-dns-doh",endpoint:{protocol:"https:",host:"dns.adguard.com",ipv4:"94.140.15.15"},description:"Remove ads and protect your computer from malware (over DoH)",country:"France",location:{lat:48.8582,long:2.3387},filter:!0},{name:"adguard-dns-family-doh",endpoint:{protocol:"https:",host:"dns-family.adguard.com",ipv4:"94.140.15.16"},description:"Adguard DNS with safesearch and adult content blocking (over DoH)",country:"France",location:{lat:48.8582,long:2.3387},filter:!0},{name:"adguard-dns-unfiltered-doh",endpoint:{protocol:"https:",host:"dns-unfiltered.adguard.com",ipv4:"94.140.14.140"},description:"AdGuard public DNS servers without filters (over DoH)",country:"France",location:{lat:48.8582,long:2.3387}},{name:"ahadns-doh-chi",endpoint:{protocol:"https:",host:"doh.chi.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Chicago, USA. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=chi",country:"United States",location:{lat:41.8483,long:-87.6517},filter:!0,cors:!0},{name:"ahadns-doh-in",endpoint:{protocol:"https:",host:"doh.in.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Mumbai, India. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=in",country:"India",location:{lat:19.0748,long:72.8856},filter:!0,cors:!0},{name:"ahadns-doh-la",endpoint:{protocol:"https:",host:"doh.la.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Los Angeles, USA. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=la",country:"United States",location:{lat:34.0549,long:-118.2578},filter:!0,cors:!0},{name:"ahadns-doh-nl",endpoint:{protocol:"https:",host:"doh.nl.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Amsterdam, Netherlands. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=nl",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"ahadns-doh-ny",endpoint:{protocol:"https:",host:"doh.ny.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in New York. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=ny",country:"United States",location:{lat:40.7308,long:-73.9975},filter:!0,cors:!0},{name:"ahadns-doh-pl",endpoint:{protocol:"https:",host:"doh.pl.ahadns.net",cors:!0},description:"A zero logging DNS with support for DNS-over-HTTPS (DoH) & DNS-over-TLS (DoT). Blocks ads, malware, trackers, viruses, ransomware, telemetry and more. No persistent logs. DNSSEC. Hosted in Poland. By https://ahadns.com/\nServer statistics can be seen at: https://statistics.ahadns.com/?server=pl",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"alidns-doh",endpoint:{protocol:"https:",host:"dns.alidns.com",ipv4:"223.5.5.5",cors:!0},description:"A public DNS resolver that supports DoH/DoT in mainland China, provided by Alibaba-Cloud.\nWarning: GFW filtering rules are applied by that resolver.\nHomepage: https://alidns.com/",country:"China",location:{lat:34.7725,long:113.7266},filter:!0,log:!0,cors:!0},{name:"ams-ads-doh-nl",endpoint:{protocol:"https:",host:"dnsnl-noads.alekberg.net"},description:"Resolver in Amsterdam. DoH protocol. Non-logging. Blocks ads, malware and trackers. DNSSEC enabled.",country:"Romania",location:{lat:45.9968,long:24.997},filter:!0},{name:"ams-doh-nl",endpoint:{protocol:"https:",host:"dnsnl.alekberg.net"},description:"Resolver in Amsterdam. DoH protocol. Non-logging, non-filtering, DNSSEC.",country:"Romania",location:{lat:45.9968,long:24.997}},{name:"att",endpoint:{protocol:"https:",host:"dohtrial.att.net"},description:"AT&T test DoH server.",log:!0},{name:"bcn-ads-doh",endpoint:{protocol:"https:",host:"dnses-noads.alekberg.net"},description:"Resolver in Spain. DoH protocol. Non-logging, remove ads and malware, DNSSEC.",country:"Spain",location:{lat:41.3891,long:2.1611},filter:!0},{name:"bcn-doh",endpoint:{protocol:"https:",host:"dnses.alekberg.net"},description:"Resolver in Spain. DoH protocol. Non-logging, non-filtering, DNSSEC.",country:"Spain",location:{lat:41.3891,long:2.1611}},{name:"brahma-world",endpoint:{protocol:"https:",host:"dns.brahma.world"},description:"DNS-over-HTTPS server. Non Logging, filters ads, trackers and malware. DNSSEC ready, QNAME Minimization, No EDNS Client-Subnet.\nHosted in Stockholm, Sweden. (https://dns.brahma.world)",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"cisco-doh",endpoint:{protocol:"https:",host:"doh.opendns.com",ipv4:"146.112.41.2"},description:"Remove your DNS blind spot (DoH protocol)\nWarning: modifies your queries to include a copy of your network\naddress when forwarding them to a selection of companies and organizations.",country:"United States",location:{lat:37.751,long:-97.822},filter:!0,log:!0},{name:"cloudflare",endpoint:{protocol:"https:",host:"dns.cloudflare.com",ipv4:"1.0.0.1",cors:!0},description:"Cloudflare DNS (anycast) - aka 1.1.1.1 / 1.0.0.1",country:"Australia",location:{lat:-33.494,long:143.2104},cors:!0},{name:"cloudflare-family",endpoint:{protocol:"https:",host:"family.cloudflare-dns.com",ipv4:"1.0.0.3",cors:!0},description:"Cloudflare DNS (anycast) with malware protection and parental control - aka 1.1.1.3 / 1.0.0.3",country:"Australia",location:{lat:-33.494,long:143.2104},filter:!0,cors:!0},{name:"cloudflare-ipv6",endpoint:{protocol:"https:",host:"1dot1dot1dot1.cloudflare-dns.com",cors:!0},description:"Cloudflare DNS over IPv6 (anycast)",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"cloudflare-security",endpoint:{protocol:"https:",host:"security.cloudflare-dns.com",ipv4:"1.0.0.2",cors:!0},description:"Cloudflare DNS (anycast) with malware blocking - aka 1.1.1.2 / 1.0.0.2",country:"Australia",location:{lat:-33.494,long:143.2104},filter:!0,cors:!0},{name:"controld-block-malware",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p1"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-block-malware-ad",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p2"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-block-malware-ad-social",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p3"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking and Social Networks domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-family-friendly",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/family"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS blocks Malware, Ads & Tracking, Adult Content and Drugs domains.",country:"Canada",location:{lat:43.6319,long:-79.3716},filter:!0},{name:"controld-uncensored",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/uncensored"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis DNS unblocks censored domains from various countries.",country:"Canada",location:{lat:43.6319,long:-79.3716}},{name:"controld-unfiltered",endpoint:{protocol:"https:",host:"freedns.controld.com",path:"/p0"},description:"ControlD Free DNS. Take CONTROL of your Internet. Block unwanted content, bypass geo-restrictions and be more productive. DoH protocol and No logging. - https://controld.com/free-dns\nThis is a Unfiltered DNS, no DNS record blocking or manipulation here, if you want to block Malware, Ads & Tracking or Social Network domains, use the other ControlD DNS configs.",country:"Canada",location:{lat:43.6319,long:-79.3716}},{name:"dns.digitale-gesellschaft.ch",endpoint:{protocol:"https:",host:"dns.digitale-gesellschaft.ch"},description:"Public DoH resolver operated by the Digital Society (https://www.digitale-gesellschaft.ch).\nHosted in Zurich, Switzerland.\nNon-logging, non-filtering, supports DNSSEC.",country:"Switzerland",location:{lat:47.1449,long:8.1551}},{name:"dns.ryan-palmer",endpoint:{protocol:"https:",host:"dns1.ryan-palmer.com"},description:"Non-logging, non-filtering, DNSSEC DoH Server. Hosted in the UK.",country:"United Kingdom",location:{lat:51.5164,long:-.093}},{name:"dns.sb",endpoint:{protocol:"https:",host:"doh.sb",ipv4:"185.222.222.222",cors:!0},description:"DNSSEC-enabled DoH server by https://xtom.com/\nhttps://dns.sb/doh/",country:"Unknown",location:{lat:47,long:8},cors:!0},{name:"dns.therifleman.name",endpoint:{protocol:"https:",host:"dns.therifleman.name"},description:"DNS-over-HTTPS DNS forwarder from Mumbai, India. Blocks web and Android trackers and ads.\nIP addresses are not logged, but queries are logged for 24 hours for debugging.\nReport issues, send suggestions @ joker349 at protonmail.com.\nAlso supports DoT (for android) @ dns.therifleman.name and plain DNS @ 172.104.206.174",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"dnsforfamily-doh",endpoint:{protocol:"https:",host:"dns-doh.dnsforfamily.com"},description:"(DoH Protocol) (Now supports DNSSEC). Block adult websites, gambling websites, malwares and advertisements.\nIt also enforces safe search in: Google, YouTube, Bing, DuckDuckGo and Yandex.\nSocial websites like Facebook and Instagram are not blocked. No DNS queries are logged.\nAs of 26-May-2022 5.9 million websites are blocked and new websites are added to blacklist daily.\nCompletely free, no ads or any commercial motive. Operating for 4 years now.\nProvided by: https://dnsforfamily.com",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0},{name:"dnsforfamily-doh-no-safe-search",endpoint:{protocol:"https:",host:"dns-doh-no-safe-search.dnsforfamily.com"},description:"(DoH Protocol) (Now supports DNSSEC) Block adult websites, gambling websites, malwares and advertisements.\nUnlike other dnsforfamily servers, this one does not enforces safe search. So Google, YouTube, Bing, DuckDuckGo and Yandex are completely accessible without any restriction.\nSocial websites like Facebook and Instagram are not blocked. No DNS queries are logged.\nAs of 26-May-2022 5.9 million websites are blocked and new websites are added to blacklist daily.\nCompletely free, no ads or any commercial motive. Operating for 4 years now.\nWarning: This server is incompatible with anonymization.\nProvided by: https://dnsforfamily.com",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0},{name:"dnsforge.de",endpoint:{protocol:"https:",host:"dnsforge.de",cors:!0},description:"Public DoH resolver running with Pihole for Adblocking (https://dnsforge.de).\nNon-logging, AD-filtering, supports DNSSEC. Hosted in Germany.",country:"Germany",location:{lat:52.2998,long:9.447},filter:!0,cors:!0},{name:"dnshome-doh",endpoint:{protocol:"https:",host:"dns.dnshome.de"},description:"https://www.dnshome.de/ public resolver in Germany"},{name:"dnspod-doh",endpoint:{protocol:"https:",host:"doh.pub",cors:!0},description:"A public DNS resolver in mainland China provided by DNSPod (Tencent Cloud).\nhttps://www.dnspod.cn/Products/Public.DNS?lang=en",filter:!0,log:!0,cors:!0},{name:"dnswarden-asia-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/adblock"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"dnswarden-asia-adultfilter-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/adultfilter"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"dnswarden-asia-uncensor-dohv4",endpoint:{protocol:"https:",host:"doh.asia.dnswarden.com",path:"/uncensored"},description:"Hosted in Singapore. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Singapore",location:{lat:1.2929,long:103.8547}},{name:"dnswarden-eu-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.eu.dnswarden.com"},description:"Hosted in Germany. For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"Germany",location:{lat:50.1103,long:8.7147},filter:!0},{name:"dnswarden-us-adblock-dohv4",endpoint:{protocol:"https:",host:"doh.us.dnswarden.com"},description:"Hosted in USA (Dallas) . For more information look [here](https://github.com/bhanupratapys/dnswarden) or [here](https://dnswarden.com).",country:"United States",location:{lat:32.7889,long:-96.8021},filter:!0},{name:"doh-ch-blahdns",endpoint:{protocol:"https:",host:"doh-ch.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Switzerland. By https://blahdns.com/",country:"Netherlands",location:{lat:52.3824,long:4.8995},filter:!0,cors:!0},{name:"doh-cleanbrowsing-adult",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/adult-filter/",cors:!0},description:"Blocks access to all adult, pornographic and explicit sites. It does\nnot block proxy or VPNs, nor mixed-content sites. Sites like Reddit\nare allowed. Google and Bing are set to the Safe Mode.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-cleanbrowsing-family",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/family-filter/",cors:!0},description:"Blocks access to all adult, pornographic and explicit sites. It also\nblocks proxy and VPN domains that are used to bypass the filters.\nMixed content sites (like Reddit) are also blocked. Google, Bing and\nYoutube are set to the Safe Mode.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-cleanbrowsing-security",endpoint:{protocol:"https:",host:"doh.cleanbrowsing.org",path:"/doh/security-filter/",cors:!0},description:"Block access to phishing, malware and malicious domains. It does not block adult content.\nBy https://cleanbrowsing.org/",filter:!0,cors:!0},{name:"doh-crypto-sx",endpoint:{protocol:"https:",host:"doh.crypto.sx",cors:!0},description:"DNS-over-HTTPS server. Anycast, no logs, no censorship, DNSSEC.\nBackend hosted by Scaleway, globally cached via Cloudflare.\nMaintained by Frank Denis.",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"doh-crypto-sx-ipv6",endpoint:{protocol:"https:",host:"doh-ipv6.crypto.sx",cors:!0},description:"DNS-over-HTTPS server accessible over IPv6. Anycast, no logs, no censorship, DNSSEC.\nBackend hosted by Scaleway, globally cached via Cloudflare.\nMaintained by Frank Denis.",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"doh-de-blahdns",endpoint:{protocol:"https:",host:"doh-de.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Germany. By https://blahdns.com/",country:"Germany",location:{lat:51.2993,long:9.491},filter:!0,cors:!0},{name:"doh-fi-blahdns",endpoint:{protocol:"https:",host:"doh-fi.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Finland. By https://blahdns.com/",country:"Finland",location:{lat:60.1758,long:24.9349},filter:!0,cors:!0},{name:"doh-ibksturm",endpoint:{protocol:"https:",host:"ibksturm.synology.me"},description:"DoH & DoT Server, No Logging, No Filters, DNSSEC\nRunning privately by ibksturm in Thurgau, Switzerland"},{name:"doh-jp-blahdns",endpoint:{protocol:"https:",host:"doh-jp.blahdns.com",cors:!0},description:"Blocks ad and Tracking, no Logging, DNSSEC, Hosted in Japan. By https://blahdns.com/",country:"Japan",location:{lat:35.6882,long:139.7532},filter:!0,cors:!0},{name:"doh.ffmuc.net",endpoint:{protocol:"https:",host:"doh.ffmuc.net"},description:"An open (non-logging, non-filtering, non-censoring) DoH resolver operated by Freifunk Munich with nodes in DE.\nhttps://ffmuc.net/",country:"Germany",location:{lat:51.2993,long:9.491}},{name:"doh.tiarap.org",endpoint:{protocol:"https:",host:"doh.tiarap.org"},description:"Non-Logging DNS-over-HTTPS server, cached via Cloudflare.\nFilters out ads, trackers and malware, NO ECS, supports DNSSEC.",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"google",endpoint:{protocol:"https:",host:"dns.google",ipv4:"8.8.8.8",cors:!0},description:"Google DNS (anycast)",country:"United States",location:{lat:37.751,long:-97.822},log:!0,cors:!0},{name:"hdns",endpoint:{protocol:"https:",host:"query.hdns.io",cors:!0},description:"HDNS is a public DNS resolver that supports Handshake domains.\nhttps://www.hdns.io",country:"United States",location:{lat:37.7771,long:-122.406},cors:!0},{name:"he",endpoint:{protocol:"https:",host:"ordns.he.net"},description:"Hurricane Electric DoH server (anycast)\nUnknown logging policy.",country:"United States",location:{lat:37.751,long:-97.822},log:!0},{name:"id-gmail-doh",endpoint:{protocol:"https:",host:"doh.tiar.app"},description:"Non-Logging DNS-over-HTTPS server located in Singapore.\nFilters out ads, trackers and malware, supports DNSSEC, provided by id-gmail.",country:"Singapore",location:{lat:1.2929,long:103.8547},filter:!0},{name:"iij",endpoint:{protocol:"https:",host:"public.dns.iij.jp"},description:"DoH server operated by Internet Initiative Japan in Tokyo.\nhttps://www.iij.ad.jp/",country:"Japan",location:{lat:35.69,long:139.69},log:!0},{name:"iqdns-doh",endpoint:{protocol:"https:",host:"a.passcloud.xyz"},description:'Non-logging DoH service runned by V2EX.com user johnsonwil.\nReturns "no such domain" for anti-Chinese government websites. Supports DNSSEC.\nFor more information: https://www.v2ex.com/t/785666',filter:!0},{name:"jp.tiar.app-doh",endpoint:{protocol:"https:",host:"jp.tiar.app"},description:"Non-Logging, Non-Filtering DNS-over-HTTPS server in Japan.\nNo ECS, Support DNSSEC",country:"Japan",location:{lat:35.6882,long:139.7532}},{name:"jp.tiarap.org",endpoint:{protocol:"https:",host:"jp.tiarap.org"},description:"DNS-over-HTTPS Server. Non-Logging, Non-Filtering, No ECS, Support DNSSEC.\nCached via Cloudflare."},{name:"libredns",endpoint:{protocol:"https:",host:"doh.libredns.gr"},description:"DoH server in Germany. No logging, but no DNS padding and no DNSSEC support.\nhttps://libredns.gr/",country:"Germany",location:{lat:51.2993,long:9.491}},{name:"nextdns",endpoint:{protocol:"https:",host:"anycsast.dns.nextdns.io"},description:"NextDNS is a cloud-based private DNS service that gives you full control\nover what is allowed and what is blocked on the Internet.\nDNSSEC, Anycast, Non-logging, NoFilters\nhttps://www.nextdns.io/",country:"Netherlands",location:{lat:52.3891,long:4.6563}},{name:"nextdns-ultralow",endpoint:{protocol:"https:",host:"dns.nextdns.io",path:"/dnscrypt-proxy"},description:'NextDNS is a cloud-based private DNS service that gives you full control\nover what is allowed and what is blocked on the Internet.\nhttps://www.nextdns.io/\nTo select the server location, the "-ultralow" variant relies on bootstrap servers\ninstead of anycast.'},{name:"njalla-doh",endpoint:{protocol:"https:",host:"dns.njal.la",cors:!0},description:"Non-logging DoH server in Sweden operated by Njalla.\nhttps://dns.njal.la/",country:"Sweden",location:{lat:59.3247,long:18.056},cors:!0},{name:"odoh-cloudflare",endpoint:{protocol:"https:",host:"odoh.cloudflare-dns.com",cors:!0},description:"Cloudflare ODoH server.\nhttps://cloudflare.com",cors:!0},{name:"odoh-crypto-sx",endpoint:{protocol:"https:",host:"odoh.crypto.sx",cors:!0},description:"ODoH target server. Anycast, no logs.\nBackend hosted by Scaleway. Maintained by Frank Denis.",cors:!0},{name:"odoh-id-gmail",endpoint:{protocol:"https:",host:"doh.tiar.app",path:"/odoh"},description:"ODoH target server. Based in Singapore, no logs.\nFilter ads, trackers and malware.",filter:!0},{name:"odoh-jp.tiar.app",endpoint:{protocol:"https:",host:"jp.tiar.app",path:"/odoh"},description:"ODoH target server. no logs."},{name:"odoh-jp.tiarap.org",endpoint:{protocol:"https:",host:"jp.tiarap.org",path:"/odoh"},description:"ODoH target server via Cloudflare, no logs."},{name:"odoh-resolver4.dns.openinternet.io",endpoint:{protocol:"https:",host:"resolver4.dns.openinternet.io"},description:"ODoH target server. no logs, no filter, DNSSEC.\nRunning on dedicated hardware colocated at Sonic.net in Santa Rosa, CA in the United States.\nUses Sonic's recusrive DNS servers as upstream resolvers (but is not affiliated with Sonic\nin any way). Provided by https://openinternet.io"},{name:"odoh-tiarap.org",endpoint:{protocol:"https:",host:"doh.tiarap.org",path:"/odoh"},description:"ODoH target server via Cloudflare, no logs.\nFilter ads, trackers and malware.",filter:!0},{name:"publicarray-au2-doh",endpoint:{protocol:"https:",host:"doh-2.seby.io",cors:!0},description:"DNSSEC \u2022 OpenNIC \u2022 Non-logging \u2022 Uncensored - hosted on ovh.com.au\nMaintained by publicarray - https://dns.seby.io",country:"Australia",location:{lat:-33.8591,long:151.2002},cors:!0},{name:"puredns-doh",endpoint:{protocol:"https:",host:"puredns.org",ipv4:"146.190.6.13",cors:!0},description:"Public uncensored DNS resolver in Singapore - https://puredns.org\n** Only available in Indonesia and Singapore **",country:"United States",location:{lat:37.751,long:-97.822},cors:!0},{name:"quad101",endpoint:{protocol:"https:",host:"dns.twnic.tw",cors:!0},description:"DNSSEC-aware public resolver by the Taiwan Network Information Center (TWNIC)\nhttps://101.101.101.101/index_en.html",cors:!0},{name:"quad9-doh-ip4-port443-filter-ecs-pri",endpoint:{protocol:"https:",host:"dns11.quad9.net",ipv4:"149.112.112.11"},description:"Quad9 (anycast) dnssec/no-log/filter/ecs 9.9.9.11 - 149.112.112.11",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"quad9-doh-ip4-port443-filter-pri",endpoint:{protocol:"https:",host:"dns.quad9.net",ipv4:"149.112.112.112"},description:"Quad9 (anycast) dnssec/no-log/filter 9.9.9.9 - 149.112.112.9 - 149.112.112.112",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"quad9-doh-ip4-port443-nofilter-ecs-pri",endpoint:{protocol:"https:",host:"dns12.quad9.net",ipv4:"9.9.9.12"},description:"Quad9 (anycast) no-dnssec/no-log/no-filter/ecs 9.9.9.12 - 149.112.112.12",country:"United States",location:{lat:37.751,long:-97.822}},{name:"quad9-doh-ip4-port443-nofilter-pri",endpoint:{protocol:"https:",host:"dns10.quad9.net",ipv4:"149.112.112.10"},description:"Quad9 (anycast) no-dnssec/no-log/no-filter 9.9.9.10 - 149.112.112.10",country:"United States",location:{lat:37.751,long:-97.822}},{name:"quad9-doh-ip6-port5053-filter-pri",endpoint:{protocol:"https:",host:"dns9.quad9.net"},description:"Quad9 (anycast) dnssec/no-log/filter 2620:fe::fe - 2620:fe::9 - 2620:fe::fe:9",country:"United States",location:{lat:37.751,long:-97.822},filter:!0},{name:"safesurfer-doh",endpoint:{protocol:"https:",host:"doh.safesurfer.io"},description:"Family safety focused blocklist for over 2 million adult sites, as well as phishing and malware and more.\nFree to use, paid for customizing blocking for more categories+sites and viewing usage at my.safesurfer.io. Logs taken for viewing\nusage, data never sold - https://safesurfer.io",filter:!0,log:!0},{name:"sth-ads-doh-se",endpoint:{protocol:"https:",host:"dnsse-noads.alekberg.net"},description:"Resolver in Stockholm, Sweden. DoH server. Non-logging, remove ads and malware, DNSSEC.",country:"Bulgaria",location:{lat:42.696,long:23.332},filter:!0},{name:"sth-doh-se",endpoint:{protocol:"https:",host:"dnsse.alekberg.net"},description:"Resolver in Stockholm, Sweden. DoH server. Non-logging, non-filtering, DNSSEC.",country:"Bulgaria",location:{lat:42.696,long:23.332}},{name:"switch",endpoint:{protocol:"https:",host:"dns.switch.ch"},description:"Public DoH service provided by SWITCH in Switzerland\nhttps://www.switch.ch\nProvides protection against malware, but does not block ads.",filter:!0},{name:"uncensoreddns-dk-ipv4",endpoint:{protocol:"https:",host:"unicast.uncensoreddns.org"},description:"Also known as censurfridns.\nDoH, no logs, no filter, DNSSEC, unicast hosted in Denmark - https://blog.uncensoreddns.org",country:"Denmark",location:{lat:55.7123,long:12.0564}},{name:"uncensoreddns-ipv4",endpoint:{protocol:"https:",host:"anycast.uncensoreddns.org"},description:"Also known as censurfridns.\nDoH, no logs, no filter, DNSSEC, anycast - https://blog.uncensoreddns.org",country:"Denmark",location:{lat:55.7123,long:12.0564}},{name:"v.dnscrypt.uk-doh-ipv4",endpoint:{protocol:"https:",host:"v.dnscrypt.uk"},description:"DoH, no logs, uncensored, DNSSEC. Hosted in London UK on Digital Ocean\nhttps://www.dnscrypt.uk",country:"United Kingdom",location:{lat:51.4964,long:-.1224}}],time:1654187067783});function Fhe(e,t,r,n){return n&&n.aborted?Promise.reject(new ghe):"udp4:"===e.protocol||"udp6:"===e.protocol?function(){throw new Error('Only "doh" endpoints are supported in the browser')}():function(e,t,r,n){return function(e,t,r,n,i){return Ohe(e,t,r,n,i)}(e.url,e.method,ahe(Object.assign({flags:rhe},t)),r,n).then((function(e){const t=e.data,r=e.response;let n=e.error;if(void 0===n)if(0===t.length)n=new mhe("Empty.");else try{const e=che(t);return e.response=r,e}catch(i){n=new mhe("Invalid packet (cause="+i.message+")",i)}throw Object.assign(n,{response:r})}))}(e,t,r,n)}const Vhe=new bhe("https://martinheidegger.github.io/dns-query/resolvers.json");function zhe(e){return/^@/.test(e)}const $he=new class{constructor(e){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:Vhe,persist:!1,localStoragePrefix:"dnsquery_",maxAge:3e5},e),this._dataP=null}_data(e,t){return e||null===this._dataP?(this._dataP=this.opts.update?async function(e,t,r,n){const i=t?t.localStoragePrefix+t.name:null;if(i)try{const e=JSON.parse(localStorage.getItem(i));if(e&&e.time>t.maxTime)return e}catch(a){}const{data:s}=await Ohe(e,"GET",null,r,n),o={time:Date.now(),data:JSON.parse(fle(s))};if(i)try{localStorage.setItem(i,JSON.stringify(o))}catch(a){o.time=null}return o}(this.opts.updateURL,this.opts.persist?{name:"resolvers.json",localStoragePrefix:this.opts.localStoragePrefix,maxTime:Date.now()-this.opts.maxAge}:null,this.opts.timeout).then((e=>qhe({data:e.data.resolvers,time:e.time}))).catch((()=>t||Khe)):Promise.resolve(Khe),this._dataP):this._dataP.then((e=>e.time<Date.now()-this.opts.maxAge?this._data(!0,e):e))}data(){return this._data(!1).then((e=>e.data))}endpoints(e){if(null===e||void 0===e)return this.data().then((e=>e.endpoints));if("doh"===e&&(e=Ghe),"dns"===e&&(e=Whe),"function"===typeof e)return this.data().then((t=>t.endpoints.filter(e)));if("string"===typeof e||"function"!==typeof e[Symbol.iterator])return Promise.reject(new Error(`Endpoints (${e}) needs to be iterable (array).`));if(-1===(e=Array.from(e).filter(Boolean)).findIndex(zhe))try{return Promise.resolve(e.map(Uhe))}catch(t){return Promise.reject(t)}return this.data().then((t=>e.map((e=>{if(zhe(e)){const r=t.endpointByName[e.substring(1)];if(!r)throw new Error(`Endpoint ${e} is not known.`);return r}return Uhe(e)}))))}};function Hhe(e,t){return t=Object.assign({retries:5,timeout:3e4},t),e.question?(r=t.endpoints,function(e){return null!==e&&"object"===typeof e&&"function"===typeof e.then}(r)?r:Promise.resolve(r)).then((r=>{if(!Array.isArray(r)||0===r.length)throw new Error("No endpoints defined to lookup dns records.");return jhe(r.map(Uhe),function(e){const t=Object.assign({type:"query"},e);return delete t.question,t.questions=[],e.question&&t.questions.push(e.question),t}(e),t)})).then((e=>(e.question=e.questions[0],delete e.questions,e))):Promise.reject(new Error("To request data you need to specify a .question!"));var r}function jhe(e,t,r){const n=1===e.length?e[0]:e[Math.floor(Math.random()*e.length)%e.length];return Fhe(n,t,r.timeout,r.signal).then((e=>(e.endpoint=n.toString(),e)),(i=>{if("AbortError"===i.name||0===r.retries)throw i.endpoint=n.toString(),i;return r.retries>0&&(r.retries-=1),jhe(e,t,r)}))}function Ghe(e){return"https:"===e.protocol||"http:"===e.protocol}function Whe(e){return"udp4:"===e.protocol||"udp6:"===e.protocol}const Yhe=new Ll("dns-over-https");class Qhe{endpoints;retries;static async create(e,t){const r=e??await $he.endpoints("doh");return new Qhe(r,t)}constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3;this.endpoints=e,this.retries=t}async resolveTXT(e){let t;try{t=(await Hhe({question:{type:"TXT",name:e}},{endpoints:this.endpoints,retries:this.retries})).answers}catch(i){throw Yhe.error("query failed: ",i),new Error("DNS query failed")}if(!t)throw new Error(`Could not resolve ${e}`);const r=t.map((e=>e.data)),n=[];return r.forEach((e=>{"string"===typeof e?n.push(e):Array.isArray(e)?e.forEach((e=>{"string"===typeof e?n.push(e):n.push(_l(e))})):n.push(_l(e))})),n}}var Jhe=__webpack_require__(5411);new Uint8Array(0);function Xhe(e){if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}var Zhe=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(255!==r[o])throw new TypeError(s+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),u=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function h(e){if("string"!==typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var n=0,i=0;e[t]===c;)n++,t++;for(var s=(e.length-t)*u+1>>>0,o=new Uint8Array(s);e[t];){var l=r[e.charCodeAt(t)];if(255===l)return;for(var h=0,d=s-1;(0!==l||h<i)&&-1!==d;d--,h++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=h,t++}if(" "!==e[t]){for(var f=s-i;f!==s&&0===o[f];)f++;for(var p=new Uint8Array(n+(s-f)),g=n;f!==s;)p[g++]=o[f++];return p}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,n=0,i=0,s=t.length;i!==s&&0===t[i];)i++,r++;for(var o=(s-i)*l+1>>>0,u=new Uint8Array(o);i!==s;){for(var h=t[i],d=0,f=o-1;(0!==h||d<n)&&-1!==f;f--,d++)h+=256*u[f]>>>0,u[f]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");n=d,i++}for(var p=o-n;p!==o&&0===u[p];)p++;for(var g=c.repeat(r);p<o;++p)g+=e.charAt(u[p]);return g},decodeUnsafe:h,decode:function(e){var r=h(e);if(r)return r;throw new Error(`Non-${t} character`)}}};const ede=Zhe;class tde{name;prefix;baseEncode;constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class rde{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"===typeof e){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))}throw Error("Can only multibase decode strings")}or(e){return ide(this,e)}}class nde{decoders;constructor(e){this.decoders=e}or(e){return ide(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(null!=r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function ide(e,t){return new nde({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class sde{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,r,n){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=n,this.encoder=new tde(e,t,r),this.decoder=new rde(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function ode(e){let{name:t,prefix:r,encode:n,decode:i}=e;return new sde(t,r,n,i)}function ade(e){let{name:t,prefix:r,alphabet:n}=e;const{encode:i,decode:s}=ede(n,t);return ode({prefix:r,name:t,encode:i,decode:e=>Xhe(s(e))})}function cde(e){let{name:t,prefix:r,bitsPerChar:n,alphabet:i}=e;return ode({prefix:r,name:t,encode:e=>function(e,t,r){const n="="===t[t.length-1],i=(1<<r)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(0!==o&&(s+=t[i&a<<r-o]),n)for(;0!==(s.length*r&7);)s+="=";return s}(e,i,n),decode:e=>function(e,t,r,n){const i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*r/8|0);let a=0,c=0,u=0;for(let l=0;l<s;++l){const t=i[e[l]];if(void 0===t)throw new SyntaxError(`Non-${n} character`);c=c<<r|t,a+=r,a>=8&&(a-=8,o[u++]=255&c>>a)}if(a>=r||0!==(255&c<<8-a))throw new SyntaxError("Unexpected end of data");return o}(e,i,n,t)})}const ude=ade({prefix:"9",name:"base10",alphabet:"0123456789"}),lde=cde({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),hde=cde({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),dde=cde({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),fde=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),pde=fde.reduce(((e,t,r)=>(e[r]=t,e)),[]),gde=fde.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const bde=ode({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=pde[t]),"")},decode:function(e){const t=[];for(const r of e){const e=gde[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}}),yde=cde({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),mde=cde({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),wde=cde({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vde=cde({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_de=cde({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ede=cde({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Sde=cde({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ade=cde({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),kde=cde({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),xde=ade({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ide=ade({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Cde=ade({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Tde=ade({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Rde=cde({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Pde=cde({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Dde=cde({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Nde=cde({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Bde=cde({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Ude=ode({prefix:"\0",name:"identity",encode:e=>{return t=e,(new TextDecoder).decode(t);var t},decode:e=>function(e){return(new TextEncoder).encode(e)}(e)}),Lde=new TextEncoder,Mde=new TextDecoder,Ode="json",qde=512;function Kde(e){return Lde.encode(JSON.stringify(e))}function Fde(e){return JSON.parse(Mde.decode(e))}const Vde="raw",zde=85;function $de(e){return Xhe(e)}function Hde(e){return Xhe(e)}var jde=function e(t,r,n){r=r||[];var i=n=n||0;for(;t>=Yde;)r[n++]=255&t|Gde,t/=128;for(;t&Wde;)r[n++]=255&t|Gde,t>>>=7;return r[n]=0|t,e.bytes=n-i+1,r},Gde=128,Wde=-128,Yde=Math.pow(2,31);var Qde=function e(t,r){var n,i=0,s=0,o=r=r||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");n=t[o++],i+=s<28?(n&Xde)<<s:(n&Xde)*Math.pow(2,s),s+=7}while(n>=Jde);return e.bytes=o-r,i},Jde=128,Xde=127;var Zde=Math.pow(2,7),efe=Math.pow(2,14),tfe=Math.pow(2,21),rfe=Math.pow(2,28),nfe=Math.pow(2,35),ife=Math.pow(2,42),sfe=Math.pow(2,49),ofe=Math.pow(2,56),afe=Math.pow(2,63);const cfe={encode:jde,decode:Qde,encodingLength:function(e){return e<Zde?1:e<efe?2:e<tfe?3:e<rfe?4:e<nfe?5:e<ife?6:e<sfe?7:e<ofe?8:e<afe?9:10}};function ufe(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return cfe.encode(e,t,r),t}function lfe(e){return cfe.encodingLength(e)}function hfe(e,t){const r=t.byteLength,n=lfe(e),i=n+lfe(r),s=new Uint8Array(i+r);return ufe(e,s,0),ufe(r,s,n),s.set(t,i),new dfe(e,r,t,s)}class dfe{code;size;digest;bytes;constructor(e,t,r,n){this.code=e,this.size=t,this.digest=r,this.bytes=n}}const ffe=Xhe;const pfe={code:0,name:"identity",encode:ffe,digest:function(e){return hfe(0,ffe(e))}};function gfe(e){let{name:t,code:r,encode:n}=e;return new bfe(t,r,n)}class bfe{name;code;encode;constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?hfe(this.code,t):t.then((e=>hfe(this.code,e)))}throw Error("Unknown type, must be binary type")}}function yfe(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const mfe=gfe({name:"sha2-256",code:18,encode:yfe("SHA-256")}),wfe=gfe({name:"sha2-512",code:19,encode:yfe("SHA-512")});new WeakMap;Symbol.toStringTag,Symbol.for("nodejs.util.inspect.custom");Symbol.for("@ipld/js-cid/CID");const vfe={...Zi,...ji,...Xi,...$i,...Hi,...Wi,...Yi,...Qi,...Ji,...Gi};function _fe(e,t,r,n){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}const Efe=_fe("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Sfe=_fe("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),Afe={utf8:Efe,"utf-8":Efe,hex:vfe.base16,latin1:Sfe,ascii:Sfe,binary:Sfe,...vfe};class kfe{static RECORD_PREFIX=_ue.RECORD_PREFIX;static TREE_PREFIX="enrtree:";static BRANCH_PREFIX="enrtree-branch:";static ROOT_PREFIX="enrtree-root:";static parseAndVerifyRoot(e,t){if(!e.startsWith(this.ROOT_PREFIX))throw new Error(`ENRTree root entry must start with '${this.ROOT_PREFIX}'`);const r=kfe.parseRootValues(e),n=Jhe.decode.asBytes(t),i=e.split(" sig")[0],s=El(i),o=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=Afe[t];if(null==r)throw new Error(`Unsupported encoding "${t}"`);return r.decoder.decode(`${r.prefix}${e}`)}(r.signature,"base64url").slice(0,64);if(!Fse(o,Kse(s),new Uint8Array(n)))throw new Error("Unable to verify ENRTree root signature");return r.eRoot}static parseRootValues(e){const t=e.match(/^enrtree-root:v1 e=([^ ]+) l=([^ ]+) seq=(\d+) sig=([^ ]+)$/);if(!Array.isArray(t))throw new Error("Could not parse ENRTree root entry");t.shift();const[r,n,i,s]=t;if(!r)throw new Error("Could not parse 'e' value from ENRTree root entry");if(!n)throw new Error("Could not parse 'l' value from ENRTree root entry");if(!i)throw new Error("Could not parse 'seq' value from ENRTree root entry");if(!s)throw new Error("Could not parse 'sig' value from ENRTree root entry");return{eRoot:r,lRoot:n,seq:Number(i),signature:s}}static parseTree(e){if(!e.startsWith(this.TREE_PREFIX))throw new Error(`ENRTree tree entry must start with '${this.TREE_PREFIX}'`);const t=e.match(/^enrtree:\/\/([^@]+)@(.+)$/);if(!Array.isArray(t))throw new Error("Could not parse ENRTree tree entry");t.shift();const[r,n]=t;if(!r)throw new Error("Could not parse public key from ENRTree tree entry");if(!n)throw new Error("Could not parse domain from ENRTree tree entry");return{publicKey:r,domain:n}}static parseBranch(e){if(!e.startsWith(this.BRANCH_PREFIX))throw new Error(`ENRTree branch entry must start with '${this.BRANCH_PREFIX}'`);return e.split(this.BRANCH_PREFIX)[1].split(",")}}const xfe=new Ll("discovery:fetch_nodes");function Ife(e,t){return t.relay>=e.relay&&t.store>=e.store&&t.filter>=e.filter&&t.lightPush>=e.lightPush}function Cfe(e,t){if(!e.nodeId)return!1;for(const r of t)if(e.nodeId===r.nodeId)return!1;return!0}function Tfe(e,t){e.relay&&(t.relay+=1),e.store&&(t.store+=1),e.filter&&(t.filter+=1),e.lightPush&&(t.lightPush+=1)}function Rfe(e,t,r){if(Ife(t,r))throw"Internal Error: Waku2 wanted capabilities are already fulfilled";const n=function(e,t){return{relay:t.relay<e.relay,store:t.store<e.store,filter:t.filter<e.filter,lightPush:t.lightPush<e.lightPush}}(t,r);return n.relay&&e.relay||n.store&&e.store||n.filter&&e.filter||n.lightPush&&e.lightPush}const Pfe=new Ll("discovery:dns");class Dfe{dns;_DNSTreeCache;_errorTolerance=10;static async dnsOverHttp(e){return e||(e=await Qhe.create()),new Dfe(e)}async getPeers(e,t){const r=Math.floor(Math.random()*e.length),{publicKey:n,domain:i}=kfe.parseTree(e[r]),s={domain:i,publicKey:n,visits:{}},o=await async function(e,t,r){const n={relay:e.relay??0,store:e.store??0,filter:e.filter??0,lightPush:e.lightPush??0},i=n.relay+n.store+n.filter+n.lightPush,s={relay:0,store:0,filter:0,lightPush:0};let o=0;const a=[];for(;!Ife(n,s)&&o<i+t;){const e=await r();e&&Cfe(e,a)&&(e.waku2&&Rfe(e.waku2,n,s)&&(Tfe(e.waku2,s),a.push(e)),xfe.info(`got new peer candidate from DNS address=${e.nodeId}@${e.ip}`)),o++}return a}(t,this._errorTolerance,(()=>this._search(i,s)));return Pfe.info("retrieved peers: ",o.map((e=>({id:e.peerId?.toString(),multiaddrs:e.multiaddrs?.map((e=>e.toString()))})))),o}constructor(e){this._DNSTreeCache={},this.dns=e}async*getNextPeer(e,t){const r=Math.floor(Math.random()*e.length),{publicKey:n,domain:i}=kfe.parseTree(e[r]),s={domain:i,publicKey:n,visits:{}};for await(const o of async function*(e,t,r){const n={relay:e.relay??0,store:e.store??0,filter:e.filter??0,lightPush:e.lightPush??0},i=n.relay+n.store+n.filter+n.lightPush,s={relay:0,store:0,filter:0,lightPush:0};let o=0;const a=new Set;for(;!Ife(n,s)&&o<i+t;){const e=await r();e&&e.nodeId&&!a.has(e.nodeId)&&(a.add(e.nodeId),e.waku2&&Rfe(e.waku2,n,s)&&(Tfe(e.waku2,s),yield e),xfe.info(`got new peer candidate from DNS address=${e.nodeId}@${e.ip}`)),o++}}(t,this._errorTolerance,(()=>this._search(i,s))))yield o}async _search(e,t){try{const n=await this._getTXTRecord(e,t);let i,s;t.visits[e]=!0;const o=function(e){return e.startsWith(kfe.ROOT_PREFIX)?kfe.ROOT_PREFIX:e.startsWith(kfe.BRANCH_PREFIX)?kfe.BRANCH_PREFIX:e.startsWith(kfe.RECORD_PREFIX)?kfe.RECORD_PREFIX:""}(n);try{switch(o){case kfe.ROOT_PREFIX:return i=kfe.parseAndVerifyRoot(n,t.publicKey),await this._search(i,t);case kfe.BRANCH_PREFIX:return s=kfe.parseBranch(n),i=function(e,t){const r={};for(const[i,s]of e.entries())t.visits[s]&&(r[i]=!0);if(Object.keys(r).length===e.length)throw new Error("Unresolvable circular path detected");let n;do{n=Math.floor(Math.random()*e.length)}while(r[n]);return e[n]}(s,t),await this._search(i,t);case kfe.RECORD_PREFIX:return Que.fromString(n);default:return null}}catch(r){return Pfe.error(`Failed to search DNS tree ${o} at subdomain ${e}: ${r}`),null}}catch(r){return Pfe.error(`Failed to retrieve TXT record at subdomain ${e}: ${r}`),null}}async _getTXTRecord(e,t){if(this._DNSTreeCache[e])return this._DNSTreeCache[e];const r=e!==t.domain?`${e}.${t.domain}`:t.domain,n=await this.dns.resolveTXT(r);if(!n.length)throw new Error("Received empty result array while fetching TXT record");if(!n[0].length)throw new Error("Received empty TXT record");const i=n.join("");return this._DNSTreeCache[e]=i,i}}const Nfe=new Ll("peer-discovery-dns");class Bfe extends sd{nextPeer;_started;_components;_options;constructor(e,t){super(),this._started=!1,this._components=e,this._options=t;const{enrUrls:r}=t;Nfe.info("Use following EIP-1459 ENR Tree URLs: ",r)}async start(){if(Nfe.info("Starting peer discovery via dns"),this._started=!0,void 0===this.nextPeer){let{enrUrls:e}=this._options;Array.isArray(e)||(e=[e]);const{wantedNodeCapabilityCount:t}=this._options,r=await Dfe.dnsOverHttp();this.nextPeer=r.getNextPeer.bind(r,e,t)}for await(const e of this.nextPeer()){if(!this._started)return;const{peerInfo:t,shardInfo:r}=e;if(!t)continue;const n={[Pie]:{value:this._options.tagValue??50,ttl:this._options.tagTTL??1e8}};let i=!1;if(await this._components.peerStore.has(t.id)){(await this._components.peerStore.get(t.id)).tags.has(Pie)||(i=!0,await this._components.peerStore.merge(t.id,{tags:n}))}else i=!0,await this._components.peerStore.save(t.id,{tags:n,...r&&{metadata:{shardInfo:Nl(r)}}});i&&this.dispatchEvent(new ad("peer",{detail:t}))}}stop(){this._started=!1}get[d_](){return!0}get[Symbol.toStringTag](){return"@waku/bootstrap"}}function Ufe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Die;return r=>new Bfe(r,{enrUrls:e,wantedNodeCapabilityCount:t})}class Lfe{proto;constructor(e){this.proto=e}static createRequest(e){const{numPeers:t}=e;return new Lfe({query:{numPeers:t},response:void 0})}encode(){return tc.encode(this.proto)}static decode(e){const t=tc.decode(e);return new Lfe(t)}get query(){return this.proto.query}get response(){return this.proto.response}}const Mfe="/vac/waku/peer-exchange/2.0.0-alpha1",Ofe=new Ll("peer-exchange");class qfe extends _h{constructor(e,t){super(Mfe,e,Ofe,t)}async query(e){const{numPeers:t}=e,r=Lfe.createRequest({numPeers:BigInt(t)}),n=await this.peerStore.get(e.peerId);if(!n)return{peerInfos:null,error:Mc.NO_PEER_AVAILABLE};const i=await this.getStream(n),s=await ph([r.encode()],rh,i,oh,(async e=>await Hl(e)));try{const e=new Zl;s.forEach((t=>{e.append(t)}));const{response:t}=Lfe.decode(e);if(!t)return Ofe.error("PeerExchangeRPC message did not contains a `response` field"),{peerInfos:null,error:Mc.EMPTY_PAYLOAD};return{peerInfos:await Promise.all(t.peerInfos.map((e=>e.enr)).filter(ac).map((async e=>({ENR:await Que.fromRLP(e)})))),error:null}}catch(o){return Ofe.error("Failed to decode push reply",o),{peerInfos:null,error:Mc.DECODE_FAILED}}}}const Kfe=new Ll("peer-exchange-discovery"),Ffe=1e4,Vfe=3,zfe=qc.PEER_EXCHANGE;class $fe extends sd{components;peerExchange;options;isStarted;queryingPeers=new Set;queryAttempts=new Map;handleDiscoveredPeer=e=>{const{protocols:t,peerId:r}=e.detail;t.includes(Mfe)&&!this.queryingPeers.has(r.toString())&&(this.queryingPeers.add(r.toString()),this.startRecurringQueries(r).catch((e=>Kfe.error(`Error querying peer ${e}`))))};constructor(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),this.components=e,this.peerExchange=new qfe(e,t),this.options=r,this.isStarted=!1}start(){this.isStarted||(Kfe.info("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(Kfe.info("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[d_](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}startRecurringQueries=async e=>{const t=e.toString(),{queryInterval:r=Ffe,maxRetries:n=Vfe}=this.options;Kfe.info(`Querying peer: ${t} (attempt ${this.queryAttempts.get(t)??1})`),await this.query(e);const i=this.queryAttempts.get(t)??1;i>n?this.abortQueriesForPeer(t):setTimeout((()=>{this.queryAttempts.set(t,i+1),this.startRecurringQueries(e).catch((e=>{Kfe.error(`Error in startRecurringQueries: ${e}`)}))}),r*i)};async query(e){const{error:t,peerInfos:r}=await this.peerExchange.query({numPeers:10,peerId:e});if(t)return Kfe.error("Peer exchange query failed",t),{error:t,peerInfos:null};for(const n of r){const{ENR:e}=n;if(!e){Kfe.warn("No ENR in peerInfo object, skipping");continue}const{peerId:t,peerInfo:r,shardInfo:i}=e;if(!t||!r)continue;await this.components.peerStore.has(t)||(await this.components.peerStore.save(t,{tags:{[zfe]:{value:this.options.tagValue??50,ttl:this.options.tagTTL??1e8}},...i&&{metadata:{shardInfo:Nl(i)}}}),Kfe.info(`Discovered peer: ${t.toString()}`),this.dispatchEvent(new ad("peer",{detail:{id:t,multiaddrs:r.multiaddrs}})))}return{error:null,peerInfos:r}}abortQueriesForPeer(e){Kfe.info(`Aborting queries for peer: ${e}`),this.queryingPeers.delete(e),this.queryAttempts.delete(e)}}function Hfe(e){return t=>new $fe(t,e)}const jfe=new Ll("peer-exchange-discovery"),Gfe=qc.LOCAL;class Wfe extends sd{components;options;isStarted;peers=[];constructor(e,t){super(),this.components=e,this.options=t,this.isStarted=!1,this.peers=this.getPeersFromLocalStorage()}get[Symbol.toStringTag](){return"@waku/local-peer-cache-discovery"}async start(){if(!this.isStarted){jfe.info("Starting Local Storage Discovery"),this.components.events.addEventListener("peer:identify",this.handleNewPeers);for(const{id:e,address:t}of this.peers){const r=await W3({id:e});await this.components.peerStore.has(r)||(await this.components.peerStore.save(r,{multiaddrs:[tI(t)],tags:{[this.options?.tagName??Gfe]:{value:this.options?.tagValue??50,ttl:this.options?.tagTTL??1e8}}}),this.dispatchEvent(new ad("peer",{detail:{id:r,multiaddrs:[tI(t)]}})))}jfe.info(`Discovered ${this.peers.length} peers`),this.isStarted=!0}}stop(){this.isStarted&&(jfe.info("Stopping Local Storage Discovery"),this.components.events.removeEventListener("peer:identify",this.handleNewPeers),this.isStarted=!1,this.savePeersToLocalStorage())}handleNewPeers=e=>{const{peerId:t,listenAddrs:r}=e.detail,n=function(e){const t=e.find((e=>e.toString().includes("ws")||e.toString().includes("wss")));if(!t)throw new Error("No ws multiaddr found in the given addresses");return t}(r),i=this.getPeersFromLocalStorage(),s=i.findIndex((e=>e.id===t.toString()));s>=0?i[s].address=n.toString():i.push({id:t.toString(),address:n.toString()}),this.peers=i,this.savePeersToLocalStorage()};getPeersFromLocalStorage(){try{const e=localStorage.getItem("waku:peers");if(!e)return[];return JSON.parse(e).filter(Yfe)}catch(e){return jfe.error("Error parsing peers from local storage:",e),[]}}savePeersToLocalStorage(){localStorage.setItem("waku:peers",JSON.stringify(this.peers))}}function Yfe(e){return e&&"object"===typeof e&&"string"===typeof e.id&&"string"===typeof e.address}function Qfe(){return(e,t)=>new Wfe(e,t)}const Jfe={lightPush:1,filter:1,store:1};const Xfe=is.createContext({decoder:void 0,encoder:void 0}),Zfe=()=>is.useContext(Xfe),epe=e=>{const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const[r,n]=is.useState(Fl({contentTopic:e,ephemeral:t})),[i,s]=is.useState(zl(e));return is.useEffect((()=>{n(Fl({contentTopic:e,ephemeral:t})),s(zl(e))}),[e,t]),{encoder:r,decoder:i}}(e.contentTopic,e.ephemeral);return is.createElement(Xfe.Provider,{value:t},e.children)},tpe=e=>(e=>{const{factory:t,options:r,protocols:n=[]}=e,[i,s]=is.useState(void 0),[o,a]=is.useState(!0),[c,u]=is.useState(void 0);return is.useEffect((()=>{let e=!1;return a(!0),t(r).then((async t=>{e||(await t.start(),await td(t,n),s(t),a(!1))})).catch((e=>{a(!1),u(`Failed at creating node: ${(null===e||void 0===e?void 0:e.message)||"no message"}`)})),()=>{e=!0}}),[]),{node:i,error:c,isLoading:o}})({...e,factory:kie}),rpe=e=>{const{node:t,encoder:r}=e,n=is.useCallback((e=>t.lightPush.send(r,e)),[t,r]);return t||r?{push:n}:{}},npe=is.createContext({node:void 0,isLoading:!1,error:void 0}),ipe=()=>is.useContext(npe),spe=e=>{const t=tpe({options:e.options,protocols:e.protocols});return is.createElement(npe.Provider,{value:t},e.children)};async function ope(e,t,r){let n=[];const i=function(e){const t=e.trim().replaceAll(/\s\s+/g," ");return t.split(" ")}(e),s=i.shift();switch(s){case"/help":["/nick <nickname>: set a new nickname","/info: some information about the node","/connect <Multiaddr>: connect to the given peer","/help: Display this help"].map((e=>n.push(e)));break;case"/nick":(function(e,t){return e?(t(e),[`New nick: ${e}`]):["No nick provided"]})(i.shift(),r).map((e=>n.push(e)));break;case"/info":(function(e){return e?[`PeerId: ${e.libp2p.peerId.toString()}`]:["Waku node is starting"]})(t).map((e=>n.push(e)));break;case"/connect":(function(e,t){if(!t)return["Waku node is starting"];if(!e)return["No peer provided"];try{const r=tI(e),n=r.getPeerId();return n?(t.dial(r).catch((e=>console.error(`Failed to dial ${r}`,e))),[`${n}: ${r.toString()} added to address book, autodial in progress`]):["Peer Id needed to dial"]}catch(r){return["Invalid multiaddr: "+r]}})(i.shift(),t).map((e=>n.push(e)));break;case"/peers":(await async function(e){if(!e)return["Waku node is starting"];let t=[];const r=await e.libp2p.peerStore.all();return Array.from(r).forEach((e=>{t.push(e.id.toString()+":");let r=" addresses: [";e.addresses.forEach((e=>{let{multiaddr:t}=e;r+=" "+t.toString()+","})),r=r.replace(/,$/,""),r+="]",t.push(r);let n=" protocols: [";n+=e.protocols,n+="]",t.push(n)})),0===t.length&&t.push("Not connected to any peer."),t}(t)).map((e=>n.push(e)));break;case"/connections":(function(e){if(!e)return["Waku node is starting"];let t=[],r=" connections: \n";return e.libp2p.getConnections().forEach((e=>{r+=e.remotePeer.toString()+", ",r+=JSON.stringify({direction:e.direction,timeline:e.timeline,multiplexer:e.multiplexer,encryption:e.encryption,status:e.status}),r+="; "+JSON.stringify(e.streams),r+="\n"})),t.push(r),0===t.length&&t.push("Not connected to any peer."),t})(t).map((e=>n.push(e)));break;default:n.push(`Unknown Command '${s}'`)}return{command:s,response:n}}var ape=__webpack_require__(579);function cpe(e){const t=e.messages.array.map((e=>{var t;return(0,ape.jsxs)("div",{className:"flex flex-col p-2 border-b border-gray-200",children:[(0,ape.jsx)("span",{className:"text-sm text-gray-500",children:e.nick}),(0,ape.jsx)("span",{className:"text-sm text-gray-500",children:upe(e)}),(0,ape.jsx)("p",{className:"text-gray-700",children:e.payloadAsUtf8})]},e.nick+e.payloadAsUtf8+e.timestamp.valueOf()+(null===(t=e.sentTimestamp)||void 0===t?void 0:t.valueOf()))}));return(0,ape.jsxs)("div",{className:"overflow-y-auto h-full",children:[t,(0,ape.jsx)(lpe,{messages:e.messages.array})]})}function upe(e){return e.timestamp.toLocaleString([],{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!1})}const lpe=e=>{const t=(0,is.useRef)(null);return(0,is.useEffect)((()=>{t.current&&t.current.scrollIntoView()}),[e.messages]),(0,ape.jsx)("div",{ref:t})};function hpe(e){const{hasLightPushPeers:t}=e,{node:r}=ipe(),[n,i]=(0,is.useState)(""),[s,o]=(0,is.useState)(!1),a=async()=>{if(e.sendMessage&&n){try{await e.sendMessage(n)}catch(t){console.error(`Failed to send message: ${t}`)}i("")}};return(0,is.useEffect)((()=>{n.startsWith("/")||t?o(!0):r&&o(!1)}),[r,n,t]),(0,ape.jsxs)("div",{className:"flex p-2",children:[(0,ape.jsx)("input",{type:"text",value:n,onChange:e=>{e.preventDefault(),i(e.target.value)},onKeyDown:async e=>{!s||"Enter"!==e.key||e.altKey||e.ctrlKey||e.shiftKey||await a()},className:"flex-grow p-2 border border-gray-300 rounded-l-md",placeholder:"Type your message..."}),(0,ape.jsx)("button",{onClick:a,className:`flex-none px-4 py-2 text-white ${s?"bg-blue-500":"bg-blue-300 cursor-not-allowed"} rounded-r-md`,disabled:!s,children:"Send"})]})}var dpe=__webpack_require__(3338),fpe=__webpack_require__(7707),ppe=__webpack_require__(5850),gpe=__webpack_require__(3931);__webpack_require__(1509)._configure(),dpe._configure(fpe),ppe._configure(gpe);const bpe=["uint64","int64","sint64","fixed64","sfixed64"];function ype(e){return function(e){for(const t of bpe){if(null==e[t])continue;const r=e[t];e[t]=function(){return BigInt(r.call(this).toString())}}return e}(new dpe(e))}function mpe(){return function(e){for(const t of bpe){if(null==e[t])continue;const r=e[t];e[t]=function(e){return r.call(this,e.toString())}}return e}(ppe.create())}var wpe;let vpe;!function(e){e[e.VARINT=0]="VARINT",e[e.BIT64=1]="BIT64",e[e.LENGTH_DELIMITED=2]="LENGTH_DELIMITED",e[e.START_GROUP=3]="START_GROUP",e[e.END_GROUP=4]="END_GROUP",e[e.BIT32=5]="BIT32"}(wpe||(wpe={})),function(e){let t;e.codec=()=>(null==t&&(t=function(e,t){return function(e,t,r,n){return{name:e,type:t,encode:r,decode:n}}("message",wpe.LENGTH_DELIMITED,e,t)}((function(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&t.fork(),null==e.timestamp)throw new Error('Protocol error: required field "timestamp" was not found in object');if(t.uint32(8),t.uint64(e.timestamp),null==e.nick)throw new Error('Protocol error: required field "nick" was not found in object');if(t.uint32(18),t.string(e.nick),null==e.payload)throw new Error('Protocol error: required field "payload" was not found in object');t.uint32(26),t.bytes(e.payload),!1!==r.lengthDelimited&&t.ldelim()}),((e,t)=>{const r={timestamp:0n,nick:"",payload:new Uint8Array(0)},n=null==t?e.len:e.pos+t;for(;e.pos<n;){const t=e.uint32();switch(t>>>3){case 1:r.timestamp=e.uint64();break;case 2:r.nick=e.string();break;case 3:r.payload=e.bytes();break;default:e.skipType(7&t)}}if(null==r.timestamp)throw new Error('Protocol error: value for required field "timestamp" was not found in protobuf');if(null==r.nick)throw new Error('Protocol error: value for required field "nick" was not found in protobuf');if(null==r.payload)throw new Error('Protocol error: value for required field "payload" was not found in protobuf');return r}))),t),e.encode=e=>function(e,t){const r=mpe();return t.encode(e,r,{lengthDelimited:!1}),r.finish()}(e,vpe.codec()),e.decode=e=>function(e,t){const r=ype(e instanceof Uint8Array?e:e.subarray());return t.decode(r)}(e,vpe.codec())}(vpe||(vpe={}));class _pe{constructor(e){this.proto=e}static fromUtf8String(e,t,r){const n=BigInt(Math.floor(e.valueOf()/1e3)),i=El(r);return new _pe({timestamp:n,nick:t,payload:i})}static decode(e){const t=vpe.decode(e);return new _pe(t)}encode(){return vpe.encode(this.proto)}get timestamp(){return new Date(Number(BigInt(this.proto.timestamp)*BigInt(1e3)))}get nick(){return this.proto.nick}get payloadAsUtf8(){return this.proto.payload?_l(this.proto.payload):""}}var Epe=__webpack_require__(9233);class Spe{constructor(e,t){this.chatMessage=void 0,this.sentTimestamp=void 0,this.chatMessage=e,this.sentTimestamp=t}static cmp(e,t){return e.timestamp.getTime()<t.timestamp.getTime()}static isEqual(e,t){return e.timestamp.valueOf()===t.timestamp.valueOf()&&e.chatMessage.nick===t.chatMessage.nick&&e.chatMessage.payloadAsUtf8===t.chatMessage.payloadAsUtf8}static fromWakuMessage(e){if(e.payload)try{const t=_pe.decode(e.payload);if(t)return new Spe(t,e.timestamp)}catch(t){console.error("Failed to decode chat message",t)}}static fromUtf8String(e,t){const r=new Date;return new Spe(_pe.fromUtf8String(r,e,t),r)}get nick(){return this.chatMessage.nick}get timestamp(){return this.chatMessage.timestamp}get payloadAsUtf8(){return this.chatMessage.payloadAsUtf8}}class Ape{constructor(e,t){this.orderCmp=e,this.isEqual=t,this.array=void 0,this.array=[]}push(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(const n of t)this.insertInOrder(this.array,n)}insertInOrder(e,t){let r=0;for(;r<e.length;)if(!this.isEqual(t,e[r])){if(this.orderCmp(t,e[r]))break;r++}return e.splice(r,0,t),e}}function kpe(e,t){if(!e)return[];const r="multicodec"in e?e.multicodec:e.protocol.multicodec;return t.filter((e=>e.protocols.includes(r))).map((e=>e.id))}const xpe=e=>{const{messages:t}=(e=>{const{node:t,decoder:r}=e,[n,i]=is.useState(void 0),[s,o]=is.useState(!1),[a,c]=is.useState([]),u=is.useCallback((e=>{e&&c((t=>[...t,e]))}),[c]);return is.useEffect((()=>{if(!t||!r)return;let e=null;return o(!0),t.filter.subscribe([r],u).then((t=>{o(!1),e=t})).catch((e=>{o(!1),i(`Failed to subscribe to filer: ${(null===e||void 0===e?void 0:e.message)||"no message"}`)})),()=>{null===e||void 0===e||e()}}),[t,r,u,i,o]),{error:n,messages:a,isLoading:s}})(e),{messages:r}=(e=>{const{node:t,decoder:r,options:n}=e,[i,s]=is.useState(void 0),[o,a]=is.useState(!1),[c,u]=is.useState([]),l=is.useCallback((e=>{e&&e.length&&u((t=>[...t,...e]))}),[u]);return is.useEffect((()=>{if(!t||!r)return;let e=!1;return a(!0),Promise.resolve().then((async()=>{for await(const i of t.store.queryGenerator([r],n)){if(e)return;const t=(await Promise.all(i)).filter((e=>!!e));l(t)}a(!1)})).catch((e=>{a(!1),s(`Failed to query messages from store: ${(null===e||void 0===e?void 0:e.message)||"no message"}`)})),()=>{e=!0}}),[t,r,l,s,a]),{error:i,isLoading:o,messages:c}})(e),[n,i]=(0,is.useState)([]);return[is.useMemo((()=>{const e=new Ape(Spe.cmp,Spe.isEqual),i=new Date;i.setDate(i.getDate()+1);const s=[...r,...t].map(Spe.fromWakuMessage).filter((e=>!!e)).filter((e=>""!==e.payloadAsUtf8)).filter((e=>e.timestamp.valueOf()<i.valueOf()));return e.push(...s),e.push(...n),e}),[r,t,n]),e=>{e&&e.length&&i((t=>[...t,...e]))}]},Ipe=e=>{const[t,r]=(0,is.useState)(new Set),[n,i]=(0,is.useState)(new Set),[s,o]=(0,is.useState)(new Set),[a,c]=(0,is.useState)(new Set);return(0,is.useEffect)((()=>{if(!e)return;const t=async t=>{(async()=>{await Tpe(t.detail,e)&&r((e=>new Set([...e,t.detail])))})().catch((e=>console.error(e)))},n=e=>{i((t=>new Set([...t,e.detail])))},s=t=>{(async()=>{await Tpe(t.detail,e)&&o((e=>new Set([...e,t.detail])))})().catch((e=>console.error(e)))},a=e=>{c((t=>new Set([...t,e.detail])))};return(async()=>{const{CONNECTED:u,DISCOVERED:l}=await e.connectionManager.getPeersByDiscovery();i(new Set(u[qc.BOOTSTRAP].map((e=>e.id)))),c(new Set(u[qc.PEER_EXCHANGE].map((e=>e.id)))),r(new Set(l[qc.BOOTSTRAP].map((e=>e.id)))),o(new Set(l[qc.PEER_EXCHANGE].map((e=>e.id)))),e.libp2p.addEventListener("peer:disconnect",(e=>{const t=e.detail;i((e=>(e.delete(t),e)))})),e.connectionManager.addEventListener(Kc.PEER_DISCOVERY_BOOTSTRAP,t),e.connectionManager.addEventListener(Kc.PEER_CONNECT_BOOTSTRAP,n),e.connectionManager.addEventListener(Kc.PEER_DISCOVERY_PEER_EXCHANGE,s),e.connectionManager.addEventListener(Kc.PEER_CONNECT_PEER_EXCHANGE,a)})(),()=>{e.connectionManager.removeEventListener(Kc.PEER_DISCOVERY_BOOTSTRAP,t),e.connectionManager.removeEventListener(Kc.PEER_CONNECT_BOOTSTRAP,n),e.connectionManager.removeEventListener(Kc.PEER_DISCOVERY_PEER_EXCHANGE,s),e.connectionManager.removeEventListener(Kc.PEER_CONNECT_PEER_EXCHANGE,a)}}),[e]),{discoveredBootstrapPeers:t,connectedBootstrapPeers:n,discoveredPeerExchangePeers:s,connectedPeerExchangePeers:a}},Cpe=e=>{const{node:t}=e,[r,n]=is.useState({});return(0,is.useEffect)((()=>{if(!t)return;const e=async()=>{const e=t.libp2p.getPeers(),r=await Promise.all(e.map((e=>t.libp2p.peerStore.get(e))));n({allConnected:r.map((e=>e.id)),storePeers:kpe(t.store,r),filterPeers:kpe(t.filter,r),lightPushPeers:kpe(t.lightPush,r)})};return e(),t.libp2p.addEventListener("peer:identify",e),()=>{t.libp2p.removeEventListener("peer:identify",e)}}),[t,n]),r},Tpe=async(e,t)=>{const r=await t.libp2p.peerStore.get(e);if(!r)return!1;if(0===r.addresses.length)return!1;return 0!==r.addresses.filter((e=>{let{multiaddr:t}=e;return Rpe(t.toString())})).length},Rpe=e=>e.includes("wss")||e.includes("/tls/ws");function Ppe(e){const{node:t}=ipe(),{encoder:r}=Zfe(),{push:n}=rpe({node:t,encoder:r}),{connectedBootstrapPeers:i,connectedPeerExchangePeers:s,discoveredBootstrapPeers:o,discoveredPeerExchangePeers:a}=Ipe(t),{allConnected:c,storePeers:u,filterPeers:l,lightPushPeers:h}=Cpe({node:t}),d=Dpe(null===c||void 0===c?void 0:c.length),f=Dpe(null===h||void 0===h?void 0:h.length),p=Dpe(null===l||void 0===l?void 0:l.length),g=Dpe(null===u||void 0===u?void 0:u.length);return(0,ape.jsxs)("div",{className:"h-screen flex flex-col",children:[(0,ape.jsxs)("div",{className:"flex justify-between items-center bg-gray-800 text-white p-4",children:[(0,ape.jsxs)("div",{children:[(0,ape.jsxs)("div",{children:["Peers Connected: ",d]}),(0,ape.jsxs)("div",{className:"mt-2",children:["Store: ",g]}),(0,ape.jsxs)("div",{children:["Filter: ",p]}),(0,ape.jsxs)("div",{children:["Light Push: ",f]})]}),(0,ape.jsx)("div",{children:"Waku v2 Web Chat"}),(0,ape.jsxs)("div",{children:[(0,ape.jsxs)("div",{className:"mt-2",children:["Peers Discovered:"," ",o.size+a.size]}),(0,ape.jsxs)("div",{children:["Bootstrap: ",o.size," Peer Exchange:"," ",a.size]}),(0,ape.jsxs)("div",{className:"mt-2",children:["Peers Connected:"," ",i.size+s.size]}),(0,ape.jsxs)("div",{children:["Bootstrap: ",i.size," Peer Exchange:"," ",s.size]})]})]}),(0,ape.jsx)(cpe,{messages:e.messages}),(0,ape.jsx)(hpe,{hasLightPushPeers:!!h,sendMessage:async t=>{if(n&&t)if(t.startsWith("/"))e.commandHandler(t);else{const r=new Date,i=_pe.fromUtf8String(r,e.nick,t).encode();await n({payload:i,timestamp:r})}}})]})}function Dpe(e){return e||0}const Npe=new Date;Npe.setTime(Date.now()-6048e5);const Bpe=new Date;function Upe(){const{node:e}=ipe(),{decoder:t}=Zfe(),[r,n]=xpe({node:e,decoder:t,options:{pageSize:5,pageDirection:Oc.FORWARD,timeFilter:{startTime:Npe,endTime:Bpe}}}),[i,s]=(()=>{const[e,t]=(0,is.useState)((()=>{const e=window.localStorage.getItem("nick");return null!==e?e:(0,Epe.c)()}));return(0,is.useEffect)((()=>{localStorage.setItem("nick",e)}),[e]),[e,t]})();return(0,ape.jsx)("div",{className:"chat-app",style:{height:"100vh",width:"100vw",overflow:"hidden"},children:(0,ape.jsx)(Ppe,{nick:i,messages:r,commandHandler:t=>{ope(t,e,s).then((e=>{let{command:t,response:r}=e;const i=r.map((e=>Spe.fromUtf8String(t,e)));n(i)}))}})})}ss.render((0,ape.jsx)(is.StrictMode,{children:(0,ape.jsx)(spe,{options:{defaultBootstrap:!0},protocols:[Lc.Store,Lc.Filter,Lc.LightPush],children:(0,ape.jsx)(epe,{contentTopic:"/toy-chat/2/huilong/proto",children:(0,ape.jsx)(Upe,{})})})}),document.getElementById("root"))})()})();
|
|
//# sourceMappingURL=main.b0962d94.js.map |