status-im-auto 1ff3bc548d Updates
2024-10-01 10:29:44 +00:00

3 lines
848 KiB
JavaScript

/*! For license information please see main.4b50e294.js.LICENSE.txt */
(()=>{var __webpack_modules__={4762:e=>{"use strict";e.exports=function(e,t){var n=new Array(arguments.length-1),r=0,o=2,i=!0;for(;o<arguments.length;)n[r++]=arguments[o++];return new Promise((function(o,s){n[r]=function(e){if(i)if(i=!1,e)s(e);else{for(var t=new Array(arguments.length-1),n=0;n<t.length;)t[n++]=arguments[n];o.apply(null,t)}};try{e.apply(t||null,n)}catch(a){i&&(i=!1,s(a))}}))}},6762:(e,t)=>{"use strict";var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=new Array(64),o=new Array(123),i=0;i<64;)o[r[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;n.encode=function(e,t,n){for(var o,i=null,s=[],a=0,l=0;t<n;){var c=e[t++];switch(l){case 0:s[a++]=r[c>>2],o=(3&c)<<4,l=1;break;case 1:s[a++]=r[o|c>>4],o=(15&c)<<2,l=2;break;case 2:s[a++]=r[o|c>>6],s[a++]=r[63&c],l=0}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return l&&(s[a++]=r[o],s[a++]=61,1===l&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";n.decode=function(e,t,n){for(var r,i=n,a=0,l=0;l<e.length;){var c=e.charCodeAt(l++);if(61===c&&a>1)break;if(void 0===(c=o[c]))throw Error(s);switch(a){case 0:r=c,a=1;break;case 1:t[n++]=r<<2|(48&c)>>4,r=c,a=2;break;case 2:t[n++]=(15&r)<<4|(60&c)>>2,r=c,a=3;break;case 3:t[n++]=(3&r)<<6|c,a=0}}if(1===a)throw Error(s);return n-i},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},1318:e=>{"use strict";function t(e,n){"string"===typeof e&&(n=e,e=void 0);var r=[];function o(e){if("string"!==typeof e){var n=i();if(t.verbose&&console.log("codegen: "+n),n="return "+n,e){for(var s=Object.keys(e),a=new Array(s.length+1),l=new Array(s.length),c=0;c<s.length;)a[c]=s[c],l[c]=e[s[c++]];return a[c]=n,Function.apply(null,a).apply(null,l)}return Function(n)()}for(var u=new Array(arguments.length-1),d=0;d<u.length;)u[d]=arguments[++d];if(d=0,e=e.replace(/%([%dfijs])/g,(function(e,t){var n=u[d++];switch(t){case"d":case"f":return String(Number(n));case"i":return String(Math.floor(n));case"j":return JSON.stringify(n);case"s":return String(n)}return"%"})),d!==u.length)throw Error("parameter count mismatch");return r.push(e),o}function i(t){return"function "+(t||n||"")+"("+(e&&e.join(",")||"")+"){\n "+r.join("\n ")+"\n}"}return o.toString=i,o}e.exports=t,t.verbose=!1},7351:e=>{"use strict";function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||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 n=this._listeners[e],r=0;r<n.length;)n[r].fn===t?n.splice(r,1):++r;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<t.length;)t[r].fn.apply(t[r++].ctx,n)}return this}},643:(e,t,n)=>{"use strict";e.exports=i;var r=n(4762),o=n(4882)("fs");function i(e,t,n){return"function"===typeof t?(n=t,t={}):t||(t={}),n?!t.xhr&&o&&o.readFile?o.readFile(e,(function(r,o){return r&&"undefined"!==typeof XMLHttpRequest?i.xhr(e,t,n):r?n(r):n(null,t.binary?o:o.toString("utf8"))})):i.xhr(e,t,n):r(i,this,e,t)}i.xhr=function(e,t,n){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4===r.readyState){if(0!==r.status&&200!==r.status)return n(Error("status "+r.status));if(t.binary){var e=r.response;if(!e){e=[];for(var o=0;o<r.responseText.length;++o)e.push(255&r.responseText.charCodeAt(o))}return n(null,"undefined"!==typeof Uint8Array?new Uint8Array(e):e)}return n(null,r.responseText)}},t.binary&&("overrideMimeType"in r&&r.overrideMimeType("text/plain; charset=x-user-defined"),r.responseType="arraybuffer"),r.open("GET",e),r.send()}},217:e=>{"use strict";function t(e){return"undefined"!==typeof Float32Array?function(){var t=new Float32Array([-0]),n=new Uint8Array(t.buffer),r=128===n[3];function o(e,r,o){t[0]=e,r[o]=n[0],r[o+1]=n[1],r[o+2]=n[2],r[o+3]=n[3]}function i(e,r,o){t[0]=e,r[o]=n[3],r[o+1]=n[2],r[o+2]=n[1],r[o+3]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],t[0]}function a(e,r){return n[3]=e[r],n[2]=e[r+1],n[1]=e[r+2],n[0]=e[r+3],t[0]}e.writeFloatLE=r?o:i,e.writeFloatBE=r?i:o,e.readFloatLE=r?s:a,e.readFloatBE=r?a:s}():function(){function t(e,t,n,r){var o=t<0?1:0;if(o&&(t=-t),0===t)e(1/t>0?0:2147483648,n,r);else if(isNaN(t))e(2143289344,n,r);else if(t>34028234663852886e22)e((o<<31|2139095040)>>>0,n,r);else if(t<11754943508222875e-54)e((o<<31|Math.round(t/1401298464324817e-60))>>>0,n,r);else{var i=Math.floor(Math.log(t)/Math.LN2);e((o<<31|i+127<<23|8388607&Math.round(t*Math.pow(2,-i)*8388608))>>>0,n,r)}}function s(e,t,n){var r=e(t,n),o=2*(r>>31)+1,i=r>>>23&255,s=8388607&r;return 255===i?s?NaN:o*(1/0):0===i?1401298464324817e-60*o*s:o*Math.pow(2,i-150)*(s+8388608)}e.writeFloatLE=t.bind(null,n),e.writeFloatBE=t.bind(null,r),e.readFloatLE=s.bind(null,o),e.readFloatBE=s.bind(null,i)}(),"undefined"!==typeof Float64Array?function(){var t=new Float64Array([-0]),n=new Uint8Array(t.buffer),r=128===n[7];function o(e,r,o){t[0]=e,r[o]=n[0],r[o+1]=n[1],r[o+2]=n[2],r[o+3]=n[3],r[o+4]=n[4],r[o+5]=n[5],r[o+6]=n[6],r[o+7]=n[7]}function i(e,r,o){t[0]=e,r[o]=n[7],r[o+1]=n[6],r[o+2]=n[5],r[o+3]=n[4],r[o+4]=n[3],r[o+5]=n[2],r[o+6]=n[1],r[o+7]=n[0]}function s(e,r){return n[0]=e[r],n[1]=e[r+1],n[2]=e[r+2],n[3]=e[r+3],n[4]=e[r+4],n[5]=e[r+5],n[6]=e[r+6],n[7]=e[r+7],t[0]}function a(e,r){return n[7]=e[r],n[6]=e[r+1],n[5]=e[r+2],n[4]=e[r+3],n[3]=e[r+4],n[2]=e[r+5],n[1]=e[r+6],n[0]=e[r+7],t[0]}e.writeDoubleLE=r?o:i,e.writeDoubleBE=r?i:o,e.readDoubleLE=r?s:a,e.readDoubleBE=r?a:s}():function(){function t(e,t,n,r,o,i){var s=r<0?1:0;if(s&&(r=-r),0===r)e(0,o,i+t),e(1/r>0?0:2147483648,o,i+n);else if(isNaN(r))e(0,o,i+t),e(2146959360,o,i+n);else if(r>17976931348623157e292)e(0,o,i+t),e((s<<31|2146435072)>>>0,o,i+n);else{var a;if(r<22250738585072014e-324)e((a=r/5e-324)>>>0,o,i+t),e((s<<31|a/4294967296)>>>0,o,i+n);else{var l=Math.floor(Math.log(r)/Math.LN2);1024===l&&(l=1023),e(4503599627370496*(a=r*Math.pow(2,-l))>>>0,o,i+t),e((s<<31|l+1023<<20|1048576*a&1048575)>>>0,o,i+n)}}}function s(e,t,n,r,o){var i=e(r,o+t),s=e(r,o+n),a=2*(s>>31)+1,l=s>>>20&2047,c=4294967296*(1048575&s)+i;return 2047===l?c?NaN:a*(1/0):0===l?5e-324*a*c:a*Math.pow(2,l-1075)*(c+4503599627370496)}e.writeDoubleLE=t.bind(null,n,0,4),e.writeDoubleBE=t.bind(null,r,4,0),e.readDoubleLE=s.bind(null,o,0,4),e.readDoubleBE=s.bind(null,i,4,0)}(),e}function n(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function r(e,t,n){t[n]=e>>>24,t[n+1]=e>>>16&255,t[n+2]=e>>>8&255,t[n+3]=255&e}function o(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function i(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},5534:(e,t)=>{"use strict";var n=t,r=n.isAbsolute=function(e){return/^(?:\/|\w+:)/.test(e)},o=n.normalize=function(e){var t=(e=e.replace(/\\/g,"/").replace(/\/{2,}/g,"/")).split("/"),n=r(e),o="";n&&(o=t.shift()+"/");for(var i=0;i<t.length;)".."===t[i]?i>0&&".."!==t[i-1]?t.splice(--i,2):n?t.splice(i,1):++i:"."===t[i]?t.splice(i,1):++i;return o+t.join("/")};n.resolve=function(e,t,n){return n||(t=o(t)),r(t)?t:(n||(e=o(e)),(e=e.replace(/(?:\/|^)[^/]+$/,"")).length?o(e+"/"+t):t)}},6931:e=>{"use strict";e.exports=function(e,t,n){var r=n||8192,o=r>>>1,i=null,s=r;return function(n){if(n<1||n>o)return e(n);s+n>r&&(i=e(r),s=0);var a=t.call(i,s,s+=n);return 7&s&&(s=1+(7|s)),a}}},8626:(e,t)=>{"use strict";var n=t;n.length=function(e){for(var t=0,n=0,r=0;r<e.length;++r)(n=e.charCodeAt(r))<128?t+=1:n<2048?t+=2:55296===(64512&n)&&56320===(64512&e.charCodeAt(r+1))?(++r,t+=4):t+=3;return t},n.read=function(e,t,n){if(n-t<1)return"";for(var r,o=null,i=[],s=0;t<n;)(r=e[t++])<128?i[s++]=r:r>191&&r<224?i[s++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(r>>10),i[s++]=56320+(1023&r)):i[s++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o?(s&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))},n.write=function(e,t,n){for(var r,o,i=n,s=0;s<e.length;++s)(r=e.charCodeAt(s))<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296===(64512&r)&&56320===(64512&(o=e.charCodeAt(s+1)))?(r=65536+((1023&r)<<10)+(1023&o),++s,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-i}},6522:(e,t,n)=>{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 n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))})),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(n){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(n){}!e&&"undefined"!==typeof process&&"env"in process&&(e={NODE_ENV:"production",PUBLIC_URL:"",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;let e;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&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[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=n(5237)(t);const{formatters:r}=e.exports;r.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},5237:(e,t,n)=>{e.exports=function(e){function t(e){let n,o,i,s=null;function a(){for(var e=arguments.length,r=new Array(e),o=0;o<e;o++)r[o]=arguments[o];if(!a.enabled)return;const i=a,s=Number(new Date),l=s-(n||s);i.diff=l,i.prev=n,i.curr=s,n=s,r[0]=t.coerce(r[0]),"string"!==typeof r[0]&&r.unshift("%O");let c=0;r[0]=r[0].replace(/%([a-zA-Z%])/g,((e,n)=>{if("%%"===e)return"%";c++;const o=t.formatters[n];if("function"===typeof o){const t=r[c];e=o.call(i,t),r.splice(c,1),c--}return e})),t.formatArgs.call(i,r);(i.log||t.log).apply(i,r)}return a.namespace=e,a.useColors=t.useColors(),a.color=t.selectColor(e),a.extend=r,a.destroy=t.destroy,Object.defineProperty(a,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"===typeof t.init&&t.init(a),a}function r(e,n){const r=t(this.namespace+("undefined"===typeof n?":":n)+e);return r.log=this.log,r}function o(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(o),...t.skips.map(o).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"===typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].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 n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(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((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},4823:e=>{"use strict";function t(e,t){for(const n in t)Object.defineProperty(e,n,{value:t[n],enumerable:!0,configurable:!0});return e}e.exports=function(e,n,r){if(!e||"string"===typeof e)throw new TypeError("Please pass an Error to err-code");r||(r={}),"object"===typeof n&&(r=n,n=""),n&&(r.code=n);try{return t(e,r)}catch(o){r.message=e.message,r.stack=e.stack;const n=function(){};n.prototype=Object.create(Object.getPrototypeOf(e));return t(new n,r)}}},2605:(e,t,n)=>{"use strict";const r=n(6639);t.PP=r.EventIterator,r.EventIterator},6639:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{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 r{constructor(e){let{highWaterMark:t=100,lowWaterMark:r=1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=new n;o.highWaterMark=t,o.lowWaterMark=r,o.removeCallback=e({push:e=>o.push(e),stop:()=>o.stop(),fail:e=>o.fail(e),on:(e,t)=>{o.eventHandlers[e]=t}})||(()=>{}),this[Symbol.asyncIterator]=()=>o[Symbol.asyncIterator](),Object.freeze(this)}}t.EventIterator=r,t.default=r},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,n=Object.create(null),r=Object.create(null);function o(o,i){n[o]=i,++t>=e&&(t=0,r=n,n=Object.create(null))}return{has:function(e){return void 0!==n[e]||void 0!==r[e]},remove:function(e){void 0!==n[e]&&(n[e]=void 0),void 0!==r[e]&&(r[e]=void 0)},get:function(e){var t=n[e];return void 0!==t?t:void 0!==(t=r[e])?(o(e,t),t):void 0},set:function(e,t){void 0!==n[e]?n[e]=t:o(e,t)},clear:function(){n=Object.create(null),r=Object.create(null)}}}},5411:(e,t,n)=>{var r;!function(){"use strict";var t="object"===typeof window?window:{};!t.HI_BASE32_NO_NODE_JS&&"object"===typeof process&&process.versions&&process.versions.node&&(t=n.g);var o=!t.HI_BASE32_NO_COMMON_JS&&e.exports,i=n.amdO,s="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},l=[0,0,0,0,0,0,0,0],c=function(e,t){t.length>10&&(t="..."+t.substr(-10));var n=new Error("Decoded data is not valid UTF-8. Maybe try base32.decode.asBytes()? Partial data after reading "+e+" bytes: "+t+" <-");throw n.position=e,n},u=function(e){if(""===e)return[];if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");for(var t,n,r,o,i,s,l,c,u=[],d=0,h=(e=e.replace(/=/g,"")).length,f=0,p=h>>3<<3;f<p;)t=a[e.charAt(f++)],n=a[e.charAt(f++)],r=a[e.charAt(f++)],o=a[e.charAt(f++)],i=a[e.charAt(f++)],s=a[e.charAt(f++)],l=a[e.charAt(f++)],c=a[e.charAt(f++)],u[d++]=255&(t<<3|n>>>2),u[d++]=255&(n<<6|r<<1|o>>>4),u[d++]=255&(o<<4|i>>>1),u[d++]=255&(i<<7|s<<2|l>>>3),u[d++]=255&(l<<5|c);var g=h-p;return 2===g?(t=a[e.charAt(f++)],n=a[e.charAt(f++)],u[d++]=255&(t<<3|n>>>2)):4===g?(t=a[e.charAt(f++)],n=a[e.charAt(f++)],r=a[e.charAt(f++)],o=a[e.charAt(f++)],u[d++]=255&(t<<3|n>>>2),u[d++]=255&(n<<6|r<<1|o>>>4)):5===g?(t=a[e.charAt(f++)],n=a[e.charAt(f++)],r=a[e.charAt(f++)],o=a[e.charAt(f++)],i=a[e.charAt(f++)],u[d++]=255&(t<<3|n>>>2),u[d++]=255&(n<<6|r<<1|o>>>4),u[d++]=255&(o<<4|i>>>1)):7===g&&(t=a[e.charAt(f++)],n=a[e.charAt(f++)],r=a[e.charAt(f++)],o=a[e.charAt(f++)],i=a[e.charAt(f++)],s=a[e.charAt(f++)],l=a[e.charAt(f++)],u[d++]=255&(t<<3|n>>>2),u[d++]=255&(n<<6|r<<1|o>>>4),u[d++]=255&(o<<4|i>>>1),u[d++]=255&(i<<7|s<<2|l>>>3)),u},d=function(e,t){if(!t)return function(e){for(var t,n,r="",o=e.length,i=0,s=0;i<o;)if((t=e[i++])<=127)r+=String.fromCharCode(t);else{t>191&&t<=223?(n=31&t,s=1):t<=239?(n=15&t,s=2):t<=247?(n=7&t,s=3):c(i,r);for(var a=0;a<s;++a)((t=e[i++])<128||t>191)&&c(i,r),n<<=6,n+=63&t;n>=55296&&n<=57343&&c(i,r),n>1114111&&c(i,r),n<=65535?r+=String.fromCharCode(n):(n-=65536,r+=String.fromCharCode(55296+(n>>10)),r+=String.fromCharCode(56320+(1023&n)))}return r}(u(e));if(""===e)return"";if(!/^[A-Z2-7=]+$/.test(e))throw new Error("Invalid base32 characters");var n,r,o,i,s,l,d,h,f="",p=e.indexOf("=");-1===p&&(p=e.length);for(var g=0,m=p>>3<<3;g<m;)n=a[e.charAt(g++)],r=a[e.charAt(g++)],o=a[e.charAt(g++)],i=a[e.charAt(g++)],s=a[e.charAt(g++)],l=a[e.charAt(g++)],d=a[e.charAt(g++)],h=a[e.charAt(g++)],f+=String.fromCharCode(255&(n<<3|r>>>2))+String.fromCharCode(255&(r<<6|o<<1|i>>>4))+String.fromCharCode(255&(i<<4|s>>>1))+String.fromCharCode(255&(s<<7|l<<2|d>>>3))+String.fromCharCode(255&(d<<5|h));var y=p-m;return 2===y?(n=a[e.charAt(g++)],r=a[e.charAt(g++)],f+=String.fromCharCode(255&(n<<3|r>>>2))):4===y?(n=a[e.charAt(g++)],r=a[e.charAt(g++)],o=a[e.charAt(g++)],i=a[e.charAt(g++)],f+=String.fromCharCode(255&(n<<3|r>>>2))+String.fromCharCode(255&(r<<6|o<<1|i>>>4))):5===y?(n=a[e.charAt(g++)],r=a[e.charAt(g++)],o=a[e.charAt(g++)],i=a[e.charAt(g++)],s=a[e.charAt(g++)],f+=String.fromCharCode(255&(n<<3|r>>>2))+String.fromCharCode(255&(r<<6|o<<1|i>>>4))+String.fromCharCode(255&(i<<4|s>>>1))):7===y&&(n=a[e.charAt(g++)],r=a[e.charAt(g++)],o=a[e.charAt(g++)],i=a[e.charAt(g++)],s=a[e.charAt(g++)],l=a[e.charAt(g++)],d=a[e.charAt(g++)],f+=String.fromCharCode(255&(n<<3|r>>>2))+String.fromCharCode(255&(r<<6|o<<1|i>>>4))+String.fromCharCode(255&(i<<4|s>>>1))+String.fromCharCode(255&(s<<7|l<<2|d>>>3))),f},h={encode:function(e,t){var n="string"!==typeof e;return n&&e.constructor===ArrayBuffer&&(e=new Uint8Array(e)),n?function(e){for(var t,n,r,o,i,a="",l=e.length,c=0,u=5*parseInt(l/5);c<u;)t=e[c++],n=e[c++],r=e[c++],o=e[c++],i=e[c++],a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[31&(r<<1|o>>>7)]+s[o>>>2&31]+s[31&(o<<3|i>>>5)]+s[31&i];var d=l-u;return 1===d?(t=e[c],a+=s[t>>>3]+s[t<<2&31]+"======"):2===d?(t=e[c++],n=e[c],a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[n<<4&31]+"===="):3===d?(t=e[c++],n=e[c++],r=e[c],a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[r<<1&31]+"==="):4===d&&(t=e[c++],n=e[c++],r=e[c++],o=e[c],a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[31&(r<<1|o>>>7)]+s[o>>>2&31]+s[o<<3&31]+"="),a}(e):t?function(e){for(var t,n,r,o,i,a="",l=e.length,c=0,u=5*parseInt(l/5);c<u;)t=e.charCodeAt(c++),n=e.charCodeAt(c++),r=e.charCodeAt(c++),o=e.charCodeAt(c++),i=e.charCodeAt(c++),a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[31&(r<<1|o>>>7)]+s[o>>>2&31]+s[31&(o<<3|i>>>5)]+s[31&i];var d=l-u;return 1===d?(t=e.charCodeAt(c),a+=s[t>>>3]+s[t<<2&31]+"======"):2===d?(t=e.charCodeAt(c++),n=e.charCodeAt(c),a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[n<<4&31]+"===="):3===d?(t=e.charCodeAt(c++),n=e.charCodeAt(c++),r=e.charCodeAt(c),a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[r<<1&31]+"==="):4===d&&(t=e.charCodeAt(c++),n=e.charCodeAt(c++),r=e.charCodeAt(c++),o=e.charCodeAt(c),a+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[31&(r<<1|o>>>7)]+s[o>>>2&31]+s[o<<3&31]+"="),a}(e):function(e){var t,n,r,o,i,a,c,u=!1,d="",h=0,f=0,p=e.length;if(""===e)return d;do{for(l[0]=l[5],l[1]=l[6],l[2]=l[7],c=f;h<p&&c<5;++h)(a=e.charCodeAt(h))<128?l[c++]=a:a<2048?(l[c++]=192|a>>6,l[c++]=128|63&a):a<55296||a>=57344?(l[c++]=224|a>>12,l[c++]=128|a>>6&63,l[c++]=128|63&a):(a=65536+((1023&a)<<10|1023&e.charCodeAt(++h)),l[c++]=240|a>>18,l[c++]=128|a>>12&63,l[c++]=128|a>>6&63,l[c++]=128|63&a);f=c-5,h===p&&++h,h>p&&c<6&&(u=!0),t=l[0],c>4?(n=l[1],r=l[2],o=l[3],i=l[4],d+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[31&(r<<1|o>>>7)]+s[o>>>2&31]+s[31&(o<<3|i>>>5)]+s[31&i]):1===c?d+=s[t>>>3]+s[t<<2&31]+"======":2===c?(n=l[1],d+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[n<<4&31]+"===="):3===c?(n=l[1],r=l[2],d+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[r<<1&31]+"==="):(n=l[1],r=l[2],o=l[3],d+=s[t>>>3]+s[31&(t<<2|n>>>6)]+s[n>>>1&31]+s[31&(n<<4|r>>>4)]+s[31&(r<<1|o>>>7)]+s[o>>>2&31]+s[o<<3&31]+"=")}while(!u);return d}(e)},decode:d};d.asBytes=u,o?e.exports=h:(t.base32=h,i&&(void 0===(r=function(){return h}.call(h,n,h,e))||(e.exports=r)))}()},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)}},2161:(e,t,n)=>{var r;!function(){"use strict";var o="input is invalid type",i="object"===typeof window,s=i?window:{};s.JS_SHA3_NO_WINDOW&&(i=!1);var a=!i&&"object"===typeof self;!s.JS_SHA3_NO_NODE_JS&&"object"===typeof process&&process.versions&&process.versions.node?s=n.g:a&&(s=self);for(var l=!s.JS_SHA3_NO_COMMON_JS&&e.exports,c=n.amdO,u=!s.JS_SHA3_NO_ARRAY_BUFFER&&"undefined"!==typeof ArrayBuffer,d="0123456789abcdef".split(""),h=[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],m=[128,256],y=["hex","buffer","arrayBuffer","array","digest"],b={128:168,256:136},w=s.JS_SHA3_NO_NODE_JS||!Array.isArray?function(e){return"[object Array]"===Object.prototype.toString.call(e)}:Array.isArray,v=!u||!s.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW&&ArrayBuffer.isView?ArrayBuffer.isView:function(e){return"object"===typeof e&&e.buffer&&e.buffer.constructor===ArrayBuffer},E=function(e){var t=typeof e;if("string"===t)return[e,!0];if("object"!==t||null===e)throw new Error(o);if(u&&e.constructor===ArrayBuffer)return[new Uint8Array(e),!1];if(!w(e)&&!v(e))throw new Error(o);return[e,!1]},S=function(e){return 0===E(e)[0].length},k=function(e){for(var t=[],n=0;n<e.length;++n)t[n]=e[n];return t},A=function(e,t,n){return function(r){return new F(e,t,e).update(r)[n]()}},_=function(e,t,n){return function(r,o){return new F(e,t,o).update(r)[n]()}},I=function(e,t,n){return function(t,r,o,i){return N["cshake"+e].update(t,r,o,i)[n]()}},x=function(e,t,n){return function(t,r,o,i){return N["kmac"+e].update(t,r,o,i)[n]()}},C=function(e,t,n,r){for(var o=0;o<y.length;++o){var i=y[o];e[i]=t(n,r,i)}return e},R=function(e,t){var n=A(e,t,"hex");return n.create=function(){return new F(e,t,e)},n.update=function(e){return n.create().update(e)},C(n,A,e,t)},T=[{name:"keccak",padding:[1,256,65536,16777216],bits:g,createMethod:R},{name:"sha3",padding:[6,1536,393216,100663296],bits:g,createMethod:R},{name:"shake",padding:[31,7936,2031616,520093696],bits:m,createMethod:function(e,t){var n=_(e,t,"hex");return n.create=function(n){return new F(e,t,n)},n.update=function(e,t){return n.create(t).update(e)},C(n,_,e,t)}},{name:"cshake",padding:h,bits:m,createMethod:function(e,t){var n=b[e],r=I(e,0,"hex");return r.create=function(r,o,i){return S(o)&&S(i)?N["shake"+e].create(r):new F(e,t,r).bytepad([o,i],n)},r.update=function(e,t,n,o){return r.create(t,n,o).update(e)},C(r,I,e,t)}},{name:"kmac",padding:h,bits:m,createMethod:function(e,t){var n=b[e],r=x(e,0,"hex");return r.create=function(r,o,i){return new $(e,t,o).bytepad(["KMAC",i],n).bytepad([r],n)},r.update=function(e,t,n,o){return r.create(e,n,o).update(t)},C(r,x,e,t)}}],N={},P=[],O=0;O<T.length;++O)for(var L=T[O],D=L.bits,B=0;B<D.length;++B){var U=L.name+"_"+D[B];if(P.push(U),N[U]=L.createMethod(D[B],L.padding),"sha3"!==L.name){var M=L.name+D[B];P.push(M),N[M]=N[U]}}function F(e,t,n){this.blocks=[],this.s=[],this.padding=t,this.outputBits=n,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=n>>5,this.extraBytes=(31&n)>>3;for(var r=0;r<50;++r)this.s[r]=0}function $(e,t,n){F.call(this,e,t,n)}F.prototype.update=function(e){if(this.finalized)throw new Error("finalize already called");var t=E(e);e=t[0];for(var n,r,o=t[1],i=this.blocks,s=this.byteCount,a=e.length,l=this.blockCount,c=0,u=this.s;c<a;){if(this.reset)for(this.reset=!1,i[0]=this.block,n=1;n<l+1;++n)i[n]=0;if(o)for(n=this.start;c<a&&n<s;++c)(r=e.charCodeAt(c))<128?i[n>>2]|=r<<f[3&n++]:r<2048?(i[n>>2]|=(192|r>>6)<<f[3&n++],i[n>>2]|=(128|63&r)<<f[3&n++]):r<55296||r>=57344?(i[n>>2]|=(224|r>>12)<<f[3&n++],i[n>>2]|=(128|r>>6&63)<<f[3&n++],i[n>>2]|=(128|63&r)<<f[3&n++]):(r=65536+((1023&r)<<10|1023&e.charCodeAt(++c)),i[n>>2]|=(240|r>>18)<<f[3&n++],i[n>>2]|=(128|r>>12&63)<<f[3&n++],i[n>>2]|=(128|r>>6&63)<<f[3&n++],i[n>>2]|=(128|63&r)<<f[3&n++]);else for(n=this.start;c<a&&n<s;++c)i[n>>2]|=e[c]<<f[3&n++];if(this.lastByteIndex=n,n>=s){for(this.start=n-s,this.block=i[l],n=0;n<l;++n)u[n]^=i[n];H(u),this.reset=!0}else this.start=n}return this},F.prototype.encode=function(e,t){var n=255&e,r=1,o=[n];for(n=255&(e>>=8);n>0;)o.unshift(n),n=255&(e>>=8),++r;return t?o.push(r):o.unshift(r),this.update(o),o.length},F.prototype.encodeString=function(e){var t=E(e);e=t[0];var n=t[1],r=0,o=e.length;if(n)for(var i=0;i<e.length;++i){var s=e.charCodeAt(i);s<128?r+=1:s<2048?r+=2:s<55296||s>=57344?r+=3:(s=65536+((1023&s)<<10|1023&e.charCodeAt(++i)),r+=4)}else r=o;return r+=this.encode(8*r),this.update(e),r},F.prototype.bytepad=function(e,t){for(var n=this.encode(t),r=0;r<e.length;++r)n+=this.encodeString(e[r]);var o=(t-n%t)%t,i=[];return i.length=o,this.update(i),this},F.prototype.finalize=function(){if(!this.finalized){this.finalized=!0;var e=this.blocks,t=this.lastByteIndex,n=this.blockCount,r=this.s;if(e[t>>2]|=this.padding[3&t],this.lastByteIndex===this.byteCount)for(e[0]=e[n],t=1;t<n+1;++t)e[t]=0;for(e[n-1]|=2147483648,t=0;t<n;++t)r[t]^=e[t];H(r)}},F.prototype.toString=F.prototype.hex=function(){this.finalize();for(var e,t=this.blockCount,n=this.s,r=this.outputBlocks,o=this.extraBytes,i=0,s=0,a="";s<r;){for(i=0;i<t&&s<r;++i,++s)e=n[i],a+=d[e>>4&15]+d[15&e]+d[e>>12&15]+d[e>>8&15]+d[e>>20&15]+d[e>>16&15]+d[e>>28&15]+d[e>>24&15];s%t===0&&(n=k(n),H(n),i=0)}return o&&(e=n[i],a+=d[e>>4&15]+d[15&e],o>1&&(a+=d[e>>12&15]+d[e>>8&15]),o>2&&(a+=d[e>>20&15]+d[e>>16&15])),a},F.prototype.arrayBuffer=function(){this.finalize();var e,t=this.blockCount,n=this.s,r=this.outputBlocks,o=this.extraBytes,i=0,s=0,a=this.outputBits>>3;e=o?new ArrayBuffer(r+1<<2):new ArrayBuffer(a);for(var l=new Uint32Array(e);s<r;){for(i=0;i<t&&s<r;++i,++s)l[s]=n[i];s%t===0&&(n=k(n),H(n))}return o&&(l[s]=n[i],e=e.slice(0,a)),e},F.prototype.buffer=F.prototype.arrayBuffer,F.prototype.digest=F.prototype.array=function(){this.finalize();for(var e,t,n=this.blockCount,r=this.s,o=this.outputBlocks,i=this.extraBytes,s=0,a=0,l=[];a<o;){for(s=0;s<n&&a<o;++s,++a)e=a<<2,t=r[s],l[e]=255&t,l[e+1]=t>>8&255,l[e+2]=t>>16&255,l[e+3]=t>>24&255;a%n===0&&(r=k(r),H(r))}return i&&(e=a<<2,t=r[s],l[e]=255&t,i>1&&(l[e+1]=t>>8&255),i>2&&(l[e+2]=t>>16&255)),l},$.prototype=new F,$.prototype.finalize=function(){return this.encode(this.outputBits,!0),F.prototype.finalize.call(this)};var H=function(e){var t,n,r,o,i,s,a,l,c,u,d,h,f,g,m,y,b,w,v,E,S,k,A,_,I,x,C,R,T,N,P,O,L,D,B,U,M,F,$,H,q,j,V,z,K,W,G,Y,Q,J,X,Z,ee,te,ne,re,oe,ie,se,ae,le,ce,ue;for(r=0;r<48;r+=2)o=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],s=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],l=e[4]^e[14]^e[24]^e[34]^e[44],c=e[5]^e[15]^e[25]^e[35]^e[45],u=e[6]^e[16]^e[26]^e[36]^e[46],d=e[7]^e[17]^e[27]^e[37]^e[47],t=(h=e[8]^e[18]^e[28]^e[38]^e[48])^(s<<1|a>>>31),n=(f=e[9]^e[19]^e[29]^e[39]^e[49])^(a<<1|s>>>31),e[0]^=t,e[1]^=n,e[10]^=t,e[11]^=n,e[20]^=t,e[21]^=n,e[30]^=t,e[31]^=n,e[40]^=t,e[41]^=n,t=o^(l<<1|c>>>31),n=i^(c<<1|l>>>31),e[2]^=t,e[3]^=n,e[12]^=t,e[13]^=n,e[22]^=t,e[23]^=n,e[32]^=t,e[33]^=n,e[42]^=t,e[43]^=n,t=s^(u<<1|d>>>31),n=a^(d<<1|u>>>31),e[4]^=t,e[5]^=n,e[14]^=t,e[15]^=n,e[24]^=t,e[25]^=n,e[34]^=t,e[35]^=n,e[44]^=t,e[45]^=n,t=l^(h<<1|f>>>31),n=c^(f<<1|h>>>31),e[6]^=t,e[7]^=n,e[16]^=t,e[17]^=n,e[26]^=t,e[27]^=n,e[36]^=t,e[37]^=n,e[46]^=t,e[47]^=n,t=u^(o<<1|i>>>31),n=d^(i<<1|o>>>31),e[8]^=t,e[9]^=n,e[18]^=t,e[19]^=n,e[28]^=t,e[29]^=n,e[38]^=t,e[39]^=n,e[48]^=t,e[49]^=n,g=e[0],m=e[1],W=e[11]<<4|e[10]>>>28,G=e[10]<<4|e[11]>>>28,R=e[20]<<3|e[21]>>>29,T=e[21]<<3|e[20]>>>29,ae=e[31]<<9|e[30]>>>23,le=e[30]<<9|e[31]>>>23,j=e[40]<<18|e[41]>>>14,V=e[41]<<18|e[40]>>>14,D=e[2]<<1|e[3]>>>31,B=e[3]<<1|e[2]>>>31,y=e[13]<<12|e[12]>>>20,b=e[12]<<12|e[13]>>>20,Y=e[22]<<10|e[23]>>>22,Q=e[23]<<10|e[22]>>>22,N=e[33]<<13|e[32]>>>19,P=e[32]<<13|e[33]>>>19,ce=e[42]<<2|e[43]>>>30,ue=e[43]<<2|e[42]>>>30,te=e[5]<<30|e[4]>>>2,ne=e[4]<<30|e[5]>>>2,U=e[14]<<6|e[15]>>>26,M=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,O=e[45]<<29|e[44]>>>3,L=e[44]<<29|e[45]>>>3,_=e[6]<<28|e[7]>>>4,I=e[7]<<28|e[6]>>>4,re=e[17]<<23|e[16]>>>9,oe=e[16]<<23|e[17]>>>9,F=e[26]<<25|e[27]>>>7,$=e[27]<<25|e[26]>>>7,E=e[36]<<21|e[37]>>>11,S=e[37]<<21|e[36]>>>11,Z=e[47]<<24|e[46]>>>8,ee=e[46]<<24|e[47]>>>8,z=e[8]<<27|e[9]>>>5,K=e[9]<<27|e[8]>>>5,x=e[18]<<20|e[19]>>>12,C=e[19]<<20|e[18]>>>12,ie=e[29]<<7|e[28]>>>25,se=e[28]<<7|e[29]>>>25,H=e[38]<<8|e[39]>>>24,q=e[39]<<8|e[38]>>>24,k=e[48]<<14|e[49]>>>18,A=e[49]<<14|e[48]>>>18,e[0]=g^~y&w,e[1]=m^~b&v,e[10]=_^~x&R,e[11]=I^~C&T,e[20]=D^~U&F,e[21]=B^~M&$,e[30]=z^~W&Y,e[31]=K^~G&Q,e[40]=te^~re&ie,e[41]=ne^~oe&se,e[2]=y^~w&E,e[3]=b^~v&S,e[12]=x^~R&N,e[13]=C^~T&P,e[22]=U^~F&H,e[23]=M^~$&q,e[32]=W^~Y&J,e[33]=G^~Q&X,e[42]=re^~ie&ae,e[43]=oe^~se&le,e[4]=w^~E&k,e[5]=v^~S&A,e[14]=R^~N&O,e[15]=T^~P&L,e[24]=F^~H&j,e[25]=$^~q&V,e[34]=Y^~J&Z,e[35]=Q^~X&ee,e[44]=ie^~ae&ce,e[45]=se^~le&ue,e[6]=E^~k&g,e[7]=S^~A&m,e[16]=N^~O&_,e[17]=P^~L&I,e[26]=H^~j&D,e[27]=q^~V&B,e[36]=J^~Z&z,e[37]=X^~ee&K,e[46]=ae^~ce&te,e[47]=le^~ue&ne,e[8]=k^~g&y,e[9]=A^~m&b,e[18]=O^~_&x,e[19]=L^~I&C,e[28]=j^~D&U,e[29]=V^~B&M,e[38]=Z^~z&W,e[39]=ee^~K&G,e[48]=ce^~te&re,e[49]=ue^~ne&oe,e[0]^=p[r],e[1]^=p[r+1]};if(l)e.exports=N;else{for(O=0;O<P.length;++O)s[P[O]]=N[P[O]];c&&(void 0===(r=function(){return N}.call(t,n,t,e))||(e.exports=r))}}()},8355:function(e,t,n){"use strict";const r=n(2142),{hasOwnProperty:o}=Object.prototype,{propertyIsEnumerable:i}=Object,s=(e,t,n)=>Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),a=this,l={concatArrays:!1,ignoreUndefined:!1},c=e=>{const t=[];for(const n in e)o.call(e,n)&&t.push(n);if(Object.getOwnPropertySymbols){const n=Object.getOwnPropertySymbols(e);for(const r of n)i.call(e,r)&&t.push(r)}return t};function u(e){return Array.isArray(e)?function(e){const t=e.slice(0,0);return c(e).forEach((n=>{s(t,n,u(e[n]))})),t}(e):r(e)?function(e){const t=null===Object.getPrototypeOf(e)?Object.create(null):{};return c(e).forEach((n=>{s(t,n,u(e[n]))})),t}(e):e}const d=(e,t,n,r)=>(n.forEach((n=>{"undefined"===typeof t[n]&&r.ignoreUndefined||(n in e&&e[n]!==Object.getPrototypeOf(e)?s(e,n,f(e[n],t[n],r)):s(e,n,u(t[n])))})),e),h=(e,t,n)=>{let r=e.slice(0,0),i=0;return[e,t].forEach((t=>{const a=[];for(let n=0;n<t.length;n++)o.call(t,n)&&(a.push(String(n)),s(r,i++,t===e?t[n]:u(t[n])));r=d(r,t,c(t).filter((e=>!a.includes(e))),n)})),r};function f(e,t,n){return n.concatArrays&&Array.isArray(e)&&Array.isArray(t)?h(e,t,n):r(t)&&r(e)?d(e,t,c(t),n):u(t)}e.exports=function(){const e=f(u(l),this!==a&&this||{},l);let t={_:{}};for(var n=arguments.length,o=new Array(n),i=0;i<n;i++)o[i]=arguments[i];for(const s of o)if(void 0!==s){if(!r(s))throw new TypeError("`"+s+"` is not an Option Object");t=f(t,{_:s},e)}return t._}},2142: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}},7340:e=>{var t=1e3,n=60*t,r=60*n,o=24*r,i=7*o,s=365.25*o;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}e.exports=function(e,l){l=l||{};var c=typeof e;if("string"===c&&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 l=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return l*s;case"weeks":case"week":case"w":return l*i;case"days":case"day":case"d":return l*o;case"hours":case"hour":case"hrs":case"hr":case"h":return l*r;case"minutes":case"minute":case"mins":case"min":case"m":return l*n;case"seconds":case"second":case"secs":case"sec":case"s":return l*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return l;default:return}}(e);if("number"===c&&isFinite(e))return l.long?function(e){var i=Math.abs(e);if(i>=o)return a(e,i,o,"day");if(i>=r)return a(e,i,r,"hour");if(i>=n)return a(e,i,n,"minute");if(i>=t)return a(e,i,t,"second");return e+" ms"}(e):function(e){var i=Math.abs(e);if(i>=o)return Math.round(e/o)+"d";if(i>=r)return Math.round(e/r)+"h";if(i>=n)return Math.round(e/n)+"m";if(i>=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))}},2962:(e,t,n)=>{e.exports=n(892)},892:function(e,t){!function(n,r){"use strict";var o={version:"3.0.0",x86:{},x64:{},inputValidation:!0};function i(e){if(!Array.isArray(e)&&!ArrayBuffer.isView(e))return!1;for(var t=0;t<e.length;t++)if(!Number.isInteger(e[t])||e[t]<0||e[t]>255)return!1;return!0}function s(e,t){return(65535&e)*t+(((e>>>16)*t&65535)<<16)}function a(e,t){return e<<t|e>>>32-t}function l(e){return e=s(e^=e>>>16,2246822507),e=s(e^=e>>>13,3266489909),e^=e>>>16}function c(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var n=[0,0,0,0];return n[3]+=e[3]+t[3],n[2]+=n[3]>>>16,n[3]&=65535,n[2]+=e[2]+t[2],n[1]+=n[2]>>>16,n[2]&=65535,n[1]+=e[1]+t[1],n[0]+=n[1]>>>16,n[1]&=65535,n[0]+=e[0]+t[0],n[0]&=65535,[n[0]<<16|n[1],n[2]<<16|n[3]]}function u(e,t){e=[e[0]>>>16,65535&e[0],e[1]>>>16,65535&e[1]],t=[t[0]>>>16,65535&t[0],t[1]>>>16,65535&t[1]];var n=[0,0,0,0];return n[3]+=e[3]*t[3],n[2]+=n[3]>>>16,n[3]&=65535,n[2]+=e[2]*t[3],n[1]+=n[2]>>>16,n[2]&=65535,n[2]+=e[3]*t[2],n[1]+=n[2]>>>16,n[2]&=65535,n[1]+=e[1]*t[3],n[0]+=n[1]>>>16,n[1]&=65535,n[1]+=e[2]*t[2],n[0]+=n[1]>>>16,n[1]&=65535,n[1]+=e[3]*t[1],n[0]+=n[1]>>>16,n[1]&=65535,n[0]+=e[0]*t[3]+e[1]*t[2]+e[2]*t[1]+e[3]*t[0],n[0]&=65535,[n[0]<<16|n[1],n[2]<<16|n[3]]}function d(e,t){return 32===(t%=64)?[e[1],e[0]]:t<32?[e[0]<<t|e[1]>>>32-t,e[1]<<t|e[0]>>>32-t]:(t-=32,[e[1]<<t|e[0]>>>32-t,e[0]<<t|e[1]>>>32-t])}function h(e,t){return 0===(t%=64)?e:t<32?[e[0]<<t|e[1]>>>32-t,e[1]<<t]:[e[1]<<t-32,0]}function f(e,t){return[e[0]^t[0],e[1]^t[1]]}function p(e){return e=f(e,[0,e[0]>>>1]),e=f(e=u(e,[4283543511,3981806797]),[0,e[0]>>>1]),e=f(e=u(e,[3301882366,444984403]),[0,e[0]>>>1])}o.x86.hash32=function(e,t){if(o.inputValidation&&!i(e))return r;t=t||0;for(var n=e.length%4,c=e.length-n,u=t,d=0,h=3432918353,f=461845907,p=0;p<c;p+=4)d=s(d=e[p]|e[p+1]<<8|e[p+2]<<16|e[p+3]<<24,h),d=s(d=a(d,15),f),u=s(u=a(u^=d,13),5)+3864292196;switch(d=0,n){case 3:d^=e[p+2]<<16;case 2:d^=e[p+1]<<8;case 1:d=s(d^=e[p],h),u^=d=s(d=a(d,15),f)}return(u=l(u^=e.length))>>>0},o.x86.hash128=function(e,t){if(o.inputValidation&&!i(e))return r;t=t||0;for(var n=e.length%16,c=e.length-n,u=t,d=t,h=t,f=t,p=0,g=0,m=0,y=0,b=597399067,w=2869860233,v=951274213,E=2716044179,S=0;S<c;S+=16)p=e[S]|e[S+1]<<8|e[S+2]<<16|e[S+3]<<24,g=e[S+4]|e[S+5]<<8|e[S+6]<<16|e[S+7]<<24,m=e[S+8]|e[S+9]<<8|e[S+10]<<16|e[S+11]<<24,y=e[S+12]|e[S+13]<<8|e[S+14]<<16|e[S+15]<<24,p=a(p=s(p,b),15),u=a(u^=p=s(p,w),19),u=s(u+=d,5)+1444728091,g=a(g=s(g,w),16),d=a(d^=g=s(g,v),17),d=s(d+=h,5)+197830471,m=a(m=s(m,v),17),h=a(h^=m=s(m,E),15),h=s(h+=f,5)+2530024501,y=a(y=s(y,E),18),f=a(f^=y=s(y,b),13),f=s(f+=u,5)+850148119;switch(p=0,g=0,m=0,y=0,n){case 15:y^=e[S+14]<<16;case 14:y^=e[S+13]<<8;case 13:y=s(y^=e[S+12],E),f^=y=s(y=a(y,18),b);case 12:m^=e[S+11]<<24;case 11:m^=e[S+10]<<16;case 10:m^=e[S+9]<<8;case 9:m=s(m^=e[S+8],v),h^=m=s(m=a(m,17),E);case 8:g^=e[S+7]<<24;case 7:g^=e[S+6]<<16;case 6:g^=e[S+5]<<8;case 5:g=s(g^=e[S+4],w),d^=g=s(g=a(g,16),v);case 4:p^=e[S+3]<<24;case 3:p^=e[S+2]<<16;case 2:p^=e[S+1]<<8;case 1:p=s(p^=e[S],b),u^=p=s(p=a(p,15),w)}return u^=e.length,u+=d^=e.length,u+=h^=e.length,d+=u+=f^=e.length,h+=u,f+=u,u=l(u),u+=d=l(d),u+=h=l(h),d+=u+=f=l(f),h+=u,f+=u,("00000000"+(u>>>0).toString(16)).slice(-8)+("00000000"+(d>>>0).toString(16)).slice(-8)+("00000000"+(h>>>0).toString(16)).slice(-8)+("00000000"+(f>>>0).toString(16)).slice(-8)},o.x64.hash128=function(e,t){if(o.inputValidation&&!i(e))return r;t=t||0;for(var n=e.length%16,s=e.length-n,a=[0,t],l=[0,t],g=[0,0],m=[0,0],y=[2277735313,289559509],b=[1291169091,658871167],w=0;w<s;w+=16)g=[e[w+4]|e[w+5]<<8|e[w+6]<<16|e[w+7]<<24,e[w]|e[w+1]<<8|e[w+2]<<16|e[w+3]<<24],m=[e[w+12]|e[w+13]<<8|e[w+14]<<16|e[w+15]<<24,e[w+8]|e[w+9]<<8|e[w+10]<<16|e[w+11]<<24],g=d(g=u(g,y),31),a=c(a=d(a=f(a,g=u(g,b)),27),l),a=c(u(a,[0,5]),[0,1390208809]),m=d(m=u(m,b),33),l=c(l=d(l=f(l,m=u(m,y)),31),a),l=c(u(l,[0,5]),[0,944331445]);switch(g=[0,0],m=[0,0],n){case 15:m=f(m,h([0,e[w+14]],48));case 14:m=f(m,h([0,e[w+13]],40));case 13:m=f(m,h([0,e[w+12]],32));case 12:m=f(m,h([0,e[w+11]],24));case 11:m=f(m,h([0,e[w+10]],16));case 10:m=f(m,h([0,e[w+9]],8));case 9:m=u(m=f(m,[0,e[w+8]]),b),l=f(l,m=u(m=d(m,33),y));case 8:g=f(g,h([0,e[w+7]],56));case 7:g=f(g,h([0,e[w+6]],48));case 6:g=f(g,h([0,e[w+5]],40));case 5:g=f(g,h([0,e[w+4]],32));case 4:g=f(g,h([0,e[w+3]],24));case 3:g=f(g,h([0,e[w+2]],16));case 2:g=f(g,h([0,e[w+1]],8));case 1:g=u(g=f(g,[0,e[w]]),y),a=f(a,g=u(g=d(g,31),b))}return a=c(a=f(a,[0,e.length]),l=f(l,[0,e.length])),l=c(l,a),a=c(a=p(a),l=p(l)),l=c(l,a),("00000000"+(a[0]>>>0).toString(16)).slice(-8)+("00000000"+(a[1]>>>0).toString(16)).slice(-8)+("00000000"+(l[0]>>>0).toString(16)).slice(-8)+("00000000"+(l[1]>>>0).toString(16)).slice(-8)},e.exports&&(t=e.exports=o),t.murmurHash3=o}()},7364:function(e,t){(function(){var e,n,r,o,i,s,a,l;l=function(e){return[(e&255<<24)>>>24,(e&255<<16)>>>16,(65280&e)>>>8,255&e].join(".")},a=function(e){var t,r,o,i,s,a;for(t=[],o=i=0;i<=3&&0!==e.length;o=++i){if(o>0){if("."!==e[0])throw new Error("Invalid IP");e=e.substring(1)}s=(a=n(e))[0],r=a[1],e=e.substring(r),t.push(s)}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")}},o=(r=function(e){return e.charCodeAt(0)})("0"),s=r("a"),i=r("A"),n=function(e){var t,n,a,l,c;for(l=0,t=10,n="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,n="7")),c=a;a<e.length;){if("0"<=e[a]&&e[a]<=n)l=l*t+(r(e[a])-o)>>>0;else{if(16!==t)break;if("a"<=e[a]&&e[a]<="f")l=l*t+(10+r(e[a])-s)>>>0;else{if(!("A"<=e[a]&&e[a]<="F"))break;l=l*t+(10+r(e[a])-i)>>>0}}if(l>4294967295)throw new Error("too large");a++}if(a===c)throw new Error("empty octet");return[l,a]},e=function(){function e(e,t){var n,r,o;if("string"!==typeof e)throw new Error("Missing `net' parameter");if(t||(o=e.split("/",2),e=o[0],t=o[1]),t||(t=32),"string"===typeof t&&t.indexOf(".")>-1){try{this.maskLong=a(t)}catch(i){throw new Error("Invalid mask: "+t)}for(n=r=32;r>=0;n=--r)if(this.maskLong===4294967295<<32-n>>>0){this.bitmask=n;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(i){throw 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=l(this.netLong),this.mask=l(this.maskLong),this.hostmask=l(~this.maskLong),this.first=this.bitmask<=30?l(this.netLong+1):this.base,this.last=this.bitmask<=30?l(this.netLong+this.size-2):l(this.netLong+this.size-1),this.broadcast=this.bitmask<=30?l(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(l(this.netLong+this.size*t),this.mask)},e.prototype.forEach=function(e){var t,n,r;for(r=a(this.first),n=a(this.last),t=0;r<=n;)e(l(r),r,t),t++,r++},e.prototype.toString=function(){return this.base+"/"+this.bitmask},e}(),t.ip2long=a,t.long2ip=l,t.Netmask=e}).call(this)},7465:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function o(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function i(e,t,r,i,s){if("function"!==typeof r)throw new TypeError("The listener must be a function");var a=new o(r,i||e,s),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function s(e,t){0===--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,o=[];if(0===this._eventsCount)return o;for(r in e=this._events)t.call(e,r)&&o.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var o=0,i=r.length,s=new Array(i);o<i;o++)s[o]=r[o].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,o,i,s){var a=n?n+e:e;if(!this._events[a])return!1;var l,c,u=this._events[a],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,o),!0;case 5:return u.fn.call(u.context,t,r,o,i),!0;case 6:return u.fn.call(u.context,t,r,o,i,s),!0}for(c=1,l=new Array(d-1);c<d;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var h,f=u.length;for(c=0;c<f;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),d){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,r);break;case 4:u[c].fn.call(u[c].context,t,r,o);break;default:if(!l)for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];u[c].fn.apply(u[c].context,l)}}return!0},a.prototype.on=function(e,t,n){return i(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return i(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,o){var i=n?n+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||o&&!a.once||r&&a.context!==r||s(this,i);else{for(var l=0,c=[],u=a.length;l<u;l++)(a[l].fn!==t||o&&!a[l].once||r&&a[l].context!==r)&&c.push(a[l]);c.length?this._events[i]=1===c.length?c[0]:c:s(this,i)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},4412:(e,t,n)=>{"use strict";e.exports=n(4573)},908:e=>{"use strict";e.exports=r;var t,n=/\/|\./;function r(e,t){n.test(e)||(e="google/protobuf/"+e+".proto",t={nested:{google:{nested:{protobuf:{nested:t}}}}}),r[e]=t}r("any",{Any:{fields:{type_url:{type:"string",id:1},value:{type:"bytes",id:2}}}}),r("duration",{Duration:t={fields:{seconds:{type:"int64",id:1},nanos:{type:"int32",id:2}}}}),r("timestamp",{Timestamp:t}),r("empty",{Empty:{fields:{}}}),r("struct",{Struct:{fields:{fields:{keyType:"string",type:"Value",id:1}}},Value:{oneofs:{kind:{oneof:["nullValue","numberValue","stringValue","boolValue","structValue","listValue"]}},fields:{nullValue:{type:"NullValue",id:1},numberValue:{type:"double",id:2},stringValue:{type:"string",id:3},boolValue:{type:"bool",id:4},structValue:{type:"Struct",id:5},listValue:{type:"ListValue",id:6}}},NullValue:{values:{NULL_VALUE:0}},ListValue:{fields:{values:{rule:"repeated",type:"Value",id:1}}}}),r("wrappers",{DoubleValue:{fields:{value:{type:"double",id:1}}},FloatValue:{fields:{value:{type:"float",id:1}}},Int64Value:{fields:{value:{type:"int64",id:1}}},UInt64Value:{fields:{value:{type:"uint64",id:1}}},Int32Value:{fields:{value:{type:"int32",id:1}}},UInt32Value:{fields:{value:{type:"uint32",id:1}}},BoolValue:{fields:{value:{type:"bool",id:1}}},StringValue:{fields:{value:{type:"string",id:1}}},BytesValue:{fields:{value:{type:"bytes",id:1}}}}),r("field_mask",{FieldMask:{fields:{paths:{rule:"repeated",type:"string",id:1}}}}),r.get=function(e){return r[e]||null}},1561:(e,t,n)=>{"use strict";var r=t,o=n(1220),i=n(9469);function s(e,t,n,r){var i=!1;if(t.resolvedType)if(t.resolvedType instanceof o){e("switch(d%s){",r);for(var s=t.resolvedType.values,a=Object.keys(s),l=0;l<a.length;++l)s[a[l]]!==t.typeDefault||i||(e("default:")('if(typeof(d%s)==="number"){m%s=d%s;break}',r,r,r),t.repeated||e("break"),i=!0),e("case%j:",a[l])("case %i:",s[a[l]])("m%s=%j",r,s[a[l]])("break");e("}")}else e('if(typeof d%s!=="object")',r)("throw TypeError(%j)",t.fullName+": object expected")("m%s=types[%i].fromObject(d%s)",r,n,r);else{var c=!1;switch(t.type){case"double":case"float":e("m%s=Number(d%s)",r,r);break;case"uint32":case"fixed32":e("m%s=d%s>>>0",r,r);break;case"int32":case"sint32":case"sfixed32":e("m%s=d%s|0",r,r);break;case"uint64":c=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e("if(util.Long)")("(m%s=util.Long.fromValue(d%s)).unsigned=%j",r,r,c)('else if(typeof d%s==="string")',r)("m%s=parseInt(d%s,10)",r,r)('else if(typeof d%s==="number")',r)("m%s=d%s",r,r)('else if(typeof d%s==="object")',r)("m%s=new util.LongBits(d%s.low>>>0,d%s.high>>>0).toNumber(%s)",r,r,r,c?"true":"");break;case"bytes":e('if(typeof d%s==="string")',r)("util.base64.decode(d%s,m%s=util.newBuffer(util.base64.length(d%s)),0)",r,r,r)("else if(d%s.length >= 0)",r)("m%s=d%s",r,r);break;case"string":e("m%s=String(d%s)",r,r);break;case"bool":e("m%s=Boolean(d%s)",r,r)}}return e}function a(e,t,n,r){if(t.resolvedType)t.resolvedType instanceof o?e("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s",r,n,r,r,n,r,r):e("d%s=types[%i].toObject(m%s,o)",r,n,r);else{var i=!1;switch(t.type){case"double":case"float":e("d%s=o.json&&!isFinite(m%s)?String(m%s):m%s",r,r,r,r);break;case"uint64":i=!0;case"int64":case"sint64":case"fixed64":case"sfixed64":e('if(typeof m%s==="number")',r)("d%s=o.longs===String?String(m%s):m%s",r,r,r)("else")("d%s=o.longs===String?util.Long.prototype.toString.call(m%s):o.longs===Number?new util.LongBits(m%s.low>>>0,m%s.high>>>0).toNumber(%s):m%s",r,r,r,r,i?"true":"",r);break;case"bytes":e("d%s=o.bytes===String?util.base64.encode(m%s,0,m%s.length):o.bytes===Array?Array.prototype.slice.call(m%s):m%s",r,r,r,r,r);break;default:e("d%s=m%s",r,r)}}return e}r.fromObject=function(e){var t=e.fieldsArray,n=i.codegen(["d"],e.name+"$fromObject")("if(d instanceof this.ctor)")("return d");if(!t.length)return n("return new this.ctor");n("var m=new this.ctor");for(var r=0;r<t.length;++r){var a=t[r].resolve(),l=i.safeProp(a.name);a.map?(n("if(d%s){",l)('if(typeof d%s!=="object")',l)("throw TypeError(%j)",a.fullName+": object expected")("m%s={}",l)("for(var ks=Object.keys(d%s),i=0;i<ks.length;++i){",l),s(n,a,r,l+"[ks[i]]")("}")("}")):a.repeated?(n("if(d%s){",l)("if(!Array.isArray(d%s))",l)("throw TypeError(%j)",a.fullName+": array expected")("m%s=[]",l)("for(var i=0;i<d%s.length;++i){",l),s(n,a,r,l+"[i]")("}")("}")):(a.resolvedType instanceof o||n("if(d%s!=null){",l),s(n,a,r,l),a.resolvedType instanceof o||n("}"))}return n("return m")},r.toObject=function(e){var t=e.fieldsArray.slice().sort(i.compareFieldsById);if(!t.length)return i.codegen()("return {}");for(var n=i.codegen(["m","o"],e.name+"$toObject")("if(!o)")("o={}")("var d={}"),r=[],s=[],l=[],c=0;c<t.length;++c)t[c].partOf||(t[c].resolve().repeated?r:t[c].map?s:l).push(t[c]);if(r.length){for(n("if(o.arrays||o.defaults){"),c=0;c<r.length;++c)n("d%s=[]",i.safeProp(r[c].name));n("}")}if(s.length){for(n("if(o.objects||o.defaults){"),c=0;c<s.length;++c)n("d%s={}",i.safeProp(s[c].name));n("}")}if(l.length){for(n("if(o.defaults){"),c=0;c<l.length;++c){var u=l[c],d=i.safeProp(u.name);if(u.resolvedType instanceof o)n("d%s=o.enums===String?%j:%j",d,u.resolvedType.valuesById[u.typeDefault],u.typeDefault);else if(u.long)n("if(util.Long){")("var n=new util.Long(%i,%i,%j)",u.typeDefault.low,u.typeDefault.high,u.typeDefault.unsigned)("d%s=o.longs===String?n.toString():o.longs===Number?n.toNumber():n",d)("}else")("d%s=o.longs===String?%j:%i",d,u.typeDefault.toString(),u.typeDefault.toNumber());else if(u.bytes){var h="["+Array.prototype.slice.call(u.typeDefault).join(",")+"]";n("if(o.bytes===String)d%s=%j",d,String.fromCharCode.apply(String,u.typeDefault))("else{")("d%s=%s",d,h)("if(o.bytes!==Array)d%s=util.newBuffer(d%s)",d,d)("}")}else n("d%s=%j",d,u.typeDefault)}n("}")}var f=!1;for(c=0;c<t.length;++c){u=t[c];var p=e._fieldsArray.indexOf(u);d=i.safeProp(u.name);u.map?(f||(f=!0,n("var ks2")),n("if(m%s&&(ks2=Object.keys(m%s)).length){",d,d)("d%s={}",d)("for(var j=0;j<ks2.length;++j){"),a(n,u,p,d+"[ks2[j]]")("}")):u.repeated?(n("if(m%s&&m%s.length){",d,d)("d%s=[]",d)("for(var j=0;j<m%s.length;++j){",d),a(n,u,p,d+"[j]")("}")):(n("if(m%s!=null&&m.hasOwnProperty(%j)){",d,u.name),a(n,u,p,d),u.partOf&&n("if(o.oneofs)")("d%s=%j",i.safeProp(u.partOf.name),u.name)),n("}")}return n("return d")}},1985:(e,t,n)=>{"use strict";e.exports=function(e){var t=i.codegen(["r","l"],e.name+"$decode")("if(!(r instanceof Reader))")("r=Reader.create(r)")("var c=l===undefined?r.len:r.pos+l,m=new this.ctor"+(e.fieldsArray.filter((function(e){return e.map})).length?",k,value":""))("while(r.pos<c){")("var t=r.uint32()");e.group&&t("if((t&7)===4)")("break");t("switch(t>>>3){");for(var n=0;n<e.fieldsArray.length;++n){var a=e._fieldsArray[n].resolve(),l=a.resolvedType instanceof r?"int32":a.type,c="m"+i.safeProp(a.name);t("case %i: {",a.id),a.map?(t("if(%s===util.emptyObject)",c)("%s={}",c)("var c2 = r.uint32()+r.pos"),void 0!==o.defaults[a.keyType]?t("k=%j",o.defaults[a.keyType]):t("k=null"),void 0!==o.defaults[l]?t("value=%j",o.defaults[l]):t("value=null"),t("while(r.pos<c2){")("var tag2=r.uint32()")("switch(tag2>>>3){")("case 1: k=r.%s(); break",a.keyType)("case 2:"),void 0===o.basic[l]?t("value=types[%i].decode(r,r.uint32())",n):t("value=r.%s()",l),t("break")("default:")("r.skipType(tag2&7)")("break")("}")("}"),void 0!==o.long[a.keyType]?t('%s[typeof k==="object"?util.longToHash(k):k]=value',c):t("%s[k]=value",c)):a.repeated?(t("if(!(%s&&%s.length))",c,c)("%s=[]",c),void 0!==o.packed[l]&&t("if((t&7)===2){")("var c2=r.uint32()+r.pos")("while(r.pos<c2)")("%s.push(r.%s())",c,l)("}else"),void 0===o.basic[l]?t(a.resolvedType.group?"%s.push(types[%i].decode(r))":"%s.push(types[%i].decode(r,r.uint32()))",c,n):t("%s.push(r.%s())",c,l)):void 0===o.basic[l]?t(a.resolvedType.group?"%s=types[%i].decode(r)":"%s=types[%i].decode(r,r.uint32())",c,n):t("%s=r.%s()",c,l),t("break")("}")}for(t("default:")("r.skipType(t&7)")("break")("}")("}"),n=0;n<e._fieldsArray.length;++n){var u=e._fieldsArray[n];u.required&&t("if(!m.hasOwnProperty(%j))",u.name)("throw util.ProtocolError(%j,{instance:m})",s(u))}return t("return m")};var r=n(1220),o=n(9876),i=n(9469);function s(e){return"missing required '"+e.name+"'"}},7573:(e,t,n)=>{"use strict";e.exports=function(e){for(var t,n=i.codegen(["m","w"],e.name+"$encode")("if(!w)")("w=Writer.create()"),a=e.fieldsArray.slice().sort(i.compareFieldsById),l=0;l<a.length;++l){var c=a[l].resolve(),u=e._fieldsArray.indexOf(c),d=c.resolvedType instanceof r?"int32":c.type,h=o.basic[d];t="m"+i.safeProp(c.name),c.map?(n("if(%s!=null&&Object.hasOwnProperty.call(m,%j)){",t,c.name)("for(var ks=Object.keys(%s),i=0;i<ks.length;++i){",t)("w.uint32(%i).fork().uint32(%i).%s(ks[i])",(c.id<<3|2)>>>0,8|o.mapKey[c.keyType],c.keyType),void 0===h?n("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()",u,t):n(".uint32(%i).%s(%s[ks[i]]).ldelim()",16|h,d,t),n("}")("}")):c.repeated?(n("if(%s!=null&&%s.length){",t,t),c.packed&&void 0!==o.packed[d]?n("w.uint32(%i).fork()",(c.id<<3|2)>>>0)("for(var i=0;i<%s.length;++i)",t)("w.%s(%s[i])",d,t)("w.ldelim()"):(n("for(var i=0;i<%s.length;++i)",t),void 0===h?s(n,c,u,t+"[i]"):n("w.uint32(%i).%s(%s[i])",(c.id<<3|h)>>>0,d,t)),n("}")):(c.optional&&n("if(%s!=null&&Object.hasOwnProperty.call(m,%j))",t,c.name),void 0===h?s(n,c,u,t):n("w.uint32(%i).%s(%s)",(c.id<<3|h)>>>0,d,t))}return n("return w")};var r=n(1220),o=n(9876),i=n(9469);function s(e,t,n,r){return t.resolvedType.group?e("types[%i].encode(%s,w.uint32(%i)).uint32(%i)",n,r,(t.id<<3|3)>>>0,(t.id<<3|4)>>>0):e("types[%i].encode(%s,w.uint32(%i).fork()).ldelim()",n,r,(t.id<<3|2)>>>0)}},1220:(e,t,n)=>{"use strict";e.exports=s;var r=n(6046);((s.prototype=Object.create(r.prototype)).constructor=s).className="Enum";var o=n(1374),i=n(9469);function s(e,t,n,o,i,s){if(r.call(this,e,n),t&&"object"!==typeof t)throw TypeError("values must be an object");if(this.valuesById={},this.values=Object.create(this.valuesById),this.comment=o,this.comments=i||{},this.valuesOptions=s,this.reserved=void 0,t)for(var a=Object.keys(t),l=0;l<a.length;++l)"number"===typeof t[a[l]]&&(this.valuesById[this.values[a[l]]=t[a[l]]]=a[l])}s.fromJSON=function(e,t){var n=new s(e,t.values,t.options,t.comment,t.comments);return n.reserved=t.reserved,n},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return i.toObject(["options",this.options,"valuesOptions",this.valuesOptions,"values",this.values,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"comment",t?this.comment:void 0,"comments",t?this.comments:void 0])},s.prototype.add=function(e,t,n,r){if(!i.isString(e))throw TypeError("name must be a string");if(!i.isInteger(t))throw TypeError("id must be an integer");if(void 0!==this.values[e])throw Error("duplicate name '"+e+"' in "+this);if(this.isReservedId(t))throw Error("id "+t+" is reserved in "+this);if(this.isReservedName(e))throw Error("name '"+e+"' is reserved in "+this);if(void 0!==this.valuesById[t]){if(!this.options||!this.options.allow_alias)throw Error("duplicate id "+t+" in "+this);this.values[e]=t}else this.valuesById[this.values[e]=t]=e;return r&&(void 0===this.valuesOptions&&(this.valuesOptions={}),this.valuesOptions[e]=r||null),this.comments[e]=n||null,this},s.prototype.remove=function(e){if(!i.isString(e))throw TypeError("name must be a string");var t=this.values[e];if(null==t)throw Error("name '"+e+"' does not exist in "+this);return delete this.valuesById[t],delete this.values[e],delete this.comments[e],this.valuesOptions&&delete this.valuesOptions[e],this},s.prototype.isReservedId=function(e){return o.isReservedId(this.reserved,e)},s.prototype.isReservedName=function(e){return o.isReservedName(this.reserved,e)}},9229:(e,t,n)=>{"use strict";e.exports=c;var r=n(6046);((c.prototype=Object.create(r.prototype)).constructor=c).className="Field";var o,i=n(1220),s=n(9876),a=n(9469),l=/^required|optional|repeated$/;function c(e,t,n,o,i,c,u){if(a.isObject(o)?(u=i,c=o,o=i=void 0):a.isObject(i)&&(u=c,c=i,i=void 0),r.call(this,e,c),!a.isInteger(t)||t<0)throw TypeError("id must be a non-negative integer");if(!a.isString(n))throw TypeError("type must be a string");if(void 0!==o&&!l.test(o=o.toString().toLowerCase()))throw TypeError("rule must be a string rule");if(void 0!==i&&!a.isString(i))throw TypeError("extend must be a string");"proto3_optional"===o&&(o="optional"),this.rule=o&&"optional"!==o?o:void 0,this.type=n,this.id=t,this.extend=i||void 0,this.required="required"===o,this.optional=!this.required,this.repeated="repeated"===o,this.map=!1,this.message=null,this.partOf=null,this.typeDefault=null,this.defaultValue=null,this.long=!!a.Long&&void 0!==s.long[n],this.bytes="bytes"===n,this.resolvedType=null,this.extensionField=null,this.declaringField=null,this._packed=null,this.comment=u}c.fromJSON=function(e,t){return new c(e,t.id,t.type,t.rule,t.extend,t.options,t.comment)},Object.defineProperty(c.prototype,"packed",{get:function(){return null===this._packed&&(this._packed=!1!==this.getOption("packed")),this._packed}}),c.prototype.setOption=function(e,t,n){return"packed"===e&&(this._packed=null),r.prototype.setOption.call(this,e,t,n)},c.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return a.toObject(["rule","optional"!==this.rule&&this.rule||void 0,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},c.prototype.resolve=function(){if(this.resolved)return this;if(void 0===(this.typeDefault=s.defaults[this.type])?(this.resolvedType=(this.declaringField?this.declaringField.parent:this.parent).lookupTypeOrEnum(this.type),this.resolvedType instanceof o?this.typeDefault=null:this.typeDefault=this.resolvedType.values[Object.keys(this.resolvedType.values)[0]]):this.options&&this.options.proto3_optional&&(this.typeDefault=null),this.options&&null!=this.options.default&&(this.typeDefault=this.options.default,this.resolvedType instanceof i&&"string"===typeof this.typeDefault&&(this.typeDefault=this.resolvedType.values[this.typeDefault])),this.options&&(!0!==this.options.packed&&(void 0===this.options.packed||!this.resolvedType||this.resolvedType instanceof i)||delete this.options.packed,Object.keys(this.options).length||(this.options=void 0)),this.long)this.typeDefault=a.Long.fromNumber(this.typeDefault,"u"===this.type.charAt(0)),Object.freeze&&Object.freeze(this.typeDefault);else if(this.bytes&&"string"===typeof this.typeDefault){var e;a.base64.test(this.typeDefault)?a.base64.decode(this.typeDefault,e=a.newBuffer(a.base64.length(this.typeDefault)),0):a.utf8.write(this.typeDefault,e=a.newBuffer(a.utf8.length(this.typeDefault)),0),this.typeDefault=e}return this.map?this.defaultValue=a.emptyObject:this.repeated?this.defaultValue=a.emptyArray:this.defaultValue=this.typeDefault,this.parent instanceof o&&(this.parent.ctor.prototype[this.name]=this.defaultValue),r.prototype.resolve.call(this)},c.d=function(e,t,n,r){return"function"===typeof t?t=a.decorateType(t).name:t&&"object"===typeof t&&(t=a.decorateEnum(t).name),function(o,i){a.decorateType(o.constructor).add(new c(i,e,t,n,{default:r}))}},c._configure=function(e){o=e}},7916:(e,t,n)=>{"use strict";var r=e.exports=n(9191);r.build="light",r.load=function(e,t,n){return"function"===typeof t?(n=t,t=new r.Root):t||(t=new r.Root),t.load(e,n)},r.loadSync=function(e,t){return t||(t=new r.Root),t.loadSync(e)},r.encoder=n(7573),r.decoder=n(1985),r.verifier=n(9875),r.converter=n(1561),r.ReflectionObject=n(6046),r.Namespace=n(1374),r.Root=n(7149),r.Enum=n(1220),r.Type=n(2225),r.Field=n(9229),r.OneOf=n(2924),r.MapField=n(4635),r.Service=n(6366),r.Method=n(360),r.Message=n(7886),r.wrappers=n(9297),r.types=n(9876),r.util=n(9469),r.ReflectionObject._configure(r.Root),r.Namespace._configure(r.Type,r.Service,r.Enum),r.Root._configure(r.Type),r.Field._configure(r.Type)},9191:(e,t,n)=>{"use strict";var r=t;function o(){r.util._configure(),r.Writer._configure(r.BufferWriter),r.Reader._configure(r.BufferReader)}r.build="minimal",r.Writer=n(5850),r.BufferWriter=n(3931),r.Reader=n(3338),r.BufferReader=n(7707),r.util=n(1509),r.rpc=n(8094),r.roots=n(1368),r.configure=o,o()},4573:(e,t,n)=>{"use strict";var r=e.exports=n(7916);r.build="full",r.tokenize=n(1752),r.parse=n(2786),r.common=n(908),r.Root._configure(r.Type,r.parse,r.common)},4635:(e,t,n)=>{"use strict";e.exports=s;var r=n(9229);((s.prototype=Object.create(r.prototype)).constructor=s).className="MapField";var o=n(9876),i=n(9469);function s(e,t,n,o,s,a){if(r.call(this,e,t,o,void 0,void 0,s,a),!i.isString(n))throw TypeError("keyType must be a string");this.keyType=n,this.resolvedKeyType=null,this.map=!0}s.fromJSON=function(e,t){return new s(e,t.id,t.keyType,t.type,t.options,t.comment)},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return i.toObject(["keyType",this.keyType,"type",this.type,"id",this.id,"extend",this.extend,"options",this.options,"comment",t?this.comment:void 0])},s.prototype.resolve=function(){if(this.resolved)return this;if(void 0===o.mapKey[this.keyType])throw Error("invalid key type: "+this.keyType);return r.prototype.resolve.call(this)},s.d=function(e,t,n){return"function"===typeof n?n=i.decorateType(n).name:n&&"object"===typeof n&&(n=i.decorateEnum(n).name),function(r,o){i.decorateType(r.constructor).add(new s(o,e,t,n))}}},7886:(e,t,n)=>{"use strict";e.exports=o;var r=n(1509);function o(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)this[t[n]]=e[t[n]]}o.create=function(e){return this.$type.create(e)},o.encode=function(e,t){return this.$type.encode(e,t)},o.encodeDelimited=function(e,t){return this.$type.encodeDelimited(e,t)},o.decode=function(e){return this.$type.decode(e)},o.decodeDelimited=function(e){return this.$type.decodeDelimited(e)},o.verify=function(e){return this.$type.verify(e)},o.fromObject=function(e){return this.$type.fromObject(e)},o.toObject=function(e,t){return this.$type.toObject(e,t)},o.prototype.toJSON=function(){return this.$type.toObject(this,r.toJSONOptions)}},360:(e,t,n)=>{"use strict";e.exports=i;var r=n(6046);((i.prototype=Object.create(r.prototype)).constructor=i).className="Method";var o=n(9469);function i(e,t,n,i,s,a,l,c,u){if(o.isObject(s)?(l=s,s=a=void 0):o.isObject(a)&&(l=a,a=void 0),void 0!==t&&!o.isString(t))throw TypeError("type must be a string");if(!o.isString(n))throw TypeError("requestType must be a string");if(!o.isString(i))throw TypeError("responseType must be a string");r.call(this,e,l),this.type=t||"rpc",this.requestType=n,this.requestStream=!!s||void 0,this.responseType=i,this.responseStream=!!a||void 0,this.resolvedRequestType=null,this.resolvedResponseType=null,this.comment=c,this.parsedOptions=u}i.fromJSON=function(e,t){return new i(e,t.type,t.requestType,t.responseType,t.requestStream,t.responseStream,t.options,t.comment,t.parsedOptions)},i.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return o.toObject(["type","rpc"!==this.type&&this.type||void 0,"requestType",this.requestType,"requestStream",this.requestStream,"responseType",this.responseType,"responseStream",this.responseStream,"options",this.options,"comment",t?this.comment:void 0,"parsedOptions",this.parsedOptions])},i.prototype.resolve=function(){return this.resolved?this:(this.resolvedRequestType=this.parent.lookupType(this.requestType),this.resolvedResponseType=this.parent.lookupType(this.responseType),r.prototype.resolve.call(this))}},1374:(e,t,n)=>{"use strict";e.exports=d;var r=n(6046);((d.prototype=Object.create(r.prototype)).constructor=d).className="Namespace";var o,i,s,a=n(9229),l=n(9469),c=n(2924);function u(e,t){if(e&&e.length){for(var n={},r=0;r<e.length;++r)n[e[r].name]=e[r].toJSON(t);return n}}function d(e,t){r.call(this,e,t),this.nested=void 0,this._nestedArray=null}function h(e){return e._nestedArray=null,e}d.fromJSON=function(e,t){return new d(e,t.options).addJSON(t.nested)},d.arrayToJSON=u,d.isReservedId=function(e,t){if(e)for(var n=0;n<e.length;++n)if("string"!==typeof e[n]&&e[n][0]<=t&&e[n][1]>t)return!0;return!1},d.isReservedName=function(e,t){if(e)for(var n=0;n<e.length;++n)if(e[n]===t)return!0;return!1},Object.defineProperty(d.prototype,"nestedArray",{get:function(){return this._nestedArray||(this._nestedArray=l.toArray(this.nested))}}),d.prototype.toJSON=function(e){return l.toObject(["options",this.options,"nested",u(this.nestedArray,e)])},d.prototype.addJSON=function(e){if(e)for(var t,n=Object.keys(e),r=0;r<n.length;++r)t=e[n[r]],this.add((void 0!==t.fields?o.fromJSON:void 0!==t.values?s.fromJSON:void 0!==t.methods?i.fromJSON:void 0!==t.id?a.fromJSON:d.fromJSON)(n[r],t));return this},d.prototype.get=function(e){return this.nested&&this.nested[e]||null},d.prototype.getEnum=function(e){if(this.nested&&this.nested[e]instanceof s)return this.nested[e].values;throw Error("no such enum: "+e)},d.prototype.add=function(e){if(!(e instanceof a&&void 0!==e.extend||e instanceof o||e instanceof c||e instanceof s||e instanceof i||e instanceof d))throw TypeError("object must be a valid nested object");if(this.nested){var t=this.get(e.name);if(t){if(!(t instanceof d&&e instanceof d)||t instanceof o||t instanceof i)throw Error("duplicate name '"+e.name+"' in "+this);for(var n=t.nestedArray,r=0;r<n.length;++r)e.add(n[r]);this.remove(t),this.nested||(this.nested={}),e.setOptions(t.options,!0)}}else this.nested={};return this.nested[e.name]=e,e.onAdd(this),h(this)},d.prototype.remove=function(e){if(!(e instanceof r))throw TypeError("object must be a ReflectionObject");if(e.parent!==this)throw Error(e+" is not a member of "+this);return delete this.nested[e.name],Object.keys(this.nested).length||(this.nested=void 0),e.onRemove(this),h(this)},d.prototype.define=function(e,t){if(l.isString(e))e=e.split(".");else if(!Array.isArray(e))throw TypeError("illegal path");if(e&&e.length&&""===e[0])throw Error("path must be relative");for(var n=this;e.length>0;){var r=e.shift();if(n.nested&&n.nested[r]){if(!((n=n.nested[r])instanceof d))throw Error("path conflicts with non-namespace objects")}else n.add(n=new d(r))}return t&&n.addJSON(t),n},d.prototype.resolveAll=function(){for(var e=this.nestedArray,t=0;t<e.length;)e[t]instanceof d?e[t++].resolveAll():e[t++].resolve();return this.resolve()},d.prototype.lookup=function(e,t,n){if("boolean"===typeof t?(n=t,t=void 0):t&&!Array.isArray(t)&&(t=[t]),l.isString(e)&&e.length){if("."===e)return this.root;e=e.split(".")}else if(!e.length)return this;if(""===e[0])return this.root.lookup(e.slice(1),t);var r=this.get(e[0]);if(r){if(1===e.length){if(!t||t.indexOf(r.constructor)>-1)return r}else if(r instanceof d&&(r=r.lookup(e.slice(1),t,!0)))return r}else for(var o=0;o<this.nestedArray.length;++o)if(this._nestedArray[o]instanceof d&&(r=this._nestedArray[o].lookup(e,t,!0)))return r;return null===this.parent||n?null:this.parent.lookup(e,t)},d.prototype.lookupType=function(e){var t=this.lookup(e,[o]);if(!t)throw Error("no such type: "+e);return t},d.prototype.lookupEnum=function(e){var t=this.lookup(e,[s]);if(!t)throw Error("no such Enum '"+e+"' in "+this);return t},d.prototype.lookupTypeOrEnum=function(e){var t=this.lookup(e,[o,s]);if(!t)throw Error("no such Type or Enum '"+e+"' in "+this);return t},d.prototype.lookupService=function(e){var t=this.lookup(e,[i]);if(!t)throw Error("no such Service '"+e+"' in "+this);return t},d._configure=function(e,t,n){o=e,i=t,s=n}},6046:(e,t,n)=>{"use strict";e.exports=i,i.className="ReflectionObject";var r,o=n(9469);function i(e,t){if(!o.isString(e))throw TypeError("name must be a string");if(t&&!o.isObject(t))throw TypeError("options must be an object");this.options=t,this.parsedOptions=null,this.name=e,this.parent=null,this.resolved=!1,this.comment=null,this.filename=null}Object.defineProperties(i.prototype,{root:{get:function(){for(var e=this;null!==e.parent;)e=e.parent;return e}},fullName:{get:function(){for(var e=[this.name],t=this.parent;t;)e.unshift(t.name),t=t.parent;return e.join(".")}}}),i.prototype.toJSON=function(){throw Error()},i.prototype.onAdd=function(e){this.parent&&this.parent!==e&&this.parent.remove(this),this.parent=e,this.resolved=!1;var t=e.root;t instanceof r&&t._handleAdd(this)},i.prototype.onRemove=function(e){var t=e.root;t instanceof r&&t._handleRemove(this),this.parent=null,this.resolved=!1},i.prototype.resolve=function(){return this.resolved||this.root instanceof r&&(this.resolved=!0),this},i.prototype.getOption=function(e){if(this.options)return this.options[e]},i.prototype.setOption=function(e,t,n){return n&&this.options&&void 0!==this.options[e]||((this.options||(this.options={}))[e]=t),this},i.prototype.setParsedOption=function(e,t,n){this.parsedOptions||(this.parsedOptions=[]);var r=this.parsedOptions;if(n){var i=r.find((function(t){return Object.prototype.hasOwnProperty.call(t,e)}));if(i){var s=i[e];o.setProperty(s,n,t)}else(i={})[e]=o.setProperty({},n,t),r.push(i)}else{var a={};a[e]=t,r.push(a)}return this},i.prototype.setOptions=function(e,t){if(e)for(var n=Object.keys(e),r=0;r<n.length;++r)this.setOption(n[r],e[n[r]],t);return this},i.prototype.toString=function(){var e=this.constructor.className,t=this.fullName;return t.length?e+" "+t:e},i._configure=function(e){r=e}},2924:(e,t,n)=>{"use strict";e.exports=s;var r=n(6046);((s.prototype=Object.create(r.prototype)).constructor=s).className="OneOf";var o=n(9229),i=n(9469);function s(e,t,n,o){if(Array.isArray(t)||(n=t,t=void 0),r.call(this,e,n),void 0!==t&&!Array.isArray(t))throw TypeError("fieldNames must be an Array");this.oneof=t||[],this.fieldsArray=[],this.comment=o}function a(e){if(e.parent)for(var t=0;t<e.fieldsArray.length;++t)e.fieldsArray[t].parent||e.parent.add(e.fieldsArray[t])}s.fromJSON=function(e,t){return new s(e,t.oneof,t.options,t.comment)},s.prototype.toJSON=function(e){var t=!!e&&Boolean(e.keepComments);return i.toObject(["options",this.options,"oneof",this.oneof,"comment",t?this.comment:void 0])},s.prototype.add=function(e){if(!(e instanceof o))throw TypeError("field must be a Field");return e.parent&&e.parent!==this.parent&&e.parent.remove(e),this.oneof.push(e.name),this.fieldsArray.push(e),e.partOf=this,a(this),this},s.prototype.remove=function(e){if(!(e instanceof o))throw TypeError("field must be a Field");var t=this.fieldsArray.indexOf(e);if(t<0)throw Error(e+" is not a member of "+this);return this.fieldsArray.splice(t,1),(t=this.oneof.indexOf(e.name))>-1&&this.oneof.splice(t,1),e.partOf=null,this},s.prototype.onAdd=function(e){r.prototype.onAdd.call(this,e);for(var t=0;t<this.oneof.length;++t){var n=e.get(this.oneof[t]);n&&!n.partOf&&(n.partOf=this,this.fieldsArray.push(n))}a(this)},s.prototype.onRemove=function(e){for(var t,n=0;n<this.fieldsArray.length;++n)(t=this.fieldsArray[n]).parent&&t.parent.remove(t);r.prototype.onRemove.call(this,e)},s.d=function(){for(var e=new Array(arguments.length),t=0;t<arguments.length;)e[t]=arguments[t++];return function(t,n){i.decorateType(t.constructor).add(new s(n,e)),Object.defineProperty(t,n,{get:i.oneOfGetter(e),set:i.oneOfSetter(e)})}}},2786:(e,t,n)=>{"use strict";e.exports=A,A.filename=null,A.defaults={keepCase:!1};var r=n(1752),o=n(7149),i=n(2225),s=n(9229),a=n(4635),l=n(2924),c=n(1220),u=n(6366),d=n(360),h=n(9876),f=n(9469),p=/^[1-9][0-9]*$/,g=/^-?[1-9][0-9]*$/,m=/^0[x][0-9a-fA-F]+$/,y=/^-?0[x][0-9a-fA-F]+$/,b=/^0[0-7]+$/,w=/^-?0[0-7]+$/,v=/^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,E=/^[a-zA-Z_][a-zA-Z_0-9]*$/,S=/^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,k=/^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;function A(e,t,n){t instanceof o||(n=t,t=new o),n||(n=A.defaults);var _,I,x,C,R,T=n.preferTrailingComment||!1,N=r(e,n.alternateCommentMode||!1),P=N.next,O=N.push,L=N.peek,D=N.skip,B=N.cmnt,U=!0,M=!1,F=t,$=n.keepCase?function(e){return e}:f.camelCase;function H(e,t,n){var r=A.filename;return n||(A.filename=null),Error("illegal "+(t||"token")+" '"+e+"' ("+(r?r+", ":"")+"line "+N.line+")")}function q(){var e,t=[];do{if('"'!==(e=P())&&"'"!==e)throw H(e);t.push(P()),D(e),e=L()}while('"'===e||"'"===e);return t.join("")}function j(e){var t=P();switch(t){case"'":case'"':return O(t),q();case"true":case"TRUE":return!0;case"false":case"FALSE":return!1}try{return function(e,t){var n=1;"-"===e.charAt(0)&&(n=-1,e=e.substring(1));switch(e){case"inf":case"INF":case"Inf":return n*(1/0);case"nan":case"NAN":case"Nan":case"NaN":return NaN;case"0":return 0}if(p.test(e))return n*parseInt(e,10);if(m.test(e))return n*parseInt(e,16);if(b.test(e))return n*parseInt(e,8);if(v.test(e))return n*parseFloat(e);throw H(e,"number",t)}(t,!0)}catch(n){if(e&&S.test(t))return t;throw H(t,"value")}}function V(e,t){var n,r;do{!t||'"'!==(n=L())&&"'"!==n?e.push([r=z(P()),D("to",!0)?z(P()):r]):e.push(q())}while(D(",",!0));var o={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Q(o,(function(e){if("option"!==e)throw H(e);ee(o,e),D(";")}),(function(){re(o)}))}function z(e,t){switch(e){case"max":case"MAX":case"Max":return 536870911;case"0":return 0}if(!t&&"-"===e.charAt(0))throw H(e,"id");if(g.test(e))return parseInt(e,10);if(y.test(e))return parseInt(e,16);if(w.test(e))return parseInt(e,8);throw H(e,"id")}function K(){if(void 0!==_)throw H("package");if(_=P(),!S.test(_))throw H(_,"name");F=F.define(_),D(";")}function W(){var e,t=L();switch(t){case"weak":e=x||(x=[]),P();break;case"public":P();default:e=I||(I=[])}t=q(),D(";"),e.push(t)}function G(){if(D("="),C=q(),!(M="proto3"===C)&&"proto2"!==C)throw H(C,"syntax");t.setOption("syntax",C),D(";")}function Y(e,t){switch(t){case"option":return ee(e,t),D(";"),!0;case"message":return J(e,t),!0;case"enum":return Z(e,t),!0;case"service":return function(e,t){if(!E.test(t=P()))throw H(t,"service name");var n=new u(t);Q(n,(function(e){if(!Y(n,e)){if("rpc"!==e)throw H(e);!function(e,t){var n=B(),r=t;if(!E.test(t=P()))throw H(t,"name");var o,i,s,a,l=t;D("("),D("stream",!0)&&(i=!0);if(!S.test(t=P()))throw H(t);o=t,D(")"),D("returns"),D("("),D("stream",!0)&&(a=!0);if(!S.test(t=P()))throw H(t);s=t,D(")");var c=new d(l,r,o,s,i,a);c.comment=n,Q(c,(function(e){if("option"!==e)throw H(e);ee(c,e),D(";")})),e.add(c)}(n,e)}})),e.add(n)}(e,t),!0;case"extend":return function(e,t){if(!S.test(t=P()))throw H(t,"reference");var n=t;Q(null,(function(t){switch(t){case"required":case"repeated":X(e,t,n);break;case"optional":X(e,M?"proto3_optional":"optional",n);break;default:if(!M||!S.test(t))throw H(t);O(t),X(e,"optional",n)}}))}(e,t),!0}return!1}function Q(e,t,n){var r=N.line;if(e&&("string"!==typeof e.comment&&(e.comment=B()),e.filename=A.filename),D("{",!0)){for(var o;"}"!==(o=P());)t(o);D(";",!0)}else n&&n(),D(";"),e&&("string"!==typeof e.comment||T)&&(e.comment=B(r)||e.comment)}function J(e,t){if(!E.test(t=P()))throw H(t,"type name");var n=new i(t);Q(n,(function(e){if(!Y(n,e))switch(e){case"map":!function(e){D("<");var t=P();if(void 0===h.mapKey[t])throw H(t,"type");D(",");var n=P();if(!S.test(n))throw H(n,"type");D(">");var r=P();if(!E.test(r))throw H(r,"name");D("=");var o=new a($(r),z(P()),t,n);Q(o,(function(e){if("option"!==e)throw H(e);ee(o,e),D(";")}),(function(){re(o)})),e.add(o)}(n);break;case"required":case"repeated":X(n,e);break;case"optional":X(n,M?"proto3_optional":"optional");break;case"oneof":!function(e,t){if(!E.test(t=P()))throw H(t,"name");var n=new l($(t));Q(n,(function(e){"option"===e?(ee(n,e),D(";")):(O(e),X(n,"optional"))})),e.add(n)}(n,e);break;case"extensions":V(n.extensions||(n.extensions=[]));break;case"reserved":V(n.reserved||(n.reserved=[]),!0);break;default:if(!M||!S.test(e))throw H(e);O(e),X(n,"optional")}})),e.add(n)}function X(e,t,n){var r=P();if("group"!==r){for(;r.endsWith(".")||L().startsWith(".");)r+=P();if(!S.test(r))throw H(r,"type");var o=P();if(!E.test(o))throw H(o,"name");o=$(o),D("=");var a=new s(o,z(P()),r,t,n);if(Q(a,(function(e){if("option"!==e)throw H(e);ee(a,e),D(";")}),(function(){re(a)})),"proto3_optional"===t){var c=new l("_"+o);a.setOption("proto3_optional",!0),c.add(a),e.add(c)}else e.add(a);M||!a.repeated||void 0===h.packed[r]&&void 0!==h.basic[r]||a.setOption("packed",!1,!0)}else!function(e,t){var n=P();if(!E.test(n))throw H(n,"name");var r=f.lcFirst(n);n===r&&(n=f.ucFirst(n));D("=");var o=z(P()),a=new i(n);a.group=!0;var l=new s(r,o,n,t);l.filename=A.filename,Q(a,(function(e){switch(e){case"option":ee(a,e),D(";");break;case"required":case"repeated":X(a,e);break;case"optional":X(a,M?"proto3_optional":"optional");break;case"message":J(a,e);break;case"enum":Z(a,e);break;default:throw H(e)}})),e.add(a).add(l)}(e,t)}function Z(e,t){if(!E.test(t=P()))throw H(t,"name");var n=new c(t);Q(n,(function(e){switch(e){case"option":ee(n,e),D(";");break;case"reserved":V(n.reserved||(n.reserved=[]),!0);break;default:!function(e,t){if(!E.test(t))throw H(t,"name");D("=");var n=z(P(),!0),r={options:void 0,setOption:function(e,t){void 0===this.options&&(this.options={}),this.options[e]=t}};Q(r,(function(e){if("option"!==e)throw H(e);ee(r,e),D(";")}),(function(){re(r)})),e.add(t,n,r.comment,r.options)}(n,e)}})),e.add(n)}function ee(e,t){var n=D("(",!0);if(!S.test(t=P()))throw H(t,"name");var r,o=t,i=o;n&&(D(")"),i=o="("+o+")",t=L(),k.test(t)&&(r=t.slice(1),o+=t,P())),D("="),function(e,t,n,r){e.setParsedOption&&e.setParsedOption(t,n,r)}(e,i,te(e,o),r)}function te(e,t){if(D("{",!0)){for(var n={};!D("}",!0);){if(!E.test(R=P()))throw H(R,"name");if(null===R)throw H(R,"end of input");var r,o=R;if(D(":",!0),"{"===L())r=te(e,t+"."+R);else if("["===L()){var i;if(r=[],D("[",!0)){do{i=j(!0),r.push(i)}while(D(",",!0));D("]"),"undefined"!==typeof i&&ne(e,t+"."+R,i)}}else r=j(!0),ne(e,t+"."+R,r);var s=n[o];s&&(r=[].concat(s).concat(r)),n[o]=r,D(",",!0),D(";",!0)}return n}var a=j(!0);return ne(e,t,a),a}function ne(e,t,n){e.setOption&&e.setOption(t,n)}function re(e){if(D("[",!0)){do{ee(e,"option")}while(D(",",!0));D("]")}return e}for(;null!==(R=P());)switch(R){case"package":if(!U)throw H(R);K();break;case"import":if(!U)throw H(R);W();break;case"syntax":if(!U)throw H(R);G();break;case"option":ee(F,R),D(";");break;default:if(Y(F,R)){U=!1;continue}throw H(R)}return A.filename=null,{package:_,imports:I,weakImports:x,syntax:C,root:t}}},3338:(e,t,n)=>{"use strict";e.exports=l;var r,o=n(1509),i=o.LongBits,s=o.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function l(e){this.buf=e,this.pos=0,this.len=e.length}var c="undefined"!==typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new l(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new l(e);throw Error("illegal buffer")},u=function(){return o.Buffer?function(e){return(l.create=function(e){return o.Buffer.isBuffer(e)?new r(e):c(e)})(e)}:c};function d(){var e=new i(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 h(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 i(h(this.buf,this.pos+=4),h(this.buf,this.pos+=4))}l.create=u(),l.prototype._slice=o.Array.prototype.subarray||o.Array.prototype.slice,l.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}}(),l.prototype.int32=function(){return 0|this.uint32()},l.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},l.prototype.bool=function(){return 0!==this.uint32()},l.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return h(this.buf,this.pos+=4)},l.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|h(this.buf,this.pos+=4)},l.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=o.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},l.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=o.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},l.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw a(this,e);if(this.pos+=e,Array.isArray(this.buf))return this.buf.slice(t,n);if(t===n){var r=o.Buffer;return r?r.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,t,n)},l.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},l.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},l.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},l._configure=function(e){r=e,l.create=u(),r._configure();var t=o.Long?"toLong":"toNumber";o.merge(l.prototype,{int64:function(){return d.call(this)[t](!1)},uint64:function(){return d.call(this)[t](!0)},sint64:function(){return d.call(this).zzDecode()[t](!1)},fixed64:function(){return f.call(this)[t](!0)},sfixed64:function(){return f.call(this)[t](!1)}})}},7707:(e,t,n)=>{"use strict";e.exports=i;var r=n(3338);(i.prototype=Object.create(r.prototype)).constructor=i;var o=n(1509);function i(e){r.call(this,e)}i._configure=function(){o.Buffer&&(i.prototype._slice=o.Buffer.prototype.slice)},i.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))},i._configure()},7149:(e,t,n)=>{"use strict";e.exports=d;var r=n(1374);((d.prototype=Object.create(r.prototype)).constructor=d).className="Root";var o,i,s,a=n(9229),l=n(1220),c=n(2924),u=n(9469);function d(e){r.call(this,"",e),this.deferred=[],this.files=[]}function h(){}d.fromJSON=function(e,t){return t||(t=new d),e.options&&t.setOptions(e.options),t.addJSON(e.nested)},d.prototype.resolvePath=u.path.resolve,d.prototype.fetch=u.fetch,d.prototype.load=function e(t,n,r){"function"===typeof n&&(r=n,n=void 0);var o=this;if(!r)return u.asPromise(e,o,t,n);var a=r===h;function l(e,t){if(r){if(a)throw e;var n=r;r=null,n(e,t)}}function c(e){var t=e.lastIndexOf("google/protobuf/");if(t>-1){var n=e.substring(t);if(n in s)return n}return null}function d(e,t){try{if(u.isString(t)&&"{"===t.charAt(0)&&(t=JSON.parse(t)),u.isString(t)){i.filename=e;var r,s=i(t,o,n),d=0;if(s.imports)for(;d<s.imports.length;++d)(r=c(s.imports[d])||o.resolvePath(e,s.imports[d]))&&f(r);if(s.weakImports)for(d=0;d<s.weakImports.length;++d)(r=c(s.weakImports[d])||o.resolvePath(e,s.weakImports[d]))&&f(r,!0)}else o.setOptions(t.options).addJSON(t.nested)}catch(h){l(h)}a||p||l(null,o)}function f(e,t){if(e=c(e)||e,!(o.files.indexOf(e)>-1))if(o.files.push(e),e in s)a?d(e,s[e]):(++p,setTimeout((function(){--p,d(e,s[e])})));else if(a){var n;try{n=u.fs.readFileSync(e).toString("utf8")}catch(i){return void(t||l(i))}d(e,n)}else++p,o.fetch(e,(function(n,i){--p,r&&(n?t?p||l(null,o):l(n):d(e,i))}))}var p=0;u.isString(t)&&(t=[t]);for(var g,m=0;m<t.length;++m)(g=o.resolvePath("",t[m]))&&f(g);if(a)return o;p||l(null,o)},d.prototype.loadSync=function(e,t){if(!u.isNode)throw Error("not supported");return this.load(e,t,h)},d.prototype.resolveAll=function(){if(this.deferred.length)throw Error("unresolvable extensions: "+this.deferred.map((function(e){return"'extend "+e.extend+"' in "+e.parent.fullName})).join(", "));return r.prototype.resolveAll.call(this)};var f=/^[A-Z]/;function p(e,t){var n=t.parent.lookup(t.extend);if(n){var r=new a(t.fullName,t.id,t.type,t.rule,void 0,t.options);return n.get(r.name)||(r.declaringField=t,t.extensionField=r,n.add(r)),!0}return!1}d.prototype._handleAdd=function(e){if(e instanceof a)void 0===e.extend||e.extensionField||p(0,e)||this.deferred.push(e);else if(e instanceof l)f.test(e.name)&&(e.parent[e.name]=e.values);else if(!(e instanceof c)){if(e instanceof o)for(var t=0;t<this.deferred.length;)p(0,this.deferred[t])?this.deferred.splice(t,1):++t;for(var n=0;n<e.nestedArray.length;++n)this._handleAdd(e._nestedArray[n]);f.test(e.name)&&(e.parent[e.name]=e)}},d.prototype._handleRemove=function(e){if(e instanceof a){if(void 0!==e.extend)if(e.extensionField)e.extensionField.parent.remove(e.extensionField),e.extensionField=null;else{var t=this.deferred.indexOf(e);t>-1&&this.deferred.splice(t,1)}}else if(e instanceof l)f.test(e.name)&&delete e.parent[e.name];else if(e instanceof r){for(var n=0;n<e.nestedArray.length;++n)this._handleRemove(e._nestedArray[n]);f.test(e.name)&&delete e.parent[e.name]}},d._configure=function(e,t,n){o=e,i=t,s=n}},1368:e=>{"use strict";e.exports={}},8094:(e,t,n)=>{"use strict";t.Service=n(3694)},3694:(e,t,n)=>{"use strict";e.exports=o;var r=n(1509);function o(e,t,n){if("function"!==typeof e)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(o.prototype=Object.create(r.EventEmitter.prototype)).constructor=o,o.prototype.rpcCall=function e(t,n,o,i,s){if(!i)throw TypeError("request must be specified");var a=this;if(!s)return r.asPromise(e,a,t,n,o,i);if(a.rpcImpl)try{return a.rpcImpl(t,n[a.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(e,n){if(e)return a.emit("error",e,t),s(e);if(null!==n){if(!(n instanceof o))try{n=o[a.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",n,t),s(null,n)}a.end(!0)}))}catch(l){return a.emit("error",l,t),void setTimeout((function(){s(l)}),0)}else setTimeout((function(){s(Error("already ended"))}),0)},o.prototype.end=function(e){return this.rpcImpl&&(e||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this}},6366:(e,t,n)=>{"use strict";e.exports=a;var r=n(1374);((a.prototype=Object.create(r.prototype)).constructor=a).className="Service";var o=n(360),i=n(9469),s=n(8094);function a(e,t){r.call(this,e,t),this.methods={},this._methodsArray=null}function l(e){return e._methodsArray=null,e}a.fromJSON=function(e,t){var n=new a(e,t.options);if(t.methods)for(var r=Object.keys(t.methods),i=0;i<r.length;++i)n.add(o.fromJSON(r[i],t.methods[r[i]]));return t.nested&&n.addJSON(t.nested),n.comment=t.comment,n},a.prototype.toJSON=function(e){var t=r.prototype.toJSON.call(this,e),n=!!e&&Boolean(e.keepComments);return i.toObject(["options",t&&t.options||void 0,"methods",r.arrayToJSON(this.methodsArray,e)||{},"nested",t&&t.nested||void 0,"comment",n?this.comment:void 0])},Object.defineProperty(a.prototype,"methodsArray",{get:function(){return this._methodsArray||(this._methodsArray=i.toArray(this.methods))}}),a.prototype.get=function(e){return this.methods[e]||r.prototype.get.call(this,e)},a.prototype.resolveAll=function(){for(var e=this.methodsArray,t=0;t<e.length;++t)e[t].resolve();return r.prototype.resolve.call(this)},a.prototype.add=function(e){if(this.get(e.name))throw Error("duplicate name '"+e.name+"' in "+this);return e instanceof o?(this.methods[e.name]=e,e.parent=this,l(this)):r.prototype.add.call(this,e)},a.prototype.remove=function(e){if(e instanceof o){if(this.methods[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.methods[e.name],e.parent=null,l(this)}return r.prototype.remove.call(this,e)},a.prototype.create=function(e,t,n){for(var r,o=new s.Service(e,t,n),a=0;a<this.methodsArray.length;++a){var l=i.lcFirst((r=this._methodsArray[a]).resolve().name).replace(/[^$\w_]/g,"");o[l]=i.codegen(["r","c"],i.isReserved(l)?l+"_":l)("return this.rpcCall(m,q,s,r,c)")({m:r,q:r.resolvedRequestType.ctor,s:r.resolvedResponseType.ctor})}return o}},1752:e=>{"use strict";e.exports=d;var t=/[\s{}=;:[\],'"()<>]/g,n=/(?:"([^"\\]*(?:\\.[^"\\]*)*)")/g,r=/(?:'([^'\\]*(?:\\.[^'\\]*)*)')/g,o=/^ *[*/]+ */,i=/^\s*\*?\/*/,s=/\n/g,a=/\s/,l=/\\(.?)/g,c={0:"\0",r:"\r",n:"\n",t:"\t"};function u(e){return e.replace(l,(function(e,t){switch(t){case"\\":case"":return t;default:return c[t]||""}}))}function d(e,l){e=e.toString();var c=0,d=e.length,h=1,f=0,p={},g=[],m=null;function y(e){return Error("illegal "+e+" (line "+h+")")}function b(t){return e.charAt(t)}function w(t,n,r){var a,c={type:e.charAt(t++),lineEmpty:!1,leading:r},u=t-(l?2:3);do{if(--u<0||"\n"===(a=e.charAt(u))){c.lineEmpty=!0;break}}while(" "===a||"\t"===a);for(var d=e.substring(t,n).split(s),g=0;g<d.length;++g)d[g]=d[g].replace(l?i:o,"").trim();c.text=d.join("\n").trim(),p[h]=c,f=h}function v(t){var n=E(t),r=e.substring(t,n);return/^\s*\/\//.test(r)}function E(e){for(var t=e;t<d&&"\n"!==b(t);)t++;return t}function S(){if(g.length>0)return g.shift();if(m)return function(){var t="'"===m?r:n;t.lastIndex=c-1;var o=t.exec(e);if(!o)throw y("string");return c=t.lastIndex,k(m),m=null,u(o[1])}();var o,i,s,f,p,S=0===c;do{if(c===d)return null;for(o=!1;a.test(s=b(c));)if("\n"===s&&(S=!0,++h),++c===d)return null;if("/"===b(c)){if(++c===d)throw y("comment");if("/"===b(c))if(l){if(f=c,p=!1,v(c-1)){p=!0;do{if((c=E(c))===d)break;if(c++,!S)break}while(v(c))}else c=Math.min(d,E(c)+1);p&&(w(f,c,S),S=!0),h++,o=!0}else{for(p="/"===b(f=c+1);"\n"!==b(++c);)if(c===d)return null;++c,p&&(w(f,c-1,S),S=!0),++h,o=!0}else{if("*"!==(s=b(c)))return"/";f=c+1,p=l||"*"===b(f);do{if("\n"===s&&++h,++c===d)throw y("comment");i=s,s=b(c)}while("*"!==i||"/"!==s);++c,p&&(w(f,c-2,S),S=!0),o=!0}}}while(o);var A=c;if(t.lastIndex=0,!t.test(b(A++)))for(;A<d&&!t.test(b(A));)++A;var _=e.substring(c,c=A);return'"'!==_&&"'"!==_||(m=_),_}function k(e){g.push(e)}function A(){if(!g.length){var e=S();if(null===e)return null;k(e)}return g[0]}return Object.defineProperty({next:S,peek:A,push:k,skip:function(e,t){var n=A();if(n===e)return S(),!0;if(!t)throw y("token '"+n+"', '"+e+"' expected");return!1},cmnt:function(e){var t,n=null;return void 0===e?(t=p[h-1],delete p[h-1],t&&(l||"*"===t.type||t.lineEmpty)&&(n=t.leading?t.text:null)):(f<e&&A(),t=p[e],delete p[e],!t||t.lineEmpty||!l&&"/"!==t.type||(n=t.leading?null:t.text)),n}},"line",{get:function(){return h}})}d.unescape=u},2225:(e,t,n)=>{"use strict";e.exports=b;var r=n(1374);((b.prototype=Object.create(r.prototype)).constructor=b).className="Type";var o=n(1220),i=n(2924),s=n(9229),a=n(4635),l=n(6366),c=n(7886),u=n(3338),d=n(5850),h=n(9469),f=n(7573),p=n(1985),g=n(9875),m=n(1561),y=n(9297);function b(e,t){r.call(this,e,t),this.fields={},this.oneofs=void 0,this.extensions=void 0,this.reserved=void 0,this.group=void 0,this._fieldsById=null,this._fieldsArray=null,this._oneofsArray=null,this._ctor=null}function w(e){return e._fieldsById=e._fieldsArray=e._oneofsArray=null,delete e.encode,delete e.decode,delete e.verify,e}Object.defineProperties(b.prototype,{fieldsById:{get:function(){if(this._fieldsById)return this._fieldsById;this._fieldsById={};for(var e=Object.keys(this.fields),t=0;t<e.length;++t){var n=this.fields[e[t]],r=n.id;if(this._fieldsById[r])throw Error("duplicate id "+r+" in "+this);this._fieldsById[r]=n}return this._fieldsById}},fieldsArray:{get:function(){return this._fieldsArray||(this._fieldsArray=h.toArray(this.fields))}},oneofsArray:{get:function(){return this._oneofsArray||(this._oneofsArray=h.toArray(this.oneofs))}},ctor:{get:function(){return this._ctor||(this.ctor=b.generateConstructor(this)())},set:function(e){var t=e.prototype;t instanceof c||((e.prototype=new c).constructor=e,h.merge(e.prototype,t)),e.$type=e.prototype.$type=this,h.merge(e,c,!0),this._ctor=e;for(var n=0;n<this.fieldsArray.length;++n)this._fieldsArray[n].resolve();var r={};for(n=0;n<this.oneofsArray.length;++n)r[this._oneofsArray[n].resolve().name]={get:h.oneOfGetter(this._oneofsArray[n].oneof),set:h.oneOfSetter(this._oneofsArray[n].oneof)};n&&Object.defineProperties(e.prototype,r)}}}),b.generateConstructor=function(e){for(var t,n=h.codegen(["p"],e.name),r=0;r<e.fieldsArray.length;++r)(t=e._fieldsArray[r]).map?n("this%s={}",h.safeProp(t.name)):t.repeated&&n("this%s=[]",h.safeProp(t.name));return n("if(p)for(var ks=Object.keys(p),i=0;i<ks.length;++i)if(p[ks[i]]!=null)")("this[ks[i]]=p[ks[i]]")},b.fromJSON=function(e,t){var n=new b(e,t.options);n.extensions=t.extensions,n.reserved=t.reserved;for(var c=Object.keys(t.fields),u=0;u<c.length;++u)n.add(("undefined"!==typeof t.fields[c[u]].keyType?a.fromJSON:s.fromJSON)(c[u],t.fields[c[u]]));if(t.oneofs)for(c=Object.keys(t.oneofs),u=0;u<c.length;++u)n.add(i.fromJSON(c[u],t.oneofs[c[u]]));if(t.nested)for(c=Object.keys(t.nested),u=0;u<c.length;++u){var d=t.nested[c[u]];n.add((void 0!==d.id?s.fromJSON:void 0!==d.fields?b.fromJSON:void 0!==d.values?o.fromJSON:void 0!==d.methods?l.fromJSON:r.fromJSON)(c[u],d))}return t.extensions&&t.extensions.length&&(n.extensions=t.extensions),t.reserved&&t.reserved.length&&(n.reserved=t.reserved),t.group&&(n.group=!0),t.comment&&(n.comment=t.comment),n},b.prototype.toJSON=function(e){var t=r.prototype.toJSON.call(this,e),n=!!e&&Boolean(e.keepComments);return h.toObject(["options",t&&t.options||void 0,"oneofs",r.arrayToJSON(this.oneofsArray,e),"fields",r.arrayToJSON(this.fieldsArray.filter((function(e){return!e.declaringField})),e)||{},"extensions",this.extensions&&this.extensions.length?this.extensions:void 0,"reserved",this.reserved&&this.reserved.length?this.reserved:void 0,"group",this.group||void 0,"nested",t&&t.nested||void 0,"comment",n?this.comment:void 0])},b.prototype.resolveAll=function(){for(var e=this.fieldsArray,t=0;t<e.length;)e[t++].resolve();var n=this.oneofsArray;for(t=0;t<n.length;)n[t++].resolve();return r.prototype.resolveAll.call(this)},b.prototype.get=function(e){return this.fields[e]||this.oneofs&&this.oneofs[e]||this.nested&&this.nested[e]||null},b.prototype.add=function(e){if(this.get(e.name))throw Error("duplicate name '"+e.name+"' in "+this);if(e instanceof s&&void 0===e.extend){if(this._fieldsById?this._fieldsById[e.id]:this.fieldsById[e.id])throw Error("duplicate id "+e.id+" in "+this);if(this.isReservedId(e.id))throw Error("id "+e.id+" is reserved in "+this);if(this.isReservedName(e.name))throw Error("name '"+e.name+"' is reserved in "+this);return e.parent&&e.parent.remove(e),this.fields[e.name]=e,e.message=this,e.onAdd(this),w(this)}return e instanceof i?(this.oneofs||(this.oneofs={}),this.oneofs[e.name]=e,e.onAdd(this),w(this)):r.prototype.add.call(this,e)},b.prototype.remove=function(e){if(e instanceof s&&void 0===e.extend){if(!this.fields||this.fields[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.fields[e.name],e.parent=null,e.onRemove(this),w(this)}if(e instanceof i){if(!this.oneofs||this.oneofs[e.name]!==e)throw Error(e+" is not a member of "+this);return delete this.oneofs[e.name],e.parent=null,e.onRemove(this),w(this)}return r.prototype.remove.call(this,e)},b.prototype.isReservedId=function(e){return r.isReservedId(this.reserved,e)},b.prototype.isReservedName=function(e){return r.isReservedName(this.reserved,e)},b.prototype.create=function(e){return new this.ctor(e)},b.prototype.setup=function(){for(var e=this.fullName,t=[],n=0;n<this.fieldsArray.length;++n)t.push(this._fieldsArray[n].resolve().resolvedType);this.encode=f(this)({Writer:d,types:t,util:h}),this.decode=p(this)({Reader:u,types:t,util:h}),this.verify=g(this)({types:t,util:h}),this.fromObject=m.fromObject(this)({types:t,util:h}),this.toObject=m.toObject(this)({types:t,util:h});var r=y[e];if(r){var o=Object.create(this);o.fromObject=this.fromObject,this.fromObject=r.fromObject.bind(o),o.toObject=this.toObject,this.toObject=r.toObject.bind(o)}return this},b.prototype.encode=function(e,t){return this.setup().encode(e,t)},b.prototype.encodeDelimited=function(e,t){return this.encode(e,t&&t.len?t.fork():t).ldelim()},b.prototype.decode=function(e,t){return this.setup().decode(e,t)},b.prototype.decodeDelimited=function(e){return e instanceof u||(e=u.create(e)),this.decode(e,e.uint32())},b.prototype.verify=function(e){return this.setup().verify(e)},b.prototype.fromObject=function(e){return this.setup().fromObject(e)},b.prototype.toObject=function(e,t){return this.setup().toObject(e,t)},b.d=function(e){return function(t){h.decorateType(t,e)}}},9876:(e,t,n)=>{"use strict";var r=t,o=n(9469),i=["double","float","int32","uint32","sint32","fixed32","sfixed32","int64","uint64","sint64","fixed64","sfixed64","bool","string","bytes"];function s(e,t){var n=0,r={};for(t|=0;n<e.length;)r[i[n+t]]=e[n++];return r}r.basic=s([1,5,0,0,0,5,5,0,0,0,1,1,0,2,2]),r.defaults=s([0,0,0,0,0,0,0,0,0,0,0,0,!1,"",o.emptyArray,null]),r.long=s([0,0,0,1,1],7),r.mapKey=s([0,0,0,5,5,0,0,0,1,1,0,2],2),r.packed=s([1,5,0,0,0,5,5,0,0,0,1,1,0])},9469:(e,t,n)=>{"use strict";var r,o,i=e.exports=n(1509),s=n(1368);i.codegen=n(1318),i.fetch=n(643),i.path=n(5534),i.fs=i.inquire("fs"),i.toArray=function(e){if(e){for(var t=Object.keys(e),n=new Array(t.length),r=0;r<t.length;)n[r]=e[t[r++]];return n}return[]},i.toObject=function(e){for(var t={},n=0;n<e.length;){var r=e[n++],o=e[n++];void 0!==o&&(t[r]=o)}return t};var a=/\\/g,l=/"/g;i.isReserved=function(e){return/^(?:do|if|in|for|let|new|try|var|case|else|enum|eval|false|null|this|true|void|with|break|catch|class|const|super|throw|while|yield|delete|export|import|public|return|static|switch|typeof|default|extends|finally|package|private|continue|debugger|function|arguments|interface|protected|implements|instanceof)$/.test(e)},i.safeProp=function(e){return!/^[$\w_]+$/.test(e)||i.isReserved(e)?'["'+e.replace(a,"\\\\").replace(l,'\\"')+'"]':"."+e},i.ucFirst=function(e){return e.charAt(0).toUpperCase()+e.substring(1)};var c=/_([a-z])/g;i.camelCase=function(e){return e.substring(0,1)+e.substring(1).replace(c,(function(e,t){return t.toUpperCase()}))},i.compareFieldsById=function(e,t){return e.id-t.id},i.decorateType=function(e,t){if(e.$type)return t&&e.$type.name!==t&&(i.decorateRoot.remove(e.$type),e.$type.name=t,i.decorateRoot.add(e.$type)),e.$type;r||(r=n(2225));var o=new r(t||e.name);return i.decorateRoot.add(o),o.ctor=e,Object.defineProperty(e,"$type",{value:o,enumerable:!1}),Object.defineProperty(e.prototype,"$type",{value:o,enumerable:!1}),o};var u=0;i.decorateEnum=function(e){if(e.$type)return e.$type;o||(o=n(1220));var t=new o("Enum"+u++,e);return i.decorateRoot.add(t),Object.defineProperty(e,"$type",{value:t,enumerable:!1}),t},i.setProperty=function(e,t,n){if("object"!==typeof e)throw TypeError("dst must be an object");if(!t)throw TypeError("path must be specified");return function e(t,n,r){var o=n.shift();if("__proto__"===o||"prototype"===o)return t;if(n.length>0)t[o]=e(t[o]||{},n,r);else{var i=t[o];i&&(r=[].concat(i).concat(r)),t[o]=r}return t}(e,t=t.split("."),n)},Object.defineProperty(i,"decorateRoot",{get:function(){return s.decorated||(s.decorated=new(n(7149)))}})},6350:(e,t,n)=>{"use strict";e.exports=o;var r=n(1509);function o(e,t){this.lo=e>>>0,this.hi=t>>>0}var i=o.zero=new o(0,0);i.toNumber=function(){return 0},i.zzEncode=i.zzDecode=function(){return this},i.length=function(){return 1};var s=o.zeroHash="\0\0\0\0\0\0\0\0";o.fromNumber=function(e){if(0===e)return i;var t=e<0;t&&(e=-e);var n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new o(n,r)},o.from=function(e){if("number"===typeof e)return o.fromNumber(e);if(r.isString(e)){if(!r.Long)return o.fromNumber(parseInt(e,10));e=r.Long.fromString(e)}return e.low||e.high?new o(e.low>>>0,e.high>>>0):i},o.prototype.toNumber=function(e){if(!e&&this.hi>>>31){var t=1+~this.lo>>>0,n=~this.hi>>>0;return t||(n=n+1>>>0),-(t+4294967296*n)}return this.lo+4294967296*this.hi},o.prototype.toLong=function(e){return r.Long?new r.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;o.fromHash=function(e){return e===s?i:new o((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)},o.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)},o.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},o.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},o.prototype.length=function(){var e=this.lo,t=(this.lo>>>28|this.hi<<4)>>>0,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}},1509:function(e,t,n){"use strict";var r=t;function o(e,t,n){for(var r=Object.keys(t),o=0;o<r.length;++o)void 0!==e[r[o]]&&n||(e[r[o]]=t[r[o]]);return e}function i(e){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),n&&o(this,n)}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}r.asPromise=n(4762),r.base64=n(6762),r.EventEmitter=n(7351),r.float=n(217),r.inquire=n(4882),r.utf8=n(8626),r.pool=n(6931),r.LongBits=n(6350),r.isNode=Boolean("undefined"!==typeof n.g&&n.g&&n.g.process&&n.g.process.versions&&n.g.process.versions.node),r.global=r.isNode&&n.g||"undefined"!==typeof window&&window||"undefined"!==typeof self&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(e){return"number"===typeof e&&isFinite(e)&&Math.floor(e)===e},r.isString=function(e){return"string"===typeof e||e instanceof String},r.isObject=function(e){return e&&"object"===typeof e},r.isset=r.isSet=function(e,t){var n=e[t];return!(null==n||!e.hasOwnProperty(t))&&("object"!==typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},r.Buffer=function(){try{var e=r.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(t){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(e){return"number"===typeof e?r.Buffer?r._Buffer_allocUnsafe(e):new r.Array(e):r.Buffer?r._Buffer_from(e):"undefined"===typeof Uint8Array?e:new Uint8Array(e)},r.Array="undefined"!==typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(e){return e?r.LongBits.from(e).toHash():r.LongBits.zeroHash},r.longFromHash=function(e,t){var n=r.LongBits.fromHash(e);return r.Long?r.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},r.merge=o,r.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},r.newError=i,r.ProtocolError=i("ProtocolError"),r.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var e=Object.keys(this),n=e.length-1;n>-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},r.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var e=r.Buffer;e?(r._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,n){return new e(t,n)},r._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):r._Buffer_from=r._Buffer_allocUnsafe=null}},9875:(e,t,n)=>{"use strict";e.exports=function(e){var t=o.codegen(["m"],e.name+"$verify")('if(typeof m!=="object"||m===null)')("return%j","object expected"),n=e.oneofsArray,r={};n.length&&t("var p={}");for(var l=0;l<e.fieldsArray.length;++l){var c=e._fieldsArray[l].resolve(),u="m"+o.safeProp(c.name);if(c.optional&&t("if(%s!=null&&m.hasOwnProperty(%j)){",u,c.name),c.map)t("if(!util.isObject(%s))",u)("return%j",i(c,"object"))("var k=Object.keys(%s)",u)("for(var i=0;i<k.length;++i){"),a(t,c,"k[i]"),s(t,c,l,u+"[k[i]]")("}");else if(c.repeated)t("if(!Array.isArray(%s))",u)("return%j",i(c,"array"))("for(var i=0;i<%s.length;++i){",u),s(t,c,l,u+"[i]")("}");else{if(c.partOf){var d=o.safeProp(c.partOf.name);1===r[c.partOf.name]&&t("if(p%s===1)",d)("return%j",c.partOf.name+": multiple values"),r[c.partOf.name]=1,t("p%s=1",d)}s(t,c,l,u)}c.optional&&t("}")}return t("return null")};var r=n(1220),o=n(9469);function i(e,t){return e.name+": "+t+(e.repeated&&"array"!==t?"[]":e.map&&"object"!==t?"{k:"+e.keyType+"}":"")+" expected"}function s(e,t,n,o){if(t.resolvedType)if(t.resolvedType instanceof r){e("switch(%s){",o)("default:")("return%j",i(t,"enum value"));for(var s=Object.keys(t.resolvedType.values),a=0;a<s.length;++a)e("case %i:",t.resolvedType.values[s[a]]);e("break")("}")}else e("{")("var e=types[%i].verify(%s);",n,o)("if(e)")("return%j+e",t.name+".")("}");else switch(t.type){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.isInteger(%s))",o)("return%j",i(t,"integer"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.isInteger(%s)&&!(%s&&util.isInteger(%s.low)&&util.isInteger(%s.high)))",o,o,o,o)("return%j",i(t,"integer|Long"));break;case"float":case"double":e('if(typeof %s!=="number")',o)("return%j",i(t,"number"));break;case"bool":e('if(typeof %s!=="boolean")',o)("return%j",i(t,"boolean"));break;case"string":e("if(!util.isString(%s))",o)("return%j",i(t,"string"));break;case"bytes":e('if(!(%s&&typeof %s.length==="number"||util.isString(%s)))',o,o,o)("return%j",i(t,"buffer"))}return e}function a(e,t,n){switch(t.keyType){case"int32":case"uint32":case"sint32":case"fixed32":case"sfixed32":e("if(!util.key32Re.test(%s))",n)("return%j",i(t,"integer key"));break;case"int64":case"uint64":case"sint64":case"fixed64":case"sfixed64":e("if(!util.key64Re.test(%s))",n)("return%j",i(t,"integer|Long key"));break;case"bool":e("if(!util.key2Re.test(%s))",n)("return%j",i(t,"boolean key"))}return e}},9297:(e,t,n)=>{"use strict";var r=t,o=n(7886);r[".google.protobuf.Any"]={fromObject:function(e){if(e&&e["@type"]){var t=e["@type"].substring(e["@type"].lastIndexOf("/")+1),n=this.lookup(t);if(n){var r="."===e["@type"].charAt(0)?e["@type"].slice(1):e["@type"];return-1===r.indexOf("/")&&(r="/"+r),this.create({type_url:r,value:n.encode(n.fromObject(e)).finish()})}}return this.fromObject(e)},toObject:function(e,t){var n="",r="";if(t&&t.json&&e.type_url&&e.value){r=e.type_url.substring(e.type_url.lastIndexOf("/")+1),n=e.type_url.substring(0,e.type_url.lastIndexOf("/")+1);var i=this.lookup(r);i&&(e=i.decode(e.value))}if(!(e instanceof this.ctor)&&e instanceof o){var s=e.$type.toObject(e,t);return""===n&&(n="type.googleapis.com/"),r=n+("."===e.$type.fullName[0]?e.$type.fullName.slice(1):e.$type.fullName),s["@type"]=r,s}return this.toObject(e,t)}}},5850:(e,t,n)=>{"use strict";e.exports=d;var r,o=n(1509),i=o.LongBits,s=o.base64,a=o.utf8;function l(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function c(){}function u(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function d(){this.len=0,this.head=new l(c,0,0),this.tail=this.head,this.states=null}var h=function(){return o.Buffer?function(){return(d.create=function(){return new r})()}:function(){return new d}};function f(e,t,n){t[n]=255&e}function p(e,t){this.len=e,this.next=void 0,this.val=t}function g(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function m(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}d.create=h(),d.alloc=function(e){return new o.Array(e)},o.Array!==Array&&(d.alloc=o.pool(d.alloc,o.Array.prototype.subarray)),d.prototype._push=function(e,t,n){return this.tail=this.tail.next=new l(e,t,n),this.len+=t,this},p.prototype=Object.create(l.prototype),p.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},d.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},d.prototype.int32=function(e){return e<0?this._push(g,10,i.fromNumber(e)):this.uint32(e)},d.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},d.prototype.uint64=function(e){var t=i.from(e);return this._push(g,t.length(),t)},d.prototype.int64=d.prototype.uint64,d.prototype.sint64=function(e){var t=i.from(e).zzEncode();return this._push(g,t.length(),t)},d.prototype.bool=function(e){return this._push(f,1,e?1:0)},d.prototype.fixed32=function(e){return this._push(m,4,e>>>0)},d.prototype.sfixed32=d.prototype.fixed32,d.prototype.fixed64=function(e){var t=i.from(e);return this._push(m,4,t.lo)._push(m,4,t.hi)},d.prototype.sfixed64=d.prototype.fixed64,d.prototype.float=function(e){return this._push(o.float.writeFloatLE,4,e)},d.prototype.double=function(e){return this._push(o.float.writeDoubleLE,8,e)};var y=o.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r<e.length;++r)t[n+r]=e[r]};d.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(f,1,0);if(o.isString(e)){var n=d.alloc(t=s.length(e));s.decode(e,n,0),e=n}return this.uint32(t)._push(y,t,e)},d.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},d.prototype.fork=function(){return this.states=new u(this),this.head=this.tail=new l(c,0,0),this.len=0,this},d.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 l(c,0,0),this.len=0),this},d.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},d.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},d._configure=function(e){r=e,d.create=h(),r._configure()}},3931:(e,t,n)=>{"use strict";e.exports=i;var r=n(5850);(i.prototype=Object.create(r.prototype)).constructor=i;var o=n(1509);function i(){r.call(this)}function s(e,t,n){e.length<40?o.utf8.write(e,t,n):t.utf8Write?t.utf8Write(e,n):t.write(e,n)}i._configure=function(){i.alloc=o._Buffer_allocUnsafe,i.writeBytesBuffer=o.Buffer&&o.Buffer.prototype instanceof Uint8Array&&"set"===o.Buffer.prototype.set.name?function(e,t,n){t.set(e,n)}:function(e,t,n){if(e.copy)e.copy(t,n,0,e.length);else for(var r=0;r<e.length;)t[n++]=e[r++]}},i.prototype.bytes=function(e){o.isString(e)&&(e=o._Buffer_from(e,"base64"));var t=e.length>>>0;return this.uint32(t),t&&this._push(i.writeBytesBuffer,t,e),this},i.prototype.string=function(e){var t=o.Buffer.byteLength(e);return this.uint32(t),t&&this._push(s,t,e),this},i._configure()},8275:(e,t)=>{"use strict";class n{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 r=n.toUint8Array(e),o=n.toUint8Array(t);if(r.length!==o.byteLength)return!1;for(let n=0;n<r.length;n++)if(r[n]!==o[n])return!1;return!0}static concat(){let e;for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];e=!Array.isArray(n[0])||n[1]instanceof Function?Array.isArray(n[0])&&n[1]instanceof Function?n[0]:n[n.length-1]instanceof Function?n.slice(0,n.length-1):n:n[0];let o=0;for(const a of e)o+=a.byteLength;const i=new Uint8Array(o);let s=0;for(const a of e){const e=this.toUint8Array(a);i.set(e,s),s+=e.length}return n[n.length-1]instanceof Function?this.toView(i,n[n.length-1]):i.buffer}}const r="string",o=/^[0-9a-f]+$/i,i=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/,s=/^[a-zA-Z0-9-_]+$/;class a{static fromString(e){const t=unescape(encodeURIComponent(e)),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n.buffer}static toString(e){const t=n.toUint8Array(e);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return decodeURIComponent(escape(r))}}class l{static toString(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const r=n.toArrayBuffer(e),o=new DataView(r);let i="";for(let n=0;n<r.byteLength;n+=2){const e=o.getUint16(n,t);i+=String.fromCharCode(e)}return i}static fromString(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=new ArrayBuffer(2*e.length),r=new DataView(n);for(let o=0;o<e.length;o++)r.setUint16(2*o,e.charCodeAt(o),t);return n}}class c{static isHex(e){return typeof e===r&&o.test(e)}static isBase64(e){return typeof e===r&&i.test(e)}static isBase64Url(e){return typeof e===r&&s.test(e)}static ToString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const r=n.toUint8Array(e);switch(t.toLowerCase()){case"utf8":return this.ToUtf8String(r);case"binary":return this.ToBinary(r);case"hex":return this.ToHex(r);case"base64":return this.ToBase64(r);case"base64url":return this.ToBase64Url(r);case"utf16le":return l.toString(r,!0);case"utf16":case"utf16be":return l.toString(r);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 l.fromString(e,!0);case"utf16":case"utf16be":return l.fromString(e);default:throw new Error(`Unknown type of encoding '${t}'`)}}static ToBase64(e){const t=n.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(!c.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(!c.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]:c.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.FromBinary(e);case"utf8":return a.fromString(e);case"utf16":case"utf16be":return l.fromString(e);case"utf16le":case"usc2":return l.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]:c.DEFAULT_UTF8_ENCODING;switch(t){case"ascii":return this.ToBinary(e);case"utf8":return a.toString(e);case"utf16":case"utf16be":return l.toString(e);case"utf16le":case"usc2":return l.toString(e,!0);default:throw new Error(`Unknown type of encoding '${t}'`)}}static FromBinary(e){const t=e.length,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);return n.buffer}static ToBinary(e){const t=n.toUint8Array(e);let r="";for(let n=0;n<t.length;n++)r+=String.fromCharCode(t[n]);return r}static ToHex(e){const t=n.toUint8Array(e);let r="";const o=t.length;for(let n=0;n<o;n++){const e=t[n];e<16&&(r+="0"),r+=e.toString(16)}return r}static FromHex(e){let t=this.formatString(e);if(!t)return new ArrayBuffer(0);if(!c.isHex(t))throw new TypeError("Argument 'hexString' is not HEX encoded");t.length%2&&(t=`0${t}`);const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2){const e=t.slice(r,r+2);n[r/2]=parseInt(e,16)}return n.buffer}static ToUtf16String(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return l.toString(e,t)}static FromUtf16String(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return l.fromString(e,t)}static Base64Padding(e){const t=4-e.length%4;if(t<4)for(let n=0;n<t;n++)e+="=";return e}static formatString(e){return(null===e||void 0===e?void 0:e.replace(/[\n\r\t ]/g,""))||""}}c.DEFAULT_UTF8_ENCODING="utf8",t._H=n,t.U$=c},2730:(e,t,n)=>{"use strict";var r=n(5043),o=n(8853);function i(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);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 s=new Set,a={};function l(e,t){c(e,t),c(e+"Capture",t)}function c(e,t){for(a[e]=t,e=0;e<t.length;e++)s.add(t[e])}var u=!("undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement),d=Object.prototype.hasOwnProperty,h=/^[: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={},p={};function g(e,t,n,r,o,i,s){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=s}var m={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach((function(e){m[e]=new g(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((function(e){var t=e[0];m[t]=new g(t,1,!1,e[1],null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((function(e){m[e]=new g(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((function(e){m[e]=new g(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){m[e]=new g(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((function(e){m[e]=new g(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((function(e){m[e]=new g(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((function(e){m[e]=new g(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((function(e){m[e]=new g(e,5,!1,e.toLowerCase(),null,!1,!1)}));var y=/[\-:]([a-z])/g;function b(e){return e[1].toUpperCase()}function w(e,t,n,r){var o=m.hasOwnProperty(t)?m[t]:null;(null!==o?0!==o.type:r||!(2<t.length)||"o"!==t[0]&&"O"!==t[0]||"n"!==t[1]&&"N"!==t[1])&&(function(e,t,n,r){if(null===t||"undefined"===typeof t||function(e,t,n,r){if(null!==n&&0===n.type)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return!r&&(null!==n?!n.acceptsBooleans:"data-"!==(e=e.toLowerCase().slice(0,5))&&"aria-"!==e);default:return!1}}(e,t,n,r))return!0;if(r)return!1;if(null!==n)switch(n.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,n,o,r)&&(n=null),r||null===o?function(e){return!!d.call(p,e)||!d.call(f,e)&&(h.test(e)?p[e]=!0:(f[e]=!0,!1))}(t)&&(null===n?e.removeAttribute(t):e.setAttribute(t,""+n)):o.mustUseProperty?e[o.propertyName]=null===n?3!==o.type&&"":n:(t=o.attributeName,r=o.attributeNamespace,null===n?e.removeAttribute(t):(n=3===(o=o.type)||4===o&&!0===n?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}"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(y,b);m[t]=new g(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(y,b);m[t]=new g(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(y,b);m[t]=new g(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((function(e){m[e]=new g(e,1,!1,e.toLowerCase(),null,!1,!1)})),m.xlinkHref=new g("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((function(e){m[e]=new g(e,1,!1,e.toLowerCase(),null,!0,!0)}));var v=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),S=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),A=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),I=Symbol.for("react.provider"),x=Symbol.for("react.context"),C=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),P=Symbol.for("react.lazy");Symbol.for("react.scope"),Symbol.for("react.debug_trace_mode");var O=Symbol.for("react.offscreen");Symbol.for("react.legacy_hidden"),Symbol.for("react.cache"),Symbol.for("react.tracing_marker");var L=Symbol.iterator;function D(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=L&&e[L]||e["@@iterator"])?e:null}var B,U=Object.assign;function M(e){if(void 0===B)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);B=t&&t[1]||""}return"\n"+B+e}var F=!1;function $(e,t){if(!e||F)return"";F=!0;var n=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 r=c}Reflect.construct(e,[],t)}else{try{t.call()}catch(c){r=c}e.call(t.prototype)}else{try{throw Error()}catch(c){r=c}e()}}catch(c){if(c&&r&&"string"===typeof c.stack){for(var o=c.stack.split("\n"),i=r.stack.split("\n"),s=o.length-1,a=i.length-1;1<=s&&0<=a&&o[s]!==i[a];)a--;for(;1<=s&&0<=a;s--,a--)if(o[s]!==i[a]){if(1!==s||1!==a)do{if(s--,0>--a||o[s]!==i[a]){var l="\n"+o[s].replace(" at new "," at ");return e.displayName&&l.includes("<anonymous>")&&(l=l.replace("<anonymous>",e.displayName)),l}}while(1<=s&&0<=a);break}}}finally{F=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?M(e):""}function H(e){switch(e.tag){case 5:return M(e.type);case 16:return M("Lazy");case 13:return M("Suspense");case 19:return M("SuspenseList");case 0:case 2:case 15:return e=$(e.type,!1);case 11:return e=$(e.type.render,!1);case 1:return e=$(e.type,!0);default:return""}}function q(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 k:return"Fragment";case S:return"Portal";case _:return"Profiler";case A:return"StrictMode";case R:return"Suspense";case T:return"SuspenseList"}if("object"===typeof e)switch(e.$$typeof){case x:return(e.displayName||"Context")+".Consumer";case I:return(e._context.displayName||"Context")+".Provider";case C:var t=e.render;return(e=e.displayName)||(e=""!==(e=t.displayName||t.name||"")?"ForwardRef("+e+")":"ForwardRef"),e;case N:return null!==(t=e.displayName||null)?t:q(e.type)||"Memo";case P:t=e._payload,e=e._init;try{return q(e(t))}catch(n){}}return null}function j(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=(e=t.render).displayName||e.name||"",t.displayName||(""!==e?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return q(t);case 8:return t===A?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if("function"===typeof t)return t.displayName||t.name||null;if("string"===typeof t)return t}return null}function V(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":case"object":return e;default:return""}}function z(e){var t=e.type;return(e=e.nodeName)&&"input"===e.toLowerCase()&&("checkbox"===t||"radio"===t)}function K(e){e._valueTracker||(e._valueTracker=function(e){var t=z(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&"undefined"!==typeof n&&"function"===typeof n.get&&"function"===typeof n.set){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(e){r=""+e,i.call(this,e)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(e){r=""+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}(e))}function W(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=z(e)?e.checked?"true":"false":e.value),(e=r)!==n&&(t.setValue(e),!0)}function G(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 Y(e,t){var n=t.checked;return U({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:null!=n?n:e._wrapperState.initialChecked})}function Q(e,t){var n=null==t.defaultValue?"":t.defaultValue,r=null!=t.checked?t.checked:t.defaultChecked;n=V(null!=t.value?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:"checkbox"===t.type||"radio"===t.type?null!=t.checked:null!=t.value}}function J(e,t){null!=(t=t.checked)&&w(e,"checked",t,!1)}function X(e,t){J(e,t);var n=V(t.value),r=t.type;if(null!=n)"number"===r?(0===n&&""===e.value||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if("submit"===r||"reset"===r)return void e.removeAttribute("value");t.hasOwnProperty("value")?ee(e,t.type,n):t.hasOwnProperty("defaultValue")&&ee(e,t.type,V(t.defaultValue)),null==t.checked&&null!=t.defaultChecked&&(e.defaultChecked=!!t.defaultChecked)}function Z(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!("submit"!==r&&"reset"!==r||void 0!==t.value&&null!==t.value))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}""!==(n=e.name)&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,""!==n&&(e.name=n)}function ee(e,t,n){"number"===t&&G(e.ownerDocument)===e||(null==n?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var te=Array.isArray;function ne(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o<n.length;o++)t["$"+n[o]]=!0;for(n=0;n<e.length;n++)o=t.hasOwnProperty("$"+e[n].value),e[n].selected!==o&&(e[n].selected=o),o&&r&&(e[n].defaultSelected=!0)}else{for(n=""+V(n),t=null,o=0;o<e.length;o++){if(e[o].value===n)return e[o].selected=!0,void(r&&(e[o].defaultSelected=!0));null!==t||e[o].disabled||(t=e[o])}null!==t&&(t.selected=!0)}}function re(e,t){if(null!=t.dangerouslySetInnerHTML)throw Error(i(91));return U({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function oe(e,t){var n=t.value;if(null==n){if(n=t.children,t=t.defaultValue,null!=n){if(null!=t)throw Error(i(92));if(te(n)){if(1<n.length)throw Error(i(93));n=n[0]}t=n}null==t&&(t=""),n=t}e._wrapperState={initialValue:V(n)}}function ie(e,t){var n=V(t.value),r=V(t.defaultValue);null!=n&&((n=""+n)!==e.value&&(e.value=n),null==t.defaultValue&&e.defaultValue!==n&&(e.defaultValue=n)),null!=r&&(e.defaultValue=""+r)}function se(e){var t=e.textContent;t===e._wrapperState.initialValue&&""!==t&&null!==t&&(e.value=t)}function ae(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 le(e,t){return null==e||"http://www.w3.org/1999/xhtml"===e?ae(t):"http://www.w3.org/2000/svg"===e&&"foreignObject"===t?"http://www.w3.org/1999/xhtml":e}var ce,ue,de=(ue=function(e,t){if("http://www.w3.org/2000/svg"!==e.namespaceURI||"innerHTML"in e)e.innerHTML=t;else{for((ce=ce||document.createElement("div")).innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=ce.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}},"undefined"!==typeof MSApp&&MSApp.execUnsafeLocalFunction?function(e,t,n,r){MSApp.execUnsafeLocalFunction((function(){return ue(e,t)}))}:ue);function he(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&3===n.nodeType)return void(n.nodeValue=t)}e.textContent=t}var fe={animationIterationCount:!0,aspectRatio:!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},pe=["Webkit","ms","Moz","O"];function ge(e,t,n){return null==t||"boolean"===typeof t||""===t?"":n||"number"!==typeof t||0===t||fe.hasOwnProperty(e)&&fe[e]?(""+t).trim():t+"px"}function me(e,t){for(var n in e=e.style,t)if(t.hasOwnProperty(n)){var r=0===n.indexOf("--"),o=ge(n,t[n],r);"float"===n&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}Object.keys(fe).forEach((function(e){pe.forEach((function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),fe[t]=fe[e]}))}));var ye=U({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 be(e,t){if(t){if(ye[e]&&(null!=t.children||null!=t.dangerouslySetInnerHTML))throw Error(i(137,e));if(null!=t.dangerouslySetInnerHTML){if(null!=t.children)throw Error(i(60));if("object"!==typeof t.dangerouslySetInnerHTML||!("__html"in t.dangerouslySetInnerHTML))throw Error(i(61))}if(null!=t.style&&"object"!==typeof t.style)throw Error(i(62))}}function we(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}}var ve=null;function Ee(e){return(e=e.target||e.srcElement||window).correspondingUseElement&&(e=e.correspondingUseElement),3===e.nodeType?e.parentNode:e}var Se=null,ke=null,Ae=null;function _e(e){if(e=vo(e)){if("function"!==typeof Se)throw Error(i(280));var t=e.stateNode;t&&(t=So(t),Se(e.stateNode,e.type,t))}}function Ie(e){ke?Ae?Ae.push(e):Ae=[e]:ke=e}function xe(){if(ke){var e=ke,t=Ae;if(Ae=ke=null,_e(e),t)for(e=0;e<t.length;e++)_e(t[e])}}function Ce(e,t){return e(t)}function Re(){}var Te=!1;function Ne(e,t,n){if(Te)return e(t,n);Te=!0;try{return Ce(e,t,n)}finally{Te=!1,(null!==ke||null!==Ae)&&(Re(),xe())}}function Pe(e,t){var n=e.stateNode;if(null===n)return null;var r=So(n);if(null===r)return null;n=r[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":(r=!r.disabled)||(r=!("button"===(e=e.type)||"input"===e||"select"===e||"textarea"===e)),e=!r;break e;default:e=!1}if(e)return null;if(n&&"function"!==typeof n)throw Error(i(231,t,typeof n));return n}var Oe=!1;if(u)try{var Le={};Object.defineProperty(Le,"passive",{get:function(){Oe=!0}}),window.addEventListener("test",Le,Le),window.removeEventListener("test",Le,Le)}catch(ue){Oe=!1}function De(e,t,n,r,o,i,s,a,l){var c=Array.prototype.slice.call(arguments,3);try{t.apply(n,c)}catch(u){this.onError(u)}}var Be=!1,Ue=null,Me=!1,Fe=null,$e={onError:function(e){Be=!0,Ue=e}};function He(e,t,n,r,o,i,s,a,l){Be=!1,Ue=null,De.apply($e,arguments)}function qe(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do{0!==(4098&(t=e).flags)&&(n=t.return),e=t.return}while(e)}return 3===t.tag?n:null}function je(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 Ve(e){if(qe(e)!==e)throw Error(i(188))}function ze(e){return null!==(e=function(e){var t=e.alternate;if(!t){if(null===(t=qe(e)))throw Error(i(188));return t!==e?null:e}for(var n=e,r=t;;){var o=n.return;if(null===o)break;var s=o.alternate;if(null===s){if(null!==(r=o.return)){n=r;continue}break}if(o.child===s.child){for(s=o.child;s;){if(s===n)return Ve(o),e;if(s===r)return Ve(o),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=o,r=s;else{for(var a=!1,l=o.child;l;){if(l===n){a=!0,n=o,r=s;break}if(l===r){a=!0,r=o,n=s;break}l=l.sibling}if(!a){for(l=s.child;l;){if(l===n){a=!0,n=s,r=o;break}if(l===r){a=!0,r=s,n=o;break}l=l.sibling}if(!a)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(3!==n.tag)throw Error(i(188));return n.stateNode.current===n?e:t}(e))?Ke(e):null}function Ke(e){if(5===e.tag||6===e.tag)return e;for(e=e.child;null!==e;){var t=Ke(e);if(null!==t)return t;e=e.sibling}return null}var We=o.unstable_scheduleCallback,Ge=o.unstable_cancelCallback,Ye=o.unstable_shouldYield,Qe=o.unstable_requestPaint,Je=o.unstable_now,Xe=o.unstable_getCurrentPriorityLevel,Ze=o.unstable_ImmediatePriority,et=o.unstable_UserBlockingPriority,tt=o.unstable_NormalPriority,nt=o.unstable_LowPriority,rt=o.unstable_IdlePriority,ot=null,it=null;var st=Math.clz32?Math.clz32:function(e){return e>>>=0,0===e?32:31-(at(e)/lt|0)|0},at=Math.log,lt=Math.LN2;var ct=64,ut=4194304;function dt(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return 4194240&e;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return 130023424&e;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ht(e,t){var n=e.pendingLanes;if(0===n)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,s=268435455&n;if(0!==s){var a=s&~o;0!==a?r=dt(a):0!==(i&=s)&&(r=dt(i))}else 0!==(s=n&~o)?r=dt(s):0!==i&&(r=dt(i));if(0===r)return 0;if(0!==t&&t!==r&&0===(t&o)&&((o=r&-r)>=(i=t&-t)||16===o&&0!==(4194240&i)))return t;if(0!==(4&r)&&(r|=16&n),0!==(t=e.entangledLanes))for(e=e.entanglements,t&=r;0<t;)o=1<<(n=31-st(t)),r|=e[n],t&=~o;return r}function ft(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;default:return-1}}function pt(e){return 0!==(e=-1073741825&e.pendingLanes)?e:1073741824&e?1073741824:0}function gt(){var e=ct;return 0===(4194240&(ct<<=1))&&(ct=64),e}function mt(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function yt(e,t,n){e.pendingLanes|=t,536870912!==t&&(e.suspendedLanes=0,e.pingedLanes=0),(e=e.eventTimes)[t=31-st(t)]=n}function bt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-st(n),o=1<<r;o&t|e[r]&t&&(e[r]|=t),n&=~o}}var wt=0;function vt(e){return 1<(e&=-e)?4<e?0!==(268435455&e)?16:536870912:4:1}var Et,St,kt,At,_t,It=!1,xt=[],Ct=null,Rt=null,Tt=null,Nt=new Map,Pt=new Map,Ot=[],Lt="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 Dt(e,t){switch(e){case"focusin":case"focusout":Ct=null;break;case"dragenter":case"dragleave":Rt=null;break;case"mouseover":case"mouseout":Tt=null;break;case"pointerover":case"pointerout":Nt.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Pt.delete(t.pointerId)}}function Bt(e,t,n,r,o,i){return null===e||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[o]},null!==t&&(null!==(t=vo(t))&&St(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,null!==o&&-1===t.indexOf(o)&&t.push(o),e)}function Ut(e){var t=wo(e.target);if(null!==t){var n=qe(t);if(null!==n)if(13===(t=n.tag)){if(null!==(t=je(n)))return e.blockedOn=t,void _t(e.priority,(function(){kt(n)}))}else if(3===t&&n.stateNode.current.memoizedState.isDehydrated)return void(e.blockedOn=3===n.tag?n.stateNode.containerInfo:null)}e.blockedOn=null}function Mt(e){if(null!==e.blockedOn)return!1;for(var t=e.targetContainers;0<t.length;){var n=Yt(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(null!==n)return null!==(t=vo(n))&&St(t),e.blockedOn=n,!1;var r=new(n=e.nativeEvent).constructor(n.type,n);ve=r,n.target.dispatchEvent(r),ve=null,t.shift()}return!0}function Ft(e,t,n){Mt(e)&&n.delete(t)}function $t(){It=!1,null!==Ct&&Mt(Ct)&&(Ct=null),null!==Rt&&Mt(Rt)&&(Rt=null),null!==Tt&&Mt(Tt)&&(Tt=null),Nt.forEach(Ft),Pt.forEach(Ft)}function Ht(e,t){e.blockedOn===t&&(e.blockedOn=null,It||(It=!0,o.unstable_scheduleCallback(o.unstable_NormalPriority,$t)))}function qt(e){function t(t){return Ht(t,e)}if(0<xt.length){Ht(xt[0],e);for(var n=1;n<xt.length;n++){var r=xt[n];r.blockedOn===e&&(r.blockedOn=null)}}for(null!==Ct&&Ht(Ct,e),null!==Rt&&Ht(Rt,e),null!==Tt&&Ht(Tt,e),Nt.forEach(t),Pt.forEach(t),n=0;n<Ot.length;n++)(r=Ot[n]).blockedOn===e&&(r.blockedOn=null);for(;0<Ot.length&&null===(n=Ot[0]).blockedOn;)Ut(n),null===n.blockedOn&&Ot.shift()}var jt=v.ReactCurrentBatchConfig,Vt=!0;function zt(e,t,n,r){var o=wt,i=jt.transition;jt.transition=null;try{wt=1,Wt(e,t,n,r)}finally{wt=o,jt.transition=i}}function Kt(e,t,n,r){var o=wt,i=jt.transition;jt.transition=null;try{wt=4,Wt(e,t,n,r)}finally{wt=o,jt.transition=i}}function Wt(e,t,n,r){if(Vt){var o=Yt(e,t,n,r);if(null===o)Vr(e,t,r,Gt,n),Dt(e,r);else if(function(e,t,n,r,o){switch(t){case"focusin":return Ct=Bt(Ct,e,t,n,r,o),!0;case"dragenter":return Rt=Bt(Rt,e,t,n,r,o),!0;case"mouseover":return Tt=Bt(Tt,e,t,n,r,o),!0;case"pointerover":var i=o.pointerId;return Nt.set(i,Bt(Nt.get(i)||null,e,t,n,r,o)),!0;case"gotpointercapture":return i=o.pointerId,Pt.set(i,Bt(Pt.get(i)||null,e,t,n,r,o)),!0}return!1}(o,e,t,n,r))r.stopPropagation();else if(Dt(e,r),4&t&&-1<Lt.indexOf(e)){for(;null!==o;){var i=vo(o);if(null!==i&&Et(i),null===(i=Yt(e,t,n,r))&&Vr(e,t,r,Gt,n),i===o)break;o=i}null!==o&&r.stopPropagation()}else Vr(e,t,r,null,n)}}var Gt=null;function Yt(e,t,n,r){if(Gt=null,null!==(e=wo(e=Ee(r))))if(null===(t=qe(e)))e=null;else if(13===(n=t.tag)){if(null!==(e=je(t)))return e;e=null}else if(3===n){if(t.stateNode.current.memoizedState.isDehydrated)return 3===t.tag?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Gt=e,null}function Qt(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(Xe()){case Ze:return 1;case et:return 4;case tt:case nt:return 16;case rt:return 536870912;default:return 16}default:return 16}}var Jt=null,Xt=null,Zt=null;function en(){if(Zt)return Zt;var e,t,n=Xt,r=n.length,o="value"in Jt?Jt.value:Jt.textContent,i=o.length;for(e=0;e<r&&n[e]===o[e];e++);var s=r-e;for(t=1;t<=s&&n[r-t]===o[i-t];t++);return Zt=o.slice(e,1<t?1-t:void 0)}function tn(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 nn(){return!0}function rn(){return!1}function on(e){function t(t,n,r,o,i){for(var s in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=o,this.target=i,this.currentTarget=null,e)e.hasOwnProperty(s)&&(t=e[s],this[s]=t?t(o):o[s]);return this.isDefaultPrevented=(null!=o.defaultPrevented?o.defaultPrevented:!1===o.returnValue)?nn:rn,this.isPropagationStopped=rn,this}return U(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=nn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():"unknown"!==typeof e.cancelBubble&&(e.cancelBubble=!0),this.isPropagationStopped=nn)},persist:function(){},isPersistent:nn}),t}var sn,an,ln,cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},un=on(cn),dn=U({},cn,{view:0,detail:0}),hn=on(dn),fn=U({},dn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_n,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!==ln&&(ln&&"mousemove"===e.type?(sn=e.screenX-ln.screenX,an=e.screenY-ln.screenY):an=sn=0,ln=e),sn)},movementY:function(e){return"movementY"in e?e.movementY:an}}),pn=on(fn),gn=on(U({},fn,{dataTransfer:0})),mn=on(U({},dn,{relatedTarget:0})),yn=on(U({},cn,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=U({},cn,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),wn=on(bn),vn=on(U({},cn,{data:0})),En={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Sn={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"},kn={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function An(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):!!(e=kn[e])&&!!t[e]}function _n(){return An}var In=U({},dn,{key:function(e){if(e.key){var t=En[e.key]||e.key;if("Unidentified"!==t)return t}return"keypress"===e.type?13===(e=tn(e))?"Enter":String.fromCharCode(e):"keydown"===e.type||"keyup"===e.type?Sn[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_n,charCode:function(e){return"keypress"===e.type?tn(e):0},keyCode:function(e){return"keydown"===e.type||"keyup"===e.type?e.keyCode:0},which:function(e){return"keypress"===e.type?tn(e):"keydown"===e.type||"keyup"===e.type?e.keyCode:0}}),xn=on(In),Cn=on(U({},fn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Rn=on(U({},dn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_n})),Tn=on(U({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Nn=U({},fn,{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}),Pn=on(Nn),On=[9,13,27,32],Ln=u&&"CompositionEvent"in window,Dn=null;u&&"documentMode"in document&&(Dn=document.documentMode);var Bn=u&&"TextEvent"in window&&!Dn,Un=u&&(!Ln||Dn&&8<Dn&&11>=Dn),Mn=String.fromCharCode(32),Fn=!1;function $n(e,t){switch(e){case"keyup":return-1!==On.indexOf(t.keyCode);case"keydown":return 229!==t.keyCode;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Hn(e){return"object"===typeof(e=e.detail)&&"data"in e?e.data:null}var qn=!1;var jn={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 Vn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return"input"===t?!!jn[e.type]:"textarea"===t}function zn(e,t,n,r){Ie(r),0<(t=Kr(t,"onChange")).length&&(n=new un("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Kn=null,Wn=null;function Gn(e){Mr(e,0)}function Yn(e){if(W(Eo(e)))return e}function Qn(e,t){if("change"===e)return t}var Jn=!1;if(u){var Xn;if(u){var Zn="oninput"in document;if(!Zn){var er=document.createElement("div");er.setAttribute("oninput","return;"),Zn="function"===typeof er.oninput}Xn=Zn}else Xn=!1;Jn=Xn&&(!document.documentMode||9<document.documentMode)}function tr(){Kn&&(Kn.detachEvent("onpropertychange",nr),Wn=Kn=null)}function nr(e){if("value"===e.propertyName&&Yn(Wn)){var t=[];zn(t,Wn,e,Ee(e)),Ne(Gn,t)}}function rr(e,t,n){"focusin"===e?(tr(),Wn=n,(Kn=t).attachEvent("onpropertychange",nr)):"focusout"===e&&tr()}function or(e){if("selectionchange"===e||"keyup"===e||"keydown"===e)return Yn(Wn)}function ir(e,t){if("click"===e)return Yn(t)}function sr(e,t){if("input"===e||"change"===e)return Yn(t)}var ar="function"===typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e===1/t)||e!==e&&t!==t};function lr(e,t){if(ar(e,t))return!0;if("object"!==typeof e||null===e||"object"!==typeof t||null===t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var o=n[r];if(!d.call(t,o)||!ar(e[o],t[o]))return!1}return!0}function cr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ur(e,t){var n,r=cr(e);for(e=0;r;){if(3===r.nodeType){if(n=e+r.textContent.length,e<=t&&n>=t)return{node:r,offset:t-e};e=n}e:{for(;r;){if(r.nextSibling){r=r.nextSibling;break e}r=r.parentNode}r=void 0}r=cr(r)}}function dr(e,t){return!(!e||!t)&&(e===t||(!e||3!==e.nodeType)&&(t&&3===t.nodeType?dr(e,t.parentNode):"contains"in e?e.contains(t):!!e.compareDocumentPosition&&!!(16&e.compareDocumentPosition(t))))}function hr(){for(var e=window,t=G();t instanceof e.HTMLIFrameElement;){try{var n="string"===typeof t.contentWindow.location.href}catch(r){n=!1}if(!n)break;t=G((e=t.contentWindow).document)}return t}function fr(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)}function pr(e){var t=hr(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&dr(n.ownerDocument.documentElement,n)){if(null!==r&&fr(n))if(t=r.start,void 0===(e=r.end)&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if((e=(t=n.ownerDocument||document)&&t.defaultView||window).getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=void 0===r.end?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=ur(n,i);var s=ur(n,r);o&&s&&(1!==e.rangeCount||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==s.node||e.focusOffset!==s.offset)&&((t=t.createRange()).setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(s.node,s.offset)):(t.setEnd(s.node,s.offset),e.addRange(t)))}for(t=[],e=n;e=e.parentNode;)1===e.nodeType&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for("function"===typeof n.focus&&n.focus(),n=0;n<t.length;n++)(e=t[n]).element.scrollLeft=e.left,e.element.scrollTop=e.top}}var gr=u&&"documentMode"in document&&11>=document.documentMode,mr=null,yr=null,br=null,wr=!1;function vr(e,t,n){var r=n.window===n?n.document:9===n.nodeType?n:n.ownerDocument;wr||null==mr||mr!==G(r)||("selectionStart"in(r=mr)&&fr(r)?r={start:r.selectionStart,end:r.selectionEnd}:r={anchorNode:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection()).anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset},br&&lr(br,r)||(br=r,0<(r=Kr(yr,"onSelect")).length&&(t=new un("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=mr)))}function Er(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Sr={animationend:Er("Animation","AnimationEnd"),animationiteration:Er("Animation","AnimationIteration"),animationstart:Er("Animation","AnimationStart"),transitionend:Er("Transition","TransitionEnd")},kr={},Ar={};function _r(e){if(kr[e])return kr[e];if(!Sr[e])return e;var t,n=Sr[e];for(t in n)if(n.hasOwnProperty(t)&&t in Ar)return kr[e]=n[t];return e}u&&(Ar=document.createElement("div").style,"AnimationEvent"in window||(delete Sr.animationend.animation,delete Sr.animationiteration.animation,delete Sr.animationstart.animation),"TransitionEvent"in window||delete Sr.transitionend.transition);var Ir=_r("animationend"),xr=_r("animationiteration"),Cr=_r("animationstart"),Rr=_r("transitionend"),Tr=new Map,Nr="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Pr(e,t){Tr.set(e,t),l(t,[e])}for(var Or=0;Or<Nr.length;Or++){var Lr=Nr[Or];Pr(Lr.toLowerCase(),"on"+(Lr[0].toUpperCase()+Lr.slice(1)))}Pr(Ir,"onAnimationEnd"),Pr(xr,"onAnimationIteration"),Pr(Cr,"onAnimationStart"),Pr("dblclick","onDoubleClick"),Pr("focusin","onFocus"),Pr("focusout","onBlur"),Pr(Rr,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Dr="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),Br=new Set("cancel close invalid load scroll toggle".split(" ").concat(Dr));function Ur(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,function(e,t,n,r,o,s,a,l,c){if(He.apply(this,arguments),Be){if(!Be)throw Error(i(198));var u=Ue;Be=!1,Ue=null,Me||(Me=!0,Fe=u)}}(r,t,void 0,e),e.currentTarget=null}function Mr(e,t){t=0!==(4&t);for(var n=0;n<e.length;n++){var r=e[n],o=r.event;r=r.listeners;e:{var i=void 0;if(t)for(var s=r.length-1;0<=s;s--){var a=r[s],l=a.instance,c=a.currentTarget;if(a=a.listener,l!==i&&o.isPropagationStopped())break e;Ur(o,a,c),i=l}else for(s=0;s<r.length;s++){if(l=(a=r[s]).instance,c=a.currentTarget,a=a.listener,l!==i&&o.isPropagationStopped())break e;Ur(o,a,c),i=l}}}if(Me)throw e=Fe,Me=!1,Fe=null,e}function Fr(e,t){var n=t[mo];void 0===n&&(n=t[mo]=new Set);var r=e+"__bubble";n.has(r)||(jr(t,e,2,!1),n.add(r))}function $r(e,t,n){var r=0;t&&(r|=4),jr(n,e,r,t)}var Hr="_reactListening"+Math.random().toString(36).slice(2);function qr(e){if(!e[Hr]){e[Hr]=!0,s.forEach((function(t){"selectionchange"!==t&&(Br.has(t)||$r(t,!1,e),$r(t,!0,e))}));var t=9===e.nodeType?e:e.ownerDocument;null===t||t[Hr]||(t[Hr]=!0,$r("selectionchange",!1,t))}}function jr(e,t,n,r){switch(Qt(t)){case 1:var o=zt;break;case 4:o=Kt;break;default:o=Wt}n=o.bind(null,t,n,e),o=void 0,!Oe||"touchstart"!==t&&"touchmove"!==t&&"wheel"!==t||(o=!0),r?void 0!==o?e.addEventListener(t,n,{capture:!0,passive:o}):e.addEventListener(t,n,!0):void 0!==o?e.addEventListener(t,n,{passive:o}):e.addEventListener(t,n,!1)}function Vr(e,t,n,r,o){var i=r;if(0===(1&t)&&0===(2&t)&&null!==r)e:for(;;){if(null===r)return;var s=r.tag;if(3===s||4===s){var a=r.stateNode.containerInfo;if(a===o||8===a.nodeType&&a.parentNode===o)break;if(4===s)for(s=r.return;null!==s;){var l=s.tag;if((3===l||4===l)&&((l=s.stateNode.containerInfo)===o||8===l.nodeType&&l.parentNode===o))return;s=s.return}for(;null!==a;){if(null===(s=wo(a)))return;if(5===(l=s.tag)||6===l){r=i=s;continue e}a=a.parentNode}}r=r.return}Ne((function(){var r=i,o=Ee(n),s=[];e:{var a=Tr.get(e);if(void 0!==a){var l=un,c=e;switch(e){case"keypress":if(0===tn(n))break e;case"keydown":case"keyup":l=xn;break;case"focusin":c="focus",l=mn;break;case"focusout":c="blur",l=mn;break;case"beforeblur":case"afterblur":l=mn;break;case"click":if(2===n.button)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":l=pn;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":l=gn;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":l=Rn;break;case Ir:case xr:case Cr:l=yn;break;case Rr:l=Tn;break;case"scroll":l=hn;break;case"wheel":l=Pn;break;case"copy":case"cut":case"paste":l=wn;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":l=Cn}var u=0!==(4&t),d=!u&&"scroll"===e,h=u?null!==a?a+"Capture":null:a;u=[];for(var f,p=r;null!==p;){var g=(f=p).stateNode;if(5===f.tag&&null!==g&&(f=g,null!==h&&(null!=(g=Pe(p,h))&&u.push(zr(p,g,f)))),d)break;p=p.return}0<u.length&&(a=new l(a,c,null,n,o),s.push({event:a,listeners:u}))}}if(0===(7&t)){if(l="mouseout"===e||"pointerout"===e,(!(a="mouseover"===e||"pointerover"===e)||n===ve||!(c=n.relatedTarget||n.fromElement)||!wo(c)&&!c[go])&&(l||a)&&(a=o.window===o?o:(a=o.ownerDocument)?a.defaultView||a.parentWindow:window,l?(l=r,null!==(c=(c=n.relatedTarget||n.toElement)?wo(c):null)&&(c!==(d=qe(c))||5!==c.tag&&6!==c.tag)&&(c=null)):(l=null,c=r),l!==c)){if(u=pn,g="onMouseLeave",h="onMouseEnter",p="mouse","pointerout"!==e&&"pointerover"!==e||(u=Cn,g="onPointerLeave",h="onPointerEnter",p="pointer"),d=null==l?a:Eo(l),f=null==c?a:Eo(c),(a=new u(g,p+"leave",l,n,o)).target=d,a.relatedTarget=f,g=null,wo(o)===r&&((u=new u(h,p+"enter",c,n,o)).target=f,u.relatedTarget=d,g=u),d=g,l&&c)e:{for(h=c,p=0,f=u=l;f;f=Wr(f))p++;for(f=0,g=h;g;g=Wr(g))f++;for(;0<p-f;)u=Wr(u),p--;for(;0<f-p;)h=Wr(h),f--;for(;p--;){if(u===h||null!==h&&u===h.alternate)break e;u=Wr(u),h=Wr(h)}u=null}else u=null;null!==l&&Gr(s,a,l,u,!1),null!==c&&null!==d&&Gr(s,d,c,u,!0)}if("select"===(l=(a=r?Eo(r):window).nodeName&&a.nodeName.toLowerCase())||"input"===l&&"file"===a.type)var m=Qn;else if(Vn(a))if(Jn)m=sr;else{m=or;var y=rr}else(l=a.nodeName)&&"input"===l.toLowerCase()&&("checkbox"===a.type||"radio"===a.type)&&(m=ir);switch(m&&(m=m(e,r))?zn(s,m,n,o):(y&&y(e,a,r),"focusout"===e&&(y=a._wrapperState)&&y.controlled&&"number"===a.type&&ee(a,"number",a.value)),y=r?Eo(r):window,e){case"focusin":(Vn(y)||"true"===y.contentEditable)&&(mr=y,yr=r,br=null);break;case"focusout":br=yr=mr=null;break;case"mousedown":wr=!0;break;case"contextmenu":case"mouseup":case"dragend":wr=!1,vr(s,n,o);break;case"selectionchange":if(gr)break;case"keydown":case"keyup":vr(s,n,o)}var b;if(Ln)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 qn?$n(e,n)&&(w="onCompositionEnd"):"keydown"===e&&229===n.keyCode&&(w="onCompositionStart");w&&(Un&&"ko"!==n.locale&&(qn||"onCompositionStart"!==w?"onCompositionEnd"===w&&qn&&(b=en()):(Xt="value"in(Jt=o)?Jt.value:Jt.textContent,qn=!0)),0<(y=Kr(r,w)).length&&(w=new vn(w,e,null,n,o),s.push({event:w,listeners:y}),b?w.data=b:null!==(b=Hn(n))&&(w.data=b))),(b=Bn?function(e,t){switch(e){case"compositionend":return Hn(t);case"keypress":return 32!==t.which?null:(Fn=!0,Mn);case"textInput":return(e=t.data)===Mn&&Fn?null:e;default:return null}}(e,n):function(e,t){if(qn)return"compositionend"===e||!Ln&&$n(e,t)?(e=en(),Zt=Xt=Jt=null,qn=!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 Un&&"ko"!==t.locale?null:t.data}}(e,n))&&(0<(r=Kr(r,"onBeforeInput")).length&&(o=new vn("onBeforeInput","beforeinput",null,n,o),s.push({event:o,listeners:r}),o.data=b))}Mr(s,t)}))}function zr(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Kr(e,t){for(var n=t+"Capture",r=[];null!==e;){var o=e,i=o.stateNode;5===o.tag&&null!==i&&(o=i,null!=(i=Pe(e,n))&&r.unshift(zr(e,i,o)),null!=(i=Pe(e,t))&&r.push(zr(e,i,o))),e=e.return}return r}function Wr(e){if(null===e)return null;do{e=e.return}while(e&&5!==e.tag);return e||null}function Gr(e,t,n,r,o){for(var i=t._reactName,s=[];null!==n&&n!==r;){var a=n,l=a.alternate,c=a.stateNode;if(null!==l&&l===r)break;5===a.tag&&null!==c&&(a=c,o?null!=(l=Pe(n,i))&&s.unshift(zr(n,l,a)):o||null!=(l=Pe(n,i))&&s.push(zr(n,l,a))),n=n.return}0!==s.length&&e.push({event:t,listeners:s})}var Yr=/\r\n?/g,Qr=/\u0000|\uFFFD/g;function Jr(e){return("string"===typeof e?e:""+e).replace(Yr,"\n").replace(Qr,"")}function Xr(e,t,n){if(t=Jr(t),Jr(e)!==t&&n)throw Error(i(425))}function Zr(){}var eo=null,to=null;function no(e,t){return"textarea"===e||"noscript"===e||"string"===typeof t.children||"number"===typeof t.children||"object"===typeof t.dangerouslySetInnerHTML&&null!==t.dangerouslySetInnerHTML&&null!=t.dangerouslySetInnerHTML.__html}var ro="function"===typeof setTimeout?setTimeout:void 0,oo="function"===typeof clearTimeout?clearTimeout:void 0,io="function"===typeof Promise?Promise:void 0,so="function"===typeof queueMicrotask?queueMicrotask:"undefined"!==typeof io?function(e){return io.resolve(null).then(e).catch(ao)}:ro;function ao(e){setTimeout((function(){throw e}))}function lo(e,t){var n=t,r=0;do{var o=n.nextSibling;if(e.removeChild(n),o&&8===o.nodeType)if("/$"===(n=o.data)){if(0===r)return e.removeChild(o),void qt(t);r--}else"$"!==n&&"$?"!==n&&"$!"!==n||r++;n=o}while(n);qt(t)}function co(e){for(;null!=e;e=e.nextSibling){var t=e.nodeType;if(1===t||3===t)break;if(8===t){if("$"===(t=e.data)||"$!"===t||"$?"===t)break;if("/$"===t)return null}}return e}function uo(e){e=e.previousSibling;for(var t=0;e;){if(8===e.nodeType){var n=e.data;if("$"===n||"$!"===n||"$?"===n){if(0===t)return e;t--}else"/$"===n&&t++}e=e.previousSibling}return null}var ho=Math.random().toString(36).slice(2),fo="__reactFiber$"+ho,po="__reactProps$"+ho,go="__reactContainer$"+ho,mo="__reactEvents$"+ho,yo="__reactListeners$"+ho,bo="__reactHandles$"+ho;function wo(e){var t=e[fo];if(t)return t;for(var n=e.parentNode;n;){if(t=n[go]||n[fo]){if(n=t.alternate,null!==t.child||null!==n&&null!==n.child)for(e=uo(e);null!==e;){if(n=e[fo])return n;e=uo(e)}return t}n=(e=n).parentNode}return null}function vo(e){return!(e=e[fo]||e[go])||5!==e.tag&&6!==e.tag&&13!==e.tag&&3!==e.tag?null:e}function Eo(e){if(5===e.tag||6===e.tag)return e.stateNode;throw Error(i(33))}function So(e){return e[po]||null}var ko=[],Ao=-1;function _o(e){return{current:e}}function Io(e){0>Ao||(e.current=ko[Ao],ko[Ao]=null,Ao--)}function xo(e,t){Ao++,ko[Ao]=e.current,e.current=t}var Co={},Ro=_o(Co),To=_o(!1),No=Co;function Po(e,t){var n=e.type.contextTypes;if(!n)return Co;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o,i={};for(o in n)i[o]=t[o];return r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function Oo(e){return null!==(e=e.childContextTypes)&&void 0!==e}function Lo(){Io(To),Io(Ro)}function Do(e,t,n){if(Ro.current!==Co)throw Error(i(168));xo(Ro,t),xo(To,n)}function Bo(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,"function"!==typeof r.getChildContext)return n;for(var o in r=r.getChildContext())if(!(o in t))throw Error(i(108,j(e)||"Unknown",o));return U({},n,r)}function Uo(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Co,No=Ro.current,xo(Ro,e),xo(To,To.current),!0}function Mo(e,t,n){var r=e.stateNode;if(!r)throw Error(i(169));n?(e=Bo(e,t,No),r.__reactInternalMemoizedMergedChildContext=e,Io(To),Io(Ro),xo(Ro,e)):Io(To),xo(To,n)}var Fo=null,$o=!1,Ho=!1;function qo(e){null===Fo?Fo=[e]:Fo.push(e)}function jo(){if(!Ho&&null!==Fo){Ho=!0;var e=0,t=wt;try{var n=Fo;for(wt=1;e<n.length;e++){var r=n[e];do{r=r(!0)}while(null!==r)}Fo=null,$o=!1}catch(o){throw null!==Fo&&(Fo=Fo.slice(e+1)),We(Ze,jo),o}finally{wt=t,Ho=!1}}return null}var Vo=[],zo=0,Ko=null,Wo=0,Go=[],Yo=0,Qo=null,Jo=1,Xo="";function Zo(e,t){Vo[zo++]=Wo,Vo[zo++]=Ko,Ko=e,Wo=t}function ei(e,t,n){Go[Yo++]=Jo,Go[Yo++]=Xo,Go[Yo++]=Qo,Qo=e;var r=Jo;e=Xo;var o=32-st(r)-1;r&=~(1<<o),n+=1;var i=32-st(t)+o;if(30<i){var s=o-o%5;i=(r&(1<<s)-1).toString(32),r>>=s,o-=s,Jo=1<<32-st(t)+o|n<<o|r,Xo=i+e}else Jo=1<<i|n<<o|r,Xo=e}function ti(e){null!==e.return&&(Zo(e,1),ei(e,1,0))}function ni(e){for(;e===Ko;)Ko=Vo[--zo],Vo[zo]=null,Wo=Vo[--zo],Vo[zo]=null;for(;e===Qo;)Qo=Go[--Yo],Go[Yo]=null,Xo=Go[--Yo],Go[Yo]=null,Jo=Go[--Yo],Go[Yo]=null}var ri=null,oi=null,ii=!1,si=null;function ai(e,t){var n=Nc(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,null===(t=e.deletions)?(e.deletions=[n],e.flags|=16):t.push(n)}function li(e,t){switch(e.tag){case 5:var n=e.type;return null!==(t=1!==t.nodeType||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t)&&(e.stateNode=t,ri=e,oi=co(t.firstChild),!0);case 6:return null!==(t=""===e.pendingProps||3!==t.nodeType?null:t)&&(e.stateNode=t,ri=e,oi=null,!0);case 13:return null!==(t=8!==t.nodeType?null:t)&&(n=null!==Qo?{id:Jo,overflow:Xo}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},(n=Nc(18,null,null,0)).stateNode=t,n.return=e,e.child=n,ri=e,oi=null,!0);default:return!1}}function ci(e){return 0!==(1&e.mode)&&0===(128&e.flags)}function ui(e){if(ii){var t=oi;if(t){var n=t;if(!li(e,t)){if(ci(e))throw Error(i(418));t=co(n.nextSibling);var r=ri;t&&li(e,t)?ai(r,n):(e.flags=-4097&e.flags|2,ii=!1,ri=e)}}else{if(ci(e))throw Error(i(418));e.flags=-4097&e.flags|2,ii=!1,ri=e}}}function di(e){for(e=e.return;null!==e&&5!==e.tag&&3!==e.tag&&13!==e.tag;)e=e.return;ri=e}function hi(e){if(e!==ri)return!1;if(!ii)return di(e),ii=!0,!1;var t;if((t=3!==e.tag)&&!(t=5!==e.tag)&&(t="head"!==(t=e.type)&&"body"!==t&&!no(e.type,e.memoizedProps)),t&&(t=oi)){if(ci(e))throw fi(),Error(i(418));for(;t;)ai(e,t),t=co(t.nextSibling)}if(di(e),13===e.tag){if(!(e=null!==(e=e.memoizedState)?e.dehydrated:null))throw Error(i(317));e:{for(e=e.nextSibling,t=0;e;){if(8===e.nodeType){var n=e.data;if("/$"===n){if(0===t){oi=co(e.nextSibling);break e}t--}else"$"!==n&&"$!"!==n&&"$?"!==n||t++}e=e.nextSibling}oi=null}}else oi=ri?co(e.stateNode.nextSibling):null;return!0}function fi(){for(var e=oi;e;)e=co(e.nextSibling)}function pi(){oi=ri=null,ii=!1}function gi(e){null===si?si=[e]:si.push(e)}var mi=v.ReactCurrentBatchConfig;function yi(e,t,n){if(null!==(e=n.ref)&&"function"!==typeof e&&"object"!==typeof e){if(n._owner){if(n=n._owner){if(1!==n.tag)throw Error(i(309));var r=n.stateNode}if(!r)throw Error(i(147,e));var o=r,s=""+e;return null!==t&&null!==t.ref&&"function"===typeof t.ref&&t.ref._stringRef===s?t.ref:(t=function(e){var t=o.refs;null===e?delete t[s]:t[s]=e},t._stringRef=s,t)}if("string"!==typeof e)throw Error(i(284));if(!n._owner)throw Error(i(290,e))}return e}function bi(e,t){throw e=Object.prototype.toString.call(t),Error(i(31,"[object Object]"===e?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function wi(e){return(0,e._init)(e._payload)}function vi(e){function t(t,n){if(e){var r=t.deletions;null===r?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;null!==r;)t(n,r),r=r.sibling;return null}function r(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 o(e,t){return(e=Oc(e,t)).index=0,e.sibling=null,e}function s(t,n,r){return t.index=r,e?null!==(r=t.alternate)?(r=r.index)<n?(t.flags|=2,n):r:(t.flags|=2,n):(t.flags|=1048576,n)}function a(t){return e&&null===t.alternate&&(t.flags|=2),t}function l(e,t,n,r){return null===t||6!==t.tag?((t=Uc(n,e.mode,r)).return=e,t):((t=o(t,n)).return=e,t)}function c(e,t,n,r){var i=n.type;return i===k?d(e,t,n.props.children,r,n.key):null!==t&&(t.elementType===i||"object"===typeof i&&null!==i&&i.$$typeof===P&&wi(i)===t.type)?((r=o(t,n.props)).ref=yi(e,t,n),r.return=e,r):((r=Lc(n.type,n.key,n.props,null,e.mode,r)).ref=yi(e,t,n),r.return=e,r)}function u(e,t,n,r){return null===t||4!==t.tag||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?((t=Mc(n,e.mode,r)).return=e,t):((t=o(t,n.children||[])).return=e,t)}function d(e,t,n,r,i){return null===t||7!==t.tag?((t=Dc(n,e.mode,r,i)).return=e,t):((t=o(t,n)).return=e,t)}function h(e,t,n){if("string"===typeof t&&""!==t||"number"===typeof t)return(t=Uc(""+t,e.mode,n)).return=e,t;if("object"===typeof t&&null!==t){switch(t.$$typeof){case E:return(n=Lc(t.type,t.key,t.props,null,e.mode,n)).ref=yi(e,null,t),n.return=e,n;case S:return(t=Mc(t,e.mode,n)).return=e,t;case P:return h(e,(0,t._init)(t._payload),n)}if(te(t)||D(t))return(t=Dc(t,e.mode,n,null)).return=e,t;bi(e,t)}return null}function f(e,t,n,r){var o=null!==t?t.key:null;if("string"===typeof n&&""!==n||"number"===typeof n)return null!==o?null:l(e,t,""+n,r);if("object"===typeof n&&null!==n){switch(n.$$typeof){case E:return n.key===o?c(e,t,n,r):null;case S:return n.key===o?u(e,t,n,r):null;case P:return f(e,t,(o=n._init)(n._payload),r)}if(te(n)||D(n))return null!==o?null:d(e,t,n,r,null);bi(e,n)}return null}function p(e,t,n,r,o){if("string"===typeof r&&""!==r||"number"===typeof r)return l(t,e=e.get(n)||null,""+r,o);if("object"===typeof r&&null!==r){switch(r.$$typeof){case E:return c(t,e=e.get(null===r.key?n:r.key)||null,r,o);case S:return u(t,e=e.get(null===r.key?n:r.key)||null,r,o);case P:return p(e,t,n,(0,r._init)(r._payload),o)}if(te(r)||D(r))return d(t,e=e.get(n)||null,r,o,null);bi(t,r)}return null}function g(o,i,a,l){for(var c=null,u=null,d=i,g=i=0,m=null;null!==d&&g<a.length;g++){d.index>g?(m=d,d=null):m=d.sibling;var y=f(o,d,a[g],l);if(null===y){null===d&&(d=m);break}e&&d&&null===y.alternate&&t(o,d),i=s(y,i,g),null===u?c=y:u.sibling=y,u=y,d=m}if(g===a.length)return n(o,d),ii&&Zo(o,g),c;if(null===d){for(;g<a.length;g++)null!==(d=h(o,a[g],l))&&(i=s(d,i,g),null===u?c=d:u.sibling=d,u=d);return ii&&Zo(o,g),c}for(d=r(o,d);g<a.length;g++)null!==(m=p(d,o,g,a[g],l))&&(e&&null!==m.alternate&&d.delete(null===m.key?g:m.key),i=s(m,i,g),null===u?c=m:u.sibling=m,u=m);return e&&d.forEach((function(e){return t(o,e)})),ii&&Zo(o,g),c}function m(o,a,l,c){var u=D(l);if("function"!==typeof u)throw Error(i(150));if(null==(l=u.call(l)))throw Error(i(151));for(var d=u=null,g=a,m=a=0,y=null,b=l.next();null!==g&&!b.done;m++,b=l.next()){g.index>m?(y=g,g=null):y=g.sibling;var w=f(o,g,b.value,c);if(null===w){null===g&&(g=y);break}e&&g&&null===w.alternate&&t(o,g),a=s(w,a,m),null===d?u=w:d.sibling=w,d=w,g=y}if(b.done)return n(o,g),ii&&Zo(o,m),u;if(null===g){for(;!b.done;m++,b=l.next())null!==(b=h(o,b.value,c))&&(a=s(b,a,m),null===d?u=b:d.sibling=b,d=b);return ii&&Zo(o,m),u}for(g=r(o,g);!b.done;m++,b=l.next())null!==(b=p(g,o,m,b.value,c))&&(e&&null!==b.alternate&&g.delete(null===b.key?m:b.key),a=s(b,a,m),null===d?u=b:d.sibling=b,d=b);return e&&g.forEach((function(e){return t(o,e)})),ii&&Zo(o,m),u}return function e(r,i,s,l){if("object"===typeof s&&null!==s&&s.type===k&&null===s.key&&(s=s.props.children),"object"===typeof s&&null!==s){switch(s.$$typeof){case E:e:{for(var c=s.key,u=i;null!==u;){if(u.key===c){if((c=s.type)===k){if(7===u.tag){n(r,u.sibling),(i=o(u,s.props.children)).return=r,r=i;break e}}else if(u.elementType===c||"object"===typeof c&&null!==c&&c.$$typeof===P&&wi(c)===u.type){n(r,u.sibling),(i=o(u,s.props)).ref=yi(r,u,s),i.return=r,r=i;break e}n(r,u);break}t(r,u),u=u.sibling}s.type===k?((i=Dc(s.props.children,r.mode,l,s.key)).return=r,r=i):((l=Lc(s.type,s.key,s.props,null,r.mode,l)).ref=yi(r,i,s),l.return=r,r=l)}return a(r);case S:e:{for(u=s.key;null!==i;){if(i.key===u){if(4===i.tag&&i.stateNode.containerInfo===s.containerInfo&&i.stateNode.implementation===s.implementation){n(r,i.sibling),(i=o(i,s.children||[])).return=r,r=i;break e}n(r,i);break}t(r,i),i=i.sibling}(i=Mc(s,r.mode,l)).return=r,r=i}return a(r);case P:return e(r,i,(u=s._init)(s._payload),l)}if(te(s))return g(r,i,s,l);if(D(s))return m(r,i,s,l);bi(r,s)}return"string"===typeof s&&""!==s||"number"===typeof s?(s=""+s,null!==i&&6===i.tag?(n(r,i.sibling),(i=o(i,s)).return=r,r=i):(n(r,i),(i=Uc(s,r.mode,l)).return=r,r=i),a(r)):n(r,i)}}var Ei=vi(!0),Si=vi(!1),ki=_o(null),Ai=null,_i=null,Ii=null;function xi(){Ii=_i=Ai=null}function Ci(e){var t=ki.current;Io(ki),e._currentValue=t}function Ri(e,t,n){for(;null!==e;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,null!==r&&(r.childLanes|=t)):null!==r&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Ti(e,t){Ai=e,Ii=_i=null,null!==(e=e.dependencies)&&null!==e.firstContext&&(0!==(e.lanes&t)&&(wa=!0),e.firstContext=null)}function Ni(e){var t=e._currentValue;if(Ii!==e)if(e={context:e,memoizedValue:t,next:null},null===_i){if(null===Ai)throw Error(i(308));_i=e,Ai.dependencies={lanes:0,firstContext:e}}else _i=_i.next=e;return t}var Pi=null;function Oi(e){null===Pi?Pi=[e]:Pi.push(e)}function Li(e,t,n,r){var o=t.interleaved;return null===o?(n.next=n,Oi(t)):(n.next=o.next,o.next=n),t.interleaved=n,Di(e,r)}function Di(e,t){e.lanes|=t;var n=e.alternate;for(null!==n&&(n.lanes|=t),n=e,e=e.return;null!==e;)e.childLanes|=t,null!==(n=e.alternate)&&(n.childLanes|=t),n=e,e=e.return;return 3===n.tag?n.stateNode:null}var Bi=!1;function Ui(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Mi(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 Fi(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function $i(e,t,n){var r=e.updateQueue;if(null===r)return null;if(r=r.shared,0!==(2&Cl)){var o=r.pending;return null===o?t.next=t:(t.next=o.next,o.next=t),r.pending=t,Di(e,n)}return null===(o=r.interleaved)?(t.next=t,Oi(r)):(t.next=o.next,o.next=t),r.interleaved=t,Di(e,n)}function Hi(e,t,n){if(null!==(t=t.updateQueue)&&(t=t.shared,0!==(4194240&n))){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}function qi(e,t){var n=e.updateQueue,r=e.alternate;if(null!==r&&n===(r=r.updateQueue)){var o=null,i=null;if(null!==(n=n.firstBaseUpdate)){do{var s={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};null===i?o=i=s:i=i.next=s,n=n.next}while(null!==n);null===i?o=i=t:i=i.next=t}else o=i=t;return n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:r.shared,effects:r.effects},void(e.updateQueue=n)}null===(e=n.lastBaseUpdate)?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ji(e,t,n,r){var o=e.updateQueue;Bi=!1;var i=o.firstBaseUpdate,s=o.lastBaseUpdate,a=o.shared.pending;if(null!==a){o.shared.pending=null;var l=a,c=l.next;l.next=null,null===s?i=c:s.next=c,s=l;var u=e.alternate;null!==u&&((a=(u=u.updateQueue).lastBaseUpdate)!==s&&(null===a?u.firstBaseUpdate=c:a.next=c,u.lastBaseUpdate=l))}if(null!==i){var d=o.baseState;for(s=0,u=c=l=null,a=i;;){var h=a.lane,f=a.eventTime;if((r&h)===h){null!==u&&(u=u.next={eventTime:f,lane:0,tag:a.tag,payload:a.payload,callback:a.callback,next:null});e:{var p=e,g=a;switch(h=t,f=n,g.tag){case 1:if("function"===typeof(p=g.payload)){d=p.call(f,d,h);break e}d=p;break e;case 3:p.flags=-65537&p.flags|128;case 0:if(null===(h="function"===typeof(p=g.payload)?p.call(f,d,h):p)||void 0===h)break e;d=U({},d,h);break e;case 2:Bi=!0}}null!==a.callback&&0!==a.lane&&(e.flags|=64,null===(h=o.effects)?o.effects=[a]:h.push(a))}else f={eventTime:f,lane:h,tag:a.tag,payload:a.payload,callback:a.callback,next:null},null===u?(c=u=f,l=d):u=u.next=f,s|=h;if(null===(a=a.next)){if(null===(a=o.shared.pending))break;a=(h=a).next,h.next=null,o.lastBaseUpdate=h,o.shared.pending=null}}if(null===u&&(l=d),o.baseState=l,o.firstBaseUpdate=c,o.lastBaseUpdate=u,null!==(t=o.shared.interleaved)){o=t;do{s|=o.lane,o=o.next}while(o!==t)}else null===i&&(o.shared.lanes=0);Bl|=s,e.lanes=s,e.memoizedState=d}}function Vi(e,t,n){if(e=t.effects,t.effects=null,null!==e)for(t=0;t<e.length;t++){var r=e[t],o=r.callback;if(null!==o){if(r.callback=null,r=n,"function"!==typeof o)throw Error(i(191,o));o.call(r)}}}var zi={},Ki=_o(zi),Wi=_o(zi),Gi=_o(zi);function Yi(e){if(e===zi)throw Error(i(174));return e}function Qi(e,t){switch(xo(Gi,t),xo(Wi,e),xo(Ki,zi),e=t.nodeType){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:le(null,"");break;default:t=le(t=(e=8===e?t.parentNode:t).namespaceURI||null,e=e.tagName)}Io(Ki),xo(Ki,t)}function Ji(){Io(Ki),Io(Wi),Io(Gi)}function Xi(e){Yi(Gi.current);var t=Yi(Ki.current),n=le(t,e.type);t!==n&&(xo(Wi,e),xo(Ki,n))}function Zi(e){Wi.current===e&&(Io(Ki),Io(Wi))}var es=_o(0);function ts(e){for(var t=e;null!==t;){if(13===t.tag){var n=t.memoizedState;if(null!==n&&(null===(n=n.dehydrated)||"$?"===n.data||"$!"===n.data))return t}else if(19===t.tag&&void 0!==t.memoizedProps.revealOrder){if(0!==(128&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 ns=[];function rs(){for(var e=0;e<ns.length;e++)ns[e]._workInProgressVersionPrimary=null;ns.length=0}var os=v.ReactCurrentDispatcher,is=v.ReactCurrentBatchConfig,ss=0,as=null,ls=null,cs=null,us=!1,ds=!1,hs=0,fs=0;function ps(){throw Error(i(321))}function gs(e,t){if(null===t)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ar(e[n],t[n]))return!1;return!0}function ms(e,t,n,r,o,s){if(ss=s,as=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,os.current=null===e||null===e.memoizedState?Zs:ea,e=n(r,o),ds){s=0;do{if(ds=!1,hs=0,25<=s)throw Error(i(301));s+=1,cs=ls=null,t.updateQueue=null,os.current=ta,e=n(r,o)}while(ds)}if(os.current=Xs,t=null!==ls&&null!==ls.next,ss=0,cs=ls=as=null,us=!1,t)throw Error(i(300));return e}function ys(){var e=0!==hs;return hs=0,e}function bs(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return null===cs?as.memoizedState=cs=e:cs=cs.next=e,cs}function ws(){if(null===ls){var e=as.alternate;e=null!==e?e.memoizedState:null}else e=ls.next;var t=null===cs?as.memoizedState:cs.next;if(null!==t)cs=t,ls=e;else{if(null===e)throw Error(i(310));e={memoizedState:(ls=e).memoizedState,baseState:ls.baseState,baseQueue:ls.baseQueue,queue:ls.queue,next:null},null===cs?as.memoizedState=cs=e:cs=cs.next=e}return cs}function vs(e,t){return"function"===typeof t?t(e):t}function Es(e){var t=ws(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var r=ls,o=r.baseQueue,s=n.pending;if(null!==s){if(null!==o){var a=o.next;o.next=s.next,s.next=a}r.baseQueue=o=s,n.pending=null}if(null!==o){s=o.next,r=r.baseState;var l=a=null,c=null,u=s;do{var d=u.lane;if((ss&d)===d)null!==c&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var h={lane:d,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};null===c?(l=c=h,a=r):c=c.next=h,as.lanes|=d,Bl|=d}u=u.next}while(null!==u&&u!==s);null===c?a=r:c.next=l,ar(r,t.memoizedState)||(wa=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(null!==(e=n.interleaved)){o=e;do{s=o.lane,as.lanes|=s,Bl|=s,o=o.next}while(o!==e)}else null===o&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ss(e){var t=ws(),n=t.queue;if(null===n)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,o=n.pending,s=t.memoizedState;if(null!==o){n.pending=null;var a=o=o.next;do{s=e(s,a.action),a=a.next}while(a!==o);ar(s,t.memoizedState)||(wa=!0),t.memoizedState=s,null===t.baseQueue&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function ks(){}function As(e,t){var n=as,r=ws(),o=t(),s=!ar(r.memoizedState,o);if(s&&(r.memoizedState=o,wa=!0),r=r.queue,Bs(xs.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||null!==cs&&1&cs.memoizedState.tag){if(n.flags|=2048,Ns(9,Is.bind(null,n,r,o,t),void 0,null),null===Rl)throw Error(i(349));0!==(30&ss)||_s(n,t,o)}return o}function _s(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},null===(t=as.updateQueue)?(t={lastEffect:null,stores:null},as.updateQueue=t,t.stores=[e]):null===(n=t.stores)?t.stores=[e]:n.push(e)}function Is(e,t,n,r){t.value=n,t.getSnapshot=r,Cs(t)&&Rs(e)}function xs(e,t,n){return n((function(){Cs(t)&&Rs(e)}))}function Cs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ar(e,n)}catch(r){return!0}}function Rs(e){var t=Di(e,1);null!==t&&nc(t,e,1,-1)}function Ts(e){var t=bs();return"function"===typeof e&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:vs,lastRenderedState:e},t.queue=e,e=e.dispatch=Gs.bind(null,as,e),[t.memoizedState,e]}function Ns(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},null===(t=as.updateQueue)?(t={lastEffect:null,stores:null},as.updateQueue=t,t.lastEffect=e.next=e):null===(n=t.lastEffect)?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Ps(){return ws().memoizedState}function Os(e,t,n,r){var o=bs();as.flags|=e,o.memoizedState=Ns(1|t,n,void 0,void 0===r?null:r)}function Ls(e,t,n,r){var o=ws();r=void 0===r?null:r;var i=void 0;if(null!==ls){var s=ls.memoizedState;if(i=s.destroy,null!==r&&gs(r,s.deps))return void(o.memoizedState=Ns(t,n,i,r))}as.flags|=e,o.memoizedState=Ns(1|t,n,i,r)}function Ds(e,t){return Os(8390656,8,e,t)}function Bs(e,t){return Ls(2048,8,e,t)}function Us(e,t){return Ls(4,2,e,t)}function Ms(e,t){return Ls(4,4,e,t)}function Fs(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 $s(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,Ls(4,4,Fs.bind(null,t,e),n)}function Hs(){}function qs(e,t){var n=ws();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&gs(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function js(e,t){var n=ws();t=void 0===t?null:t;var r=n.memoizedState;return null!==r&&null!==t&&gs(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function Vs(e,t,n){return 0===(21&ss)?(e.baseState&&(e.baseState=!1,wa=!0),e.memoizedState=n):(ar(n,t)||(n=gt(),as.lanes|=n,Bl|=n,e.baseState=!0),t)}function zs(e,t){var n=wt;wt=0!==n&&4>n?n:4,e(!0);var r=is.transition;is.transition={};try{e(!1),t()}finally{wt=n,is.transition=r}}function Ks(){return ws().memoizedState}function Ws(e,t,n){var r=tc(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ys(e))Qs(t,n);else if(null!==(n=Li(e,t,n,r))){nc(n,e,r,ec()),Js(n,t,r)}}function Gs(e,t,n){var r=tc(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ys(e))Qs(t,o);else{var i=e.alternate;if(0===e.lanes&&(null===i||0===i.lanes)&&null!==(i=t.lastRenderedReducer))try{var s=t.lastRenderedState,a=i(s,n);if(o.hasEagerState=!0,o.eagerState=a,ar(a,s)){var l=t.interleaved;return null===l?(o.next=o,Oi(t)):(o.next=l.next,l.next=o),void(t.interleaved=o)}}catch(c){}null!==(n=Li(e,t,o,r))&&(nc(n,e,r,o=ec()),Js(n,t,r))}}function Ys(e){var t=e.alternate;return e===as||null!==t&&t===as}function Qs(e,t){ds=us=!0;var n=e.pending;null===n?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Js(e,t,n){if(0!==(4194240&n)){var r=t.lanes;n|=r&=e.pendingLanes,t.lanes=n,bt(e,n)}}var Xs={readContext:Ni,useCallback:ps,useContext:ps,useEffect:ps,useImperativeHandle:ps,useInsertionEffect:ps,useLayoutEffect:ps,useMemo:ps,useReducer:ps,useRef:ps,useState:ps,useDebugValue:ps,useDeferredValue:ps,useTransition:ps,useMutableSource:ps,useSyncExternalStore:ps,useId:ps,unstable_isNewReconciler:!1},Zs={readContext:Ni,useCallback:function(e,t){return bs().memoizedState=[e,void 0===t?null:t],e},useContext:Ni,useEffect:Ds,useImperativeHandle:function(e,t,n){return n=null!==n&&void 0!==n?n.concat([e]):null,Os(4194308,4,Fs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Os(4194308,4,e,t)},useInsertionEffect:function(e,t){return Os(4,2,e,t)},useMemo:function(e,t){var n=bs();return t=void 0===t?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=bs();return t=void 0!==n?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Ws.bind(null,as,e),[r.memoizedState,e]},useRef:function(e){return e={current:e},bs().memoizedState=e},useState:Ts,useDebugValue:Hs,useDeferredValue:function(e){return bs().memoizedState=e},useTransition:function(){var e=Ts(!1),t=e[0];return e=zs.bind(null,e[1]),bs().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=as,o=bs();if(ii){if(void 0===n)throw Error(i(407));n=n()}else{if(n=t(),null===Rl)throw Error(i(349));0!==(30&ss)||_s(r,t,n)}o.memoizedState=n;var s={value:n,getSnapshot:t};return o.queue=s,Ds(xs.bind(null,r,s,e),[e]),r.flags|=2048,Ns(9,Is.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=bs(),t=Rl.identifierPrefix;if(ii){var n=Xo;t=":"+t+"R"+(n=(Jo&~(1<<32-st(Jo)-1)).toString(32)+n),0<(n=hs++)&&(t+="H"+n.toString(32)),t+=":"}else t=":"+t+"r"+(n=fs++).toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},ea={readContext:Ni,useCallback:qs,useContext:Ni,useEffect:Bs,useImperativeHandle:$s,useInsertionEffect:Us,useLayoutEffect:Ms,useMemo:js,useReducer:Es,useRef:Ps,useState:function(){return Es(vs)},useDebugValue:Hs,useDeferredValue:function(e){return Vs(ws(),ls.memoizedState,e)},useTransition:function(){return[Es(vs)[0],ws().memoizedState]},useMutableSource:ks,useSyncExternalStore:As,useId:Ks,unstable_isNewReconciler:!1},ta={readContext:Ni,useCallback:qs,useContext:Ni,useEffect:Bs,useImperativeHandle:$s,useInsertionEffect:Us,useLayoutEffect:Ms,useMemo:js,useReducer:Ss,useRef:Ps,useState:function(){return Ss(vs)},useDebugValue:Hs,useDeferredValue:function(e){var t=ws();return null===ls?t.memoizedState=e:Vs(t,ls.memoizedState,e)},useTransition:function(){return[Ss(vs)[0],ws().memoizedState]},useMutableSource:ks,useSyncExternalStore:As,useId:Ks,unstable_isNewReconciler:!1};function na(e,t){if(e&&e.defaultProps){for(var n in t=U({},t),e=e.defaultProps)void 0===t[n]&&(t[n]=e[n]);return t}return t}function ra(e,t,n,r){n=null===(n=n(r,t=e.memoizedState))||void 0===n?t:U({},t,n),e.memoizedState=n,0===e.lanes&&(e.updateQueue.baseState=n)}var oa={isMounted:function(e){return!!(e=e._reactInternals)&&qe(e)===e},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ec(),o=tc(e),i=Fi(r,o);i.payload=t,void 0!==n&&null!==n&&(i.callback=n),null!==(t=$i(e,i,o))&&(nc(t,e,o,r),Hi(t,e,o))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ec(),o=tc(e),i=Fi(r,o);i.tag=1,i.payload=t,void 0!==n&&null!==n&&(i.callback=n),null!==(t=$i(e,i,o))&&(nc(t,e,o,r),Hi(t,e,o))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ec(),r=tc(e),o=Fi(n,r);o.tag=2,void 0!==t&&null!==t&&(o.callback=t),null!==(t=$i(e,o,r))&&(nc(t,e,r,n),Hi(t,e,r))}};function ia(e,t,n,r,o,i,s){return"function"===typeof(e=e.stateNode).shouldComponentUpdate?e.shouldComponentUpdate(r,i,s):!t.prototype||!t.prototype.isPureReactComponent||(!lr(n,r)||!lr(o,i))}function sa(e,t,n){var r=!1,o=Co,i=t.contextType;return"object"===typeof i&&null!==i?i=Ni(i):(o=Oo(t)?No:Ro.current,i=(r=null!==(r=t.contextTypes)&&void 0!==r)?Po(e,o):Co),t=new t(n,i),e.memoizedState=null!==t.state&&void 0!==t.state?t.state:null,t.updater=oa,e.stateNode=t,t._reactInternals=e,r&&((e=e.stateNode).__reactInternalMemoizedUnmaskedChildContext=o,e.__reactInternalMemoizedMaskedChildContext=i),t}function aa(e,t,n,r){e=t.state,"function"===typeof t.componentWillReceiveProps&&t.componentWillReceiveProps(n,r),"function"===typeof t.UNSAFE_componentWillReceiveProps&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&oa.enqueueReplaceState(t,t.state,null)}function la(e,t,n,r){var o=e.stateNode;o.props=n,o.state=e.memoizedState,o.refs={},Ui(e);var i=t.contextType;"object"===typeof i&&null!==i?o.context=Ni(i):(i=Oo(t)?No:Ro.current,o.context=Po(e,i)),o.state=e.memoizedState,"function"===typeof(i=t.getDerivedStateFromProps)&&(ra(e,t,i,n),o.state=e.memoizedState),"function"===typeof t.getDerivedStateFromProps||"function"===typeof o.getSnapshotBeforeUpdate||"function"!==typeof o.UNSAFE_componentWillMount&&"function"!==typeof o.componentWillMount||(t=o.state,"function"===typeof o.componentWillMount&&o.componentWillMount(),"function"===typeof o.UNSAFE_componentWillMount&&o.UNSAFE_componentWillMount(),t!==o.state&&oa.enqueueReplaceState(o,o.state,null),ji(e,n,o,r),o.state=e.memoizedState),"function"===typeof o.componentDidMount&&(e.flags|=4194308)}function ca(e,t){try{var n="",r=t;do{n+=H(r),r=r.return}while(r);var o=n}catch(i){o="\nError generating stack: "+i.message+"\n"+i.stack}return{value:e,source:t,stack:o,digest:null}}function ua(e,t,n){return{value:e,source:null,stack:null!=n?n:null,digest:null!=t?t:null}}function da(e,t){try{console.error(t.value)}catch(n){setTimeout((function(){throw n}))}}var ha="function"===typeof WeakMap?WeakMap:Map;function fa(e,t,n){(n=Fi(-1,n)).tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Vl||(Vl=!0,zl=r),da(0,t)},n}function pa(e,t,n){(n=Fi(-1,n)).tag=3;var r=e.type.getDerivedStateFromError;if("function"===typeof r){var o=t.value;n.payload=function(){return r(o)},n.callback=function(){da(0,t)}}var i=e.stateNode;return null!==i&&"function"===typeof i.componentDidCatch&&(n.callback=function(){da(0,t),"function"!==typeof r&&(null===Kl?Kl=new Set([this]):Kl.add(this));var e=t.stack;this.componentDidCatch(t.value,{componentStack:null!==e?e:""})}),n}function ga(e,t,n){var r=e.pingCache;if(null===r){r=e.pingCache=new ha;var o=new Set;r.set(t,o)}else void 0===(o=r.get(t))&&(o=new Set,r.set(t,o));o.has(n)||(o.add(n),e=_c.bind(null,e,t,n),t.then(e,e))}function ma(e){do{var t;if((t=13===e.tag)&&(t=null===(t=e.memoizedState)||null!==t.dehydrated),t)return e;e=e.return}while(null!==e);return null}function ya(e,t,n,r,o){return 0===(1&e.mode)?(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,1===n.tag&&(null===n.alternate?n.tag=17:((t=Fi(-1,1)).tag=2,$i(n,t,1))),n.lanes|=1),e):(e.flags|=65536,e.lanes=o,e)}var ba=v.ReactCurrentOwner,wa=!1;function va(e,t,n,r){t.child=null===e?Si(t,null,n,r):Ei(t,e.child,n,r)}function Ea(e,t,n,r,o){n=n.render;var i=t.ref;return Ti(t,o),r=ms(e,t,n,r,i,o),n=ys(),null===e||wa?(ii&&n&&ti(t),t.flags|=1,va(e,t,r,o),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Va(e,t,o))}function Sa(e,t,n,r,o){if(null===e){var i=n.type;return"function"!==typeof i||Pc(i)||void 0!==i.defaultProps||null!==n.compare||void 0!==n.defaultProps?((e=Lc(n.type,null,r,t,t.mode,o)).ref=t.ref,e.return=t,t.child=e):(t.tag=15,t.type=i,ka(e,t,i,r,o))}if(i=e.child,0===(e.lanes&o)){var s=i.memoizedProps;if((n=null!==(n=n.compare)?n:lr)(s,r)&&e.ref===t.ref)return Va(e,t,o)}return t.flags|=1,(e=Oc(i,r)).ref=t.ref,e.return=t,t.child=e}function ka(e,t,n,r,o){if(null!==e){var i=e.memoizedProps;if(lr(i,r)&&e.ref===t.ref){if(wa=!1,t.pendingProps=r=i,0===(e.lanes&o))return t.lanes=e.lanes,Va(e,t,o);0!==(131072&e.flags)&&(wa=!0)}}return Ia(e,t,n,r,o)}function Aa(e,t,n){var r=t.pendingProps,o=r.children,i=null!==e?e.memoizedState:null;if("hidden"===r.mode)if(0===(1&t.mode))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},xo(Ol,Pl),Pl|=n;else{if(0===(1073741824&n))return e=null!==i?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,xo(Ol,Pl),Pl|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=null!==i?i.baseLanes:n,xo(Ol,Pl),Pl|=r}else null!==i?(r=i.baseLanes|n,t.memoizedState=null):r=n,xo(Ol,Pl),Pl|=r;return va(e,t,o,n),t.child}function _a(e,t){var n=t.ref;(null===e&&null!==n||null!==e&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Ia(e,t,n,r,o){var i=Oo(n)?No:Ro.current;return i=Po(t,i),Ti(t,o),n=ms(e,t,n,r,i,o),r=ys(),null===e||wa?(ii&&r&&ti(t),t.flags|=1,va(e,t,n,o),t.child):(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~o,Va(e,t,o))}function xa(e,t,n,r,o){if(Oo(n)){var i=!0;Uo(t)}else i=!1;if(Ti(t,o),null===t.stateNode)ja(e,t),sa(t,n,r),la(t,n,r,o),r=!0;else if(null===e){var s=t.stateNode,a=t.memoizedProps;s.props=a;var l=s.context,c=n.contextType;"object"===typeof c&&null!==c?c=Ni(c):c=Po(t,c=Oo(n)?No:Ro.current);var u=n.getDerivedStateFromProps,d="function"===typeof u||"function"===typeof s.getSnapshotBeforeUpdate;d||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(a!==r||l!==c)&&aa(t,s,r,c),Bi=!1;var h=t.memoizedState;s.state=h,ji(t,r,s,o),l=t.memoizedState,a!==r||h!==l||To.current||Bi?("function"===typeof u&&(ra(t,n,u,r),l=t.memoizedState),(a=Bi||ia(t,n,a,r,h,l,c))?(d||"function"!==typeof s.UNSAFE_componentWillMount&&"function"!==typeof s.componentWillMount||("function"===typeof s.componentWillMount&&s.componentWillMount(),"function"===typeof s.UNSAFE_componentWillMount&&s.UNSAFE_componentWillMount()),"function"===typeof s.componentDidMount&&(t.flags|=4194308)):("function"===typeof s.componentDidMount&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),s.props=r,s.state=l,s.context=c,r=a):("function"===typeof s.componentDidMount&&(t.flags|=4194308),r=!1)}else{s=t.stateNode,Mi(e,t),a=t.memoizedProps,c=t.type===t.elementType?a:na(t.type,a),s.props=c,d=t.pendingProps,h=s.context,"object"===typeof(l=n.contextType)&&null!==l?l=Ni(l):l=Po(t,l=Oo(n)?No:Ro.current);var f=n.getDerivedStateFromProps;(u="function"===typeof f||"function"===typeof s.getSnapshotBeforeUpdate)||"function"!==typeof s.UNSAFE_componentWillReceiveProps&&"function"!==typeof s.componentWillReceiveProps||(a!==d||h!==l)&&aa(t,s,r,l),Bi=!1,h=t.memoizedState,s.state=h,ji(t,r,s,o);var p=t.memoizedState;a!==d||h!==p||To.current||Bi?("function"===typeof f&&(ra(t,n,f,r),p=t.memoizedState),(c=Bi||ia(t,n,c,r,h,p,l)||!1)?(u||"function"!==typeof s.UNSAFE_componentWillUpdate&&"function"!==typeof s.componentWillUpdate||("function"===typeof s.componentWillUpdate&&s.componentWillUpdate(r,p,l),"function"===typeof s.UNSAFE_componentWillUpdate&&s.UNSAFE_componentWillUpdate(r,p,l)),"function"===typeof s.componentDidUpdate&&(t.flags|=4),"function"===typeof s.getSnapshotBeforeUpdate&&(t.flags|=1024)):("function"!==typeof s.componentDidUpdate||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),s.props=r,s.state=p,s.context=l,r=c):("function"!==typeof s.componentDidUpdate||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),"function"!==typeof s.getSnapshotBeforeUpdate||a===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Ca(e,t,n,r,i,o)}function Ca(e,t,n,r,o,i){_a(e,t);var s=0!==(128&t.flags);if(!r&&!s)return o&&Mo(t,n,!1),Va(e,t,i);r=t.stateNode,ba.current=t;var a=s&&"function"!==typeof n.getDerivedStateFromError?null:r.render();return t.flags|=1,null!==e&&s?(t.child=Ei(t,e.child,null,i),t.child=Ei(t,null,a,i)):va(e,t,a,i),t.memoizedState=r.state,o&&Mo(t,n,!0),t.child}function Ra(e){var t=e.stateNode;t.pendingContext?Do(0,t.pendingContext,t.pendingContext!==t.context):t.context&&Do(0,t.context,!1),Qi(e,t.containerInfo)}function Ta(e,t,n,r,o){return pi(),gi(o),t.flags|=256,va(e,t,n,r),t.child}var Na,Pa,Oa,La,Da={dehydrated:null,treeContext:null,retryLane:0};function Ba(e){return{baseLanes:e,cachePool:null,transitions:null}}function Ua(e,t,n){var r,o=t.pendingProps,s=es.current,a=!1,l=0!==(128&t.flags);if((r=l)||(r=(null===e||null!==e.memoizedState)&&0!==(2&s)),r?(a=!0,t.flags&=-129):null!==e&&null===e.memoizedState||(s|=1),xo(es,1&s),null===e)return ui(t),null!==(e=t.memoizedState)&&null!==(e=e.dehydrated)?(0===(1&t.mode)?t.lanes=1:"$!"===e.data?t.lanes=8:t.lanes=1073741824,null):(l=o.children,e=o.fallback,a?(o=t.mode,a=t.child,l={mode:"hidden",children:l},0===(1&o)&&null!==a?(a.childLanes=0,a.pendingProps=l):a=Bc(l,o,0,null),e=Dc(e,o,n,null),a.return=t,e.return=t,a.sibling=e,t.child=a,t.child.memoizedState=Ba(n),t.memoizedState=Da,e):Ma(t,l));if(null!==(s=e.memoizedState)&&null!==(r=s.dehydrated))return function(e,t,n,r,o,s,a){if(n)return 256&t.flags?(t.flags&=-257,Fa(e,t,a,r=ua(Error(i(422))))):null!==t.memoizedState?(t.child=e.child,t.flags|=128,null):(s=r.fallback,o=t.mode,r=Bc({mode:"visible",children:r.children},o,0,null),(s=Dc(s,o,a,null)).flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,0!==(1&t.mode)&&Ei(t,e.child,null,a),t.child.memoizedState=Ba(a),t.memoizedState=Da,s);if(0===(1&t.mode))return Fa(e,t,a,null);if("$!"===o.data){if(r=o.nextSibling&&o.nextSibling.dataset)var l=r.dgst;return r=l,Fa(e,t,a,r=ua(s=Error(i(419)),r,void 0))}if(l=0!==(a&e.childLanes),wa||l){if(null!==(r=Rl)){switch(a&-a){case 4:o=2;break;case 16:o=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:o=32;break;case 536870912:o=268435456;break;default:o=0}0!==(o=0!==(o&(r.suspendedLanes|a))?0:o)&&o!==s.retryLane&&(s.retryLane=o,Di(e,o),nc(r,e,o,-1))}return gc(),Fa(e,t,a,r=ua(Error(i(421))))}return"$?"===o.data?(t.flags|=128,t.child=e.child,t=xc.bind(null,e),o._reactRetry=t,null):(e=s.treeContext,oi=co(o.nextSibling),ri=t,ii=!0,si=null,null!==e&&(Go[Yo++]=Jo,Go[Yo++]=Xo,Go[Yo++]=Qo,Jo=e.id,Xo=e.overflow,Qo=t),t=Ma(t,r.children),t.flags|=4096,t)}(e,t,l,o,r,s,n);if(a){a=o.fallback,l=t.mode,r=(s=e.child).sibling;var c={mode:"hidden",children:o.children};return 0===(1&l)&&t.child!==s?((o=t.child).childLanes=0,o.pendingProps=c,t.deletions=null):(o=Oc(s,c)).subtreeFlags=14680064&s.subtreeFlags,null!==r?a=Oc(r,a):(a=Dc(a,l,n,null)).flags|=2,a.return=t,o.return=t,o.sibling=a,t.child=o,o=a,a=t.child,l=null===(l=e.child.memoizedState)?Ba(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},a.memoizedState=l,a.childLanes=e.childLanes&~n,t.memoizedState=Da,o}return e=(a=e.child).sibling,o=Oc(a,{mode:"visible",children:o.children}),0===(1&t.mode)&&(o.lanes=n),o.return=t,o.sibling=null,null!==e&&(null===(n=t.deletions)?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=o,t.memoizedState=null,o}function Ma(e,t){return(t=Bc({mode:"visible",children:t},e.mode,0,null)).return=e,e.child=t}function Fa(e,t,n,r){return null!==r&&gi(r),Ei(t,e.child,null,n),(e=Ma(t,t.pendingProps.children)).flags|=2,t.memoizedState=null,e}function $a(e,t,n){e.lanes|=t;var r=e.alternate;null!==r&&(r.lanes|=t),Ri(e.return,t,n)}function Ha(e,t,n,r,o){var i=e.memoizedState;null===i?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:o}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=o)}function qa(e,t,n){var r=t.pendingProps,o=r.revealOrder,i=r.tail;if(va(e,t,r.children,n),0!==(2&(r=es.current)))r=1&r|2,t.flags|=128;else{if(null!==e&&0!==(128&e.flags))e:for(e=t.child;null!==e;){if(13===e.tag)null!==e.memoizedState&&$a(e,n,t);else if(19===e.tag)$a(e,n,t);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}r&=1}if(xo(es,r),0===(1&t.mode))t.memoizedState=null;else switch(o){case"forwards":for(n=t.child,o=null;null!==n;)null!==(e=n.alternate)&&null===ts(e)&&(o=n),n=n.sibling;null===(n=o)?(o=t.child,t.child=null):(o=n.sibling,n.sibling=null),Ha(t,!1,o,n,i);break;case"backwards":for(n=null,o=t.child,t.child=null;null!==o;){if(null!==(e=o.alternate)&&null===ts(e)){t.child=o;break}e=o.sibling,o.sibling=n,n=o,o=e}Ha(t,!0,n,null,i);break;case"together":Ha(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function ja(e,t){0===(1&t.mode)&&null!==e&&(e.alternate=null,t.alternate=null,t.flags|=2)}function Va(e,t,n){if(null!==e&&(t.dependencies=e.dependencies),Bl|=t.lanes,0===(n&t.childLanes))return null;if(null!==e&&t.child!==e.child)throw Error(i(153));if(null!==t.child){for(n=Oc(e=t.child,e.pendingProps),t.child=n,n.return=t;null!==e.sibling;)e=e.sibling,(n=n.sibling=Oc(e,e.pendingProps)).return=t;n.sibling=null}return t.child}function za(e,t){if(!ii)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;null!==t;)null!==t.alternate&&(n=t),t=t.sibling;null===n?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;null!==n;)null!==n.alternate&&(r=n),n=n.sibling;null===r?t||null===e.tail?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ka(e){var t=null!==e.alternate&&e.alternate.child===e.child,n=0,r=0;if(t)for(var o=e.child;null!==o;)n|=o.lanes|o.childLanes,r|=14680064&o.subtreeFlags,r|=14680064&o.flags,o.return=e,o=o.sibling;else for(o=e.child;null!==o;)n|=o.lanes|o.childLanes,r|=o.subtreeFlags,r|=o.flags,o.return=e,o=o.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Wa(e,t,n){var r=t.pendingProps;switch(ni(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ka(t),null;case 1:case 17:return Oo(t.type)&&Lo(),Ka(t),null;case 3:return r=t.stateNode,Ji(),Io(To),Io(Ro),rs(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),null!==e&&null!==e.child||(hi(t)?t.flags|=4:null===e||e.memoizedState.isDehydrated&&0===(256&t.flags)||(t.flags|=1024,null!==si&&(sc(si),si=null))),Pa(e,t),Ka(t),null;case 5:Zi(t);var o=Yi(Gi.current);if(n=t.type,null!==e&&null!=t.stateNode)Oa(e,t,n,r,o),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(null===t.stateNode)throw Error(i(166));return Ka(t),null}if(e=Yi(Ki.current),hi(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[fo]=t,r[po]=s,e=0!==(1&t.mode),n){case"dialog":Fr("cancel",r),Fr("close",r);break;case"iframe":case"object":case"embed":Fr("load",r);break;case"video":case"audio":for(o=0;o<Dr.length;o++)Fr(Dr[o],r);break;case"source":Fr("error",r);break;case"img":case"image":case"link":Fr("error",r),Fr("load",r);break;case"details":Fr("toggle",r);break;case"input":Q(r,s),Fr("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},Fr("invalid",r);break;case"textarea":oe(r,s),Fr("invalid",r)}for(var l in be(n,s),o=null,s)if(s.hasOwnProperty(l)){var c=s[l];"children"===l?"string"===typeof c?r.textContent!==c&&(!0!==s.suppressHydrationWarning&&Xr(r.textContent,c,e),o=["children",c]):"number"===typeof c&&r.textContent!==""+c&&(!0!==s.suppressHydrationWarning&&Xr(r.textContent,c,e),o=["children",""+c]):a.hasOwnProperty(l)&&null!=c&&"onScroll"===l&&Fr("scroll",r)}switch(n){case"input":K(r),Z(r,s,!0);break;case"textarea":K(r),se(r);break;case"select":case"option":break;default:"function"===typeof s.onClick&&(r.onclick=Zr)}r=o,t.updateQueue=r,null!==r&&(t.flags|=4)}else{l=9===o.nodeType?o:o.ownerDocument,"http://www.w3.org/1999/xhtml"===e&&(e=ae(n)),"http://www.w3.org/1999/xhtml"===e?"script"===n?((e=l.createElement("div")).innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):"string"===typeof r.is?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),"select"===n&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[fo]=t,e[po]=r,Na(e,t,!1,!1),t.stateNode=e;e:{switch(l=we(n,r),n){case"dialog":Fr("cancel",e),Fr("close",e),o=r;break;case"iframe":case"object":case"embed":Fr("load",e),o=r;break;case"video":case"audio":for(o=0;o<Dr.length;o++)Fr(Dr[o],e);o=r;break;case"source":Fr("error",e),o=r;break;case"img":case"image":case"link":Fr("error",e),Fr("load",e),o=r;break;case"details":Fr("toggle",e),o=r;break;case"input":Q(e,r),o=Y(e,r),Fr("invalid",e);break;case"option":default:o=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},o=U({},r,{value:void 0}),Fr("invalid",e);break;case"textarea":oe(e,r),o=re(e,r),Fr("invalid",e)}for(s in be(n,o),c=o)if(c.hasOwnProperty(s)){var u=c[s];"style"===s?me(e,u):"dangerouslySetInnerHTML"===s?null!=(u=u?u.__html:void 0)&&de(e,u):"children"===s?"string"===typeof u?("textarea"!==n||""!==u)&&he(e,u):"number"===typeof u&&he(e,""+u):"suppressContentEditableWarning"!==s&&"suppressHydrationWarning"!==s&&"autoFocus"!==s&&(a.hasOwnProperty(s)?null!=u&&"onScroll"===s&&Fr("scroll",e):null!=u&&w(e,s,u,l))}switch(n){case"input":K(e),Z(e,r,!1);break;case"textarea":K(e),se(e);break;case"option":null!=r.value&&e.setAttribute("value",""+V(r.value));break;case"select":e.multiple=!!r.multiple,null!=(s=r.value)?ne(e,!!r.multiple,s,!1):null!=r.defaultValue&&ne(e,!!r.multiple,r.defaultValue,!0);break;default:"function"===typeof o.onClick&&(e.onclick=Zr)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}null!==t.ref&&(t.flags|=512,t.flags|=2097152)}return Ka(t),null;case 6:if(e&&null!=t.stateNode)La(e,t,e.memoizedProps,r);else{if("string"!==typeof r&&null===t.stateNode)throw Error(i(166));if(n=Yi(Gi.current),Yi(Ki.current),hi(t)){if(r=t.stateNode,n=t.memoizedProps,r[fo]=t,(s=r.nodeValue!==n)&&null!==(e=ri))switch(e.tag){case 3:Xr(r.nodeValue,n,0!==(1&e.mode));break;case 5:!0!==e.memoizedProps.suppressHydrationWarning&&Xr(r.nodeValue,n,0!==(1&e.mode))}s&&(t.flags|=4)}else(r=(9===n.nodeType?n:n.ownerDocument).createTextNode(r))[fo]=t,t.stateNode=r}return Ka(t),null;case 13:if(Io(es),r=t.memoizedState,null===e||null!==e.memoizedState&&null!==e.memoizedState.dehydrated){if(ii&&null!==oi&&0!==(1&t.mode)&&0===(128&t.flags))fi(),pi(),t.flags|=98560,s=!1;else if(s=hi(t),null!==r&&null!==r.dehydrated){if(null===e){if(!s)throw Error(i(318));if(!(s=null!==(s=t.memoizedState)?s.dehydrated:null))throw Error(i(317));s[fo]=t}else pi(),0===(128&t.flags)&&(t.memoizedState=null),t.flags|=4;Ka(t),s=!1}else null!==si&&(sc(si),si=null),s=!0;if(!s)return 65536&t.flags?t:null}return 0!==(128&t.flags)?(t.lanes=n,t):((r=null!==r)!==(null!==e&&null!==e.memoizedState)&&r&&(t.child.flags|=8192,0!==(1&t.mode)&&(null===e||0!==(1&es.current)?0===Ll&&(Ll=3):gc())),null!==t.updateQueue&&(t.flags|=4),Ka(t),null);case 4:return Ji(),Pa(e,t),null===e&&qr(t.stateNode.containerInfo),Ka(t),null;case 10:return Ci(t.type._context),Ka(t),null;case 19:if(Io(es),null===(s=t.memoizedState))return Ka(t),null;if(r=0!==(128&t.flags),null===(l=s.rendering))if(r)za(s,!1);else{if(0!==Ll||null!==e&&0!==(128&e.flags))for(e=t.child;null!==e;){if(null!==(l=ts(e))){for(t.flags|=128,za(s,!1),null!==(r=l.updateQueue)&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;null!==n;)e=r,(s=n).flags&=14680066,null===(l=s.alternate)?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=l.childLanes,s.lanes=l.lanes,s.child=l.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=l.memoizedProps,s.memoizedState=l.memoizedState,s.updateQueue=l.updateQueue,s.type=l.type,e=l.dependencies,s.dependencies=null===e?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return xo(es,1&es.current|2),t.child}e=e.sibling}null!==s.tail&&Je()>ql&&(t.flags|=128,r=!0,za(s,!1),t.lanes=4194304)}else{if(!r)if(null!==(e=ts(l))){if(t.flags|=128,r=!0,null!==(n=e.updateQueue)&&(t.updateQueue=n,t.flags|=4),za(s,!0),null===s.tail&&"hidden"===s.tailMode&&!l.alternate&&!ii)return Ka(t),null}else 2*Je()-s.renderingStartTime>ql&&1073741824!==n&&(t.flags|=128,r=!0,za(s,!1),t.lanes=4194304);s.isBackwards?(l.sibling=t.child,t.child=l):(null!==(n=s.last)?n.sibling=l:t.child=l,s.last=l)}return null!==s.tail?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=Je(),t.sibling=null,n=es.current,xo(es,r?1&n|2:1&n),t):(Ka(t),null);case 22:case 23:return dc(),r=null!==t.memoizedState,null!==e&&null!==e.memoizedState!==r&&(t.flags|=8192),r&&0!==(1&t.mode)?0!==(1073741824&Pl)&&(Ka(t),6&t.subtreeFlags&&(t.flags|=8192)):Ka(t),null;case 24:case 25:return null}throw Error(i(156,t.tag))}function Ga(e,t){switch(ni(t),t.tag){case 1:return Oo(t.type)&&Lo(),65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 3:return Ji(),Io(To),Io(Ro),rs(),0!==(65536&(e=t.flags))&&0===(128&e)?(t.flags=-65537&e|128,t):null;case 5:return Zi(t),null;case 13:if(Io(es),null!==(e=t.memoizedState)&&null!==e.dehydrated){if(null===t.alternate)throw Error(i(340));pi()}return 65536&(e=t.flags)?(t.flags=-65537&e|128,t):null;case 19:return Io(es),null;case 4:return Ji(),null;case 10:return Ci(t.type._context),null;case 22:case 23:return dc(),null;default:return null}}Na=function(e,t){for(var n=t.child;null!==n;){if(5===n.tag||6===n.tag)e.appendChild(n.stateNode);else if(4!==n.tag&&null!==n.child){n.child.return=n,n=n.child;continue}if(n===t)break;for(;null===n.sibling;){if(null===n.return||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}},Pa=function(){},Oa=function(e,t,n,r){var o=e.memoizedProps;if(o!==r){e=t.stateNode,Yi(Ki.current);var i,s=null;switch(n){case"input":o=Y(e,o),r=Y(e,r),s=[];break;case"select":o=U({},o,{value:void 0}),r=U({},r,{value:void 0}),s=[];break;case"textarea":o=re(e,o),r=re(e,r),s=[];break;default:"function"!==typeof o.onClick&&"function"===typeof r.onClick&&(e.onclick=Zr)}for(u in be(n,r),n=null,o)if(!r.hasOwnProperty(u)&&o.hasOwnProperty(u)&&null!=o[u])if("style"===u){var l=o[u];for(i in l)l.hasOwnProperty(i)&&(n||(n={}),n[i]="")}else"dangerouslySetInnerHTML"!==u&&"children"!==u&&"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&"autoFocus"!==u&&(a.hasOwnProperty(u)?s||(s=[]):(s=s||[]).push(u,null));for(u in r){var c=r[u];if(l=null!=o?o[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(null!=c||null!=l))if("style"===u)if(l){for(i in l)!l.hasOwnProperty(i)||c&&c.hasOwnProperty(i)||(n||(n={}),n[i]="");for(i in c)c.hasOwnProperty(i)&&l[i]!==c[i]&&(n||(n={}),n[i]=c[i])}else n||(s||(s=[]),s.push(u,n)),n=c;else"dangerouslySetInnerHTML"===u?(c=c?c.__html:void 0,l=l?l.__html:void 0,null!=c&&l!==c&&(s=s||[]).push(u,c)):"children"===u?"string"!==typeof c&&"number"!==typeof c||(s=s||[]).push(u,""+c):"suppressContentEditableWarning"!==u&&"suppressHydrationWarning"!==u&&(a.hasOwnProperty(u)?(null!=c&&"onScroll"===u&&Fr("scroll",e),s||l===c||(s=[])):(s=s||[]).push(u,c))}n&&(s=s||[]).push("style",n);var u=s;(t.updateQueue=u)&&(t.flags|=4)}},La=function(e,t,n,r){n!==r&&(t.flags|=4)};var Ya=!1,Qa=!1,Ja="function"===typeof WeakSet?WeakSet:Set,Xa=null;function Za(e,t){var n=e.ref;if(null!==n)if("function"===typeof n)try{n(null)}catch(r){Ac(e,t,r)}else n.current=null}function el(e,t,n){try{n()}catch(r){Ac(e,t,r)}}var tl=!1;function nl(e,t,n){var r=t.updateQueue;if(null!==(r=null!==r?r.lastEffect:null)){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,void 0!==i&&el(t,n,i)}o=o.next}while(o!==r)}}function rl(e,t){if(null!==(t=null!==(t=t.updateQueue)?t.lastEffect:null)){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ol(e){var t=e.ref;if(null!==t){var n=e.stateNode;e.tag,e=n,"function"===typeof t?t(e):t.current=e}}function il(e){var t=e.alternate;null!==t&&(e.alternate=null,il(t)),e.child=null,e.deletions=null,e.sibling=null,5===e.tag&&(null!==(t=e.stateNode)&&(delete t[fo],delete t[po],delete t[mo],delete t[yo],delete t[bo])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function sl(e){return 5===e.tag||3===e.tag||4===e.tag}function al(e){e:for(;;){for(;null===e.sibling;){if(null===e.return||sl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;5!==e.tag&&6!==e.tag&&18!==e.tag;){if(2&e.flags)continue e;if(null===e.child||4===e.tag)continue e;e.child.return=e,e=e.child}if(!(2&e.flags))return e.stateNode}}function ll(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?8===n.nodeType?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(8===n.nodeType?(t=n.parentNode).insertBefore(e,n):(t=n).appendChild(e),null!==(n=n._reactRootContainer)&&void 0!==n||null!==t.onclick||(t.onclick=Zr));else if(4!==r&&null!==(e=e.child))for(ll(e,t,n),e=e.sibling;null!==e;)ll(e,t,n),e=e.sibling}function cl(e,t,n){var r=e.tag;if(5===r||6===r)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(4!==r&&null!==(e=e.child))for(cl(e,t,n),e=e.sibling;null!==e;)cl(e,t,n),e=e.sibling}var ul=null,dl=!1;function hl(e,t,n){for(n=n.child;null!==n;)fl(e,t,n),n=n.sibling}function fl(e,t,n){if(it&&"function"===typeof it.onCommitFiberUnmount)try{it.onCommitFiberUnmount(ot,n)}catch(a){}switch(n.tag){case 5:Qa||Za(n,t);case 6:var r=ul,o=dl;ul=null,hl(e,t,n),dl=o,null!==(ul=r)&&(dl?(e=ul,n=n.stateNode,8===e.nodeType?e.parentNode.removeChild(n):e.removeChild(n)):ul.removeChild(n.stateNode));break;case 18:null!==ul&&(dl?(e=ul,n=n.stateNode,8===e.nodeType?lo(e.parentNode,n):1===e.nodeType&&lo(e,n),qt(e)):lo(ul,n.stateNode));break;case 4:r=ul,o=dl,ul=n.stateNode.containerInfo,dl=!0,hl(e,t,n),ul=r,dl=o;break;case 0:case 11:case 14:case 15:if(!Qa&&(null!==(r=n.updateQueue)&&null!==(r=r.lastEffect))){o=r=r.next;do{var i=o,s=i.destroy;i=i.tag,void 0!==s&&(0!==(2&i)||0!==(4&i))&&el(n,t,s),o=o.next}while(o!==r)}hl(e,t,n);break;case 1:if(!Qa&&(Za(n,t),"function"===typeof(r=n.stateNode).componentWillUnmount))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(a){Ac(n,t,a)}hl(e,t,n);break;case 21:hl(e,t,n);break;case 22:1&n.mode?(Qa=(r=Qa)||null!==n.memoizedState,hl(e,t,n),Qa=r):hl(e,t,n);break;default:hl(e,t,n)}}function pl(e){var t=e.updateQueue;if(null!==t){e.updateQueue=null;var n=e.stateNode;null===n&&(n=e.stateNode=new Ja),t.forEach((function(t){var r=Cc.bind(null,e,t);n.has(t)||(n.add(t),t.then(r,r))}))}}function gl(e,t){var n=t.deletions;if(null!==n)for(var r=0;r<n.length;r++){var o=n[r];try{var s=e,a=t,l=a;e:for(;null!==l;){switch(l.tag){case 5:ul=l.stateNode,dl=!1;break e;case 3:case 4:ul=l.stateNode.containerInfo,dl=!0;break e}l=l.return}if(null===ul)throw Error(i(160));fl(s,a,o),ul=null,dl=!1;var c=o.alternate;null!==c&&(c.return=null),o.return=null}catch(u){Ac(o,t,u)}}if(12854&t.subtreeFlags)for(t=t.child;null!==t;)ml(t,e),t=t.sibling}function ml(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(gl(t,e),yl(e),4&r){try{nl(3,e,e.return),rl(3,e)}catch(m){Ac(e,e.return,m)}try{nl(5,e,e.return)}catch(m){Ac(e,e.return,m)}}break;case 1:gl(t,e),yl(e),512&r&&null!==n&&Za(n,n.return);break;case 5:if(gl(t,e),yl(e),512&r&&null!==n&&Za(n,n.return),32&e.flags){var o=e.stateNode;try{he(o,"")}catch(m){Ac(e,e.return,m)}}if(4&r&&null!=(o=e.stateNode)){var s=e.memoizedProps,a=null!==n?n.memoizedProps:s,l=e.type,c=e.updateQueue;if(e.updateQueue=null,null!==c)try{"input"===l&&"radio"===s.type&&null!=s.name&&J(o,s),we(l,a);var u=we(l,s);for(a=0;a<c.length;a+=2){var d=c[a],h=c[a+1];"style"===d?me(o,h):"dangerouslySetInnerHTML"===d?de(o,h):"children"===d?he(o,h):w(o,d,h,u)}switch(l){case"input":X(o,s);break;case"textarea":ie(o,s);break;case"select":var f=o._wrapperState.wasMultiple;o._wrapperState.wasMultiple=!!s.multiple;var p=s.value;null!=p?ne(o,!!s.multiple,p,!1):f!==!!s.multiple&&(null!=s.defaultValue?ne(o,!!s.multiple,s.defaultValue,!0):ne(o,!!s.multiple,s.multiple?[]:"",!1))}o[po]=s}catch(m){Ac(e,e.return,m)}}break;case 6:if(gl(t,e),yl(e),4&r){if(null===e.stateNode)throw Error(i(162));o=e.stateNode,s=e.memoizedProps;try{o.nodeValue=s}catch(m){Ac(e,e.return,m)}}break;case 3:if(gl(t,e),yl(e),4&r&&null!==n&&n.memoizedState.isDehydrated)try{qt(t.containerInfo)}catch(m){Ac(e,e.return,m)}break;case 4:default:gl(t,e),yl(e);break;case 13:gl(t,e),yl(e),8192&(o=e.child).flags&&(s=null!==o.memoizedState,o.stateNode.isHidden=s,!s||null!==o.alternate&&null!==o.alternate.memoizedState||(Hl=Je())),4&r&&pl(e);break;case 22:if(d=null!==n&&null!==n.memoizedState,1&e.mode?(Qa=(u=Qa)||d,gl(t,e),Qa=u):gl(t,e),yl(e),8192&r){if(u=null!==e.memoizedState,(e.stateNode.isHidden=u)&&!d&&0!==(1&e.mode))for(Xa=e,d=e.child;null!==d;){for(h=Xa=d;null!==Xa;){switch(p=(f=Xa).child,f.tag){case 0:case 11:case 14:case 15:nl(4,f,f.return);break;case 1:Za(f,f.return);var g=f.stateNode;if("function"===typeof g.componentWillUnmount){r=f,n=f.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(m){Ac(r,n,m)}}break;case 5:Za(f,f.return);break;case 22:if(null!==f.memoizedState){El(h);continue}}null!==p?(p.return=f,Xa=p):El(h)}d=d.sibling}e:for(d=null,h=e;;){if(5===h.tag){if(null===d){d=h;try{o=h.stateNode,u?"function"===typeof(s=o.style).setProperty?s.setProperty("display","none","important"):s.display="none":(l=h.stateNode,a=void 0!==(c=h.memoizedProps.style)&&null!==c&&c.hasOwnProperty("display")?c.display:null,l.style.display=ge("display",a))}catch(m){Ac(e,e.return,m)}}}else if(6===h.tag){if(null===d)try{h.stateNode.nodeValue=u?"":h.memoizedProps}catch(m){Ac(e,e.return,m)}}else if((22!==h.tag&&23!==h.tag||null===h.memoizedState||h===e)&&null!==h.child){h.child.return=h,h=h.child;continue}if(h===e)break e;for(;null===h.sibling;){if(null===h.return||h.return===e)break e;d===h&&(d=null),h=h.return}d===h&&(d=null),h.sibling.return=h.return,h=h.sibling}}break;case 19:gl(t,e),yl(e),4&r&&pl(e);case 21:}}function yl(e){var t=e.flags;if(2&t){try{e:{for(var n=e.return;null!==n;){if(sl(n)){var r=n;break e}n=n.return}throw Error(i(160))}switch(r.tag){case 5:var o=r.stateNode;32&r.flags&&(he(o,""),r.flags&=-33),cl(e,al(e),o);break;case 3:case 4:var s=r.stateNode.containerInfo;ll(e,al(e),s);break;default:throw Error(i(161))}}catch(a){Ac(e,e.return,a)}e.flags&=-3}4096&t&&(e.flags&=-4097)}function bl(e,t,n){Xa=e,wl(e,t,n)}function wl(e,t,n){for(var r=0!==(1&e.mode);null!==Xa;){var o=Xa,i=o.child;if(22===o.tag&&r){var s=null!==o.memoizedState||Ya;if(!s){var a=o.alternate,l=null!==a&&null!==a.memoizedState||Qa;a=Ya;var c=Qa;if(Ya=s,(Qa=l)&&!c)for(Xa=o;null!==Xa;)l=(s=Xa).child,22===s.tag&&null!==s.memoizedState?Sl(o):null!==l?(l.return=s,Xa=l):Sl(o);for(;null!==i;)Xa=i,wl(i,t,n),i=i.sibling;Xa=o,Ya=a,Qa=c}vl(e)}else 0!==(8772&o.subtreeFlags)&&null!==i?(i.return=o,Xa=i):vl(e)}}function vl(e){for(;null!==Xa;){var t=Xa;if(0!==(8772&t.flags)){var n=t.alternate;try{if(0!==(8772&t.flags))switch(t.tag){case 0:case 11:case 15:Qa||rl(5,t);break;case 1:var r=t.stateNode;if(4&t.flags&&!Qa)if(null===n)r.componentDidMount();else{var o=t.elementType===t.type?n.memoizedProps:na(t.type,n.memoizedProps);r.componentDidUpdate(o,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;null!==s&&Vi(t,s,r);break;case 3:var a=t.updateQueue;if(null!==a){if(n=null,null!==t.child)switch(t.child.tag){case 5:case 1:n=t.child.stateNode}Vi(t,a,n)}break;case 5:var l=t.stateNode;if(null===n&&4&t.flags){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:case 4:case 12:case 19:case 17:case 21:case 22:case 23:case 25:break;case 13:if(null===t.memoizedState){var u=t.alternate;if(null!==u){var d=u.memoizedState;if(null!==d){var h=d.dehydrated;null!==h&&qt(h)}}}break;default:throw Error(i(163))}Qa||512&t.flags&&ol(t)}catch(f){Ac(t,t.return,f)}}if(t===e){Xa=null;break}if(null!==(n=t.sibling)){n.return=t.return,Xa=n;break}Xa=t.return}}function El(e){for(;null!==Xa;){var t=Xa;if(t===e){Xa=null;break}var n=t.sibling;if(null!==n){n.return=t.return,Xa=n;break}Xa=t.return}}function Sl(e){for(;null!==Xa;){var t=Xa;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{rl(4,t)}catch(l){Ac(t,n,l)}break;case 1:var r=t.stateNode;if("function"===typeof r.componentDidMount){var o=t.return;try{r.componentDidMount()}catch(l){Ac(t,o,l)}}var i=t.return;try{ol(t)}catch(l){Ac(t,i,l)}break;case 5:var s=t.return;try{ol(t)}catch(l){Ac(t,s,l)}}}catch(l){Ac(t,t.return,l)}if(t===e){Xa=null;break}var a=t.sibling;if(null!==a){a.return=t.return,Xa=a;break}Xa=t.return}}var kl,Al=Math.ceil,_l=v.ReactCurrentDispatcher,Il=v.ReactCurrentOwner,xl=v.ReactCurrentBatchConfig,Cl=0,Rl=null,Tl=null,Nl=0,Pl=0,Ol=_o(0),Ll=0,Dl=null,Bl=0,Ul=0,Ml=0,Fl=null,$l=null,Hl=0,ql=1/0,jl=null,Vl=!1,zl=null,Kl=null,Wl=!1,Gl=null,Yl=0,Ql=0,Jl=null,Xl=-1,Zl=0;function ec(){return 0!==(6&Cl)?Je():-1!==Xl?Xl:Xl=Je()}function tc(e){return 0===(1&e.mode)?1:0!==(2&Cl)&&0!==Nl?Nl&-Nl:null!==mi.transition?(0===Zl&&(Zl=gt()),Zl):0!==(e=wt)?e:e=void 0===(e=window.event)?16:Qt(e.type)}function nc(e,t,n,r){if(50<Ql)throw Ql=0,Jl=null,Error(i(185));yt(e,n,r),0!==(2&Cl)&&e===Rl||(e===Rl&&(0===(2&Cl)&&(Ul|=n),4===Ll&&ac(e,Nl)),rc(e,r),1===n&&0===Cl&&0===(1&t.mode)&&(ql=Je()+500,$o&&jo()))}function rc(e,t){var n=e.callbackNode;!function(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,o=e.expirationTimes,i=e.pendingLanes;0<i;){var s=31-st(i),a=1<<s,l=o[s];-1===l?0!==(a&n)&&0===(a&r)||(o[s]=ft(a,t)):l<=t&&(e.expiredLanes|=a),i&=~a}}(e,t);var r=ht(e,e===Rl?Nl:0);if(0===r)null!==n&&Ge(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(null!=n&&Ge(n),1===t)0===e.tag?function(e){$o=!0,qo(e)}(lc.bind(null,e)):qo(lc.bind(null,e)),so((function(){0===(6&Cl)&&jo()})),n=null;else{switch(vt(r)){case 1:n=Ze;break;case 4:n=et;break;case 16:default:n=tt;break;case 536870912:n=rt}n=Rc(n,oc.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function oc(e,t){if(Xl=-1,Zl=0,0!==(6&Cl))throw Error(i(327));var n=e.callbackNode;if(Sc()&&e.callbackNode!==n)return null;var r=ht(e,e===Rl?Nl:0);if(0===r)return null;if(0!==(30&r)||0!==(r&e.expiredLanes)||t)t=mc(e,r);else{t=r;var o=Cl;Cl|=2;var s=pc();for(Rl===e&&Nl===t||(jl=null,ql=Je()+500,hc(e,t));;)try{bc();break}catch(l){fc(e,l)}xi(),_l.current=s,Cl=o,null!==Tl?t=0:(Rl=null,Nl=0,t=Ll)}if(0!==t){if(2===t&&(0!==(o=pt(e))&&(r=o,t=ic(e,o))),1===t)throw n=Dl,hc(e,0),ac(e,r),rc(e,Je()),n;if(6===t)ac(e,r);else{if(o=e.current.alternate,0===(30&r)&&!function(e){for(var t=e;;){if(16384&t.flags){var n=t.updateQueue;if(null!==n&&null!==(n=n.stores))for(var r=0;r<n.length;r++){var o=n[r],i=o.getSnapshot;o=o.value;try{if(!ar(i(),o))return!1}catch(a){return!1}}}if(n=t.child,16384&t.subtreeFlags&&null!==n)n.return=t,t=n;else{if(t===e)break;for(;null===t.sibling;){if(null===t.return||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}(o)&&(2===(t=mc(e,r))&&(0!==(s=pt(e))&&(r=s,t=ic(e,s))),1===t))throw n=Dl,hc(e,0),ac(e,r),rc(e,Je()),n;switch(e.finishedWork=o,e.finishedLanes=r,t){case 0:case 1:throw Error(i(345));case 2:case 5:Ec(e,$l,jl);break;case 3:if(ac(e,r),(130023424&r)===r&&10<(t=Hl+500-Je())){if(0!==ht(e,0))break;if(((o=e.suspendedLanes)&r)!==r){ec(),e.pingedLanes|=e.suspendedLanes&o;break}e.timeoutHandle=ro(Ec.bind(null,e,$l,jl),t);break}Ec(e,$l,jl);break;case 4:if(ac(e,r),(4194240&r)===r)break;for(t=e.eventTimes,o=-1;0<r;){var a=31-st(r);s=1<<a,(a=t[a])>o&&(o=a),r&=~s}if(r=o,10<(r=(120>(r=Je()-r)?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Al(r/1960))-r)){e.timeoutHandle=ro(Ec.bind(null,e,$l,jl),r);break}Ec(e,$l,jl);break;default:throw Error(i(329))}}}return rc(e,Je()),e.callbackNode===n?oc.bind(null,e):null}function ic(e,t){var n=Fl;return e.current.memoizedState.isDehydrated&&(hc(e,t).flags|=256),2!==(e=mc(e,t))&&(t=$l,$l=n,null!==t&&sc(t)),e}function sc(e){null===$l?$l=e:$l.push.apply($l,e)}function ac(e,t){for(t&=~Ml,t&=~Ul,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-st(t),r=1<<n;e[n]=-1,t&=~r}}function lc(e){if(0!==(6&Cl))throw Error(i(327));Sc();var t=ht(e,0);if(0===(1&t))return rc(e,Je()),null;var n=mc(e,t);if(0!==e.tag&&2===n){var r=pt(e);0!==r&&(t=r,n=ic(e,r))}if(1===n)throw n=Dl,hc(e,0),ac(e,t),rc(e,Je()),n;if(6===n)throw Error(i(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ec(e,$l,jl),rc(e,Je()),null}function cc(e,t){var n=Cl;Cl|=1;try{return e(t)}finally{0===(Cl=n)&&(ql=Je()+500,$o&&jo())}}function uc(e){null!==Gl&&0===Gl.tag&&0===(6&Cl)&&Sc();var t=Cl;Cl|=1;var n=xl.transition,r=wt;try{if(xl.transition=null,wt=1,e)return e()}finally{wt=r,xl.transition=n,0===(6&(Cl=t))&&jo()}}function dc(){Pl=Ol.current,Io(Ol)}function hc(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(-1!==n&&(e.timeoutHandle=-1,oo(n)),null!==Tl)for(n=Tl.return;null!==n;){var r=n;switch(ni(r),r.tag){case 1:null!==(r=r.type.childContextTypes)&&void 0!==r&&Lo();break;case 3:Ji(),Io(To),Io(Ro),rs();break;case 5:Zi(r);break;case 4:Ji();break;case 13:case 19:Io(es);break;case 10:Ci(r.type._context);break;case 22:case 23:dc()}n=n.return}if(Rl=e,Tl=e=Oc(e.current,null),Nl=Pl=t,Ll=0,Dl=null,Ml=Ul=Bl=0,$l=Fl=null,null!==Pi){for(t=0;t<Pi.length;t++)if(null!==(r=(n=Pi[t]).interleaved)){n.interleaved=null;var o=r.next,i=n.pending;if(null!==i){var s=i.next;i.next=o,r.next=s}n.pending=r}Pi=null}return e}function fc(e,t){for(;;){var n=Tl;try{if(xi(),os.current=Xs,us){for(var r=as.memoizedState;null!==r;){var o=r.queue;null!==o&&(o.pending=null),r=r.next}us=!1}if(ss=0,cs=ls=as=null,ds=!1,hs=0,Il.current=null,null===n||null===n.return){Ll=1,Dl=t,Tl=null;break}e:{var s=e,a=n.return,l=n,c=t;if(t=Nl,l.flags|=32768,null!==c&&"object"===typeof c&&"function"===typeof c.then){var u=c,d=l,h=d.tag;if(0===(1&d.mode)&&(0===h||11===h||15===h)){var f=d.alternate;f?(d.updateQueue=f.updateQueue,d.memoizedState=f.memoizedState,d.lanes=f.lanes):(d.updateQueue=null,d.memoizedState=null)}var p=ma(a);if(null!==p){p.flags&=-257,ya(p,a,l,0,t),1&p.mode&&ga(s,u,t),c=u;var g=(t=p).updateQueue;if(null===g){var m=new Set;m.add(c),t.updateQueue=m}else g.add(c);break e}if(0===(1&t)){ga(s,u,t),gc();break e}c=Error(i(426))}else if(ii&&1&l.mode){var y=ma(a);if(null!==y){0===(65536&y.flags)&&(y.flags|=256),ya(y,a,l,0,t),gi(ca(c,l));break e}}s=c=ca(c,l),4!==Ll&&(Ll=2),null===Fl?Fl=[s]:Fl.push(s),s=a;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t,qi(s,fa(0,c,t));break e;case 1:l=c;var b=s.type,w=s.stateNode;if(0===(128&s.flags)&&("function"===typeof b.getDerivedStateFromError||null!==w&&"function"===typeof w.componentDidCatch&&(null===Kl||!Kl.has(w)))){s.flags|=65536,t&=-t,s.lanes|=t,qi(s,pa(s,l,t));break e}}s=s.return}while(null!==s)}vc(n)}catch(v){t=v,Tl===n&&null!==n&&(Tl=n=n.return);continue}break}}function pc(){var e=_l.current;return _l.current=Xs,null===e?Xs:e}function gc(){0!==Ll&&3!==Ll&&2!==Ll||(Ll=4),null===Rl||0===(268435455&Bl)&&0===(268435455&Ul)||ac(Rl,Nl)}function mc(e,t){var n=Cl;Cl|=2;var r=pc();for(Rl===e&&Nl===t||(jl=null,hc(e,t));;)try{yc();break}catch(o){fc(e,o)}if(xi(),Cl=n,_l.current=r,null!==Tl)throw Error(i(261));return Rl=null,Nl=0,Ll}function yc(){for(;null!==Tl;)wc(Tl)}function bc(){for(;null!==Tl&&!Ye();)wc(Tl)}function wc(e){var t=kl(e.alternate,e,Pl);e.memoizedProps=e.pendingProps,null===t?vc(e):Tl=t,Il.current=null}function vc(e){var t=e;do{var n=t.alternate;if(e=t.return,0===(32768&t.flags)){if(null!==(n=Wa(n,t,Pl)))return void(Tl=n)}else{if(null!==(n=Ga(n,t)))return n.flags&=32767,void(Tl=n);if(null===e)return Ll=6,void(Tl=null);e.flags|=32768,e.subtreeFlags=0,e.deletions=null}if(null!==(t=t.sibling))return void(Tl=t);Tl=t=e}while(null!==t);0===Ll&&(Ll=5)}function Ec(e,t,n){var r=wt,o=xl.transition;try{xl.transition=null,wt=1,function(e,t,n,r){do{Sc()}while(null!==Gl);if(0!==(6&Cl))throw Error(i(327));n=e.finishedWork;var o=e.finishedLanes;if(null===n)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(i(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(function(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var o=31-st(n),i=1<<o;t[o]=0,r[o]=-1,e[o]=-1,n&=~i}}(e,s),e===Rl&&(Tl=Rl=null,Nl=0),0===(2064&n.subtreeFlags)&&0===(2064&n.flags)||Wl||(Wl=!0,Rc(tt,(function(){return Sc(),null}))),s=0!==(15990&n.flags),0!==(15990&n.subtreeFlags)||s){s=xl.transition,xl.transition=null;var a=wt;wt=1;var l=Cl;Cl|=4,Il.current=null,function(e,t){if(eo=Vt,fr(e=hr())){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{var r=(n=(n=e.ownerDocument)&&n.defaultView||window).getSelection&&n.getSelection();if(r&&0!==r.rangeCount){n=r.anchorNode;var o=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch(E){n=null;break e}var a=0,l=-1,c=-1,u=0,d=0,h=e,f=null;t:for(;;){for(var p;h!==n||0!==o&&3!==h.nodeType||(l=a+o),h!==s||0!==r&&3!==h.nodeType||(c=a+r),3===h.nodeType&&(a+=h.nodeValue.length),null!==(p=h.firstChild);)f=h,h=p;for(;;){if(h===e)break t;if(f===n&&++u===o&&(l=a),f===s&&++d===r&&(c=a),null!==(p=h.nextSibling))break;f=(h=f).parentNode}h=p}n=-1===l||-1===c?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(to={focusedElem:e,selectionRange:n},Vt=!1,Xa=t;null!==Xa;)if(e=(t=Xa).child,0!==(1028&t.subtreeFlags)&&null!==e)e.return=t,Xa=e;else for(;null!==Xa;){t=Xa;try{var g=t.alternate;if(0!==(1024&t.flags))switch(t.tag){case 0:case 11:case 15:case 5:case 6:case 4:case 17:break;case 1:if(null!==g){var m=g.memoizedProps,y=g.memoizedState,b=t.stateNode,w=b.getSnapshotBeforeUpdate(t.elementType===t.type?m:na(t.type,m),y);b.__reactInternalSnapshotBeforeUpdate=w}break;case 3:var v=t.stateNode.containerInfo;1===v.nodeType?v.textContent="":9===v.nodeType&&v.documentElement&&v.removeChild(v.documentElement);break;default:throw Error(i(163))}}catch(E){Ac(t,t.return,E)}if(null!==(e=t.sibling)){e.return=t.return,Xa=e;break}Xa=t.return}g=tl,tl=!1}(e,n),ml(n,e),pr(to),Vt=!!eo,to=eo=null,e.current=n,bl(n,e,o),Qe(),Cl=l,wt=a,xl.transition=s}else e.current=n;if(Wl&&(Wl=!1,Gl=e,Yl=o),s=e.pendingLanes,0===s&&(Kl=null),function(e){if(it&&"function"===typeof it.onCommitFiberRoot)try{it.onCommitFiberRoot(ot,e,void 0,128===(128&e.current.flags))}catch(t){}}(n.stateNode),rc(e,Je()),null!==t)for(r=e.onRecoverableError,n=0;n<t.length;n++)o=t[n],r(o.value,{componentStack:o.stack,digest:o.digest});if(Vl)throw Vl=!1,e=zl,zl=null,e;0!==(1&Yl)&&0!==e.tag&&Sc(),s=e.pendingLanes,0!==(1&s)?e===Jl?Ql++:(Ql=0,Jl=e):Ql=0,jo()}(e,t,n,r)}finally{xl.transition=o,wt=r}return null}function Sc(){if(null!==Gl){var e=vt(Yl),t=xl.transition,n=wt;try{if(xl.transition=null,wt=16>e?16:e,null===Gl)var r=!1;else{if(e=Gl,Gl=null,Yl=0,0!==(6&Cl))throw Error(i(331));var o=Cl;for(Cl|=4,Xa=e.current;null!==Xa;){var s=Xa,a=s.child;if(0!==(16&Xa.flags)){var l=s.deletions;if(null!==l){for(var c=0;c<l.length;c++){var u=l[c];for(Xa=u;null!==Xa;){var d=Xa;switch(d.tag){case 0:case 11:case 15:nl(8,d,s)}var h=d.child;if(null!==h)h.return=d,Xa=h;else for(;null!==Xa;){var f=(d=Xa).sibling,p=d.return;if(il(d),d===u){Xa=null;break}if(null!==f){f.return=p,Xa=f;break}Xa=p}}}var g=s.alternate;if(null!==g){var m=g.child;if(null!==m){g.child=null;do{var y=m.sibling;m.sibling=null,m=y}while(null!==m)}}Xa=s}}if(0!==(2064&s.subtreeFlags)&&null!==a)a.return=s,Xa=a;else e:for(;null!==Xa;){if(0!==(2048&(s=Xa).flags))switch(s.tag){case 0:case 11:case 15:nl(9,s,s.return)}var b=s.sibling;if(null!==b){b.return=s.return,Xa=b;break e}Xa=s.return}}var w=e.current;for(Xa=w;null!==Xa;){var v=(a=Xa).child;if(0!==(2064&a.subtreeFlags)&&null!==v)v.return=a,Xa=v;else e:for(a=w;null!==Xa;){if(0!==(2048&(l=Xa).flags))try{switch(l.tag){case 0:case 11:case 15:rl(9,l)}}catch(S){Ac(l,l.return,S)}if(l===a){Xa=null;break e}var E=l.sibling;if(null!==E){E.return=l.return,Xa=E;break e}Xa=l.return}}if(Cl=o,jo(),it&&"function"===typeof it.onPostCommitFiberRoot)try{it.onPostCommitFiberRoot(ot,e)}catch(S){}r=!0}return r}finally{wt=n,xl.transition=t}}return!1}function kc(e,t,n){e=$i(e,t=fa(0,t=ca(n,t),1),1),t=ec(),null!==e&&(yt(e,1,t),rc(e,t))}function Ac(e,t,n){if(3===e.tag)kc(e,e,n);else for(;null!==t;){if(3===t.tag){kc(t,e,n);break}if(1===t.tag){var r=t.stateNode;if("function"===typeof t.type.getDerivedStateFromError||"function"===typeof r.componentDidCatch&&(null===Kl||!Kl.has(r))){t=$i(t,e=pa(t,e=ca(n,e),1),1),e=ec(),null!==t&&(yt(t,1,e),rc(t,e));break}}t=t.return}}function _c(e,t,n){var r=e.pingCache;null!==r&&r.delete(t),t=ec(),e.pingedLanes|=e.suspendedLanes&n,Rl===e&&(Nl&n)===n&&(4===Ll||3===Ll&&(130023424&Nl)===Nl&&500>Je()-Hl?hc(e,0):Ml|=n),rc(e,t)}function Ic(e,t){0===t&&(0===(1&e.mode)?t=1:(t=ut,0===(130023424&(ut<<=1))&&(ut=4194304)));var n=ec();null!==(e=Di(e,t))&&(yt(e,t,n),rc(e,n))}function xc(e){var t=e.memoizedState,n=0;null!==t&&(n=t.retryLane),Ic(e,n)}function Cc(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;null!==o&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(i(314))}null!==r&&r.delete(t),Ic(e,n)}function Rc(e,t){return We(e,t)}function Tc(e,t,n,r){this.tag=e,this.key=n,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=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nc(e,t,n,r){return new Tc(e,t,n,r)}function Pc(e){return!(!(e=e.prototype)||!e.isReactComponent)}function Oc(e,t){var n=e.alternate;return null===n?((n=Nc(e.tag,t,e.key,e.mode)).elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=14680064&e.flags,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=null===t?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Lc(e,t,n,r,o,s){var a=2;if(r=e,"function"===typeof e)Pc(e)&&(a=1);else if("string"===typeof e)a=5;else e:switch(e){case k:return Dc(n.children,o,s,t);case A:a=8,o|=8;break;case _:return(e=Nc(12,n,t,2|o)).elementType=_,e.lanes=s,e;case R:return(e=Nc(13,n,t,o)).elementType=R,e.lanes=s,e;case T:return(e=Nc(19,n,t,o)).elementType=T,e.lanes=s,e;case O:return Bc(n,o,s,t);default:if("object"===typeof e&&null!==e)switch(e.$$typeof){case I:a=10;break e;case x:a=9;break e;case C:a=11;break e;case N:a=14;break e;case P:a=16,r=null;break e}throw Error(i(130,null==e?e:typeof e,""))}return(t=Nc(a,n,t,o)).elementType=e,t.type=r,t.lanes=s,t}function Dc(e,t,n,r){return(e=Nc(7,e,r,t)).lanes=n,e}function Bc(e,t,n,r){return(e=Nc(22,e,r,t)).elementType=O,e.lanes=n,e.stateNode={isHidden:!1},e}function Uc(e,t,n){return(e=Nc(6,e,null,t)).lanes=n,e}function Mc(e,t,n){return(t=Nc(4,null!==e.children?e.children:[],e.key,t)).lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Fc(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=mt(0),this.expirationTimes=mt(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=mt(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function $c(e,t,n,r,o,i,s,a,l){return e=new Fc(e,t,n,a,l),1===t?(t=1,!0===i&&(t|=8)):t=0,i=Nc(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ui(i),e}function Hc(e){if(!e)return Co;e:{if(qe(e=e._reactInternals)!==e||1!==e.tag)throw Error(i(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Oo(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(null!==t);throw Error(i(171))}if(1===e.tag){var n=e.type;if(Oo(n))return Bo(e,n,t)}return t}function qc(e,t,n,r,o,i,s,a,l){return(e=$c(n,r,!0,e,0,i,0,a,l)).context=Hc(null),n=e.current,(i=Fi(r=ec(),o=tc(n))).callback=void 0!==t&&null!==t?t:null,$i(n,i,o),e.current.lanes=o,yt(e,o,r),rc(e,r),e}function jc(e,t,n,r){var o=t.current,i=ec(),s=tc(o);return n=Hc(n),null===t.context?t.context=n:t.pendingContext=n,(t=Fi(i,s)).payload={element:e},null!==(r=void 0===r?null:r)&&(t.callback=r),null!==(e=$i(o,t,s))&&(nc(e,o,s,i),Hi(e,o,s)),s}function Vc(e){return(e=e.current).child?(e.child.tag,e.child.stateNode):null}function zc(e,t){if(null!==(e=e.memoizedState)&&null!==e.dehydrated){var n=e.retryLane;e.retryLane=0!==n&&n<t?n:t}}function Kc(e,t){zc(e,t),(e=e.alternate)&&zc(e,t)}kl=function(e,t,n){if(null!==e)if(e.memoizedProps!==t.pendingProps||To.current)wa=!0;else{if(0===(e.lanes&n)&&0===(128&t.flags))return wa=!1,function(e,t,n){switch(t.tag){case 3:Ra(t),pi();break;case 5:Xi(t);break;case 1:Oo(t.type)&&Uo(t);break;case 4:Qi(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,o=t.memoizedProps.value;xo(ki,r._currentValue),r._currentValue=o;break;case 13:if(null!==(r=t.memoizedState))return null!==r.dehydrated?(xo(es,1&es.current),t.flags|=128,null):0!==(n&t.child.childLanes)?Ua(e,t,n):(xo(es,1&es.current),null!==(e=Va(e,t,n))?e.sibling:null);xo(es,1&es.current);break;case 19:if(r=0!==(n&t.childLanes),0!==(128&e.flags)){if(r)return qa(e,t,n);t.flags|=128}if(null!==(o=t.memoizedState)&&(o.rendering=null,o.tail=null,o.lastEffect=null),xo(es,es.current),r)break;return null;case 22:case 23:return t.lanes=0,Aa(e,t,n)}return Va(e,t,n)}(e,t,n);wa=0!==(131072&e.flags)}else wa=!1,ii&&0!==(1048576&t.flags)&&ei(t,Wo,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;ja(e,t),e=t.pendingProps;var o=Po(t,Ro.current);Ti(t,n),o=ms(null,t,r,e,o,n);var s=ys();return t.flags|=1,"object"===typeof o&&null!==o&&"function"===typeof o.render&&void 0===o.$$typeof?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Oo(r)?(s=!0,Uo(t)):s=!1,t.memoizedState=null!==o.state&&void 0!==o.state?o.state:null,Ui(t),o.updater=oa,t.stateNode=o,o._reactInternals=t,la(t,r,e,n),t=Ca(null,t,r,!0,s,n)):(t.tag=0,ii&&s&&ti(t),va(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(ja(e,t),e=t.pendingProps,r=(o=r._init)(r._payload),t.type=r,o=t.tag=function(e){if("function"===typeof e)return Pc(e)?1:0;if(void 0!==e&&null!==e){if((e=e.$$typeof)===C)return 11;if(e===N)return 14}return 2}(r),e=na(r,e),o){case 0:t=Ia(null,t,r,e,n);break e;case 1:t=xa(null,t,r,e,n);break e;case 11:t=Ea(null,t,r,e,n);break e;case 14:t=Sa(null,t,r,na(r.type,e),n);break e}throw Error(i(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,Ia(e,t,r,o=t.elementType===r?o:na(r,o),n);case 1:return r=t.type,o=t.pendingProps,xa(e,t,r,o=t.elementType===r?o:na(r,o),n);case 3:e:{if(Ra(t),null===e)throw Error(i(387));r=t.pendingProps,o=(s=t.memoizedState).element,Mi(e,t),ji(t,r,null,n);var a=t.memoizedState;if(r=a.element,s.isDehydrated){if(s={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=s,t.memoizedState=s,256&t.flags){t=Ta(e,t,r,n,o=ca(Error(i(423)),t));break e}if(r!==o){t=Ta(e,t,r,n,o=ca(Error(i(424)),t));break e}for(oi=co(t.stateNode.containerInfo.firstChild),ri=t,ii=!0,si=null,n=Si(t,null,r,n),t.child=n;n;)n.flags=-3&n.flags|4096,n=n.sibling}else{if(pi(),r===o){t=Va(e,t,n);break e}va(e,t,r,n)}t=t.child}return t;case 5:return Xi(t),null===e&&ui(t),r=t.type,o=t.pendingProps,s=null!==e?e.memoizedProps:null,a=o.children,no(r,o)?a=null:null!==s&&no(r,s)&&(t.flags|=32),_a(e,t),va(e,t,a,n),t.child;case 6:return null===e&&ui(t),null;case 13:return Ua(e,t,n);case 4:return Qi(t,t.stateNode.containerInfo),r=t.pendingProps,null===e?t.child=Ei(t,null,r,n):va(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,Ea(e,t,r,o=t.elementType===r?o:na(r,o),n);case 7:return va(e,t,t.pendingProps,n),t.child;case 8:case 12:return va(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,s=t.memoizedProps,a=o.value,xo(ki,r._currentValue),r._currentValue=a,null!==s)if(ar(s.value,a)){if(s.children===o.children&&!To.current){t=Va(e,t,n);break e}}else for(null!==(s=t.child)&&(s.return=t);null!==s;){var l=s.dependencies;if(null!==l){a=s.child;for(var c=l.firstContext;null!==c;){if(c.context===r){if(1===s.tag){(c=Fi(-1,n&-n)).tag=2;var u=s.updateQueue;if(null!==u){var d=(u=u.shared).pending;null===d?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}s.lanes|=n,null!==(c=s.alternate)&&(c.lanes|=n),Ri(s.return,n,t),l.lanes|=n;break}c=c.next}}else if(10===s.tag)a=s.type===t.type?null:s.child;else if(18===s.tag){if(null===(a=s.return))throw Error(i(341));a.lanes|=n,null!==(l=a.alternate)&&(l.lanes|=n),Ri(a,n,t),a=s.sibling}else a=s.child;if(null!==a)a.return=s;else for(a=s;null!==a;){if(a===t){a=null;break}if(null!==(s=a.sibling)){s.return=a.return,a=s;break}a=a.return}s=a}va(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,Ti(t,n),r=r(o=Ni(o)),t.flags|=1,va(e,t,r,n),t.child;case 14:return o=na(r=t.type,t.pendingProps),Sa(e,t,r,o=na(r.type,o),n);case 15:return ka(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:na(r,o),ja(e,t),t.tag=1,Oo(r)?(e=!0,Uo(t)):e=!1,Ti(t,n),sa(t,r,o),la(t,r,o,n),Ca(null,t,r,!0,e,n);case 19:return qa(e,t,n);case 22:return Aa(e,t,n)}throw Error(i(156,t.tag))};var Wc="function"===typeof reportError?reportError:function(e){console.error(e)};function Gc(e){this._internalRoot=e}function Yc(e){this._internalRoot=e}function Qc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType)}function Jc(e){return!(!e||1!==e.nodeType&&9!==e.nodeType&&11!==e.nodeType&&(8!==e.nodeType||" react-mount-point-unstable "!==e.nodeValue))}function Xc(){}function Zc(e,t,n,r,o){var i=n._reactRootContainer;if(i){var s=i;if("function"===typeof o){var a=o;o=function(){var e=Vc(s);a.call(e)}}jc(t,s,e,o)}else s=function(e,t,n,r,o){if(o){if("function"===typeof r){var i=r;r=function(){var e=Vc(s);i.call(e)}}var s=qc(t,r,e,0,null,!1,0,"",Xc);return e._reactRootContainer=s,e[go]=s.current,qr(8===e.nodeType?e.parentNode:e),uc(),s}for(;o=e.lastChild;)e.removeChild(o);if("function"===typeof r){var a=r;r=function(){var e=Vc(l);a.call(e)}}var l=$c(e,0,!1,null,0,!1,0,"",Xc);return e._reactRootContainer=l,e[go]=l.current,qr(8===e.nodeType?e.parentNode:e),uc((function(){jc(t,l,n,r)})),l}(n,t,e,o,r);return Vc(s)}Yc.prototype.render=Gc.prototype.render=function(e){var t=this._internalRoot;if(null===t)throw Error(i(409));jc(e,t,null,null)},Yc.prototype.unmount=Gc.prototype.unmount=function(){var e=this._internalRoot;if(null!==e){this._internalRoot=null;var t=e.containerInfo;uc((function(){jc(null,e,null,null)})),t[go]=null}},Yc.prototype.unstable_scheduleHydration=function(e){if(e){var t=At();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Ot.length&&0!==t&&t<Ot[n].priority;n++);Ot.splice(n,0,e),0===n&&Ut(e)}},Et=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=dt(t.pendingLanes);0!==n&&(bt(t,1|n),rc(t,Je()),0===(6&Cl)&&(ql=Je()+500,jo()))}break;case 13:uc((function(){var t=Di(e,1);if(null!==t){var n=ec();nc(t,e,1,n)}})),Kc(e,1)}},St=function(e){if(13===e.tag){var t=Di(e,134217728);if(null!==t)nc(t,e,134217728,ec());Kc(e,134217728)}},kt=function(e){if(13===e.tag){var t=tc(e),n=Di(e,t);if(null!==n)nc(n,e,t,ec());Kc(e,t)}},At=function(){return wt},_t=function(e,t){var n=wt;try{return wt=e,t()}finally{wt=n}},Se=function(e,t,n){switch(t){case"input":if(X(e,n),t=n.name,"radio"===n.type&&null!=t){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var o=So(r);if(!o)throw Error(i(90));W(r),X(r,o)}}}break;case"textarea":ie(e,n);break;case"select":null!=(t=n.value)&&ne(e,!!n.multiple,t,!1)}},Ce=cc,Re=uc;var eu={usingClientEntryPoint:!1,Events:[vo,Eo,So,Ie,xe,cc]},tu={findFiberByHostInstance:wo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},nu={bundleType:tu.bundleType,version:tu.version,rendererPackageName:tu.rendererPackageName,rendererConfig:tu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:v.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return null===(e=ze(e))?null:e.stateNode},findFiberByHostInstance:tu.findFiberByHostInstance||function(){return null},findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if("undefined"!==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__){var ru=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ru.isDisabled&&ru.supportsFiber)try{ot=ru.inject(nu),it=ru}catch(ue){}}t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=eu,t.createPortal=function(e,t){var n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:null;if(!Qc(t))throw Error(i(200));return function(e,t,n){var r=3<arguments.length&&void 0!==arguments[3]?arguments[3]:null;return{$$typeof:S,key:null==r?null:""+r,children:e,containerInfo:t,implementation:n}}(e,t,null,n)},t.createRoot=function(e,t){if(!Qc(e))throw Error(i(299));var n=!1,r="",o=Wc;return null!==t&&void 0!==t&&(!0===t.unstable_strictMode&&(n=!0),void 0!==t.identifierPrefix&&(r=t.identifierPrefix),void 0!==t.onRecoverableError&&(o=t.onRecoverableError)),t=$c(e,1,!1,null,0,n,0,r,o),e[go]=t.current,qr(8===e.nodeType?e.parentNode:e),new Gc(t)},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(i(188));throw e=Object.keys(e).join(","),Error(i(268,e))}return e=null===(e=ze(t))?null:e.stateNode},t.flushSync=function(e){return uc(e)},t.hydrate=function(e,t,n){if(!Jc(t))throw Error(i(200));return Zc(null,e,t,!0,n)},t.hydrateRoot=function(e,t,n){if(!Qc(e))throw Error(i(405));var r=null!=n&&n.hydratedSources||null,o=!1,s="",a=Wc;if(null!==n&&void 0!==n&&(!0===n.unstable_strictMode&&(o=!0),void 0!==n.identifierPrefix&&(s=n.identifierPrefix),void 0!==n.onRecoverableError&&(a=n.onRecoverableError)),t=qc(t,null,e,1,null!=n?n:null,o,0,s,a),e[go]=t.current,qr(e),r)for(e=0;e<r.length;e++)o=(o=(n=r[e])._getVersion)(n._source),null==t.mutableSourceEagerHydrationData?t.mutableSourceEagerHydrationData=[n,o]:t.mutableSourceEagerHydrationData.push(n,o);return new Yc(t)},t.render=function(e,t,n){if(!Jc(t))throw Error(i(200));return Zc(null,e,t,!1,n)},t.unmountComponentAtNode=function(e){if(!Jc(e))throw Error(i(40));return!!e._reactRootContainer&&(uc((function(){Zc(null,null,e,!1,(function(){e._reactRootContainer=null,e[go]=null}))})),!0)},t.unstable_batchedUpdates=cc,t.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Jc(n))throw Error(i(200));if(null==e||void 0===e._reactInternals)throw Error(i(38));return Zc(e,t,n,!1,r)},t.version="18.3.1-next-f1338f8080-20240426"},4391:(e,t,n)=>{"use strict";var r=n(7950);t.createRoot=r.createRoot,t.hydrateRoot=r.hydrateRoot},7950:(e,t,n)=>{"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=n(2730)},1153:(e,t,n)=>{"use strict";var r=n(5043),o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,i={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)s.call(t,r)&&!l.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:o,type:e,key:c,ref:u,props:i,_owner:a.current}}t.jsx=c,t.jsxs=c},4202:(e,t)=>{"use strict";var n=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),f=Symbol.iterator;var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,m={};function y(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||p}function b(){}function w(e,t,n){this.props=e,this.context=t,this.refs=m,this.updater=n||p}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if("object"!==typeof e&&"function"!==typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},b.prototype=y.prototype;var v=w.prototype=new b;v.constructor=w,g(v,y.prototype),v.isPureReactComponent=!0;var E=Array.isArray,S=Object.prototype.hasOwnProperty,k={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function _(e,t,r){var o,i={},s=null,a=null;if(null!=t)for(o in void 0!==t.ref&&(a=t.ref),void 0!==t.key&&(s=""+t.key),t)S.call(t,o)&&!A.hasOwnProperty(o)&&(i[o]=t[o]);var l=arguments.length-2;if(1===l)i.children=r;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(o in l=e.defaultProps)void 0===i[o]&&(i[o]=l[o]);return{$$typeof:n,type:e,key:s,ref:a,props:i,_owner:k.current}}function I(e){return"object"===typeof e&&null!==e&&e.$$typeof===n}var x=/\/+/g;function C(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 R(e,t,o,i,s){var a=typeof e;"undefined"!==a&&"boolean"!==a||(e=null);var l=!1;if(null===e)l=!0;else switch(a){case"string":case"number":l=!0;break;case"object":switch(e.$$typeof){case n:case r:l=!0}}if(l)return s=s(l=e),e=""===i?"."+C(l,0):i,E(s)?(o="",null!=e&&(o=e.replace(x,"$&/")+"/"),R(s,t,o,"",(function(e){return e}))):null!=s&&(I(s)&&(s=function(e,t){return{$$typeof:n,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(s,o+(!s.key||l&&l.key===s.key?"":(""+s.key).replace(x,"$&/")+"/")+e)),t.push(s)),1;if(l=0,i=""===i?".":i+":",E(e))for(var c=0;c<e.length;c++){var u=i+C(a=e[c],c);l+=R(a,t,o,u,s)}else if(u=function(e){return null===e||"object"!==typeof e?null:"function"===typeof(e=f&&e[f]||e["@@iterator"])?e:null}(e),"function"===typeof u)for(e=u.call(e),c=0;!(a=e.next()).done;)l+=R(a=a.value,t,o,u=i+C(a,c++),s);else if("object"===a)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return l}function T(e,t,n){if(null==e)return e;var r=[],o=0;return R(e,r,"","",(function(e){return t.call(n,e,o++)})),r}function N(e){if(-1===e._status){var t=e._result;(t=t()).then((function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)}),(function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)})),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var P={current:null},O={transition:null},L={ReactCurrentDispatcher:P,ReactCurrentBatchConfig:O,ReactCurrentOwner:k};function D(){throw Error("act(...) is not supported in production builds of React.")}t.Children={map:T,forEach:function(e,t,n){T(e,(function(){t.apply(this,arguments)}),n)},count:function(e){var t=0;return T(e,(function(){t++})),t},toArray:function(e){return T(e,(function(e){return e}))||[]},only:function(e){if(!I(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},t.Component=y,t.Fragment=o,t.Profiler=s,t.PureComponent=w,t.StrictMode=i,t.Suspense=u,t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=L,t.act=D,t.cloneElement=function(e,t,r){if(null===e||void 0===e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var o=g({},e.props),i=e.key,s=e.ref,a=e._owner;if(null!=t){if(void 0!==t.ref&&(s=t.ref,a=k.current),void 0!==t.key&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)S.call(t,c)&&!A.hasOwnProperty(c)&&(o[c]=void 0===t[c]&&void 0!==l?l[c]:t[c])}var c=arguments.length-2;if(1===c)o.children=r;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];o.children=l}return{$$typeof:n,type:e.type,key:i,ref:s,props:o,_owner:a}},t.createContext=function(e){return(e={$$typeof:l,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:a,_context:e},e.Consumer=e},t.createElement=_,t.createFactory=function(e){var t=_.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=I,t.lazy=function(e){return{$$typeof:h,_payload:{_status:-1,_result:e},_init:N}},t.memo=function(e,t){return{$$typeof:d,type:e,compare:void 0===t?null:t}},t.startTransition=function(e){var t=O.transition;O.transition={};try{e()}finally{O.transition=t}},t.unstable_act=D,t.useCallback=function(e,t){return P.current.useCallback(e,t)},t.useContext=function(e){return P.current.useContext(e)},t.useDebugValue=function(){},t.useDeferredValue=function(e){return P.current.useDeferredValue(e)},t.useEffect=function(e,t){return P.current.useEffect(e,t)},t.useId=function(){return P.current.useId()},t.useImperativeHandle=function(e,t,n){return P.current.useImperativeHandle(e,t,n)},t.useInsertionEffect=function(e,t){return P.current.useInsertionEffect(e,t)},t.useLayoutEffect=function(e,t){return P.current.useLayoutEffect(e,t)},t.useMemo=function(e,t){return P.current.useMemo(e,t)},t.useReducer=function(e,t,n){return P.current.useReducer(e,t,n)},t.useRef=function(e){return P.current.useRef(e)},t.useState=function(e){return P.current.useState(e)},t.useSyncExternalStore=function(e,t,n){return P.current.useSyncExternalStore(e,t,n)},t.useTransition=function(){return P.current.useTransition()},t.version="18.3.1"},5043:(e,t,n)=>{"use strict";e.exports=n(4202)},579:(e,t,n)=>{"use strict";e.exports=n(1153)},7234:(e,t)=>{"use strict";function n(e,t){var n=e.length;e.push(t);e:for(;0<n;){var r=n-1>>>1,o=e[r];if(!(0<i(o,t)))break e;e[r]=t,e[n]=o,n=r}}function r(e){return 0===e.length?null:e[0]}function o(e){if(0===e.length)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;e:for(var r=0,o=e.length,s=o>>>1;r<s;){var a=2*(r+1)-1,l=e[a],c=a+1,u=e[c];if(0>i(l,n))c<o&&0>i(u,l)?(e[r]=u,e[c]=n,r=c):(e[r]=l,e[a]=n,r=a);else{if(!(c<o&&0>i(u,n)))break e;e[r]=u,e[c]=n,r=c}}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return 0!==n?n:e.id-t.id}if("object"===typeof performance&&"function"===typeof performance.now){var s=performance;t.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();t.unstable_now=function(){return a.now()-l}}var c=[],u=[],d=1,h=null,f=3,p=!1,g=!1,m=!1,y="function"===typeof setTimeout?setTimeout:null,b="function"===typeof clearTimeout?clearTimeout:null,w="undefined"!==typeof setImmediate?setImmediate:null;function v(e){for(var t=r(u);null!==t;){if(null===t.callback)o(u);else{if(!(t.startTime<=e))break;o(u),t.sortIndex=t.expirationTime,n(c,t)}t=r(u)}}function E(e){if(m=!1,v(e),!g)if(null!==r(c))g=!0,O(S);else{var t=r(u);null!==t&&L(E,t.startTime-e)}}function S(e,n){g=!1,m&&(m=!1,b(I),I=-1),p=!0;var i=f;try{for(v(n),h=r(c);null!==h&&(!(h.expirationTime>n)||e&&!R());){var s=h.callback;if("function"===typeof s){h.callback=null,f=h.priorityLevel;var a=s(h.expirationTime<=n);n=t.unstable_now(),"function"===typeof a?h.callback=a:h===r(c)&&o(c),v(n)}else o(c);h=r(c)}if(null!==h)var l=!0;else{var d=r(u);null!==d&&L(E,d.startTime-n),l=!1}return l}finally{h=null,f=i,p=!1}}"undefined"!==typeof navigator&&void 0!==navigator.scheduling&&void 0!==navigator.scheduling.isInputPending&&navigator.scheduling.isInputPending.bind(navigator.scheduling);var k,A=!1,_=null,I=-1,x=5,C=-1;function R(){return!(t.unstable_now()-C<x)}function T(){if(null!==_){var e=t.unstable_now();C=e;var n=!0;try{n=_(!0,e)}finally{n?k():(A=!1,_=null)}}else A=!1}if("function"===typeof w)k=function(){w(T)};else if("undefined"!==typeof MessageChannel){var N=new MessageChannel,P=N.port2;N.port1.onmessage=T,k=function(){P.postMessage(null)}}else k=function(){y(T,0)};function O(e){_=e,A||(A=!0,k())}function L(e,n){I=y((function(){e(t.unstable_now())}),n)}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(){g||p||(g=!0,O(S))},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"):x=0<e?Math.floor(1e3/e):5},t.unstable_getCurrentPriorityLevel=function(){return f},t.unstable_getFirstCallbackNode=function(){return r(c)},t.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},t.unstable_scheduleCallback=function(e,o,i){var s=t.unstable_now();switch("object"===typeof i&&null!==i?i="number"===typeof(i=i.delay)&&0<i?s+i:s:i=s,e){case 1:var a=-1;break;case 2:a=250;break;case 5:a=1073741823;break;case 4:a=1e4;break;default:a=5e3}return e={id:d++,callback:o,priorityLevel:e,startTime:i,expirationTime:a=i+a,sortIndex:-1},i>s?(e.sortIndex=i,n(u,e),null===r(c)&&e===r(u)&&(m?(b(I),I=-1):m=!0,L(E,i-s))):(e.sortIndex=a,n(c,e),g||p||(g=!0,O(S))),e},t.unstable_shouldYield=R,t.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}},8853:(e,t,n)=>{"use strict";e.exports=n(7234)},495:()=>{}},__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var n=__webpack_module_cache__[e]={exports:{}};return __webpack_modules__[e].call(n.exports,n,n.exports,__webpack_require__),n.exports}__webpack_require__.amdO={},(()=>{var e,t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__;__webpack_require__.t=function(n,r){if(1&r&&(n=this(n)),8&r)return n;if("object"===typeof n&&n){if(4&r&&n.__esModule)return n;if(16&r&&"function"===typeof n.then)return n}var o=Object.create(null);__webpack_require__.r(o);var i={};e=e||[null,t({}),t([]),t(t)];for(var s=2&r&&n;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>i[e]=()=>n[e]));return i.default=()=>n,__webpack_require__.d(o,i),o}})(),__webpack_require__.d=(e,t)=>{for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__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:()=>ce});var t={};__webpack_require__.r(t),__webpack_require__.d(t,{base16:()=>ue,base16upper:()=>de});var n={};__webpack_require__.r(n),__webpack_require__.d(n,{base2:()=>he});var r={};__webpack_require__.r(r),__webpack_require__.d(r,{base256emoji:()=>me});var o={};__webpack_require__.r(o),__webpack_require__.d(o,{base32:()=>ye,base32hex:()=>Ee,base32hexpad:()=>ke,base32hexpadupper:()=>Ae,base32hexupper:()=>Se,base32pad:()=>we,base32padupper:()=>ve,base32upper:()=>be,base32z:()=>_e});var i={};__webpack_require__.r(i),__webpack_require__.d(i,{base36:()=>Ie,base36upper:()=>xe});var s={};__webpack_require__.r(s),__webpack_require__.d(s,{base58btc:()=>Ce,base58flickr:()=>Re});var a={};__webpack_require__.r(a),__webpack_require__.d(a,{base64:()=>Te,base64pad:()=>Ne,base64url:()=>Pe,base64urlpad:()=>Oe});var l={};__webpack_require__.r(l),__webpack_require__.d(l,{base8:()=>Le});var c={};__webpack_require__.r(c),__webpack_require__.d(c,{identity:()=>De});var u={};__webpack_require__.r(u),__webpack_require__.d(u,{code:()=>Fe,decode:()=>He,encode:()=>$e,name:()=>Me});var d={};__webpack_require__.r(d),__webpack_require__.d(d,{code:()=>je,decode:()=>ze,encode:()=>Ve,name:()=>qe});var h={};__webpack_require__.r(h),__webpack_require__.d(h,{identity:()=>mt});var f={};__webpack_require__.r(f),__webpack_require__.d(f,{sha256:()=>vt,sha512:()=>Et});var p={};__webpack_require__.r(p),__webpack_require__.d(p,{aK:()=>Zs,e8:()=>Us,DO:()=>Bs,dJ:()=>ea,OG:()=>ta,My:()=>Fs,Ph:()=>zs,lX:()=>Ks,Id:()=>Qs,fg:()=>oa,qj:()=>Ys,aT:()=>Vs,r4:()=>Xs,aY:()=>Ds,x:()=>aa,lq:()=>Ws,z:()=>Gs,zW:()=>$s,Q5:()=>sa});var g={};__webpack_require__.r(g),__webpack_require__.d(g,{Ed25519PrivateKey:()=>fl,Ed25519PublicKey:()=>hl,generateKeyPair:()=>ml,generateKeyPairFromSeed:()=>yl,unmarshalEd25519PrivateKey:()=>pl,unmarshalEd25519PublicKey:()=>gl});var m={};__webpack_require__.r(m),__webpack_require__.d(m,{MAX_RSA_KEY_SIZE:()=>Mu,RsaPrivateKey:()=>$u,RsaPublicKey:()=>Fu,fromJwk:()=>ju,generateKeyPair:()=>Vu,unmarshalRsaPrivateKey:()=>Hu,unmarshalRsaPublicKey:()=>qu});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{Secp256k1PrivateKey:()=>dd,Secp256k1PublicKey:()=>ud,generateKeyPair:()=>pd,unmarshalSecp256k1PrivateKey:()=>hd,unmarshalSecp256k1PublicKey:()=>fd});var b=__webpack_require__(5043),w=__webpack_require__(4391);function v(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}function E(){return new Uint8Array(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0)}const S=Math.pow(2,7),k=Math.pow(2,14),A=Math.pow(2,21),_=Math.pow(2,28),I=Math.pow(2,35),x=Math.pow(2,42),C=Math.pow(2,49),R=128,T=127;function N(e){if(e<S)return 1;if(e<k)return 2;if(e<A)return 3;if(e<_)return 4;if(e<I)return 5;if(e<x)return 6;if(e<C)return 7;if(null!=Number.MAX_SAFE_INTEGER&&e>Number.MAX_SAFE_INTEGER)throw new RangeError("Could not encode varint");return 8}function P(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(N(e)){case 8:t[n++]=255&e|R,e/=128;case 7:t[n++]=255&e|R,e/=128;case 6:t[n++]=255&e|R,e/=128;case 5:t[n++]=255&e|R,e/=128;case 4:t[n++]=255&e|R,e>>>=7;case 3:t[n++]=255&e|R,e>>>=7;case 2:t[n++]=255&e|R,e>>>=7;case 1:t[n++]=255&e,e>>>=7;break;default:throw new Error("unreachable")}return t}function O(e,t){let n=e[t],r=0;if(r+=n&T,n<R)return r;if(n=e[t+1],r+=(n&T)<<7,n<R)return r;if(n=e[t+2],r+=(n&T)<<14,n<R)return r;if(n=e[t+3],r+=(n&T)<<21,n<R)return r;if(n=e[t+4],r+=(n&T)*_,n<R)return r;if(n=e[t+5],r+=(n&T)*I,n<R)return r;if(n=e[t+6],r+=(n&T)*x,n<R)return r;if(n=e[t+7],r+=(n&T)*C,n<R)return r;throw new RangeError("Could not decode varint")}function L(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return null==t&&(t=E(N(e))),t instanceof Uint8Array?P(e,t,n):function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;switch(N(e)){case 8:t.set(n++,255&e|R),e/=128;case 7:t.set(n++,255&e|R),e/=128;case 6:t.set(n++,255&e|R),e/=128;case 5:t.set(n++,255&e|R),e/=128;case 4:t.set(n++,255&e|R),e>>>=7;case 3:t.set(n++,255&e|R),e>>>=7;case 2:t.set(n++,255&e|R),e>>>=7;case 1:t.set(n++,255&e),e>>>=7;break;default:throw new Error("unreachable")}return t}(e,t,n)}function D(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e instanceof Uint8Array?O(e,t):function(e,t){let n=e.get(t),r=0;if(r+=n&T,n<R)return r;if(n=e.get(t+1),r+=(n&T)<<7,n<R)return r;if(n=e.get(t+2),r+=(n&T)<<14,n<R)return r;if(n=e.get(t+3),r+=(n&T)<<21,n<R)return r;if(n=e.get(t+4),r+=(n&T)*_,n<R)return r;if(n=e.get(t+5),r+=(n&T)*I,n<R)return r;if(n=e.get(t+6),r+=(n&T)*x,n<R)return r;if(n=e.get(t+7),r+=(n&T)*C,n<R)return r;throw new RangeError("Could not decode varint")}(e,t)}const B=new Float32Array([-0]),U=new Uint8Array(B.buffer);function M(e,t,n){B[0]=e,t[n]=U[0],t[n+1]=U[1],t[n+2]=U[2],t[n+3]=U[3]}const F=new Float64Array([-0]),$=new Uint8Array(F.buffer);function H(e,t,n){F[0]=e,t[n]=$[0],t[n+1]=$[1],t[n+2]=$[2],t[n+3]=$[3],t[n+4]=$[4],t[n+5]=$[5],t[n+6]=$[6],t[n+7]=$[7]}const q=BigInt(Number.MAX_SAFE_INTEGER),j=BigInt(Number.MIN_SAFE_INTEGER);class V{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,n=this.hi>>>24;return 0===n?0===t?e<16384?e<128?1:2:e<2097152?3:4:t<16384?t<128?5:6:t<2097152?7:8:n<128?9:10}static fromBigInt(e){if(0n===e)return z;if(e<q&&e>j)return this.fromNumber(Number(e));const t=e<0n;t&&(e=-e);let n=e>>32n,r=e-(n<<32n);return t&&(n=0n|~n,r=0n|~r,++r>K&&(r=0n,++n>K&&(n=0n))),new V(Number(r),Number(n))}static fromNumber(e){if(0===e)return z;const t=e<0;t&&(e=-e);let n=e>>>0,r=(e-n)/4294967296>>>0;return t&&(r=~r>>>0,n=~n>>>0,++n>4294967295&&(n=0,++r>4294967295&&(r=0))),new V(n,r)}static from(e){return"number"===typeof e?V.fromNumber(e):"bigint"===typeof e?V.fromBigInt(e):"string"===typeof e?V.fromBigInt(BigInt(e)):null!=e.low||null!=e.high?new V(e.low>>>0,e.high>>>0):z}}const z=new V(0,0);z.toBigInt=function(){return 0n},z.zzEncode=z.zzDecode=function(){return this},z.length=function(){return 1};const K=4294967296n;function W(e,t,n){const r=n;let o,i;for(let s=0;s<e.length;++s)o=e.charCodeAt(s),o<128?t[n++]=o:o<2048?(t[n++]=o>>6|192,t[n++]=63&o|128):55296===(64512&o)&&56320===(64512&(i=e.charCodeAt(s+1)))?(o=65536+((1023&o)<<10)+(1023&i),++s,t[n++]=o>>18|240,t[n++]=o>>12&63|128,t[n++]=o>>6&63|128,t[n++]=63&o|128):(t[n++]=o>>12|224,t[n++]=o>>6&63|128,t[n++]=63&o|128);return n-r}function G(e,t){return RangeError(`index out of range: ${e.pos} + ${t??1} > ${e.len}`)}function Y(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}class Q{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,G(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 G(this,4);return Y(this.buf,this.pos+=4)}sfixed32(){if(this.pos+4>this.len)throw G(this,4);return 0|Y(this.buf,this.pos+=4)}float(){if(this.pos+4>this.len)throw G(this,4);const e=(t=this.buf,n=this.pos,U[0]=t[n],U[1]=t[n+1],U[2]=t[n+2],U[3]=t[n+3],B[0]);var t,n;return this.pos+=4,e}double(){if(this.pos+8>this.len)throw G(this,4);const e=(t=this.buf,n=this.pos,$[0]=t[n],$[1]=t[n+1],$[2]=t[n+2],$[3]=t[n+3],$[4]=t[n+4],$[5]=t[n+5],$[6]=t[n+6],$[7]=t[n+7],F[0]);var t,n;return this.pos+=8,e}bytes(){const e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw G(this,e);return this.pos+=e,t===n?new Uint8Array(0):this.buf.subarray(t,n)}string(){const e=this.bytes();return function(e,t,n){if(n-t<1)return"";let r;const o=[];let i,s=0;for(;t<n;)i=e[t++],i<128?o[s++]=i:i>191&&i<224?o[s++]=(31&i)<<6|63&e[t++]:i>239&&i<365?(i=((7&i)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,o[s++]=55296+(i>>10),o[s++]=56320+(1023&i)):o[s++]=(15&i)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((r??(r=[])).push(String.fromCharCode.apply(String,o)),s=0);return null!=r?(s>0&&r.push(String.fromCharCode.apply(String,o.slice(0,s))),r.join("")):String.fromCharCode.apply(String,o.slice(0,s))}(e,0,e.length)}skip(e){if("number"===typeof e){if(this.pos+e>this.len)throw G(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw G(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 V(0,0);let t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw G(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 G(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 G(this,8);const e=Y(this.buf,this.pos+=4),t=Y(this.buf,this.pos+=4);return new V(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=O(this.buf,this.pos);return this.pos+=N(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 J(e,t,n){const r=function(e){return new Q(e instanceof Uint8Array?e:e.subarray())}(e);return t.decode(r,void 0,n)}new Uint8Array(0);function X(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 Z=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var i=e.charAt(o),s=i.charCodeAt(0);if(255!==n[s])throw new TypeError(i+" is ambiguous");n[s]=o}var a=e.length,l=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(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 r=0,o=0;e[t]===l;)r++,t++;for(var i=(e.length-t)*c+1>>>0,s=new Uint8Array(i);e[t];){var u=n[e.charCodeAt(t)];if(255===u)return;for(var d=0,h=i-1;(0!==u||d<o)&&-1!==h;h--,d++)u+=a*s[h]>>>0,s[h]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");o=d,t++}if(" "!==e[t]){for(var f=i-o;f!==i&&0===s[f];)f++;for(var p=new Uint8Array(r+(i-f)),g=r;f!==i;)p[g++]=s[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 n=0,r=0,o=0,i=t.length;o!==i&&0===t[o];)o++,n++;for(var s=(i-o)*u+1>>>0,c=new Uint8Array(s);o!==i;){for(var d=t[o],h=0,f=s-1;(0!==d||h<r)&&-1!==f;f--,h++)d+=256*c[f]>>>0,c[f]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");r=h,o++}for(var p=s-r;p!==s&&0===c[p];)p++;for(var g=l.repeat(n);p<s;++p)g+=e.charAt(c[p]);return g},decodeUnsafe:d,decode:function(e){var n=d(e);if(n)return n;throw new Error(`Non-${t} character`)}}};const ee=Z;class te{name;prefix;baseEncode;constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ne{name;prefix;baseDecode;prefixCodePoint;constructor(e,t,n){this.name=e,this.prefix=t;const r=t.codePointAt(0);if(void 0===r)throw new Error("Invalid prefix character");this.prefixCodePoint=r,this.baseDecode=n}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 oe(this,e)}}class re{decoders;constructor(e){this.decoders=e}or(e){return oe(this,e)}decode(e){const t=e[0],n=this.decoders[t];if(null!=n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function oe(e,t){return new re({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class ie{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,t,n,r){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=r,this.encoder=new te(e,t,n),this.decoder=new ne(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}function se(e){let{name:t,prefix:n,encode:r,decode:o}=e;return new ie(t,n,r,o)}function ae(e){let{name:t,prefix:n,alphabet:r}=e;const{encode:o,decode:i}=ee(r,t);return se({prefix:n,name:t,encode:o,decode:e=>X(i(e))})}function le(e){let{name:t,prefix:n,bitsPerChar:r,alphabet:o}=e;return se({prefix:n,name:t,encode:e=>function(e,t,n){const r="="===t[t.length-1],o=(1<<n)-1;let i="",s=0,a=0;for(let l=0;l<e.length;++l)for(a=a<<8|e[l],s+=8;s>n;)s-=n,i+=t[o&a>>s];if(0!==s&&(i+=t[o&a<<n-s]),r)for(;0!==(i.length*n&7);)i+="=";return i}(e,o,r),decode:e=>function(e,t,n,r){const o={};for(let u=0;u<t.length;++u)o[t[u]]=u;let i=e.length;for(;"="===e[i-1];)--i;const s=new Uint8Array(i*n/8|0);let a=0,l=0,c=0;for(let u=0;u<i;++u){const t=o[e[u]];if(void 0===t)throw new SyntaxError(`Non-${r} character`);l=l<<n|t,a+=n,a>=8&&(a-=8,s[c++]=255&l>>a)}if(a>=n||0!==(255&l<<8-a))throw new SyntaxError("Unexpected end of data");return s}(e,o,r,t)})}const ce=ae({prefix:"9",name:"base10",alphabet:"0123456789"}),ue=le({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),de=le({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),he=le({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),fe=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"),pe=fe.reduce(((e,t,n)=>(e[n]=t,e)),[]),ge=fe.reduce(((e,t,n)=>{const r=t.codePointAt(0);if(null==r)throw new Error(`Invalid character: ${t}`);return e[r]=n,e}),[]);const me=se({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=pe[t]),"")},decode:function(e){const t=[];for(const n of e){const e=n.codePointAt(0);if(null==e)throw new Error(`Invalid character: ${n}`);const r=ge[e];if(null==r)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}}),ye=le({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),be=le({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),we=le({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ve=le({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ee=le({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Se=le({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),ke=le({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ae=le({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_e=le({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Ie=ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xe=ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Ce=ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Re=ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Te=le({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ne=le({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pe=le({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Oe=le({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Le=le({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),De=se({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)}),Be=new TextEncoder,Ue=new TextDecoder,Me="json",Fe=512;function $e(e){return Be.encode(JSON.stringify(e))}function He(e){return JSON.parse(Ue.decode(e))}const qe="raw",je=85;function Ve(e){return X(e)}function ze(e){return X(e)}var Ke=function e(t,n,r){n=n||[];var o=r=r||0;for(;t>=Ye;)n[r++]=255&t|We,t/=128;for(;t&Ge;)n[r++]=255&t|We,t>>>=7;return n[r]=0|t,e.bytes=r-o+1,n},We=128,Ge=-128,Ye=Math.pow(2,31);var Qe=function e(t,n){var r,o=0,i=0,s=n=n||0,a=t.length;do{if(s>=a)throw e.bytes=0,new RangeError("Could not decode varint");r=t[s++],o+=i<28?(r&Xe)<<i:(r&Xe)*Math.pow(2,i),i+=7}while(r>=Je);return e.bytes=s-n,o},Je=128,Xe=127;var Ze=Math.pow(2,7),et=Math.pow(2,14),tt=Math.pow(2,21),nt=Math.pow(2,28),rt=Math.pow(2,35),ot=Math.pow(2,42),it=Math.pow(2,49),st=Math.pow(2,56),at=Math.pow(2,63);const lt={encode:Ke,decode:Qe,encodingLength:function(e){return e<Ze?1:e<et?2:e<tt?3:e<nt?4:e<rt?5:e<ot?6:e<it?7:e<st?8:e<at?9:10}};function ct(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return[lt.decode(e,t),lt.decode.bytes]}function ut(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return lt.encode(e,t,n),t}function dt(e){return lt.encodingLength(e)}function ht(e,t){const n=t.byteLength,r=dt(e),o=r+dt(n),i=new Uint8Array(o+n);return ut(e,i,0),ut(n,i,r),i.set(t,o),new pt(e,n,t,i)}function ft(e){const t=X(e),[n,r]=ct(t),[o,i]=ct(t.subarray(r)),s=t.subarray(r+i);if(s.byteLength!==o)throw new Error("Incorrect length");return new pt(n,o,s,t)}class pt{code;size;digest;bytes;constructor(e,t,n,r){this.code=e,this.size=t,this.digest=n,this.bytes=r}}const gt=X;const mt={code:0,name:"identity",encode:gt,digest:function(e){return ht(0,gt(e))}};function yt(e){let{name:t,code:n,encode:r}=e;return new bt(t,n,r)}class bt{name;code;encode;constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ht(this.code,t):t.then((e=>ht(this.code,e)))}throw Error("Unknown type, must be binary type")}}function wt(e){return async t=>new Uint8Array(await crypto.subtle.digest(e,t))}const vt=yt({name:"sha2-256",code:18,encode:wt("SHA-256")}),Et=yt({name:"sha2-512",code:19,encode:wt("SHA-512")});function St(e,t){const{bytes:n,version:r}=e;return 0===r?function(e,t,n){const{prefix:r}=n;if(r!==Ce.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);const o=t.get(r);if(null==o){const o=n.encode(e).slice(1);return t.set(r,o),o}return o}(n,At(e),t??Ce.encoder):function(e,t,n){const{prefix:r}=n,o=t.get(r);if(null==o){const o=n.encode(e);return t.set(r,o),o}return o}(n,At(e),t??ye.encoder)}const kt=new WeakMap;function At(e){const t=kt.get(e);if(null==t){const t=new Map;return kt.set(e,t),t}return t}class _t{code;version;multihash;bytes;"/";constructor(e,t,n,r){this.code=t,this.version=e,this.multihash=n,this.bytes=r,this["/"]=r}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!==It)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==xt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return _t.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,n=ht(e,t);return _t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return _t.equals(this,e)}static equals(e,t){const n=t;return null!=n&&e.code===n.code&&e.version===n.version&&function(e,t){if(e===t)return!0;{const n=t;return e.code===n.code&&e.size===n.size&&n.bytes instanceof Uint8Array&&function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}(e.bytes,n.bytes)}}(e.multihash,n.multihash)}toString(e){return St(this,e)}toJSON(){return{"/":St(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 _t)return t;if(null!=t["/"]&&t["/"]===t.bytes||t.asCID===t){const{version:e,code:n,multihash:r,bytes:o}=t;return new _t(e,n,r,o??Ct(e,n,r.bytes))}if(!0===t[Rt]){const{version:e,multihash:n,code:r}=t,o=ft(n);return _t.create(e,r,o)}return null}static create(e,t,n){if("number"!==typeof t)throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:if(t!==It)throw new Error(`Version 0 CID must use dag-pb (code: ${It}) block encoding`);return new _t(e,t,n,n.bytes);case 1:{const r=Ct(e,t,n.bytes);return new _t(e,t,n,r)}default:throw new Error("Invalid version")}}static createV0(e){return _t.create(0,It,e)}static createV1(e,t){return _t.create(1,e,t)}static decode(e){const[t,n]=_t.decodeFirst(e);if(0!==n.length)throw new Error("Incorrect length");return t}static decodeFirst(e){const t=_t.inspectBytes(e),n=t.size-t.multihashSize,r=X(e.subarray(n,n+t.multihashSize));if(r.byteLength!==t.multihashSize)throw new Error("Incorrect length");const o=r.subarray(t.multihashSize-t.digestSize),i=new pt(t.multihashCode,t.digestSize,o,r);return[0===t.version?_t.createV0(i):_t.createV1(t.codec,i),e.subarray(t.size)]}static inspectBytes(e){let t=0;const n=()=>{const[n,r]=ct(e.subarray(t));return t+=r,n};let r=n(),o=It;if(18===r?(r=0,t=0):o=n(),0!==r&&1!==r)throw new RangeError(`Invalid CID version ${r}`);const i=t,s=n(),a=n(),l=t+a;return{version:r,codec:o,multihashCode:s,digestSize:a,multihashSize:l-i,size:l}}static parse(e,t){const[n,r]=function(e,t){switch(e[0]){case"Q":{const n=t??Ce;return[Ce.prefix,n.decode(`${Ce.prefix}${e}`)]}case Ce.prefix:{const n=t??Ce;return[Ce.prefix,n.decode(e)]}case ye.prefix:{const n=t??ye;return[ye.prefix,n.decode(e)]}case Ie.prefix:{const n=t??Ie;return[Ie.prefix,n.decode(e)]}default:if(null==t)throw Error("To parse non base32, base36 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}(e,t),o=_t.decode(r);if(0===o.version&&"Q"!==e[0])throw Error("Version 0 CID string must not include multibase prefix");return At(o).set(n,e),o}}const It=112,xt=18;function Ct(e,t,n){const r=dt(e),o=r+dt(t),i=new Uint8Array(o+n.byteLength);return ut(e,i,0),ut(t,i,r),i.set(n,o),i}const Rt=Symbol.for("@ipld/js-cid/CID"),Tt={...c,...n,...l,...e,...t,...o,...i,...s,...a,...r};function Nt(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const Pt=Nt("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Ot=Nt("ascii","a",(e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}),(e=>{const t=E((e=e.substring(1)).length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t})),Lt={utf8:Pt,"utf-8":Pt,hex:Tt.base16,latin1:Ot,ascii:Ot,binary:Ot,...Tt};function Dt(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const n=Lt[t];if(null==n)throw new Error(`Unsupported encoding "${t}"`);return n.decoder.decode(`${n.prefix}${e}`)}class Bt{fn;len;next;val;constructor(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}}function Ut(){}class Mt{head;tail;len;next;constructor(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}}const Ft=function(e){const t=e??8192,n=t>>>1;let r,o=t;return function(e){if(e<1||e>n)return E(e);o+e>t&&(r=E(t),o=0);const i=r.subarray(o,o+=e);return 0!==(7&o)&&(o=1+(7|o)),i}}();class $t{len;head;tail;states;constructor(){this.len=0,this.head=new Bt(Ut,0,0),this.tail=this.head,this.states=null}_push(e,t,n){return this.tail=this.tail.next=new Bt(e,t,n),this.len+=t,this}uint32(e){return this.len+=(this.tail=this.tail.next=new jt((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this}int32(e){return e<0?this._push(Vt,10,V.fromNumber(e)):this.uint32(e)}sint32(e){return this.uint32((e<<1^e>>31)>>>0)}uint64(e){const t=V.fromBigInt(e);return this._push(Vt,t.length(),t)}uint64Number(e){return this._push(P,N(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=V.fromBigInt(e).zzEncode();return this._push(Vt,t.length(),t)}sint64Number(e){const t=V.fromNumber(e).zzEncode();return this._push(Vt,t.length(),t)}sint64String(e){return this.sint64(BigInt(e))}bool(e){return this._push(Ht,1,e?1:0)}fixed32(e){return this._push(zt,4,e>>>0)}sfixed32(e){return this.fixed32(e)}fixed64(e){const t=V.fromBigInt(e);return this._push(zt,4,t.lo)._push(zt,4,t.hi)}fixed64Number(e){const t=V.fromNumber(e);return this._push(zt,4,t.lo)._push(zt,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(M,4,e)}double(e){return this._push(H,8,e)}bytes(e){const t=e.length>>>0;return 0===t?this._push(Ht,1,0):this.uint32(t)._push(Kt,t,e)}string(e){const t=function(e){let t=0,n=0;for(let r=0;r<e.length;++r)n=e.charCodeAt(r),n<128?t+=1:n<2048?t+=2:55296===(64512&n)&&56320===(64512&e.charCodeAt(r+1))?(++r,t+=4):t+=3;return t}(e);return 0!==t?this.uint32(t)._push(W,t,e):this._push(Ht,1,0)}fork(){return this.states=new Mt(this),this.head=this.tail=new Bt(Ut,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 Bt(Ut,0,0),this.len=0),this}ldelim(){const e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),0!==n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this}finish(){let e=this.head.next;const t=(n=this.len,null!=globalThis.Buffer?E(n):Ft(n));var n;let r=0;for(;null!=e;)e.fn(e.val,t,r),r+=e.len,e=e.next;return t}}function Ht(e,t,n){t[n]=255&e}function qt(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e}class jt extends Bt{next;constructor(e,t){super(qt,e,t),this.next=void 0}}function Vt(e,t,n){for(;0!==e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function zt(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}function Kt(e,t,n){t.set(e,n)}function Wt(e,t,n){t.set(e,n)}function Gt(e,t,n){e.length<40?W(e,t,n):null!=t.utf8Write?t.utf8Write(e,n):t.set(Dt(e),n)}function Yt(e,t){const n=new $t;return t.encode(e,n,{lengthDelimited:!1}),n.finish()}var Qt,Jt,Xt,Zt,en,tn,nn,rn,on,sn,an,ln,cn,un,dn,hn,fn,pn,gn,mn,yn,bn,wn,vn,En,Sn,kn,An,_n,In;function xn(e,t,n,r){return{name:e,type:t,encode:n,decode:r}}function Cn(e){function t(t){if(null==e[t.toString()])throw new Error("Invalid enum value");return e[t]}return xn("enum",Qt.VARINT,(function(e,n){const r=t(e);n.int32(r)}),(function(e){return t(e.int32())}))}function Rn(e,t){return xn("message",Qt.LENGTH_DELIMITED,e,t)}null!=globalThis.Buffer&&($t.prototype.bytes=function(e){const t=e.length>>>0;return this.uint32(t),t>0&&this._push(Wt,t,e),this},$t.prototype.string=function(e){const t=globalThis.Buffer.byteLength(e);return this.uint32(t),t>0&&this._push(Gt,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"}(Qt||(Qt={}));Error;class Tn extends Error{code="ERR_MAX_LENGTH";name="MaxLengthError"}function Nn(e){return Boolean(e)}function Pn(e){const t=new Map;return e.forEach((e=>{let n=t.get(e.contentTopic);n||(t.set(e.contentTopic,[]),n=t.get(e.contentTopic)),n.push(e)})),t}!function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={proof:v(0),merkleRoot:v(0),epoch:v(0),shareX:v(0),shareY:v(0),nullifier:v(0),rlnIdentifier:v(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(Jt||(Jt={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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),Jt.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={payload:v(0),contentTopic:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){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=Jt.codec().decode(e,e.uint32(),{limits:n.limits?.rateLimitProof});break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(Xt||(Xt={})),function(e){let t,n;!function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(10),t.string(e.contentTopic)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={contentTopic:""},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();if(t>>>3===1)n.contentTopic=e.string();else e.skipType(7&t)}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(t=e.ContentFilter||(e.ContentFilter={})),e.codec=()=>(null==n&&(n=Rn((function(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&n.fork(),null!=t.subscribe&&!1!==t.subscribe&&(n.uint32(8),n.bool(t.subscribe)),null!=t.topic&&""!==t.topic&&(n.uint32(18),n.string(t.topic)),null!=t.contentFilters)for(const o of t.contentFilters)n.uint32(26),e.ContentFilter.codec().encode(o,n);!1!==r.lengthDelimited&&n.ldelim()}),(function(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const o={subscribe:!1,topic:"",contentFilters:[]},i=null==n?t.len:t.pos+n;for(;t.pos<i;){const n=t.uint32();switch(n>>>3){case 1:o.subscribe=t.bool();break;case 2:o.topic=t.string();break;case 3:if(null!=r.limits?.contentFilters&&o.contentFilters.length===r.limits.contentFilters)throw new Tn('Decode error - map field "contentFilters" had too many elements');o.contentFilters.push(e.ContentFilter.codec().decode(t,t.uint32(),{limits:r.limits?.contentFilters$}));break;default:t.skipType(7&n)}}return o}))),n),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(Zt||(Zt={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&t.fork(),null!=e.messages)for(const r of e.messages)t.uint32(10),rn.codec().encode(r,t);!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={messages:[]},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();if(t>>>3===1){if(null!=n.limits?.messages&&r.messages.length===n.limits.messages)throw new Tn('Decode error - map field "messages" had too many elements');r.messages.push(rn.codec().decode(e,e.uint32(),{limits:n.limits?.messages$}))}else e.skipType(7&t)}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(en||(en={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),Zt.codec().encode(e.request,t)),null!=e.push&&(t.uint32(26),en.codec().encode(e.push,t)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={requestId:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.request=Zt.codec().decode(e,e.uint32(),{limits:n.limits?.request});break;case 3:r.push=en.codec().decode(e,e.uint32(),{limits:n.limits?.push});break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(tn||(tn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={proof:v(0),merkleRoot:v(0),epoch:v(0),shareX:v(0),shareY:v(0),nullifier:v(0),rlnIdentifier:v(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(nn||(nn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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),nn.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={payload:v(0),contentTopic:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){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=nn.codec().decode(e,e.uint32(),{limits:n.limits?.rateLimitProof});break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(rn||(rn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.contentTopic&&""!==e.contentTopic&&(t.uint32(18),t.string(e.contentTopic)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={contentTopic:""},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();if(t>>>3===2)n.contentTopic=e.string();else e.skipType(7&t)}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(on||(on={})),function(e){let t,n,r;!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"}(n||(n={})),function(e){e.codec=()=>Cn(n)}(t=e.FilterSubscribeType||(e.FilterSubscribeType={})),e.codec=()=>(null==r&&(r=Rn((function(t,r){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==o.lengthDelimited&&r.fork(),null!=t.requestId&&""!==t.requestId&&(r.uint32(10),r.string(t.requestId)),null!=t.filterSubscribeType&&0!==n[t.filterSubscribeType]&&(r.uint32(16),e.FilterSubscribeType.codec().encode(t.filterSubscribeType,r)),null!=t.pubsubTopic&&(r.uint32(82),r.string(t.pubsubTopic)),null!=t.contentTopics)for(const e of t.contentTopics)r.uint32(90),r.string(e);!1!==o.lengthDelimited&&r.ldelim()}),(function(n,r){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const i={requestId:"",filterSubscribeType:t.SUBSCRIBER_PING,contentTopics:[]},s=null==r?n.len:n.pos+r;for(;n.pos<s;){const t=n.uint32();switch(t>>>3){case 1:i.requestId=n.string();break;case 2:i.filterSubscribeType=e.FilterSubscribeType.codec().decode(n);break;case 10:i.pubsubTopic=n.string();break;case 11:if(null!=o.limits?.contentTopics&&i.contentTopics.length===o.limits.contentTopics)throw new Tn('Decode error - map field "contentTopics" had too many elements');i.contentTopics.push(n.string());break;default:n.skipType(7&t)}}return i}))),r),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(sn||(sn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={requestId:"",statusCode:0},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.requestId=e.string();break;case 10:n.statusCode=e.uint32();break;case 11:n.statusDesc=e.string();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(an||(an={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.wakuMessage&&(t.uint32(10),un.codec().encode(e.wakuMessage,t)),null!=e.pubsubTopic&&(t.uint32(18),t.string(e.pubsubTopic)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.wakuMessage=un.codec().decode(e,e.uint32(),{limits:n.limits?.wakuMessage});break;case 2:r.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(ln||(ln={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={proof:v(0),merkleRoot:v(0),epoch:v(0),shareX:v(0),shareY:v(0),nullifier:v(0),rlnIdentifier:v(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(cn||(cn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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),cn.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={payload:v(0),contentTopic:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){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=cn.codec().decode(e,e.uint32(),{limits:n.limits?.rateLimitProof});break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(un||(un={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.pubsubTopic&&""!==e.pubsubTopic&&(t.uint32(10),t.string(e.pubsubTopic)),null!=e.message&&(t.uint32(18),gn.codec().encode(e.message,t)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={pubsubTopic:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.pubsubTopic=e.string();break;case 2:r.message=gn.codec().decode(e,e.uint32(),{limits:n.limits?.message});break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(dn||(dn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={isSuccess:!1},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.isSuccess=e.bool();break;case 2:n.info=e.string();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(hn||(hn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.request&&(t.uint32(18),dn.codec().encode(e.request,t)),null!=e.response&&(t.uint32(26),hn.codec().encode(e.response,t)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={requestId:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.request=dn.codec().decode(e,e.uint32(),{limits:n.limits?.request});break;case 3:r.response=hn.codec().decode(e,e.uint32(),{limits:n.limits?.response});break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(fn||(fn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={proof:v(0),merkleRoot:v(0),epoch:v(0),shareX:v(0),shareY:v(0),nullifier:v(0),rlnIdentifier:v(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(pn||(pn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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),pn.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={payload:v(0),contentTopic:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){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=pn.codec().decode(e,e.uint32(),{limits:n.limits?.rateLimitProof});break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(gn||(gn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.messageHash&&(t.uint32(10),t.bytes(e.messageHash)),null!=e.message&&(t.uint32(18),vn.codec().encode(e.message,t)),null!=e.pubsubTopic&&(t.uint32(26),t.string(e.pubsubTopic)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.messageHash=e.bytes();break;case 2:r.message=vn.codec().decode(e,e.uint32(),{limits:n.limits?.message});break;case 3:r.pubsubTopic=e.string();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(mn||(mn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.includeData&&!1!==e.includeData&&(t.uint32(16),t.bool(e.includeData)),null!=e.pubsubTopic&&(t.uint32(82),t.string(e.pubsubTopic)),null!=e.contentTopics)for(const r of e.contentTopics)t.uint32(90),t.string(r);if(null!=e.timeStart&&(t.uint32(96),t.sint64(e.timeStart)),null!=e.timeEnd&&(t.uint32(104),t.sint64(e.timeEnd)),null!=e.messageHashes)for(const r of e.messageHashes)t.uint32(162),t.bytes(r);null!=e.paginationCursor&&(t.uint32(410),t.bytes(e.paginationCursor)),null!=e.paginationForward&&!1!==e.paginationForward&&(t.uint32(416),t.bool(e.paginationForward)),null!=e.paginationLimit&&(t.uint32(424),t.uint64(e.paginationLimit)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={requestId:"",includeData:!1,contentTopics:[],messageHashes:[],paginationForward:!1},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.requestId=e.string();break;case 2:r.includeData=e.bool();break;case 10:r.pubsubTopic=e.string();break;case 11:if(null!=n.limits?.contentTopics&&r.contentTopics.length===n.limits.contentTopics)throw new Tn('Decode error - map field "contentTopics" had too many elements');r.contentTopics.push(e.string());break;case 12:r.timeStart=e.sint64();break;case 13:r.timeEnd=e.sint64();break;case 20:if(null!=n.limits?.messageHashes&&r.messageHashes.length===n.limits.messageHashes)throw new Tn('Decode error - map field "messageHashes" had too many elements');r.messageHashes.push(e.bytes());break;case 51:r.paginationCursor=e.bytes();break;case 52:r.paginationForward=e.bool();break;case 53:r.paginationLimit=e.uint64();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(yn||(yn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&t.fork(),null!=e.requestId&&""!==e.requestId&&(t.uint32(10),t.string(e.requestId)),null!=e.statusCode&&(t.uint32(80),t.uint32(e.statusCode)),null!=e.statusDesc&&(t.uint32(90),t.string(e.statusDesc)),null!=e.messages)for(const r of e.messages)t.uint32(162),mn.codec().encode(r,t);null!=e.paginationCursor&&(t.uint32(410),t.bytes(e.paginationCursor)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={requestId:"",messages:[]},o=null==t?e.len:e.pos+t;for(;e.pos<o;){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;case 20:if(null!=n.limits?.messages&&r.messages.length===n.limits.messages)throw new Tn('Decode error - map field "messages" had too many elements');r.messages.push(mn.codec().decode(e,e.uint32(),{limits:n.limits?.messages$}));break;case 51:r.paginationCursor=e.bytes();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(bn||(bn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={proof:v(0),merkleRoot:v(0),epoch:v(0),shareX:v(0),shareY:v(0),nullifier:v(0),rlnIdentifier:v(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.proof=e.bytes();break;case 2:n.merkleRoot=e.bytes();break;case 3:n.epoch=e.bytes();break;case 4:n.shareX=e.bytes();break;case 5:n.shareY=e.bytes();break;case 6:n.nullifier=e.bytes();break;case 7:n.rlnIdentifier=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(wn||(wn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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),wn.codec().encode(e.rateLimitProof,t)),null!=e.ephemeral&&(t.uint32(248),t.bool(e.ephemeral)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={payload:v(0),contentTopic:""},o=null==t?e.len:e.pos+t;for(;e.pos<o;){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=wn.codec().decode(e,e.uint32(),{limits:n.limits?.rateLimitProof});break;case 31:r.ephemeral=e.bool();break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(vn||(vn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.enr&&(t.uint32(10),t.bytes(e.enr)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();if(t>>>3===1)n.enr=e.bytes();else e.skipType(7&t)}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(En||(En={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.numPeers&&(t.uint32(8),t.uint64(e.numPeers)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){const n={},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();if(t>>>3===1)n.numPeers=e.uint64();else e.skipType(7&t)}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(Sn||(Sn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&t.fork(),null!=e.peerInfos)for(const r of e.peerInfos)t.uint32(10),En.codec().encode(r,t);!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={peerInfos:[]},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();if(t>>>3===1){if(null!=n.limits?.peerInfos&&r.peerInfos.length===n.limits.peerInfos)throw new Tn('Decode error - map field "peerInfos" had too many elements');r.peerInfos.push(En.codec().decode(e,e.uint32(),{limits:n.limits?.peerInfos$}))}else e.skipType(7&t)}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(kn||(kn={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.query&&(t.uint32(10),Sn.codec().encode(e.query,t)),null!=e.response&&(t.uint32(18),kn.codec().encode(e.response,t)),!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.query=Sn.codec().decode(e,e.uint32(),{limits:n.limits?.query});break;case 2:r.response=kn.codec().decode(e,e.uint32(),{limits:n.limits?.response});break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(An||(An={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const r of e.shards)t.uint32(16),t.uint32(r);!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={shards:[]},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.clusterId=e.uint32();break;case 2:if(null!=n.limits?.shards&&r.shards.length===n.limits.shards)throw new Tn('Decode error - map field "shards" had too many elements');r.shards.push(e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(_n||(_n={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&t.fork(),null!=e.clusterId&&(t.uint32(8),t.uint32(e.clusterId)),null!=e.shards)for(const r of e.shards)t.uint32(16),t.uint32(r);!1!==n.lengthDelimited&&t.ldelim()}),(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r={shards:[]},o=null==t?e.len:e.pos+t;for(;e.pos<o;){const t=e.uint32();switch(t>>>3){case 1:r.clusterId=e.uint32();break;case 2:if(null!=n.limits?.shards&&r.shards.length===n.limits.shards)throw new Tn('Decode error - map field "shards" had too many elements');r.shards.push(e.uint32());break;default:e.skipType(7&t)}}return r}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=(t,n)=>J(t,e.codec(),n)}(In||(In={}));function On(e){return new Promise((t=>{setTimeout(t,e)}))}const Ln=e=>e.length/1048576<=1;function Dn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Bn(e){if(!((t=e)instanceof Uint8Array||null!=t&&"object"===typeof t&&"Uint8Array"===t.constructor.name))throw new Error("Uint8Array expected");for(var t,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];if(r.length>0&&!r.includes(e.length))throw new Error(`Uint8Array expected of length ${r}, not of length=${e.length}`)}function Un(e){if("function"!==typeof e||"function"!==typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Dn(e.outputLen),Dn(e.blockLen)}function Mn(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 Fn(e,t){Bn(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const $n="object"===typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;const Hn=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),qn=(e,t)=>e<<32-t|e>>>t;new Uint8Array(new Uint32Array([287454020]).buffer)[0];const jn=async()=>{};async function Vn(e,t,n){let r=Date.now();for(let o=0;o<e;o++){n(o);const e=Date.now()-r;e>=0&&e<t||(await jn(),r+=e)}}function zn(e){return"string"===typeof e&&(e=function(e){if("string"!==typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),Bn(e),e}class Kn{clone(){return this._cloneInto()}}const Wn={}.toString;function Gn(e){const t=t=>e().update(zn(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function Yn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if($n&&"function"===typeof $n.getRandomValues)return $n.getRandomValues(new Uint8Array(e));if($n&&"function"===typeof $n.randomBytes)return $n.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const Qn=(e,t,n)=>e&t^e&n^t&n;class Jn extends Kn{constructor(e,t,n,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Hn(this.buffer)}update(e){Mn(this);const{view:t,buffer:n,blockLen:r}=this,o=(e=zn(e)).length;for(let i=0;i<o;){const s=Math.min(r-this.pos,o-i);if(s!==r)n.set(e.subarray(i,i+s),this.pos),this.pos+=s,i+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=Hn(e);for(;r<=o-i;i+=r)this.process(t,i)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){Mn(this),Fn(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:o}=this;let{pos:i}=this;t[i++]=128,this.buffer.subarray(i).fill(0),this.padOffset>r-i&&(this.process(n,0),i=0);for(let u=i;u<r;u++)t[u]=0;!function(e,t,n,r){if("function"===typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}(n,r-8,BigInt(8*this.length),o),this.process(n,0);const s=Hn(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,c=this.get();if(l>c.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<l;u++)s.setUint32(4*u,c[u],o)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:r,finished:o,destroyed:i,pos:s}=this;return e.length=r,e.pos=s,e.finished=o,e.destroyed=i,r%t&&e.buffer.set(n),e}}const Xn=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]),Zn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),er=new Uint32Array(64);class tr extends Jn{constructor(){super(64,32,8,!1),this.A=0|Zn[0],this.B=0|Zn[1],this.C=0|Zn[2],this.D=0|Zn[3],this.E=0|Zn[4],this.F=0|Zn[5],this.G=0|Zn[6],this.H=0|Zn[7]}get(){const{A:e,B:t,C:n,D:r,E:o,F:i,G:s,H:a}=this;return[e,t,n,r,o,i,s,a]}set(e,t,n,r,o,i,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|o,this.F=0|i,this.G=0|s,this.H=0|a}process(e,t){for(let d=0;d<16;d++,t+=4)er[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){const e=er[d-15],t=er[d-2],n=qn(e,7)^qn(e,18)^e>>>3,r=qn(t,17)^qn(t,19)^t>>>10;er[d]=r+er[d-7]+n+er[d-16]|0}let{A:n,B:r,C:o,D:i,E:s,F:a,G:l,H:c}=this;for(let d=0;d<64;d++){const e=c+(qn(s,6)^qn(s,11)^qn(s,25))+((u=s)&a^~u&l)+Xn[d]+er[d]|0,t=(qn(n,2)^qn(n,13)^qn(n,22))+Qn(n,r,o)|0;c=l,l=a,a=s,s=i+e|0,i=o,o=r,r=n,n=e+t|0}var u;n=n+this.A|0,r=r+this.B|0,o=o+this.C|0,i=i+this.D|0,s=s+this.E|0,a=a+this.F|0,l=l+this.G|0,c=c+this.H|0,this.set(n,r,o,i,s,a,l,c)}roundClean(){er.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const nr=Gn((()=>new tr));var rr,or,ir,sr,ar;!function(e){e.Relay="relay",e.Store="store",e.LightPush="lightpush",e.Filter="filter"}(rr||(rr={})),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.TOPIC_DECODER_MISMATCH="Topic decoder mismatch",e.INVALID_DECODER_TOPICS="Invalid decoder topics",e.NO_PEER_AVAILABLE="No peer available",e.NO_STREAM_AVAILABLE="No stream available",e.NO_RESPONSE="No response received",e.REMOTE_PEER_REJECTED="Remote peer rejected",e.REQUEST_TIMEOUT="Request timeout",e.RLN_IDENTITY_MISSING="Identity credentials are not set",e.RLN_MEMBERSHIP_INDEX="Membership index is not set",e.RLN_LIMIT_MISSING="User message limit is not set",e.RLN_PROOF_GENERATION="Proof generation failed"}(or||(or={})),function(e){e.BOOTSTRAP="bootstrap",e.PEER_EXCHANGE="peer-exchange",e.LOCAL="local-peer-cache"}(ir||(ir={})),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"}(sr||(sr={})),function(e){e.CONNECTION_STATUS="waku:connection"}(ar||(ar={}));const lr="@waku/bootstrap",cr={clusterId:1,shards:[0,1,2,3,4,5,6,7,8]};var ur;function dr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const n=Lt[t];if(null==n)throw new Error(`Unsupported encoding "${t}"`);return n.encoder.encode(e).substring(1)}function hr(e){if("string"===typeof e){return Dt(e.replace(/^0x/i,"").toLowerCase(),"base16")}return e}!function(e){e.Unhealthy="Unhealthy",e.MinimallyHealthy="MinimallyHealthy",e.SufficientlyHealthy="SufficientlyHealthy"}(ur||(ur={}));const fr=e=>dr(e,"base16"),pr=e=>dr(e,"utf8"),gr=e=>Dt(e,"utf8");function mr(e,t){const n=t??e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(n);let o=0;for(const i of e)r.set(i,o),o+=i.length;return r}const yr=e=>{if("contentTopics"in e&&e.contentTopics)return Array.from(new Set(e.contentTopics.map((t=>Sr(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??1}/${t}`))))}if("application"in e&&"version"in e)return[Sr(`/${e.application}/${e.version}/default/default`,e.clusterId)];throw new Error("Missing required configuration in shard parameters")},br=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 n=parseInt(t[4]),r=parseInt(t[5]);if(isNaN(n)||isNaN(r))throw new Error("Invalid clusterId or shard");return{clusterId:n,shard:r}},wr=e=>{const t=new Set,n=new Set;for(const r of e){const{clusterId:e,shard:o}=br(r);t.add(`${e}:${o}`),n.add(e)}if(0===t.size)throw new Error("No valid pubsub topics provided");if(n.size>1)throw new Error("Pubsub topics from multiple cluster IDs are not supported");return{clusterId:n.values().next().value,shards:Array.from(t).map((e=>parseInt(e.split(":")[1])))}};function vr(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 Er(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const{application:n,version:r}=function(e){const t=e.split("/");if(t.length<5||t.length>6)throw Error("Content topic format is invalid");let n=0;if(6==t.length){if(n=parseInt(t[1]),isNaN(n))throw new Error("Invalid generation field in content topic");if(n>0)throw new Error("Generation greater than 0 is not supported")}const r=t.splice(-4);if(0==r[0].length)throw new Error("Application field cannot be empty");if(0==r[1].length)throw new Error("Version field cannot be empty");if(0==r[2].length)throw new Error("Topic name field cannot be empty");if(0==r[3].length)throw new Error("Encoding field cannot be empty");return{generation:n,application:r[0],version:r[1],topicName:r[2],encoding:r[3]}}(e),o=nr(mr([gr(n),gr(r)])),i=new DataView(o.buffer.slice(-8));return Number(i.getBigUint64(0,!1)%BigInt(t))}function Sr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:8;if(!e)throw Error("Content topic must be specified");return`/waku/2/rs/${t}/${Er(e,n)}`}function kr(e,t){return"string"==typeof t?t:void 0!==t?.shard?(e=>{if(void 0===e.shard)throw new Error("Invalid shard");return`/waku/2/rs/${e.clusterId??1}/${e.shard}`})(t):Sr(e,t?.clusterId??1)}const Ar=e=>{if((e=new Uint8Array(e)).length<3)throw new Error("Insufficient data");const t=new DataView(e.buffer),n=t.getUint16(0),r=[];if(130===e.length)for(let o=0;o<1024;o++){const e=Math.floor(o/8)+2,n=7-o%8;t.getUint8(e)&1<<n&&r.push(o)}else{const n=t.getUint8(2);for(let o=0,i=3;o<n;o++,i+=2){if(i+1>=e.length)throw new Error("Unexpected end of data");r.push(t.getUint16(i))}}return{clusterId:n,shards:r}},_r=e=>{const{clusterId:t,shards:n}=e,r=n.length>=64?130:3+2*n.length,o=new ArrayBuffer(r),i=new DataView(o);if(i.setUint16(0,t),n.length>=64)for(const s of n){const e=Math.floor(s/8)+2,t=7-s%8;i.setUint8(e,i.getUint8(e)|1<<t)}else{i.setUint8(2,n.length);for(let e=0,t=3;e<n.length;e++,t+=2)i.setUint16(t,n[e])}return new Uint8Array(o)};var Ir=__webpack_require__(6522);const xr="waku";class Cr{_debug;_info;_warn;_error;static createDebugNamespace(e,t){return t?`${xr}:${e}:${t}`:`${xr}:${e}`}constructor(e){this._debug=Ir(Cr.createDebugNamespace("debug",e)),this._info=Ir(Cr.createDebugNamespace("info",e)),this._warn=Ir(Cr.createDebugNamespace("warn",e)),this._error=Ir(Cr.createDebugNamespace("error",e))}get debug(){return this._debug}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(e){const t=this[e];for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];t(...r)}}const Rr=new Cr("message:version-0"),Tr=BigInt(1e6);class Nr{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/Tr;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 Pr{contentTopic;ephemeral;pubsubTopic;metaSetter;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2?arguments[2]:void 0,r=arguments.length>3?arguments[3]:void 0;if(this.contentTopic=e,this.ephemeral=t,this.pubsubTopic=n,this.metaSetter=r,!e||""===e)throw new Error("Content topic must be specified")}async toWire(e){return Xt.encode(await this.toProtoObj(e))}async toProtoObj(e){const t=e.timestamp??new Date,n={payload:e.payload,version:0,contentTopic:this.contentTopic,timestamp:BigInt(t.valueOf())*Tr,meta:void 0,rateLimitProof:e.rateLimitProof,ephemeral:this.ephemeral};if(this.metaSetter){const e=this.metaSetter(n);return{...n,meta:e}}return n}}function Or(e){let{pubsubTopic:t,pubsubTopicShardInfo:n,contentTopic:r,ephemeral:o,metaSetter:i}=e;return new Pr(r,o,kr(r,t??n),i)}class Lr{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=Xt.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?(Rr.error("Failed to decode due to incorrect version, expected:",0,", actual:",t.version),Promise.resolve(void 0)):new Nr(e,t)}}const Dr=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{const t=[];for await(const n of e)t.push(n);return t})();const t=[];for(const n of e)t.push(n);return t};function Br(e,t){null==t&&(t=e.reduce(((e,t)=>e+t.length),0));const n=E(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function Ur(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0}const Mr=Symbol.for("@achingbrain/uint8arraylist");function Fr(e,t){if(null==t||t<0)throw new RangeError("index is out of bounds");let n=0;for(const r of e){const e=n+r.byteLength;if(t<e)return{buf:r,index:t-n};n=e}throw new RangeError("index is out of bounds")}function $r(e){return Boolean(e?.[Mr])}class Hr{bufs;length;[Mr]=!0;constructor(){this.bufs=[],this.length=0;for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];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),n=0;n<e;n++)t[n]=arguments[n];this.appendAll(t)}appendAll(e){let t=0;for(const n of e)if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.push(n);else{if(!$r(n))throw new Error("Could not append value, must be an Uint8Array or a Uint8ArrayList");t+=n.byteLength,this.bufs.push(...n.bufs)}this.length+=t}prepend(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this.prependAll(t)}prependAll(e){let t=0;for(const n of e.reverse())if(n instanceof Uint8Array)t+=n.byteLength,this.bufs.unshift(n);else{if(!$r(n))throw new Error("Could not prepend value, must be an Uint8Array or a Uint8ArrayList");t+=n.byteLength,this.bufs.unshift(...n.bufs)}this.length+=t}get(e){const t=Fr(this.bufs,e);return t.buf[t.index]}set(e,t){const n=Fr(this.bufs,e);n.buf[n.index]=t}write(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e instanceof Uint8Array)for(let n=0;n<e.length;n++)this.set(t+n,e[n]);else{if(!$r(e))throw new Error("Could not write value, must be an Uint8Array or a Uint8ArrayList");for(let n=0;n<e.length;n++)this.set(t+n,e.get(n))}}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:n,length:r}=this._subList(e,t);return Br(n,r)}subarray(e,t){const{bufs:n,length:r}=this._subList(e,t);return 1===n.length?n[0]:Br(n,r)}sublist(e,t){const{bufs:n,length:r}=this._subList(e,t),o=new Hr;return o.length=r,o.bufs=[...n],o}_subList(e,t){if(e=e??0,t=t??this.length,e<0&&(e=this.length+e),t<0&&(t=this.length+t),e<0||t>this.length)throw new RangeError("index is out of bounds");if(e===t)return{bufs:[],length:0};if(0===e&&t===this.length)return{bufs:this.bufs,length:this.length};const n=[];let r=0;for(let o=0;o<this.bufs.length;o++){const i=this.bufs[o],s=r,a=s+i.byteLength;if(r=a,e>=a)continue;const l=e>=s&&e<a,c=t>s&&t<=a;if(l&&c){if(e===s&&t===a){n.push(i);break}const r=e-s;n.push(i.subarray(r,r+(t-e)));break}if(l){if(0===e){n.push(i);continue}n.push(i.subarray(e-s))}else{if(c){if(t===a){n.push(i);break}n.push(i.subarray(0,t-s));break}n.push(i)}}return{bufs:n,length:t-e}}indexOf(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(!$r(e)&&!(e instanceof Uint8Array))throw new TypeError('The "value" argument must be a Uint8ArrayList or Uint8Array');const n=e instanceof Uint8Array?e:e.subarray();if(t=Number(t??0),isNaN(t)&&(t=0),t<0&&(t=this.length+t),t<0&&(t=0),0===e.length)return t>this.length?this.length:t;const r=n.byteLength;if(0===r)throw new TypeError("search must be at least 1 byte long");const o=new Int32Array(256);for(let c=0;c<256;c++)o[c]=-1;for(let c=0;c<r;c++)o[n[c]]=c;const i=o,s=this.byteLength-n.byteLength,a=n.byteLength-1;let l;for(let c=t;c<=s;c+=l){l=0;for(let e=a;e>=0;e--){const t=this.get(c+e);if(n[e]!==t){l=Math.max(1,e-i[t]);break}}if(0===l)return c}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 n=E(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setInt8(0,t),this.write(n,e)}getInt16(e,t){const n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt16(0,t)}setInt16(e,t,n){const r=v(2);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt16(0,t,n),this.write(r,e)}getInt32(e,t){const n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getInt32(0,t)}setInt32(e,t,n){const r=v(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setInt32(0,t,n),this.write(r,e)}getBigInt64(e,t){const n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigInt64(0,t)}setBigInt64(e,t,n){const r=v(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setBigInt64(0,t,n),this.write(r,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 n=E(1);new DataView(n.buffer,n.byteOffset,n.byteLength).setUint8(0,t),this.write(n,e)}getUint16(e,t){const n=this.subarray(e,e+2);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint16(0,t)}setUint16(e,t,n){const r=v(2);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint16(0,t,n),this.write(r,e)}getUint32(e,t){const n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,t)}setUint32(e,t,n){const r=v(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setUint32(0,t,n),this.write(r,e)}getBigUint64(e,t){const n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getBigUint64(0,t)}setBigUint64(e,t,n){const r=v(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setBigUint64(0,t,n),this.write(r,e)}getFloat32(e,t){const n=this.subarray(e,e+4);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat32(0,t)}setFloat32(e,t,n){const r=v(4);new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat32(0,t,n),this.write(r,e)}getFloat64(e,t){const n=this.subarray(e,e+8);return new DataView(n.buffer,n.byteOffset,n.byteLength).getFloat64(0,t)}setFloat64(e,t,n){const r=v(8);new DataView(r.buffer,r.byteOffset,r.byteLength).setFloat64(0,t,n),this.write(r,e)}equals(e){if(null==e)return!1;if(!(e instanceof Hr))return!1;if(e.bufs.length!==this.bufs.length)return!1;for(let t=0;t<this.bufs.length;t++)if(!Ur(this.bufs[t],e.bufs[t]))return!1;return!0}static fromUint8Arrays(e,t){const n=new Hr;return n.bufs=e,null==t&&(t=e.reduce(((e,t)=>e+t.byteLength),0)),n.length=t,n}}function qr(e){return null!=e[Symbol.asyncIterator]}const jr=e=>{const t=N(e),n=E(t);return L(e,n),jr.bytes=t,n};function Vr(e,t){const n=(t=t??{}).lengthEncoder??jr;function*r(e){const t=n(e.byteLength);t instanceof Uint8Array?yield t:yield*t,e instanceof Uint8Array?yield e:yield*e}return qr(e)?async function*(){for await(const t of e)yield*r(t)}():function*(){for(const t of e)yield*r(t)}()}jr.bytes=0,Vr.single=(e,t)=>{const n=(t=t??{}).lengthEncoder??jr;return new Hr(n(e.byteLength),e)};class zr extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"}class Kr extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"}class Wr extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"}class Gr extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"}var Yr;!function(e){e[e.LENGTH=0]="LENGTH",e[e.DATA=1]="DATA"}(Yr||(Yr={}));const Qr=e=>{const t=D(e);return Qr.bytes=N(t),t};function Jr(e,t){const n=new Hr;let r=Yr.LENGTH,o=-1;const i=t?.lengthDecoder??Qr,s=t?.maxLengthLength??8,a=t?.maxDataLength??4194304;function*l(){for(;n.byteLength>0;){if(r===Yr.LENGTH)try{if(o=i(n),o<0)throw new zr("Invalid message length");if(o>a)throw new Kr("Message length too long");const e=i.bytes;n.consume(e),null!=t?.onLength&&t.onLength(o),r=Yr.DATA}catch(e){if(e instanceof RangeError){if(n.byteLength>s)throw new Wr("Message length length too long");break}throw e}if(r===Yr.DATA){if(n.byteLength<o)break;const e=n.sublist(0,o);n.consume(o),null!=t?.onData&&t.onData(e),yield e,r=Yr.LENGTH}}}return qr(e)?async function*(){for await(const t of e)n.append(t),yield*l();if(n.byteLength>0)throw new Gr("Unexpected end of input")}():function*(){for(const t of e)n.append(t),yield*l();if(n.byteLength>0)throw new Gr("Unexpected end of input")}()}function Xr(){const e={};return e.promise=new Promise(((t,n)=>{e.resolve=t,e.reject=n})),e}Qr.bytes=0,Jr.fromReader=(e,t)=>{let n=1;return Jr(async function*(){for(;;)try{const{done:t,value:r}=await e.next(n);if(!0===t)return;null!=r&&(yield r)}catch(t){if("ERR_UNDER_READ"===t.code)return{done:!0,value:null};throw t}finally{n=1}}(),{...t??{},onLength:e=>{n=e}})};class Zr{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 eo{size;hwm;head;tail;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.hwm=e.splitLimit??16,this.head=new Zr(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 Zr(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 to extends Error{type;code;constructor(e,t){super(e??"The operation was aborted"),this.type="aborted",this.code=t??"ABORT_ERR"}}function no(){return ro((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 ro(e,t){let n,r,o,i=(t=t??{}).onEnd,s=new eo,a=Xr();const l=e=>null!=r?r(e):(s.push(e),n),c=e=>{if(o)return n;if(!0!==t?.objectMode&&null==e?.byteLength)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return l({done:!1,value:e})},u=e=>o?n:(o=!0,null!=e?(e=>(s=new eo,null!=r?r({error:e}):(s.push({error:e}),n)))(e):l({done:!0}));if(n={[Symbol.asyncIterator](){return this},next:async()=>{try{return s.isEmpty()?o?{done:!0}:await new Promise(((t,o)=>{r=i=>{r=null,s.push(i);try{t(e(s))}catch(a){o(a)}return n}})):e(s)}finally{s.isEmpty()&&queueMicrotask((()=>{a.resolve(),a=Xr()}))}},return:()=>(s=new eo,u(),{done:!0}),throw:e=>(u(e),{done:!0}),push:c,end:u,get readableLength(){return s.size},onEmpty:async e=>{const t=e?.signal;if(t?.throwIfAborted(),s.isEmpty())return;let n,r;null!=t&&(n=new Promise(((e,n)=>{r=()=>{n(new to)},t.addEventListener("abort",r)})));try{await Promise.race([a.promise,n])}finally{null!=r&&null!=t&&t?.removeEventListener("abort",r)}}},null==i)return n;const d=n;return n={[Symbol.asyncIterator](){return this},next:()=>d.next(),throw:e=>(d.throw(e),null!=i&&(i(e),i=void 0),{done:!0}),return:()=>(d.return(),null!=i&&(i(),i=void 0),{done:!0}),push:c,end:e=>(d.end(e),null!=i&&(i(e),i=void 0),n),get readableLength(){return d.readableLength},onEmpty:e=>d.onEmpty(e)},n}const oo=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const r=[];for(const o of t)null==o[Symbol.asyncIterator]&&r.push(o);return r.length===t.length?function*(){for(const e of r)yield*e}():async function*(){const e=no({objectMode:!0});Promise.resolve().then((async()=>{try{await Promise.all(t.map((async t=>{for await(const n of t)e.push(n)}))),e.end()}catch(n){e.end(n)}})),yield*e}()};function io(e){if(null==e)throw new Error("Empty pipeline");if(co(e)){const t=e;e=()=>t.source}else if(lo(e)||ao(e)){const t=e;e=()=>t}for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];const o=[e,...n];if(o.length>1&&co(o[o.length-1])&&(o[o.length-1]=o[o.length-1].sink),o.length>2)for(let i=1;i<o.length-1;i++)co(o[i])&&(o[i]=uo(o[i]));return so(...o)}const so=function(){let e;for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];for(;n.length>0;)e=n.shift()(e);return e},ao=e=>null!=e?.[Symbol.asyncIterator],lo=e=>null!=e?.[Symbol.iterator],co=e=>null!=e&&(null!=e.sink&&null!=e.source),uo=e=>t=>{const n=e.sink(t);if(null!=n?.then){const t=no({objectMode:!0});let r;n.then((()=>{t.end()}),(e=>{t.end(e)}));const o=e.source;if(ao(o))r=async function*(){yield*o,t.end()};else{if(!lo(o))throw new Error("Unknown duplex source type - must be Iterable or AsyncIterable");r=function*(){yield*o,t.end()}}return oo(t,r())}return e.source};class ho{multicodec;getConnections;addEventListener;streamPool;log;constructor(e,t,n){this.multicodec=e,this.getConnections=t,this.addEventListener=n,this.log=new Cr(`stream-manager:${e}`),this.streamPool=new Map,this.addEventListener("peer:update",this.handlePeerUpdateStreamPool)}async getStream(e){const t=e.id.toString(),n=this.streamPool.get(t);if(!n)return this.createStream(e);this.streamPool.delete(t),this.prepareStream(e);try{const e=await n;if(e&&"closed"!==e.status)return e}catch(r){this.log.warn(`Failed to get stream for ${t} -- `,r),this.log.warn("Attempting to create a new stream for the peer")}return this.createStream(e)}async createStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=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(!n)throw new Error("Failed to get a connection to the peer");try{return await n.newStream(this.multicodec)}catch(r){if(t<3){const n=1e3*Math.pow(2,t);return await new Promise((e=>setTimeout(e,n))),this.createStream(e,t+1)}throw new Error(`Failed to create a new stream for ${e.id.toString()} -- `+r)}}prepareStream(e){const t=new Promise((e=>setTimeout(e,5e3))),n=Promise.race([this.createStream(e),t.then((()=>{throw new Error("Connection timeout")}))]).catch((t=>{this.log.error(`Failed to prepare a new stream for ${e.id.toString()} -- `,t)}));this.streamPool.set(e.id.toString(),n)}handlePeerUpdateStreamPool=e=>{const{peer:t}=e.detail;if(t.protocols.includes(this.multicodec)){if(this.isConnectedTo(t.id))this.log.info(`Preemptively opening a stream to ${t.id.toString()}`),this.prepareStream(t);else{const e=t.id.toString();this.streamPool.delete(e),this.log.info(`Removed pending stream for disconnected peer ${e}`)}}};isConnectedTo(e){return this.getConnections(e).some((e=>"open"===e.status))}}class fo{multicodec;components;log;pubsubTopics;addLibp2pEventListener;removeLibp2pEventListener;streamManager;constructor(e,t,n,r){this.multicodec=e,this.components=t,this.log=n,this.pubsubTopics=r,this.addLibp2pEventListener=t.events.addEventListener.bind(t.events),this.removeLibp2pEventListener=t.events.removeEventListener.bind(t.events),this.streamManager=new ho(e,t.connectionManager.getConnections.bind(t.connectionManager),this.addLibp2pEventListener)}async getStream(e){return this.streamManager.getStream(e)}async allPeers(){return async function(e,t){const n=[];return await e.forEach((e=>{for(let r=0;r<t.length;r++)if(e.protocols.includes(t[r])){n.push(e);break}})),n}(this.components.peerStore,[this.multicodec])}async connectedPeers(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(await this.allPeers()).filter((t=>{const n=this.components.connectionManager.getConnections(t.id);return e?n.some((e=>e.streams.some((e=>e.protocol===this.multicodec)))):n.length>0}))}async getPeers(){let{numPeers:e,maxBootstrapPeers:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{maxBootstrapPeers:0,numPeers:0};const n=function(e,t,n){let r=e.filter((e=>e.tags.has(ir.BOOTSTRAP))).slice(0,n);t>0&&t<r.length&&(r=r.slice(0,t));const o=e.filter((e=>!e.tags.has(ir.BOOTSTRAP)));if(0===t)return[...r,...o];const i=[...r];for(;i.length<t&&o.length>0;){const e=Math.floor(Math.random()*o.length),t=o.splice(e,1)[0];i.push(t)}return i}(await this.connectedPeers(),e,t),r=await async function(e,t){return 0===t.length?[]:(await Promise.all(t.map((async t=>{try{const n=(await e.get(t.id)).metadata.get("ping");return n?{peer:t,ping:Number(pr(n))}:{peer:t,ping:1/0}}catch(n){return{peer:t,ping:1/0}}})))).filter((e=>null!==e)).sort(((e,t)=>e.ping-t.ping)).map((e=>e.peer))}(this.components.peerStore,n);return 0===r.length&&this.log.warn("No peers found. Ensure you have a connection to the network."),r.length<e&&this.log.warn(`Only ${r.length} peers found. Requested ${e}.`),r}}const po={randomUUID:"undefined"!==typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let go;const mo=new Uint8Array(16);function yo(){if(!go&&(go="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!go))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return go(mo)}const bo=[];for(let kk=0;kk<256;++kk)bo.push((kk+256).toString(16).slice(1));function wo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return bo[e[t+0]]+bo[e[t+1]]+bo[e[t+2]]+bo[e[t+3]]+"-"+bo[e[t+4]]+bo[e[t+5]]+"-"+bo[e[t+6]]+bo[e[t+7]]+"-"+bo[e[t+8]]+bo[e[t+9]]+"-"+bo[e[t+10]]+bo[e[t+11]]+bo[e[t+12]]+bo[e[t+13]]+bo[e[t+14]]+bo[e[t+15]]}const vo=function(e,t,n){if(po.randomUUID&&!t&&!e)return po.randomUUID();const r=(e=e||{}).random||(e.rng||yo)();if(r[6]=15&r[6]|64,r[8]=63&r[8]|128,t){n=n||0;for(let e=0;e<16;++e)t[n+e]=r[e];return t}return wo(r)};class Eo{proto;constructor(e){this.proto=e}static decode(e){const t=ln.decode(e);return new Eo(t)}encode(){return ln.encode(this.proto)}get wakuMessage(){return this.proto.wakuMessage}get pubsubTopic(){return this.proto.pubsubTopic}}class So{proto;constructor(e){this.proto=e}static createSubscribeRequest(e,t){return new So({requestId:vo(),filterSubscribeType:sn.FilterSubscribeType.SUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeRequest(e,t){return new So({requestId:vo(),filterSubscribeType:sn.FilterSubscribeType.UNSUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeAllRequest(e){return new So({requestId:vo(),filterSubscribeType:sn.FilterSubscribeType.UNSUBSCRIBE_ALL,pubsubTopic:e,contentTopics:[]})}static createSubscriberPingRequest(){return new So({requestId:vo(),filterSubscribeType:sn.FilterSubscribeType.SUBSCRIBER_PING,pubsubTopic:"",contentTopics:[]})}static decode(e){const t=sn.decode(e);return new So(t)}encode(){return sn.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 ko{proto;constructor(e){this.proto=e}static decode(e){const t=an.decode(e);return new ko(t)}encode(){return an.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get requestId(){return this.proto.requestId}}const Ao=new Cr("filter:v2"),_o="/vac/waku/filter-subscribe/2.0.0-beta1",Io="/vac/waku/filter-push/2.0.0-beta1";class xo extends fo{handleIncomingMessage;handleError;pubsubTopics;constructor(e,t,n,r){super(_o,r.components,Ao,n),this.handleIncomingMessage=e,this.handleError=t,this.pubsubTopics=n,r.handle(Io,this.onRequest.bind(this),{maxInboundStreams:100}).catch((e=>{Ao.error("Failed to register ",Io,e)}))}async subscribe(e,t,n){const r=await this.getStream(t),o=So.createSubscribeRequest(e,n);let i;try{i=await io([o.encode()],Vr,r,Jr,(async e=>await Dr(e)))}catch(c){return Ao.error("Failed to send subscribe request",c),{success:null,failure:{error:or.GENERIC_FAIL,peerId:t.id}}}const{statusCode:s,requestId:a,statusDesc:l}=ko.decode(i[0].slice());return s<200||s>=300?(Ao.error(`Filter subscribe request ${a} failed with status code ${s}: ${l}`),{failure:{error:or.REMOTE_PEER_REJECTED,peerId:t.id},success:null}):{failure:null,success:t.id}}async unsubscribe(e,t,n){let r;try{r=await this.getStream(t)}catch(i){return Ao.error(`Failed to get a stream for remote peer${t.id.toString()}`,i),{success:null,failure:{error:or.NO_STREAM_AVAILABLE,peerId:t.id}}}const o=So.createUnsubscribeRequest(e,n);try{await io([o.encode()],Vr,r.sink)}catch(i){return Ao.error("Failed to send unsubscribe request",i),{success:null,failure:{error:or.GENERIC_FAIL,peerId:t.id}}}return{success:t.id,failure:null}}async unsubscribeAll(e,t){const n=await this.getStream(t),r=So.createUnsubscribeAllRequest(e),o=await io([r.encode()],Vr,n,Jr,(async e=>await Dr(e)));if(!o||!o.length)return{failure:{error:or.NO_RESPONSE,peerId:t.id},success:null};const{statusCode:i,requestId:s,statusDesc:a}=ko.decode(o[0].slice());return i<200||i>=300?(Ao.error(`Filter unsubscribe all request ${s} failed with status code ${i}: ${a}`),{failure:{error:or.REMOTE_PEER_REJECTED,peerId:t.id},success:null}):{failure:null,success:t.id}}async ping(e){let t;try{t=await this.getStream(e)}catch(a){return Ao.error(`Failed to get a stream for remote peer${e.id.toString()}`,a),{success:null,failure:{error:or.NO_STREAM_AVAILABLE,peerId:e.id}}}const n=So.createSubscriberPingRequest();let r;try{r=await io([n.encode()],Vr,t,Jr,(async e=>await Dr(e)))}catch(a){return Ao.error("Failed to send ping request",a),{success:null,failure:{error:or.GENERIC_FAIL,peerId:e.id}}}if(!r||!r.length)return{success:null,failure:{error:or.NO_RESPONSE,peerId:e.id}};const{statusCode:o,requestId:i,statusDesc:s}=ko.decode(r[0].slice());return o<200||o>=300?(Ao.error(`Filter ping request ${i} failed with status code ${o}: ${s}`),{success:null,failure:{error:or.REMOTE_PEER_REJECTED,peerId:e.id}}):{success:e.id,failure:null}}onRequest(e){const{connection:t,stream:n}=e,{remotePeer:r}=t;Ao.info(`Received message from ${r.toString()}`);try{io(n,Jr,(async e=>{for await(const n of e){const e=Eo.decode(n.slice()),{pubsubTopic:r,wakuMessage:o}=e;if(!o)return void Ao.error("Received empty message");if(!r)return void Ao.error("Pubsub topic missing from push message");await this.handleIncomingMessage(r,o,t.remotePeer.toString())}})).then((()=>{Ao.info("Receiving pipe closed.")}),(async e=>{Ao.error("Error with receiving pipe",e," -- ","on peer ",t.remotePeer.toString()," -- ","stream ",n),await this.handleError(e)}))}catch(o){Ao.error("Error decoding message",o)}}}class Co{proto;constructor(e){this.proto=e}static createRequest(e,t){return new Co({requestId:vo(),request:{message:e,pubsubTopic:t},response:void 0})}static decode(e){const t=fn.decode(e);return new Co(t)}encode(){return fn.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const Ro=new Cr("light-push");class To extends fo{pubsubTopics;constructor(e,t){super("/vac/waku/lightpush/2.0.0-beta1",t.components,Ro,e),this.pubsubTopics=e}async preparePushMessage(e,t){try{if(!t.payload||0===t.payload.length)return Ro.error("Failed to send waku light push: payload is empty"),{query:null,error:or.EMPTY_PAYLOAD};if(!await async function(e,t){const n=await e.toWire(t);return!!n&&Ln(n)}(e,t))return Ro.error("Failed to send waku light push: message is bigger than 1MB"),{query:null,error:or.SIZE_TOO_BIG};const n=await e.toProtoObj(t);if(!n)return Ro.error("Failed to encode to protoMessage, aborting push"),{query:null,error:or.ENCODE_FAILED};return{query:Co.createRequest(n,e.pubsubTopic),error:null}}catch(n){return Ro.error("Failed to prepare push message",n),{query:null,error:or.GENERIC_FAIL}}}async send(e,t,n){const{query:r,error:o}=await this.preparePushMessage(e,t);if(o||!r)return{success:null,failure:{error:o,peerId:n.id}};let i,s;try{i=await this.getStream(n)}catch(u){return Ro.error("Failed to get stream",u),{success:null,failure:{error:or.NO_STREAM_AVAILABLE,peerId:n.id}}}try{s=await io([r.encode()],Vr,i,Jr,(async e=>await Dr(e)))}catch(d){return Ro.error("Failed to send waku light push request",d),{success:null,failure:{error:or.GENERIC_FAIL,peerId:n.id}}}const a=new Hr;let l;s.forEach((e=>{a.append(e)}));try{l=Co.decode(a).response}catch(d){return Ro.error("Failed to decode push reply",d),{success:null,failure:{error:or.DECODE_FAILED,peerId:n.id}}}if(!l)return Ro.error("Remote peer fault: No response in PushRPC"),{success:null,failure:{error:or.NO_RESPONSE,peerId:n.id}};if((c=l.info)&&c.includes("could not generate rln-v2 proof")){const e=(e=>{const t={[or.RLN_IDENTITY_MISSING]:or.RLN_IDENTITY_MISSING,[or.RLN_MEMBERSHIP_INDEX]:or.RLN_MEMBERSHIP_INDEX,[or.RLN_LIMIT_MISSING]:or.RLN_LIMIT_MISSING},n=e.toLowerCase();for(const r in t)if(n.includes(r.toLowerCase()))return t[r];return or.RLN_PROOF_GENERATION})(l.info);return Ro.error("Remote peer rejected the message: ",e),{success:null,failure:{error:e,peerId:n.id}}}var c;return l.isSuccess?{success:n.id,failure:null}:(Ro.error("Remote peer rejected the message: ",l.info),{success:null,failure:{error:or.REMOTE_PEER_REJECTED,peerId:n.id}})}}const No={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};const Po=1e6;class Oo{proto;constructor(e){this.proto=e}static create(e){const t=new Oo({...e,requestId:vo(),timeStart:e.timeStart?BigInt(e.timeStart.getTime()*Po):void 0,timeEnd:e.timeEnd?BigInt(e.timeEnd.getTime()*Po):void 0,messageHashes:e.messageHashes||[],paginationLimit:e.paginationLimit?BigInt(e.paginationLimit):void 0});if(e.pubsubTopic&&!e.contentTopics||!e.pubsubTopic&&e.contentTopics)throw new Error("Both pubsubTopic and contentTopics must be set or unset");if(e.messageHashes&&(e.pubsubTopic||e.contentTopics||e.timeStart||e.timeEnd))throw new Error("Message hash lookup queries cannot include content filter criteria");return t}static decode(e){const t=yn.decode(e);return new Oo(t)}encode(){return yn.encode(this.proto)}}class Lo{proto;constructor(e){this.proto=e}static decode(e){const t=bn.decode(e);return new Lo(t)}encode(){return bn.encode(this.proto)}get statusCode(){return this.proto.statusCode}get statusDesc(){return this.proto.statusDesc}get messages(){return this.proto.messages}get paginationCursor(){return this.proto.paginationCursor}}const Do=new Cr("store");class Bo extends fo{pubsubTopics;constructor(e,t){super("/vac/waku/store-query/3.0.0",t.components,Do,e),this.pubsubTopics=e}async*queryPerPage(e,t,n){if(e.contentTopics.toString()!==Array.from(t.keys()).toString())throw new Error("Internal error, the decoders should match the query's content topics");let r=e.paginationCursor;for(;;){const i=Oo.create({...e,paginationCursor:r});let s;try{s=await this.getStream(n)}catch(o){Do.error("Failed to get stream",o);break}const a=await io([i.encode()],Vr,s,Jr,(async e=>await Dr(e))),l=new Hr;a.forEach((e=>{l.append(e)}));const c=Lo.decode(l);if(!c.statusCode||c.statusCode>=300){const e=`Store query failed with status code: ${c.statusCode}, description: ${c.statusDesc}`;throw Do.error(e),new Error(e)}if(!c.messages||!c.messages.length){Do.warn("Stopping pagination due to empty messages in response");break}Do.info(`${c.messages.length} messages retrieved from store`);const u=c.messages.map((e=>{if(!e.message)return Promise.resolve(void 0);const n=e.message.contentTopic;if(n){const o=t.get(n);if(o)return o.fromProtoObj(e.pubsubTopic||"",(r=e.message,{...No,...r}))}var r;return Promise.resolve(void 0)}));if(yield u,r=e.paginationForward?c.messages[c.messages.length-1].messageHash:c.messages[0].messageHash,c.messages.length>100&&c.messages.length<(e.paginationLimit||20))break}}}class Uo extends Error{constructor(e){super(e),this.name="TimeoutError"}}class Mo extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const Fo=e=>void 0===globalThis.DOMException?new Mo(e):new DOMException(e),$o=e=>{const t=void 0===e.reason?Fo("This operation was aborted."):e.reason;return t instanceof Error?t:Fo(t)};function Ho(e,t){const{milliseconds:n,fallback:r,message:o,customTimers:i={setTimeout:setTimeout,clearTimeout:clearTimeout}}=t;let s;const a=new Promise(((a,l)=>{if("number"!==typeof n||1!==Math.sign(n))throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(t.signal){const{signal:e}=t;e.aborted&&l($o(e)),e.addEventListener("abort",(()=>{l($o(e))}))}if(n===Number.POSITIVE_INFINITY)return void e.then(a,l);const c=new Uo;s=i.setTimeout.call(void 0,(()=>{if(r)try{a(r())}catch(t){l(t)}else"function"===typeof e.cancel&&e.cancel(),!1===o?a():o instanceof Error?l(o):(c.message=o??`Promise timed out after ${n} milliseconds`,l(c))}),n),(async()=>{try{a(await e)}catch(t){l(t)}})()})).finally((()=>{a.clear()}));return a.clear=()=>{i.clearTimeout.call(void 0,s),s=void 0},a}const qo=e=>{const t=e.addEventListener||e.on||e.addListener,n=e.removeEventListener||e.off||e.removeListener;if(!t||!n)throw new TypeError("Emitter is not compatible");return{addListener:t.bind(e),removeListener:n.bind(e)}};function jo(e,t,n){"function"===typeof n&&(n={filter:n});const r=function(e,t,n){let r;const o=new Promise(((o,i)=>{if(!((n={rejectionEvents:["error"],multiArgs:!1,resolveImmediately:!1,...n}).count>=0)||n.count!==Number.POSITIVE_INFINITY&&!Number.isInteger(n.count))throw new TypeError("The `count` option should be at least 0 or more");n.signal?.throwIfAborted();const s=[t].flat(),a=[],{addListener:l,removeListener:c}=qo(e),u=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];const s=n.multiArgs?t:t[0];n.filter&&!n.filter(s)||(a.push(s),n.count===a.length&&(r(),o(a)))},d=e=>{r(),i(e)};r=()=>{for(const e of s)c(e,u);for(const e of n.rejectionEvents)c(e,d)};for(const e of s)l(e,u);for(const e of n.rejectionEvents)l(e,d);n.signal&&n.signal.addEventListener("abort",(()=>{d(n.signal.reason)}),{once:!0}),n.resolveImmediately&&o(a)}));if(o.cancel=r,"number"===typeof n.timeout){const e=Ho(o,{milliseconds:n.timeout});return e.cancel=r,e}return o}(e,t,n={...n,count:1,resolveImmediately:!1}),o=r.then((e=>e[0]));return o.cancel=r.cancel,o}const Vo=new Cr("wait-for-remote-peer");async function zo(e,t,n){if(t=t??function(e){const t=[];e.relay&&t.push(rr.Relay);e.filter&&t.push(rr.Filter);e.store&&t.push(rr.Store);e.lightPush&&t.push(rr.LightPush);return t}(e),!e.isStarted())return Promise.reject("Waku node is not started");const r=[];if(t.includes(rr.Relay)){if(!e.relay)throw new Error("Cannot wait for Relay peer: protocol not mounted");r.push(async function(e){let t=e.getMeshPeers();const n=e.pubsubTopics;for(const r of n)for(;0==t.length;)await jo(e.gossipSub,"gossipsub:heartbeat"),t=e.getMeshPeers(r)}(e.relay))}if(t.includes(rr.Store)){if(!e.store)throw new Error("Cannot wait for Store peer: protocol not mounted");r.push(Ko(e.store.protocol,e.libp2p.services.metadata))}if(t.includes(rr.LightPush)){if(!e.lightPush)throw new Error("Cannot wait for LightPush peer: protocol not mounted");r.push(Ko(e.lightPush.protocol,e.libp2p.services.metadata))}if(t.includes(rr.Filter)){if(!e.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");r.push(Ko(e.filter.protocol,e.libp2p.services.metadata))}n?await async function(e,t,n){await Promise.race([e,Wo(t,n)])}(Promise.all(r),n,"Timed out waiting for a remote peer."):await Promise.all(r)}async function Ko(e,t){const n=e.multicodec,r=await e.connectedPeers();if(r.length){if(!t)return void Vo.info(`${n} peer found: `,r[0].id.toString());try{return void await Promise.any(r.map((e=>t.confirmOrAttemptHandshake(e.id))))}catch(o){"ERR_CONNECTION_BEING_CLOSED"===o.code&&Vo.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${o}`),Vo.error(`Error waiting for handshake confirmation: ${o}`)}}Vo.info(`Waiting for ${n} peer`),await new Promise((r=>{const o=i=>{i.detail?.protocols?.includes(n)&&(t?t.confirmOrAttemptHandshake(i.detail.peerId).then((()=>{e.removeLibp2pEventListener("peer:identify",o),r()})).catch((e=>{"ERR_CONNECTION_BEING_CLOSED"===e.code&&Vo.error(`Connection with the peer was closed and possibly because it's on a different shard. Error: ${e}`),Vo.error(`Error waiting for handshake confirmation: ${e}`)})):(e.removeLibp2pEventListener("peer:identify",o),r()))};e.addLibp2pEventListener("peer:identify",o)}))}const Wo=(e,t)=>new Promise(((n,r)=>setTimeout((()=>r(t)),e)));const Go=function(e){try{for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r]}catch{}};class Yo extends EventTarget{#e=(()=>new Map)();constructor(){super(),Go(1/0,this)}listenerCount(e){const t=this.#e.get(e);return null==t?0:t.length}addEventListener(e,t,n){super.addEventListener(e,t,n);let r=this.#e.get(e);null==r&&(r=[],this.#e.set(e,r)),r.push({callback:t,once:(!0!==n&&!1!==n&&n?.once)??!1})}removeEventListener(e,t,n){super.removeEventListener(e.toString(),t??null,n);let r=this.#e.get(e);null!=r&&(r=r.filter((e=>{let{callback:n}=e;return n!==t})),this.#e.set(e,r))}dispatchEvent(e){const t=super.dispatchEvent(e);let n=this.#e.get(e.type);return null==n||(n=n.filter((e=>{let{once:t}=e;return!t})),this.#e.set(e.type,n)),t}safeDispatchEvent(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.dispatchEvent(new Qo(e,t))}}const Qo=globalThis.CustomEvent,Jo=new Cr("keep-alive");class Xo{relay;libp2p;options;pingKeepAliveTimers=(()=>new Map)();relayKeepAliveTimers=(()=>new Map)();constructor(e){let{options:t,relay:n,libp2p:r}=e;this.options=t,this.relay=n,this.libp2p=r}start(e){this.stop(e);const{pingKeepAlive:t,relayKeepAlive:n}=this.options,r=e.toString();if(0!==t){const n=setInterval((()=>{(async()=>{let n;try{try{n=await this.libp2p.services.ping.ping(e),Jo.info(`Ping succeeded (${r})`,n)}catch(o){return void Jo.error(`Ping failed for peer (${r}).\n Next ping will be attempted in ${t} seconds.\n `)}try{await this.libp2p.peerStore.merge(e,{metadata:{ping:gr(n.toString())}})}catch(i){Jo.error("Failed to update ping",i)}}catch(i){Jo.error(`Ping failed (${r})`,i)}})()}),1e3*t);this.pingKeepAliveTimers.set(r,n)}const o=this.relay;if(o&&0!==n){const t=this.scheduleRelayPings(o,n,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,n){const r=[];for(const o of e.pubsubTopics){if(!e.getMeshPeers(o).includes(n))continue;const i=Or({pubsubTopicShardInfo:br(o),contentTopic:"/relay-ping/1/ping/null",ephemeral:!0}),s=setInterval((()=>{Jo.info("Sending Waku Relay ping message"),e.send(i,{payload:new Uint8Array([1])}).catch((e=>Jo.error("Failed to send relay ping",e)))}),1e3*t);r.push(s)}return r}}const Zo=new Cr("connection-manager");class ei extends Yo{configuredPubsubTopics;static instances=(()=>new Map)();keepAliveManager;options;libp2p;dialAttemptsForPeer=(()=>new Map)();dialErrorsForPeer=(()=>new Map)();currentActiveParallelDialCount=0;pendingPeerDialQueue=[];isP2PNetworkConnected=!1;isConnected(){return!(globalThis?.navigator&&!globalThis?.navigator?.onLine)&&this.isP2PNetworkConnected}static create(e,t,n,r,o,i){let s=ei.instances.get(e);return s||(s=new ei(t,n,r,o,i),ei.instances.set(e,s)),s}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"]),this.stopNetworkStatusListener()}async dropConnection(e){try{this.keepAliveManager.stop(e),await this.libp2p.hangUp(e),Zo.info(`Dropped connection with peer ${e.toString()}`)}catch(t){Zo.error(`Error dropping connection with peer ${e.toString()} - ${t}`)}}async getPeersByDiscovery(){const e=await this.libp2p.peerStore.all(),t=this.libp2p.getConnections().map((e=>e.remotePeer)),n=[],r=[],o=[],i=[],s=[],a=[];for(const l of e){const e=await this.getTagNamesForPeer(l.id);e.includes(ir.BOOTSTRAP)?n.push(l):e.includes(ir.PEER_EXCHANGE)?r.push(l):e.includes(ir.LOCAL)&&o.push(l)}for(const l of t){const e=await this.libp2p.peerStore.get(l),t=await this.getTagNamesForPeer(l);t.includes(ir.BOOTSTRAP)?i.push(e):t.includes(ir.PEER_EXCHANGE)?s.push(e):t.includes(ir.LOCAL)&&a.push(e)}return{DISCOVERED:{[ir.BOOTSTRAP]:n,[ir.PEER_EXCHANGE]:r,[ir.LOCAL]:o},CONNECTED:{[ir.BOOTSTRAP]:i,[ir.PEER_EXCHANGE]:s,[ir.LOCAL]:a}}}constructor(e,t,n,r,o){super(),this.configuredPubsubTopics=n,this.libp2p=e,this.configuredPubsubTopics=n,this.options={maxDialAttemptsForPeer:3,maxBootstrapPeersAllowed:1,maxParallelDials:3,...o},this.keepAliveManager=new Xo({relay:r,libp2p:e,options:t}),this.startEventListeners().then((()=>Zo.info("Connection Manager is now running"))).catch((e=>Zo.error("Unexpected error while running service",e))),this.dialPeerStorePeers().catch((e=>Zo.error("Unexpected error while dialing peer store peers",e)))}async dialPeerStorePeers(){const e=await this.libp2p.peerStore.all(),t=[];for(const r of e)this.libp2p.getConnections().find((e=>e.remotePeer===r.id))||t.push(this.attemptDial(r.id));try{await Promise.all(t)}catch(n){Zo.error("Unexpected error while dialing peer store peers",n)}}async startEventListeners(){this.startPeerDiscoveryListener(),this.startPeerConnectionListener(),this.startPeerDisconnectionListener(),this.startNetworkStatusListener()}async dialPeer(e){this.currentActiveParallelDialCount+=1;let t=0;for(;t<this.options.maxDialAttemptsForPeer;)try{Zo.info(`Dialing peer ${e.toString()} on attempt ${t+1}`),await this.libp2p.dial(e);const n=await this.getTagNamesForPeer(e);this.libp2p.getConnections(e).forEach((e=>{e.tags=Array.from(new Set([...e.tags,...n]))})),this.dialAttemptsForPeer.set(e.toString(),-1),this.keepAliveManager.start(e);break}catch(n){n instanceof AggregateError?Zo.error(`Error dialing peer ${e.toString()} - ${n.errors}`):Zo.error(`Error dialing peer ${e.toString()} - ${n.message}`),this.dialErrorsForPeer.set(e.toString(),n),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 n;t instanceof AggregateError?t.errors?0===t.errors.length?Zo.warn("Errors array is empty for AggregateError"):n=JSON.stringify(t.errors[0]):Zo.warn("No errors array found for AggregateError"):n=t.message,Zo.info(`Deleting undialable peer ${e.toString()} from peer store. Reason: ${n}`)}this.dialErrorsForPeer.delete(e.toString()),await this.libp2p.peerStore.delete(e),await this.attemptDnsDiscovery()}catch(n){throw new Error(`Error deleting undialable peer ${e.toString()} from peer store - ${n}`)}}async attemptDnsDiscovery(){if(this.libp2p.getConnections().length>0)return;if((await this.libp2p.peerStore.all()).length>0)return;Zo.info("Attempting to trigger DNS discovery.");const e=Object.values(this.libp2p.components.components).find((e=>!(!e||!e.toString)&&e.toString().includes(lr)));e&&await e.findPeers()}processDialQueue(){if(this.pendingPeerDialQueue.length>0&&this.currentActiveParallelDialCount<this.options.maxParallelDials){const e=this.pendingPeerDialQueue.shift();if(!e)return;this.attemptDial(e).catch((e=>{Zo.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):await this.dialPeer(e))}onEventHandlers={"peer:discovery":e=>{(async()=>{const{id:t}=e.detail;await this.dispatchDiscoveryEvent(t);try{await this.attemptDial(t)}catch(n){Zo.error(`Error dialing peer ${t.toString()} : ${n}`)}})()},"peer:connect":e=>{(async()=>{Zo.info(`Connected to peer ${e.detail.toString()}`);const t=e.detail;this.keepAliveManager.start(t);if((await this.getTagNamesForPeer(t)).includes(ir.BOOTSTRAP)){this.libp2p.getConnections().filter((e=>e.tags.includes(ir.BOOTSTRAP))).length>this.options.maxBootstrapPeersAllowed?await this.dropConnection(t):this.dispatchEvent(new Qo(sr.PEER_CONNECT_BOOTSTRAP,{detail:t}))}else this.dispatchEvent(new Qo(sr.PEER_CONNECT_PEER_EXCHANGE,{detail:t}));this.setP2PNetworkConnected()})()},"peer:disconnect":e=>{(async()=>{this.keepAliveManager.stop(e.detail),this.setP2PNetworkDisconnected()})()},"browser:network":()=>{this.dispatchWakuConnectionEvent()}};async shouldDialPeer(e){if(this.libp2p.getConnections(e).length>0)return Zo.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 Zo.warn(`Discovered peer ${e.toString()} with ShardInfo ${t} is not part of any of the configured pubsub topics (${this.configuredPubsubTopics}).\n Not dialing.`),!1}if(!await this.isPeerDialableBasedOnBootstrapStatus(e))return Zo.warn(`Peer ${e.toString()} is not dialable based on bootstrap status. Not dialing.`),!1;return!this.dialAttemptsForPeer.has(e.toString())||(Zo.warn(`Peer ${e.toString()} has already been attempted dial before, or already has a dial attempt in progress, skipping dial`),!1)}async isPeerDialableBasedOnBootstrapStatus(e){if(!(await this.getTagNamesForPeer(e)).some((e=>e===ir.BOOTSTRAP)))return!0;return this.libp2p.getConnections().filter((e=>e.tags.find((e=>e===ir.BOOTSTRAP)))).length<this.options.maxBootstrapPeersAllowed}async dispatchDiscoveryEvent(e){const t=(await this.getTagNamesForPeer(e)).includes(ir.BOOTSTRAP);this.dispatchEvent(new Qo(t?sr.PEER_DISCOVERY_BOOTSTRAP:sr.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 Zo.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 yr(t).some((e=>this.configuredPubsubTopics.includes(e)))}async getPeerShardInfo(e,t){const n=(await t.get(e)).metadata.get("shardInfo");if(n)return Ar(n)}startNetworkStatusListener(){try{globalThis.addEventListener("online",this.onEventHandlers["browser:network"]),globalThis.addEventListener("offline",this.onEventHandlers["browser:network"])}catch(e){Zo.error(`Failed to start network listener: ${e}`)}}stopNetworkStatusListener(){try{globalThis.removeEventListener("online",this.onEventHandlers["browser:network"]),globalThis.removeEventListener("offline",this.onEventHandlers["browser:network"])}catch(e){Zo.error(`Failed to stop network listener: ${e}`)}}setP2PNetworkConnected(){this.isP2PNetworkConnected||(this.isP2PNetworkConnected=!0,this.dispatchWakuConnectionEvent())}setP2PNetworkDisconnected(){this.isP2PNetworkConnected&&0===this.libp2p.getConnections().length&&(this.isP2PNetworkConnected=!1,this.dispatchWakuConnectionEvent())}dispatchWakuConnectionEvent(){this.dispatchEvent(new Qo(ar.CONNECTION_STATUS,{detail:this.isConnected()}))}}class ti{static instance;health;constructor(){this.health={overallStatus:ur.Unhealthy,protocolStatuses:new Map}}static getInstance(){return ti.instance||(ti.instance=new ti),ti.instance}getHealthStatus(){return this.health.overallStatus}getProtocolStatus(e){return this.health.protocolStatuses.get(e)}updateProtocolHealth(e,t){const n=this.getNameFromMulticodec(e);let r=ur.Unhealthy;1==t?r=ur.MinimallyHealthy:t>=2&&(r=ur.SufficientlyHealthy),this.health.protocolStatuses.set(n,{name:n,status:r,lastUpdate:new Date}),this.updateOverallHealth()}getNameFromMulticodec(e){let t;if(e.includes("filter"))t=rr.Filter;else if(e.includes("lightpush"))t=rr.LightPush;else{if(!e.includes("store"))throw new Error(`Unknown protocol: ${e}`);t=rr.Store}return t}updateOverallHealth(){const e=[rr.LightPush,rr.Filter].map((e=>this.getProtocolStatus(e)?.status));e.some((e=>e===ur.Unhealthy))?this.health.overallStatus=ur.Unhealthy:e.some((e=>e===ur.MinimallyHealthy))?this.health.overallStatus=ur.MinimallyHealthy:this.health.overallStatus=ur.SufficientlyHealthy}}const ni=()=>ti.getInstance(),ri=new Cr("metadata"),oi="/vac/waku/metadata/1.0.0";class ii extends fo{pubsubTopics;libp2pComponents;handshakesConfirmed=(()=>new Map)();constructor(e,t){super(oi,t.components,ri,e),this.pubsubTopics=e,this.libp2pComponents=t,t.registrar.handle(oi,(e=>{this.onRequest(e)}))}async query(e){const t=_n.encode(wr(this.pubsubTopics)),n=await this.libp2pComponents.peerStore.get(e);if(!n)return{shardInfo:null,error:or.NO_PEER_AVAILABLE};let r;try{r=await this.getStream(n)}catch(i){return ri.error("Failed to get stream",i),{shardInfo:null,error:or.NO_STREAM_AVAILABLE}}const o=await io([t],Vr,r,Jr,(async e=>await Dr(e))),{error:i,shardInfo:s}=this.decodeMetadataResponse(o);return i?{shardInfo:null,error:i}:(await this.savePeerShardInfo(e,s),{shardInfo:s,error:null})}async confirmOrAttemptHandshake(e){const t=this.handshakesConfirmed.get(e.toString());return t?{shardInfo:t,error:null}:await this.query(e)}async onRequest(e){try{const{stream:t,connection:n}=e,r=In.encode(wr(this.pubsubTopics)),o=await io([r],Vr,t,Jr,(async e=>await Dr(e))),{error:i,shardInfo:s}=this.decodeMetadataResponse(o);if(i)return;await this.savePeerShardInfo(n.remotePeer,s)}catch(t){ri.error("Error handling metadata request",t)}}decodeMetadataResponse(e){const t=new Hr;e.forEach((e=>{t.append(e)}));const n=In.decode(t);return n?{shardInfo:n,error:null}:(ri.error("Error decoding metadata response"),{shardInfo:null,error:or.DECODE_FAILED})}async savePeerShardInfo(e,t){await this.libp2pComponents.peerStore.merge(e,{metadata:{shardInfo:_r(t)}}),this.handshakesConfirmed.set(e.toString(),t)}}function si(e){return t=>new ii(e,t)}const ai=Symbol.for("@libp2p/peer-id");function li(e){return null!=e&&Boolean(e[ai])}const ci=new class{index=0;input="";new(e){return this.index=0,this.input=e,this}readAtomically(e){const t=this.index,n=e();return void 0===n&&(this.index=t),n}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,n){return this.readAtomically((()=>{if(!(t>0&&void 0===this.readGivenChar(e)))return n()}))}readNumber(e,t,n,r){return this.readAtomically((()=>{let o=0,i=0;const s=this.peekChar();if(void 0===s)return;const a="0"===s,l=2**(8*r)-1;for(;;){const n=this.readAtomically((()=>{const t=this.readChar();if(void 0===t)return;const n=Number.parseInt(t,e);return Number.isNaN(n)?void 0:n}));if(void 0===n)break;if(o*=e,o+=n,o>l)return;if(i+=1,void 0!==t&&i>t)return}return 0===i||!n&&a&&i>1?void 0:o}))}readIPv4Addr(){return this.readAtomically((()=>{const e=new Uint8Array(4);for(let t=0;t<e.length;t++){const n=this.readSeparator(".",t,(()=>this.readNumber(10,3,!1,1)));if(void 0===n)return;e[t]=n}return e}))}readIPv6Addr(){const e=e=>{for(let t=0;t<e.length/2;t++){const n=2*t;if(t<e.length-3){const r=this.readSeparator(":",t,(()=>this.readIPv4Addr()));if(void 0!==r)return e[n]=r[0],e[n+1]=r[1],e[n+2]=r[2],e[n+3]=r[3],[n+4,!0]}const r=this.readSeparator(":",t,(()=>this.readNumber(16,4,!0,2)));if(void 0===r)return[n,!1];e[n]=r>>8,e[n+1]=255&r}return[e.length,!1]};return this.readAtomically((()=>{const t=new Uint8Array(16),[n,r]=e(t);if(16===n)return t;if(r)return;if(void 0===this.readGivenChar(":"))return;if(void 0===this.readGivenChar(":"))return;const o=new Uint8Array(14),i=16-(n+2),[s]=e(o.subarray(0,i));return t.set(o.subarray(0,s),16-s),t}))}readIPAddr(){return this.readIPv4Addr()??this.readIPv6Addr()}};parseInt("0xFFFF",16),new Uint8Array([0,0,0,0,0,0,0,0,0,0,255,255]);function ui(e){return Boolean(function(e){if(!(e.length>15))return ci.new(e).parseWith((()=>ci.readIPv4Addr()))}(e))}function di(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>45))return ci.new(e).parseWith((()=>ci.readIPv6Addr()))}(e))}function hi(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>45))return ci.new(e).parseWith((()=>ci.readIPAddr()))}(e))}const fi=ui,pi=di,gi=function(e){let t=0;if(e=e.toString().trim(),fi(e)){const n=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{n[t++]=255&parseInt(e,10)})),n}if(pi(e)){const n=e.split(":",8);let r;for(r=0;r<n.length;r++){let e;fi(n[r])&&(e=gi(n[r]),n[r]=dr(e.slice(0,2),"base16")),null!=e&&++r<8&&n.splice(r,0,dr(e.slice(2,4),"base16"))}if(""===n[0])for(;n.length<8;)n.unshift("0");else if(""===n[n.length-1])for(;n.length<8;)n.push("0");else if(n.length<8){for(r=0;r<n.length&&""!==n[r];r++);const e=[r,1];for(r=9-n.length;r>0;r--)e.push("0");n.splice.apply(n,e)}const o=new Uint8Array(t+16);for(r=0;r<n.length;r++){const e=parseInt(n[r],16);o[t++]=e>>8&255,o[t++]=255&e}return o}throw new Error("invalid ip address")},mi=-1,yi={},bi={};function wi(e){if("number"===typeof e){if(null!=bi[e])return bi[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=yi[e])return yi[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,mi,"ip6zone"],[43,8,"ipcidr"],[53,mi,"dns",!0],[54,mi,"dns4",!0],[55,mi,"dns6",!0],[56,mi,"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,mi,"unix",!1,!0],[421,mi,"ipfs"],[421,mi,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,mi,"garlic64"],[448,0,"tls"],[449,mi,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,mi,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,mi,"http-path"],[777,mi,"memory"]].forEach((e=>{const t=function(e,t,n,r,o){return{code:e,size:t,name:n,resolvable:Boolean(r),path:Boolean(o)}}(...e);bi[t.code]=t,yi[t.name]=t}));wi("ip4"),wi("ip6"),wi("ipcidr");function vi(e,t){switch(wi(e).code){case 4:case 41:return function(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;t=~~t,n=n??e.length-t;const r=new DataView(e.buffer);if(4===n){const r=[];for(let o=0;o<n;o++)r.push(e[t+o]);return r.join(".")}if(16===n){const e=[];for(let o=0;o<n;o+=2)e.push(r.getUint16(t+o).toString(16));return e.join(":").replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}return""}(e,0,e.length);if(null==t)throw new Error("ipBuff is required");if(!hi(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 Ci(t);case 6:case 273:case 33:case 132:return Ii(t).toString();case 421:return function(e){const t=D(e),n=e.slice(N(t));if(n.length!==t)throw new Error("inconsistent lengths");return dr(n,"base58btc")}(t);case 444:case 445:return Ri(t);case 466:return function(e){const t=D(e),n=e.slice(N(t));if(n.length!==t)throw new Error("inconsistent lengths");return"u"+dr(n,"base64url")}(t);case 481:return globalThis.encodeURIComponent(Ci(t));default:return dr(t,"base16")}}function Ei(e,t){switch(wi(e).code){case 4:case 41:return Ai(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return xi(t);case 6:case 273:case 33:case 132:return _i(parseInt(t,10));case 421:return function(e){let t;t="Q"===e[0]||"1"===e[0]?ft(Ce.decode(`z${e}`)).bytes:_t.parse(e).multihash.bytes;const n=Uint8Array.from(L(t.length));return Br([n,t],n.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 n=ye.decode("b"+t[0]),r=parseInt(t[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const o=_i(r);return Br([n,o],n.length+o.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 n=ye.decode(`b${t[0]}`),r=parseInt(t[1],10);if(r<1||r>65536)throw new Error("Port number is not in range(1, 65536)");const o=_i(r);return Br([n,o],n.length+o.length)}(t);case 466:return function(e){const t=ki.decode(e),n=Uint8Array.from(L(t.length));return Br([n,t],n.length+t.length)}(t);case 481:return xi(globalThis.decodeURIComponent(t));default:return Dt(t,"base16")}}const Si=Object.values(Tt).map((e=>e.decoder)),ki=function(){let e=Si[0].or(Si[1]);return Si.slice(2).forEach((t=>e=e.or(t))),e}();function Ai(e){if(!hi(e))throw new Error("invalid ip address");return gi(e)}function _i(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function Ii(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function xi(e){const t=Dt(e),n=Uint8Array.from(L(t.length));return Br([n,t],n.length+t.length)}function Ci(e){const t=D(e);if((e=e.slice(N(t))).length!==t)throw new Error("inconsistent lengths");return dr(e)}function Ri(e){const t=e.slice(0,e.length-2),n=e.slice(e.length-2);return`${dr(t,"base32")}:${Ii(n)}`}function Ti(e){const t=[],n=[];let r=null,o=0;for(;o<e.length;){const i=D(e,o),s=N(i),a=wi(i),l=Oi(a,e.slice(o+s));if(0===l){t.push([i]),n.push([i]),o+=s;continue}const c=e.slice(o+s,o+s+l);if(o+=l+s,o>e.length)throw Di("Invalid address Uint8Array: "+dr(e,"base16"));t.push([i,c]);const u=vi(i,c);if(n.push([i,u]),!0===a.path){r=u;break}}return{bytes:Uint8Array.from(e),string:Ni(n),tuples:t,stringTuples:n,path:r}}function Ni(e){const t=[];return e.map((e=>{const n=wi(e[0]);return t.push(n.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),Li(t.join("/"))}function Pi(e){return Br(e.map((e=>{const t=wi(e[0]);let n=Uint8Array.from(L(t.code));return e.length>1&&null!=e[1]&&(n=Br([n,e[1]])),n})))}function Oi(e,t){if(e.size>0)return e.size/8;if(0===e.size)return 0;{const e=D(t instanceof Uint8Array?t:Uint8Array.from(t));return e+N(e)}}function Li(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function Di(e){return new Error("Error parsing address: "+e)}const Bi=Symbol.for("nodejs.util.inspect.custom"),Ui=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Mi=[wi("dns").code,wi("dns4").code,wi("dns6").code,wi("dnsaddr").code];class Fi extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"No available resolver"),this.name="NoAvailableResolverError"}}class $i{bytes;#t;#n;#r;#o;[Ui]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=Ti(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=[],n=[];let r=null;const o=(e=Li(e)).split("/").slice(1);if(1===o.length&&""===o[0])return{bytes:new Uint8Array,string:"/",tuples:[],stringTuples:[],path:null};for(let i=0;i<o.length;i++){const s=wi(o[i]);if(0===s.size){t.push([s.code]),n.push([s.code]);continue}if(i++,i>=o.length)throw Di("invalid address: "+e);if(!0===s.path){r=Li(o.slice(i).join("/")),t.push([s.code,Ei(s.code,r)]),n.push([s.code,r]);break}const a=Ei(s.code,o[i]);t.push([s.code,a]),n.push([s.code,vi(s.code,a)])}return{string:Ni(n),bytes:Pi(t),tuples:t,stringTuples:n,path:r}}(e)}else{if(!qi(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=Ti(e.bytes)}this.bytes=t.bytes,this.#t=t.string,this.#n=t.tuples,this.#r=t.stringTuples,this.#o=t.path}toString(){return this.#t}toJSON(){return this.toString()}toOptions(){let e,t,n,r,o="";const i=wi("tcp"),s=wi("udp"),a=wi("ip4"),l=wi("ip6"),c=wi("dns6"),u=wi("ip6zone");for(const[d,h]of this.stringTuples())d===u.code&&(o=`%${h??""}`),Mi.includes(d)&&(t=i.name,r=443,n=`${h??""}${o}`,e=d===c.code?6:4),d!==i.code&&d!==s.code||(t=wi(d).name,r=parseInt(h??"")),d!==a.code&&d!==l.code||(t=wi(d).name,n=`${h??""}${o}`,e=d===l.code?6:4);if(null==e||null==t||null==n||null==r)throw new Error('multiaddr must have a valid format: "/{ip4, ip6, dns4, dns6, dnsaddr}/{address}/{tcp, udp}/{port}".');return{family:e,host:n,transport:t,port:r}}protos(){return this.#n.map((e=>{let[t]=e;return Object.assign({},wi(t))}))}protoCodes(){return this.#n.map((e=>{let[t]=e;return t}))}protoNames(){return this.#n.map((e=>{let[t]=e;return wi(t).name}))}tuples(){return this.#n}stringTuples(){return this.#r}encapsulate(e){return e=new $i(e),new $i(this.toString()+e.toString())}decapsulate(e){const t=e.toString(),n=this.toString(),r=n.lastIndexOf(t);if(r<0)throw new Error(`Address ${this.toString()} does not contain subaddress: ${e.toString()}`);return new $i(n.slice(0,r))}decapsulateCode(e){const t=this.tuples();for(let n=t.length-1;n>=0;n--)if(t[n][0]===e)return new $i(Pi(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[n,r]=t;n===yi.p2p.code&&e.push([n,r]),n===yi["p2p-circuit"].code&&(e=[])}));const t=e.pop();if(null!=t?.[1]){const e=t[1];return"Q"===e[0]||"1"===e[0]?dr(Ce.decode(`z${e}`),"base58btc"):dr(_t.parse(e).multihash.bytes,"base58btc")}return null}catch(e){return null}}getPath(){return this.#o}equals(e){return Ur(this.bytes,e.bytes)}async resolve(e){const t=this.protos().find((e=>e.resolvable));if(null==t)return[this];const n=Hi.get(t.name);if(null==n)throw new Fi(`no available resolver for ${t.name}`);return(await n(this,e)).map((e=>ji(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))}[Bi](){return`Multiaddr(${this.#t})`}}const Hi=new Map;function qi(e){return Boolean(e?.[Ui])}function ji(e){return new $i(e)}new Error("timeout while waiting for mutex to become available"),new Error("mutex already locked");const Vi=new Error("request for lock canceled");var zi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class Ki{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Vi;this._value=e,this._cancelError=t,this._queue=[],this._weightedWaiters=[]}acquire(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(((n,r)=>{const o={resolve:n,reject:r,weight:e,priority:t},i=Wi(this._queue,(e=>t<=e.priority));-1===i&&e<=this._value?this._dispatchItem(o):this._queue.splice(i+1,0,o)}))}runExclusive(e){return zi(this,arguments,void 0,(function(e){var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return function*(){const[o,i]=yield t.acquire(n,r);try{return yield e(o)}finally{i()}}()}))}waitForUnlock(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return this._couldLockImmediately(e,t)?Promise.resolve():new Promise((n=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),function(e,t){const n=Wi(e,(e=>t.priority<=e.priority));e.splice(n+1,0,t)}(this._weightedWaiters[e-1],{resolve:n,priority:t})}))}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatchQueue()}release(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatchQueue()}cancel(){this._queue.forEach((e=>e.reject(this._cancelError))),this._queue=[]}_dispatchQueue(){for(this._drainUnlockWaiters();this._queue.length>0&&this._queue[0].weight<=this._value;)this._dispatchItem(this._queue.shift()),this._drainUnlockWaiters()}_dispatchItem(e){const t=this._value;this._value-=e.weight,e.resolve([t,this._newReleaser(e.weight)])}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){if(0===this._queue.length)for(let e=this._value;e>0;e--){const t=this._weightedWaiters[e-1];t&&(t.forEach((e=>e.resolve())),this._weightedWaiters[e-1]=[])}else{const e=this._queue[0].priority;for(let t=this._value;t>0;t--){const n=this._weightedWaiters[t-1];if(!n)continue;const r=n.findIndex((t=>t.priority<=e));(-1===r?n:n.splice(0,r)).forEach((e=>e.resolve()))}}}_couldLockImmediately(e,t){return(0===this._queue.length||this._queue[0].priority<t)&&e<=this._value}}function Wi(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var Gi=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{l(r.next(e))}catch(t){i(t)}}function a(e){try{l(r.throw(e))}catch(t){i(t)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}l((r=r.apply(e,t||[])).next())}))};class Yi{constructor(e){this._semaphore=new Ki(1,e)}acquire(){return Gi(this,arguments,void 0,(function(){var e=this;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return function*(){const[,n]=yield e._semaphore.acquire(1,t);return n}()}))}runExclusive(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this._semaphore.runExclusive((()=>e()),1,t)}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._semaphore.waitForUnlock(1,e)}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}class Qi{connectionManager;core;log;peers=(()=>new Map)();healthManager;readMutex=(()=>new Yi)();writeMutex=(()=>new Yi)();writeLockHolder=null;constructor(e,t,n){this.connectionManager=e,this.core=t,this.log=n,this.healthManager=ni(),this.healthManager.updateProtocolHealth(this.core.multicodec,0)}getWriteLockHolder(){return this.writeLockHolder}getPeers(){return Array.from(this.peers.values())}async addPeer(e){return this.writeMutex.runExclusive((async()=>{this.writeLockHolder=`addPeer: ${e.id.toString()}`,await this.connectionManager.attemptDial(e.id),this.peers.set(e.id.toString(),e),this.log.info(`Added and dialed peer: ${e.id.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null}))}async removePeer(e){return this.writeMutex.runExclusive((()=>{this.writeLockHolder=`removePeer: ${e.toString()}`,this.peers.delete(e.toString()),this.log.info(`Removed peer: ${e.toString()}`),this.healthManager.updateProtocolHealth(this.core.multicodec,this.peers.size),this.writeLockHolder=null}))}async getPeerCount(){return this.readMutex.runExclusive((()=>this.peers.size))}async hasPeers(){return this.readMutex.runExclusive((()=>this.peers.size>0))}async removeExcessPeers(e){this.log.info(`Removing ${e} excess peer(s)`);const t=Array.from(this.peers.values()).slice(0,e);for(const n of t)await this.removePeer(n.id)}async disconnectPeer(e){try{return this.writeLockHolder=`disconnectPeer: ${e.toString()}`,this.log.info(`Disconnecting peer: ${e}`),await this.connectionManager.dropConnection(e),await this.removePeer(e),this.log.info(`Disconnected peer: ${e}`),this.writeLockHolder=null,!0}catch(t){return this.log.error("Error disconnecting peer:",t),this.writeLockHolder=null,!1}}async findAndAddPeers(e){const t=await this.findPeers(e);return 0===t.length?(this.log.warn("No additional peers found"),[]):this.addMultiplePeers(t)}async findPeers(e){const t=await this.core.getPeers();return this.readMutex.runExclusive((async()=>t.filter((e=>!this.peers.has(e.id.toString()))).slice(0,e)))}async addMultiplePeers(e){const t=[];for(const n of e)await this.addPeer(n),t.push(n);return t}}class Ji{core;connectionManager;peerManager;numPeersToUse;maintainPeersIntervalId=null;log;constructor(e,t,n){this.core=e,this.connectionManager=t,this.log=new Cr(`sdk:${e.multicodec}`),this.peerManager=new Qi(t,e,this.log),this.numPeersToUse=n?.numPeersToUse??2;const r=n?.maintainPeersInterval??3e4;this.log.info(`Initializing BaseProtocolSDK with numPeersToUse: ${this.numPeersToUse}, maintainPeersInterval: ${r}ms`),this.startMaintainPeersInterval(r)}get connectedPeers(){return this.peerManager.getPeers()}async renewPeer(e){this.log.info(`Attempting to renew peer ${e}`);if(!await this.peerManager.disconnectPeer(e))return void this.log.warn(`Failed to disconnect from peer ${e}`);this.log.debug(`Successfully disconnected from peer ${e}, searching for a new peer`);const t=await this.peerManager.findAndAddPeers(1);if(0!==t.length)return this.log.info(`Successfully renewed peer. New peer: ${t[0].id}`),t[0];this.log.error("Failed to find a new peer to replace the disconnected one")}stopMaintainPeersInterval(){this.maintainPeersIntervalId?(clearInterval(this.maintainPeersIntervalId),this.maintainPeersIntervalId=null,this.log.info("Maintain peers interval stopped")):this.log.debug("Maintain peers interval was not running")}async hasPeers(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{forceUseAllPeers:t=!1,maxAttempts:n=3}=e;if(this.log.debug(`Checking for peers. forceUseAllPeers: ${t}, maxAttempts: ${n}`),!t&&this.connectedPeers.length>0)return this.log.debug(`At least one peer connected (${this.connectedPeers.length}), not forcing use of all peers`),!0;if(!t){await this.maintainPeers();const e=this.connectedPeers.length>0;return this.log.debug(`After maintenance, connected peers: ${this.connectedPeers.length}`),e}for(let r=0;r<n;r++){if(this.log.debug(`Attempt ${r+1}/${n} to reach required number of peers`),await this.maintainPeers(),this.connectedPeers.length>=this.numPeersToUse)return this.log.info(`Required number of peers (${this.numPeersToUse}) reached`),!0;this.log.warn(`Found only ${this.connectedPeers.length}/${this.numPeersToUse} required peers. Retrying...`)}return this.log.error(`Failed to find required number of peers (${this.numPeersToUse}) after ${n} attempts`),!1}async startMaintainPeersInterval(e){this.log.info(`Starting maintain peers interval with ${e}ms interval`);try{this.maintainPeersIntervalId=setInterval((()=>{this.log.debug("Running scheduled peer maintenance"),this.maintainPeers().catch((e=>{this.log.error("Error during scheduled peer maintenance:",e)}))}),e),this.log.info("Maintain peers interval started successfully")}catch(t){throw this.log.error("Error starting maintain peers interval:",t),t}}async maintainPeers(){try{const e=await this.peerManager.getPeerCount(),t=this.numPeersToUse-e;if(this.log.debug(`Current peer count: ${e}, target: ${this.numPeersToUse}`),0===t)return void this.log.info("Peer count is at target, no maintenance required");t>0?(this.log.info(`Attempting to add ${t} peer(s)`),await this.peerManager.findAndAddPeers(t)):(this.log.info(`Attempting to remove ${Math.abs(t)} excess peer(s)`),await this.peerManager.removeExcessPeers(Math.abs(t)));const n=await this.peerManager.getPeerCount();this.log.info(`Peer maintenance completed. Initial count: ${e}, Final count: ${n}`)}catch(e){this.log.error("Error during peer maintenance",{error:e})}}}const Xi=1e4,Zi={keepAlive:Xi};function es(e,t){const n=gr(e),r=gr(t.contentTopic),o=function(e){if(!e)return;let t;t="bigint"===typeof e?e:1000000n*BigInt(e.valueOf());return function(e){const t=new ArrayBuffer(8),n=new DataView(t);return"number"===typeof e?n.setFloat64(0,e,!1):n.setBigInt64(0,e,!1),new Uint8Array(t)}(t)}(t.timestamp),i=mr([n,t.payload,r,t.meta,o].filter(Nn));return nr(i)}const ts=new Cr("sdk:receiver:reliability_monitor");class ns{pubsubTopic;getPeers;renewPeer;getContentTopics;protocolSubscribe;receivedMessagesHashes;missedMessagesByPeer=(()=>new Map)();maxMissedMessagesThreshold=3;peerFailures=(()=>new Map)();maxPingFailures=3;peerRenewalLocks=(()=>new Set)();constructor(e,t,n,r,o){this.pubsubTopic=e,this.getPeers=t,this.renewPeer=n,this.getContentTopics=r,this.protocolSubscribe=o;const i=this.getPeers().map((e=>e.id.toString()));this.receivedMessagesHashes={all:new Set,nodes:{...Object.fromEntries(i.map((e=>[e,new Set])))}},i.forEach((e=>this.missedMessagesByPeer.set(e,0)))}setMaxMissedMessagesThreshold(e){void 0!==e&&(this.maxMissedMessagesThreshold=e)}setMaxPingFailures(e){void 0!==e&&(this.maxPingFailures=e)}async handlePingResult(e,t){if(t?.success)return void this.peerFailures.delete(e.toString());const n=(this.peerFailures.get(e.toString())||0)+1;if(this.peerFailures.set(e.toString(),n),n>=this.maxPingFailures)try{await this.renewAndSubscribePeer(e),this.peerFailures.delete(e.toString())}catch(r){ts.error(`Failed to renew peer ${e.toString()}: ${r}.`)}}processIncomingMessage(e,t,n){const r=this.addMessageToCache(e,t,n);return this.checkAndRenewPeers(),r}addMessageToCache(e,t,n){const r=function(e,t){const n=es(e,t);return pr(n)}(t,e),o=this.receivedMessagesHashes.all.has(r);if(this.receivedMessagesHashes.all.add(r),n){this.receivedMessagesHashes.nodes[n]||(ts.warn(`Peer ${n} not initialized in receivedMessagesHashes.nodes, adding it.`),this.receivedMessagesHashes.nodes[n]=new Set),this.receivedMessagesHashes.nodes[n].add(r)}return o}async checkAndRenewPeers(){for(const t of this.receivedMessagesHashes.all)for(const[n,r]of Object.entries(this.receivedMessagesHashes.nodes))if(!r.has(t)&&(this.incrementMissedMessageCount(n),this.shouldRenewPeer(n))){ts.info(`Peer ${n} has missed too many messages, renewing.`);const t=this.getPeers().find((e=>e.id.toString()===n))?.id;if(!t){ts.error(`Unexpected Error: Peer ${n} not found in connected peers.`);continue}try{await this.renewAndSubscribePeer(t)}catch(e){ts.error(`Failed to renew peer ${n}: ${e}`)}}}async renewAndSubscribePeer(e){const t=e.toString();try{if(this.peerRenewalLocks.has(t))return void ts.info(`Peer ${t} is already being renewed.`);this.peerRenewalLocks.add(t);const n=await this.renewPeer(e);return n?(await this.protocolSubscribe(this.pubsubTopic,n,this.getContentTopics()),this.receivedMessagesHashes.nodes[n.id.toString()]=new Set,this.missedMessagesByPeer.set(n.id.toString(),0),this.peerFailures.delete(t),this.missedMessagesByPeer.delete(t),delete this.receivedMessagesHashes.nodes[t],n):void ts.warn(`Failed to renew peer ${t}: No new peer found.`)}catch(n){return void ts.error(`Failed to renew peer ${t}: ${n}.`)}finally{this.peerRenewalLocks.delete(t)}}incrementMissedMessageCount(e){const t=this.missedMessagesByPeer.get(e)||0;this.missedMessagesByPeer.set(e,t+1)}shouldRenewPeer(e){return(this.missedMessagesByPeer.get(e)||0)>this.maxMissedMessagesThreshold}}const rs=new Cr("sdk:sender:reliability_monitor");class os{renewPeer;attempts=(()=>new Map)();maxAttemptsBeforeRenewal=3;constructor(e){this.renewPeer=e}async attemptRetriesOrRenew(e,t){const n=e.toString(),r=this.attempts.get(n)||0;if(this.attempts.set(n,r+1),r+1<this.maxAttemptsBeforeRenewal)try{const r=await t();r.success?(rs.info(`Successfully sent message after retry to ${n}`),this.attempts.delete(n)):(rs.error(`Failed to send message after retry to ${n}: ${r.failure}`),await this.attemptRetriesOrRenew(e,t))}catch(o){rs.error(`Failed to send message after retry to ${n}: ${o}`),await this.attemptRetriesOrRenew(e,t)}else try{const r=await this.renewPeer(e);r?(rs.info(`Renewed peer ${e.toString()} to ${r.id.toString()}`),this.attempts.delete(n),this.attempts.set(r.id.toString(),0),await t()):rs.error(`Failed to renew peer ${e.toString()}: New peer is undefined`)}catch(o){rs.error(`Failed to renew peer ${e.toString()}: ${o}`)}}}class is{static receiverMonitors=(()=>new Map)();static senderMonitor;static createReceiverMonitor(e,t,n,r,o){if(is.receiverMonitors.has(e))return is.receiverMonitors.get(e);const i=new ns(e,t,n,r,o);return is.receiverMonitors.set(e,i),i}static createSenderMonitor(e){return is.senderMonitor||(is.senderMonitor=new os(e)),is.senderMonitor}constructor(){}static stop(e){this.receiverMonitors.delete(e),this.senderMonitor=void 0}static stopAll(){for(const[e,t]of this.receiverMonitors)t.setMaxMissedMessagesThreshold(void 0),t.setMaxPingFailures(void 0),this.receiverMonitors.delete(e),this.senderMonitor=void 0}}const ss=new Cr("sdk:filter:subscription_manager");class as{pubsubTopic;protocol;connectionManager;getPeers;renewPeer;reliabilityMonitor;keepAliveTimer=null;subscriptionCallbacks;constructor(e,t,n,r,o){this.pubsubTopic=e,this.protocol=t,this.connectionManager=n,this.getPeers=r,this.renewPeer=o,this.pubsubTopic=e,this.subscriptionCallbacks=new Map,this.reliabilityMonitor=is.createReceiverMonitor(this.pubsubTopic,this.getPeers.bind(this),this.renewPeer.bind(this),(()=>Array.from(this.subscriptionCallbacks.keys())),this.protocol.subscribe.bind(this.protocol))}async subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Zi;this.reliabilityMonitor.setMaxMissedMessagesThreshold(n.maxMissedMessagesThreshold),this.reliabilityMonitor.setMaxPingFailures(n.pingsBeforePeerRenewed),this.keepAliveTimer=n.keepAlive||Xi;const r=Array.isArray(e)?e:[e];for(const c of r)if(c.pubsubTopic!==this.pubsubTopic)return{failures:[{error:or.TOPIC_DECODER_MISMATCH}],successes:[]};const o=Pn(r),i=Array.from(o.keys()),s=this.getPeers().map((async e=>this.protocol.subscribe(this.pubsubTopic,e,i))),a=await Promise.allSettled(s),l=this.handleResult(a,"subscribe");return o.forEach(((e,n)=>{const r={decoders:e,callback:t};this.subscriptionCallbacks.set(n,r)})),this.startSubscriptionsMaintenance(this.keepAliveTimer),l}async unsubscribe(e){const t=this.getPeers().map((async t=>{const n=await this.protocol.unsubscribe(this.pubsubTopic,t,e);return e.forEach((e=>{this.subscriptionCallbacks.delete(e)})),n})),n=await Promise.allSettled(t),r=this.handleResult(n,"unsubscribe");return 0===this.subscriptionCallbacks.size&&this.stopSubscriptionsMaintenance(),r}async ping(e){const t=(e?[e]:this.getPeers().map((e=>e.id))).map((e=>this.pingSpecificPeer(e))),n=await Promise.allSettled(t);return this.handleResult(n,"ping")}async unsubscribeAll(){const e=this.getPeers().map((async e=>this.protocol.unsubscribeAll(this.pubsubTopic,e))),t=await Promise.allSettled(e);this.subscriptionCallbacks.clear();const n=this.handleResult(t,"unsubscribeAll");return this.stopSubscriptionsMaintenance(),n}async processIncomingMessage(e,t){if(this.reliabilityMonitor.processIncomingMessage(e,this.pubsubTopic,t))return void ss.info("Message already received, skipping");const{contentTopic:n}=e,r=this.subscriptionCallbacks.get(n);r?(ss.info("Processing message with content topic ",n," on pubsub topic ",this.pubsubTopic),await async function(e,t,n){const{decoders:r,callback:o}=e,{contentTopic:i}=n;if(!i)return void ss.warn("Message has no content topic, skipping");try{const e=r.map((e=>e.fromProtoObj(t,n).then((e=>e||Promise.reject("Decoding failed"))))),i=await Promise.any(e);await o(i)}catch(s){ss.error("Error decoding message",s)}}(r,this.pubsubTopic,e)):ss.error("No subscription callback available for ",n)}handleResult(e,t){const n={failures:[],successes:[]};for(const r of e)if("rejected"===r.status)ss.error(`Failed to resolve ${t} promise successfully: `,r.reason),n.failures.push({error:or.GENERIC_FAIL});else{const e=r.value;e.failure?n.failures.push(e.failure):n.successes.push(e.success)}return n}async pingSpecificPeer(e){const t=this.getPeers().find((t=>t.id.equals(e)));if(!t)return{success:null,failure:{peerId:e,error:or.NO_PEER_AVAILABLE}};let n;try{return n=await this.protocol.ping(t),n}catch(r){return{success:null,failure:{peerId:e,error:or.GENERIC_FAIL}}}finally{this.reliabilityMonitor.handlePingResult(e,n)}}startSubscriptionsMaintenance(e){ss.info("Starting subscriptions maintenance"),this.startKeepAlivePings(e),this.startConnectionListener()}stopSubscriptionsMaintenance(){ss.info("Stopping subscriptions maintenance"),this.stopKeepAlivePings(),this.stopConnectionListener()}startConnectionListener(){this.connectionManager.addEventListener(ar.CONNECTION_STATUS,this.connectionListener.bind(this))}stopConnectionListener(){this.connectionManager.removeEventListener(ar.CONNECTION_STATUS,this.connectionListener.bind(this))}async connectionListener(e){let{detail:t}=e;if(t){try{await this.ping()}catch(n){ss.error(`networkStateListener failed to recover: ${n}`)}this.startKeepAlivePings(this.keepAliveTimer||Xi)}else this.stopKeepAlivePings()}startKeepAlivePings(e){this.keepAliveTimer?ss.info("Recurring pings already set up."):this.keepAliveTimer=setInterval((()=>{ss.info("Sending keep-alive ping"),this.ping().then((()=>ss.info("Keep-alive ping successful"))).catch((e=>ss.error("Error in keep-alive ping cycle:",e)))}),e)}stopKeepAlivePings(){this.keepAliveTimer?(ss.info("Stopping recurring pings."),clearInterval(this.keepAliveTimer),this.keepAliveTimer=null):ss.info("Already stopped recurring pings.")}}const ls=new Cr("sdk:filter");class cs extends Ji{protocol;activeSubscriptions=(()=>new Map)();constructor(e,t,n){super(new xo((async(e,t,n)=>{const r=this.getActiveSubscription(e);r?await r.processIncomingMessage(t,n):ls.error(`No subscription locally registered for topic ${e}`)}),(async e=>{ls.error("Error with receiving pipe",e)}),e.configuredPubsubTopics,t),e,{numPeersToUse:n?.numPeersToUse}),this.protocol=this.core,this.activeSubscriptions=new Map}async subscribe(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Zi;const o=this.getUniquePubsubTopics(e);if(1!==o.length)return{subscription:null,error:or.INVALID_DECODER_TOPICS,results:null};const i=o[0],{subscription:s,error:a}=await this.createSubscription(i,n);if(a)return{subscription:null,error:a,results:null};const{failures:l,successes:c}=await s.subscribe(e,t,r);return{subscription:s,error:null,results:{failures:l,successes:c}}}async createSubscription(e,t){t={autoRetry:!0,...t};const n="string"==typeof e?e:yr(e)?.[0];vr(n,this.protocol.pubsubTopics);if(!await this.hasPeers(t))return{error:or.NO_PEER_AVAILABLE,subscription:null};ls.info(`Creating filter subscription with ${this.connectedPeers.length} peers: `,this.connectedPeers.map((e=>e.id.toString())));return{error:null,subscription:this.getActiveSubscription(n)??this.setActiveSubscription(n,new as(n,this.protocol,this.connectionManager,(()=>this.connectedPeers),this.renewPeer.bind(this)))}}async subscribeWithUnsubscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Zi;const r=this.getUniquePubsubTopics(e);if(0===r.length)throw Error("Failed to subscribe: no pubsubTopic found on decoders provided.");if(r.length>1)throw Error("Failed to subscribe: all decoders should have the same pubsub topic. Use createSubscription to be more agile.");const{subscription:o,error:i}=await this.createSubscription(r[0]);if(i)throw Error(`Failed to create subscription: ${i}`);await o.subscribe(e,t,n);const s=Array.from(Pn(Array.isArray(e)?e:[e]).keys());return async()=>{await o.unsubscribe(s)}}toSubscriptionIterator(e){return async function(e,t,n){const r=n?.iteratorDelay??60,o=[];let i;i=await e.subscribeWithUnsubscribe(t,(e=>{o.push(e)}));const s=Number.isInteger(n?.timeoutMs),a=n?.timeoutMs??0,l=Date.now();return{iterator:async function*(){for(;;){if(s&&Date.now()-l>=a)return;await On(r);const e=o.shift();if(!i&&0===o.length)return e;!e&&i||(yield e)}}(),async stop(){i&&(await i(),i=void 0)}}}(this,e)}getActiveSubscription(e){return this.activeSubscriptions.get(e)}setActiveSubscription(e,t){return this.activeSubscriptions.set(e,t),t}getUniquePubsubTopics(e){if(!Array.isArray(e))return[e.pubsubTopic];if(0===e.length)return[];const t=new Set(e.map((e=>e.pubsubTopic)));return[...t]}}const us=new Cr("sdk:light-push");class ds extends Ji{protocol;reliabilityMonitor;constructor(e,t,n){super(new To(e.configuredPubsubTopics,t),e,{numPeersToUse:n?.numPeersToUse}),this.reliabilityMonitor=is.createSenderMonitor(this.renewPeer.bind(this)),this.protocol=this.core}async send(e,t,n){const r={autoRetry:!0,...n},o=[],i=[],{pubsubTopic:s}=e;try{vr(s,this.protocol.pubsubTopics)}catch(c){return us.error("Failed to send waku light push: pubsub topic not configured"),{failures:[{error:or.TOPIC_NOT_CONFIGURED}],successes:[]}}if(!await this.hasPeers(r))return{successes:o,failures:[{error:or.NO_PEER_AVAILABLE}]};const a=this.connectedPeers.map((n=>this.protocol.send(e,t,n))),l=await Promise.allSettled(a);for(const u of l)if("fulfilled"===u.status){const{failure:n,success:r}=u.value;if(r&&o.push(r),n&&(i.push(n),n.peerId)){const r=this.connectedPeers.find((e=>e.id.equals(n.peerId)));r&&(us.info(`\n Failed to send message to peer ${n.peerId}.\n Retrying the message with the same peer in the background.\n If this fails, the peer will be renewed.\n `),this.reliabilityMonitor.attemptRetriesOrRenew(n.peerId,(()=>this.protocol.send(e,t,r))))}}else us.error("Failed unexpectedly while sending:",u.reason),i.push({error:or.GENERIC_FAIL});return{successes:o,failures:i}}}const hs=new Cr("waku:store:sdk");class fs extends Ji{protocol;constructor(e,t){super(new Bo(e.configuredPubsubTopics,t),e,{numPeersToUse:1}),this.protocol=this.core}async*queryGenerator(e,t){const{pubsubTopic:n,contentTopics:r,decodersAsMap:o}=this.validateDecodersAndPubsubTopic(e),i={pubsubTopic:n,contentTopics:r,includeData:!0,paginationForward:!0,...t},s=(await this.protocol.getPeers({numPeers:this.numPeersToUse,maxBootstrapPeers:1}))[0];if(!s)throw hs.error("No peers available to query"),new Error("No peers available to query");hs.info(`Querying store with options: ${JSON.stringify(t)}`);const a=this.protocol.queryPerPage(i,o,s);for await(const l of a)yield l}async queryWithOrderedCallback(e,t,n){hs.info("Querying store with ordered callback");for await(const r of this.queryGenerator(e,n))if(await this.processMessages(r,t))break}async queryWithPromiseCallback(e,t,n){hs.info("Querying store with promise callback");let r=!1;for await(const o of this.queryGenerator(e,n)){const e=o.map((async e=>{r||(r=Boolean(await t(e)))}));if(await Promise.all(e),r)break}}async processMessages(e,t){let n=!1;const r=(await Promise.all(e)).filter(Nn);return await Promise.all(r.map((async e=>{e&&!n&&(n=Boolean(await t(e)))}))),n}createCursor(e){return es(e.pubsubTopic,e)}validateDecodersAndPubsubTopic(e){if(0===e.length)throw hs.error("No decoders provided"),new Error("No decoders provided");const t=Array.from(new Set(e.map((e=>e.pubsubTopic))));if(t.length>1)throw hs.error("API does not support querying multiple pubsub topics at once"),new Error("API does not support querying multiple pubsub topics at once");const n=t[0];vr(n,this.protocol.pubsubTopics);const r=new Map;e.forEach((e=>{if(r.has(e.contentTopic))throw hs.error("API does not support different decoder per content topic"),new Error("API does not support different decoder per content topic");r.set(e.contentTopic,e)}));const o=e.filter((e=>e.pubsubTopic===n)).map((e=>e.contentTopic));if(0===o.length)throw hs.error(`No decoders found for topic ${n}`),new Error("No decoders found for topic "+n);return{pubsubTopic:n,contentTopics:o,decodersAsMap:r}}}const ps=new Cr("waku");class gs{pubsubTopics;libp2p;relay;store;filter;lightPush;connectionManager;health;constructor(e,t,n,r,o){this.pubsubTopics=e,this.relay=o,this.libp2p=n,r={filter:!1,lightpush:!1,store:!1,...r};const i=t.pingKeepAlive||300,s=this.relay?t.relayKeepAlive||300:0,a=this.libp2p.peerId.toString();if(this.connectionManager=ei.create(a,n,{pingKeepAlive:i,relayKeepAlive:s},this.pubsubTopics,this.relay),this.health=ni(),r.store){const e=(l=this.connectionManager,e=>new fs(l,e));this.store=e(n)}var l;if(r.lightpush){const e=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return n=>new ds(e,n,t)}(this.connectionManager);this.lightPush=e(n)}if(r.filter){const e=function(e,t){return n=>new cs(e,n,t)}(this.connectionManager);this.filter=e(n)}ps.info("Waku node created",a,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}async dial(e,t){const n=t??[],r=function(e){return li(e)?e:ji(e)}(e);"undefined"===typeof t&&(this.relay&&n.push(rr.Relay),this.store&&n.push(rr.Store),this.filter&&n.push(rr.Filter),this.lightPush&&n.push(rr.LightPush));const o=[];return n.includes(rr.Relay)&&(this.relay?this.relay.gossipSub.multicodecs.forEach((e=>o.push(e))):ps.error("Relay codec not included in dial codec: protocol not mounted locally")),n.includes(rr.Store)&&(this.store?o.push(this.store.protocol.multicodec):ps.error("Store codec not included in dial codec: protocol not mounted locally")),n.includes(rr.LightPush)&&(this.lightPush?o.push(this.lightPush.protocol.multicodec):ps.error("Light Push codec not included in dial codec: protocol not mounted locally")),n.includes(rr.Filter)&&(this.filter?o.push(this.filter.protocol.multicodec):ps.error("Filter codec not included in dial codec: protocol not mounted locally")),ps.info(`Dialing to ${r.toString()} with protocols ${n}`),this.libp2p.dialProtocol(r,o)}async start(){await this.libp2p.start()}async stop(){is.stopAll(),this.connectionManager.stop(),await this.libp2p.stop()}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()}}class ms extends Error{code;type;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The operation was aborted"),this.name="AbortError",this.code=ms.code,this.type=ms.type}static code="ABORT_ERR";static type="aborted"}class ys extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}}class bs extends AggregateError{code;props;constructor(e,t,n,r){super(e,t),this.code=n,this.name=r?.name??"AggregateCodeError",this.props=r??{}}}Error;Error;Error;const ws="ERR_TIMEOUT";function vs(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const Es=BigInt(2**32-1),Ss=BigInt(32);function ks(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{h:Number(e&Es),l:Number(e>>Ss&Es)}:{h:0|Number(e>>Ss&Es),l:0|Number(e&Es)}}const As={fromBig:ks,split:function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let o=0;o<e.length;o++){const{h:i,l:s}=ks(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]},toBig:(e,t)=>BigInt(e>>>0)<<Ss|BigInt(t>>>0),shrSH:(e,t,n)=>e>>>n,shrSL:(e,t,n)=>e<<32-n|t>>>n,rotrSH:(e,t,n)=>e>>>n|t<<32-n,rotrSL:(e,t,n)=>e<<32-n|t>>>n,rotrBH:(e,t,n)=>e<<64-n|t>>>n-32,rotrBL:(e,t,n)=>e>>>n-32|t<<64-n,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,n)=>e<<n|t>>>32-n,rotlSL:(e,t,n)=>t<<n|e>>>32-n,rotlBH:(e,t,n)=>t<<n-32|e>>>64-n,rotlBL:(e,t,n)=>e<<n-32|t>>>64-n,add:function(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:0|o}},add3L:(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),add3H:(e,t,n,r)=>t+n+r+(e/2**32|0)|0,add4L:(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),add4H:(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,add5H:(e,t,n,r,o,i)=>t+n+r+o+i+(e/2**32|0)|0,add5L:(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0)},_s=As,[Is,xs]=(()=>_s.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)))))(),Cs=new Uint32Array(80),Rs=new Uint32Array(80);class Ts extends Jn{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:n,Bl:r,Ch:o,Cl:i,Dh:s,Dl:a,Eh:l,El:c,Fh:u,Fl:d,Gh:h,Gl:f,Hh:p,Hl:g}=this;return[e,t,n,r,o,i,s,a,l,c,u,d,h,f,p,g]}set(e,t,n,r,o,i,s,a,l,c,u,d,h,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|o,this.Cl=0|i,this.Dh=0|s,this.Dl=0|a,this.Eh=0|l,this.El=0|c,this.Fh=0|u,this.Fl=0|d,this.Gh=0|h,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let b=0;b<16;b++,t+=4)Cs[b]=e.getUint32(t),Rs[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){const e=0|Cs[b-15],t=0|Rs[b-15],n=_s.rotrSH(e,t,1)^_s.rotrSH(e,t,8)^_s.shrSH(e,t,7),r=_s.rotrSL(e,t,1)^_s.rotrSL(e,t,8)^_s.shrSL(e,t,7),o=0|Cs[b-2],i=0|Rs[b-2],s=_s.rotrSH(o,i,19)^_s.rotrBH(o,i,61)^_s.shrSH(o,i,6),a=_s.rotrSL(o,i,19)^_s.rotrBL(o,i,61)^_s.shrSL(o,i,6),l=_s.add4L(r,a,Rs[b-7],Rs[b-16]),c=_s.add4H(l,n,s,Cs[b-7],Cs[b-16]);Cs[b]=0|c,Rs[b]=0|l}let{Ah:n,Al:r,Bh:o,Bl:i,Ch:s,Cl:a,Dh:l,Dl:c,Eh:u,El:d,Fh:h,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let b=0;b<80;b++){const e=_s.rotrSH(u,d,14)^_s.rotrSH(u,d,18)^_s.rotrBH(u,d,41),t=_s.rotrSL(u,d,14)^_s.rotrSL(u,d,18)^_s.rotrBL(u,d,41),w=u&h^~u&p,v=d&f^~d&g,E=_s.add5L(y,t,v,xs[b],Rs[b]),S=_s.add5H(E,m,e,w,Is[b],Cs[b]),k=0|E,A=_s.rotrSH(n,r,28)^_s.rotrBH(n,r,34)^_s.rotrBH(n,r,39),_=_s.rotrSL(n,r,28)^_s.rotrBL(n,r,34)^_s.rotrBL(n,r,39),I=n&o^n&s^o&s,x=r&i^r&a^i&a;m=0|p,y=0|g,p=0|h,g=0|f,h=0|u,f=0|d,({h:u,l:d}=_s.add(0|l,0|c,0|S,0|k)),l=0|s,c=0|a,s=0|o,a=0|i,o=0|n,i=0|r;const C=_s.add3L(k,_,x);n=_s.add3H(C,S,A,I),r=0|C}({h:n,l:r}=_s.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:i}=_s.add(0|this.Bh,0|this.Bl,0|o,0|i)),({h:s,l:a}=_s.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:l,l:c}=_s.add(0|this.Dh,0|this.Dl,0|l,0|c)),({h:u,l:d}=_s.add(0|this.Eh,0|this.El,0|u,0|d)),({h:h,l:f}=_s.add(0|this.Fh,0|this.Fl,0|h,0|f)),({h:p,l:g}=_s.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=_s.add(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(n,r,o,i,s,a,l,c,u,d,h,f,p,g,m,y)}roundClean(){Cs.fill(0),Rs.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 Ns=Gn((()=>new Ts)),Ps=BigInt(0),Os=BigInt(1),Ls=BigInt(2);function Ds(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}function Bs(e){if(!Ds(e))throw new Error("Uint8Array expected")}function Us(e,t){if("boolean"!==typeof t)throw new Error(`${e} must be valid boolean, got "${t}".`)}const Ms=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Fs(e){Bs(e);let t="";for(let n=0;n<e.length;n++)t+=Ms[e[n]];return t}function $s(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function Hs(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const qs={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function js(e){return e>=qs._0&&e<=qs._9?e-qs._0:e>=qs._A&&e<=qs._F?e-(qs._A-10):e>=qs._a&&e<=qs._f?e-(qs._a-10):void 0}function Vs(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,n=t/2;if(t%2)throw new Error("padded hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,i=0;o<n;o++,i+=2){const t=js(e.charCodeAt(i)),n=js(e.charCodeAt(i+1));if(void 0===t||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[o]=16*t+n}return r}function zs(e){return Hs(Fs(e))}function Ks(e){return Bs(e),Hs(Fs(Uint8Array.from(e).reverse()))}function Ws(e,t){return Vs(e.toString(16).padStart(2*t,"0"))}function Gs(e,t){return Ws(e,t).reverse()}function Ys(e,t,n){let r;if("string"===typeof t)try{r=Vs(t)}catch(i){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${i}`)}else{if(!Ds(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const o=r.length;if("number"===typeof n&&o!==n)throw new Error(`${e} expected ${n} bytes, got ${o}`);return r}function Qs(){let e=0;for(let n=0;n<arguments.length;n++){const t=n<0||arguments.length<=n?void 0:arguments[n];Bs(t),e+=t.length}const t=new Uint8Array(e);for(let n=0,r=0;n<arguments.length;n++){const e=n<0||arguments.length<=n?void 0:arguments[n];t.set(e,r),r+=e.length}return t}const Js=e=>"bigint"===typeof e&&Ps<=e;function Xs(e,t,n){return Js(e)&&Js(t)&&Js(n)&&t<=e&&e<n}function Zs(e,t,n,r){if(!Xs(t,n,r))throw new Error(`expected valid ${e}: ${n} <= n < ${r}, got ${typeof t} ${t}`)}function ea(e){let t;for(t=0;e>Ps;e>>=Os,t+=1);return t}const ta=e=>(Ls<<BigInt(e-1))-Os,na=e=>new Uint8Array(e),ra=e=>Uint8Array.from(e);function oa(e,t,n){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 n)throw new Error("hmacFn must be a function");let r=na(e),o=na(e),i=0;const s=()=>{r.fill(1),o.fill(0),i=0},a=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n(o,r,...t)},l=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:na();o=a(ra([0]),e),r=a(),0!==e.length&&(o=a(ra([1]),e),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=a();const t=r.slice();n.push(t),e+=r.length}return Qs(...n)};return(e,t)=>{let n;for(s(),l(e);!(n=t(c()));)l();return s(),n}}const ia={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||Ds(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 sa(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=(t,n,r)=>{const o=ia[n];if("function"!==typeof o)throw new Error(`Invalid validator "${n}", expected function`);const i=e[t];if((!r||void 0!==i)&&!o(i,e))throw new Error(`Invalid param ${String(t)}=${i} (${typeof i}), expected ${n}`)};for(const[o,i]of Object.entries(t))r(o,i,!1);for(const[o,i]of Object.entries(n))r(o,i,!0);return e}function aa(e){const t=new WeakMap;return function(n){const r=t.get(n);if(void 0!==r)return r;for(var o=arguments.length,i=new Array(o>1?o-1:0),s=1;s<o;s++)i[s-1]=arguments[s];const a=e(n,...i);return t.set(n,a),a}}const la=BigInt(0),ca=BigInt(1),ua=BigInt(2),da=BigInt(3),ha=BigInt(4),fa=BigInt(5),pa=BigInt(8);BigInt(9),BigInt(16);function ga(e,t){const n=e%t;return n>=la?n:t+n}function ma(e,t,n){if(n<=la||t<la)throw new Error("Expected power/modulo > 0");if(n===ca)return la;let r=ca;for(;t>la;)t&ca&&(r=r*e%n),e=e*e%n,t>>=ca;return r}function ya(e,t,n){let r=e;for(;t-- >la;)r*=r,r%=n;return r}function ba(e,t){if(e===la||t<=la)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=ga(e,t),r=t,o=la,i=ca,s=ca,a=la;for(;n!==la;){const e=r/n,t=r%n,l=o-s*e,c=i-a*e;r=n,n=t,o=s,i=a,s=l,a=c}if(r!==ca)throw new Error("invert: does not exist");return ga(o,t)}function wa(e){if(e%ha===da){const t=(e+ca)/ha;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}if(e%pa===fa){const t=(e-fa)/pa;return function(e,n){const r=e.mul(n,ua),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,ua),o),a=e.mul(i,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-ca)/ua;let n,r,o;for(n=e-ca,r=0;n%ua===la;n/=ua,r++);for(o=ua;o<e&&ma(o,t,e)!==e-ca;o++);if(1===r){const t=(e+ca)/ha;return function(e,n){const r=e.pow(n,t);if(!e.eql(e.sqr(r),n))throw new Error("Cannot find square root");return r}}const i=(n+ca)/ua;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,l=e.pow(e.mul(e.ONE,o),n),c=e.pow(s,i),u=e.pow(s,n);for(;!e.eql(u,e.ONE);){if(e.eql(u,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(u);t<a&&!e.eql(r,e.ONE);t++)r=e.sqr(r);const n=e.pow(l,ca<<BigInt(a-t-1));l=e.sqr(n),c=e.mul(c,n),u=e.mul(u,l),a=t}return c}}(e)}const va=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ea(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Sa(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e<=la)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=Ea(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=wa(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:ta(o),ZERO:la,ONE:ca,create:t=>ga(t,e),isValid:t=>{if("bigint"!==typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return la<=t&&t<e},is0:e=>e===la,isOdd:e=>(e&ca)===ca,neg:t=>ga(-t,e),eql:(e,t)=>e===t,sqr:t=>ga(t*t,e),add:(t,n)=>ga(t+n,e),sub:(t,n)=>ga(t-n,e),mul:(t,n)=>ga(t*n,e),pow:(e,t)=>function(e,t,n){if(n<la)throw new Error("Expected power > 0");if(n===la)return e.ONE;if(n===ca)return t;let r=e.ONE,o=t;for(;n>la;)n&ca&&(r=e.mul(r,o)),o=e.sqr(o),n>>=ca;return r}(a,e,t),div:(t,n)=>ga(t*ba(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ba(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>function(e,t){const n=new Array(t.length),r=t.reduce(((t,r,o)=>e.is0(r)?t:(n[o]=t,e.mul(t,r))),e.ONE),o=e.inv(r);return t.reduceRight(((t,r,o)=>e.is0(r)?t:(n[o]=e.mul(t,n[o]),e.mul(t,r))),o),n}(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?Gs(e,i):Ws(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?Ks(e):zs(e)}});return Object.freeze(a)}function ka(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 Aa(e){const t=ka(e);return t+Math.ceil(t/2)}const _a=BigInt(0),Ia=BigInt(1),xa=new WeakMap,Ca=new WeakMap;function Ra(e,t){const n=(e,t)=>{const n=t.negate();return e?n:t},r=e=>{if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error(`Wrong window size=${e}, should be [1..${t}]`)},o=e=>{r(e);return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}};return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,o=t;for(;n>_a;)n&Ia&&(r=r.add(o)),o=o.double(),n>>=Ia;return r},precomputeWindow(e,t){const{windows:n,windowSize:r}=o(t),i=[];let s=e,a=s;for(let o=0;o<n;o++){a=s,i.push(a);for(let e=1;e<r;e++)a=a.add(s),i.push(a);s=a.double()}return i},wNAF(t,r,i){const{windows:s,windowSize:a}=o(t);let l=e.ZERO,c=e.BASE;const u=BigInt(2**t-1),d=2**t,h=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let o=Number(i&u);i>>=h,o>a&&(o-=d,i+=Ia);const s=t,f=t+Math.abs(o)-1,p=e%2!==0,g=o<0;0===o?c=c.add(n(p,r[s])):l=l.add(n(g,r[f]))}return{p:l,f:c}},wNAFCached(e,t,n){const r=Ca.get(e)||1;let o=xa.get(e);return o||(o=this.precomputeWindow(e,r),1!==r&&xa.set(e,n(o))),this.wNAF(r,o,t)},setWindowSize(e,t){r(t),Ca.set(e,t),xa.delete(e)}}}function Ta(e,t,n,r){if(!Array.isArray(n)||!Array.isArray(r)||r.length!==n.length)throw new Error("arrays of points and scalars must have equal length");r.forEach(((e,n)=>{if(!t.isValid(e))throw new Error(`wrong scalar at index ${n}`)})),n.forEach(((t,n)=>{if(!(t instanceof e))throw new Error(`wrong point at index ${n}`)}));const o=ea(BigInt(n.length)),i=o>12?o-3:o>4?o-2:o?2:1,s=(1<<i)-1,a=new Array(s+1).fill(e.ZERO),l=Math.floor((t.BITS-1)/i)*i;let c=e.ZERO;for(let u=l;u>=0;u-=i){a.fill(e.ZERO);for(let e=0;e<r.length;e++){const t=r[e],o=Number(t>>BigInt(u)&BigInt(s));a[o]=a[o].add(n[e])}let t=e.ZERO;for(let n=a.length-1,r=e.ZERO;n>0;n--)r=r.add(a[n]),t=t.add(r);if(c=c.add(t),0!==u)for(let e=0;e<i;e++)c=c.double()}return c}function Na(e){return function(e){const t=va.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});sa(e,t)}(e.Fp),sa(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ea(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const Pa=BigInt(0),Oa=BigInt(1),La=BigInt(2),Da=BigInt(8),Ba={zip215:!0};function Ua(e){const t=function(e){const t=Na(e);return sa(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:n,n:r,prehash:o,hash:i,randomBytes:s,nByteLength:a,h:l}=t,c=La<<BigInt(8*a)-Oa,u=n.create,d=Sa(t.n,t.nBitLength),h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e*n.inv(t))}}catch(r){return{isValid:!1,value:Pa}}}),f=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,n)=>{if(Us("phflag",n),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){Zs("coordinate "+e,t,Pa,c)}function m(e){if(!(e instanceof w))throw new Error("ExtendedPoint expected")}const y=aa(((e,t)=>{const{ex:r,ey:o,ez:i}=e,s=e.is0();null==t&&(t=s?Da:n.inv(i));const a=u(r*t),l=u(o*t),c=u(i*t);if(s)return{x:Pa,y:Oa};if(c!==Oa)throw new Error("invZ was invalid");return{x:a,y:l}})),b=aa((e=>{const{a:n,d:r}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:o,ey:i,ez:s,et:a}=e,l=u(o*o),c=u(i*i),d=u(s*s),h=u(d*d),f=u(l*n);if(u(d*u(f+c))!==u(h+u(r*u(l*c))))throw new Error("bad point: equation left != right (1)");if(u(o*i)!==u(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class w{constructor(e,t,n,r){this.ex=e,this.ey=t,this.ez=n,this.et=r,g("x",e),g("y",t),g("z",n),g("t",r),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof w)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return g("x",t),g("y",n),new w(t,n,Oa,u(t*n))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(w.fromAffine)}static msm(e,t){return Ta(w,d,e,t)}_setWindowSize(e){S.setWindowSize(this,e)}assertValidity(){b(this)}equals(e){m(e);const{ex:t,ey:n,ez:r}=this,{ex:o,ey:i,ez:s}=e,a=u(t*s),l=u(o*r),c=u(n*s),d=u(i*r);return a===l&&c===d}is0(){return this.equals(w.ZERO)}negate(){return new w(u(-this.ex),this.ey,this.ez,u(-this.et))}double(){const{a:e}=t,{ex:n,ey:r,ez:o}=this,i=u(n*n),s=u(r*r),a=u(La*u(o*o)),l=u(e*i),c=n+r,d=u(u(c*c)-i-s),h=l+s,f=h-a,p=l-s,g=u(d*f),m=u(h*p),y=u(d*p),b=u(f*h);return new w(g,m,b,y)}add(e){m(e);const{a:n,d:r}=t,{ex:o,ey:i,ez:s,et:a}=this,{ex:l,ey:c,ez:d,et:h}=e;if(n===BigInt(-1)){const e=u((i-o)*(c+l)),t=u((i+o)*(c-l)),n=u(t-e);if(n===Pa)return this.double();const r=u(s*La*h),f=u(a*La*d),p=f+r,g=t+e,m=f-r,y=u(p*n),b=u(g*m),v=u(p*m),E=u(n*g);return new w(y,b,E,v)}const f=u(o*l),p=u(i*c),g=u(a*r*h),y=u(s*d),b=u((o+i)*(l+c)-f-p),v=y-g,E=y+g,S=u(p-n*f),k=u(b*v),A=u(E*S),_=u(b*S),I=u(v*E);return new w(k,A,I,_)}subtract(e){return this.add(e.negate())}wNAF(e){return S.wNAFCached(this,e,w.normalizeZ)}multiply(e){const t=e;Zs("scalar",t,Oa,r);const{p:n,f:o}=this.wNAF(t);return w.normalizeZ([n,o])[0]}multiplyUnsafe(e){const t=e;return Zs("scalar",t,Pa,r),t===Pa?E:this.equals(E)||t===Oa?this:this.equals(v)?this.wNAF(t).p:S.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return S.unsafeLadder(this,r).is0()}toAffine(e){return y(this,e)}clearCofactor(){const{h:e}=t;return e===Oa?this:this.multiplyUnsafe(e)}static fromHex(e){let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const{d:o,a:i}=t,s=n.BYTES;e=Ys("pointHex",e,s),Us("zip215",r);const a=e.slice(),l=e[s-1];a[s-1]=-129&l;const d=Ks(a),f=r?c:n.ORDER;Zs("pointHex.y",d,Pa,f);const p=u(d*d),g=u(p-Oa),m=u(o*p-i);let{isValid:y,value:b}=h(g,m);if(!y)throw new Error("Point.fromHex: invalid y coordinate");const v=(b&Oa)===Oa,E=0!==(128&l);if(!r&&b===Pa&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==v&&(b=u(-b)),w.fromAffine({x:b,y:d})}static fromPrivateKey(e){return _(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=Gs(t,n.BYTES);return r[r.length-1]|=e&Oa?128:0,r}toHex(){return Fs(this.toRawBytes())}}w.BASE=new w(t.Gx,t.Gy,Oa,u(t.Gx*t.Gy)),w.ZERO=new w(Pa,Oa,Oa,Pa);const{BASE:v,ZERO:E}=w,S=Ra(w,8*a);function k(e){return ga(e,r)}function A(e){return k(Ks(e))}function _(e){const t=a;e=Ys("private key",e,t);const n=Ys("hashed private key",i(e),2*t),r=f(n.slice(0,t)),o=n.slice(t,2*t),s=A(r),l=v.multiply(s),c=l.toRawBytes();return{head:r,prefix:o,scalar:s,point:l,pointBytes:c}}function I(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Uint8Array;for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];const s=Qs(...n);return A(i(p(s,Ys("context",e),!!o)))}const x=Ba;v._setWindowSize(8);const C={getExtendedPublicKey:_,randomPrivateKey:()=>s(n.BYTES),precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:w.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};return{CURVE:t,getPublicKey:function(e){return _(e).pointBytes},sign:function(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e=Ys("message",e),o&&(e=o(e));const{prefix:s,scalar:l,pointBytes:c}=_(t),u=I(i.context,s,e),d=v.multiply(u).toRawBytes(),h=k(u+I(i.context,d,c,e)*l);return Zs("signature.s",h,Pa,r),Ys("result",Qs(d,Gs(h,n.BYTES)),2*a)},verify:function(e,t,r){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:x;const{context:s,zip215:a}=i,l=n.BYTES;e=Ys("signature",e,2*l),t=Ys("message",t),void 0!==a&&Us("zip215",a),o&&(t=o(t));const c=Ks(e.slice(l,2*l));let u,d,h;try{u=w.fromHex(r,a),d=w.fromHex(e.slice(0,l),a),h=v.multiplyUnsafe(c)}catch(p){return!1}if(!a&&u.isSmallOrder())return!1;const f=I(s,d.toRawBytes(),u.toRawBytes(),t);return d.add(u.multiplyUnsafe(f)).subtract(h).clearCofactor().equals(w.ZERO)},ExtendedPoint:w,utils:C}}const Ma=BigInt(0),Fa=BigInt(1);function $a(e){const t=(sa(n=e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...n}));var n;const{P:r}=t,o=e=>ga(e,r),i=t.montgomeryBits,s=Math.ceil(i/8),a=t.nByteLength,l=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>ma(e,r-BigInt(2),r));function u(e,t,n){const r=o(e*(t-n));return[t=o(t-r),n=o(n+r)]}const d=(t.a-BigInt(2))/BigInt(4);function h(e){return Gs(o(e),s)}function f(e,t){const n=function(e){const t=Ys("u coordinate",e,s);return 32===a&&(t[31]&=127),Ks(t)}(t),f=function(e){const t=Ys("scalar",e),n=t.length;if(n!==s&&n!==a)throw new Error(`Expected ${s} or ${a} bytes, got ${n}`);return Ks(l(t))}(e),p=function(e,t){Zs("u",e,Ma,r),Zs("scalar",t,Ma,r);const n=t,s=e;let a,l=Fa,h=Ma,f=e,p=Fa,g=Ma;for(let r=BigInt(i-1);r>=Ma;r--){const e=n>>r&Fa;g^=e,a=u(g,l,f),l=a[0],f=a[1],a=u(g,h,p),h=a[0],p=a[1],g=e;const t=l+h,i=o(t*t),c=l-h,m=o(c*c),y=i-m,b=f+p,w=o((f-p)*t),v=o(b*c),E=w+v,S=w-v;f=o(E*E),p=o(s*o(S*S)),l=o(i*m),h=o(y*(i+o(d*y)))}a=u(g,l,f),l=a[0],f=a[1],a=u(g,h,p),h=a[0],p=a[1];const m=c(h);return o(l*m)}(n,f);if(p===Ma)throw new Error("Invalid private or public key received");return h(p)}const p=h(t.Gu);function g(e){return f(e,p)}return{scalarMult:f,scalarMultBase:g,getSharedSecret:(e,t)=>f(e,t),getPublicKey:e=>g(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:p}}const Ha=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),qa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),ja=(BigInt(0),BigInt(1)),Va=BigInt(2),za=BigInt(3),Ka=BigInt(5),Wa=BigInt(8);function Ga(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),i=Ha,s=e*e%i*e%i,a=ya(s,Va,i)*s%i,l=ya(a,ja,i)*e%i,c=ya(l,Ka,i)*l%i,u=ya(c,t,i)*c%i,d=ya(u,n,i)*u%i,h=ya(d,r,i)*d%i,f=ya(h,o,i)*h%i,p=ya(f,o,i)*h%i,g=ya(p,t,i)*c%i;return{pow_p_5_8:ya(g,Va,i)*e%i,b2:s}}function Ya(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Qa(e,t){const n=Ha,r=ga(t*t*t,n),o=ga(r*r*t,n);let i=ga(e*r*Ga(e*o).pow_p_5_8,n);const s=ga(t*i*i,n),a=i,l=ga(i*qa,n),c=s===e,u=s===ga(-e,n),d=s===ga(-e*qa,n);return c&&(i=a),(u||d)&&(i=l),((e,t)=>(ga(e,t)&ca)===ca)(i,n)&&(i=ga(-i,n)),{isValid:c||u,value:i}}const Ja=(()=>Sa(Ha,void 0,!0))(),Xa=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ja,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Wa,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Ns,randomBytes:Yn,adjustScalarBytes:Ya,uvRatio:Qa}))(),Za=(()=>Ua(Xa))();const el=(()=>$a({P:Ha,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Ha,{pow_p_5_8:n,b2:r}=Ga(e);return ga(ya(n,za,t)*r,t)},adjustScalarBytes:Ya,randomBytes:Yn}))();const tl=32,nl=64,rl=32;function ol(e,t){const n=new Uint8Array(nl);for(let r=0;r<rl;r++)n[r]=e[r],n[rl+r]=t[r];return n}const il={get(){const e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:globalThis).crypto;if(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}},sl={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function al(e,t){const n=function(e){const t=e?.algorithm??"AES-GCM";let n=e?.keyLength??16;const r=e?.nonceLength??12,o=e?.digest??"SHA-256",i=e?.saltLength??16,s=e?.iterations??32767,a=il.get();return n*=8,{encrypt:async function(e,l){const c=a.getRandomValues(new Uint8Array(i)),u=a.getRandomValues(new Uint8Array(r)),d={name:t,iv:u};let h;if("string"===typeof l&&(l=Dt(l)),0===l.length){h=await a.subtle.importKey("jwk",sl,{name:"AES-GCM"},!0,["encrypt"]);try{const e={name:"PBKDF2",salt:c,iterations:s,hash:{name:o}},r=await a.subtle.importKey("raw",l,{name:"PBKDF2"},!1,["deriveKey"]);h=await a.subtle.deriveKey(e,r,{name:t,length:n},!0,["encrypt"])}catch{h=await a.subtle.importKey("jwk",sl,{name:"AES-GCM"},!0,["encrypt"])}}else{const e={name:"PBKDF2",salt:c,iterations:s,hash:{name:o}},r=await a.subtle.importKey("raw",l,{name:"PBKDF2"},!1,["deriveKey"]);h=await a.subtle.deriveKey(e,r,{name:t,length:n},!0,["encrypt"])}const f=await a.subtle.encrypt(d,h,e);return Br([c,d.iv,new Uint8Array(f)])},decrypt:async function(e,l){const c=e.subarray(0,i),u=e.subarray(i,i+r),d=e.subarray(i+r),h={name:t,iv:u};let f;if("string"===typeof l&&(l=Dt(l)),0===l.length)try{const e={name:"PBKDF2",salt:c,iterations:s,hash:{name:o}},r=await a.subtle.importKey("raw",l,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,r,{name:t,length:n},!0,["decrypt"])}catch{f=await a.subtle.importKey("jwk",sl,{name:"AES-GCM"},!0,["decrypt"])}else{const e={name:"PBKDF2",salt:c,iterations:s,hash:{name:o}},r=await a.subtle.importKey("raw",l,{name:"PBKDF2"},!1,["deriveKey"]);f=await a.subtle.deriveKey(e,r,{name:t,length:n},!0,["decrypt"])}const p=await a.subtle.decrypt(h,f,d);return new Uint8Array(p)}}}(),r=await n.encrypt(e,t);return Te.encode(r)}var ll,cl,ul,dl;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(ll||(ll={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(cl||(cl={})),function(e){e.codec=()=>Cn(cl)}(ll||(ll={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),ll.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.Type=ll.codec().decode(e);break;case 2:n.Data=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(ul||(ul={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.Type&&(t.uint32(8),ll.codec().encode(e.Type,t)),null!=e.Data&&(t.uint32(18),t.bytes(e.Data)),!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.Type=ll.codec().decode(e);break;case 2:n.Data=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(dl||(dl={}));class hl{_key;constructor(e){this._key=bl(e,tl)}verify(e,t){return function(e,t,n){return Za.verify(t,n instanceof Uint8Array?n:n.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return ul.encode({Type:ll.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return vs(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class fl{_key;_publicKey;constructor(e,t){this._key=bl(e,nl),this._publicKey=bl(t,tl)}sign(e){return function(e,t){const n=e.subarray(0,rl);return Za.sign(t instanceof Uint8Array?t:t.subarray(),n)}(this._key,e)}get public(){return new hl(this._publicKey)}marshal(){return this._key}get bytes(){return dl.encode({Type:ll.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}async hash(){const e=vt.digest(this.bytes);let t;return vs(e)?({bytes:t}=await e):t=e.bytes,t}async id(){const e=mt.digest(this.public.bytes);return Ce.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 al(this.bytes,e);throw new ys(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function pl(e){if(e.length>nl){const t=(e=bl(e,nl+tl)).subarray(0,nl),n=e.subarray(nl,e.length);return new fl(t,n)}const t=(e=bl(e,nl)).subarray(0,nl),n=e.subarray(tl);return new fl(t,n)}function gl(e){return e=bl(e,tl),new hl(e)}async function ml(){const{privateKey:e,publicKey:t}=function(){const e=Za.utils.randomPrivateKey(),t=Za.getPublicKey(e);return{privateKey:ol(e,t),publicKey:t}}();return new fl(e,t)}async function yl(e){const{privateKey:t,publicKey:n}=function(e){if(e.length!==rl)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,n=Za.getPublicKey(t);return{privateKey:ol(t,n),publicKey:n}}(e);return new fl(t,n)}function bl(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new ys(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}async function wl(e){const t=[await il.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await El(e)],n=await vl({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function vl(e){if(null==e.privateKey||null==e.publicKey)throw new ys("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([il.get().subtle.exportKey("jwk",e.privateKey),il.get().subtle.exportKey("jwk",e.publicKey)])}async function El(e){return il.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 Sl(e){if("RSA"!==e.kty)throw new ys("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ys("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*Dt(e.n,"base64url").length}class kl extends Kn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Un(e);const n=zn(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 r=this.blockLen,o=new Uint8Array(r);o.set(n.length>r?e.create().update(n).digest():n);for(let i=0;i<o.length;i++)o[i]^=54;this.iHash.update(o),this.oHash=e.create();for(let i=0;i<o.length;i++)o[i]^=106;this.oHash.update(o),o.fill(0)}update(e){return Mn(this),this.iHash.update(e),this}digestInto(e){Mn(this),Bn(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:n,finished:r,destroyed:o,blockLen:i,outputLen:s}=this;return e.finished=r,e.destroyed=o,e.blockLen=i,e.outputLen=s,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Al=(e,t,n)=>new kl(e,t).update(n).digest();function _l(e,t,n,r){Un(e);const o=function(e,t){if(void 0!==t&&"[object Object]"!==Wn.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)}({dkLen:32,asyncTick:10},r),{c:i,dkLen:s,asyncTick:a}=o;if(Dn(i),Dn(s),Dn(a),i<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const l=zn(t),c=zn(n),u=new Uint8Array(s),d=Al.create(e,l),h=d._cloneInto().update(c);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:h}}function Il(e,t,n,r,o){return e.destroy(),t.destroy(),r&&r.destroy(),o.fill(0),n}Al.create=(e,t)=>new kl(e,t);var xl=__webpack_require__(8275);function Cl(e,t){let n=0;if(1===e.length)return e[0];for(let r=e.length-1;r>=0;r--)n+=e[e.length-1-r]*Math.pow(2,t*r);return n}function Rl(e,t){const n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:-1;let r=e,o=0,i=Math.pow(2,t);for(let s=1;s<8;s++){if(e<i){let e;if(n<0)e=new ArrayBuffer(s),o=s;else{if(n<s)return new ArrayBuffer(0);e=new ArrayBuffer(n),o=n}const i=new Uint8Array(e);for(let n=s-1;n>=0;n--){const e=Math.pow(2,n*t);i[o-n-1]=Math.floor(r/e),r-=i[o-n-1]*e}return e}i*=Math.pow(2,t)}return new ArrayBuffer(0)}function Tl(){let e=0,t=0;for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];for(const a of r)e+=a.length;const i=new ArrayBuffer(e),s=new Uint8Array(i);for(const a of r)s.set(a,t),t+=a.length;return s}function Nl(){const e=new Uint8Array(this.valueHex);if(this.valueHex.byteLength>=2){const t=255===e[0]&&128&e[1],n=0===e[0]&&0===(128&e[1]);(t||n)&&this.warnings.push("Needlessly long format")}const t=new ArrayBuffer(this.valueHex.byteLength),n=new Uint8Array(t);for(let s=0;s<this.valueHex.byteLength;s++)n[s]=0;n[0]=128&e[0];const r=Cl(n,8),o=new ArrayBuffer(this.valueHex.byteLength),i=new Uint8Array(o);for(let s=0;s<this.valueHex.byteLength;s++)i[s]=e[s];i[0]&=127;return Cl(i,8)-r}function Pl(e,t){const n=e.toString(10);if(t<n.length)return"";const r=t-n.length,o=new Array(r);for(let i=0;i<r;i++)o[i]="0";return o.join("").concat(n)}Math.log(2);function Ol(){if("undefined"===typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Ll(e){let t=0,n=0;for(let o=0;o<e.length;o++){t+=e[o].byteLength}const r=new Uint8Array(t);for(let o=0;o<e.length;o++){const t=e[o];r.set(new Uint8Array(t),n),n+=t.byteLength}return r.buffer}function Dl(e,t,n,r){return t instanceof Uint8Array?t.byteLength?n<0?(e.error="Wrong parameter: inputOffset less than zero",!1):r<0?(e.error="Wrong parameter: inputLength less than zero",!1):!(t.byteLength-n-r<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 Bl{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Ll(this.items)}}const Ul=[new Uint8Array([1])],Ml="0123456789",Fl="",$l=new ArrayBuffer(0),Hl=new Uint8Array(0),ql="EndOfContent",jl="OCTET STRING",Vl="BIT STRING";function zl(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?xl._H.toUint8Array(t.valueHex):Hl}get valueHex(){return this.valueHexView.slice().buffer}set valueHex(e){this.valueHexView=new Uint8Array(e)}fromBER(e,t,n){const r=e instanceof ArrayBuffer?new Uint8Array(e):e;if(!Dl(this,r,t,n))return-1;const o=t+n;return this.valueHexView=r.subarray(t,o),this.valueHexView.length?(this.blockLength=n,o):(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",$l)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:xl.U$.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}class Kl{constructor(){let{blockLength:e=0,error:t=Fl,warnings:n=[],valueBeforeDecode:r=Hl}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=xl._H.toUint8Array(r)}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:xl.U$.ToHex(this.valueBeforeDecodeView)}}}Kl.NAME="baseBlock";class Wl extends Kl{fromBER(e,t,n){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}toBER(e,t){throw TypeError("User need to make a specific function in a class which extends 'ValueBlock'")}}Wl.NAME="valueBlock";class Gl extends(zl(Kl)){constructor(){let{idBlock:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,n,r,o;super(),e?(this.isHexOnly=null!==(t=e.isHexOnly)&&void 0!==t&&t,this.valueHexView=e.valueHex?xl._H.toUint8Array(e.valueHex):Hl,this.tagClass=null!==(n=e.tagClass)&&void 0!==n?n:-1,this.tagNumber=null!==(r=e.tagNumber)&&void 0!==r?r:-1,this.isConstructed=null!==(o=e.isConstructed)&&void 0!==o&&o):(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",$l}if(this.isConstructed&&(t|=32),this.tagNumber<31&&!this.isHexOnly){const n=new Uint8Array(1);if(!e){let e=this.tagNumber;e&=31,t|=e,n[0]=t}return n.buffer}if(!this.isHexOnly){const n=Rl(this.tagNumber,7),r=new Uint8Array(n),o=n.byteLength,i=new Uint8Array(o+1);if(i[0]=31|t,!e){for(let e=0;e<o-1;e++)i[e+1]=128|r[e];i[o]=r[o-1]}return i.buffer}const n=new Uint8Array(this.valueHexView.byteLength+1);if(n[0]=31|t,!e){const e=this.valueHexView;for(let t=0;t<e.length-1;t++)n[t+1]=128|e[t];n[this.valueHexView.byteLength]=e[e.length-1]}return n.buffer}fromBER(e,t,n){const r=xl._H.toUint8Array(e);if(!Dl(this,r,t,n))return-1;const o=r.subarray(t,t+n);if(0===o.length)return this.error="Zero buffer length",-1;switch(192&o[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&o[0]),this.isHexOnly=!1;const i=31&o[0];if(31!==i)this.tagNumber=i,this.blockLength=1;else{let e=1,t=this.valueHexView=new Uint8Array(255),n=255;for(;128&o[e];){if(t[e-1]=127&o[e],e++,e>=o.length)return this.error="End of input reached before message was fully decoded",-1;if(e===n){n+=255;const e=new Uint8Array(n);for(let n=0;n<t.length;n++)e[n]=t[n];t=this.valueHexView=new Uint8Array(n)}}this.blockLength=e+1,t[e-1]=127&o[e];const r=new Uint8Array(e);for(let o=0;o<e;o++)r[o]=t[o];t=this.valueHexView=new Uint8Array(e),t.set(r),this.blockLength<=9?this.tagNumber=Cl(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}}}Gl.NAME="identificationBlock";class Yl extends Kl{constructor(){let{lenBlock:e={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var t,n,r;super(),this.isIndefiniteForm=null!==(t=e.isIndefiniteForm)&&void 0!==t&&t,this.longFormUsed=null!==(n=e.longFormUsed)&&void 0!==n&&n,this.length=null!==(r=e.length)&&void 0!==r?r:0}fromBER(e,t,n){const r=xl._H.toUint8Array(e);if(!Dl(this,r,t,n))return-1;const o=r.subarray(t,t+n);if(0===o.length)return this.error="Zero buffer length",-1;if(255===o[0])return this.error="Length block 0xFF is reserved by standard",-1;if(this.isIndefiniteForm=128===o[0],this.isIndefiniteForm)return this.blockLength=1,t+this.blockLength;if(this.longFormUsed=!!(128&o[0]),!1===this.longFormUsed)return this.length=o[0],this.blockLength=1,t+this.blockLength;const i=127&o[0];if(i>8)return this.error="Too big integer",-1;if(i+1>o.length)return this.error="End of input reached before message was fully decoded",-1;const s=t+1,a=r.subarray(s,s+i);return 0===a[i-1]&&this.warnings.push("Needlessly long encoded length"),this.length=Cl(a,8),this.longFormUsed&&this.length<=127&&this.warnings.push("Unnecessary usage of long length form"),this.blockLength=i+1,t+this.blockLength}toBER(){let e,t,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(this.length>127&&(this.longFormUsed=!0),this.isIndefiniteForm)return e=new ArrayBuffer(1),!1===n&&(t=new Uint8Array(e),t[0]=128),e;if(this.longFormUsed){const r=Rl(this.length,8);if(r.byteLength>127)return this.error="Too big length",$l;if(e=new ArrayBuffer(r.byteLength+1),n)return e;const o=new Uint8Array(r);t=new Uint8Array(e),t[0]=128|r.byteLength;for(let e=0;e<r.byteLength;e++)t[e+1]=o[e];return e}return e=new ArrayBuffer(1),!1===n&&(t=new Uint8Array(e),t[0]=this.length),e}toJSON(){return{...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,longFormUsed:this.longFormUsed,length:this.length}}}Yl.NAME="lengthBlock";const Ql={};class Jl extends Kl{constructor(){let{name:e=Fl,optional:t=!1,primitiveSchema:n,...r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=arguments.length>1?arguments[1]:void 0;super(r),this.name=e,this.optional=t,n&&(this.primitiveSchema=n),this.idBlock=new Gl(r),this.lenBlock=new Yl(r),this.valueBlock=o?new o(r):new Wl(r)}fromBER(e,t,n){const r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return-1===r?(this.error=this.valueBlock.error,r):(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),r)}toBER(e,t){const n=t||new Bl;t||Xl(this);const r=this.idBlock.toBER(e);if(n.write(r),this.lenBlock.isIndefiniteForm)n.write(new Uint8Array([128]).buffer),this.valueBlock.toBER(e,n),n.write(new ArrayBuffer(2));else{const t=this.valueBlock.toBER(e);this.lenBlock.length=t.byteLength;const r=this.lenBlock.toBER(e);n.write(r),n.write(t)}return t?$l:n.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():xl.U$.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${xl.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 n=new Uint8Array(e),r=new Uint8Array(t);for(let o=0;o<n.length;o++)if(n[o]!==r[o])return!1;return!0}(this.toBER(),e.toBER())}}function Xl(e){if(e instanceof Ql.Constructed)for(const t of e.valueBlock.value)Xl(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock.isIndefiniteForm}Jl.NAME="BaseBlock";class Zl extends Jl{constructor(){let{value:e=Fl,...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,n){const r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return-1===r?(this.error=this.valueBlock.error,r):(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),r)}onAsciiEncoding(){return`${this.constructor.NAME} : '${this.valueBlock.value}'`}}Zl.NAME="BaseStringBlock";class ec extends(zl(Wl)){constructor(){let{isHexOnly:e=!0,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.isHexOnly=e}}var tc,nc,rc,oc,ic,sc,ac,lc,cc,uc,dc,hc,fc,pc,gc,mc,yc,bc,wc,vc,Ec,Sc,kc,Ac,_c,Ic,xc,Cc,Rc,Tc,Nc,Pc,Oc;ec.NAME="PrimitiveValueBlock";class Lc extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},ec),this.idBlock.isConstructed=!1}}function Dc(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.length;const r=t;let o=new Jl({},Wl);const i=new Kl;if(!Dl(i,e,t,n))return o.error=i.error,{offset:-1,result:o};if(!e.subarray(t,t+n).length)return o.error="Zero buffer length",{offset:-1,result:o};let s=o.idBlock.fromBER(e,t,n);if(o.idBlock.warnings.length&&o.warnings.concat(o.idBlock.warnings),-1===s)return o.error=o.idBlock.error,{offset:-1,result:o};if(t=s,n-=o.idBlock.blockLength,s=o.lenBlock.fromBER(e,t,n),o.lenBlock.warnings.length&&o.warnings.concat(o.lenBlock.warnings),-1===s)return o.error=o.lenBlock.error,{offset:-1,result:o};if(t=s,n-=o.lenBlock.blockLength,!o.idBlock.isConstructed&&o.lenBlock.isIndefiniteForm)return o.error="Indefinite length form used for primitive encoding form",{offset:-1,result:o};let a=Jl;if(1===o.idBlock.tagClass){if(o.idBlock.tagNumber>=37&&!1===o.idBlock.isHexOnly)return o.error="UNIVERSAL 37 and upper tags are reserved by ASN.1 standard",{offset:-1,result:o};switch(o.idBlock.tagNumber){case 0:if(o.idBlock.isConstructed&&o.lenBlock.length>0)return o.error="Type [UNIVERSAL 0] is reserved",{offset:-1,result:o};a=Ql.EndOfContent;break;case 1:a=Ql.Boolean;break;case 2:a=Ql.Integer;break;case 3:a=Ql.BitString;break;case 4:a=Ql.OctetString;break;case 5:a=Ql.Null;break;case 6:a=Ql.ObjectIdentifier;break;case 10:a=Ql.Enumerated;break;case 12:a=Ql.Utf8String;break;case 13:a=Ql.RelativeObjectIdentifier;break;case 14:a=Ql.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:a=Ql.Sequence;break;case 17:a=Ql.Set;break;case 18:a=Ql.NumericString;break;case 19:a=Ql.PrintableString;break;case 20:a=Ql.TeletexString;break;case 21:a=Ql.VideotexString;break;case 22:a=Ql.IA5String;break;case 23:a=Ql.UTCTime;break;case 24:a=Ql.GeneralizedTime;break;case 25:a=Ql.GraphicString;break;case 26:a=Ql.VisibleString;break;case 27:a=Ql.GeneralString;break;case 28:a=Ql.UniversalString;break;case 29:a=Ql.CharacterString;break;case 30:a=Ql.BmpString;break;case 31:a=Ql.DATE;break;case 32:a=Ql.TimeOfDay;break;case 33:a=Ql.DateTime;break;case 34:a=Ql.Duration;break;default:{const e=o.idBlock.isConstructed?new Ql.Constructed:new Ql.Primitive;e.idBlock=o.idBlock,e.lenBlock=o.lenBlock,e.warnings=o.warnings,o=e}}}else a=o.idBlock.isConstructed?Ql.Constructed:Ql.Primitive;return o=function(e,t){if(e instanceof t)return e;const n=new t;return n.idBlock=e.idBlock,n.lenBlock=e.lenBlock,n.warnings=e.warnings,n.valueBeforeDecodeView=e.valueBeforeDecodeView,n}(o,a),s=o.fromBER(e,t,o.lenBlock.isIndefiniteForm?n:o.lenBlock.length),o.valueBeforeDecodeView=e.subarray(r,r+o.blockLength),{offset:s,result:o}}function Bc(e){if(!e.byteLength){const e=new Jl({},Wl);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Dc(xl._H.toUint8Array(e).slice(),0,e.byteLength)}tc=Lc,Ql.Primitive=tc,Lc.NAME="PRIMITIVE";class Uc extends Wl{constructor(){let{value:e=[],isIndefiniteForm:t=!1,...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(n),this.value=e,this.isIndefiniteForm=t}fromBER(e,t,n){const r=xl._H.toUint8Array(e);if(!Dl(this,r,t,n))return-1;if(this.valueBeforeDecodeView=r.subarray(t,t+n),0===this.valueBeforeDecodeView.length)return this.warnings.push("Zero buffer length"),t;let o=t;for(;i=this.isIndefiniteForm,s=n,(i?1:s)>0;){const e=Dc(r,o,n);if(-1===e.offset)return this.error=e.result.error,this.warnings.concat(e.result.warnings),-1;if(o=e.offset,this.blockLength+=e.result.blockLength,n-=e.result.blockLength,this.value.push(e.result),this.isIndefiniteForm&&e.result.constructor.NAME===ql)break}var i,s;return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===ql?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){const n=t||new Bl;for(let r=0;r<this.value.length;r++)this.value[r].toBER(e,n);return t?$l:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}Uc.NAME="ConstructedValueBlock";class Mc extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Uc),this.idBlock.isConstructed=!0}fromBER(e,t,n){this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm;const r=this.valueBlock.fromBER(e,t,this.lenBlock.isIndefiniteForm?n:this.lenBlock.length);return-1===r?(this.error=this.valueBlock.error,r):(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),r)}onAsciiEncoding(){const e=[];for(const n of this.valueBlock.value)e.push(n.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} :`}}nc=Mc,Ql.Constructed=nc,Mc.NAME="CONSTRUCTED";class Fc extends Wl{fromBER(e,t,n){return t}toBER(e){return $l}}Fc.override="EndOfContentValueBlock";class $c extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Fc),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}rc=$c,Ql.EndOfContent=rc,$c.NAME=ql;class Hc extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Wl),this.idBlock.tagClass=1,this.idBlock.tagNumber=5}fromBER(e,t,n){return this.lenBlock.length>0&&this.warnings.push("Non-zero length of value block for Null type"),this.idBlock.error.length||(this.blockLength+=this.idBlock.blockLength),this.lenBlock.error.length||(this.blockLength+=this.lenBlock.blockLength),this.blockLength+=n,t+n>e.byteLength?(this.error="End of input reached before message was fully decoded (inconsistent offset and length values)",-1):t+n}toBER(e,t){const n=new ArrayBuffer(2);if(!e){const e=new Uint8Array(n);e[0]=5,e[1]=0}return t&&t.write(n),n}onAsciiEncoding(){return`${this.constructor.NAME}`}}oc=Hc,Ql.Null=oc,Hc.NAME="NULL";class qc extends(zl(Wl)){constructor(){let{value:e,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),t.valueHex?this.valueHexView=xl._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,n){const r=xl._H.toUint8Array(e);return Dl(this,r,t,n)?(this.valueHexView=r.subarray(t,t+n),n>1&&this.warnings.push("Boolean value encoded in more then 1 octet"),this.isHexOnly=!0,Nl.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}qc.NAME="BooleanValueBlock";class jc extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},qc),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}`}}ic=jc,Ql.Boolean=ic,jc.NAME="BOOLEAN";class Vc extends(zl(Uc)){constructor(){let{isConstructed:e=!1,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.isConstructed=e}fromBER(e,t,n){let r=0;if(this.isConstructed){if(this.isHexOnly=!1,r=Uc.prototype.fromBER.call(this,e,t,n),-1===r)return r;for(let e=0;e<this.value.length;e++){const t=this.value[e].constructor.NAME;if(t===ql){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==jl)return this.error="OCTET STRING may consists of OCTET STRINGs only",-1}}else this.isHexOnly=!0,r=super.fromBER(e,t,n),this.blockLength=n;return r}toBER(e,t){return this.isConstructed?Uc.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Vc.NAME="OctetStringValueBlock";class zc extends Jl{constructor(){let{idBlock:e={},lenBlock:t={},...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var r,o;null!==(r=n.isConstructed)&&void 0!==r||(n.isConstructed=!!(null===(o=n.value)||void 0===o?void 0:o.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Vc),this.idBlock.tagClass=1,this.idBlock.tagNumber=4}fromBER(e,t,n){if(this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,0===n)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 o=(e instanceof ArrayBuffer?new Uint8Array(e):e).subarray(t,t+n);try{if(o.byteLength){const e=Dc(o,0,o.byteLength);-1!==e.offset&&e.offset===n&&(this.valueBlock.value=[e.result])}}catch(r){}}return super.fromBER(e,t,n)}onAsciiEncoding(){return this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length?Mc.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${xl.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 zc&&e.push(t.valueBlock.valueHexView);return xl._H.concat(e)}}sc=zc,Ql.OctetString=sc,zc.NAME=jl;class Kc extends(zl(Uc)){constructor(){let{unusedBits:e=0,isConstructed:t=!1,...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(n),this.unusedBits=e,this.isConstructed=t,this.blockLength=this.valueHexView.byteLength}fromBER(e,t,n){if(!n)return t;let r=-1;if(this.isConstructed){if(r=Uc.prototype.fromBER.call(this,e,t,n),-1===r)return r;for(const e of this.value){const t=e.constructor.NAME;if(t===ql){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==Vl)return this.error="BIT STRING may consists of BIT STRINGs only",-1;const n=e.valueBlock;if(this.unusedBits>0&&n.unusedBits>0)return this.error='Using of "unused bits" inside constructive BIT STRING allowed for least one only',-1;this.unusedBits=n.unusedBits}return r}const o=xl._H.toUint8Array(e);if(!Dl(this,o,t,n))return-1;const i=o.subarray(t,t+n);if(this.unusedBits=i[0],this.unusedBits>7)return this.error="Unused bits for BitString must be in range 0-7",-1;if(!this.unusedBits){const e=i.subarray(1);try{if(e.byteLength){const t=Dc(e,0,e.byteLength);-1!==t.offset&&t.offset===n-1&&(this.value=[t.result])}}catch(s){}}return this.valueHexView=i.subarray(1),this.blockLength=i.length,t+n}toBER(e,t){if(this.isConstructed)return Uc.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return $l;const n=new Uint8Array(this.valueHexView.length+1);return n[0]=this.unusedBits,n.set(this.valueHexView,1),n.buffer}toJSON(){return{...super.toJSON(),unusedBits:this.unusedBits,isConstructed:this.isConstructed}}}Kc.NAME="BitStringValueBlock";class Wc extends Jl{constructor(){let{idBlock:e={},lenBlock:t={},...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};var r,o;null!==(r=n.isConstructed)&&void 0!==r||(n.isConstructed=!!(null===(o=n.value)||void 0===o?void 0:o.length)),super({idBlock:{isConstructed:n.isConstructed,...e},lenBlock:{...t,isIndefiniteForm:!!n.isIndefiniteForm},...n},Kc),this.idBlock.tagClass=1,this.idBlock.tagNumber=3}fromBER(e,t,n){return this.valueBlock.isConstructed=this.idBlock.isConstructed,this.valueBlock.isIndefiniteForm=this.lenBlock.isIndefiniteForm,super.fromBER(e,t,n)}onAsciiEncoding(){if(this.valueBlock.isConstructed||this.valueBlock.value&&this.valueBlock.value.length)return Mc.prototype.onAsciiEncoding.call(this);{const e=[],t=this.valueBlock.valueHexView;for(const r of t)e.push(r.toString(2).padStart(8,"0"));const n=e.join("");return`${this.constructor.NAME} : ${n.substring(0,n.length-this.valueBlock.unusedBits)}`}}}function Gc(e,t){const n=new Uint8Array([0]),r=new Uint8Array(e),o=new Uint8Array(t);let i=r.slice(0);const s=i.length-1,a=o.slice(0),l=a.length-1;let c=0;let u=0;for(let d=l<s?s:l;d>=0;d--,u++){if(!0===u<a.length)c=i[s-u]+a[l-u]+n[0];else c=i[s-u]+n[0];if(n[0]=c/10,!0===u>=i.length)i=Tl(new Uint8Array([c%10]),i);else i[s-u]=c%10}return n[0]>0&&(i=Tl(n,i)),i}function Yc(e){if(e>=Ul.length)for(let t=Ul.length;t<=e;t++){const e=new Uint8Array([0]);let n=Ul[t-1].slice(0);for(let t=n.length-1;t>=0;t--){const r=new Uint8Array([(n[t]<<1)+e[0]]);e[0]=r[0]/10,n[t]=r[0]%10}e[0]>0&&(n=Tl(e,n)),Ul.push(n)}return Ul[e]}function Qc(e,t){let n=0;const r=new Uint8Array(e),o=new Uint8Array(t),i=r.slice(0),s=i.length-1,a=o.slice(0),l=a.length-1;let c,u=0;for(let d=l;d>=0;d--,u++)if(c=i[s-u]-a[l-u]-n,!0===c<0)n=1,i[s-u]=c+10;else n=0,i[s-u]=c;if(n>0)for(let d=s-l+1;d>=0;d--,u++){if(c=i[s-u]-n,!(c<0)){n=0,i[s-u]=c;break}n=1,i[s-u]=c+10}return i.slice()}ac=Wc,Ql.BitString=ac,Wc.NAME=Vl;class Jc extends(zl(Wl)){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=Nl.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 n=128;for(let r=1;r<8;r++){if(t<=n){if(e<0){const e=Rl(n-t,8,r);return new Uint8Array(e)[0]|=128,e}let o=Rl(t,8,r),i=new Uint8Array(o);if(128&i[0]){const e=o.slice(0),t=new Uint8Array(e);o=new ArrayBuffer(o.byteLength+1),i=new Uint8Array(o);for(let n=0;n<e.byteLength;n++)i[n+1]=t[n];i[0]=0}return o}n*=Math.pow(2,8)}return new ArrayBuffer(0)}(e))}get valueDec(){return this._valueDec}fromDER(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0;const o=this.fromBER(e,t,n);if(-1===o)return o;const i=this.valueHexView;return 0===i[0]&&0!==(128&i[1])?this.valueHexView=i.subarray(1):0!==r&&i.length<r&&(r-i.length>1&&(r=i.length+1),this.valueHexView=i.subarray(r-i.length)),o}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,n){const r=super.fromBER(e,t,n);return-1===r||this.setValueHex(),r}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,n=new Uint8Array(8*this.valueHexView.length/3),r=0;const o=this.valueHexView;let i="",s=!1;for(let a=o.byteLength-1;a>=0;a--){t=o[a];for(let o=0;o<8;o++){if(1===(1&t))if(r===e)n=Qc(Yc(r),n),i="-";else n=Gc(n,Yc(r));r++,t>>=1}}for(let a=0;a<n.length;a++)n[a]&&(s=!0),s&&(i+=Ml.charAt(n[a]));return!1===s&&(i+=Ml.charAt(0)),i}}lc=Jc,Jc.NAME="IntegerValueBlock",Object.defineProperty(lc.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class Xc extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Jc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Ol(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Ol();const t=BigInt(e),n=new Bl,r=t.toString(16).replace(/^-/,""),o=new Uint8Array(xl.U$.FromHex(r));if(t<0){const e=new Uint8Array(o.length+(128&o[0]?1:0));e[0]|=128;const r=BigInt(`0x${xl.U$.ToHex(e)}`)+t,i=xl._H.toUint8Array(xl.U$.FromHex(r.toString(16)));i[0]|=128,n.write(i)}else 128&o[0]&&n.write(new Uint8Array([0])),n.write(o);return new Xc({valueHex:n.final()})}convertToDER(){const e=new Xc({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Xc({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}cc=Xc,Ql.Integer=cc,Xc.NAME="INTEGER";class Zc extends Xc{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}uc=Zc,Ql.Enumerated=uc,Zc.NAME="ENUMERATED";class eu extends(zl(Wl)){constructor(){let{valueDec:e=-1,isFirstSid:t=!1,...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(n),this.valueDec=e,this.isFirstSid=t}fromBER(e,t,n){if(!n)return t;const r=xl._H.toUint8Array(e);if(!Dl(this,r,t,n))return-1;const o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let s=0;s<n&&(this.valueHexView[s]=127&o[s],this.blockLength++,0!==(128&o[s]));s++);const i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength;s++)i[s]=this.valueHexView[s];return this.valueHexView=i,0!==(128&o[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=Cl(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Ol();let t=BigInt(e).toString(2);for(;t.length%7;)t="0"+t;const n=new Uint8Array(t.length/7);for(let r=0;r<n.length;r++)n[r]=parseInt(t.slice(7*r,7*r+7),2)+(r+1<n.length?128:0);this.fromBER(n.buffer,0,n.length)}toBER(e){if(this.isHexOnly){if(e)return new ArrayBuffer(this.valueHexView.byteLength);const t=this.valueHexView,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=128|t[e];return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}const t=Rl(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",$l;const n=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=128|e[t];n[r]=e[r]}return n}toString(){let e="";if(this.isHexOnly)e=xl.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}}}eu.NAME="sidBlock";class tu extends Wl{constructor(){let{value:e=Fl,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){const t=new eu;if(r=t.fromBER(e,r,n),-1===r)return this.blockLength=0,this.error=t.error,r;0===this.value.length&&(t.isFirstSid=!0),this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e){const t=[];for(let n=0;n<this.value.length;n++){const r=this.value[n].toBER(e);if(0===r.byteLength)return this.error=this.value[n].error,$l;t.push(r)}return Ll(t)}fromString(e){this.value=[];let t=0,n=0,r="",o=!1;do{if(n=e.indexOf(".",t),r=-1===n?e.substring(t):e.substring(t,n),t=n+1,o){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 n=parseInt(r,10);if(isNaN(n))return;e.valueDec=n+t,o=!1}else{const e=new eu;if(r>Number.MAX_SAFE_INTEGER){Ol();const t=BigInt(r);e.valueBigInt=t}else if(e.valueDec=parseInt(r,10),isNaN(e.valueDec))return;this.value.length||(e.isFirstSid=!0,o=!0),this.value.push(e)}}while(-1!==n)}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();0!==n&&(e=`${e}.`),t?(r=`{${r}}`,this.value[n].isFirstSid?e=`2.{${r} - 80}`:e+=r):e+=r}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}}tu.NAME="ObjectIdentifierValueBlock";class nu extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},tu),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()}}}dc=nu,Ql.ObjectIdentifier=dc,nu.NAME="OBJECT IDENTIFIER";class ru extends(zl(Kl)){constructor(){let{valueDec:e=0,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.valueDec=e}fromBER(e,t,n){if(0===n)return t;const r=xl._H.toUint8Array(e);if(!Dl(this,r,t,n))return-1;const o=r.subarray(t,t+n);this.valueHexView=new Uint8Array(n);for(let s=0;s<n&&(this.valueHexView[s]=127&o[s],this.blockLength++,0!==(128&o[s]));s++);const i=new Uint8Array(this.blockLength);for(let s=0;s<this.blockLength;s++)i[s]=this.valueHexView[s];return this.valueHexView=i,0!==(128&o[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=Cl(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,n=new Uint8Array(this.blockLength);for(let e=0;e<this.blockLength-1;e++)n[e]=128|t[e];return n[this.blockLength-1]=t[this.blockLength-1],n.buffer}const t=Rl(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",$l;const n=new Uint8Array(t.byteLength);if(!e){const e=new Uint8Array(t),r=t.byteLength-1;for(let t=0;t<r;t++)n[t]=128|e[t];n[r]=e[r]}return n.buffer}toString(){let e="";return e=this.isHexOnly?xl.U$.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}ru.NAME="relativeSidBlock";class ou extends Wl{constructor(){let{value:e=Fl,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.value=[],e&&this.fromString(e)}fromBER(e,t,n){let r=t;for(;n>0;){const t=new ru;if(r=t.fromBER(e,r,n),-1===r)return this.blockLength=0,this.error=t.error,r;this.blockLength+=t.blockLength,n-=t.blockLength,this.value.push(t)}return r}toBER(e,t){const n=[];for(let r=0;r<this.value.length;r++){const t=this.value[r].toBER(e);if(0===t.byteLength)return this.error=this.value[r].error,$l;n.push(t)}return Ll(n)}fromString(e){this.value=[];let t=0,n=0,r="";do{n=e.indexOf(".",t),r=-1===n?e.substring(t):e.substring(t,n),t=n+1;const o=new ru;if(o.valueDec=parseInt(r,10),isNaN(o.valueDec))return!0;this.value.push(o)}while(-1!==n);return!0}toString(){let e="",t=!1;for(let n=0;n<this.value.length;n++){t=this.value[n].isHexOnly;let r=this.value[n].toString();0!==n&&(e=`${e}.`),t?(r=`{${r}}`,e+=r):e+=r}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}}ou.NAME="RelativeObjectIdentifierValueBlock";class iu extends Jl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},ou),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()}}}hc=iu,Ql.RelativeObjectIdentifier=hc,iu.NAME="RelativeObjectIdentifier";class su extends Mc{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}fc=su,Ql.Sequence=fc,su.NAME="SEQUENCE";class au extends Mc{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}pc=au,Ql.Set=pc,au.NAME="SET";class lu extends(zl(Wl)){constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.isHexOnly=!0,this.value=Fl}toJSON(){return{...super.toJSON(),value:this.value}}}lu.NAME="StringValueBlock";class cu extends lu{}cu.NAME="SimpleStringValueBlock";class uu extends Zl{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e,cu)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,xl._H.toUint8Array(e))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=e.charCodeAt(r);this.valueBlock.value=e}}uu.NAME="SIMPLE STRING";class du extends uu{fromBuffer(e){this.valueBlock.valueHexView=xl._H.toUint8Array(e);try{this.valueBlock.value=xl.U$.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=xl.U$.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(xl.U$.FromUtf8String(e)),this.valueBlock.value=e}}du.NAME="Utf8StringValueBlock";class hu extends du{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}gc=hu,Ql.Utf8String=gc,hu.NAME="UTF8String";class fu extends uu{fromBuffer(e){this.valueBlock.value=xl.U$.ToUtf16String(e),this.valueBlock.valueHexView=xl._H.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(xl.U$.FromUtf16String(e))}}fu.NAME="BmpStringValueBlock";class pu extends fu{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}mc=pu,Ql.BmpString=mc,pu.NAME="BMPString";class gu extends uu{fromBuffer(e){const t=ArrayBuffer.isView(e)?e.slice().buffer:e.slice(0),n=new Uint8Array(t);for(let r=0;r<n.length;r+=4)n[r]=n[r+3],n[r+1]=n[r+2],n[r+2]=0,n[r+3]=0;this.valueBlock.value=String.fromCharCode.apply(null,new Uint32Array(t))}fromString(e){const t=e.length,n=this.valueBlock.valueHexView=new Uint8Array(4*t);for(let r=0;r<t;r++){const t=Rl(e.charCodeAt(r),8),o=new Uint8Array(t);if(o.length>4)continue;const i=4-o.length;for(let e=o.length-1;e>=0;e--)n[4*r+e+i]=o[e]}this.valueBlock.value=e}}gu.NAME="UniversalStringValueBlock";class mu extends gu{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}yc=mu,Ql.UniversalString=yc,mu.NAME="UniversalString";class yu extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}bc=yu,Ql.NumericString=bc,yu.NAME="NumericString";class bu extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}wc=bu,Ql.PrintableString=wc,bu.NAME="PrintableString";class wu extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}vc=wu,Ql.TeletexString=vc,wu.NAME="TeletexString";class vu extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}Ec=vu,Ql.VideotexString=Ec,vu.NAME="VideotexString";class Eu extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}Sc=Eu,Ql.IA5String=Sc,Eu.NAME="IA5String";class Su extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}kc=Su,Ql.GraphicString=kc,Su.NAME="GraphicString";class ku extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Ac=ku,Ql.VisibleString=Ac,ku.NAME="VisibleString";class Au extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}_c=Au,Ql.GeneralString=_c,Au.NAME="GeneralString";class _u extends uu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}Ic=_u,Ql.CharacterString=Ic,_u.NAME="CharacterString";class Iu extends ku{constructor(){let{value:e,valueDate:t,...n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(super(n),this.year=0,this.month=0,this.day=0,this.hour=0,this.minute=0,this.second=0,e){this.fromString(e),this.valueBlock.valueHexView=new Uint8Array(e.length);for(let 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,xl._H.toUint8Array(e)))}toBuffer(){const e=this.toString(),t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);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 n=parseInt(t[1],10);this.year=n>=50?1900+n:2e3+n,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]=Pl(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Pl(this.month,2),e[2]=Pl(this.day,2),e[3]=Pl(this.hour,2),e[4]=Pl(this.minute,2),e[5]=Pl(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}}}xc=Iu,Ql.UTCTime=xc,Iu.NAME="UTCTime";class xu extends Iu{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,n=!1,r="",o="",i=0,s=0,a=0;if("Z"===e[e.length-1])r=e.substring(0,e.length-1),n=!0;else{const t=new Number(e[e.length-1]);if(isNaN(t.valueOf()))throw new Error("Wrong input string for conversion");r=e}if(n){if(-1!==r.indexOf("+"))throw new Error("Wrong input string for conversion");if(-1!==r.indexOf("-"))throw new Error("Wrong input string for conversion")}else{let e=1,t=r.indexOf("+"),n="";if(-1===t&&(t=r.indexOf("-"),e=-1),-1!==t){if(n=r.substring(t+1),r=r.substring(0,t),2!==n.length&&4!==n.length)throw new Error("Wrong input string for conversion");let o=parseInt(n.substring(0,2),10);if(isNaN(o.valueOf()))throw new Error("Wrong input string for conversion");if(s=e*o,4===n.length){if(o=parseInt(n.substring(2,4),10),isNaN(o.valueOf()))throw new Error("Wrong input string for conversion");a=e*o}}}let l=r.indexOf(".");if(-1===l&&(l=r.indexOf(",")),-1!==l){const e=new Number(`0${r.substring(l)}`);if(isNaN(e.valueOf()))throw new Error("Wrong input string for conversion");i=e.valueOf(),o=r.substring(0,l)}else o=r;switch(!0){case 8===o.length:if(t=/(\d{4})(\d{2})(\d{2})/gi,-1!==l)throw new Error("Wrong input string for conversion");break;case 10===o.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})/gi,-1!==l){let e=60*i;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===o.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==l){let e=60*i;this.second=Math.floor(e),e=1e3*(e-this.second),this.millisecond=Math.floor(e)}break;case 14===o.length:if(t=/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/gi,-1!==l){const e=1e3*i;this.millisecond=Math.floor(e)}break;default:throw new Error("Wrong input string for conversion")}const c=t.exec(o);if(null===c)throw new Error("Wrong input string for conversion");for(let u=1;u<c.length;u++)switch(u){case 1:this.year=parseInt(c[u],10);break;case 2:this.month=parseInt(c[u],10);break;case 3:this.day=parseInt(c[u],10);break;case 4:this.hour=parseInt(c[u],10)+s;break;case 5:this.minute=parseInt(c[u],10)+a;break;case 6:this.second=parseInt(c[u],10);break;default:throw new Error("Wrong input string for conversion")}if(!1===n){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(Pl(this.year,4)),e.push(Pl(this.month,2)),e.push(Pl(this.day,2)),e.push(Pl(this.hour,2)),e.push(Pl(this.minute,2)),e.push(Pl(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(Pl(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}Cc=xu,Ql.GeneralizedTime=Cc,xu.NAME="GeneralizedTime";class Cu extends hu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Rc=Cu,Ql.DATE=Rc,Cu.NAME="DATE";class Ru extends hu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}Tc=Ru,Ql.TimeOfDay=Tc,Ru.NAME="TimeOfDay";class Tu extends hu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Nc=Tu,Ql.DateTime=Nc,Tu.NAME="DateTime";class Nu extends hu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Pc=Nu,Ql.Duration=Pc,Nu.NAME="Duration";class Pu extends hu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Oc=Pu,Ql.TIME=Oc,Pu.NAME="TIME";function Ou(e){if(isNaN(e)||e<=0)throw new ys("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Yn(e)}function Lu(e){let t=e.toString(16);t.length%2>0&&(t=`0${t}`);const n=t.length/2,r=new Uint8Array(n);let o=0,i=0;for(;o<n;)r[o]=parseInt(t.slice(i,i+2),16),o+=1,i+=2;return r}function Du(e){const t=[];return e.forEach((function(e){let n=e.toString(16);n.length%2>0&&(n=`0${n}`),t.push(n)})),BigInt("0x"+t.join(""))}const Bu=1e4;async function Uu(e,t){const n=il.get(),r=new su({value:[new Xc({value:0}),new su({value:[new nu({value:"1.2.840.113549.1.1.1"}),new Hc]}),new zc({valueHex:e.marshal()})]}).toBER(),o=new Uint8Array(r,0,r.byteLength),i=Ou(16),s=await async function(e,t,n,r){const{c:o,dkLen:i,asyncTick:s,DK:a,PRF:l,PRFSalt:c}=_l(e,t,n,r);let u;const d=new Uint8Array(4),h=Hn(d),f=new Uint8Array(l.outputLen);for(let p=1,g=0;g<i;p++,g+=l.outputLen){const e=a.subarray(g,g+l.outputLen);h.setInt32(0,p,!1),(u=c._cloneInto(u)).update(d).digestInto(f),e.set(f.subarray(0,e.length)),await Vn(o-1,s,(()=>{l._cloneInto(u).update(f).digestInto(f);for(let t=0;t<e.length;t++)e[t]^=f[t]}))}return Il(l,c,a,u,f)}(Ns,t,i,{c:Bu,dkLen:32}),a=Ou(16),l=await n.subtle.importKey("raw",s,"AES-CBC",!1,["encrypt"]),c=await n.subtle.encrypt({name:"AES-CBC",iv:a},l,o),u=new su({value:[new zc({valueHex:i}),new Xc({value:Bu}),new Xc({value:32}),new su({value:[new nu({value:"1.2.840.113549.2.11"}),new Hc]})]}),d=new su({value:[new nu({value:"1.2.840.113549.1.5.13"}),new su({value:[new su({value:[new nu({value:"1.2.840.113549.1.5.12"}),u]}),new su({value:[new nu({value:"2.16.840.1.101.3.4.1.42"}),new zc({valueHex:a})]})]})]}),h=new su({value:[d,new zc({valueHex:c})]}).toBER();return["-----BEGIN ENCRYPTED PRIVATE KEY-----",...dr(new Uint8Array(h,0,h.byteLength),"base64pad").split(/(.{64})/).filter(Boolean),"-----END ENCRYPTED PRIVATE KEY-----"].join("\n")}const Mu=8192;class Fu{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,n){const r=await il.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return il.get().subtle.verify({name:"RSASSA-PKCS1-v1_5"},r,t,n instanceof Uint8Array?n:n.subarray())}(this._key,t,e)}marshal(){return function(e){if(null==e.n||null==e.e)throw new ys("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new su({value:[new su({value:[new nu({value:"1.2.840.113549.1.1.1"}),new Hc]}),new Wc({valueHex:new su({value:[Xc.fromBigInt(Du(Dt(e.n,"base64url"))),Xc.fromBigInt(Du(Dt(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return ul.encode({Type:ll.RSA,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return vs(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class $u{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Ou(16)}sign(e){return async function(e,t){const n=await il.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=await il.get().subtle.sign({name:"RSASSA-PKCS1-v1_5"},n,t instanceof Uint8Array?t:t.subarray());return new Uint8Array(r,0,r.byteLength)}(this._key,e)}get public(){if(null==this._publicKey)throw new ys("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Fu(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 ys("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new su({value:[new Xc({value:0}),Xc.fromBigInt(Du(Dt(e.n,"base64url"))),Xc.fromBigInt(Du(Dt(e.e,"base64url"))),Xc.fromBigInt(Du(Dt(e.d,"base64url"))),Xc.fromBigInt(Du(Dt(e.p,"base64url"))),Xc.fromBigInt(Du(Dt(e.q,"base64url"))),Xc.fromBigInt(Du(Dt(e.dp,"base64url"))),Xc.fromBigInt(Du(Dt(e.dq,"base64url"))),Xc.fromBigInt(Du(Dt(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return dl.encode({Type:ll.RSA,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return vs(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return dr(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 Uu(this,e);if("libp2p-key"===t)return al(this.bytes,e);throw new ys(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function Hu(e){const t=function(e){const{result:t}=Bc(e),n=t.valueBlock.value;return{n:dr(Lu(n[1].toBigInt()),"base64url"),e:dr(Lu(n[2].toBigInt()),"base64url"),d:dr(Lu(n[3].toBigInt()),"base64url"),p:dr(Lu(n[4].toBigInt()),"base64url"),q:dr(Lu(n[5].toBigInt()),"base64url"),dp:dr(Lu(n[6].toBigInt()),"base64url"),dq:dr(Lu(n[7].toBigInt()),"base64url"),qi:dr(Lu(n[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(Sl(t)>Mu)throw new ys("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const n=await wl(t);return new $u(n.privateKey,n.publicKey)}function qu(e){const t=function(e){const{result:t}=Bc(e),n=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:dr(Lu(n[0].toBigInt()),"base64url"),e:dr(Lu(n[1].toBigInt()),"base64url")}}(e);if(Sl(t)>Mu)throw new ys("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Fu(t)}async function ju(e){if(Sl(e)>Mu)throw new ys("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await wl(e);return new $u(t.privateKey,t.publicKey)}async function Vu(e){if(e>Mu)throw new ys("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await il.get().subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:e,publicExponent:new Uint8Array([1,0,1]),hash:{name:"SHA-256"}},!0,["sign","verify"]),n=await vl(t);return{privateKey:n[0],publicKey:n[1]}}(e);return new $u(t.privateKey,t.publicKey)}function zu(e){void 0!==e.lowS&&Us("lowS",e.lowS),void 0!==e.prehash&&Us("prehash",e.prehash)}const{Ph:Ku,aT:Wu}=p,Gu={Err:class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}},_tlv:{encode:(e,t)=>{const{Err:n}=Gu;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=$s(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?$s(o.length/2|128):"";return`${$s(e)}${i}${o}${t}`},decode(e,t){const{Err:n}=Gu;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++];let i=0;if(!!(128&o)){const e=127&o;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const s=t.subarray(r,r+e);if(s.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===s[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of s)i=i<<8|t;if(r+=e,i<128)throw new n("tlv.decode(long): not minimal encoding")}else i=o;const s=t.subarray(r,r+i);if(s.length!==i)throw new n("tlv.decode: wrong value length");return{v:s,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=Gu;if(e<Yu)throw new t("integer: negative integers are not allowed");let n=$s(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected assertion");return n},decode(e){const{Err:t}=Gu;if(128&e[0])throw new t("Invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("Invalid signature integer: unnecessary leading zero");return Ku(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=Gu,o="string"===typeof e?Wu(e):e;Bs(o);const{v:i,l:s}=r.decode(48,o);if(s.length)throw new t("Invalid signature: left bytes after parsing");const{v:a,l:l}=r.decode(2,i),{v:c,l:u}=r.decode(2,l);if(u.length)throw new t("Invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(c)}},hexFromSig(e){const{_tlv:t,_int:n}=Gu,r=`${t.encode(2,n.encode(e.r))}${t.encode(2,n.encode(e.s))}`;return t.encode(48,r)}},Yu=BigInt(0),Qu=BigInt(1),Ju=(BigInt(2),BigInt(3));BigInt(4);function Xu(e){const t=function(e){const t=Na(e);sa(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:n,Fp:r,a:o}=t;if(n){if(!r.eql(o,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!==typeof n||"bigint"!==typeof n.beta||"function"!==typeof n.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:n}=t,r=Sa(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return Qs(Uint8Array.from([4]),n.toBytes(o.x),n.toBytes(o.y))}),i=t.fromBytes||(e=>{const t=e.subarray(1);return{x:n.fromBytes(t.subarray(0,n.BYTES)),y:n.fromBytes(t.subarray(n.BYTES,2*n.BYTES))}});function s(e){const{a:r,b:o}=t,i=n.sqr(e),s=n.mul(i,e);return n.add(n.add(s,n.mul(e,r)),o)}if(!n.eql(n.sqr(t.Gy),s(t.Gx)))throw new Error("bad generator point: equation left != right");function a(e){const{allowedPrivateKeyLengths:n,nByteLength:r,wrapPrivateKey:o,n:i}=t;if(n&&"bigint"!==typeof e){if(Ds(e)&&(e=Fs(e)),"string"!==typeof e||!n.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*r,"0")}let s;try{s="bigint"===typeof e?e:zs(Ys("private key",e,r))}catch(a){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(s=ga(s,i)),Zs("private key",s,Qu,i),s}function l(e){if(!(e instanceof d))throw new Error("ProjectivePoint expected")}const c=aa(((e,t)=>{const{px:r,py:o,pz:i}=e;if(n.eql(i,n.ONE))return{x:r,y:o};const s=e.is0();null==t&&(t=s?n.ONE:n.inv(i));const a=n.mul(r,t),l=n.mul(o,t),c=n.mul(i,t);if(s)return{x:n.ZERO,y:n.ZERO};if(!n.eql(c,n.ONE))throw new Error("invZ was invalid");return{x:a,y:l}})),u=aa((e=>{if(e.is0()){if(t.allowInfinityPoint&&!n.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:r,y:o}=e.toAffine();if(!n.isValid(r)||!n.isValid(o))throw new Error("bad point: x or y not FE");const i=n.sqr(o),a=s(r);if(!n.eql(i,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class d{constructor(e,t,r){if(this.px=e,this.py=t,this.pz=r,null==e||!n.isValid(e))throw new Error("x required");if(null==t||!n.isValid(t))throw new Error("y required");if(null==r||!n.isValid(r))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:r}=e||{};if(!e||!n.isValid(t)||!n.isValid(r))throw new Error("invalid affine point");if(e instanceof d)throw new Error("projective point not allowed");const o=e=>n.eql(e,n.ZERO);return o(t)&&o(r)?d.ZERO:new d(t,r,n.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(d.fromAffine)}static fromHex(e){const t=d.fromAffine(i(Ys("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}static msm(e,t){return Ta(d,r,e,t)}_setWindowSize(e){f.setWindowSize(this,e)}assertValidity(){u(this)}hasEvenY(){const{y:e}=this.toAffine();if(n.isOdd)return!n.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){l(e);const{px:t,py:r,pz:o}=this,{px:i,py:s,pz:a}=e,c=n.eql(n.mul(t,a),n.mul(i,o)),u=n.eql(n.mul(r,a),n.mul(s,o));return c&&u}negate(){return new d(this.px,n.neg(this.py),this.pz)}double(){const{a:e,b:r}=t,o=n.mul(r,Ju),{px:i,py:s,pz:a}=this;let l=n.ZERO,c=n.ZERO,u=n.ZERO,h=n.mul(i,i),f=n.mul(s,s),p=n.mul(a,a),g=n.mul(i,s);return g=n.add(g,g),u=n.mul(i,a),u=n.add(u,u),l=n.mul(e,u),c=n.mul(o,p),c=n.add(l,c),l=n.sub(f,c),c=n.add(f,c),c=n.mul(l,c),l=n.mul(g,l),u=n.mul(o,u),p=n.mul(e,p),g=n.sub(h,p),g=n.mul(e,g),g=n.add(g,u),u=n.add(h,h),h=n.add(u,h),h=n.add(h,p),h=n.mul(h,g),c=n.add(c,h),p=n.mul(s,a),p=n.add(p,p),h=n.mul(p,g),l=n.sub(l,h),u=n.mul(p,f),u=n.add(u,u),u=n.add(u,u),new d(l,c,u)}add(e){l(e);const{px:r,py:o,pz:i}=this,{px:s,py:a,pz:c}=e;let u=n.ZERO,h=n.ZERO,f=n.ZERO;const p=t.a,g=n.mul(t.b,Ju);let m=n.mul(r,s),y=n.mul(o,a),b=n.mul(i,c),w=n.add(r,o),v=n.add(s,a);w=n.mul(w,v),v=n.add(m,y),w=n.sub(w,v),v=n.add(r,i);let E=n.add(s,c);return v=n.mul(v,E),E=n.add(m,b),v=n.sub(v,E),E=n.add(o,i),u=n.add(a,c),E=n.mul(E,u),u=n.add(y,b),E=n.sub(E,u),f=n.mul(p,v),u=n.mul(g,b),f=n.add(u,f),u=n.sub(y,f),f=n.add(y,f),h=n.mul(u,f),y=n.add(m,m),y=n.add(y,m),b=n.mul(p,b),v=n.mul(g,v),y=n.add(y,b),b=n.sub(m,b),b=n.mul(p,b),v=n.add(v,b),m=n.mul(y,v),h=n.add(h,m),m=n.mul(E,v),u=n.mul(w,u),u=n.sub(u,m),m=n.mul(w,y),f=n.mul(E,f),f=n.add(f,m),new d(u,h,f)}subtract(e){return this.add(e.negate())}is0(){return this.equals(d.ZERO)}wNAF(e){return f.wNAFCached(this,e,d.normalizeZ)}multiplyUnsafe(e){Zs("scalar",e,Yu,t.n);const r=d.ZERO;if(e===Yu)return r;if(e===Qu)return this;const{endo:o}=t;if(!o)return f.unsafeLadder(this,e);let{k1neg:i,k1:s,k2neg:a,k2:l}=o.splitScalar(e),c=r,u=r,h=this;for(;s>Yu||l>Yu;)s&Qu&&(c=c.add(h)),l&Qu&&(u=u.add(h)),h=h.double(),s>>=Qu,l>>=Qu;return i&&(c=c.negate()),a&&(u=u.negate()),u=new d(n.mul(u.px,o.beta),u.py,u.pz),c.add(u)}multiply(e){const{endo:r,n:o}=t;let i,s;if(Zs("scalar",e,Qu,o),r){const{k1neg:t,k1:o,k2neg:a,k2:l}=r.splitScalar(e);let{p:c,f:u}=this.wNAF(o),{p:h,f:p}=this.wNAF(l);c=f.constTimeNegate(t,c),h=f.constTimeNegate(a,h),h=new d(n.mul(h.px,r.beta),h.py,h.pz),i=c.add(h),s=u.add(p)}else{const{p:t,f:n}=this.wNAF(e);i=t,s=n}return d.normalizeZ([i,s])[0]}multiplyAndAddUnsafe(e,t,n){const r=d.BASE,o=(e,t)=>t!==Yu&&t!==Qu&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),i=o(this,t).add(o(e,n));return i.is0()?void 0:i}toAffine(e){return c(this,e)}isTorsionFree(){const{h:e,isTorsionFree:n}=t;if(e===Qu)return!0;if(n)return n(d,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:n}=t;return e===Qu?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Us("isCompressed",e),this.assertValidity(),o(d,this,e)}toHex(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Us("isCompressed",e),Fs(this.toRawBytes(e))}}d.BASE=new d(t.Gx,t.Gy,n.ONE),d.ZERO=new d(n.ZERO,n.ONE,n.ZERO);const h=t.nBitLength,f=Ra(d,t.endo?Math.ceil(h/2):h);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:function(e){return Xs(e,Qu,t.n)}}}function Zu(e){const t=function(e){const t=Na(e);return sa(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:n,n:r}=t,o=n.BYTES+1,i=2*n.BYTES+1;function s(e){return ga(e,r)}function a(e){return ba(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=Xu({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=Qs;return Us("isCompressed",r),r?s(Uint8Array.from([t.hasEvenY()?2:3]),i):s(Uint8Array.from([4]),i,n.toBytes(o.y))},fromBytes(e){const t=e.length,r=e[0],s=e.subarray(1);if(t!==o||2!==r&&3!==r){if(t===i&&4===r){return{x:n.fromBytes(s.subarray(0,n.BYTES)),y:n.fromBytes(s.subarray(n.BYTES,2*n.BYTES))}}throw new Error(`Point of length ${t} was invalid. Expected ${o} compressed bytes or ${i} uncompressed bytes`)}{const e=zs(s);if(!Xs(e,Qu,n.ORDER))throw new Error("Point is not on curve");const t=u(e);let o;try{o=n.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("Point is not on curve"+e)}return 1===(1&r)!==((o&Qu)===Qu)&&(o=n.neg(o)),{x:e,y:o}}}}),h=e=>Fs(Ws(e,t.nByteLength));function f(e){return e>r>>Qu}const p=(e,t,n)=>zs(e.slice(t,n));class g{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const n=t.nByteLength;return e=Ys("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=Gu.toSig(Ys("DER",e));return new g(t,n)}assertValidity(){Zs("r",this.r,Qu,r),Zs("s",this.s,Qu,r)}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:i}=this,c=w(Ys("msgHash",e));if(null==i||![0,1,2,3].includes(i))throw new Error("recovery id invalid");const u=2===i||3===i?r+t.n:r;if(u>=n.ORDER)throw new Error("recovery id 2 or 3 invalid");const d=0===(1&i)?"02":"03",f=l.fromHex(d+h(u)),p=a(u),g=s(-c*p),m=s(o*p),y=l.BASE.multiplyAndAddUnsafe(f,g,m);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,s(-this.s),this.recovery):this}toDERRawBytes(){return Vs(this.toDERHex())}toDERHex(){return Gu.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Vs(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const m={isValidPrivateKey(e){try{return c(e),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const e=Aa(t.n);return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=e.length,o=ka(t),i=Aa(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=ga(n?zs(e):Ks(e),t-ca)+ca;return n?Gs(s,o):Ws(s,o)}(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]:l.BASE;return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function y(e){const t=Ds(e),n="string"===typeof e,r=(t||n)&&e.length;return t?r===o||r===i:n?r===2*o||r===2*i:e instanceof l}const b=t.bits2int||function(e){const n=zs(e),r=8*e.length-t.nBitLength;return r>0?n>>BigInt(r):n},w=t.bits2int_modN||function(e){return s(b(e))},v=ta(t.nBitLength);function E(e){return Zs(`num < 2^${t.nBitLength}`,e,Yu,v),Ws(e,t.nByteLength)}function S(e,r){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k;if(["recovered","canonical"].some((e=>e in o)))throw new Error("sign() legacy options not supported");const{hash:i,randomBytes:u}=t;let{lowS:h,prehash:p,extraEntropy:m}=o;null==h&&(h=!0),e=Ys("msgHash",e),zu(o),p&&(e=Ys("prehashed msgHash",i(e)));const y=w(e),v=c(r),S=[E(v),E(y)];if(null!=m&&!1!==m){const e=!0===m?u(n.BYTES):m;S.push(Ys("extraEntropy",e))}const A=Qs(...S),_=y;return{seed:A,k2sig:function(e){const t=b(e);if(!d(t))return;const n=a(t),r=l.BASE.multiply(t).toAffine(),o=s(r.x);if(o===Yu)return;const i=s(n*s(_+o*v));if(i===Yu)return;let c=(r.x===o?0:2)|Number(r.y&Qu),u=i;return h&&f(i)&&(u=function(e){return f(e)?s(-e):e}(i),c^=1),new g(o,u,c)}}}const k={lowS:t.lowS,prehash:!1},A={lowS:t.lowS,prehash:!1};return l.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return l.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t){let n=!(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 l.fromHex(t).multiply(c(e)).toRawBytes(n)},sign:function(e,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k;const{seed:o,k2sig:i}=S(e,n,r),s=t;return oa(s.hash.outputLen,s.nByteLength,s.hmac)(o,i)},verify:function(e,n,r){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:A;const i=e;if(n=Ys("msgHash",n),r=Ys("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");zu(o);const{lowS:c,prehash:u}=o;let d,h;try{if("string"===typeof i||Ds(i))try{d=g.fromDER(i)}catch(S){if(!(S instanceof Gu.Err))throw S;d=g.fromCompact(i)}else{if("object"!==typeof i||"bigint"!==typeof i.r||"bigint"!==typeof i.s)throw new Error("PARSE");{const{r:e,s:t}=i;d=new g(e,t)}}h=l.fromHex(r)}catch(k){if("PARSE"===k.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&d.hasHighS())return!1;u&&(n=t.hash(n));const{r:f,s:p}=d,m=w(n),y=a(p),b=s(m*y),v=s(f*y),E=l.BASE.multiplyAndAddUnsafe(h,b,v)?.toAffine();return!!E&&s(E.x)===f},ProjectivePoint:l,Signature:g,utils:m}}function ed(e){return{hash:e,hmac:function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Al(e,t,function(){let e=0;for(let n=0;n<arguments.length;n++){const t=n<0||arguments.length<=n?void 0:arguments[n];Bn(t),e+=t.length}const t=new Uint8Array(e);for(let n=0,r=0;n<arguments.length;n++){const e=n<0||arguments.length<=n?void 0:arguments[n];t.set(e,r),r+=e.length}return t}(...r))},randomBytes:Yn}}const td=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),nd=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),rd=BigInt(1),od=BigInt(2),id=(e,t)=>(e+t/od)/t;function sd(e){const t=td,n=BigInt(3),r=BigInt(6),o=BigInt(11),i=BigInt(22),s=BigInt(23),a=BigInt(44),l=BigInt(88),c=e*e*e%t,u=c*c*e%t,d=ya(u,n,t)*u%t,h=ya(d,n,t)*u%t,f=ya(h,od,t)*c%t,p=ya(f,o,t)*f%t,g=ya(p,i,t)*p%t,m=ya(g,a,t)*g%t,y=ya(m,l,t)*m%t,b=ya(y,a,t)*g%t,w=ya(b,n,t)*u%t,v=ya(w,s,t)*p%t,E=ya(v,r,t)*c%t,S=ya(E,od,t);if(!ad.eql(ad.sqr(S),e))throw new Error("Cannot find square root");return S}const ad=Sa(td,void 0,void 0,{sqrt:sd}),ld=function(e,t){const n=t=>Zu({...e,...ed(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:ad,n:nd,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=nd,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-rd*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=id(i*e,t),l=id(-r*e,t);let c=ga(e-a*n-l*o,t),u=ga(-a*r-l*i,t);const d=c>s,h=u>s;if(d&&(c=t-c),h&&(u=t-u),c>s||u>s)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:h,k2:u}}}},nr);BigInt(0);ld.ProjectivePoint;function cd(e){try{ld.ProjectivePoint.fromHex(e)}catch(t){throw new ys(String(t),"ERR_INVALID_PUBLIC_KEY")}}class ud{_key;constructor(e){cd(e),this._key=e}verify(e,t){return function(e,t,n){const r=vt.digest(n instanceof Uint8Array?n:n.subarray());if(vs(r))return r.then((n=>{let{digest:r}=n;return ld.verify(t,r,e)})).catch((e=>{throw new ys(String(e),"ERR_INVALID_INPUT")}));try{return ld.verify(t,r.digest,e)}catch(o){throw new ys(String(o),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,ld.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return ul.encode({Type:ll.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}async hash(){const e=vt.digest(this.bytes);let t;return vs(e)?({bytes:t}=await e):t=e.bytes,t}}class dd{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return ld.getPublicKey(e,!0)}catch(t){throw new ys(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{ld.getPublicKey(e,!0)}catch(t){throw new ys(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),cd(this._publicKey)}sign(e){return function(e,t){const n=vt.digest(t instanceof Uint8Array?t:t.subarray());if(vs(n))return n.then((t=>{let{digest:n}=t;return ld.sign(n,e).toDERRawBytes()})).catch((e=>{throw new ys(String(e),"ERR_INVALID_INPUT")}));try{return ld.sign(n.digest,e).toDERRawBytes()}catch(r){throw new ys(String(r),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new ud(this._publicKey)}marshal(){return this._key}get bytes(){return dl.encode({Type:ll.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return vs(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}async id(){return dr(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 al(this.bytes,e);throw new ys(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function hd(e){return new dd(e)}function fd(e){return new ud(e)}async function pd(){const e=ld.utils.randomPrivateKey();return new dd(e)}const gd={rsa:m,ed25519:g,secp256k1:y};function md(e){const t=Object.keys(gd).join(" / ");return new ys(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function yd(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return gd[e];throw md(e)}function bd(e){const t=ul.decode(e),n=t.Data??new Uint8Array;switch(t.Type){case ll.RSA:return gd.rsa.unmarshalRsaPublicKey(n);case ll.Ed25519:return gd.ed25519.unmarshalEd25519PublicKey(n);case ll.Secp256k1:return gd.secp256k1.unmarshalSecp256k1PublicKey(n);default:throw md(t.Type??"unknown")}}function wd(e,t){return yd(t=(t??"rsa").toLowerCase()),e.bytes}async function vd(e){const t=dl.decode(e),n=t.Data??new Uint8Array;switch(t.Type){case ll.RSA:return gd.rsa.unmarshalRsaPrivateKey(n);case ll.Ed25519:return gd.ed25519.unmarshalEd25519PrivateKey(n);case ll.Secp256k1:return gd.secp256k1.unmarshalSecp256k1PrivateKey(n);default:throw md(t.Type??"RSA")}}const Ed=Symbol.for("@libp2p/service-capabilities"),Sd=Symbol.for("@libp2p/service-dependencies"),kd=Symbol.for("nodejs.util.inspect.custom"),Ad=Object.values(Tt).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),Tt.identity.decoder);class _d{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()})`}[ai]=!0;toString(){return null==this.string&&(this.string=Ce.encode(this.multihash.bytes).slice(1)),this.string}toCID(){return _t.createV1(114,this.multihash)}toBytes(){return this.multihash.bytes}toJSON(){return this.toString()}equals(e){if(null==e)return!1;if(e instanceof Uint8Array)return Ur(this.multihash.bytes,e);if("string"===typeof e)return Nd(e).equals(this);if(null!=e?.multihash?.bytes)return Ur(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[kd](){return`PeerId(${this.toString()})`}}class Id extends _d{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class xd extends _d{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class Cd extends _d{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}const Rd=2336;class Td{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=mt.digest(Dt(this.url))}[kd](){return`PeerId(${this.url})`}[ai]=!0;toString(){return this.toCID().toString()}toCID(){return _t.createV1(Rd,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return null!=e&&(e instanceof Uint8Array&&(e=dr(e)),e.toString()===this.toString())}}function Nd(e,t){if(t=t??Ad,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=ft(Ce.decode(`z${e}`));return e.startsWith("12D")?new xd({multihash:t}):e.startsWith("16U")?new Cd({multihash:t}):new Id({multihash:t})}return Pd(Ad.decode(e))}function Pd(e){try{const t=ft(e);if(t.code===mt.code){if(36===t.digest.length)return new xd({multihash:t});if(37===t.digest.length)return new Cd({multihash:t})}if(t.code===vt.code)return new Id({multihash:t})}catch{return function(e){if(null==e?.multihash||null==e.version||1===e.version&&114!==e.code&&e.code!==Rd)throw new Error("Supplied PeerID CID is invalid");if(e.code===Rd){const t=dr(e.multihash.digest);return new Td(new URL(t))}const t=e.multihash;if(t.code===vt.code)return new Id({multihash:e.multihash});if(t.code===mt.code){if(36===t.digest.length)return new xd({multihash:e.multihash});if(37===t.digest.length)return new Cd({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(_t.decode(e))}throw new Error("Supplied PeerID CID is invalid")}async function Od(e,t){return 36===e.length?new xd({multihash:ht(mt.code,e),privateKey:t}):37===e.length?new Cd({multihash:ht(mt.code,e),privateKey:t}):new Id({multihash:await vt.digest(e),publicKey:e,privateKey:t})}class Ld extends Error{type;code;constructor(e,t,n){super(e??"The operation was aborted"),this.type="aborted",this.name=n??"AbortError",this.code=t??"ABORT_ERR"}}async function Dd(e,t,n){if(null==t)return e;if(t.aborted)return Promise.reject(new Ld(n?.errorMessage,n?.errorCode,n?.errorName));let r;const o=new Ld(n?.errorMessage,n?.errorCode,n?.errorName);try{return await Promise.race([e,new Promise(((e,n)=>{r=()=>{n(o)},t.addEventListener("abort",r)}))])}finally{null!=r&&t.removeEventListener("abort",r)}}class Bd{readNext;haveNext;ended;nextResult;constructor(){this.ended=!1,this.readNext=Xr(),this.haveNext=Xr()}[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=Xr(),e}async throw(e){this.ended=!0,null!=e&&(this.haveNext.promise.catch((()=>{})),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");for(;null!=this.nextResult;)await this.readNext.promise;null!=e?this.nextResult={done:!1,value:e}:(this.ended=!0,this.nextResult={done:!0,value:void 0}),this.haveNext.resolve(),this.haveNext=Xr(),await Dd(this.readNext.promise,t?.signal,t)}}class Ud extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"}class Md extends Error{code;constructor(e,t){super(e),this.code=t}}class Fd extends Md{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}}function $d(e,t){const n=new Bd;e.sink(n).catch((async e=>{await n.end(e)})),e.sink=async e=>{for await(const t of e)await n.push(t);await n.end()};let r=e.source;null!=e.source[Symbol.iterator]?r=e.source[Symbol.iterator]():null!=e.source[Symbol.asyncIterator]&&(r=e.source[Symbol.asyncIterator]());const o=new Hr,i={read:async(e,t)=>{let n;t?.signal?.throwIfAborted();const i=new Promise(((e,r)=>{n=()=>{r(new Fd("Read aborted"))},t?.signal?.addEventListener("abort",n)}));try{if(null==e){const{done:e,value:t}=await Promise.race([r.next(),i]);return!0===e?new Hr:t}for(;o.byteLength<e;){const{value:e,done:t}=await Promise.race([r.next(),i]);if(!0===t)throw new Ud("unexpected end of input");o.append(e)}const t=o.sublist(0,e);return o.consume(e),t}finally{null!=n&&t?.signal?.removeEventListener("abort",n)}},write:async(e,t)=>{t?.signal?.throwIfAborted(),e instanceof Uint8Array?await n.push(e,t):await n.push(e.subarray(),t)},unwrap:()=>{if(o.byteLength>0){const n=e.source;e.source=async function*(){!1===t?.yieldBytes?yield o:yield*o,yield*n}()}return e}};return i}class Hd extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"}class qd extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"}class jd extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"}function Vd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=$d(e,t);null!=t.maxDataLength&&null==t.maxLengthLength&&(t.maxLengthLength=N(t.maxDataLength));const r=t?.lengthDecoder??D,o=t?.lengthEncoder??L;return{read:async e=>{let o=-1;const i=new Hr;for(;;){i.append(await n.read(1,e));try{o=r(i)}catch(s){if(s instanceof RangeError)continue;throw s}if(o<0)throw new Hd("Invalid message length");if(null!=t?.maxLengthLength&&i.byteLength>t.maxLengthLength)throw new jd("message length length too long");if(o>-1)break}if(null!=t?.maxDataLength&&o>t.maxDataLength)throw new qd("message length too long");return n.read(o,e)},write:async(e,t)=>{await n.write(new Hr(o(e.byteLength),e),t)},writeV:async(e,t)=>{const r=new Hr(...e.flatMap((e=>[o(e.byteLength),e])));await n.write(r,t)},unwrap:()=>n.unwrap()}}function zd(){const e=Xr();let t=!1;return{sink:async n=>{if(t)throw new Error("already piped");t=!0,e.resolve(n)},source:async function*(){const t=await e.promise;yield*t}()}}const Kd=65535,Wd=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);function Gd(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Yd(e){if("boolean"!==typeof e)throw new Error(`boolean expected, not ${e}`)}function Qd(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}function Jd(e){if(!Qd(e))throw new Error("Uint8Array expected");for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(n.length>0&&!n.includes(e.length))throw new Error(`Uint8Array expected of length ${n}, not of length=${e.length}`)}function Xd(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 Zd(e,t){Jd(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const eh=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),th=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 nh(e){if("string"===typeof e)e=function(e){if("string"!==typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!Qd(e))throw new Error("Uint8Array expected, got "+typeof e);e=ih(e)}return e}const rh=(e,t)=>(Object.assign(t,e),t);function oh(e,t,n,r){if("function"===typeof e.setBigUint64)return e.setBigUint64(t,n,r);const o=BigInt(32),i=BigInt(4294967295),s=Number(n>>o&i),a=Number(n&i),l=r?4:0,c=r?0:4;e.setUint32(t+l,s,r),e.setUint32(t+c,a,r)}function ih(e){return Uint8Array.from(e)}function sh(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(let r=0;r<t.length;r++)t[r].fill(0)}const ah=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),lh=ah("expand 16-byte k"),ch=ah("expand 32-byte k"),uh=eh(lh),dh=eh(ch);dh.slice();function hh(e,t){return e<<t|e>>>32-t}function fh(e){return e.byteOffset%4===0}const ph=2**32-1,gh=new Uint32Array;function mh(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:o,counterRight:i,rounds:s}=function(e,t){if(null==t||"object"!==typeof t)throw new Error("options must be defined");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 Gd(o),Gd(s),Yd(i),Yd(n),function(t,a,l,c){let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;Jd(t),Jd(a),Jd(l);const d=l.length;if(void 0===c&&(c=new Uint8Array(d)),Jd(c),Gd(u),u<0||u>=ph)throw new Error("arx: counter overflow");if(c.length<d)throw new Error(`arx: output (${c.length}) is shorter than data (${d})`);const h=[];let f,p,g=t.length;if(32===g)h.push(f=ih(t)),p=dh;else{if(16!==g||!n)throw new Error(`arx: invalid 32-byte key, got length=${g}`);f=new Uint8Array(32),f.set(t),f.set(t,16),p=uh,h.push(f)}fh(a)||h.push(a=ih(a));const m=eh(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,eh(a.subarray(0,16)),m),a=a.subarray(16)}const y=16-o;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,i?0:12-a.length),a=e,h.push(a)}const b=eh(a);return function(e,t,n,r,o,i,s,a){const l=o.length,c=new Uint8Array(64),u=eh(c),d=fh(o)&&fh(i),h=d?eh(o):gh,f=d?eh(i):gh;for(let p=0;p<l;s++){if(e(t,n,r,u,s,a),s>=ph)throw new Error("arx: counter overflow");const g=Math.min(64,l-p);if(d&&64===g){const e=p/4;if(p%4!==0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,f[t]=h[t]^u[n];p+=64}else{for(let e,t=0;t<g;t++)e=p+t,i[e]=o[e]^c[t];p+=g}}}(e,p,m,b,l,c,u,s),sh(...h),c}}const yh=(e,t)=>255&e[t++]|(255&e[t++])<<8;class bh{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,Jd(e=nh(e),32);const t=yh(e,0),n=yh(e,2),r=yh(e,4),o=yh(e,6),i=yh(e,8),s=yh(e,10),a=yh(e,12),l=yh(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|r<<6),this.r[3]=8191&(r>>>7|o<<9),this.r[4]=255&(o>>>4|i<<12),this.r[5]=i>>>1&8190,this.r[6]=8191&(i>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|l<<8),this.r[9]=l>>>5&127;for(let c=0;c<8;c++)this.pad[c]=yh(e,16+2*c)}process(e,t){const n=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?0:2048,{h:r,r:o}=this,i=o[0],s=o[1],a=o[2],l=o[3],c=o[4],u=o[5],d=o[6],h=o[7],f=o[8],p=o[9],g=yh(e,t+0),m=yh(e,t+2),y=yh(e,t+4),b=yh(e,t+6),w=yh(e,t+8),v=yh(e,t+10),E=yh(e,t+12),S=yh(e,t+14);let k=r[0]+(8191&g),A=r[1]+(8191&(g>>>13|m<<3)),_=r[2]+(8191&(m>>>10|y<<6)),I=r[3]+(8191&(y>>>7|b<<9)),x=r[4]+(8191&(b>>>4|w<<12)),C=r[5]+(w>>>1&8191),R=r[6]+(8191&(w>>>14|v<<2)),T=r[7]+(8191&(v>>>11|E<<5)),N=r[8]+(8191&(E>>>8|S<<8)),P=r[9]+(S>>>5|n),O=0,L=O+k*i+A*(5*p)+_*(5*f)+I*(5*h)+x*(5*d);O=L>>>13,L&=8191,L+=C*(5*u)+R*(5*c)+T*(5*l)+N*(5*a)+P*(5*s),O+=L>>>13,L&=8191;let D=O+k*s+A*i+_*(5*p)+I*(5*f)+x*(5*h);O=D>>>13,D&=8191,D+=C*(5*d)+R*(5*u)+T*(5*c)+N*(5*l)+P*(5*a),O+=D>>>13,D&=8191;let B=O+k*a+A*s+_*i+I*(5*p)+x*(5*f);O=B>>>13,B&=8191,B+=C*(5*h)+R*(5*d)+T*(5*u)+N*(5*c)+P*(5*l),O+=B>>>13,B&=8191;let U=O+k*l+A*a+_*s+I*i+x*(5*p);O=U>>>13,U&=8191,U+=C*(5*f)+R*(5*h)+T*(5*d)+N*(5*u)+P*(5*c),O+=U>>>13,U&=8191;let M=O+k*c+A*l+_*a+I*s+x*i;O=M>>>13,M&=8191,M+=C*(5*p)+R*(5*f)+T*(5*h)+N*(5*d)+P*(5*u),O+=M>>>13,M&=8191;let F=O+k*u+A*c+_*l+I*a+x*s;O=F>>>13,F&=8191,F+=C*i+R*(5*p)+T*(5*f)+N*(5*h)+P*(5*d),O+=F>>>13,F&=8191;let $=O+k*d+A*u+_*c+I*l+x*a;O=$>>>13,$&=8191,$+=C*s+R*i+T*(5*p)+N*(5*f)+P*(5*h),O+=$>>>13,$&=8191;let H=O+k*h+A*d+_*u+I*c+x*l;O=H>>>13,H&=8191,H+=C*a+R*s+T*i+N*(5*p)+P*(5*f),O+=H>>>13,H&=8191;let q=O+k*f+A*h+_*d+I*u+x*c;O=q>>>13,q&=8191,q+=C*l+R*a+T*s+N*i+P*(5*p),O+=q>>>13,q&=8191;let j=O+k*p+A*f+_*h+I*d+x*u;O=j>>>13,j&=8191,j+=C*c+R*l+T*a+N*s+P*i,O+=j>>>13,j&=8191,O=(O<<2)+O|0,O=O+L|0,L=8191&O,O>>>=13,D+=O,r[0]=L,r[1]=D,r[2]=B,r[3]=U,r[4]=M,r[5]=F,r[6]=$,r[7]=H,r[8]=q,r[9]=j}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let s=2;s<10;s++)e[s]+=r,r=e[s]>>>13,e[s]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let s=1;s<10;s++)n[s]=e[s]+r,r=n[s]>>>13,n[s]&=8191;n[9]-=8192;let o=(1^r)-1;for(let s=0;s<10;s++)n[s]&=o;o=~o;for(let s=0;s<10;s++)e[s]=e[s]&o|n[s];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 i=e[0]+t[0];e[0]=65535&i;for(let s=1;s<8;s++)i=(e[s]+t[s]|0)+(i>>>16)|0,e[s]=65535&i;sh(n)}update(e){Xd(this);const{buffer:t,blockLen:n}=this,r=(e=nh(e)).length;for(let o=0;o<r;){const i=Math.min(n-this.pos,r-o);if(i!==n)t.set(e.subarray(o,o+i),this.pos),this.pos+=i,o+=i,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-o;o+=n)this.process(e,o)}return this}destroy(){sh(this.h,this.r,this.buffer,this.pad)}digestInto(e){Xd(this),Zd(e,this),this.finished=!0;const{buffer:t,h:n}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let o=0;for(let i=0;i<8;i++)e[o++]=n[i]>>>0,e[o++]=n[i]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}const wh=function(e){const t=(t,n)=>e(n).update(nh(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}((e=>new bh(e)));function vh(e,t,n,r,o){let i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:20,s=e[0],a=e[1],l=e[2],c=e[3],u=t[0],d=t[1],h=t[2],f=t[3],p=t[4],g=t[5],m=t[6],y=t[7],b=o,w=n[0],v=n[1],E=n[2],S=s,k=a,A=l,_=c,I=u,x=d,C=h,R=f,T=p,N=g,P=m,O=y,L=b,D=w,B=v,U=E;for(let F=0;F<i;F+=2)S=S+I|0,L=hh(L^S,16),T=T+L|0,I=hh(I^T,12),S=S+I|0,L=hh(L^S,8),T=T+L|0,I=hh(I^T,7),k=k+x|0,D=hh(D^k,16),N=N+D|0,x=hh(x^N,12),k=k+x|0,D=hh(D^k,8),N=N+D|0,x=hh(x^N,7),A=A+C|0,B=hh(B^A,16),P=P+B|0,C=hh(C^P,12),A=A+C|0,B=hh(B^A,8),P=P+B|0,C=hh(C^P,7),_=_+R|0,U=hh(U^_,16),O=O+U|0,R=hh(R^O,12),_=_+R|0,U=hh(U^_,8),O=O+U|0,R=hh(R^O,7),S=S+x|0,U=hh(U^S,16),P=P+U|0,x=hh(x^P,12),S=S+x|0,U=hh(U^S,8),P=P+U|0,x=hh(x^P,7),k=k+C|0,L=hh(L^k,16),O=O+L|0,C=hh(C^O,12),k=k+C|0,L=hh(L^k,8),O=O+L|0,C=hh(C^O,7),A=A+R|0,D=hh(D^A,16),T=T+D|0,R=hh(R^T,12),A=A+R|0,D=hh(D^A,8),T=T+D|0,R=hh(R^T,7),_=_+I|0,B=hh(B^_,16),N=N+B|0,I=hh(I^N,12),_=_+I|0,B=hh(B^_,8),N=N+B|0,I=hh(I^N,7);let M=0;r[M++]=s+S|0,r[M++]=a+k|0,r[M++]=l+A|0,r[M++]=c+_|0,r[M++]=u+I|0,r[M++]=d+x|0,r[M++]=h+C|0,r[M++]=f+R|0,r[M++]=p+T|0,r[M++]=g+N|0,r[M++]=m+P|0,r[M++]=y+O|0,r[M++]=b+L|0,r[M++]=w+D|0,r[M++]=v+B|0,r[M++]=E+U|0}const Eh=mh(vh,{counterRight:!1,counterLength:4,allowShortKeys:!1}),Sh=mh(vh,{counterRight:!1,counterLength:8,extendNonceFn:function(e,t,n,r){let o=e[0],i=e[1],s=e[2],a=e[3],l=t[0],c=t[1],u=t[2],d=t[3],h=t[4],f=t[5],p=t[6],g=t[7],m=n[0],y=n[1],b=n[2],w=n[3];for(let E=0;E<20;E+=2)o=o+l|0,m=hh(m^o,16),h=h+m|0,l=hh(l^h,12),o=o+l|0,m=hh(m^o,8),h=h+m|0,l=hh(l^h,7),i=i+c|0,y=hh(y^i,16),f=f+y|0,c=hh(c^f,12),i=i+c|0,y=hh(y^i,8),f=f+y|0,c=hh(c^f,7),s=s+u|0,b=hh(b^s,16),p=p+b|0,u=hh(u^p,12),s=s+u|0,b=hh(b^s,8),p=p+b|0,u=hh(u^p,7),a=a+d|0,w=hh(w^a,16),g=g+w|0,d=hh(d^g,12),a=a+d|0,w=hh(w^a,8),g=g+w|0,d=hh(d^g,7),o=o+c|0,w=hh(w^o,16),p=p+w|0,c=hh(c^p,12),o=o+c|0,w=hh(w^o,8),p=p+w|0,c=hh(c^p,7),i=i+u|0,m=hh(m^i,16),g=g+m|0,u=hh(u^g,12),i=i+u|0,m=hh(m^i,8),g=g+m|0,u=hh(u^g,7),s=s+d|0,y=hh(y^s,16),h=h+y|0,d=hh(d^h,12),s=s+d|0,y=hh(y^s,8),h=h+y|0,d=hh(d^h,7),a=a+l|0,b=hh(b^a,16),f=f+b|0,l=hh(l^f,12),a=a+l|0,b=hh(b^a,8),f=f+b|0,l=hh(l^f,7);let v=0;r[v++]=o,r[v++]=i,r[v++]=s,r[v++]=a,r[v++]=m,r[v++]=y,r[v++]=b,r[v++]=w},allowShortKeys:!1}),kh=new Uint8Array(16),Ah=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(kh.subarray(n))},_h=new Uint8Array(32);function Ih(e,t,n,r,o){const i=e(t,n,_h),s=wh.create(i);o&&Ah(s,o),Ah(s,r);const a=new Uint8Array(16),l=th(a);oh(l,0,BigInt(o?o.length:0),!0),oh(l,8,BigInt(r.length),!0),s.update(a);const c=s.digest();return sh(i,a),c}const xh=e=>(t,n,r)=>{const o=16;return Jd(t,32),Jd(n),{encrypt(i,s){const a=i.length,l=a+o;s?Jd(s,l):s=new Uint8Array(l),e(t,n,i,s,1);const c=Ih(e,t,n,s.subarray(0,-16),r);return s.set(c,a),sh(c),s},decrypt(i,s){const a=i.length,l=a-o;if(a<o)throw new Error("encrypted data must be at least 16 bytes");s?Jd(s,l):s=new Uint8Array(l);const c=i.subarray(0,-16),u=i.subarray(-16),d=Ih(e,t,n,c,r);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return 0===n}(u,d))throw new Error("invalid tag");return e(t,n,c,s,1),sh(d),s}}},Ch=rh({blockSize:64,nonceLength:12,tagLength:16},xh(Eh));xh(Sh);function Rh(e,t,n){return Un(e),void 0===n&&(n=new Uint8Array(e.outputLen)),Al(e,zn(n),zn(t))}const Th=new Uint8Array([0]),Nh=new Uint8Array;function Ph(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;if(Un(e),Dn(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const o=Math.ceil(r/e.outputLen);void 0===n&&(n=Nh);const i=new Uint8Array(o*e.outputLen),s=Al.create(e,t),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let c=0;c<o;c++)Th[0]=c+1,a.update(0===c?Nh:l).update(n).update(Th).digestInto(l),i.set(l,e.outputLen*c),s._cloneInto(a);return s.destroy(),a.destroy(),l.fill(0),Th.fill(0),i.slice(0,r)}const Oh={hashSHA256:e=>nr(e.subarray()),getHKDF(e,t){const n=Rh(nr,t,e),r=Ph(nr,n,void 0,96);return[r.subarray(0,32),r.subarray(32,64),r.subarray(64,96)]},generateX25519KeyPair(){const e=el.utils.randomPrivateKey();return{publicKey:el.getPublicKey(e),privateKey:e}},generateX25519KeyPairFromSeed:e=>({publicKey:el.getPublicKey(e),privateKey:e}),generateX25519SharedKey:(e,t)=>el.getSharedSecret(e.subarray(),t.subarray()),chaCha20Poly1305Encrypt:(e,t,n,r)=>Ch(r,t,n).encrypt(e.subarray()),chaCha20Poly1305Decrypt:(e,t,n,r,o)=>Ch(r,t,n).decrypt(e.subarray(),o)};const Lh=e=>{const t=E(2);return t[0]=e>>8,t[1]=e,t};Lh.bytes=2;const Dh=e=>{if(e.length<2)throw RangeError("Could not decode int16BE");if(e instanceof Uint8Array){let t=0;return t+=e[0]<<8,t+=e[1],t}return e.getUint16(0)};function Bh(e,t){t.enabled&&Wd&&(e?(t(`LOCAL_STATIC_PUBLIC_KEY ${dr(e.publicKey,"hex")}`),t(`LOCAL_STATIC_PRIVATE_KEY ${dr(e.privateKey,"hex")}`)):t("Missing local static keys."))}function Uh(e,t){t.enabled&&Wd&&(e?(t(`LOCAL_PUBLIC_EPHEMERAL_KEY ${dr(e.publicKey,"hex")}`),t(`LOCAL_PRIVATE_EPHEMERAL_KEY ${dr(e.privateKey,"hex")}`)):t("Missing local ephemeral keys."))}function Mh(e,t){t.enabled&&Wd&&t(e?`REMOTE_EPHEMERAL_PUBLIC_KEY ${dr(e.subarray(),"hex")}`:"Missing remote ephemeral keys.")}function Fh(e,t,n){n.enabled&&Wd&&(n(`CIPHER_STATE_1 ${e.n.getUint64()} ${e.k&&dr(e.k,"hex")}`),n(`CIPHER_STATE_2 ${t.n.getUint64()} ${t.k&&dr(t.k,"hex")}`))}Dh.bytes=2;class $h extends Error{code;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected Peer"),this.code=$h.code}static code="ERR_UNEXPECTED_PEER"}class Hh extends Error{code;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto exchange"),this.code=Hh.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"}class qh{n;bytes;view;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;this.n=e,this.bytes=v(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")}}const jh=v(0);class Vh{k;n;crypto;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;this.crypto=e,this.k=t,this.n=new qh(n)}hasKey(){return Boolean(this.k)}encryptWithAd(e,t){if(!this.hasKey())return t;this.n.assertValue();const n=this.crypto.encrypt(t,this.n.getBytes(),e,this.k);return this.n.increment(),n}decryptWithAd(e,t,n){if(!this.hasKey())return t;this.n.assertValue();const r=this.crypto.decrypt(t,this.n.getBytes(),e,this.k,n);return this.n.increment(),r}}class zh{cs;ck;h;crypto;constructor(e,t){this.crypto=e;const n=Dt(t,"utf-8");this.h=function(e,t){if(t.length<=32){const e=v(32);return e.set(t),e}return e.hash(t)}(e,n),this.ck=this.h,this.cs=new Vh(e)}mixKey(e){const[t,n]=this.crypto.hkdf(this.ck,e);this.ck=t,this.cs=new Vh(this.crypto,n)}mixHash(e){this.h=this.crypto.hash(new Hr(this.h,e))}encryptAndHash(e){const t=this.cs.encryptWithAd(this.h,e);return this.mixHash(t),t}decryptAndHash(e){const t=this.cs.decryptWithAd(this.h,e);return this.mixHash(e),t}split(){const[e,t]=this.crypto.hkdf(this.ck,jh);return[new Vh(this.crypto,e),new Vh(this.crypto,t)]}}class Kh{ss;s;e;rs;re;initiator;crypto;constructor(e){const{crypto:t,protocolName:n,prologue:r,initiator:o,s:i,e:s,rs:a,re:l}=e;this.crypto=t,this.ss=new zh(t,n),this.ss.mixHash(r),this.initiator=o,this.s=i,this.e=s,this.rs=a,this.re=l}writeE(){if(this.e)throw new Error("ephemeral keypair is already set");const e=this.crypto.generateKeypair();return this.ss.mixHash(e.publicKey),this.e=e,e.publicKey}writeS(){if(!this.s)throw new Error("static keypair is not set");return this.ss.encryptAndHash(this.s.publicKey)}writeEE(){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.re))}writeES(){if(this.initiator){if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}else{if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}}writeSE(){if(this.initiator){if(!this.s)throw new Error("static keypair is not set");if(!this.re)throw new Error("remote ephemeral public key is not set");this.ss.mixKey(this.crypto.dh(this.s,this.re))}else{if(!this.e)throw new Error("ephemeral keypair is not set");if(!this.rs)throw new Error("remote static public key is not set");this.ss.mixKey(this.crypto.dh(this.e,this.rs))}}readE(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.re)throw new Error("remote ephemeral public key is already set");if(e.byteLength<t+32)throw new Error("message is not long enough");this.re=e.sublist(t,t+32),this.ss.mixHash(this.re)}readS(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(this.rs)throw new Error("remote static public key is already set");const n=32+(this.ss.cs.hasKey()?16:0);if(e.byteLength<t+n)throw new Error("message is not long enough");const r=e.sublist(t,t+n);return this.rs=this.ss.decryptAndHash(r),n}readEE(){this.writeEE()}readES(){this.writeES()}readSE(){this.writeSE()}}class Wh extends Kh{writeMessageA(e){return new Hr(this.writeE(),this.ss.encryptAndHash(e))}writeMessageB(e){const t=this.writeE();this.writeEE();const n=this.writeS();return this.writeES(),new Hr(t,n,this.ss.encryptAndHash(e))}writeMessageC(e){const t=this.writeS();return this.writeSE(),new Hr(t,this.ss.encryptAndHash(e))}readMessageA(e){try{return this.readE(e),this.ss.decryptAndHash(e.sublist(32))}catch(t){throw new Hh(`handshake stage 0 validation fail: ${t.message}`)}}readMessageB(e){try{this.readE(e),this.readEE();const t=this.readS(e,32);return this.readES(),this.ss.decryptAndHash(e.sublist(32+t))}catch(t){throw new Hh(`handshake stage 1 validation fail: ${t.message}`)}}readMessageC(e){try{const t=this.readS(e);return this.readSE(),this.ss.decryptAndHash(e.sublist(t))}catch(t){throw new Hh(`handshake stage 2 validation fail: ${t.message}`)}}}var Gh,Yh;async function Qh(e,t,n){const r=await e.sign(Xh(t));return Yh.encode({identityKey:e.public.bytes,identitySig:r,extensions:n})}async function Jh(e,t,n){try{const r=Yh.decode(e);if(n){const e=n.subarray();if(!Ur(e,r.identityKey))throw new Error(`Payload identity key ${dr(r.identityKey,"hex")} does not match expected remote identity key ${dr(e,"hex")}`)}if(!t)throw new Error("Remote static does not exist");const o=Xh(t),i=bd(r.identityKey);if(!await i.verify(o,r.identitySig))throw new Error("Invalid payload signature");return r}catch(r){throw new $h(r.message)}}function Xh(e){const t=Dt("noise-libp2p-static-key:");return e instanceof Uint8Array?Br([t,e],t.length+e.length):(e.prepend(t),e)}async function Zh(e,t){const{log:n,connection:r,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:l,extensions:c}=e,u=await Qh(i,a.publicKey,c),d=new Wh({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!0,prologue:s,s:a});Bh(d.s,n),n.trace("Stage 0 - Initiator starting to send first message."),await r.write(d.writeMessageA(jh),t),n.trace("Stage 0 - Initiator finished sending first message."),Uh(d.e,n),n.trace("Stage 1 - Initiator waiting to receive first message from responder...");const h=d.readMessageB(await r.read(t));var f,p;n.trace("Stage 1 - Initiator received the message."),Mh(d.re,n),f=d.rs,(p=n).enabled&&Wd&&p(f?`REMOTE_STATIC_PUBLIC_KEY ${dr(f.subarray(),"hex")}`:"Missing remote static public key."),n.trace("Initiator going to check remote's signature...");const g=await Jh(h,d.rs,l);n.trace("All good with the signature!"),n.trace("Stage 2 - Initiator sending third handshake message."),await r.write(d.writeMessageC(u),t),n.trace("Stage 2 - Initiator sent message with signed payload.");const[m,y]=d.ss.split();return Fh(m,y,n),{payload:g,encrypt:e=>m.encryptWithAd(jh,e),decrypt:(e,t)=>y.decryptWithAd(jh,e,t)}}!function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.lengthDelimited&&t.fork(),null!=e.webtransportCerthashes)for(const r of e.webtransportCerthashes)t.uint32(10),t.bytes(r);!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={webtransportCerthashes:[]},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();if(t>>>3===1)n.webtransportCerthashes.push(e.bytes());else e.skipType(7&t)}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(Gh||(Gh={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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),Gh.codec().encode(e.extensions,t)),!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={identityKey:v(0),identitySig:v(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.identityKey=e.bytes();break;case 2:n.identitySig=e.bytes();break;case 4:n.extensions=Gh.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(Yh||(Yh={}));class ef{protocol="/noise";crypto;prologue;staticKey;extensions;metrics;components;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{staticNoiseKey:n,extensions:r,crypto:o,prologueBytes:i}=t,{metrics:s}=e;this.components=e;const a=o??Oh;this.crypto=function(e){return{generateKeypair:e.generateX25519KeyPair,dh:(t,n)=>e.generateX25519SharedKey(t.privateKey,n).subarray(0,32),encrypt:e.chaCha20Poly1305Encrypt,decrypt:e.chaCha20Poly1305Decrypt,hash:e.hashSHA256,hkdf:e.getHKDF}}(a),this.extensions=r,this.metrics=s?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"})}}(s):void 0,this.staticKey=n?a.generateX25519KeyPairFromSeed(n):a.generateX25519KeyPair(),this.prologue=i??v(0)}[Symbol.toStringTag]="@chainsafe/libp2p-noise";[Ed]=["@libp2p/connection-encryption","@chainsafe/libp2p-noise"];async secureOutbound(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const{localPeer:r,connection:o,remotePeer:i,signal:s}=this.parseArgs(t),a=Vd(o,{lengthEncoder:Lh,lengthDecoder:Dh,maxDataLength:Kd});if(!r.privateKey)throw new ys("local peerId does not contain private key","ERR_NO_PRIVATE_KEY");const l=await vd(r.privateKey),c=i?.publicKey,u=await this.performHandshakeInitiator(a,l,c,{signal:s}),d=await this.createSecureConnection(a,u);return o.source=d.source,o.sink=d.sink,{conn:o,remoteExtensions:u.payload.extensions,remotePeer:await Od(u.payload.identityKey)}}async secureInbound(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];const{localPeer:r,connection:o,remotePeer:i,signal:s}=this.parseArgs(t),a=Vd(o,{lengthEncoder:Lh,lengthDecoder:Dh,maxDataLength:Kd});if(!r.privateKey)throw new ys("local peerId does not contain private key","ERR_NO_PRIVATE_KEY");const l=await vd(r.privateKey),c=i?.publicKey,u=await this.performHandshakeResponder(a,l,c,{signal:s}),d=await this.createSecureConnection(a,u);return o.source=d.source,o.sink=d.sink,{conn:o,remoteExtensions:u.payload.extensions,remotePeer:await Od(u.payload.identityKey)}}async performHandshakeInitiator(e,t,n,r){let o;try{o=await Zh({connection:e,privateKey:t,remoteIdentityKey:n,log:this.components.logger.forComponent("libp2p:noise:xxhandshake"),crypto:this.crypto,prologue:this.prologue,s:this.staticKey,extensions:this.extensions},r),this.metrics?.xxHandshakeSuccesses.increment()}catch(i){throw this.metrics?.xxHandshakeErrors.increment(),i}return o}async performHandshakeResponder(e,t,n,r){let o;try{o=await async function(e,t){const{log:n,connection:r,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:l,extensions:c}=e,u=await Qh(i,a.publicKey,c),d=new Wh({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!1,prologue:s,s:a});Bh(d.s,n),n.trace("Stage 0 - Responder waiting to receive first message."),d.readMessageA(await r.read(t)),n.trace("Stage 0 - Responder received first message."),Mh(d.re,n),n.trace("Stage 1 - Responder sending out first message with signed payload and static key."),await r.write(d.writeMessageB(u),t),n.trace("Stage 1 - Responder sent the second handshake message with signed payload."),Uh(d.e,n),n.trace("Stage 2 - Responder waiting for third handshake message...");const h=d.readMessageC(await r.read(t));n.trace("Stage 2 - Responder received the message, finished handshake.");const f=await Jh(h,d.rs,l),[p,g]=d.ss.split();return Fh(p,g,n),{payload:f,encrypt:e=>g.encryptWithAd(jh,e),decrypt:(e,t)=>p.decryptWithAd(jh,e,t)}}({connection:e,privateKey:t,remoteIdentityKey:n,log:this.components.logger.forComponent("libp2p:noise:xxhandshake"),crypto:this.crypto,prologue:this.prologue,s:this.staticKey,extensions:this.extensions},r),this.metrics?.xxHandshakeSuccesses.increment()}catch(i){throw this.metrics?.xxHandshakeErrors.increment(),i}return o}async createSecureConnection(e,t){const[n,r]=function(){const e=zd(),t=zd();return[{source:e.source,sink:t.sink},{source:t.source,sink:e.sink}]}(),o=e.unwrap();return await io(n,function(e,t){return async function*(n){for await(const r of n)for(let n=0;n<r.length;n+=65519){let o,i=n+65519;i>r.length&&(i=r.length),o=r instanceof Uint8Array?e.encrypt(r.subarray(n,i)):e.encrypt(r.sublist(n,i)),t?.encryptedPackets.increment(),yield new Hr(Lh(o.byteLength),o)}}}(t,this.metrics),o,(e=>Jr(e,{lengthDecoder:Dh})),function(e,t){return async function*(n){for await(const o of n)for(let n=0;n<o.length;n+=Kd){let i=n+Kd;if(i>o.length&&(i=o.length),i-16<n)throw new Error("Invalid chunk");const s=o.sublist(n,i),a=o.subarray(n,i-16);try{const n=e.decrypt(s,a);t?.decryptedPackets.increment(),yield n}catch(r){throw t?.decryptErrors.increment(),r}}}}(t,this.metrics),n),r}parseArgs(e){return li(e[0])?{localPeer:e[0],connection:e[1],remotePeer:e[2]}:{localPeer:this.components.peerId,connection:e[0],remotePeer:e[1]?.remotePeer,signal:e[1]?.signal}}}function tf(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new ef(t,e)}const nf=Symbol.for("@libp2p/peer-discovery"),rf=Df("dns4"),of=Df("dns6"),sf=Df("dnsaddr"),af=Lf(Df("dns"),sf,rf,of),lf=Lf(Df("ip4"),Df("ip6")),cf=Lf(Of(lf,Df("tcp")),Of(af,Df("tcp"))),uf=Of(lf,Df("udp")),df=Of(uf,Df("utp")),hf=Of(uf,Df("quic")),ff=Of(uf,Df("quic-v1")),pf=Lf(Of(cf,Df("ws")),Of(af,Df("ws"))),gf=Lf(Of(pf,Df("p2p")),pf),mf=Lf(Of(cf,Df("wss")),Of(af,Df("wss")),Of(cf,Df("tls"),Df("ws")),Of(af,Df("tls"),Df("ws"))),yf=Lf(Of(mf,Df("p2p")),mf),bf=Lf(Of(cf,Df("http")),Of(lf,Df("http")),Of(af,Df("http"))),wf=Lf(Of(cf,Df("https")),Of(lf,Df("https")),Of(af,Df("https"))),vf=Of(uf,Df("webrtc-direct"),Df("certhash")),Ef=Lf(Of(vf,Df("p2p")),vf),Sf=Of(ff,Df("webtransport"),Df("certhash"),Df("certhash")),kf=Lf(Of(Sf,Df("p2p")),Sf),Af=Lf(Of(gf,Df("p2p-webrtc-star"),Df("p2p")),Of(yf,Df("p2p-webrtc-star"),Df("p2p")),Of(gf,Df("p2p-webrtc-star")),Of(yf,Df("p2p-webrtc-star"))),_f=(Lf(Of(gf,Df("p2p-websocket-star"),Df("p2p")),Of(yf,Df("p2p-websocket-star"),Df("p2p")),Of(gf,Df("p2p-websocket-star")),Of(yf,Df("p2p-websocket-star"))),Lf(Of(bf,Df("p2p-webrtc-direct"),Df("p2p")),Of(wf,Df("p2p-webrtc-direct"),Df("p2p")),Of(bf,Df("p2p-webrtc-direct")),Of(wf,Df("p2p-webrtc-direct")))),If=Lf(pf,mf,bf,wf,Af,_f,cf,df,hf,af,Ef,kf),xf=(Lf(Of(If,Df("p2p-stardust"),Df("p2p")),Of(If,Df("p2p-stardust"))),Lf(Of(If,Df("p2p")),Af,_f,Ef,kf,Df("p2p"))),Cf=Lf(Of(xf,Df("p2p-circuit"),xf),Of(xf,Df("p2p-circuit")),Of(Df("p2p-circuit"),xf),Of(If,Df("p2p-circuit")),Of(Df("p2p-circuit"),If),Df("p2p-circuit")),Rf=()=>Lf(Of(Cf,Rf),Cf),Tf=Rf(),Nf=Lf(Of(Tf,xf,Tf),Of(xf,Tf),Of(Tf,xf),Tf,xf);Lf(Of(Tf,Df("webrtc"),Df("p2p")),Of(Tf,Df("webrtc")),Of(If,Df("webrtc"),Df("p2p")),Of(If,Df("webrtc")),Df("webrtc"));function Pf(e){return function(t){let n;try{n=ji(t)}catch(o){return!1}const r=e(n.protoNames());return null!==r&&(!0===r||!1===r?r:0===r.length)}}function Of(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];function r(e){if(e.length<t.length)return null;let n=e;return t.some((t=>(n="function"===typeof t?t().partialMatch(e):t.partialMatch(e),Array.isArray(n)&&(e=n),null===n))),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Pf(r),partialMatch:r}}function Lf(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];function r(e){let n=null;return t.some((t=>{const r="function"===typeof t?t().partialMatch(e):t.partialMatch(e);return null!=r&&(n=r,!0)})),n}return{toString:function(){return"{ "+t.join(" ")+" }"},input:t,matches:Pf(r),partialMatch:r}}function Df(e){const t=e;return{toString:function(){return t},matches:function(e){let n;try{n=ji(e)}catch(o){return!1}const r=n.protoNames();return 1===r.length&&r[0]===t},partialMatch:function(e){return 0===e.length?null:e[0]===t?e.slice(1):null}}}class Bf extends Yo{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 n of t.list){if(!Nf.matches(n)){this.log.error("Invalid multiaddr");continue}const e=ji(n),t=e.getPeerId();if(null==t){this.log.error("Invalid bootstrap multiaddr without peer id");continue}const r={id:Nd(t),multiaddrs:[e]};this.list.push(r)}this._init=t}[nf]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[Ed]=["@libp2p/peer-discovery"];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}}const Uf=Uint8Array.from([3,1]);var Mf;!function(e){let t,n;!function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.multiaddr&&e.multiaddr.byteLength>0&&(t.uint32(10),t.bytes(e.multiaddr)),!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={multiaddr:new Uint8Array(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();if(t>>>3===1)n.multiaddr=e.bytes();else e.skipType(7&t)}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(t=e.AddressInfo||(e.AddressInfo={})),e.codec=()=>(null==n&&(n=Rn((function(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&n.fork(),null!=t.peerId&&t.peerId.byteLength>0&&(n.uint32(10),n.bytes(t.peerId)),null!=t.seq&&0n!==t.seq&&(n.uint32(16),n.uint64(t.seq)),null!=t.addresses)for(const o of t.addresses)n.uint32(26),e.AddressInfo.codec().encode(o,n);!1!==r.lengthDelimited&&n.ldelim()}),((t,n)=>{const r={peerId:new Uint8Array(0),seq:0n,addresses:[]},o=null==n?t.len:t.pos+n;for(;t.pos<o;){const n=t.uint32();switch(n>>>3){case 1:r.peerId=t.bytes();break;case 2:r.seq=t.uint64();break;case 3:r.addresses.push(e.AddressInfo.codec().decode(t,t.uint32()));break;default:t.skipType(7&n)}}return r}))),n),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(Mf||(Mf={}));class Ff{static createFromProtobuf=e=>{const t=Mf.decode(e),n=Pd(t.peerId),r=(t.addresses??[]).map((e=>ji(e.multiaddr))),o=t.seq;return new Ff({peerId:n,multiaddrs:r,seqNumber:o})};static DOMAIN="libp2p-peer-record";static CODEC=(()=>Uf)();peerId;multiaddrs;seqNumber;domain=(()=>Ff.DOMAIN)();codec=(()=>Ff.CODEC)();marshaled;constructor(e){const{peerId:t,multiaddrs:n,seqNumber:r}=e;this.peerId=t,this.multiaddrs=n??[],this.seqNumber=r??BigInt(Date.now())}marshal(){return null==this.marshaled&&(this.marshaled=Mf.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))})),this.marshaled}equals(e){return e instanceof Ff&&(!!this.peerId.equals(e.peerId)&&(this.seqNumber===e.seqNumber&&!!function(e,t){const n=(e,t)=>e.toString().localeCompare(t.toString());return e.length===t.length&&(t.sort(n),e.sort(n).every(((e,n)=>t[n].equals(e))))}(this.multiaddrs,e.multiaddrs)))}}const $f="ERR_SIGNATURE_NOT_VALID";var Hf;!function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={publicKey:new Uint8Array(0),payloadType:new Uint8Array(0),payload:new Uint8Array(0),signature:new Uint8Array(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.publicKey=e.bytes();break;case 2:n.payloadType=e.bytes();break;case 3:n.payload=e.bytes();break;case 5:n.signature=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(Hf||(Hf={}));class qf{static createFromProtobuf=async e=>{const t=Hf.decode(e),n=await Od(t.publicKey);return new qf({peerId:n,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 n=e.domain,r=e.codec,o=e.marshal(),i=jf(n,r,o),s=await vd(t.privateKey),a=await s.sign(i.subarray());return new qf({peerId:t,payloadType:r,payload:o,signature:a})};static openAndCertify=async(e,t)=>{const n=await qf.createFromProtobuf(e);if(!await n.validate(t))throw new ys("envelope signature is not valid for the given domain",$f);return n};peerId;payloadType;payload;signature;marshaled;constructor(e){const{peerId:t,payloadType:n,payload:r,signature:o}=e;this.peerId=t,this.payloadType=n,this.payload=r,this.signature=o}marshal(){if(null==this.peerId.publicKey)throw new Error("Missing public key");return null==this.marshaled&&(this.marshaled=Hf.encode({publicKey:this.peerId.publicKey,payloadType:this.payloadType,payload:this.payload.subarray(),signature:this.signature})),this.marshaled}equals(e){return Ur(this.marshal(),e.marshal())}async validate(e){const t=jf(e,this.payloadType,this.payload);if(null==this.peerId.publicKey)throw new Error("Missing public key");return bd(this.peerId.publicKey).verify(t.subarray(),this.signature)}}const jf=(e,t,n)=>{const r=Dt(e),o=L(r.byteLength),i=L(t.length),s=L(n.length);return new Hr(o,r,i,t,s,n)},Vf=e=>({match:t=>!(t.length<1)&&(!!e(t[0])&&t.slice(1)),pattern:"fn"}),zf=e=>({match:t=>Vf((t=>t===e)).match(t),pattern:e}),Kf=()=>({match:e=>Vf((e=>"string"===typeof e)).match(e),pattern:"{string}"}),Wf=()=>({match:e=>Vf((e=>!isNaN(parseInt(e)))).match(e),pattern:"{number}"}),Gf=()=>({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{Ce.decode(`z${e[1]}`)}catch(t){return!1}return e.slice(2)},pattern:"/p2p/{peerid}"}),Yf=()=>({match:e=>{if(e.length<2)return!1;if("certhash"!==e[0])return!1;try{Pe.decode(e[1])}catch{return!1}return e.slice(2)},pattern:"/certhash/{certhash}"}),Qf=e=>({match:t=>{const n=e.match(t);return!1===n?t:n},pattern:`optional(${e.pattern})`}),Jf=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return{match:e=>{let n;for(const r of t){const t=r.match(e);!1!==t&&((null==n||t.length<n.length)&&(n=t))}return null!=n&&n},pattern:`or(${t.map((e=>e.pattern)).join(", ")})`}},Xf=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return{match:e=>{for(const n of t){const t=n.match(e);if(!1===t)return!1;e=t}return e},pattern:`and(${t.map((e=>e.pattern)).join(", ")})`}};function Zf(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];function r(e){let n=(e=>e.toString().split("/").slice(1))(e);for(const r of t){const e=r.match(n);if(!1===e)return!1;n=e}return n}return{matches:function(e){return!1!==r(e)},exactMatch:function(e){const t=r(e);return!1!==t&&0===t.length}}}const ep=Xf(zf("dns4"),Kf()),tp=Xf(zf("dns6"),Kf()),np=Xf(zf("dnsaddr"),Kf()),rp=Xf(zf("dns"),Kf()),op=(Zf(ep),Zf(tp),Zf(np),Zf(Jf(rp,np,ep,tp)),Xf(zf("ip4"),Vf(ui))),ip=Xf(zf("ip6"),Vf(di)),sp=Jf(op,ip),ap=Jf(sp,rp,ep,tp,np),lp=Zf(ap),cp=(Zf(op),Zf(ip),Zf(sp),Xf(ap,zf("tcp"),Wf())),up=Xf(ap,zf("udp"),Wf()),dp=(Zf(cp),Zf(up),Xf(up,zf("quic"))),hp=Xf(up,zf("quic-v1")),fp=Jf(dp,hp),pp=(Zf(dp),Zf(hp),Jf(ap,cp,up,dp,hp)),gp=Jf(Xf(pp,zf("ws"),Qf(Gf()))),mp=(Zf(gp),Jf(Xf(pp,zf("wss"),Qf(Gf())),Xf(pp,zf("tls"),zf("ws"),Qf(Gf())))),yp=(Zf(mp),Xf(up,zf("webrtc-direct"),Qf(Yf()),Qf(Yf()),Qf(Gf()))),bp=(Zf(yp),Xf(hp,zf("webtransport"),Qf(Yf()),Qf(Yf()),Qf(Gf()))),wp=(Zf(bp),Jf(gp,mp,Xf(cp,Qf(Gf())),Xf(fp,Qf(Gf())),Xf(ap,Qf(Gf())),yp,bp,Gf())),vp=(Zf(wp),Zf(Xf(wp,zf("p2p-circuit"),Gf())));Zf(Jf(Xf(wp,zf("p2p-circuit"),zf("webrtc"),Qf(Gf())),Xf(wp,zf("webrtc"),Qf(Gf())),zf("webrtc"))),Zf(Jf(Xf(ap,zf("tcp"),Wf(),zf("http"),Qf(Gf())),Xf(ap,zf("http"),Qf(Gf())))),Zf(Jf(Xf(ap,zf("tcp"),Jf(Xf(zf("443"),zf("http")),Xf(Wf(),zf("https"))),Qf(Gf())),Xf(ap,zf("tls"),zf("http"),Qf(Gf())),Xf(ap,zf("https"),Qf(Gf()))));function Ep(e,t){const n=Vd(e,t),r={read:async(e,t)=>{const r=await n.read(t);return e.decode(r)},write:async(e,t,r)=>{await n.write(t.encode(e),r)},writeV:async(e,t,r)=>{await n.writeV(e.map((e=>t.encode(e))),r)},pb:e=>({read:async t=>r.read(e,t),write:async(t,n)=>r.write(t,e,n),writeV:async(t,n)=>r.writeV(t,e,n),unwrap:()=>r}),unwrap:()=>n.unwrap()};return r}var Sp;!function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==n.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 r of e.listenAddrs)t.uint32(18),t.bytes(r);if(null!=e.observedAddr&&(t.uint32(34),t.bytes(e.observedAddr)),null!=e.protocols)for(const r of e.protocols)t.uint32(26),t.string(r);null!=e.signedPeerRecord&&(t.uint32(66),t.bytes(e.signedPeerRecord)),!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={listenAddrs:[],protocols:[]},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 5:n.protocolVersion=e.string();break;case 6:n.agentVersion=e.string();break;case 1:n.publicKey=e.bytes();break;case 2:n.listenAddrs.push(e.bytes());break;case 4:n.observedAddr=e.bytes();break;case 3:n.protocols.push(e.string());break;case 8:n.signedPeerRecord=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(Sp||(Sp={}));var kp=__webpack_require__(4053);const Ap="object"===typeof window&&"object"===typeof document&&9===document.nodeType,_p=kp(),Ip=Ap&&!_p,xp=_p&&!Ap,Cp=_p&&Ap,Rp="undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.release&&"node"===globalThis.process.release.name&&!_p,Tp="function"===typeof importScripts&&"undefined"!==typeof self&&"undefined"!==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,Np=("undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.env&&globalThis.process.env.NODE_ENV,"undefined"!==typeof navigator&&"ReactNative"===navigator.product),Pp={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnTransientConnection:!0,concurrency:32};class Op{host;protocol;started;timeout;peerId;peerStore;registrar;addressManager;maxInboundStreams;maxOutboundStreams;maxMessageSize;maxObservedAddresses;events;runOnTransientConnection;log;constructor(e,t){var n,r;this.protocol=t.protocol,this.started=!1,this.peerId=e.peerId,this.peerStore=e.peerStore,this.registrar=e.registrar,this.addressManager=e.addressManager,this.events=e.events,this.log=t.log,this.timeout=t.timeout??Pp.timeout,this.maxInboundStreams=t.maxInboundStreams??Pp.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Pp.maxOutboundStreams,this.maxMessageSize=t.maxMessageSize??Pp.maxMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Pp.maxObservedAddresses,this.runOnTransientConnection=t.runOnTransientConnection??Pp.runOnTransientConnection,this.host={protocolVersion:`${t.protocolPrefix??Pp.protocolPrefix}/0.1.0`,agentVersion:(n=e.nodeInfo,r=t.agentVersion,null!=r||(r=`${n.name}/${n.version}`,Rp||xp?r+=` UserAgent=${globalThis.process.version}`:(Ip||Tp||Cp||Np)&&(r+=` UserAgent=${globalThis.navigator.userAgent}`)),r)}}isStarted(){return this.started}async start(){this.started||(await this.peerStore.merge(this.peerId,{metadata:{AgentVersion:Dt(this.host.agentVersion),ProtocolVersion:Dt(this.host.protocolVersion)}}),await this.registrar.handle(this.protocol,(e=>{this.handleProtocol(e).catch((e=>{this.log.error(e)}))}),{maxInboundStreams:this.maxInboundStreams,maxOutboundStreams:this.maxOutboundStreams,runOnTransientConnection:this.runOnTransientConnection}),this.started=!0)}async stop(){await this.registrar.unhandle(this.protocol),this.started=!1}}class Lp extends Op{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,{...t,protocol:`/${t.protocolPrefix??Pp.protocolPrefix}/id/1.0.0`,log:e.logger.forComponent("libp2p:identify")}),(t.runOnConnectionOpen??Pp.runOnConnectionOpen)&&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)}))}))}[Ed]=["@libp2p/identify"];async _identify(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==n.signal){const e=AbortSignal.timeout(this.timeout);Go(1/0,e),n={...n,signal:e}}try{t=await e.newStream(this.protocol,{...n,runOnTransientConnection:this.runOnTransientConnection});const r=Ep(t,{maxDataLength:this.maxMessageSize}).pb(Sp),o=await r.read(n);return await t.close(n),o}catch(r){throw this.log.error("error while reading identify message",r),t?.abort(r),r}}async identify(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=await this._identify(e,t),{publicKey:r,protocols:o,observedAddr:i}=n;if(null==r)throw new ys("public key was missing from identify message","ERR_MISSING_PUBLIC_KEY");const s=await Od(r);if(!e.remotePeer.equals(s))throw new ys("identified peer does not match the expected peer","ERR_INVALID_PEER");if(this.peerId.equals(s))throw new ys("identified peer is our own peer id?","ERR_INVALID_PEER");const a=function(e){if(null!=e&&e.length>0)try{return ji(e)}catch{}}(i);return this.log("identify completed for peer %p and protocols %o",s,o),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)),async function(e,t,n,r,o){if(n("received identify from %p",r.remotePeer),null==o)throw new ys("message was null or undefined","ERR_INVALID_MESSAGE");const i={};if(o.listenAddrs.length>0&&(i.addresses=o.listenAddrs.map((e=>({isCertified:!1,multiaddr:ji(e)})))),o.protocols.length>0&&(i.protocols=o.protocols),null!=o.publicKey&&(i.publicKey=o.publicKey,!(await Od(o.publicKey)).equals(r.remotePeer)))throw new ys("public key did not match remote PeerId","ERR_INVALID_PUBLIC_KEY");let s;if(null!=o.signedPeerRecord){n("received signedPeerRecord from %p",r.remotePeer);let t=o.signedPeerRecord;const a=await qf.openAndCertify(t,Ff.DOMAIN);let c,u=Ff.createFromProtobuf(a.payload);if(!u.peerId.equals(a.peerId))throw new ys("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!r.remotePeer.equals(u.peerId))throw new ys("signing key does not match remote PeerId","ERR_INVALID_PEER_RECORD_KEY");try{c=await e.get(u.peerId)}catch(l){if("ERR_NOT_FOUND"!==l.code)throw l}if(null!=c&&(i.metadata=c.metadata,null!=c.peerRecordEnvelope)){const e=await qf.createFromProtobuf(c.peerRecordEnvelope),r=Ff.createFromProtobuf(e.payload);r.seqNumber>=u.seqNumber&&(n("sequence number was lower or equal to existing sequence number - stored: %d received: %d",r.seqNumber,u.seqNumber),u=r,t=c.peerRecordEnvelope)}i.peerRecordEnvelope=t,i.addresses=u.multiaddrs.map((e=>({isCertified:!0,multiaddr:e}))),s={seq:u.seqNumber,addresses:u.multiaddrs}}else n("%p did not send a signed peer record",r.remotePeer);if(n("patching %p with",r.remotePeer,i),await e.patch(r.remotePeer,i),null!=o.agentVersion||null!=o.protocolVersion){const t={};null!=o.agentVersion&&(t.AgentVersion=Dt(o.agentVersion)),null!=o.protocolVersion&&(t.ProtocolVersion=Dt(o.protocolVersion)),n("merging %p metadata",r.remotePeer,t),await e.merge(r.remotePeer,{metadata:t})}const a={peerId:r.remotePeer,protocolVersion:o.protocolVersion,agentVersion:o.agentVersion,publicKey:o.publicKey,listenAddrs:o.listenAddrs.map((e=>ji(e))),observedAddr:null==o.observedAddr?void 0:ji(o.observedAddr),protocols:o.protocols,signedPeerRecord:s,connection:r};return t.safeDispatchEvent("peer:identify",{detail:a}),a}(this.peerStore,this.events,this.log,e,n)}async handleProtocol(e){const{connection:t,stream:n}=e,r=AbortSignal.timeout(this.timeout);Go(1/0,r);try{const e=this.peerId.publicKey??new Uint8Array(0),o=await this.peerStore.get(this.peerId),i=this.addressManager.getAddresses().map((e=>e.decapsulateCode(wi("p2p").code)));let s=o.peerRecordEnvelope;if(i.length>0&&null==s){const e=new Ff({peerId:this.peerId,multiaddrs:i});s=(await qf.seal(e,this.peerId)).marshal().subarray()}let a=t.remoteAddr.bytes;lp.matches(t.remoteAddr)||(a=void 0);const l=Ep(n).pb(Sp);await l.write({protocolVersion:this.host.protocolVersion,agentVersion:this.host.agentVersion,publicKey:e,listenAddrs:i.map((e=>e.bytes)),signedPeerRecord:s,observedAddr:a,protocols:o.protocols},{signal:r}),await n.close({signal:r})}catch(o){this.log.error("could not respond to identify request",o),n.abort(o)}}}function Dp(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Lp(t,e)}function Bp(e,t){const n=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 r;null!=(r=n)&&"function"===typeof r.then&&"function"===typeof r.catch&&"function"===typeof r.finally&&n.catch((e=>{t.error("could not cause iterator to return",e)}))}const Up=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},Mp=new WeakMap;const Fp=function(){let{clearTimeout:e,setTimeout:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(n){let r,o,i,{value:s,signal:a}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(a?.aborted)return Promise.reject(Up());const l=e??clearTimeout,c=()=>{l(r),i(Up())},u=new Promise(((e,l)=>{o=()=>{a&&a.removeEventListener("abort",c),e(s)},i=l,r=(t??setTimeout)(o,n)}));return a&&a.addEventListener("abort",c,{once:!0}),Mp.set(u,(()=>{l(r),r=null,o()})),u}}(),$p=Fp;class Hp{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 qp}async consume(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=this.getKey(e),o=this._getKeySecDuration(n);let i=this.memoryStorage.incrby(r,t,o);if(i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i.consumedPoints>this.points)throw this.blockDuration>0&&i.consumedPoints<=this.points+t&&(i=this.memoryStorage.set(r,i.consumedPoints,this.blockDuration)),new ys("Rate limit exceeded","ERR_RATE_LIMIT_EXCEEDED",i);if(this.execEvenly&&i.msBeforeNext>0&&!i.isFirstInDuration){let e=Math.ceil(i.msBeforeNext/(i.remainingPoints+2));e<this.execEvenlyMinDelayMs&&(e=i.consumedPoints*this.execEvenlyMinDelayMs),await $p(e)}return i}penalty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=this.getKey(e),o=this._getKeySecDuration(n),i=this.memoryStorage.incrby(r,t,o);return i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i}reward(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=this.getKey(e),o=this._getKeySecDuration(n),i=this.memoryStorage.incrby(r,-t,o);return i.remainingPoints=Math.max(this.points-i.consumedPoints,0),i}block(e,t){const n=1e3*t,r=this.points+1;return this.memoryStorage.set(this.getKey(e),r,t),{remainingPoints:0,msBeforeNext:0===n?-1:n,consumedPoints:r,isFirstInDuration:!1}}set(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const r=1e3*(n>=0?n:this.duration);return this.memoryStorage.set(this.getKey(e),t,n),{remainingPoints:0,msBeforeNext:0===r?-1:r,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 qp{storage;constructor(){this.storage=new Map}incrby(e,t,n){const r=this.storage.get(e);if(null!=r){const o=null!=r.expiresAt?r.expiresAt.getTime()-(new Date).getTime():-1;return null==r.expiresAt||o>0?(r.value+=t,{remainingPoints:0,msBeforeNext:o,consumedPoints:r.value,isFirstInDuration:!1}):this.set(e,t,n)}return this.set(e,t,n)}set(e,t,n){const r=1e3*n,o=this.storage.get(e);null!=o&&clearTimeout(o.timeoutId);const i={value:t,expiresAt:r>0?new Date(Date.now()+r):void 0};return this.storage.set(e,i),r>0&&(i.timeoutId=setTimeout((()=>{this.storage.delete(e)}),r),null!=i.timeoutId.unref&&i.timeoutId.unref()),{remainingPoints:0,msBeforeNext:0===r?-1:r,consumedPoints:i.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)}}var jp;!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"}(jp||(jp={}));const Vp=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),zp=Object.freeze({NEW_STREAM:jp.NEW_STREAM,MESSAGE:jp.MESSAGE_INITIATOR,CLOSE:jp.CLOSE_INITIATOR,RESET:jp.RESET_INITIATOR}),Kp=Object.freeze({MESSAGE:jp.MESSAGE_RECEIVER,CLOSE:jp.CLOSE_RECEIVER,RESET:jp.RESET_RECEIVER}),Wp=1<<20;class Gp{_buffer;_headerInfo;_maxMessageSize;_maxUnprocessedMessageQueueSize;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Wp,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:4194304;this._buffer=new Hr,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(n){if("ERR_MSG_TOO_BIG"===n.code)throw n;break}const{id:e,type:r,length:o,offset:i}=this._headerInfo;if(this._buffer.length-i<o)break;const s={id:e,type:r};r!==jp.NEW_STREAM&&r!==jp.MESSAGE_INITIATOR&&r!==jp.MESSAGE_RECEIVER||(s.data=this._buffer.sublist(i,i+o)),t.push(s),this._buffer.consume(i+o),this._headerInfo=null}return t}_decodeHeader(e){const{value:t,offset:n}=Jp(e),{value:r,offset:o}=Jp(e,n),i=7&t;if(null==Vp[i])throw new Error(`Invalid type received: ${i}`);if(r>this._maxMessageSize)throw Object.assign(new Error("message size too large!"),{code:"ERR_MSG_TOO_BIG"});return{id:t>>3,type:i,offset:n+o,length:r}}}const Yp=128,Qp=127;function Jp(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=0,o=0,i=n;const s=e.length;do{if(i>=s||o>49)throw n=0,new RangeError("Could not decode varint");t=e.get(i++),r+=o<28?(t&Qp)<<o:(t&Qp)*Math.pow(2,o),o+=7}while(t>=Yp);return n=i-n,{value:r,offset:n}}const Xp=10240;const Zp=new class{_pool;_poolOffset;constructor(){this._pool=E(Xp),this._poolOffset=0}write(e,t){const n=this._pool;let r=this._poolOffset;L(e.id<<3|e.type,n,r),r+=N(e.id<<3|e.type),e.type!==jp.NEW_STREAM&&e.type!==jp.MESSAGE_INITIATOR&&e.type!==jp.MESSAGE_RECEIVER||null==e.data?(L(0,n,r),r+=N(0)):(L(e.data.length,n,r),r+=N(e.data.length));const o=n.subarray(this._poolOffset,r);Xp-r<100?(this._pool=E(Xp),this._poolOffset=0):this._poolOffset=r,t.append(o),e.type!==jp.NEW_STREAM&&e.type!==jp.MESSAGE_INITIATOR&&e.type!==jp.MESSAGE_RECEIVER||null==e.data||t.append(e.data)}};function eg(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}class tg{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=Xr(),this.closed=Xr(),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=no({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 ys(`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);eg(e)&&await e}const n=()=>{Bp(e,this.log)};try{this.sinkController.signal.addEventListener("abort",n),this.log.trace("sink reading from source");for await(let n of e){n=n instanceof Uint8Array?new Hr(n):n;const e=this.sendData(n,t);eg(e)&&(this.sendingData=Xr(),await e,this.sendingData.resolve(),this.sendingData=void 0)}}finally{this.sinkController.signal.removeEventListener("abort",n)}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 Dd(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 Dd(this.sink([]),e.signal)),"writing"===this.writeStatus&&(null!=this.sendingData&&await Dd(this.sendingData.promise,e.signal),this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),await Dd(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();eg(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 ys("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 ng extends tg{name;streamId;send;types;maxDataSize;constructor(e){super(e),this.types="outbound"===e.direction?zp:Kp,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:zp.NEW_STREAM,data:new Hr(Dt(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 rg(e){const t={...e,type:`${Vp[e.type]} (${e.type})`};return e.type===jp.NEW_STREAM&&(t.data=dr(e.data instanceof Uint8Array?e.data:e.data.subarray())),e.type!==jp.MESSAGE_INITIATOR&&e.type!==jp.MESSAGE_RECEIVER||(t.data=dr(e.data instanceof Uint8Array?e.data:e.data.subarray(),"base16")),t}class og{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=no({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=io(this._source,(e=>async function*(e){for await(const t of e){const e=new Hr;Zp.write(t,e),yield e}}(e))),this.closeController=new AbortController,this.rateLimiter=new Hp({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 n=this._streams.initiators;return this._newStream({id:t,name:e,type:"initiator",registry:n})}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(n){this.abort(n)}}abort(e){this.closeController.signal.aborted||(this.streams.forEach((t=>{t.abort(e)})),this.closeController.abort(e))}_newReceiverStream(e){const{id:t,name:n}=e,r=this._streams.receivers;return this._newStream({id:t,name:n,type:"receiver",registry:r})}_newStream(e){const{id:t,name:n,type:r,registry:o}=e;if(this.log("new %s stream %s",r,t),"initiator"===r&&this._streams.initiators.size===(this._init.maxOutboundStreams??1024))throw new ys("Too many outbound streams open","ERR_TOO_MANY_OUTBOUND_STREAMS");if(o.has(t))throw new Error(`${r} stream ${t} already exists!`);const i=function(e){const{id:t,name:n,send:r,onEnd:o,type:i="initiator",maxMsgSize:s=Wp}=e;return new ng({id:"initiator"===i?`i${t}`:`r${t}`,streamId:t,name:`${n??t}`,direction:"initiator"===i?"outbound":"inbound",maxDataSize:s,onEnd:o,send:r,log:e.logger.forComponent(`libp2p:mplex:stream:${i}:${t}`)})}({id:t,name:n,send:async e=>{this.log.enabled&&this.log.trace("%s stream %s send",r,t,rg(e)),this._source.push(e)},type:r,onEnd:()=>{this.log("%s stream with id %s and protocol %s ended",r,t,i.protocol),o.delete(t),null!=this._init.onStreamEnd&&this._init.onStreamEnd(i)},maxMsgSize:this._init.maxMsgSize,logger:this.logger});return o.set(t,i),i}_createSink(){return async e=>{const t=()=>{Bp(e,this.log)};this.closeController.signal.addEventListener("abort",t);try{const t=new Gp(this._init.maxMsgSize,this._init.maxUnprocessedMessageQueueSize);for await(const n of e)for(const e of t.write(n))await this._handleIncoming(e);this._source.end()}catch(n){this.log("error in sink",n),this._source.end(n)}finally{this.closeController.signal.removeEventListener("abort",t)}}}async _handleIncoming(e){const{id:t,type:n}=e;if(this.log.enabled&&this.log.trace("incoming message",rg(e)),e.type===jp.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??1024)){this.log("too many inbound streams open"),this._source.push({id:t,type:jp.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 n=this._newReceiverStream({id:t,name:dr(e.data instanceof Uint8Array?e.data:e.data.subarray())});return void(null!=this._init.onIncomingStream&&this._init.onIncomingStream(n))}const r=(1===(1&n)?this._streams.initiators:this._streams.receivers).get(t);if(null==r){this.log("missing stream %s for message type %s",t,Vp[n]);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 o=this._init.maxStreamBufferSize??4194304;try{switch(n){case jp.MESSAGE_INITIATOR:case jp.MESSAGE_RECEIVER:if(r.sourceReadableLength()>o)throw this._source.push({id:e.id,type:n===jp.MESSAGE_INITIATOR?jp.RESET_RECEIVER:jp.RESET_INITIATOR}),new ys("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers","ERR_STREAM_INPUT_BUFFER_FULL");r.sourcePush(e.data);break;case jp.CLOSE_INITIATOR:case jp.CLOSE_RECEIVER:r.remoteCloseWrite();break;case jp.RESET_INITIATOR:case jp.RESET_RECEIVER:r.reset();break;default:this.log("unknown message type %s",n)}}catch(i){this.log.error("error while processing message",i),r.abort(i)}}}class ig{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}[Symbol.toStringTag]="@libp2p/mplex";[Ed]=["@libp2p/stream-multiplexing"];createStreamMuxer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new og(this.components,{...e,...this._init})}}function sg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new ig(t,e)}const ag=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e)return t})();for(const t of e)return t},lg="ERR_WRONG_PING_ACK";class cg{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)}[Symbol.toStringTag]="@libp2p/ping";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,n=Date.now();AbortSignal.timeout(this.timeout).addEventListener("abort",(()=>{t?.abort(new ys("ping timeout",ws))})),io(t,(async function*(e){let n=0;for await(const r of e){if(n+=r.byteLength,n>32)return void t?.abort(new ys("Too much data received","ERR_INVALID_MESSAGE"));yield r}}),t).catch((n=>{this.log.error("incoming ping from %p failed with error",e.connection.remotePeer,n),t?.abort(n)})).finally((()=>{const t=Date.now()-n;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 n=Date.now(),r=Ou(32),o=await this.components.connectionManager.openConnection(e,t);let i,s=()=>{};if(null==t.signal){const e=AbortSignal.timeout(this.timeout);t={...t,signal:e}}try{i=await o.newStream(this.protocol,{...t,runOnTransientConnection:this.runOnTransientConnection}),s=()=>{i?.abort(new ys("ping timeout",ws))},t.signal?.addEventListener("abort",s,{once:!0});const e=await io([r],i,(async e=>ag(e))),a=Date.now()-n;if(null==e)throw new ys(`Did not receive a ping ack after ${a}ms`,lg);if(!Ur(r,e.subarray()))throw new ys(`Received wrong ping ack after ${a}ms`,lg);return this.log("ping %p complete in %dms",o.remotePeer,a),a}catch(a){throw this.log.error("error while pinging %p",o.remotePeer,a),i?.abort(a),a}finally{t.signal?.removeEventListener("abort",s),null!=i&&await i.close()}}}function ug(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new cg(t,e)}const dg=Symbol.for("@libp2p/transport");var hg;!function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"}(hg||(hg={}));const fg=[wi("tcp").code,wi("dns").code,wi("dnsaddr").code,wi("dns4").code,wi("dns6").code];function pg(e){let t;try{t=wi("sni").code}catch(n){return null}for(const[r,o]of e)if(r===t&&void 0!==o)return o;return null}function gg(e){return e.some((e=>{let[t,n]=e;return t===wi("tls").code}))}function mg(e,t,n){const r=yg[wi(e).name];if(void 0===r)throw new Error(`Can't interpret protocol ${wi(e).name}`);const o=r(t,n);return e===wi("ip6").code?`[${o}]`:o}const yg={ip4:(e,t)=>e,ip6:(e,t)=>0===t.length?e:`[${e}]`,tcp:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`tcp://${mg(n[0],n[1]??"",t)}:${e}`},udp:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`udp://${mg(n[0],n[1]??"",t)}:${e}`},dnsaddr:(e,t)=>e,dns4:(e,t)=>e,dns6:(e,t)=>e,dns:(e,t)=>e,ipfs:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`${mg(n[0],n[1]??"",t)}/ipfs/${e}`},p2p:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`${mg(n[0],n[1]??"",t)}/p2p/${e}`},http:(e,t)=>{const n=gg(t),r=pg(t);if(n&&null!==r)return`https://${r}`;const o=n?"https://":"http://",i=t.pop();if(void 0===i)throw new Error("Unexpected end of multiaddr");let s=mg(i[0],i[1]??"",t);return s=s.replace("tcp://",""),`${o}${s}`},"http-path":(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`${mg(n[0],n[1]??"",t)}/${decodeURIComponent(e)}`},tls:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return mg(n[0],n[1]??"",t)},sni:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return mg(n[0],n[1]??"",t)},https:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");let r=mg(n[0],n[1]??"",t);return r=r.replace("tcp://",""),`https://${r}`},ws:(e,t)=>{const n=gg(t),r=pg(t);if(n&&null!==r)return`wss://${r}`;const o=n?"wss://":"ws://",i=t.pop();if(void 0===i)throw new Error("Unexpected end of multiaddr");let s=mg(i[0],i[1]??"",t);return s=s.replace("tcp://",""),`${o}${s}`},wss:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");let r=mg(n[0],n[1]??"",t);return r=r.replace("tcp://",""),`wss://${r}`},"p2p-websocket-star":(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`${mg(n[0],n[1]??"",t)}/p2p-websocket-star`},"p2p-webrtc-star":(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`${mg(n[0],n[1]??"",t)}/p2p-webrtc-star`},"p2p-webrtc-direct":(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return`${mg(n[0],n[1]??"",t)}/p2p-webrtc-direct`}};const bg=async e=>{if(e.readyState>=2)throw new Error("socket closed");1!==e.readyState&&await new Promise(((t,n)=>{function r(){e.removeEventListener("open",o),e.removeEventListener("error",i)}function o(){r(),t()}function i(t){r(),n(t.error??new Error(`connect ECONNREFUSED ${e.url}`))}e.addEventListener("open",o),e.addEventListener("error",i)}))},wg=(e,t)=>{(t=t??{}).closeOnEnd=!1!==t.closeOnEnd;return async n=>{for await(const t of n){try{await bg(e)}catch(r){if("socket closed"===r.message)break;throw r}if(e.readyState===e.CLOSING||e.readyState===e.CLOSED)break;e.send(t)}null!=t.closeOnEnd&&e.readyState<=1&&await new Promise(((t,n)=>{e.addEventListener("close",(e=>{if(e.wasClean||1006===e.code)t();else{const t=Object.assign(new Error("ws error"),{event:e});n(t)}})),setTimeout((()=>{e.close()}))}))}};var vg=__webpack_require__(2605);function Eg(e){return e instanceof ArrayBuffer||"ArrayBuffer"===e?.constructor?.name&&"number"===typeof e?.byteLength}const Sg=(e,t)=>{t=t??{};const n=(e=>{e.binaryType="arraybuffer";const t=async()=>{await new Promise(((t,n)=>{if(o)return void t();if(null!=r)return void n(r);const i=t=>{e.removeEventListener("open",s),e.removeEventListener("error",a),t()},s=()=>{i(t)},a=t=>{i((()=>{n(t.error??new Error(`connect ECONNREFUSED ${e.url}`))}))};e.addEventListener("open",s),e.addEventListener("error",a)}))},n=async function*(){const n=new vg.PP((t=>{let{push:n,stop:r,fail:o}=t;const i=e=>{let t=null;"string"===typeof e.data&&(t=Dt(e.data)),Eg(e.data)&&(t=new Uint8Array(e.data)),e.data instanceof Uint8Array&&(t=e.data),null!=t&&n(t)},s=e=>{o(e.error??new Error("Socket error"))};return e.addEventListener("message",i),e.addEventListener("error",s),e.addEventListener("close",r),()=>{e.removeEventListener("message",i),e.removeEventListener("error",s),e.removeEventListener("close",r)}}),{highWaterMark:1/0});await t();for await(const e of n)yield Eg(e)?new Uint8Array(e):e}();let r,o=1===e.readyState;return e.addEventListener("open",(()=>{o=!0,r=null})),e.addEventListener("close",(()=>{o=!1,r=null})),e.addEventListener("error",(t=>{o||(r=t.error??new Error(`connect ECONNREFUSED ${e.url}`))})),Object.assign(n,{connected:t})})(e);let r=t.remoteAddress,o=t.remotePort;if(null!=e.url)try{const t=new URL(e.url);r=t.hostname,o=parseInt(t.port,10)}catch{}if(null==r||null==o)throw new Error("Remote connection did not have address and/or port");return{sink:wg(e,t),source:n,connected:async()=>{await n.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:r,remotePort:o,socket:e}},kg=WebSocket,Ag={"http:":"ws:","https:":"wss:"};function _g(e,t){t=t??{};const n=((e,t)=>{if(e.startsWith("//")&&(e=`${t?.protocol??"ws:"}${e}`),e.startsWith("/")&&null!=t){const n=t.protocol??"ws:",r=t.host,o=null!=t.port&&!0!==r?.endsWith(`:${t.port}`)?`:${t.port}`:"";e=`${n}//${r}${o}${e}`}const n=new URL(e);for(const[r,o]of Object.entries(Ag))n.protocol===r&&(n.protocol=o);return n})(e,"undefined"===typeof window?void 0:window.location),r=new kg(n.toString(),t.websocket);return Sg(r,t)}class Ig extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}}function xg(e){return e.filter((e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return gf.matches(t)||yf.matches(t)}))}function Cg(e){return e.filter((e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return yf.matches(t)}))}class Rg{log;init;logger;metrics;components;constructor(e,t){this.log=e.logger.forComponent("libp2p:websockets"),this.logger=e.logger,this.components=e,this.init=t,null!=e.metrics&&(this.metrics={dialerEvents:e.metrics.registerCounterGroup("libp2p_websockets_dialer_events_total",{label:"event",help:"Total count of WebSockets dialer events by type"})})}[dg]=!0;[Symbol.toStringTag]="@libp2p/websockets";[Ed]=["@libp2p/transport"];async dial(e,t){this.log("dialing %s",e),t=t??{};const n=function(e,t,n){const r=n.logger.forComponent("libp2p:websockets:maconn"),o=n.metrics,i=n.metricPrefix??"",s={log:r,async sink(t){try{await e.sink(async function*(){for await(const e of t)e instanceof Uint8Array?yield e:yield e.subarray()}())}catch(n){"aborted"!==n.type&&r.error(n)}},source:e.source,remoteAddr:t,timeline:{open:Date.now()},async close(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const n=Date.now();if(null==t.signal){const e=AbortSignal.timeout(500);t={...t,signal:e}}const o=()=>{const{host:e,port:t}=s.remoteAddr.toOptions();r("timeout closing stream to %s:%s after %dms, destroying it manually",e,t,Date.now()-n),this.abort(new ys("Socket close timeout","ERR_SOCKET_CLOSE_TIMEOUT"))};t.signal?.addEventListener("abort",o);try{await e.close()}catch(i){r.error("error closing WebSocket gracefully",i),this.abort(i)}finally{t.signal?.removeEventListener("abort",o),s.timeline.close=Date.now()}},abort(t){const{host:n,port:a}=s.remoteAddr.toOptions();r("timeout closing stream to %s:%s due to error",n,a,t),e.destroy(),s.timeline.close=Date.now(),o?.increment({[`${i}error`]:!0})}};return e.socket.addEventListener("close",(()=>{o?.increment({[`${i}close`]:!0}),null==s.timeline.close&&(s.timeline.close=Date.now())}),{once:!0}),s}(await this._connect(e,t),e,{logger:this.logger,metrics:this.metrics?.dialerEvents});this.log("new outbound connection %s",n.remoteAddr);const r=await t.upgrader.upgradeOutbound(n,t);return this.log("outbound connection %s upgraded",n.remoteAddr),r}async _connect(e,t){t?.signal?.throwIfAborted();const n=e.toOptions();this.log("dialing %s:%s",n.host,n.port);const r=Xr(),o=_g(function(e,t){const n=ji(e).stringTuples(),r=n.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");const o=wi(r[0]),i=yg[o.name];if(null==i)throw new Error(`No interpreter found for ${o.name}`);let s=i(r[1]??"",n);return!1!==t?.assumeHttp&&fg.includes(r[0])&&(s=s.replace(/^.*:\/\//,""),s="443"===r[1]?`https://${s}`:`http://${s}`),(s.startsWith("http://")||s.startsWith("https://"))&&(s=new URL(s).toString(),s.endsWith("/")&&(s=s.substring(0,s.length-1))),s}(e),this.init);o.socket.addEventListener("error",(()=>{const t=new ys(`Could not connect to ${e.toString()}`,"ERR_CONNECTION_FAILED");this.log.error("connection error:",t),this.metrics?.dialerEvents.increment({error:!0}),r.reject(t)}));try{t.onProgress?.(new Ig("websockets:open-connection")),await Dd(Promise.race([o.connected(),r.promise]),t.signal)}catch(i){throw!0===t.signal?.aborted&&this.metrics?.dialerEvents.increment({abort:!0}),o.close().catch((e=>{this.log.error("error closing raw socket",e)})),i}return this.log("connected %s",e),this.metrics?.dialerEvents.increment({connect:!0}),o}createListener(e){return function(){throw new Error("WebSocket Servers can not be created in the browser!")}((this.logger,this.components.metrics),this.init)}listenFilter(e){return e=Array.isArray(e)?e:[e],null!=this.init?.filter?this.init?.filter(e):Ip||Tp?Cg(e):xg(e)}dialFilter(e){return this.listenFilter(e)}}function Tg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Rg(t,e)}const Ng=Symbol.for("@libp2p/content-routing"),Pg=Symbol.for("@libp2p/peer-routing"),Og=1e3,Lg=60*Og,Dg=60*Lg,Bg=24*Dg,Ug=7*Bg,Mg=365.25*Bg;const Fg=function(e,t){try{if("string"===typeof e&&e.length>0)return function(e){if((e=String(e)).length>100)throw new Error("Value exceeds the maximum length of 100 characters.");const t=/^(-?(?:\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(!t)return NaN;const n=parseFloat(t[1]),r=(t[2]||"ms").toLowerCase();switch(r){case"years":case"year":case"yrs":case"yr":case"y":return n*Mg;case"weeks":case"week":case"w":return n*Ug;case"days":case"day":case"d":return n*Bg;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Dg;case"minutes":case"minute":case"mins":case"min":case"m":return n*Lg;case"seconds":case"second":case"secs":case"sec":case"s":return n*Og;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:throw new Error(`The unit ${r} was matched, but no matching case exists.`)}}(e);if("number"===typeof e&&isFinite(e))return t?.long?function(e){const t=Math.abs(e);if(t>=Bg)return $g(e,t,Bg,"day");if(t>=Dg)return $g(e,t,Dg,"hour");if(t>=Lg)return $g(e,t,Lg,"minute");if(t>=Og)return $g(e,t,Og,"second");return`${e} ms`}(e):function(e){const t=Math.abs(e);if(t>=Bg)return`${Math.round(e/Bg)}d`;if(t>=Dg)return`${Math.round(e/Dg)}h`;if(t>=Lg)return`${Math.round(e/Lg)}m`;if(t>=Og)return`${Math.round(e/Og)}s`;return`${e}ms`}(e);throw new Error("Value is not a string or number.")}catch(n){const t=function(e){return"object"===typeof e&&null!==e&&"message"in e}(n)?`${n.message}. value=${JSON.stringify(e)}`:"An unknown error has occured.";throw new Error(t)}};function $g(e,t,n,r){const o=t>=1.5*n;return`${Math.round(e/n)} ${r}${o?"s":""}`}const Hg=function(){try{return localStorage}catch(e){}}();const qg=console.debug??console.log??(()=>{});const jg=function(e){function t(e){let r,o,i,s=null;function a(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];if(!a.enabled)return;const i=a,s=Number(new Date),l=s-(r||s);i.diff=l,i.prev=r,i.curr=s,r=s,n[0]=t.coerce(n[0]),"string"!==typeof n[0]&&n.unshift("%O");let c=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,((e,r)=>{if("%%"===e)return"%";c++;const o=t.formatters[r];if("function"===typeof o){const t=n[c];e=o.call(i,t),n.splice(c,1),c--}return e})),t.formatArgs.call(i,n);(i.log||t.log).apply(i,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!==s?s:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{s=e}}),"function"===typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+("undefined"===typeof n?":":n)+e);return r.log=this.log,r}function r(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(r),...t.skips.map(r).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.namespaces=e,t.names=[],t.skips=[];const r=("string"===typeof e?e:"").split(/[\s,]+/),o=r.length;for(n=0;n<o;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=Fg,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((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.setupFormatters(t.formatters),t.enable(t.load()),t}({formatArgs:function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Fg(this.diff),!this.useColors)return;const t="color: "+this.color;e.splice(1,0,t,"color: inherit");let n=0,r=0;e[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(n++,"%c"===e&&(r=n))})),e.splice(r,0,t)},save:function(e){try{e?Hg?.setItem("debug",e):Hg?.removeItem("debug")}catch(t){}},load:function(){let e;try{e=Hg?.getItem("debug")}catch(t){}return!e&&"undefined"!==typeof process&&"env"in process&&(e={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DEBUG),e},useColors:function(){return!("undefined"===typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"===typeof navigator||null==navigator.userAgent?.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!==typeof document&&document.documentElement?.style?.WebkitAppearance||"undefined"!==typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!==typeof navigator&&null!=navigator.userAgent?.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!==typeof navigator&&navigator.userAgent?.toLowerCase().match(/applewebkit\/(\d+)/))},setupFormatters:function(e){e.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}},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"],storage:Hg,log:qg}),Vg=jg;function zg(){return{forComponent:e=>Kg(e)}}function Kg(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 Vg.enabled(`${e}:trace`)&&null!=Vg.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=Vg(`${e}:trace`)),Object.assign(Vg(e),{error:Vg(`${e}:error`),trace:t})}function Wg(e,t){const n={[Symbol.iterator]:()=>n,next:()=>{const n=e.next(),r=n.value;if(!0===n.done||null==r){return{done:!0,value:void 0}}return{done:!1,value:t(r)}}};return n}Vg.formatters.b=e=>null==e?"undefined":Ce.baseEncode(e),Vg.formatters.t=e=>null==e?"undefined":ye.baseEncode(e),Vg.formatters.m=e=>null==e?"undefined":Te.baseEncode(e),Vg.formatters.p=e=>null==e?"undefined":e.toString(),Vg.formatters.c=e=>null==e?"undefined":e.toString(),Vg.formatters.k=e=>null==e?"undefined":e.toString(),Vg.formatters.a=e=>null==e?"undefined":e.toString();class Gg{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 Wg(this.set.entries(),(e=>{const t=Nd(e[0]);return[t,t]}))}forEach(e){this.set.forEach((t=>{const n=Nd(t);e(n,n,this)}))}has(e){return this.set.has(e.toString())}values(){return Wg(this.set.values(),(e=>Nd(e)))}intersection(e){const t=new Gg;for(const n of e)this.has(n)&&t.add(n);return t}difference(e){const t=new Gg;for(const n of this)e.has(n)||t.add(n);return t}union(e){const t=new Gg;for(const n of e)t.add(n);for(const n of this)t.add(n);return t}}const Yg=async()=>{const e=await async function(e,t){return yd(e).generateKeyPair(t??2048)}("Ed25519"),t=await Qg(e);if("Ed25519"===t.type)return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function Qg(e){return Od(wd(e.public),(t=e,yd(n=(n??"rsa").toLowerCase()),t.bytes));var t,n}async function Jg(e){return Xg(Dt(e.id,"base58btc"),null!=e.privKey?Dt(e.privKey,"base64pad"):void 0,null!=e.pubKey?Dt(e.pubKey,"base64pad"):void 0)}async function Xg(e,t,n){if(null!=t){return Qg(await vd(t))}if(null!=n){return async function(e){return Od(wd(e))}(bd(n))}const r=Pd(e);if("Ed25519"!==r.type&&"secp256k1"!==r.type&&"RSA"!==r.type)throw new Error("Supplied PeerID is invalid");return r}class Zg{map;constructor(e){if(this.map=new Map,null!=e)for(const[t,n]of e.entries())this.map.set(t.toString(),n)}[Symbol.iterator](){return this.entries()}clear(){this.map.clear()}delete(e){return this.map.delete(e.toString())}entries(){return Wg(this.map.entries(),(e=>[Nd(e[0]),e[1]]))}forEach(e){this.map.forEach(((t,n)=>{e(t,Nd(n),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 Wg(this.map.keys(),(e=>Nd(e)))}values(){return this.map.values()}get size(){return this.map.size}}var em=__webpack_require__(7465);class tm{#i=[];enqueue(e,t){const n={priority:(t={priority:0,...t}).priority,run:e};if(this.size&&this.#i[this.size-1].priority>=t.priority)return void this.#i.push(n);const r=function(e,t,n){let r=0,o=e.length;for(;o>0;){const i=Math.trunc(o/2);let s=r+i;n(e[s],t)<=0?(r=++s,o-=i+1):o=i}return r}(this.#i,n,((e,t)=>t.priority-e.priority));this.#i.splice(r,0,n)}dequeue(){const e=this.#i.shift();return e?.run}filter(e){return this.#i.filter((t=>t.priority===e.priority)).map((e=>e.run))}get size(){return this.#i.length}}class nm extends em{#s;#a;#l=0;#c;#u;#d=0;#h;#f;#i;#p;#g=0;#m;#y;#b;timeout;constructor(e){if(super(),!("number"===typeof(e={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:tm,...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.#s=e.carryoverConcurrencyCount,this.#a=e.intervalCap===Number.POSITIVE_INFINITY||0===e.interval,this.#c=e.intervalCap,this.#u=e.interval,this.#i=new e.queueClass,this.#p=e.queueClass,this.concurrency=e.concurrency,this.timeout=e.timeout,this.#b=!0===e.throwOnTimeout,this.#y=!1===e.autoStart}get#w(){return this.#a||this.#l<this.#c}get#v(){return this.#g<this.#m}#E(){this.#g--,this.#S(),this.emit("next")}#k(){this.#A(),this.#_(),this.#f=void 0}get#I(){const e=Date.now();if(void 0===this.#h){const t=this.#d-e;if(!(t<0))return void 0===this.#f&&(this.#f=setTimeout((()=>{this.#k()}),t)),!0;this.#l=this.#s?this.#g:0}return!1}#S(){if(0===this.#i.size)return this.#h&&clearInterval(this.#h),this.#h=void 0,this.emit("empty"),0===this.#g&&this.emit("idle"),!1;if(!this.#y){const e=!this.#I;if(this.#w&&this.#v){const t=this.#i.dequeue();return!!t&&(this.emit("active"),t(),e&&this.#_(),!0)}}return!1}#_(){this.#a||void 0!==this.#h||(this.#h=setInterval((()=>{this.#A()}),this.#u),this.#d=Date.now()+this.#u)}#A(){0===this.#l&&0===this.#g&&this.#h&&(clearInterval(this.#h),this.#h=void 0),this.#l=this.#s?this.#g:0,this.#x()}#x(){for(;this.#S(););}get concurrency(){return this.#m}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.#m=e,this.#x()}async#C(e){return new Promise(((t,n)=>{e.addEventListener("abort",(()=>{n(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.#b,...t},new Promise(((n,r)=>{this.#i.enqueue((async()=>{this.#g++,this.#l++;try{t.signal?.throwIfAborted();let r=e({signal:t.signal});t.timeout&&(r=Ho(Promise.resolve(r),{milliseconds:t.timeout})),t.signal&&(r=Promise.race([r,this.#C(t.signal)]));const o=await r;n(o),this.emit("completed",o)}catch(o){if(o instanceof Uo&&!t.throwOnTimeout)return void n();r(o),this.emit("error",o)}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.#y?(this.#y=!1,this.#x(),this):this}pause(){this.#y=!0}clear(){this.#i=new this.#p}async onEmpty(){0!==this.#i.size&&await this.#R("empty")}async onSizeLessThan(e){this.#i.size<e||await this.#R("next",(()=>this.#i.size<e))}async onIdle(){0===this.#g&&0===this.#i.size||await this.#R("idle")}async#R(e,t){return new Promise((n=>{const r=()=>{t&&!t()||(this.off(e,r),n())};this.on(e,r)}))}get size(){return this.#i.size}sizeBy(e){return this.#i.filter(e).length}get pending(){return this.#g}get isPaused(){return this.#y}}const rm={},om=e=>{e.addEventListener("message",(t=>{om.dispatchEvent("message",e,t)})),null!=e.port&&e.port.addEventListener("message",(t=>{om.dispatchEvent("message",e,t)}))};om.addEventListener=(e,t)=>{null==rm[e]&&(rm[e]=[]),rm[e].push(t)},om.removeEventListener=(e,t)=>{null!=rm[e]&&(rm[e]=rm[e].filter((e=>e===t)))},om.dispatchEvent=function(e,t,n){null!=rm[e]&&rm[e].forEach((e=>e(t,n)))};const im=om,sm="lock:worker:request-read",am="lock:worker:release-read",lm="lock:master:grant-read",cm="lock:worker:request-write",um="lock:worker:release-write",dm="lock:master:grant-write",hm=(e,t,n,r,o)=>(i,s)=>{if(s.data.type!==n)return;const a={type:s.data.type,name:s.data.name,identifier:s.data.identifier};e.dispatchEvent(new MessageEvent(t,{data:{name:a.name,handler:async()=>{i.postMessage({type:o,name:a.name,identifier:a.identifier}),await new Promise((e=>{const t=n=>{if(null==n||null==n.data)return;const o=n.data.type,s=(n.data.name,n.data.identifier);o===r&&s===a.identifier&&(i.removeEventListener("message",t),e())};i.addEventListener("message",t)}))}}}))},fm=(e,t,n,r)=>async()=>{const o=Math.random().toString().substring(2);return globalThis.postMessage({type:t,identifier:o,name:e}),new Promise((t=>{const i=s=>{if(null==s||null==s.data)return;const a=s.data.type,l=s.data.identifier;a===n&&l===o&&(globalThis.removeEventListener("message",i),t((()=>{globalThis.postMessage({type:r,identifier:o,name:e})})))};globalThis.addEventListener("message",i)}))},pm={singleProcess:!1},gm={};let mm;async function ym(e,t){let n;const r=new Promise((e=>{n=e}));return e.add((async()=>Ho((async()=>{await new Promise((e=>{n((()=>{e()}))}))})(),{milliseconds:t.timeout}))),r}const bm={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function wm(e){const t=Object.assign({},bm,e);return null==mm&&(mm=(e=>{if(e=Object.assign({},pm,e),Boolean(globalThis.document)||e.singleProcess){const e=new EventTarget;return im.addEventListener("message",hm(e,"requestReadLock",sm,am,lm)),im.addEventListener("message",hm(e,"requestWriteLock",cm,um,dm)),e}return{isWorker:!0,readLock:e=>fm(e,sm,lm,am),writeLock:e=>fm(e,cm,dm,um)}})(t),!0!==mm.isWorker&&(mm.addEventListener("requestReadLock",(e=>{null!=gm[e.data.name]&&gm[e.data.name].readLock().then((async t=>e.data.handler().finally((()=>{t()}))))})),mm.addEventListener("requestWriteLock",(async e=>{null!=gm[e.data.name]&&gm[e.data.name].writeLock().then((async t=>e.data.handler().finally((()=>{t()}))))})))),null==gm[t.name]&&(gm[t.name]=((e,t)=>{if(!0===mm.isWorker)return{readLock:mm.readLock(e,t),writeLock:mm.writeLock(e,t)};const n=new nm({concurrency:1});let r;return{async readLock(){if(null!=r)return ym(r,t);r=new nm({concurrency:t.concurrency,autoStart:!1});const e=r,o=ym(r,t);return n.add((async()=>{e.start(),await e.onIdle().then((()=>{r===e&&(r=null)}))})),o},writeLock:async()=>(r=null,ym(n,t))}})(t.name,t)),gm[t.name]}const vm="ERR_INVALID_PARAMETERS";var Em,Sm,km;function Am(e,t){const n=Em.decode(t);null!=n.publicKey&&null==e.publicKey&&(e=function(e){if("RSA"===e.type)return new Id(e);if("Ed25519"===e.type)return new xd(e);if("secp256k1"===e.type)return new Cd(e);throw new ys("Not a PeerId","ERR_INVALID_PARAMETERS")}({...e,publicKey:e.publicKey}));const r=new Map,o=BigInt(Date.now());for(const[i,s]of n.tags.entries())null!=s.expiry&&s.expiry<o||r.set(i,s);return{...n,id:e,addresses:n.addresses.map((e=>{let{multiaddr:t,isCertified:n}=e;return{multiaddr:ji(t),isCertified:n??!1}})),metadata:n.metadata,peerRecordEnvelope:n.peerRecordEnvelope??void 0,tags:r}}!function(e){let t,n,r;!function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={key:"",value:new Uint8Array(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.key=e.string();break;case 2:n.value=e.bytes();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(t=e.Peer$metadataEntry||(e.Peer$metadataEntry={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.lengthDelimited&&t.fork(),null!=e.key&&""!==e.key&&(t.uint32(10),t.string(e.key)),null!=e.value&&(t.uint32(18),km.codec().encode(e.value,t)),!1!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={key:""},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.key=e.string();break;case 2:n.value=km.codec().decode(e,e.uint32());break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(n=e.Peer$tagsEntry||(e.Peer$tagsEntry={})),e.codec=()=>(null==r&&(r=Rn((function(t,n){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!1!==r.lengthDelimited&&n.fork(),null!=t.addresses)for(const e of t.addresses)n.uint32(10),Sm.codec().encode(e,n);if(null!=t.protocols)for(const e of t.protocols)n.uint32(18),n.string(e);if(null!=t.publicKey&&(n.uint32(34),n.bytes(t.publicKey)),null!=t.peerRecordEnvelope&&(n.uint32(42),n.bytes(t.peerRecordEnvelope)),null!=t.metadata&&0!==t.metadata.size)for(const[o,i]of t.metadata.entries())n.uint32(50),e.Peer$metadataEntry.codec().encode({key:o,value:i},n);if(null!=t.tags&&0!==t.tags.size)for(const[o,i]of t.tags.entries())n.uint32(58),e.Peer$tagsEntry.codec().encode({key:o,value:i},n);!1!==r.lengthDelimited&&n.ldelim()}),((t,n)=>{const r={addresses:[],protocols:[],metadata:new Map,tags:new Map},o=null==n?t.len:t.pos+n;for(;t.pos<o;){const n=t.uint32();switch(n>>>3){case 1:r.addresses.push(Sm.codec().decode(t,t.uint32()));break;case 2:r.protocols.push(t.string());break;case 4:r.publicKey=t.bytes();break;case 5:r.peerRecordEnvelope=t.bytes();break;case 6:{const n=e.Peer$metadataEntry.codec().decode(t,t.uint32());r.metadata.set(n.key,n.value);break}case 7:{const n=e.Peer$tagsEntry.codec().decode(t,t.uint32());r.tags.set(n.key,n.value);break}default:t.skipType(7&n)}}return r}))),r),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(Em||(Em={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={multiaddr:new Uint8Array(0)},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.multiaddr=e.bytes();break;case 2:n.isCertified=e.bool();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(Sm||(Sm={})),function(e){let t;e.codec=()=>(null==t&&(t=Rn((function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};!1!==n.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!==n.lengthDelimited&&t.ldelim()}),((e,t)=>{const n={value:0},r=null==t?e.len:e.pos+t;for(;e.pos<r;){const t=e.uint32();switch(t>>>3){case 1:n.value=e.uint32();break;case 2:n.expiry=e.uint64();break;default:e.skipType(7&t)}}return n}))),t),e.encode=t=>Yt(t,e.codec()),e.decode=t=>J(t,e.codec())}(km||(km={}));const _m="/",Im=(new TextEncoder).encode(_m),xm=Im[0];class Cm{_buf;constructor(e,t){if("string"===typeof e)this._buf=Dt(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]!==xm)throw new Error("Invalid key")}toString(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"utf8";return dr(this._buf,e)}uint8Array(){return this._buf}get[Symbol.toStringTag](){return`Key(${this.toString()})`}static withNamespaces(e){return new Cm(e.join(_m))}static random(){return new Cm(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||"string"===typeof e?new Cm(e):"function"===typeof e.uint8Array?new Cm(e.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=Im),this._buf[0]!==xm){const e=new Uint8Array(this._buf.byteLength+1);e.fill(xm,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===xm;)this._buf=this._buf.subarray(0,-1)}less(e){const t=this.list(),n=e.list();for(let r=0;r<t.length;r++){if(n.length<r+1)return!1;const e=t[r],o=n[r];if(e<o)return!0;if(e>o)return!1}return t.length<n.length}reverse(){return Cm.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(_m).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 Cm(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(_m)||(e+=_m),e+=this.type(),new Cm(e)}parent(){const e=this.list();return 1===e.length?new Cm(_m):new Cm(e.slice(0,-1).join(_m))}child(e){return this.toString()===_m?e:e.toString()===_m?this:new Cm(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),n=0;n<e;n++)t[n]=arguments[n];return Cm.withNamespaces([...this.namespaces(),...(r=t.map((e=>e.namespaces())),[].concat(...r))]);var r}}const Rm="/peers/";function Tm(e){if(!li(e)||null==e.type)throw new ys("Invalid PeerId",vm);const t=e.toCID().toString();return new Cm(`${Rm}${t}`)}async function Nm(e,t,n){const r=new Map;for(const o of n){if(null==o)continue;if(o.multiaddr instanceof Uint8Array&&(o.multiaddr=ji(o.multiaddr)),!qi(o.multiaddr))throw new ys("Multiaddr was invalid",vm);if(!await t(e,o.multiaddr))continue;const n=o.isCertified??!1,i=o.multiaddr.toString(),s=r.get(i);null!=s?o.isCertified=s.isCertified||n:r.set(i,{multiaddr:o.multiaddr,isCertified:n})}return[...r.values()].sort(((e,t)=>e.multiaddr.toString().localeCompare(t.multiaddr.toString()))).map((e=>{let{isCertified:t,multiaddr:n}=e;return{isCertified:t,multiaddr:n.bytes}}))}async function Pm(e,t,n,r){if(null==t)throw new ys("Invalid PeerData",vm);if(null!=t.publicKey&&null!=e.publicKey&&!Ur(t.publicKey,e.publicKey))throw new ys("publicKey bytes do not match peer id publicKey bytes",vm);const o=r.existingPeer;if(null!=o&&!e.equals(o.id))throw new ys("peer id did not match existing peer id",vm);let i=o?.addresses??[],s=new Set(o?.protocols??[]),a=o?.metadata??new Map,l=o?.tags??new Map,c=o?.peerRecordEnvelope;if("patch"===n){if(null==t.multiaddrs&&null==t.addresses||(i=[],null!=t.multiaddrs&&i.push(...t.multiaddrs.map((e=>({isCertified:!1,multiaddr:e})))),null!=t.addresses&&i.push(...t.addresses)),null!=t.protocols&&(s=new Set(t.protocols)),null!=t.metadata){a=Om(t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata),{validate:Lm})}if(null!=t.tags){l=Om(t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),{validate:Dm,map:Bm})}null!=t.peerRecordEnvelope&&(c=t.peerRecordEnvelope)}if("merge"===n){if(null!=t.multiaddrs&&i.push(...t.multiaddrs.map((e=>({isCertified:!1,multiaddr:e})))),null!=t.addresses&&i.push(...t.addresses),null!=t.protocols&&(s=new Set([...s,...t.protocols])),null!=t.metadata){const e=t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata);for(const[t,n]of e)null==n?a.delete(t):a.set(t,n);a=Om([...a.entries()],{validate:Lm})}if(null!=t.tags){const e=t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),n=new Map(l);for(const[t,r]of e)null==r?n.delete(t):n.set(t,r);l=Om([...n.entries()],{validate:Dm,map:Bm})}null!=t.peerRecordEnvelope&&(c=t.peerRecordEnvelope)}const u={addresses:await Nm(e,r.addressFilter??(async()=>!0),i),protocols:[...s.values()].sort(((e,t)=>e.localeCompare(t))),metadata:a,tags:l,publicKey:o?.id.publicKey??t.publicKey??e.publicKey,peerRecordEnvelope:c};return"RSA"!==e.type&&delete u.publicKey,u}function Om(e,t){const n=new Map;for(const[r,o]of e)null!=o&&t.validate(r,o);for(const[r,o]of e.sort(((e,t)=>{let[n]=e,[r]=t;return n.localeCompare(r)})))null!=o&&n.set(r,t.map?.(r,o)??o);return n}function Lm(e,t){if("string"!==typeof e)throw new ys("Metadata key must be a string",vm);if(!(t instanceof Uint8Array))throw new ys("Metadata value must be a Uint8Array",vm)}function Dm(e,t){if("string"!==typeof e)throw new ys("Tag name must be a string",vm);if(null!=t.value){if(parseInt(`${t.value}`,10)!==t.value)throw new ys("Tag value must be an integer",vm);if(t.value<0||t.value>100)throw new ys("Tag value must be between 0-100",vm)}if(null!=t.ttl){if(parseInt(`${t.ttl}`,10)!==t.ttl)throw new ys("Tag ttl must be an integer",vm);if(t.ttl<0)throw new ys("Tag ttl must be between greater than 0",vm)}}function Bm(e,t){let n;return null!=t.expiry&&(n=t.expiry),null!=t.ttl&&(n=BigInt(Date.now()+Number(t.ttl))),{value:t.value??0,expiry:n}}function Um(e,t,n){const r=e.toString().split("/")[2],o=Pd(ye.decode(r)),i=n.get(o);if(null!=i)return i;const s=Am(o,t);return n.set(o,s),s}class Mm{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=wm({name:"peer-store",singleProcess:!0})}async has(e){return this.datastore.has(Tm(e))}async delete(e){if(this.peerId.equals(e))throw new ys("Cannot delete self peer",vm);await this.datastore.delete(Tm(e))}async load(e){return Am(e,await this.datastore.get(Tm(e)))}async save(e,t){const{existingBuf:n,existingPeer:r}=await this.#T(e),o=await Pm(e,t,"patch",{addressFilter:this.addressFilter});return this.#N(e,o,n,r)}async patch(e,t){const{existingBuf:n,existingPeer:r}=await this.#T(e),o=await Pm(e,t,"patch",{addressFilter:this.addressFilter,existingPeer:r});return this.#N(e,o,n,r)}async merge(e,t){const{existingBuf:n,existingPeer:r}=await this.#T(e),o=await Pm(e,t,"merge",{addressFilter:this.addressFilter,existingPeer:r});return this.#N(e,o,n,r)}async*all(e){const t=new Zg;for await(const{key:n,value:r}of this.datastore.query(function(e,t){return null==e?{}:{prefix:Rm,filters:(e.filters??[]).map((e=>n=>{let{key:r,value:o}=n;return e(Um(r,o,t))})),orders:(e.orders??[]).map((e=>(n,r)=>e(Um(n.key,n.value,t),Um(r.key,r.value,t))))}}(e??{},t))){const e=Um(n,r,t);e.id.equals(this.peerId)||(yield e)}}async#T(e){try{const t=await this.datastore.get(Tm(e));return{existingBuf:t,existingPeer:Am(e,t)}}catch(t){if("ERR_NOT_FOUND"!==t.code)throw t}return{}}async#N(e,t,n,r){const o=Em.encode(t);return null!=n&&Ur(o,n)?{peer:Am(e,o),previous:r,updated:!1}:(await this.datastore.put(Tm(e),o),{peer:Am(e,o),previous:r,updated:!0})}}class Fm{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 Mm(e,t)}[Symbol.toStringTag]="@libp2p/peer-store";async forEach(e,t){this.log.trace("forEach await read lock");const n=await this.store.lock.readLock();this.log.trace("forEach got read lock");try{for await(const n of this.store.all(t))e(n)}finally{this.log.trace("forEach release read lock"),n()}}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 Dr(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 n=await this.store.lock.writeLock();this.log.trace("save got write lock");try{const n=await this.store.save(e,t);return this.#P(e,n),n.peer}finally{this.log.trace("save release write lock"),n()}}async patch(e,t){this.log.trace("patch await write lock");const n=await this.store.lock.writeLock();this.log.trace("patch got write lock");try{const n=await this.store.patch(e,t);return this.#P(e,n),n.peer}finally{this.log.trace("patch release write lock"),n()}}async merge(e,t){this.log.trace("merge await write lock");const n=await this.store.lock.writeLock();this.log.trace("merge got write lock");try{const n=await this.store.merge(e,t);return this.#P(e,n),n.peer}finally{this.log.trace("merge release write lock"),n()}}async consumePeerRecord(e,t){const n=await qf.openAndCertify(e,Ff.DOMAIN);if(!1===t?.equals(n.peerId))return this.log("envelope peer id was not the expected peer id - expected: %p received: %p",t,n.peerId),!1;const r=Ff.createFromProtobuf(n.payload);let o;try{o=await this.get(n.peerId)}catch(i){if("ERR_NOT_FOUND"!==i.code)throw i}if(null!=o?.peerRecordEnvelope){const e=await qf.createFromProtobuf(o.peerRecordEnvelope),t=Ff.createFromProtobuf(e.payload);if(t.seqNumber>=r.seqNumber)return this.log("sequence number was lower or equal to existing sequence number - stored: %d received: %d",t.seqNumber,r.seqNumber),!1}return await this.patch(r.peerId,{peerRecordEnvelope:e,addresses:r.multiaddrs.map((e=>({isCertified:!0,multiaddr:e})))}),!0}#P(e,t){t.updated&&(this.peerId.equals(e)?this.events.safeDispatchEvent("self:peer:update",{detail:t}):this.events.safeDispatchEvent("peer:update",{detail:t}))}}const $m=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e);})();for(const t of e);};const Hm=function(e){const[t,n]=null!=e[Symbol.asyncIterator]?[e[Symbol.asyncIterator](),Symbol.asyncIterator]:[e[Symbol.iterator](),Symbol.iterator],r=[];return{peek:()=>t.next(),push:e=>{r.push(e)},next:()=>r.length>0?{done:!1,value:r.shift()}:t.next(),[n](){return this}}};const qm=function(e,t){let n=0;if(null!=e[Symbol.asyncIterator])return async function*(){for await(const r of e)await t(r,n++)&&(yield r)}();const r=Hm(e),{value:o,done:i}=r.next();if(!0===i)return function*(){}();const s=t(o,n++);if("function"===typeof s.then)return async function*(){await s&&(yield o);for await(const e of r)await t(e,n++)&&(yield e)}();const a=t;return function*(){!0===s&&(yield o);for(const e of r)a(e,n++)&&(yield e)}()};const jm=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(){const n=await Dr(e);yield*n.sort(t)}():function*(){const n=Dr(e);yield*n.sort(t)}()};const Vm=function(e,t){return null!=e[Symbol.asyncIterator]?async function*(){let n=0;if(!(t<1))for await(const r of e)if(yield r,n++,n===t)return}():function*(){let n=0;if(!(t<1))for(const r of e)if(yield r,n++,n===t)return}()};class zm{put(e,t,n){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 n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const{key:r,value:o}of e)await t.put(r,o,n),yield r}()}catch(n){return Promise.reject(n)}}getMany(e){try{var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const r of e)yield{key:r,value:await t.get(r,n)}}()}catch(n){return Promise.reject(n)}}deleteMany(e){try{var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){for await(const r of e)await t.delete(r,n),yield r}()}catch(n){return Promise.reject(n)}}batch(){let e=[],t=[];return{put(t,n){e.push({key:t,value:n})},delete(e){t.push(e)},commit:async n=>{await $m(this.putMany(e,n)),e=[],await $m(this.deleteMany(t,n)),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 n=this._all(e,t);if(null!=e.prefix){const t=e.prefix;n=qm(n,(e=>e.key.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(n=e.filters.reduce(((e,t)=>qm(e,t)),n)),Array.isArray(e.orders)&&(n=e.orders.reduce(((e,t)=>jm(e,t)),n)),null!=e.offset){let t=0;const r=e.offset;n=qm(n,(()=>t++>=r))}return null!=e.limit&&(n=Vm(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(null!=e.prefix){const t=e.prefix;n=qm(n,(e=>e.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(n=e.filters.reduce(((e,t)=>qm(e,t)),n)),Array.isArray(e.orders)&&(n=e.orders.reduce(((e,t)=>jm(e,t)),n)),null!=e.offset){const t=e.offset;let r=0;n=qm(n,(()=>r++>=t))}return null!=e.limit&&(n=Vm(n,e.limit)),n}}var Km=__webpack_require__(4823);class Wm extends zm{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 n=n??new Error("Not Found"),Km(n,"ERR_NOT_FOUND");var n;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 Cm(e),value:t}}*_allKeys(){for(const e of this.data.keys())yield new Cm(e)}}const Gm=e=>e;function Ym(e,t){const n=e.getPeerId();if(null!=n){Nd(n).equals(t)&&(e=e.decapsulate(ji(`/p2p/${t.toString()}`)))}return e}class Qm{log;components;listen;announce;observed;announceFilter;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{listen:n=[],announce:r=[]}=t;this.components=e,this.log=e.logger.forComponent("libp2p:address-manager"),this.listen=n.map((e=>e.toString())),this.announce=new Set(r.map((e=>e.toString()))),this.observed=new Map,this.announceFilter=t.announceFilter??Gm,this._updatePeerStoreAddresses=function(e,t){let n;return function(){clearTimeout(n),n=setTimeout((function(){n=void 0,e()}),t)}}(this._updatePeerStoreAddresses.bind(this),1e3),e.events.addEventListener("transport:listening",(()=>{this._updatePeerStoreAddresses()})),e.events.addEventListener("transport:close",(()=>{this._updatePeerStoreAddresses()}))}[Symbol.toStringTag]="@libp2p/address-manager";_updatePeerStoreAddresses(){const e=this.getAnnounceAddrs().concat(this.components.transportManager.getAddrs()).concat([...this.observed.entries()].filter((e=>{let[t,n]=e;return n.confident})).map((e=>{let[t]=e;return ji(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=>ji(e)))}getAnnounceAddrs(){return Array.from(this.announce).map((e=>ji(e)))}getObservedAddrs(){return Array.from(this.observed).map((e=>{let[t]=e;return ji(t)}))}addObservedAddr(e){const t=(e=Ym(e,this.components.peerId)).toString();this.observed.has(t)||this.observed.set(t,{confident:!1})}confirmObservedAddr(e){const t=(e=Ym(e,this.components.peerId)).toString(),n=(this.observed.get(t)??{confident:!1}).confident;this.observed.set(t,{confident:!0}),n||this._updatePeerStoreAddresses()}removeObservedAddr(e){const t=(e=Ym(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,n]=e;return n.confident})).map((e=>{let[t]=e;return t})));const t=new Set(e);return this.announceFilter(Array.from(t).map((e=>ji(e)))).map((e=>!0===e.protos().pop()?.path||e.getPeerId()===this.components.peerId.toString()?e:e.encapsulate(`/p2p/${this.components.peerId.toString()}`)))}}function Jm(e){return null!=e&&"function"===typeof e.start&&"function"===typeof e.stop}class Xm{components={};_started=!1;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.components={};for(const[t,n]of Object.entries(e))this.components[t]=n;null==this.components.logger&&(this.components.logger=zg())}isStarted(){return this._started}async _invokeStartableMethod(e){await Promise.all(Object.values(this.components).filter((e=>Jm(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 Zm=["metrics","connectionProtector","dns"],ey=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];function ty(e){return Array.isArray(e?.[Ed])?e[Ed]:[]}function ny(e){return Array.isArray(e?.[Sd])?e[Sd]:[]}function ry(e){return e?.[Symbol.toStringTag]??e?.toString()??"unknown"}var oy=__webpack_require__(7364);const iy=["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 oy.Netmask(e)));function sy(e){for(const t of iy)if(t.contains(e))return!0;return!1}function ay(e){return ui(e)?sy(e):/^::ffff:([0-9a-fA-F]{1,4}):([0-9a-fA-F]{1,4})$/.test(e)?function(e){const t=e.split(":");if(t.length<2)return!1;const n=t[t.length-1].padStart(4,"0"),r=t[t.length-2].padStart(4,"0");return sy(`${parseInt(r.substring(0,2),16)}.${parseInt(r.substring(2),16)}.${parseInt(n.substring(0,2),16)}.${parseInt(n.substring(2),16)}`)}(e):function(e){return/^::ffff:([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)}(e)?function(e){const t=e.split(":");return sy(t[t.length-1])}(e):di(e)?function(e){return/^::$/.test(e)||/^::1$/.test(e)||/^64:ff9b::([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/.test(e)||/^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(e)||/^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(e)||/^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(e)||/^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(e)||/^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(e)||/^f[c-d]([0-9a-fA-F]{2,2}):/i.test(e)||/^fe[8-9a-bA-B][0-9a-fA-F]:/i.test(e)||/^ff([0-9a-fA-F]{2,2}):/i.test(e)}(e):void 0}function ly(){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async e=>{const t=e.stringTuples();return(4===t[0][0]||41===t[0][0])&&Boolean(ay(`${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 cy(e){try{const{address:t}=e.nodeAddress();return Boolean(ay(t))}catch{return!0}}function uy(e,t){const n=function(e,t){const n=cy(e.multiaddr),r=cy(t.multiaddr);return n&&!r?1:!n&&r?-1:0}(e,t);if(0!==n)return n;const r=function(e,t){const n=vp.exactMatch(e.multiaddr),r=vp.exactMatch(t.multiaddr);return n&&!r?1:!n&&r?-1:0}(e,t);if(0!==r)return r;const o=function(e,t){return e.isCertified&&!t.isCertified?-1:!e.isCertified&&t.isCertified?1:0}(e,t);return o}function dy(e){const t=[yy.A];return null==e?t:Array.isArray(e)?0===e.length?t:e:[e]}function hy(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:yy[e.type]}))),Answer:(e.Answer??e.answers??[]).map((e=>({name:e.name,type:yy[e.type],TTL:e.TTL??e.ttl??60,data:e.data instanceof Uint8Array?dr(e.data):e.data})))}}function fy(e){const t=new nm({concurrency:(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).queryConcurrency??4});return async function(n){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=new URLSearchParams;o.set("name",n),dy(r.types).forEach((e=>{o.append("type",yy[e])})),r.onProgress?.(new Ig("dns:query",{detail:n}));const i=await t.add((async()=>{const t=await fetch(`${e}?${o}`,{headers:{accept:"application/dns-json"},signal:r?.signal});if(200!==t.status)throw new Error(`Unexpected HTTP status: ${t.status} - ${t.statusText}`);const n=hy(await t.json());return r.onProgress?.(new Ig("dns:response",{detail:n})),n}),{signal:r.signal});if(null==i)throw new Error("No DNS response received");return i}}var py=__webpack_require__(101);class gy{lru;constructor(e){this.lru=py(e)}get(e,t){let n=!0;const r=[];for(const o of t){const t=this.getAnswers(e,o);if(0===t.length){n=!1;break}r.push(...t)}if(n)return hy({answers:r})}getAnswers(e,t){const n=`${e.toLowerCase()}-${t}`,r=this.lru.get(n);if(null!=r){const e=r.filter((e=>e.expires>Date.now())).map((e=>{let{expires:t,value:n}=e;return{...n,TTL:Math.round((t-Date.now())/1e3),type:yy[n.type]}}));return 0===e.length&&this.lru.remove(n),e}return[]}add(e,t){const n=`${e.toLowerCase()}-${t.type}`,r=this.lru.get(n)??[];r.push({expires:Date.now()+1e3*(t.TTL??60),value:t}),this.lru.set(n,r)}remove(e,t){const n=`${e.toLowerCase()}-${t}`;this.lru.remove(n)}clear(){this.lru.clear()}}class my{resolvers;cache;constructor(e){var t;this.resolvers={},this.cache=(t=e.cacheSize??1e3,new gy(t)),Object.entries(e.resolvers??{}).forEach((e=>{let[t,n]=e;Array.isArray(n)||(n=[n]),t.endsWith(".")||(t=`${t}.`),this.resolvers[t]=n})),null==this.resolvers["."]&&(this.resolvers["."]=[fy("https://cloudflare-dns.com/dns-query"),fy("https://dns.google/resolve")])}async query(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=dy(t.types),r=!1!==t.cached?this.cache.get(e,n):void 0;if(null!=r)return t.onProgress?.(new Ig("dns:cache",{detail:r})),r;const o=`${e.split(".").pop()}.`,i=(this.resolvers[o]??this.resolvers["."]).sort((()=>Math.random()>.5?-1:1)),s=[];for(const l of i){if(!0===t.signal?.aborted)break;try{const r=await l(e,{...t,types:n});for(const t of r.Answer)this.cache.add(e,t);return r}catch(a){s.push(a),t.onProgress?.(new Ig("dns:error",{detail:a}))}}if(1===s.length)throw s[0];throw new AggregateError(s,`DNS lookup of ${e} ${n} failed`)}}var yy;!function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"}(yy||(yy={}));const{code:by}=wi("dnsaddr");class wy extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Max recursive depth reached"),this.name="RecursionLimitError"}}const vy=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t.maxRecursiveDepth??32;if(0===n)throw new wy("Max recursive depth reached");const[,r]=e.stringTuples().find((e=>{let[t]=e;return t===by}))??[],o=t?.dns??function(){return new my(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}(),i=await o.query(`_dnsaddr.${r}`,{signal:t?.signal,types:[yy.TXT]}),s=e.getPeerId(),a=[];for(const l of i.Answer){const e=l.data.replace(/["']/g,"").trim().split("=")[1];if(null==e)continue;if(null!=s&&!e.includes(s))continue;const r=ji(e);if(e.startsWith("/dnsaddr")){const e=await r.resolve({...t,maxRecursiveDepth:n-1});a.push(...e.map((e=>e.toString())))}else a.push(r.toString())}return a};const Ey=__webpack_require__(8355);var Sy,ky;!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"}(Sy||(Sy={})),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"}(ky||(ky={}));const Ay={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{resolvers:{dnsaddr:vy},addressSorter:uy},transportManager:{faultTolerance:hg.FATAL_ALL}};function _y(e){if(li(e))return{peerId:e,multiaddrs:[]};let t;if(Array.isArray(e)||(e=[e]),e.length>0){const n=e[0].getPeerId();t=null==n?void 0:Nd(n),e.forEach((e=>{if(!qi(e))throw new ys("Invalid Multiaddr",ky.ERR_INVALID_MULTIADDR);const n=e.getPeerId();if(null==n){if(null!=t)throw new ys("Multiaddrs must all have the same peer id or have no peer id",ky.ERR_INVALID_PARAMETERS)}else{const e=Nd(n);if(!0!==t?.equals(e))throw new ys("Multiaddrs must all have the same peer id or have no peer id",ky.ERR_INVALID_PARAMETERS)}}))}return{peerId:t,multiaddrs:e}}class Iy 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 xy(e,t,n,r){const o=new Iy(r?.errorMessage,r?.errorCode);return!0===n?.aborted?Promise.reject(o):new Promise(((i,s)=>{function a(){n?.removeEventListener("abort",u),e.removeEventListener(t,l),null!=r?.errorEvent&&e.removeEventListener(r.errorEvent,c)}const l=e=>{try{if(!1===r?.filter?.(e))return}catch(t){return a(),void s(t)}a(),i(e)},c=e=>{a(),s(e.detail)},u=()=>{a(),s(o)};n?.addEventListener("abort",u),e.addEventListener(t,l),null!=r?.errorEvent&&e.addEventListener(r.errorEvent,c)}))}class Cy{deferred;signal;constructor(e){this.signal=e,this.deferred=Xr(),this.onAbort=this.onAbort.bind(this),this.signal?.addEventListener("abort",this.onAbort)}onAbort(){this.deferred.reject(this.signal?.reason??new ms)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}}class Ry{id;fn;options;recipients;status;timeline;controller;constructor(e,t){this.id=`${parseInt(String(1e9*Math.random()),10).toString()}${Date.now()}`,this.status="queued",this.fn=e,this.options=t,this.recipients=[],this.timeline={created:Date.now()},this.controller=new AbortController,Go(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 ms),this.cleanup())}async join(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=new Cy(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 Dd(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.cleanup(),e.signal?.removeEventListener("abort",this.onAbort)}))}}class Ty extends Yo{concurrency;queue;pending;sort;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.sort=e.sort,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){this.queue.push(e),null!=this.sort&&this.queue.sort(this.sort)}async add(e,t){t?.signal?.throwIfAborted();const n=new Ry(e,t);return this.enqueue(n),this.safeDispatchEvent("add"),this.tryToStartAnother(),n.join(t).then((e=>(this.safeDispatchEvent("completed",{detail:e}),this.safeDispatchEvent("success",{detail:{job:n,result:e}}),e))).catch((e=>{if("queued"===n.status)for(let t=0;t<this.queue.length;t++)if(this.queue[t]===n){this.queue.splice(t,1);break}throw this.safeDispatchEvent("error",{detail:e}),this.safeDispatchEvent("failure",{detail:{job:n,error:e}}),e}))}clear(){this.queue.splice(0,this.queue.length)}abort(){this.queue.forEach((e=>{e.abort(new ms)})),this.clear()}async onEmpty(e){0!==this.size&&await xy(this,"empty",e?.signal)}async onSizeLessThan(e,t){this.size<e||await xy(this,"next",t?.signal,{filter:()=>this.size<e})}async onIdle(e){0===this.pending&&0===this.size||await xy(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=no({objectMode:!0}),n=e=>{null!=e?this.abort():this.clear(),t.end(e)},r=e=>{null!=e.detail&&t.push(e.detail)},o=e=>{n(e.detail)},i=()=>{n()},s=()=>{n(new ys("Queue aborted","ERR_QUEUE_ABORTED"))};this.addEventListener("completed",r),this.addEventListener("error",o),this.addEventListener("idle",i),e?.signal?.addEventListener("abort",s);try{yield*t}finally{this.removeEventListener("completed",r),this.removeEventListener("error",o),this.removeEventListener("idle",i),e?.signal?.removeEventListener("abort",s),n()}}}class Ny extends Ty{has(e){return null!=this.find(e)}find(e){return this.queue.find((t=>e.equals(t.options.peerId)))}}const Py=42e4,Oy="last-dial-failure",Ly={minConnections:5,maxQueueLength:100,autoDialConcurrency:25,autoDialPriority:0,autoDialInterval:5e3,autoDialPeerRetryThreshold:Py,autoDialDiscoveredPeersDebounce:10};class Dy{connectionManager;peerStore;queue;minConnections;autoDialPriority;autoDialIntervalMs;autoDialMaxQueueLength;autoDialPeerRetryThresholdMs;autoDialDiscoveredPeersDebounce;autoDialInterval;started;running;log;constructor(e,t){let n;this.connectionManager=e.connectionManager,this.peerStore=e.peerStore,this.minConnections=t.minConnections??Ly.minConnections,this.autoDialPriority=t.autoDialPriority??Ly.autoDialPriority,this.autoDialIntervalMs=t.autoDialInterval??Ly.autoDialInterval,this.autoDialMaxQueueLength=t.maxQueueLength??Ly.maxQueueLength,this.autoDialPeerRetryThresholdMs=t.autoDialPeerRetryThreshold??Ly.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=t.autoDialDiscoveredPeersDebounce??Ly.autoDialDiscoveredPeersDebounce,this.log=e.logger.forComponent("libp2p:connection-manager:auto-dial"),this.started=!1,this.running=!1,this.queue=new Ny({concurrency:t.autoDialConcurrency??Ly.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(n),n=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 n=new Gg(this.connectionManager.getDialQueue().map((e=>e.peerId)).filter(Boolean)),r=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):n.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)]}),o=r.sort((()=>Math.random()>.5?1:-1)),i=new Zg;for(const a of o)i.has(a.id)||i.set(a.id,[...a.tags.values()].reduce(((e,t)=>e+t.value),0));const s=o.sort(((e,t)=>{const n=i.get(e.id)??0,r=i.get(t.id)??0;return n>r?-1:n<r?1:0})).filter((e=>{const t=e.metadata.get(Oy);if(null==t)return!0;const n=parseInt(dr(t));return!!isNaN(n)||Date.now()-n>this.autoDialPeerRetryThresholdMs}));this.log("selected %d/%d peers to dial",s.length,r.length);for(const a of s)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 By=["/ipfs/id/1.0.0","/ipfs/id/push/1.0.0","/libp2p/autonat/1.0.0","/libp2p/dcutr"];const Uy={maxConnections:100,allow:[]};class My{maxConnections;connectionManager;peerStore;allow;events;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.maxConnections=t.maxConnections??Uy.maxConnections,this.allow=t.allow??Uy.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;if(this.log("checking max connections limit %d/%d",t,this.maxConnections),t<=this.maxConnections)return;const n=new Zg;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(s){"ERR_NOT_FOUND"!==s.code&&this.log.error("error loading peer tags",s)}}}const r=this.sortConnections(e,n),o=Math.max(t-this.maxConnections,0),i=[];for(const a of r){this.log("too many connections open - closing a connection to %p",a.remotePeer);if(this.allow.some((e=>a.remoteAddr.toString().startsWith(e.toString())))||i.push(a),i.length===o)break}await Promise.all(i.map((async e=>{await async function(e,t){const n=e?.streams?.map((e=>e.protocol))??[],r=t?.closableProtocols??By;if(!(n.filter((e=>null!=e&&!r.includes(e))).length>0))try{await(e?.close(t))}catch(s){e?.abort(s)}}(e,{signal:AbortSignal.timeout(1e3)})}))),this.events.safeDispatchEvent("connection:prune",{detail:i})}sortConnections(e,t){return e.sort(((e,t)=>{const n=e.timeline.open,r=t.timeline.open;return n<r?1:n>r?-1:0})).sort(((e,t)=>"outbound"===e.direction&&"inbound"===t.direction?1:"inbound"===e.direction&&"outbound"===t.direction?-1:0)).sort(((e,t)=>e.streams.length>t.streams.length?1:e.streams.length<t.streams.length?-1:0)).sort(((e,n)=>{const r=t.get(e.remotePeer)??0,o=t.get(n.remotePeer)??0;return r>o?1:r<o?-1:0}))}}class Fy extends Ty{constructor(){super({...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},sort:(e,t)=>e.options.priority>t.options.priority?-1:e.options.priority<t.options.priority?1:0})}}function $y(e){const t=new globalThis.AbortController;function n(){t.abort();for(const t of e)null!=t?.removeEventListener&&t.removeEventListener("abort",n)}for(const o of e){if(!0===o?.aborted){n();break}null!=o?.addEventListener&&o.addEventListener("abort",n)}const r=t.signal;return r.clear=function(){for(const t of e)null!=t?.removeEventListener&&t.removeEventListener("abort",n)},r}const Hy={addressSorter:uy,maxParallelDials:50,maxDialQueueLength:500,maxPeerAddrsToDial:25,dialTimeout:5e3,resolvers:{dnsaddr:vy}};class qy{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??Hy.addressSorter,this.maxPeerAddrsToDial=t.maxPeerAddrsToDial??Hy.maxPeerAddrsToDial,this.maxDialQueueLength=t.maxDialQueueLength??Hy.maxDialQueueLength,this.dialTimeout=t.dialTimeout??Hy.dialTimeout,this.connections=t.connections??new Zg,this.log=e.logger.forComponent("libp2p:connection-manager:dial-queue"),this.components=e,this.shutDownController=new AbortController,Go(1/0,this.shutDownController.signal);for(const[n,r]of Object.entries(t.resolvers??{}))Hi.set(n,r);this.queue=new Fy({concurrency:t.maxParallelDials??Hy.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,Go(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:n,multiaddrs:r}=_y(e),o=Array.from(this.connections.values()).flat().find((e=>!0!==t.force&&(!!e.remotePeer.equals(n)||r.find((t=>t.equals(e.remoteAddr))))));if(null!=o)return this.log("already connected to %a",o.remoteAddr),t.onProgress?.(new Ig("dial-queue:already-connected")),o;const i=this.queue.queue.find((e=>{if(!0===n?.equals(e.options.peerId))return!0;const t=e.options.multiaddrs;if(null==t)return!1;for(const n of r)if(t.has(n.toString()))return!0;return!1}));if(null!=i){this.log("joining existing dial target for %p",n);for(const e of r)i.options.multiaddrs.add(e.toString());return t.onProgress?.(new Ig("dial-queue:already-in-dial-queue")),i.join(t)}if(this.queue.size>=this.maxDialQueueLength)throw new ys("Dial queue is full","ERR_DIAL_QUEUE_FULL");return this.log("creating dial target for %p",n,r.map((e=>e.toString()))),t.onProgress?.(new Ig("dial-queue:add-to-dial-queue")),this.queue.add((async e=>{e?.onProgress?.(new Ig("dial-queue:start-dial"));const t=this.createDialAbortController(e?.signal);let r;try{r=await this.calculateMultiaddrs(n,e?.multiaddrs,{...e,signal:t}),e?.onProgress?.(new Ig("dial-queue:calculated-addresses",r)),r.map((e=>{let{multiaddr:t}=e;return t.toString()})).forEach((t=>{e?.multiaddrs.add(t)}))}catch(o){throw t.clear(),o}try{let i=0;const s=[];for(const a of r){if(i===this.maxPeerAddrsToDial)throw this.log("dialed maxPeerAddrsToDial (%d) addresses for %p, not trying any others",i,n),new ys("Peer had more than maxPeerAddrsToDial",ky.ERR_TOO_MANY_ADDRESSES);i++;try{const n=await this.components.transportManager.dial(a.multiaddr,{...e,signal:t});return this.log("dial to %a succeeded",a.multiaddr),n}catch(o){if(this.log.error("dial failed to %a",a.multiaddr,o),null!=n)try{await this.components.peerStore.patch(n,{metadata:{[Oy]:Dt(Date.now().toString())}})}catch(o){this.log.error("could not update last dial failure key for %p",n,o)}if(t.aborted)throw new ys(o.message,ws);s.push(o)}}if(1===s.length)throw s[0];throw new bs(s,"All multiaddr dials failed",ky.ERR_TRANSPORT_DIAL_FAILED)}finally{t.clear()}}),{peerId:n,priority:t.priority??jy,multiaddrs:new Set(r.map((e=>e.toString()))),signal:t.signal,onProgress:t.onProgress})}createDialAbortController(e){const t=$y([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,e]);return Go(1/0,t),t}async calculateMultiaddrs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=[...t].map((e=>({multiaddr:ji(e),isCertified:!1})));if(null!=e){if(this.components.peerId.equals(e))throw new ys("Tried to dial self",ky.ERR_DIALED_SELF);if(!0===await(this.components.connectionGater.denyDialPeer?.(e)))throw new ys("The dial request is blocked by gater.allowDialPeer",ky.ERR_PEER_DIAL_INTERCEPTED);if(0===r.length){this.log("loading multiaddrs for %p",e);try{const t=await this.components.peerStore.get(e);r.push(...t.addresses),this.log("loaded multiaddrs for %p",e,r.map((e=>{let{multiaddr:t}=e;return t.toString()})))}catch(u){if(u.code!==ky.ERR_NOT_FOUND)throw u}}if(0===r.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,r.map((e=>{let{multiaddr:t}=e;return t.toString()}))),r.push(...t.multiaddrs.map((e=>({multiaddr:e,isCertified:!1}))))}catch(u){u.code!==ky.ERR_NO_ROUTERS_AVAILABLE&&this.log.error("looking up multiaddrs for %p in the peer routing failed",e,u)}}}let o=(await Promise.all(r.map((async e=>{const t=await async function(e,t){let n=!1;for(const o of Hi.keys())if(n=e.protoNames().includes(o),n)break;if(!n)return[e];const r=await e.resolve(t);return t.log("resolved %s to",e,r.map((e=>e.toString()))),r}(e.multiaddr,{dns:this.components.dns,...n,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()}`;o=o.map((e=>{const n=e.multiaddr.protos().pop();return!0===n?.path?e:null==e.multiaddr.getPeerId()?{multiaddr:e.multiaddr.encapsulate(t),isCertified:e.isCertified}:e}))}const i=o.filter((t=>{if(null==this.components.transportManager.dialTransportForMultiaddr(t.multiaddr))return!1;const n=t.multiaddr.getPeerId();return null==e||null==n||e.equals(n)})),s=new Map;for(const d of i){const e=d.multiaddr.toString(),t=s.get(e);null==t?s.set(e,d):t.isCertified=t.isCertified||d.isCertified||!1}const a=[...s.values()];if(0===a.length)throw new ys("The dial request has no valid addresses",ky.ERR_NO_VALID_ADDRESSES);const l=[];for(const d of a)null!=this.components.connectionGater.denyDialMultiaddr&&await this.components.connectionGater.denyDialMultiaddr(d.multiaddr)||l.push(d);const c=l.sort(this.addressSorter);if(0===c.length)throw new ys("The connection gater denied all addresses in the dial request",ky.ERR_NO_VALID_ADDRESSES);return this.log.trace("addresses for %p before filtering",e??"unknown peer",o.map((e=>{let{multiaddr:t}=e;return t.toString()}))),this.log.trace("addresses for %p after filtering",e??"unknown peer",c.map((e=>{let{multiaddr:t}=e;return t.toString()}))),c}async isDialable(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Array.isArray(e)||(e=[e]);try{const n=await this.calculateMultiaddrs(void 0,new Set(e.map((e=>e.toString()))),t);return!1!==t.runOnTransientConnection||null!=n.find((e=>!vp.matches(e.multiaddr)))}catch(n){this.log.trace("error calculating if multiaddr(s) were dialable",n)}return!1}}const jy=50,Vy={minConnections:5,maxConnections:100,inboundConnectionThreshold:5,maxIncomingPendingConnections:10,autoDialConcurrency:25,autoDialPriority:0,autoDialMaxQueueLength:100,autoDialPeerRetryThreshold:Py,autoDialDiscoveredPeersDebounce:10};class zy{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??Vy.maxConnections;const n=t.minConnections??Vy.minConnections;if(this.maxConnections<n)throw new ys("Connection Manager maxConnections must be greater than minConnections",ky.ERR_INVALID_PARAMETERS);this.connections=new Zg,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=>ji(e))),this.deny=(t.deny??[]).map((e=>ji(e))),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=t.maxIncomingPendingConnections??Vy.maxIncomingPendingConnections,this.inboundConnectionRateLimiter=new Hp({points:t.inboundConnectionThreshold??Vy.inboundConnectionThreshold,duration:1}),this.autoDial=new Dy({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{minConnections:n,autoDialConcurrency:t.autoDialConcurrency??Vy.autoDialConcurrency,autoDialPriority:t.autoDialPriority??Vy.autoDialPriority,autoDialPeerRetryThreshold:t.autoDialPeerRetryThreshold??Vy.autoDialPeerRetryThreshold,autoDialDiscoveredPeersDebounce:t.autoDialDiscoveredPeersDebounce??Vy.autoDialDiscoveredPeersDebounce,maxQueueLength:t.autoDialMaxQueueLength??Vy.autoDialMaxQueueLength}),this.connectionPruner=new My({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new qy(e,{addressSorter:t.addressSorter??uy,maxParallelDials:t.maxParallelDials??50,maxDialQueueLength:t.maxDialQueueLength??500,maxPeerAddrsToDial:t.maxPeerAddrsToDial??25,dialTimeout:t.dialTimeout??5e3,resolvers:t.resolvers??{dnsaddr:vy},connections:this.connections})}[Symbol.toStringTag]="@libp2p/connection-manager";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 n of t)"inbound"===n.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 n of t)for(const t of n.streams){const n=`${t.direction} ${t.protocol??"unnegotiated"}`;e[n]=(e[n]??0)+1}return e}}),this.metrics?.registerMetricGroup("libp2p_connection_manager_protocol_streams_per_connection_90th_percentile",{label:"protocol",calculate:()=>{const e={};for(const n of this.connections.values())for(const t of n){const n={};for(const e of t.streams){const t=`${e.direction} ${e.protocol??"unnegotiated"}`;n[t]=(n[t]??0)+1}for(const[t,r]of Object.entries(n))e[t]=e[t]??[],e[t].push(r)}const t={};for(let[n,r]of Object.entries(e)){r=r.sort(((e,t)=>e-t));const e=Math.floor(.9*r.length);t[n]=r[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 n of t)e.push((async()=>{try{await n.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 n=t.remotePeer,r=this.connections.get(n);let o=!1;null!=r?r.push(t):(o=!0,this.connections.set(n,[t])),null!=n.publicKey&&"RSA"===n.type&&await this.peerStore.patch(n,{publicKey:n.publicKey}),o&&this.events.safeDispatchEvent("peer:connect",{detail:t.remotePeer})}onDisconnect(e){const{detail:t}=e;if(!this.started)return;const n=t.remotePeer;let r=this.connections.get(n);null!=r&&r.length>1?(r=r.filter((e=>e.id!==t.id)),this.connections.set(n,r)):null!=r&&(this.connections.delete(n),this.events.safeDispatchEvent("peer:disconnect",{detail:t.remotePeer}))}getConnections(e){if(null!=e)return this.connections.get(e)??[];let t=[];for(const n of this.connections.values())t=t.concat(n);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 ys("Not started",ky.ERR_NODE_NOT_STARTED);t.signal?.throwIfAborted();const{peerId:n}=_y(e);if(null!=n&&!0!==t.force){this.log("dial %p",n);const e=this.getConnections(n).find((e=>!e.transient));if(null!=e)return this.log("had an existing non-transient connection to %p",n),t.onProgress?.(new Ig("dial-queue:already-connected")),e}const r=await this.dialQueue.dial(e,{...t,priority:t.priority??jy});let o=this.connections.get(r.remotePeer);null==o&&(o=[],this.connections.set(r.remotePeer,o));let i=!1;for(const s of o)s.id===r.id&&(i=!0);return i||o.push(r),r}async closeConnections(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.connections.get(e)??[];await Promise.all(n.map((async e=>{try{await e.close(t)}catch(n){e.abort(n)}})))}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=>ji(e)))})))}async isDialable(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.dialQueue.isDialable(e,t)}}class Ky{movingAverage;variance;deviation;forecast;timespan;previousTime;constructor(e){this.timespan=e,this.movingAverage=0,this.variance=0,this.deviation=0,this.forecast=0}alpha(e,t){return 1-Math.exp(-(e-t)/this.timespan)}push(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Date.now();if(null!=this.previousTime){const n=this.alpha(t,this.previousTime),r=e-this.movingAverage,o=n*r;this.movingAverage=n*e+(1-n)*this.movingAverage,this.variance=(1-n)*(this.variance+r*o),this.deviation=Math.sqrt(this.variance),this.forecast=this.movingAverage+n*r}else this.movingAverage=e;this.previousTime=t}}class Wy{success;failure;next;metric;timeoutMultiplier;failureMultiplier;minTimeout;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.success=new Ky(e.interval??5e3),this.failure=new Ky(e.interval??5e3),this.next=new Ky(e.interval??5e3),this.failureMultiplier=e.failureMultiplier??2,this.timeoutMultiplier=e.timeoutMultiplier??1.2,this.minTimeout=e.minTimeout??2e3,null!=e.metricName&&(this.metric=e.metrics?.registerMetricGroup(e.metricName))}getTimeoutSignal(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Math.max(Math.round(this.next.movingAverage*(e.timeoutFactor??this.timeoutMultiplier)),this.minTimeout),n=AbortSignal.timeout(t),r=$y([e.signal,n]);return Go(1/0,r,n),r.start=Date.now(),r.timeout=t,r}cleanUp(e){const t=Date.now()-e.start;e.aborted?(this.failure.push(t),this.next.push(t*this.failureMultiplier),this.metric?.update({failureMovingAverage:this.failure.movingAverage,failureDeviation:this.failure.deviation,failureForecast:this.failure.forecast,failureVariance:this.failure.variance,failure:t})):(this.success.push(t),this.next.push(t),this.metric?.update({successMovingAverage:this.success.movingAverage,successDeviation:this.success.deviation,successForecast:this.success.forecast,successVariance:this.success.variance,success:t}))}}class Gy{protocol;components;log;heartbeatInterval;pingIntervalMs;abortController;timeout;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.components=e,this.protocol=`/${t.protocolPrefix??"ipfs"}/ping/1.0.0`,this.log=e.logger.forComponent("libp2p:connection-monitor"),this.pingIntervalMs=t.pingInterval??1e4,this.timeout=new Wy({...t.pingTimeout??{},metrics:e.metrics,metricName:"libp2p_connection_monitor_ping_time_milliseconds"})}[Symbol.toStringTag]="@libp2p/connection-monitor";[Ed]=["@libp2p/connection-monitor"];start(){this.abortController=new AbortController,this.heartbeatInterval=setInterval((()=>{this.components.connectionManager.getConnections().forEach((e=>{Promise.resolve().then((async()=>{let t=Date.now();try{const n=this.timeout.getTimeoutSignal({signal:this.abortController?.signal}),r=$d(await e.newStream(this.protocol,{signal:n,runOnTransientConnection:!0}));t=Date.now(),await Promise.all([r.write(Ou(32),{signal:n}),r.read(32,{signal:n})]),e.rtt=Date.now()-t,await r.unwrap().close({signal:n})}catch(n){if("ERR_UNSUPPORTED_PROTOCOL"!==n.code)throw n;e.rtt=(Date.now()-t)/2}})).catch((t=>{this.log.error("error during heartbeat, aborting connection",t),e.abort(t)}))}))}),this.pingIntervalMs)}stop(){this.abortController?.abort(),null!=this.heartbeatInterval&&clearInterval(this.heartbeatInterval)}}class Yy{routers;started;components;constructor(e,t){this.routers=t.routers??[],this.started=!1,this.components=e}[Symbol.toStringTag]="@libp2p/content-routing";isStarted(){return this.started}async start(){this.started=!0}async stop(){this.started=!1}findProviders(e){try{var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){if(0===t.routers.length)throw new ys("No content routers available",ky.ERR_NO_ROUTERS_AVAILABLE);const r=t,o=new Gg;for await(const i of oo(...r.routers.map((t=>t.findProviders(e,n)))))null!=i&&(i.multiaddrs.length>0&&await t.components.peerStore.merge(i.id,{multiaddrs:i.multiaddrs}),o.has(i.id)||(o.add(i.id),yield i))}()}catch(n){return Promise.reject(n)}}async provide(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(0===this.routers.length)throw new ys("No content routers available",ky.ERR_NO_ROUTERS_AVAILABLE);await Promise.all(this.routers.map((async n=>{await n.provide(e,t)})))}async put(e,t,n){if(!this.isStarted())throw new ys(Sy.NOT_STARTED_YET,ky.ERR_NODE_NOT_STARTED);await Promise.all(this.routers.map((async r=>{await r.put(e,t,n)})))}async get(e,t){if(!this.isStarted())throw new ys(Sy.NOT_STARTED_YET,ky.ERR_NODE_NOT_STARTED);return Promise.any(this.routers.map((async n=>n.get(e,t))))}}class Qy{fp;h;seed;constructor(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:2;if(r>64)throw new TypeError("Invalid Fingerprint Size");const o=t.hashV(e,n),i=v(r);for(let s=0;s<i.length;s++)i[s]=o[s];0===i.length&&(i[0]=7),this.fp=i,this.h=t,this.seed=n}hash(){return this.h.hash(this.fp,this.seed)}equals(e){return e?.fp instanceof Uint8Array&&Ur(this.fp,e.fp)}}function Jy(e,t){return Math.floor(Math.random()*(t-e))+e}class Xy{contents;constructor(e){this.contents=new Array(e).fill(null)}has(e){if(!(e instanceof Qy))throw new TypeError("Invalid Fingerprint");return this.contents.some((t=>e.equals(t)))}add(e){if(!(e instanceof Qy))throw new TypeError("Invalid Fingerprint");for(let t=0;t<this.contents.length;t++)if(null==this.contents[t])return this.contents[t]=e,!0;return!0}swap(e){if(!(e instanceof Qy))throw new TypeError("Invalid Fingerprint");const t=Jy(0,this.contents.length-1),n=this.contents[t];return this.contents[t]=e,n}remove(e){if(!(e instanceof Qy))throw new TypeError("Invalid Fingerprint");const t=this.contents.findIndex((t=>e.equals(t)));return t>-1&&(this.contents[t]=null,!0)}}const Zy={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},eb={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},tb=new globalThis.TextEncoder;function nb(e){let{size:t=32,utf8Buffer:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Zy[t])throw new Error("The `size` option must be one of 32, 64, 128, 256, 512, or 1024");if("string"===typeof e){if(n)return function(e,t,n){if(0===n.length)throw new Error("The `utf8Buffer` option must have a length greater than zero");const r=Zy[t];let o=eb[t],i=e;for(;i.length>0;){const e=tb.encodeInto(i,n);i=i.slice(e.read);for(let i=0;i<e.written;i++)o^=BigInt(n[i]),o=BigInt.asUintN(t,o*r)}return o}(e,t,n);e=tb.encode(e)}return function(e,t){const n=Zy[t];let r=eb[t];for(let o=0;o<e.length;o++)r^=BigInt(e[o]),r=BigInt.asUintN(t,r*n);return r}(e,t)}__webpack_require__(2962);const rb={hash:e=>Number(nb(e,{size:32})),hashV:(e,t)=>ob(rb.hash(e,t))};function ob(e){let t=e.toString(16);return t.length%2===1&&(t=`0${t}`),Dt(t,"base16")}class ib{bucketSize;filterSize;fingerprintSize;buckets;count;hash;seed;constructor(e){this.filterSize=e.filterSize,this.bucketSize=e.bucketSize??4,this.fingerprintSize=e.fingerprintSize??2,this.count=0,this.buckets=[],this.hash=e.hash??rb,this.seed=e.seed??Jy(0,Math.pow(2,10))}add(e){"string"===typeof e&&(e=Dt(e));const t=new Qy(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,r=(n^t.hash())%this.filterSize;if(null==this.buckets[n]&&(this.buckets[n]=new Xy(this.bucketSize)),null==this.buckets[r]&&(this.buckets[r]=new Xy(this.bucketSize)),this.buckets[n].add(t)||this.buckets[r].add(t))return this.count++,!0;const o=[n,r];let i=o[Jy(0,o.length-1)];null==this.buckets[i]&&(this.buckets[i]=new Xy(this.bucketSize));for(let s=0;s<500;s++){const e=this.buckets[i].swap(t);if(null!=e&&(i=(i^e.hash())%this.filterSize,null==this.buckets[i]&&(this.buckets[i]=new Xy(this.bucketSize)),this.buckets[i].add(e)))return this.count++,!0}return!1}has(e){"string"===typeof e&&(e=Dt(e));const t=new Qy(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,r=this.buckets[n]?.has(t)??!1;if(r)return r;const o=(n^t.hash())%this.filterSize;return this.buckets[o]?.has(t)??!1}remove(e){"string"===typeof e&&(e=Dt(e));const t=new Qy(e,this.hash,this.seed,this.fingerprintSize),n=this.hash.hash(e,this.seed)%this.filterSize,r=this.buckets[n]?.remove(t)??!1;if(r)return this.count--,r;const o=(n^t.hash())%this.filterSize,i=this.buckets[o]?.remove(t)??!1;return i&&this.count--,i}get reliable(){return Math.floor(this.count/this.filterSize*100)<=90}}const sb={1:.5,2:.84,4:.95,8:.98};function ab(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.001;const n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.001;return e>.002?2:e>1e-5?4:8}(t),r=sb[n];return{filterSize:Math.round(e/r),bucketSize:n,fingerprintSize:Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*n)),64)}}class lb{filterSize;bucketSize;fingerprintSize;scale;filterSeries;hash;seed;constructor(e){this.bucketSize=e.bucketSize??4,this.filterSize=e.filterSize??(1<<18)/this.bucketSize,this.fingerprintSize=e.fingerprintSize??2,this.scale=e.scale??2,this.hash=e.hash??rb,this.seed=e.seed??Jy(0,Math.pow(2,10)),this.filterSeries=[new ib({filterSize:this.filterSize,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed})]}add(e){if("string"===typeof e&&(e=Dt(e)),this.has(e))return!0;let t=this.filterSeries.find((e=>e.reliable));if(null==t){const e=this.filterSize*Math.pow(this.scale,this.filterSeries.length);t=new ib({filterSize:e,bucketSize:this.bucketSize,fingerprintSize:this.fingerprintSize,hash:this.hash,seed:this.seed}),this.filterSeries.push(t)}return t.add(e)}has(e){"string"===typeof e&&(e=Dt(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].has(e))return!0;return!1}remove(e){"string"===typeof e&&(e=Dt(e));for(let t=0;t<this.filterSeries.length;t++)if(this.filterSeries[t].remove(e))return!0;return!1}get count(){return this.filterSeries.reduce(((e,t)=>e+t.count),0)}}const cb=globalThis.CustomEvent??Event;class ub{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??[]}[Symbol.toStringTag]="@libp2p/peer-routing";async findPeer(e,t){if(0===this.routers.length)throw new ys("No peer routers available",ky.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.peerId.toString())throw new ys("Should not try to find self",ky.ERR_FIND_SELF);const n=this,r=oo(...this.routers.map((r=>async function*(){try{yield await r.findPeer(e,t)}catch(o){n.log.error(o)}}())));for await(const o of r)if(null!=o)return o.multiaddrs.length>0&&await this.peerStore.merge(o.id,{multiaddrs:o.multiaddrs}),o;throw new ys(Sy.NOT_FOUND,ky.ERR_NOT_FOUND)}getClosestPeers(e){try{var t=this;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){if(0===t.routers.length)throw new ys("No peer routers available",ky.ERR_NO_ROUTERS_AVAILABLE);const r=t,o=function(e){let t=arguments.length>2?arguments[2]:void 0;return new lb({...ab(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:.001),...t??{}})}(1024);for await(const i of function(e){try{let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return async function*(){let n=t.concurrency??1/0;n<1&&(n=1/0);const r=null!=t.ordered&&t.ordered,o=new EventTarget,i=[];let s,a=Xr(),l=Xr(),c=!1,u=!1;function d(){return r?i[0]?.done:Boolean(i.find((e=>e.done)))}function*h(){for(;i.length>0&&i[0].done;){const e=i[0];if(i.shift(),!e.ok)throw u=!0,a.resolve(),e.err;yield e.value,a.resolve()}}function*f(){for(;d();)for(let e=0;e<i.length;e++)if(i[e].done){const t=i[e];if(i.splice(e,1),e--,!t.ok)throw u=!0,a.resolve(),t.err;yield t.value,a.resolve()}}for(o.addEventListener("task-complete",(()=>{l.resolve()})),Promise.resolve().then((async()=>{try{for await(const t of e){if(i.length===n&&(a=Xr(),await a.promise),u)break;const e={done:!1};i.push(e),t().then((t=>{e.done=!0,e.ok=!0,e.value=t,o.dispatchEvent(new cb("task-complete"))}),(t=>{e.done=!0,e.err=t,o.dispatchEvent(new cb("task-complete"))}))}c=!0,o.dispatchEvent(new cb("task-complete"))}catch(t){s=t,o.dispatchEvent(new cb("task-complete"))}}));;){if(d()||(l=Xr(),await l.promise),null!=s)throw s;if(r?yield*h():yield*f(),c&&0===i.length)break}}()}catch(t){return Promise.reject(t)}}(async function*(){const t=oo(...r.routers.map((t=>t.getClosestPeers(e,n))));for await(let e of t)yield async()=>{if(0===e.multiaddrs.length)try{e=await r.findPeer(e.id,{...n,useCache:!1})}catch(t){return void r.log.error("could not find peer multiaddrs",t)}return e}}()))null!=i&&(i.multiaddrs.length>0&&await t.peerStore.merge(i.id,{multiaddrs:i.multiaddrs}),o.has(i.id.toBytes())||(o.add(i.id.toBytes()),yield i))}()}catch(n){return Promise.reject(n)}}}class db extends Yo{peerRouting;log;walking;walkers;shutdownController;walkController;needNext;constructor(e){super(),this.log=e.logger.forComponent("libp2p:random-walk"),this.peerRouting=e.peerRouting,this.walkers=0,this.walking=!1,this.shutdownController=new AbortController,Go(1/0,this.shutdownController.signal)}[Symbol.toStringTag]="@libp2p/random-walk";start(){this.shutdownController=new AbortController,Go(1/0,this.shutdownController.signal)}stop(){this.shutdownController.abort()}async*walk(e){this.walking||this.startWalk(),this.walkers++;const t=$y([this.shutdownController.signal,e?.signal]);Go(1/0,t);try{for(;;){this.needNext?.resolve(),this.needNext=Xr();const e=await xy(this,"walk:peer",t,{errorEvent:"walk:error"});yield e.detail}}finally{t.clear(),this.walkers--,0===this.walkers&&(this.walkController?.abort(),this.walkController=void 0)}}startWalk(){this.walking=!0,this.walkController=new AbortController,Go(1/0,this.walkController.signal);const e=$y([this.walkController.signal,this.shutdownController.signal]);Go(1/0,e);const t=Date.now();let n=0;Promise.resolve().then((async()=>{for(this.log("start walk");this.walkers>0;)try{const t=Ou(32);let r=Date.now();for await(const o of this.peerRouting.getClosestPeers(t,{signal:e}))e.aborted&&this.log("aborting walk"),e.throwIfAborted(),this.log("found peer %p after %dms for %d walkers",o.id,Date.now()-r,this.walkers),n++,this.safeDispatchEvent("walk:peer",{detail:o}),1===this.walkers&&null!=this.needNext&&(this.log("wait for need next"),await Dd(this.needNext.promise,e)),r=Date.now();this.log("walk iteration for %b and %d walkers finished, found %d peers",t,this.walkers,n)}catch(t){this.log.error("randomwalk errored",t),this.safeDispatchEvent("walk:error",{detail:t})}this.log("no walkers left, ended walk")})).catch((e=>{this.log.error("randomwalk errored",e)})).finally((()=>{this.log("finished walk, found %d peers after %dms",n,Date.now()-t),this.walking=!1}))}}class hb{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)}[Symbol.toStringTag]="@libp2p/registrar";getProtocols(){return Array.from(new Set([...this.handlers.keys()])).sort()}getHandler(e){const t=this.handlers.get(e);if(null==t)throw new ys(`No handler registered for protocol ${e}`,ky.ERR_NO_HANDLER_FOR_PROTOCOL);return t}getTopologies(e){const t=this.topologies.get(e);return null==t?[]:[...t.values()]}async handle(e,t,n){if(this.handlers.has(e))throw new ys(`Handler already registered for protocol ${e}`,ky.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const r=Ey.bind({ignoreUndefined:!0})({maxInboundStreams:32,maxOutboundStreams:64},n);this.handlers.set(e,{handler:t,options:r}),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 ys("invalid topology",ky.ERR_INVALID_PARAMETERS);const n=`${(1e9*Math.random()).toString(36)}${Date.now()}`;let r=this.topologies.get(e);return null==r&&(r=new Map,this.topologies.set(e,r)),r.set(n,t),n}unregister(e){for(const[t,n]of this.topologies.entries())n.has(e)&&(n.delete(e),0===n.size&&this.topologies.delete(t))}_onDisconnect(e){const t=e.detail;this.components.peerStore.get(t).then((e=>{for(const n of e.protocols){const e=this.topologies.get(n);if(null!=e)for(const n of e.values())!1!==n.filter?.has(t)&&(n.filter?.remove(t),n.onDisconnect?.(t))}})).catch((e=>{e.code!==ky.ERR_NOT_FOUND&&this.log.error("could not inform topologies of disconnecting peer %p",t,e)}))}_onPeerUpdate(e){const{peer:t,previous:n}=e.detail,r=(n?.protocols??[]).filter((e=>!t.protocols.includes(e)));for(const o of r){const e=this.topologies.get(o);if(null!=e)for(const n of e.values())!1!==n.filter?.has(t.id)&&(n.filter?.remove(t.id),n.onDisconnect?.(t.id))}}_onPeerIdentify(e){const t=e.detail.protocols,n=e.detail.connection,r=e.detail.peerId;for(const o of t){const e=this.topologies.get(o);if(null!=e)for(const t of e.values())n.transient&&!0!==t.notifyOnTransient||!0!==t.filter?.has(r)&&(t.filter?.add(r),t.onConnect?.(r,n))}}}class fb extends Map{metric;constructor(e){super();const{name:t,metrics:n}=e;this.metric=n.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 pb{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:n}=e;let r;return r=null!=n?new fb({name:t,metrics:n}):new Map,r}({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=t.faultTolerance??hg.FATAL_ALL}[Symbol.toStringTag]="@libp2p/transport-manager";add(e){const t=e[Symbol.toStringTag];if(null==t)throw new ys("Transport must have a valid tag",ky.ERR_INVALID_KEY);if(this.transports.has(t))throw new ys(`There is already a transport with the tag ${t}`,ky.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,n]of this.listeners)for(this.log("closing listeners for %s",t);n.length>0;){const t=n.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 n=this.dialTransportForMultiaddr(e);if(null==n)throw new ys(`No transport available for address ${String(e)}`,ky.ERR_TRANSPORT_UNAVAILABLE);t?.onProgress?.(new Ig("transport-manager:selected-transport",n[Symbol.toStringTag]));try{return await n.dial(e,{...t,upgrader:this.components.upgrader})}catch(r){throw null==r.code&&(r.code=ky.ERR_TRANSPORT_DIAL_FAILED),r}}getAddrs(){let e=[];for(const t of this.listeners.values())for(const n of t)e=[...e,...n.getAddrs()];return e}getTransports(){return Array.of(...this.transports.values())}getListeners(){return Array.of(...this.listeners.values()).flat()}dialTransportForMultiaddr(e){for(const t of this.transports.values()){if(t.dialFilter([e]).length>0)return t}}listenTransportForMultiaddr(e){for(const t of this.transports.values()){if(t.listenFilter([e]).length>0)return t}}async listen(e){if(!this.isStarted())throw new ys("Not started",ky.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[n,r]of this.transports.entries()){const o=r.listenFilter(e),i=[];for(const e of o){this.log("creating listener for %s on %a",n,e);const t=r.createListener({upgrader:this.components.upgrader});let o=this.listeners.get(n)??[];null==o&&(o=[],this.listeners.set(n,o)),o.push(t),t.addEventListener("listening",(()=>{this.components.events.safeDispatchEvent("transport:listening",{detail:t})})),t.addEventListener("close",(()=>{const e=o.findIndex((e=>e===t));o.splice(e,1),this.components.events.safeDispatchEvent("transport:close",{detail:t})})),i.push(t.listen(e))}if(0===i.length){t.push(n);continue}if(null==(await Promise.allSettled(i)).find((e=>"fulfilled"===e.status))&&this.faultTolerance!==hg.NO_FATAL)throw new ys(`Transport (${n}) could not listen on any available address`,ky.ERR_NO_VALID_ADDRESSES)}if(t.length===this.transports.size){const e=`no valid addresses were provided for transports [${t.join(", ")}]`;if(this.faultTolerance===hg.FATAL_ALL)throw new ys(e,ky.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 n=[];for(this.log.trace("closing listeners for %s",e);t.length>0;){const e=t.pop();null!=e&&n.push(e.close())}await Promise.all(n),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)}}const gb="/multistream/1.0.0",mb=1024,yb=Dt("\n");async function bb(e,t,n){await e.write(t,n)}async function wb(e,t){const n=await async function(e,t){const n=await e.read(t);if(0===n.byteLength||n.get(n.byteLength-1)!==yb[0])throw t.log.error("Invalid mss message - missing newline",n),new ys("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return n.sublist(0,-1)}(e,t);return dr(n.subarray())}async function vb(e,t,n){t=Array.isArray(t)?t:[t],n.log.trace("handle: available protocols %s",t);const r=Vd(e,{...n,maxDataLength:mb,maxLengthLength:2});for(;;){n.log.trace("handle: reading incoming string");const e=await wb(r,n);if(n.log.trace('handle: read "%s"',e),e!==gb){if(t.includes(e))return n.log.trace('handle: respond with "%s" for "%s"',e,e),await bb(r,Dt(`${e}\n`),n),n.log.trace('handle: responded with "%s" for "%s"',e,e),{stream:r.unwrap(),protocol:e};if("ls"!==e)n.log('handle: respond with "na" for "%s"',e),await bb(r,Dt("na\n"),n),n.log('handle: responded with "na" for "%s"',e);else{const o=new Hr(...t.map((e=>Vr.single(Dt(`${e}\n`)))),Dt("\n"));n.log.trace('handle: respond with "%s" for %s',t,e),await bb(r,o,n),n.log.trace('handle: responded with "%s" for %s',t,e)}}else n.log.trace('handle: respond with "%s" for "%s"',gb,e),await bb(r,Dt(`${gb}\n`),n),n.log.trace('handle: responded with "%s" for "%s"',gb,e)}}async function Eb(e,t,n){if(1===(t=Array.isArray(t)?[...t]:[t]).length&&!1===n.negotiateFully)return function(e,t,n){const r=e.sink.bind(e),o=e.source;let i=!1,s=!1;const a=Xr();let l=!1,c=!1;const u=Xr();let d=!1,h=!1;const f=Xr(),p=Vd({sink:r,source:o},{...n,maxDataLength:mb});async function g(){if(s)return n.log.trace("optimistic: already negotiating %s stream",t),void await a.promise;s=!0;try{l||(n.log.trace("optimistic: doing send protocol for %s stream",t),await m()),d||(n.log.trace("optimistic: doing read protocol for %s stream",t),await y())}finally{s=!1,i=!0,a.resolve()}}async function m(){if(c)await u.promise;else{c=!0;try{n.log.trace('optimistic: write ["%s", "%s", data] in source',gb,t),await p.writeV([Dt(`${gb}\n`),Dt(`${t}\n`)]),n.log.trace('optimistic: wrote ["%s", "%s", data] in source',gb,t)}finally{l=!0,c=!1,u.resolve()}}}async function y(){if(h)await f.promise;else{h=!0;try{n.log.trace("optimistic: reading multistream select header");let e=await wb(p,n);if(n.log.trace('optimistic: read multistream select header "%s"',e),e===gb&&(e=await wb(p,n)),n.log.trace('optimistic: read protocol "%s", expecting "%s"',e,t),e!==t)throw new ys("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}finally{d=!0,h=!1,f.resolve()}}}if(e.sink=async e=>{const{sink:r}=p.unwrap();await r(async function*(){let r=!1;for await(const o of e){if(c&&await u.promise,l)yield o;else{c=!0,n.log.trace('optimistic: write ["%s", "%s", data(%d)] in sink',gb,t,o.byteLength);const e=`${t}\n`;yield new Hr(Uint8Array.from([19]),Dt(`${gb}\n`),L(e.length),Dt(e),o).subarray(),n.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink',gb,t,o.byteLength),l=!0,c=!1,u.resolve(),g().catch((e=>{n.log.error("could not finish optimistic protocol negotiation of %s",t,e)}))}r=!0}r||await g()}())},e.source=async function*(){await g(),n.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=>{i||await g().catch((e=>{n.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=>{i||await g().catch((e=>{n.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 n=[];c&&n.push(u.promise),h&&n.push(f.promise),n.length>0?await Dd(Promise.all(n),e?.signal):(i=!0,s=!1,a.resolve()),await t(e)}}return{stream:e,protocol:t}}(e,t[0],n);const r=Vd(e,{...n,maxDataLength:mb}),o=t.shift();if(null==o)throw new Error("At least one protocol must be specified");n.log.trace('select: write ["%s", "%s"]',gb,o);const i=Dt(`${gb}\n`),s=Dt(`${o}\n`);await async function(e,t,n){await e.writeV(t,n)}(r,[i,s],n),n.log.trace("select: reading multistream-select header");let a=await wb(r,n);if(n.log.trace('select: read "%s"',a),a===gb&&(n.log.trace("select: reading protocol response"),a=await wb(r,n),n.log.trace('select: read "%s"',a)),a===o)return{stream:r.unwrap(),protocol:o};for(const l of t){n.log.trace('select: write "%s"',l),await bb(r,Dt(`${l}\n`),n),n.log.trace("select: reading protocol response");const e=await wb(r,n);if(n.log.trace('select: read "%s" for "%s"',e,l),e===l)return{stream:r.unwrap(),protocol:l}}throw new ys("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}const Sb=Symbol.for("@libp2p/connection");class kb{id;remoteAddr;remotePeer;direction;timeline;multiplexer;encryption;status;transient;log;tags;_newStream;_close;_abort;_getStreams;constructor(e){const{remoteAddr:t,remotePeer:n,newStream:r,close:o,abort:i,getStreams:s}=e;this.id=`${parseInt(String(1e9*Math.random())).toString(36)}${Date.now()}`,this.remoteAddr=t,this.remotePeer=n,this.direction=e.direction,this.status="open",this.timeline=e.timeline,this.multiplexer=e.multiplexer,this.encryption=e.encryption,this.transient=e.transient??!1,this.log=e.logger.forComponent(`libp2p:connection:${this.direction}:${this.id}`),null==this.remoteAddr.getPeerId()&&(this.remoteAddr=this.remoteAddr.encapsulate(`/p2p/${this.remotePeer}`)),this._newStream=r,this._close=o,this._abort=i,this._getStreams=s,this.tags=[]}[Symbol.toStringTag]="Connection";[Sb]=!0;get streams(){return this._getStreams()}async newStream(e,t){if("closing"===this.status)throw new ys("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if("closed"===this.status)throw new ys("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&!0!==t?.runOnTransientConnection)throw new ys("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");const n=await this._newStream(e,t);return n.direction="outbound",n}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);Go(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 Ab(e,t,n){let r=0;return n.streams.forEach((n=>{n.direction===t&&n.protocol===e&&r++})),r}class _b{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}[Symbol.toStringTag]="@libp2p/upgrader";async shouldBlockConnection(e,t,n){const r=this.components.connectionGater[n];if(void 0!==r&&await r(e,t))throw new ys(`The multiaddr connection is blocked by gater.${n}`,ky.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new ys("connection denied",ky.ERR_CONNECTION_DENIED);let n,r,o,i,s;const a=AbortSignal.timeout(this.inboundUpgradeTimeout),l=()=>{e.abort(new ys("inbound upgrade timeout",ws))};a.addEventListener("abort",l,{once:!0}),Go(1/0,a);try{if(!0===await(this.components.connectionGater.denyInboundConnection?.(e)))throw new ys("The multiaddr connection is blocked by gater.acceptConnection",ky.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(n=a,!0!==t?.skipEncryption){t?.onProgress?.(new Ig("upgrader:encrypt-inbound-connection")),({conn:n,remotePeer:r,protocol:s}=await this._encryptInbound(a));const e={...a,...n};await this.shouldBlockConnection(r,e,"denyInboundEncryptedConnection")}else{const t=e.remoteAddr.getPeerId();if(null==t)throw new ys("inbound connection that skipped encryption must have a peer id",ky.ERR_INVALID_MULTIADDR);const n=Nd(t);s="native",r=n}if(o=n,null!=t?.muxerFactory)i=t.muxerFactory;else if(this.muxers.size>0){t?.onProgress?.(new Ig("upgrader:multiplex-inbound-connection"));const e=await this._multiplexInbound({...a,...n},this.muxers);i=e.muxerFactory,o=e.stream}}catch(c){throw e.log.error("failed to upgrade inbound connection",c),c}return await this.shouldBlockConnection(r,e,"denyInboundUpgradedConnection"),e.log("successfully upgraded inbound connection"),this._createConnection({cryptoProtocol:s,direction:"inbound",maConn:e,upgradedConn:o,muxerFactory:i,remotePeer:r,transient:t?.transient})}finally{a.removeEventListener("abort",l),this.components.connectionManager.afterUpgradeInbound()}}async upgradeOutbound(e,t){const n=e.remoteAddr.getPeerId();let r,o,i,s,a,l;null!=n&&(r=Nd(n),await this.shouldBlockConnection(r,e,"denyOutboundConnection")),this.components.metrics?.trackMultiaddrConnection(e),e.log("starting the outbound connection upgrade");let c=e;if(!0!==t?.skipProtection){const t=this.components.connectionProtector;null!=t&&(c=await t.protect(e))}try{if(o=c,!0!==t?.skipEncryption){({conn:o,remotePeer:i,protocol:a}=await this._encryptOutbound(c,r));const e={...c,...o};await this.shouldBlockConnection(i,e,"denyOutboundEncryptedConnection")}else{if(null==r)throw new ys("Encryption was skipped but no peer id was passed",ky.ERR_INVALID_PEER);a="native",i=r}if(s=o,null!=t?.muxerFactory)l=t.muxerFactory;else if(this.muxers.size>0){const e=await this._multiplexOutbound({...c,...o},this.muxers);l=e.muxerFactory,s=e.stream}}catch(u){throw e.log.error("failed to upgrade outbound connection",u),await e.close(u),u}return await this.shouldBlockConnection(i,e,"denyOutboundUpgradedConnection"),e.log("successfully upgraded outbound connection"),this._createConnection({cryptoProtocol:a,direction:"outbound",maConn:e,upgradedConn:s,muxerFactory:l,remotePeer:i,transient:t?.transient})}_createConnection(e){var t=this;const{cryptoProtocol:n,direction:r,maConn:o,upgradedConn:i,remotePeer:s,muxerFactory:a,transient:l}=e;let c,u,d;null!=a&&(c=a.createStreamMuxer({direction:r,onIncomingStream:e=>{null!=d&&Promise.resolve().then((async()=>{const t=this.components.registrar.getProtocols(),{stream:n,protocol:r}=await vb(e,t,{log:e.log,yieldBytes:!1});if(null==d)return;d.log("incoming stream opened on %s",r);const o=function(e,t){try{const{options:n}=t.getHandler(e);return n.maxInboundStreams}catch(n){if(n.code!==ky.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return 32}(r,this.components.registrar);if(Ab(r,"inbound",d)===o){const t=new ys(`Too many inbound protocol streams for protocol "${r}" - limit ${o}`,ky.ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS);throw e.abort(t),t}e.source=n.source,e.sink=n.sink,e.protocol=r,null!=n.closeWrite&&(e.closeWrite=n.closeWrite),null!=n.closeRead&&(e.closeRead=n.closeRead),null!=n.close&&(e.close=n.close),await this.components.peerStore.merge(s,{protocols:[r]}),this.components.metrics?.trackProtocolStream(e,d),this._onStream({connection:d,stream:e,protocol:r})})).catch((async t=>{d.log.error("error handling incoming stream id %s",e.id,t.message,t.code,t.stack),null==e.timeline.close&&await e.close()}))}}),u=async function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null==c)throw new ys("Stream is not multiplexed",ky.ERR_MUXER_UNAVAILABLE);d.log("starting new stream for protocols %s",e);const r=await c.newStream();d.log.trace("started new stream %s for protocols %s",r.id,e);try{if(null==n.signal){r.log("no abort signal was passed while trying to negotiate protocols %s falling back to default timeout",e);const t=AbortSignal.timeout(3e4);Go(1/0,t),n={...n,signal:t}}r.log.trace("selecting protocol from protocols %s",e);const{stream:o,protocol:i}=await Eb(r,e,{...n,log:r.log,yieldBytes:!0});r.log("selected protocol %s",i);const a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};try{const{options:n}=t.getHandler(e);if(null!=n.maxOutboundStreams)return n.maxOutboundStreams}catch(r){if(r.code!==ky.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return n.maxOutboundStreams??64}(i,t.components.registrar,n),l=Ab(i,"outbound",d);if(l>=a){const e=new ys(`Too many outbound protocol streams for protocol "${i}" - ${l}/${a}`,ky.ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS);throw r.abort(e),e}return await t.components.peerStore.merge(s,{protocols:[i]}),r.source=o.source,r.sink=o.sink,r.protocol=i,null!=o.closeWrite&&(r.closeWrite=o.closeWrite),null!=o.closeRead&&(r.closeRead=o.closeRead),null!=o.close&&(r.close=o.close),t.components.metrics?.trackProtocolStream(r,d),r}catch(o){if(d.log.error("could not create new stream for protocols %s",e,o),null==r.timeline.close&&r.abort(o),null!=o.code)throw o;throw new ys(String(o),ky.ERR_UNSUPPORTED_PROTOCOL)}},Promise.all([c.sink(i.source),i.sink(c.source)]).catch((e=>{d.log.error("error piping data through muxer",e)})));const h=o.timeline;o.timeline=new Proxy(h,{set:function(){return null!=d&&"close"===(arguments.length<=1?void 0:arguments[1])&&null!=(arguments.length<=2?void 0:arguments[2])&&null==h.close&&(async()=>{try{"open"===d.status&&await d.close()}catch(e){d.log.error("error closing connection after timeline close",e)}finally{t.events.safeDispatchEvent("connection:close",{detail:d})}})().catch((e=>{d.log.error("error thrown while dispatching connection:close event",e)})),Reflect.set(...arguments)}}),o.timeline.upgraded=Date.now();var f;return f={remoteAddr:o.remoteAddr,remotePeer:s,status:"open",direction:r,timeline:o.timeline,multiplexer:c?.protocol,encryption:n,transient:l,logger:this.components.logger,newStream:u??(()=>{throw new ys("connection is not multiplexed",ky.ERR_CONNECTION_NOT_MULTIPLEXED)}),getStreams:()=>null!=c?c.streams:[],close:async e=>{null!=c&&(d.log.trace("close muxer"),await c.close(e)),d.log.trace("close maconn"),await o.close(e),d.log.trace("closed maconn")},abort:e=>{o.abort(e),null!=c&&c.abort(e)}},d=new kb(f),this.events.safeDispatchEvent("connection:open",{detail:d}),d}_onStream(e){const{connection:t,stream:n,protocol:r}=e,{handler:o,options:i}=this.components.registrar.getHandler(r);if(t.transient&&!0!==i.runOnTransientConnection)throw new ys("Cannot open protocol stream on transient connection","ERR_TRANSIENT_CONNECTION");o({connection:t,stream:n})}async _encryptInbound(e){const t=Array.from(this.connectionEncryption.keys());e.log("handling inbound crypto protocol selection",t);try{const{stream:n,protocol:r}=await vb(e,t,{log:e.log}),o=this.connectionEncryption.get(r);if(null==o)throw new Error(`no crypto module found for ${r}`);return e.log("encrypting inbound connection using",r),{...await o.secureInbound(this.components.peerId,n),protocol:r}}catch(n){throw e.log.error("encrypting inbound connection failed",n),new ys(n.message,ky.ERR_ENCRYPTION_FAILED)}}async _encryptOutbound(e,t){const n=Array.from(this.connectionEncryption.keys());e.log("selecting outbound crypto protocol",n);try{e.log.trace("selecting encrypter from %s",n);const{stream:r,protocol:o}=await Eb(e,n,{log:e.log,yieldBytes:!0}),i=this.connectionEncryption.get(o);if(null==i)throw new Error(`no crypto module found for ${o}`);return e.log("encrypting outbound connection to %p using %s",t,i),{...await i.secureOutbound(this.components.peerId,r,t),protocol:o}}catch(r){throw e.log.error("encrypting outbound connection to %p failed",t,r),new ys(r.message,ky.ERR_ENCRYPTION_FAILED)}}async _multiplexOutbound(e,t){const n=Array.from(t.keys());e.log("outbound selecting muxer %s",n);try{e.log.trace("selecting stream muxer from %s",n);const{stream:r,protocol:o}=await Eb(e,n,{log:e.log,yieldBytes:!0});e.log("selected %s as muxer protocol",o);return{stream:r,muxerFactory:t.get(o)}}catch(r){throw e.log.error("error multiplexing outbound connection",r),new ys(String(r),ky.ERR_MUXER_UNAVAILABLE)}}async _multiplexInbound(e,t){const n=Array.from(t.keys());e.log("inbound handling muxers %s",n);try{const{stream:r,protocol:o}=await vb(e,n,{log:e.log});return{stream:r,muxerFactory:t.get(o)}}catch(r){throw e.log.error("error multiplexing inbound connection",r),new ys(String(r),ky.ERR_MUXER_UNAVAILABLE)}}}class Ib extends Yo{peerId;peerStore;contentRouting;peerRouting;metrics;services;logger;status;components;log;constructor(e){super(),this.status="stopped";const t=new Yo,n=t.dispatchEvent.bind(t);t.dispatchEvent=e=>{const t=n(e),r=this.dispatchEvent(new Qo(e.type,{detail:e.detail}));return t||r},Go(1/0,t),this.peerId=e.peerId,this.logger=e.logger??zg(),this.log=this.logger.forComponent("libp2p"),this.services={};const r=this.components=function(){const e=new Xm(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return new Proxy(e,{get(t,n,r){if("string"===typeof n&&!ey.includes(n)){const t=e.components[n];if(null==t&&!Zm.includes(n))throw new ys(`${n} not set`,"ERR_SERVICE_MISSING");return t}return Reflect.get(t,n,r)},set:(t,n,r)=>("string"===typeof n?e.components[n]=r:Reflect.set(t,n,r),!0)})}({peerId:e.peerId,privateKey:e.privateKey,nodeInfo:e.nodeInfo??{name:"libp2p",version:"1.9.4"},logger:this.logger,events:t,datastore:e.datastore??new Wm,connectionGater:ly(e.connectionGater),dns:e.dns});this.peerStore=this.configureComponent("peerStore",new Fm(r,{addressFilter:this.components.connectionGater.filterMultiaddrForPeer,...e.peerStore})),null!=e.metrics&&(this.metrics=this.configureComponent("metrics",e.metrics(this.components))),r.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))};r.events.safeDispatchEvent("peer:discovery",{detail:t})}})),null!=e.connectionProtector&&this.configureComponent("connectionProtector",e.connectionProtector(r)),this.components.upgrader=new _b(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 pb(this.components,e.transportManager)),this.configureComponent("connectionManager",new zy(this.components,e.connectionManager)),!1!==e.connectionMonitor?.enabled&&this.configureComponent("connectionMonitor",new Gy(this.components,e.connectionMonitor)),this.configureComponent("registrar",new hb(this.components)),this.configureComponent("addressManager",new Qm(this.components,e.addresses));const o=(e.peerRouters??[]).map(((e,t)=>this.configureComponent(`peer-router-${t}`,e(this.components))));this.peerRouting=this.components.peerRouting=this.configureComponent("peerRouting",new ub(this.components,{routers:o}));const i=(e.contentRouters??[]).map(((e,t)=>this.configureComponent(`content-router-${t}`,e(this.components))));if(this.contentRouting=this.components.contentRouting=this.configureComponent("contentRouting",new Yy(this.components,{routers:i})),this.configureComponent("randomWalk",new db(this.components)),(e.peerDiscovery??[]).forEach(((e,t)=>{this.configureComponent(`peer-discovery-${t}`,e(this.components)).addEventListener("peer",(e=>{this.#O(e)}))})),e.transports?.forEach(((e,t)=>{this.components.transportManager.add(this.configureComponent(`transport-${t}`,e(this.components)))})),null!=e.services)for(const s of Object.keys(e.services)){const t=(0,e.services[s])(this.components);null!=t?(this.services[s]=t,this.configureComponent(s,t),null!=t[Ng]&&(this.log("registering service %s for content routing",s),i.push(t[Ng])),null!=t[Pg]&&(this.log("registering service %s for peer routing",s),o.push(t[Pg])),null!=t[nf]&&(this.log("registering service %s for peer discovery",s),t[nf].addEventListener?.("peer",(e=>{this.#O(e)})))):this.log.error("service factory %s returned null or undefined instance",s)}!function(e){const t={};for(const n of Object.values(e.components))for(const e of ty(n))t[e]=!0;for(const n of Object.values(e.components))for(const e of ny(n))if(!0!==t[e])throw new ys(`Service "${ry(n)}" required capability "${e}" but it was not provided by any component, you may need to add additional configuration when creating your node.`,"ERR_UNMET_SERVICE_DEPENDENCIES")}(r)}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 Gg;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 n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(null==t)throw new ys("no protocols were provided to open a stream",ky.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw new ys("no protocols were provided to open a stream",ky.ERR_INVALID_PROTOCOLS_FOR_STREAM);return(await this.dial(e,n)).newStream(t,n)}getMultiaddrs(){return this.components.addressManager.getAddresses()}getProtocols(){return this.components.registrar.getProtocols()}async hangUp(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};qi(e)&&(e=Nd(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(o){if(o.code!==ky.ERR_NOT_FOUND)throw o}const n=Br([Dt("/pk/"),e.multihash.digest]),r=await this.contentRouting.get(n,t);return bd(r),await this.peerStore.patch(e,{publicKey:r}),r}async handle(e,t,n){Array.isArray(e)||(e=[e]),await Promise.all(e.map((async e=>{await this.components.registrar.handle(e,t,n)})))}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)}async isDialable(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.components.connectionManager.isDialable(e,t)}#O(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(ky.ERR_DISCOVERED_SELF))}}async function xb(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.peerId??=await Yg();if(null==t.privateKey)throw new ys("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return e.privateKey??=await vd(t.privateKey),new Ib(await async function(e){const t=Ey(Ay,e);if(null===t.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw new ys(Sy.ERR_PROTECTOR_REQUIRED,ky.ERR_PROTECTOR_REQUIRED);if(null!=t.privateKey&&!(await Od(t.privateKey.public.bytes,t.privateKey.bytes)).equals(t.peerId))throw new ys("Private key doesn't match peer id",ky.ERR_INVALID_KEY);return t}(e))}const Cb="enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im",Rb="enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im",Tb="bootstrap",Nb={store:1,filter:2,lightPush:2};var Pb=__webpack_require__(495),Ob=__webpack_require__.t(Pb,2);const Lb=BigInt(0),Db=BigInt(1),Bb=BigInt(2),Ub=BigInt(3),Mb=BigInt(8),Fb=Object.freeze({a:Lb,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Db,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),$b=(e,t)=>(e+t/Bb)/t,Hb={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=Fb,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Db*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=$b(i*e,t),l=$b(-r*e,t);let c=fw(e-a*n-l*o,t),u=fw(-a*r-l*i,t);const d=c>s,h=u>s;if(d&&(c=t-c),h&&(u=t-u),c>s||u>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+e);return{k1neg:d,k1:c,k2neg:h,k2:u}}},qb=32,jb=32;function Vb(e){const{a:t,b:n}=Fb,r=fw(e*e),o=fw(r*e);return fw(o+t*e+n)}const zb=Fb.a===Lb;class Kb extends Error{constructor(e){super(e)}}function Wb(e){if(!(e instanceof Gb))throw new TypeError("JacobianPoint expected")}class Gb{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Jb))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Jb.ZERO)?Gb.ZERO:new Gb(e.x,e.y,Db)}static toAffineBatch(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Fb.P;const n=new Array(e.length),r=e.reduce(((e,r,o)=>r===Lb?e:(n[o]=e,fw(e*r,t))),Db),o=gw(r,t);return e.reduceRight(((e,r,o)=>r===Lb?e:(n[o]=fw(e*n[o],t),fw(e*r,t))),o),n}(e.map((e=>e.z)));return e.map(((e,n)=>e.toAffine(t[n])))}static normalizeZ(e){return Gb.toAffineBatch(e).map(Gb.fromAffine)}equals(e){Wb(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e,a=fw(r*r),l=fw(s*s),c=fw(t*l),u=fw(o*a),d=fw(fw(n*s)*l),h=fw(fw(i*r)*a);return c===u&&d===h}negate(){return new Gb(this.x,fw(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,r=fw(e*e),o=fw(t*t),i=fw(o*o),s=e+o,a=fw(Bb*(fw(s*s)-r-i)),l=fw(Ub*r),c=fw(l*l),u=fw(c-Bb*a),d=fw(l*(a-u)-Mb*i),h=fw(Bb*t*n);return new Gb(u,d,h)}add(e){Wb(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e;if(o===Lb||i===Lb)return this;if(t===Lb||n===Lb)return e;const a=fw(r*r),l=fw(s*s),c=fw(t*l),u=fw(o*a),d=fw(fw(n*s)*l),h=fw(fw(i*r)*a),f=fw(u-c),p=fw(h-d);if(f===Lb)return p===Lb?this.double():Gb.ZERO;const g=fw(f*f),m=fw(f*g),y=fw(c*g),b=fw(p*p-m-Bb*y),w=fw(p*(y-b)-d*m),v=fw(r*s*f);return new Gb(b,w,v)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Gb.ZERO;if("bigint"===typeof e&&e===Lb)return t;let n=hw(e);if(n===Db)return this;if(!zb){let e=t,r=this;for(;n>Lb;)n&Db&&(e=e.add(r)),r=r.double(),n>>=Db;return e}let{k1neg:r,k1:o,k2neg:i,k2:s}=Hb.splitScalar(n),a=t,l=t,c=this;for(;o>Lb||s>Lb;)o&Db&&(a=a.add(c)),s&Db&&(l=l.add(c)),c=c.double(),o>>=Db,s>>=Db;return r&&(a=a.negate()),i&&(l=l.negate()),l=new Gb(fw(l.x*Hb.beta),l.y,l.z),a.add(l)}precomputeWindow(e){const t=zb?128/e+1:256/e+1,n=[];let r=this,o=r;for(let i=0;i<t;i++){o=r,n.push(o);for(let t=1;t<2**(e-1);t++)o=o.add(r),n.push(o);r=o.double()}return n}wNAF(e,t){!t&&this.equals(Gb.BASE)&&(t=Jb.BASE);const n=t&&t._WINDOW_SIZE||1;if(256%n)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let r=t&&Qb.get(t);r||(r=this.precomputeWindow(n),t&&1!==n&&(r=Gb.normalizeZ(r),Qb.set(t,r)));let o=Gb.ZERO,i=Gb.BASE;const s=1+(zb?128/n:256/n),a=2**(n-1),l=BigInt(2**n-1),c=2**n,u=BigInt(n);for(let d=0;d<s;d++){const t=d*a;let n=Number(e&l);e>>=u,n>a&&(n-=c,e+=Db);const s=t,h=t+Math.abs(n)-1,f=d%2!==0,p=n<0;0===n?i=i.add(Yb(f,r[s])):o=o.add(Yb(p,r[h]))}return{p:o,f:i}}multiply(e,t){let n,r,o=hw(e);if(zb){const{k1neg:e,k1:i,k2neg:s,k2:a}=Hb.splitScalar(o);let{p:l,f:c}=this.wNAF(i,t),{p:u,f:d}=this.wNAF(a,t);l=Yb(e,l),u=Yb(s,u),u=new Gb(fw(u.x*Hb.beta),u.y,u.z),n=l.add(u),r=c.add(d)}else{const{p:e,f:i}=this.wNAF(o,t);n=e,r=i}return Gb.normalizeZ([n,r])[0]}toAffine(e){const{x:t,y:n,z:r}=this,o=this.equals(Gb.ZERO);null==e&&(e=o?Mb:gw(r));const i=e,s=fw(i*i),a=fw(s*i),l=fw(t*s),c=fw(n*a),u=fw(r*i);if(o)return Jb.ZERO;if(u!==Db)throw new Error("invZ was invalid");return new Jb(l,c)}}function Yb(e,t){const n=t.negate();return e?n:t}Gb.BASE=new Gb(Fb.Gx,Fb.Gy,Db),Gb.ZERO=new Gb(Lb,Db,Lb);const Qb=new WeakMap;class Jb{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,Qb.delete(this)}hasEvenY(){return this.y%Bb===Lb}static fromCompressedHex(e){const t=32===e.length,n=uw(t?e:e.subarray(1));if(!Ew(n))throw new Error("Point is not on curve");let r=function(e){const{P:t}=Fb,n=BigInt(6),r=BigInt(11),o=BigInt(22),i=BigInt(23),s=BigInt(44),a=BigInt(88),l=e*e*e%t,c=l*l*e%t,u=pw(c,Ub)*c%t,d=pw(u,Ub)*c%t,h=pw(d,Bb)*l%t,f=pw(h,r)*h%t,p=pw(f,o)*f%t,g=pw(p,s)*p%t,m=pw(g,a)*g%t,y=pw(m,s)*p%t,b=pw(y,Ub)*c%t,w=pw(b,i)*f%t,v=pw(w,n)*l%t,E=pw(v,Bb);if(E*E%t!==e)throw new Error("Cannot find square root");return E}(Vb(n));const o=(r&Db)===Db;if(t)o&&(r=fw(-r));else{1===(1&e[0])!==o&&(r=fw(-r))}const i=new Jb(n,r);return i.assertValidity(),i}static fromUncompressedHex(e){const t=uw(e.subarray(1,33)),n=uw(e.subarray(33,65)),r=new Jb(t,n);return r.assertValidity(),r}static fromHex(e){const t=dw(e),n=t.length,r=t[0];if(n===qb)return this.fromCompressedHex(t);if(33===n&&(2===r||3===r))return this.fromCompressedHex(t);if(65===n&&4===r)return this.fromUncompressedHex(t);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${n}`)}static fromPrivateKey(e){return Jb.BASE.multiply(kw(e))}static fromSignature(e,t,n){const{r:r,s:o}=_w(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const i=mw(dw(e)),{n:s}=Fb,a=2===n||3===n?r+s:r,l=gw(a,s),c=fw(-i*l,s),u=fw(o*l,s),d=1&n?"03":"02",h=Jb.fromHex(d+iw(a)),f=Jb.BASE.multiplyAndAddUnsafe(h,c,u);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 cw(this.toHex(e))}toHex(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=iw(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${iw(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:n}=this;if(!Ew(t)||!Ew(n))throw new Error(e);const r=fw(n*n);if(fw(r-Vb(t))!==Lb)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Jb(this.x,fw(-this.y))}double(){return Gb.fromAffine(this).double().toAffine()}add(e){return Gb.fromAffine(this).add(Gb.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Gb.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const r=Gb.fromAffine(this),o=t===Lb||t===Db||this!==Jb.BASE?r.multiplyUnsafe(t):r.multiply(t),i=Gb.fromAffine(e).multiplyUnsafe(n),s=o.add(i);return s.equals(Gb.ZERO)?void 0:s.toAffine()}}function Xb(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function Zb(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${rw(e)}`);const t=e[1],n=e.subarray(2,t+2);if(!t||n.length!==t)throw new Error("Invalid signature integer: wrong length");if(0===n[0]&&n[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:uw(n),left:e.subarray(t+2)}}Jb.BASE=new Jb(Fb.Gx,Fb.Gy),Jb.ZERO=new Jb(Lb,Lb);class ew{constructor(e,t){this.r=e,this.s=t,this.assertValidity()}static fromCompact(e){const t=e instanceof Uint8Array,n="Signature.fromCompact";if("string"!==typeof e&&!t)throw new TypeError(`${n}: Expected string or Uint8Array`);const r=t?rw(e):e;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new ew(lw(r.slice(0,64)),lw(r.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:n,s:r}=function(e){if(e.length<2||48!=e[0])throw new Error(`Invalid signature tag: ${rw(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=Zb(e.subarray(2)),{data:r,left:o}=Zb(n);if(o.length)throw new Error(`Invalid signature: left bytes after parsing: ${rw(o)}`);return{r:t,s:r}}(t?e:cw(e));return new ew(n,r)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!vw(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!vw(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=Fb.n>>Db;return this.s>e}normalizeS(){return this.hasHighS()?new ew(this.r,fw(-this.s,Fb.n)):this}toDERRawBytes(){return cw(this.toDERHex())}toDERHex(){const e=Xb(aw(this.s)),t=Xb(aw(this.r)),n=e.length/2,r=t.length/2,o=aw(n),i=aw(r);return`30${aw(r+n+4)}02${i}${t}02${o}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return cw(this.toCompactHex())}toCompactHex(){return iw(this.r)+iw(this.s)}}function tw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(!t.every((e=>e instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const r=t.reduce(((e,t)=>e+t.length),0),o=new Uint8Array(r);for(let i=0,s=0;i<t.length;i++){const e=t[i];o.set(e,s),s+=e.length}return o}const nw=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function rw(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let n=0;n<e.length;n++)t+=nw[e[n]];return t}const ow=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function iw(e){if("bigint"!==typeof e)throw new Error("Expected bigint");if(!(Lb<=e&&e<ow))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function sw(e){const t=cw(iw(e));if(32!==t.length)throw new Error("Error: expected 32 bytes");return t}function aw(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function lw(e){if("string"!==typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function cw(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 n=0;n<t.length;n++){const r=2*n,o=e.slice(r,r+2),i=Number.parseInt(o,16);if(Number.isNaN(i)||i<0)throw new Error("Invalid byte sequence");t[n]=i}return t}function uw(e){return lw(rw(e))}function dw(e){return e instanceof Uint8Array?Uint8Array.from(e):cw(e)}function hw(e){if("number"===typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"===typeof e&&vw(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function fw(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Fb.P;const n=e%t;return n>=Lb?n:t+n}function pw(e,t){const{P:n}=Fb;let r=e;for(;t-- >Lb;)r*=r,r%=n;return r}function gw(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Fb.P;if(e===Lb||t<=Lb)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=fw(e,t),r=t,o=Lb,i=Db,s=Db,a=Lb;for(;n!==Lb;){const e=r/n,t=r%n,l=o-s*e,c=i-a*e;r=n,n=t,o=s,i=a,s=l,a=c}if(r!==Db)throw new Error("invert: does not exist");return fw(o,t)}function mw(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=function(e){const t=8*e.length-256,n=uw(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:r}=Fb;return n>=r?n-r:n}let yw,bw;class ww{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),n=0;n<e;n++)t[n]=arguments[n];return Lw.hmacSha256(this.k,...t)}hmacSync(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return bw(this.k,...t)}checkSync(){if("function"!==typeof bw)throw new Kb("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 n=this.v.slice();t.push(n),e+=this.v.length}return tw(...t)}generateSync(){this.checkSync(),this.incr();let e=0;const t=[];for(;e<this.qByteLen;){this.v=this.hmacSync(this.v);const n=this.v.slice();t.push(n),e+=this.v.length}return tw(...t)}}function vw(e){return Lb<e&&e<Fb.n}function Ew(e){return Lb<e&&e<Fb.P}function Sw(e,t,n){let r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const{n:o}=Fb,i=mw(e,!0);if(!vw(i))return;const s=gw(i,o),a=Jb.BASE.multiply(i),l=fw(a.x,o);if(l===Lb)return;const c=fw(s*fw(t+n*l,o),o);if(c===Lb)return;let u=new ew(l,c),d=(a.x===u.r?0:2)|Number(a.y&Db);return r&&u.hasHighS()&&(u=u.normalizeS(),d^=1),{sig:u,recovery:d}}function kw(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(64!==e.length)throw new Error("Expected 32 bytes of private key");t=lw(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(e.length!==jb)throw new Error("Expected 32 bytes of private key");t=uw(e)}if(!vw(t))throw new Error("Expected private key: 0 < key < n");return t}function Aw(e){return e instanceof Jb?(e.assertValidity(),e):Jb.fromHex(e)}function _w(e){if(e instanceof ew)return e.assertValidity(),e;try{return ew.fromDER(e)}catch(t){return ew.fromCompact(e)}}function Iw(e){return uw(e.length>qb?e.slice(0,qb):e)}function xw(e){const t=Iw(e),n=fw(t,Fb.n);return Cw(n<Lb?t:n)}function Cw(e){return sw(e)}function Rw(e,t,n){if(null==e)throw new Error(`sign: expected valid message hash, not "${e}"`);const r=dw(e),o=kw(t),i=[Cw(o),xw(r)];if(null!=n){!0===n&&(n=Lw.randomBytes(qb));const e=dw(n);if(e.length!==qb)throw new Error("sign: Expected 32 bytes of extra data");i.push(e)}return{seed:tw(...i),m:Iw(r),d:o}}function Tw(e,t){const{sig:n,recovery:r}=e,{der:o,recovered:i}=Object.assign({canonical:!0,der:!0},t),s=o?n.toDERRawBytes():n.toCompactRawBytes();return i?[s,r]:s}const Nw={strict:!0};Jb.BASE._setWindowSize(8);const Pw={node:Ob,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0},Ow={},Lw={bytesToHex:rw,hexToBytes:cw,concatBytes:tw,mod:fw,invert:gw,isValidPrivateKey(e){try{return kw(e),!0}catch(t){return!1}},_bigintTo32Bytes:sw,_normalizePrivateKey:kw,hashToPrivateKey:e=>{if((e=dw(e)).length<40||e.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return sw(fw(uw(e),Fb.n-Db)+Db)},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(Pw.web)return Pw.web.getRandomValues(new Uint8Array(e));if(Pw.node){const{randomBytes:t}=Pw.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Lw.hashToPrivateKey(Lw.randomBytes(40)),precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Jb.BASE;const n=t===Jb.BASE?t:new Jb(t.x,t.y);return n._setWindowSize(e),n.multiply(Ub),n},sha256:async function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(Pw.web){const e=await Pw.web.subtle.digest("SHA-256",tw(...t));return new Uint8Array(e)}if(Pw.node){const{createHash:e}=Pw.node,n=e("sha256");return t.forEach((e=>n.update(e))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];if(Pw.web){const t=await Pw.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),r=tw(...n),o=await Pw.web.subtle.sign("HMAC",t,r);return new Uint8Array(o)}if(Pw.node){const{createHmac:t}=Pw.node,r=t("sha256",e);return n.forEach((e=>r.update(e))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async function(e){let t=Ow[e];if(void 0===t){const n=await Lw.sha256(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=tw(n,n),Ow[e]=t}for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return Lw.sha256(t,...r)},taggedHashSync:function(e){if("function"!==typeof yw)throw new Kb("sha256Sync is undefined, you need to set it");let t=Ow[e];if(void 0===t){const n=yw(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=tw(n,n),Ow[e]=t}for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return yw(t,...r)},_JacobianPoint:Gb};Object.defineProperties(Lw,{sha256Sync:{configurable:!1,get:()=>yw,set(e){yw||(yw=e)}},hmacSha256Sync:{configurable:!1,get:()=>bw,set(e){bw||(bw=e)}}});var Dw=__webpack_require__(2161);function Bw(e){return new Uint8Array(Dw.keccak256.arrayBuffer(e))}function Uw(e,t,n){try{return function(e,t,n){let r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Nw;try{r=_w(e),t=dw(t)}catch(p){return!1}const{r:i,s:s}=r;if(o.strict&&r.hasHighS())return!1;const a=mw(t);let l;try{l=Aw(n)}catch(p){return!1}const{n:c}=Fb,u=gw(s,c),d=fw(a*u,c),h=fw(i*u,c),f=Jb.BASE.multiplyAndAddUnsafe(l,d,h);return!!f&&fw(f.x,c)===i}(ew.fromCompact(e.slice(0,64)),t,n)}catch{return!1}}const Mw="Invalid record id";function Fw(e,t){switch(t){case"udp":return Fw(e,"udp4")||Fw(e,"udp6");case"tcp":return Fw(e,"tcp4")||Fw(e,"tcp6")}const n=t.endsWith("6"),r=e.get(n?"ip6":"ip");if(!r)return;const o=t.slice(0,3);let i;switch(o){case"udp":i=n?e.get("udp6"):e.get("udp");break;case"tcp":i=n?e.get("tcp6"):e.get("tcp");break;default:return}return i?function(e,t,n,r){let o=ji("/"+e+"/"+vi(e,n));return o=o.encapsulate(ji("/"+t+"/"+vi(t,r))),o}(n?"ip6":"ip4",o,r,i):void 0}function $w(e){const t=e.reduce(((e,t)=>e+2+t.bytes.length),0),n=new Uint8Array(t),r=new DataView(n.buffer);let o=0;return e.forEach((e=>{if(e.getPeerId())throw new Error("`multiaddr` field MUST not contain peer id");r.setUint16(o,e.bytes.length),o+=2,n.set(e.bytes,o),o+=e.bytes.length})),n}function Hw(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 qw 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),n=arguments.length>2?arguments[2]:void 0;super(Object.entries(e)),this.seq=t,this.signature=n}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 pr(e)}get publicKey(){if("v4"===this.id)return this.get("secp256k1");throw new Error(Mw)}get rs(){const e=this.get("rs");if(e)return Ar(e)}get rsv(){const e=this.get("rsv");if(e)return Ar(e)}get ip(){return jw(this,"ip","ip4")}set ip(e){zw(this,"ip","ip4",e)}get tcp(){return Vw(this,"tcp","tcp")}set tcp(e){Kw(this,"tcp","tcp",e)}get udp(){return Vw(this,"udp","udp")}set udp(e){Kw(this,"udp","udp",e)}get ip6(){return jw(this,"ip6","ip6")}set ip6(e){zw(this,"ip6","ip6",e)}get tcp6(){return Vw(this,"tcp6","tcp")}set tcp6(e){Kw(this,"tcp6","tcp",e)}get udp6(){return Vw(this,"udp6","udp")}set udp6(e){Kw(this,"udp6","udp",e)}get multiaddrs(){const e=this.get("multiaddrs");if(e)return function(e){const t=[];let n=0;for(;n<e.length;){const r=new DataView(e.buffer,n,2).getUint16(0);n+=2;const o=e.slice(n,n+r);n+=r,t.push(ji(o))}return t}(e)}set multiaddrs(e){Ww(this,"multiaddrs",e,$w)}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){Ww(this,"waku2",e,(e=>new Uint8Array([Hw(e)])))}}function jw(e,t,n){const r=e.get(t);if(r)return vi(n,r)}function Vw(e,t,n){const r=e.get(t);if(r)return Number(vi(n,r))}function zw(e,t,n,r){Ww(e,t,r,Ei.bind({},n))}function Kw(e,t,n,r){zw(e,t,n,r?.toString(10))}function Ww(e,t,n,r){void 0!==n?e.set(t,r(n)):e.delete(t)}async function Gw(e,t){return async function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{seed:r,m:o,d:i}=Rw(e,t,n.extraEntropy),s=new ww(32,jb);let a;for(await s.reseed(r);!(a=Sw(await s.generate(),o,i,n.canonical));)await s.reseed();return Tw(a,n)}(Bw(t),e,{der:!1})}const Yw=new Cr("enr");var Qw,Jw;!function(e){e.TCP="tcp",e.UDP="udp"}(Qw||(Qw={})),function(e){e.TCP4="tcp4",e.UDP4="udp4",e.TCP6="tcp6",e.UDP6="udp6"}(Jw||(Jw={}));class Xw extends qw{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 n=new Xw(e,t,arguments.length>2?arguments[2]:void 0);try{const e=n.publicKey;e&&(n.peerId=await function(e){return Od(new gd.secp256k1.Secp256k1PublicKey(e).bytes,void 0)}(e))}catch(r){Yw.error("Could not calculate peer id for ENR",r)}return n}get nodeId(){if("v4"===this.id)return this.publicKey?function(e){const t=Jb.fromHex(e).toRawBytes(!1);return fr(Bw(t.slice(1)))}(this.publicKey):void 0;throw new Error(Mw)}getLocationMultiaddr=(()=>Fw.bind({},this))();get shardInfo(){return this.rs&&this.rsv&&Yw.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 n=e.tuples();if(!n[0][1]||!n[1][1])throw new Error("Invalid multiaddr");4===n[0][0]?(this.set("ip",n[0][1]),this.set(t[1],n[1][1])):(this.set("ip6",n[0][1]),this.set(t[1]+"6",n[1][1]))}getAllLocationMultiaddrs(){const e=[];for(const n of Object.values(Jw)){const t=this.getLocationMultiaddr(n);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(Mw);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return Uw(t,Bw(e),this.publicKey)}async sign(e,t){if("v4"!==this.id)throw new Error(Mw);return this.signature=await Gw(t,e),this.signature}}let Zw=!1,ev=!1;const tv={debug:1,default:2,info:2,warning:3,error:4,off:5};let nv=tv.default,rv=null;const ov=function(){try{const e=[];if(["NFD","NFC","NFKD","NFKC"].forEach((t=>{try{if("test"!=="test".normalize(t))throw new Error("bad normalize")}catch(n){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 iv,sv;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(iv||(iv={})),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"}(sv||(sv={}));const av="0123456789abcdef";class lv{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const n=e.toLowerCase();null==tv[n]&&this.throwArgumentError("invalid log level name","logLevel",e),nv>tv[n]||console.log.apply(console,t)}debug(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log(lv.levels.DEBUG,t)}info(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log(lv.levels.INFO,t)}warn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log(lv.levels.WARNING,t)}makeError(e,t,n){if(ev)return this.makeError("censored error",t,{});t||(t=lv.errors.UNKNOWN_ERROR),n||(n={});const r=[];Object.keys(n).forEach((e=>{const t=n[e];try{if(t instanceof Uint8Array){let n="";for(let e=0;e<t.length;e++)n+=av[t[e]>>4],n+=av[15&t[e]];r.push(e+"=Uint8Array(0x"+n+")")}else r.push(e+"="+JSON.stringify(t))}catch(s){r.push(e+"="+JSON.stringify(n[e].toString()))}})),r.push(`code=${t}`),r.push(`version=${this.version}`);const o=e;let i="";switch(t){case sv.NUMERIC_FAULT:{i="NUMERIC_FAULT";const t=e;switch(t){case"overflow":case"underflow":case"division-by-zero":i+="-"+t;break;case"negative-power":case"negative-width":i+="-unsupported";break;case"unbound-bitwise-result":i+="-unbound-result"}break}case sv.CALL_EXCEPTION:case sv.INSUFFICIENT_FUNDS:case sv.MISSING_NEW:case sv.NONCE_EXPIRED:case sv.REPLACEMENT_UNDERPRICED:case sv.TRANSACTION_REPLACED:case sv.UNPREDICTABLE_GAS_LIMIT:i=t}i&&(e+=" [ See: https://links.ethers.org/v5-errors-"+i+" ]"),r.length&&(e+=" ("+r.join(", ")+")");const s=new Error(e);return s.reason=o,s.code=t,Object.keys(n).forEach((function(e){s[e]=n[e]})),s}throwError(e,t,n){throw this.makeError(e,t,n)}throwArgumentError(e,t,n){return this.throwError(e,lv.errors.INVALID_ARGUMENT,{argument:t,value:n})}assert(e,t,n,r){e||this.throwError(t,n,r)}assertArgument(e,t,n,r){e||this.throwArgumentError(t,n,r)}checkNormalize(e){null==e&&(e="platform missing String.prototype.normalize"),ov&&this.throwError("platform missing String.prototype.normalize",lv.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:ov})}checkSafeUint53(e,t){"number"===typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,lv.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,lv.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,n){n=n?": "+n:"",e<t&&this.throwError("missing argument"+n,lv.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+n,lv.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",lv.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",lv.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",lv.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return rv||(rv=new lv("logger/5.7.0")),rv}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",lv.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),Zw){if(!e)return;this.globalLogger().throwError("error censorship permanent",lv.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}ev=!!e,Zw=!!t}static setLogLevel(e){const t=tv[e.toLowerCase()];null!=t?nv=t:lv.globalLogger().warn("invalid log level - "+e)}static from(e){return new lv(e)}}lv.errors=sv,lv.levels=iv;const cv=new lv("bytes/5.7.0");function uv(e){return!!e.toHexString}function dv(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return dv(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function hv(e){return mv(e)&&!(e.length%2)||pv(e)}function fv(e){return"number"===typeof e&&e==e&&e%1===0}function pv(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"===typeof e)return!1;if(!fv(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const n=e[t];if(!fv(n)||n<0||n>=256)return!1}return!0}function gv(e,t){if(t||(t={}),"number"===typeof e){cv.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),dv(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),uv(e)&&(e=e.toHexString()),mv(e)){let n=e.substring(2);n.length%2&&("left"===t.hexPad?n="0"+n:"right"===t.hexPad?n+="0":cv.throwArgumentError("hex data is odd-length","value",e));const r=[];for(let e=0;e<n.length;e+=2)r.push(parseInt(n.substring(e,e+2),16));return dv(new Uint8Array(r))}return pv(e)?dv(new Uint8Array(e)):cv.throwArgumentError("invalid arrayify value","value",e)}function mv(e,t){return!("string"!==typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}const yv="0123456789abcdef";function bv(e,t){if(t||(t={}),"number"===typeof e){cv.checkSafeUint53(e,"invalid hexlify value");let t="";for(;e;)t=yv[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),uv(e))return e.toHexString();if(mv(e))return e.length%2&&("left"===t.hexPad?e="0x0"+e.substring(2):"right"===t.hexPad?e+="0":cv.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(pv(e)){let t="0x";for(let n=0;n<e.length;n++){let r=e[n];t+=yv[(240&r)>>4]+yv[15&r]}return t}return cv.throwArgumentError("invalid hexlify value","value",e)}const wv=new lv("rlp/5.7.0");function vv(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function Ev(e,t,n){let r=0;for(let o=0;o<n;o++)r=256*r+e[t+o];return r}function Sv(e){if(Array.isArray(e)){let t=[];if(e.forEach((function(e){t=t.concat(Sv(e))})),t.length<=55)return t.unshift(192+t.length),t;const n=vv(t.length);return n.unshift(247+n.length),n.concat(t)}hv(e)||wv.throwArgumentError("RLP object must be BytesLike","object",e);const t=Array.prototype.slice.call(gv(e));if(1===t.length&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const n=vv(t.length);return n.unshift(183+n.length),n.concat(t)}function kv(e){return bv(Sv(e))}function Av(e,t,n,r){const o=[];for(;n<t+1+r;){const i=_v(e,n);o.push(i.result),(n+=i.consumed)>t+1+r&&wv.throwError("child data too short",lv.errors.BUFFER_OVERRUN,{})}return{consumed:1+r,result:o}}function _v(e,t){if(0===e.length&&wv.throwError("data too short",lv.errors.BUFFER_OVERRUN,{}),e[t]>=248){const n=e[t]-247;t+1+n>e.length&&wv.throwError("data short segment too short",lv.errors.BUFFER_OVERRUN,{});const r=Ev(e,t+1,n);return t+1+n+r>e.length&&wv.throwError("data long segment too short",lv.errors.BUFFER_OVERRUN,{}),Av(e,t,t+1+n,n+r)}if(e[t]>=192){const n=e[t]-192;return t+1+n>e.length&&wv.throwError("data array too short",lv.errors.BUFFER_OVERRUN,{}),Av(e,t,t+1,n)}if(e[t]>=184){const n=e[t]-183;t+1+n>e.length&&wv.throwError("data array too short",lv.errors.BUFFER_OVERRUN,{});const r=Ev(e,t+1,n);t+1+n+r>e.length&&wv.throwError("data array too short",lv.errors.BUFFER_OVERRUN,{});return{consumed:1+n+r,result:bv(e.slice(t+1+n,t+1+n+r))}}if(e[t]>=128){const n=e[t]-128;t+1+n>e.length&&wv.throwError("data too short",lv.errors.BUFFER_OVERRUN,{});return{consumed:1+n,result:bv(e.slice(t+1,t+1+n))}}return{consumed:1,result:bv(e[t])}}const Iv=new Cr("enr:decoder");class xv{static fromString(e){if(!e.startsWith(Xw.RECORD_PREFIX))throw new Error(`"string encoded ENR must start with '${Xw.RECORD_PREFIX}'`);return xv.fromRLP(Dt(e.slice(4),"base64url"))}static fromRLP(e){const t=function(e){const t=gv(e),n=_v(t,0);return n.consumed!==t.length&&wv.throwArgumentError("invalid rlp data","data",e),n.result}(e).map(hr);return async function(e){const{signature:t,seq:n,kvs:r}=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,n,...r]=e;if(!t||Array.isArray(t))throw new Error("Decoded ENR invalid signature: must be a byte array");if(!n||Array.isArray(n))throw new Error("Decoded ENR invalid sequence number: must be a byte array");return{signature:t,seq:n,kvs:r}}(e),o={};for(let l=0;l<r.length;l+=2)try{o[pr(r[l])]=r[l+1]}catch(a){Iv.error("Failed to decode ENR key to UTF-8, skipping it",r[l],a)}const i=function(e){return e.length?BigInt("0x"+fr(e)):BigInt(0)}(n),s=await Xw.create(o,i,t);return function(e,t,n,r){const o=hr(kv([e,...t]));if(!n.verify(o,r))throw new Error("Unable to verify ENR signature")}(n,r,s,t),s}(t)}}const Cv=/^(\d{1,3}\.){3,3}\d{1,3}$/,Rv=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,Tv={name:"v4",size:4,isFormat:e=>Cv.test(e),encode(e,t,n){n=~~n,t=t||new Uint8Array(n+4);const r=e.length;let o=0;for(let i=0;i<r;){const r=e.charCodeAt(i++);46===r?(t[n++]=o,o=0):o=10*o+(r-48)}return t[n]=o,t},decode:(e,t)=>(t=~~t,`${e[t++]}.${e[t++]}.${e[t++]}.${e[t]}`)},Nv={name:"v6",size:16,isFormat:e=>e.length>0&&Rv.test(e),encode(e,t,n){let r=(n=~~n)+16,o=-1,i=0,s=0,a=!0,l=!1;t=t||new Uint8Array(n+16);for(let c=0;c<e.length;c++){let u=e.charCodeAt(c);58===u?(a?-1!==o?(n<r&&(t[n]=0),n<r-1&&(t[n+1]=0),n+=2):n<r&&(o=n):(!0===l?(n<r&&(t[n]=s),n++):(n<r&&(t[n]=i>>8),n<r-1&&(t[n+1]=255&i),n+=2),i=0,s=0),a=!0,l=!1):46===u?(n<r&&(t[n]=s),n++,s=0,i=0,a=!1,l=!0):(a=!1,u>=97?u-=87:u>=65?u-=55:(u-=48,s=10*s+u),i=(i<<4)+u)}if(!1===a)!0===l?(n<r&&(t[n]=s),n++):(n<r&&(t[n]=i>>8),n<r-1&&(t[n+1]=255&i),n+=2);else if(0===o)n<r&&(t[n]=0),n<r-1&&(t[n+1]=0),n+=2;else if(-1!==o){n+=2;for(let e=Math.min(n-1,r-1);e>=o+2;e--)t[e]=t[e-2];t[o]=0,t[o+1]=0,o=n}if(o!==n&&-1!==o)for(n>r-2&&(n=r-2);r>o;)t[--r]=n<r&&n>o?t[--n]:0;else for(;n<r;)t[n++]=0;return t},decode(e,t){t=~~t;let n="";for(let r=0;r<16;r+=2)0!==r&&(n+=":"),n+=(e[t+r]<<8|e[t+r+1]).toString(16);return n.replace(/(^|:)0(:0)*:0(:|$)/,"$1::$3").replace(/:{3,4}/,"::")}};function Pv(e){if(Tv.isFormat(e))return Tv.size;if(Nv.isFormat(e))return Nv.size;throw Error(`Invalid ip address: ${e}`)}function Ov(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 Lv(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 Dv(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 Bv(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 Uv(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 Mv(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 Fv(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 $v=55296,Hv=56320;function qv(e){let t=0;const n=e.length;for(let r=0;r<n;r+=1){const o=e.charCodeAt(r);if(o<=127)t+=1;else if(o<=2047)t+=2;else if((63488&o)!==$v)t+=3;else{const i=r+1;if(i===n||o>=Hv)t+=3;else{(64512&e.charCodeAt(i))!==Hv?t+=3:(r=i,t+=4)}}}return t}function jv(e,t,n){const r=e.length;void 0!==n&&null!==n||(n=0),void 0===t&&(t=new Uint8Array(qv(e)+n));let o=n;for(let i=0;i<r;i+=1){let n=e.charCodeAt(i);if(n<=127)t[o++]=n;else if(n<=2047)t[o++]=192|(1984&n)>>6,t[o++]=128|63&n;else if((63488&n)!==$v)t[o++]=224|(61440&n)>>12,t[o++]=128|(4032&n)>>6,t[o++]=128|63&n;else{const s=i+1;if(s===r||n>=Hv)t[o++]=239,t[o++]=191,t[o++]=189;else{const r=e.charCodeAt(s);(64512&r)!==Hv?(t[o++]=239,t[o++]=191,t[o++]=189):(i=s,n=65536|(1023&n)<<10|1023&r,t[o++]=240|(1835008&n)>>18,t[o++]=128|(258048&n)>>12,t[o++]=128|(4032&n)>>6,t[o++]=128|63&n)}}}return jv.bytes=o-n,t}function Vv(e,t,n){let r="";void 0!==t&&null!==t||(t=0),void 0!==n&&null!==n||(n=e.length);for(let o=t;o<n;){const t=e[o++];let n;if(t<=128)n=t;else if(t>191&&t<224)n=(31&t)<<6|63&e[o++];else if(t>239&&t<365){n=((7&t)<<18|(63&e[o++])<<12|(63&e[o++])<<6|63&e[o++])-65536;const i=$v|n>>10&1023;r+=String.fromCharCode(i),n=Hv|1023&n}else n=(15&t)<<12|(63&e[o++])<<6|63&e[o++];r+=String.fromCharCode(n)}return Vv.bytes=n-t,r}jv.bytes=0,Vv.bytes=0;const zv=e=>e instanceof Uint8Array;function Kv(e){return"string"===typeof e?qv(e):e.byteLength}function Wv(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):jv(e)}function Gv(e,t,n){if("string"!==typeof t)throw new Error("unknown input type");return jv(t,e,n),jv.bytes}const Yv=Math.pow(2,24),Qv=Math.pow(2,16),Jv=Math.pow(2,8),Xv=(e,t)=>e[t]*Yv+e[t+1]*Qv+e[t+2]*Jv+e[t+3],Zv=(e,t)=>e[t]<<8|e[t+1],eE=(e,t,n)=>(t=+t,e[n+3]=t,t>>>=8,e[n+2]=t,t>>>=8,e[n+1]=t,t>>>=8,e[n]=t,n+4),tE=(e,t,n)=>(e[n]=t>>8,e[n+1]=255&t,n+2);function nE(e,t,n,r,o){return n<0&&(r-=n,n=0),r<0&&(r=0),o<0?new Uint8Array(0):n>=t.length||r>=o?0:function(e,t,n,r,o){o-r>t.length-n&&(o=r+t.length-n);let i=o-r;const s=e.length-r;i>s&&(i=s);(0!==r||o<e.length)&&(e=new Uint8Array(e.buffer,e.byteOffset+r,i));return t.set(e,n),i}(e,t,n,r,o)}const rE=32768;function oE(e){let{bytes:t=0,encode:n,decode:r,encodingLength:o}=e;return n.bytes=t,r.bytes=t,{encode:n,decode:r,encodingLength:o||(()=>t)}}const iE=oE({encode(e,t,n){t||(t=new Uint8Array(iE.encodingLength(e))),n||(n=0);const r=n,o=e.replace(/^\.|\.$/gm,"");if(o.length){const e=o.split(".");for(let r=0;r<e.length;r++){const o=Gv(t,e[r],n+1);t[n]=o,n+=o+1}}return t[n++]=0,iE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=[];let r=t,o=0,i=0,s=!1;for(;;){if(t>=e.length)throw new Error("Cannot decode name (buffer overflow)");const a=e[t++];if(i+=s?0:1,0===a)break;if(0===(192&a)){if(t+a>e.length)throw new Error("Cannot decode name (buffer overflow)");if(o+=a+1,o>254)throw new Error("Cannot decode name (name too long)");n.push(Vv(e,t,t+a)),t+=a,i+=s?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 n=Zv(e,t-1)-49152;if(n>=r)throw new Error("Cannot decode name (bad pointer)");t=n,r=n,i+=s?0:1,s=!0}}}return iE.decode.bytes=i,0===n.length?".":n.join(".")},encodingLength:e=>"."===e||".."===e?1:Kv(e.replace(/^\.|\.$/gm,""))+2}),sE=oE({encode(e,t,n){t||(t=new Uint8Array(sE.encodingLength(e))),n||(n=0);const r=Gv(t,e,n+1);return t[n]=r,sE.encode.bytes=r+1,t},decode(e,t){t||(t=0);const n=e[t],r=Vv(e,t+1,t+1+n);return sE.decode.bytes=n+1,r},encodingLength:e=>Kv(e)+1}),aE=oE({bytes:12,encode(e,t,n){t||(t=new Uint8Array(aE.encodingLength(e))),n||(n=0);const r=32767&(e.flags||0),o="response"===e.type?32768:0;return tE(t,e.id||0,n),tE(t,r|o,n+2),tE(t,e.questions.length,n+4),tE(t,e.answers.length,n+6),tE(t,e.authorities.length,n+8),tE(t,e.additionals.length,n+10),t},decode(e,t){if(t||(t=0),e.length<12)throw new Error("Header must be 12 bytes");const n=Zv(e,t+2);return{id:Zv(e,t),type:32768&n?"response":"query",flags:32767&n,flag_qr:1===(n>>15&1),opcode:Bv(n>>11&15),flag_aa:1===(n>>10&1),flag_tc:1===(n>>9&1),flag_rd:1===(n>>8&1),flag_ra:1===(n>>7&1),flag_z:1===(n>>6&1),flag_ad:1===(n>>5&1),flag_cd:1===(n>>4&1),rcode:Dv(15&n),questions:new Array(Zv(e,t+4)),answers:new Array(Zv(e,t+6)),authorities:new Array(Zv(e,t+8)),additionals:new Array(Zv(e,t+10))}},encodingLength:()=>12}),lE=oE({encode(e,t,n){t||(t=new Uint8Array(lE.encodingLength(e))),n||(n=0);const r=e.length;return tE(t,r,n),nE(e,t,n+2,0,r),lE.encode.bytes=r+2,t},decode(e,t){t||(t=0);const n=Zv(e,t),r=e.slice(t+2,t+2+n);return lE.decode.bytes=n+2,r},encodingLength:e=>e.length+2}),cE=oE({encode:(e,t,n)=>(t||(t=new Uint8Array(cE.encodingLength(e))),n||(n=0),iE.encode(e,t,n+2),tE(t,iE.encode.bytes,n),cE.encode.bytes=iE.encode.bytes+2,t),decode(e,t){t||(t=0);const n=Zv(e,t),r=iE.decode(e,t+2);return cE.decode.bytes=n+2,r},encodingLength:e=>iE.encodingLength(e)+2}),uE=oE({encode(e,t,n){t||(t=new Uint8Array(uE.encodingLength(e))),n||(n=0);const r=n;return n+=2,iE.encode(e.mname,t,n),n+=iE.encode.bytes,iE.encode(e.rname,t,n),n+=iE.encode.bytes,eE(t,e.serial||0,n),n+=4,eE(t,e.refresh||0,n),n+=4,eE(t,e.retry||0,n),n+=4,eE(t,e.expire||0,n),n+=4,eE(t,e.minimum||0,n),tE(t,(n+=4)-r-2,r),uE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.mname=iE.decode(e,t),t+=iE.decode.bytes,r.rname=iE.decode(e,t),t+=iE.decode.bytes,r.serial=Xv(e,t),t+=4,r.refresh=Xv(e,t),t+=4,r.retry=Xv(e,t),t+=4,r.expire=Xv(e,t),t+=4,r.minimum=Xv(e,t),t+=4,uE.decode.bytes=t-n,r},encodingLength:e=>22+iE.encodingLength(e.mname)+iE.encodingLength(e.rname)}),dE=oE({encode(e,t,n){Array.isArray(e)||(e=[e]);for(let o=0;o<e.length;o++)if("string"===typeof e[o]&&(e[o]=Wv(e[o])),!zv(e[o]))throw new Error("Must be a Buffer");t||(t=new Uint8Array(dE.encodingLength(e))),n||(n=0);const r=n;return n+=2,e.forEach((function(e){t[n++]=e.length,nE(e,t,n,0,e.length),n+=e.length})),tE(t,n-r-2,r),dE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t;let r=Zv(e,t);t+=2;const o=[];for(;r>0;){const n=e[t++];if(--r,r<n)throw new Error("Buffer overflow");o.push(e.slice(t,t+n)),t+=n,r-=n}return dE.decode.bytes=t-n,o},encodingLength(e){Array.isArray(e)||(e=[e]);let t=2;return e.forEach((function(e){t+="string"===typeof e?Kv(e)+1:e.length+1})),t}}),hE=oE({encode(e,t,n){t||(t=new Uint8Array(hE.encodingLength(e))),n||(n=0),"string"===typeof e&&(e=Wv(e)),e||(e=new Uint8Array(0));const r=n;n+=2;const o=e.length;return nE(e,t,n,0,o),tE(t,(n+=o)-r-2,r),hE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r=Zv(e,t);t+=2;const o=e.slice(t,t+r);return t+=r,hE.decode.bytes=t-n,o},encodingLength:e=>e?(zv(e)?e.length:Kv(e))+2:2}),fE=oE({encode(e,t,n){t||(t=new Uint8Array(fE.encodingLength(e))),n||(n=0);const r=n;return n+=2,sE.encode(e.cpu,t,n),n+=sE.encode.bytes,sE.encode(e.os,t,n),n+=sE.encode.bytes,tE(t,n-r-2,r),fE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.cpu=sE.decode(e,t),t+=sE.decode.bytes,r.os=sE.decode(e,t),t+=sE.decode.bytes,fE.decode.bytes=t-n,r},encodingLength:e=>sE.encodingLength(e.cpu)+sE.encodingLength(e.os)+2}),pE=oE({encode:(e,t,n)=>(t||(t=new Uint8Array(pE.encodingLength(e))),n||(n=0),iE.encode(e,t,n+2),tE(t,iE.encode.bytes,n),pE.encode.bytes=iE.encode.bytes+2,t),decode(e,t){t||(t=0);const n=iE.decode(e,t+2);return pE.decode.bytes=iE.decode.bytes+2,n},encodingLength:e=>iE.encodingLength(e)+2}),gE=oE({encode(e,t,n){t||(t=new Uint8Array(gE.encodingLength(e))),n||(n=0),tE(t,e.priority||0,n+2),tE(t,e.weight||0,n+4),tE(t,e.port||0,n+6),iE.encode(e.target,t,n+8);const r=iE.encode.bytes+6;return tE(t,r,n),gE.encode.bytes=r+2,t},decode(e,t){t||(t=0);const n=Zv(e,t),r={};return r.priority=Zv(e,t+2),r.weight=Zv(e,t+4),r.port=Zv(e,t+6),r.target=iE.decode(e,t+8),gE.decode.bytes=n+2,r},encodingLength:e=>8+iE.encodingLength(e.target)}),mE=oE({encode(e,t,n){const r=mE.encodingLength(e);return t||(t=new Uint8Array(mE.encodingLength(e))),n||(n=0),e.issuerCritical&&(e.flags=mE.ISSUER_CRITICAL),tE(t,r-2,n),t[n+=2]=e.flags||0,n+=1,sE.encode(e.tag,t,n),n+=sE.encode.bytes,Gv(t,e.value,n),n+=Kv(e.value),mE.encode.bytes=r,t},decode(e,t){t||(t=0);const n=Zv(e,t),r=t+=2,o={};return o.flags=e[t],t+=1,o.tag=sE.decode(e,t),t+=sE.decode.bytes,o.value=Vv(e,t,r+n),o.issuerCritical=!!(o.flags&mE.ISSUER_CRITICAL),mE.decode.bytes=n+2,o},encodingLength:e=>sE.encodingLength(e.tag)+sE.encodingLength(e.value)+2});mE.ISSUER_CRITICAL=128;const yE=oE({encode(e,t,n){t||(t=new Uint8Array(yE.encodingLength(e))),n||(n=0);const r=n;return n+=2,tE(t,e.preference||0,n),n+=2,iE.encode(e.exchange,t,n),n+=iE.encode.bytes,tE(t,n-r-2,r),yE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.preference=Zv(e,t),t+=2,r.exchange=iE.decode(e,t),t+=iE.decode.bytes,yE.decode.bytes=t-n,r},encodingLength:e=>4+iE.encodingLength(e.exchange)}),bE=oE({encode:(e,t,n)=>(t||(t=new Uint8Array(bE.encodingLength(e))),n||(n=0),tE(t,4,n),n+=2,Tv.encode(e,t,n),t),decode(e,t){t||(t=0),t+=2;return Tv.decode(e,t)},bytes:6}),wE=oE({encode:(e,t,n)=>(t||(t=new Uint8Array(wE.encodingLength(e))),n||(n=0),tE(t,16,n),n+=2,Nv.encode(e,t,n),wE.encode.bytes=18,t),decode(e,t){t||(t=0),t+=2;const n=Nv.decode(e,t);return wE.decode.bytes=18,n},bytes:18}),vE=e=>new Uint8Array(e),EE=oE({encode(e,t,n){t||(t=new Uint8Array(EE.encodingLength(e))),n||(n=0);const r=n,o=Fv(e.code);if(tE(t,o,n),n+=2,e.data)tE(t,e.data.length,n),n+=2,nE(e.data,t,n),n+=e.data.length;else switch(o){case 8:{const r=e.sourcePrefixLength||0,o=e.family||function(e){return Pv(e)===Tv.size?1:2}(e.ip),i=function(e,t,n){n=~~n;const r=Pv(e);return"function"===typeof t&&(t=t(n+r)),r===Tv.size?Tv.encode(e,t,n):Nv.encode(e,t,n)}(e.ip,vE),s=Math.ceil(r/8);tE(t,s+4,n),tE(t,o,n+=2),n+=2,t[n++]=r,t[n++]=e.scopePrefixLength||0,nE(i,t,n,0,s),n+=s}break;case 11:e.timeout?(tE(t,2,n),n+=2,tE(t,e.timeout,n),n+=2):(tE(t,0,n),n+=2);break;case 12:{const r=e.length||0;tE(t,r,n),n+=2,t.fill(0,n,n+r),n+=r}break;case 14:{const r=2*e.tags.length;tE(t,r,n),n+=2;for(const o of e.tags)tE(t,o,n),n+=2}break;default:throw new Error(`Unknown roption code: ${e.code}`)}return EE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n={};n.code=Zv(e,t),n.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}`}(n.code);const r=Zv(e,t+=2);switch(t+=2,n.data=e.slice(t,t+r),n.code){case 8:n.family=Zv(e,t),t+=2,n.sourcePrefixLength=e[t++],n.scopePrefixLength=e[t++];{const o=new Uint8Array(1===n.family?4:16);nE(e,o,0,t,t+r-4),n.ip=function(e,t,n){if(t=~~t,(n=n||e.length-t)===Tv.size)return Tv.decode(e,t,n);if(n===Nv.size)return Nv.decode(e,t,n);throw Error(`Invalid buffer size needs to be ${Tv.size} for v4 or ${Nv.size} for v6.`)}(o)}break;case 11:r>0&&(n.timeout=Zv(e,t),t+=2);break;case 14:n.tags=[];for(let o=0;o<r;o+=2)n.tags.push(Zv(e,t)),t+=2}return EE.decode.bytes=r+4,n},encodingLength(e){if(e.data)return e.data.length+4;switch(Fv(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}`)}}),SE=oE({encode(e,t,n){t||(t=new Uint8Array(SE.encodingLength(e))),n||(n=0);const r=n,o=$E(e,EE);return tE(t,o,n),n=HE(e,EE,t,n+2),SE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r=[];let o=Zv(e,t);t+=2;let i=0;for(;o>0;)r[i++]=EE.decode(e,t),t+=EE.decode.bytes,o-=EE.decode.bytes;return SE.decode.bytes=t-n,r},encodingLength:e=>2+$E(e||[],EE)}),kE=oE({encode(e,t,n){t||(t=new Uint8Array(kE.encodingLength(e))),n||(n=0);const r=n,o=e.key;if(!zv(o))throw new Error("Key must be a Buffer");return n+=2,tE(t,e.flags,n),t[n+=2]=kE.PROTOCOL_DNSSEC,t[n+=1]=e.algorithm,nE(o,t,n+=1,0,o.length),n+=o.length,kE.encode.bytes=n-r,tE(t,kE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=Zv(e,t);if(t+=2,r.flags=Zv(e,t),e[t+=2]!==kE.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return t+=1,r.algorithm=e[t],t+=1,r.key=e.slice(t,n+o+2),t+=r.key.length,kE.decode.bytes=t-n,r},encodingLength:e=>6+Kv(e.key)});kE.PROTOCOL_DNSSEC=3,kE.ZONE_KEY=128,kE.SECURE_ENTRYPOINT=32768;const AE=oE({encode(e,t,n){t||(t=new Uint8Array(AE.encodingLength(e))),n||(n=0);const r=n,o=e.signature;if(!zv(o))throw new Error("Signature must be a Buffer");return n+=2,tE(t,Lv(e.typeCovered),n),t[n+=2]=e.algorithm,t[n+=1]=e.labels,n+=1,eE(t,e.originalTTL,n),n+=4,eE(t,e.expiration,n),n+=4,eE(t,e.inception,n),n+=4,tE(t,e.keyTag,n),n+=2,iE.encode(e.signersName,t,n),nE(o,t,n+=iE.encode.bytes,0,o.length),n+=o.length,AE.encode.bytes=n-r,tE(t,AE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=Zv(e,t);return t+=2,r.typeCovered=Ov(Zv(e,t)),t+=2,r.algorithm=e[t],t+=1,r.labels=e[t],t+=1,r.originalTTL=Xv(e,t),t+=4,r.expiration=Xv(e,t),t+=4,r.inception=Xv(e,t),t+=4,r.keyTag=Zv(e,t),t+=2,r.signersName=iE.decode(e,t),t+=iE.decode.bytes,r.signature=e.slice(t,n+o+2),t+=r.signature.length,AE.decode.bytes=t-n,r},encodingLength:e=>20+iE.encodingLength(e.signersName)+Kv(e.signature)}),_E=oE({encode(e,t,n){t||(t=new Uint8Array(_E.encodingLength(e))),n||(n=0);const r=n;return n+=2,iE.encode(e.mbox||".",t,n),n+=iE.encode.bytes,iE.encode(e.txt||".",t,n),n+=iE.encode.bytes,_E.encode.bytes=n-r,tE(t,_E.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.mbox=iE.decode(e,t)||".",t+=iE.decode.bytes,r.txt=iE.decode(e,t)||".",t+=iE.decode.bytes,_E.decode.bytes=t-n,r},encodingLength:e=>2+iE.encodingLength(e.mbox||".")+iE.encodingLength(e.txt||".")}),IE=oE({encode(e,t,n){t||(t=new Uint8Array(IE.encodingLength(e))),n||(n=0);const r=n,o=[];for(let i=0;i<e.length;i++){const t=Lv(e[i]);void 0===o[t>>8]&&(o[t>>8]=[]),o[t>>8][t>>3&31]|=1<<7-(7&t)}for(let i=0;i<o.length;i++)if(void 0!==o[i]){const e=Wv(o[i]);t[n]=i,t[n+=1]=e.length,nE(e,t,n+=1,0,e.length),n+=e.length}return IE.encode.bytes=n-r,t},decode(e,t,n){t||(t=0);const r=t,o=[];for(;t-r<n;){const n=e[t],r=e[t+=1];t+=1;for(let i=0;i<r;i++){const r=e[t+i];for(let e=0;e<8;e++)if(r&1<<7-e){const t=Ov(n<<8|i<<3|e);o.push(t)}}t+=r}return IE.decode.bytes=t-r,o},encodingLength(e){const t=[];for(let r=0;r<e.length;r++){const n=Lv(e[r]);t[n>>8]=Math.max(t[n>>8]||0,255&n)}let n=0;for(let r=0;r<t.length;r++)void 0!==t[r]&&(n+=2+Math.ceil((t[r]+1)/8));return n}}),xE=oE({encode(e,t,n){t||(t=new Uint8Array(xE.encodingLength(e))),n||(n=0);const r=n;return n+=2,iE.encode(e.nextDomain,t,n),n+=iE.encode.bytes,IE.encode(e.rrtypes,t,n),n+=IE.encode.bytes,xE.encode.bytes=n-r,tE(t,xE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=Zv(e,t);return t+=2,r.nextDomain=iE.decode(e,t),t+=iE.decode.bytes,r.rrtypes=IE.decode(e,t,o-(t-n)),t+=IE.decode.bytes,xE.decode.bytes=t-n,r},encodingLength:e=>2+iE.encodingLength(e.nextDomain)+IE.encodingLength(e.rrtypes)}),CE=oE({encode(e,t,n){t||(t=new Uint8Array(CE.encodingLength(e))),n||(n=0);const r=n,o=e.salt;if(!zv(o))throw new Error("salt must be a Buffer");const i=e.nextDomain;if(!zv(i))throw new Error("nextDomain must be a Buffer");return t[n+=2]=e.algorithm,t[n+=1]=e.flags,n+=1,tE(t,e.iterations,n),t[n+=2]=o.length,nE(o,t,n+=1,0,o.length),t[n+=o.length]=i.length,nE(i,t,n+=1,0,i.length),n+=i.length,IE.encode(e.rrtypes,t,n),n+=IE.encode.bytes,CE.encode.bytes=n-r,tE(t,CE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=Zv(e,t);t+=2,r.algorithm=e[t],t+=1,r.flags=e[t],t+=1,r.iterations=Zv(e,t);const i=e[t+=2];t+=1,r.salt=e.slice(t,t+i);const s=e[t+=i];return t+=1,r.nextDomain=e.slice(t,t+s),t+=s,r.rrtypes=IE.decode(e,t,o-(t-n)),t+=IE.decode.bytes,CE.decode.bytes=t-n,r},encodingLength:e=>8+e.salt.length+e.nextDomain.length+IE.encodingLength(e.rrtypes)}),RE=oE({encode(e,t,n){t||(t=new Uint8Array(RE.encodingLength(e))),n||(n=0);const r=n,o=e.digest;if(!zv(o))throw new Error("Digest must be a Buffer");return n+=2,tE(t,e.keyTag,n),t[n+=2]=e.algorithm,t[n+=1]=e.digestType,nE(o,t,n+=1,0,o.length),n+=o.length,RE.encode.bytes=n-r,tE(t,RE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=Zv(e,t);return t+=2,r.keyTag=Zv(e,t),t+=2,r.algorithm=e[t],t+=1,r.digestType=e[t],t+=1,r.digest=e.slice(t,n+o+2),t+=r.digest.length,RE.decode.bytes=t-n,r},encodingLength:e=>6+Kv(e.digest)});function TE(e){switch(e.toUpperCase()){case"A":return bE;case"PTR":case"CNAME":case"DNAME":return pE;case"TXT":return dE;case"NULL":return hE;case"AAAA":return wE;case"SRV":return gE;case"HINFO":return fE;case"CAA":return mE;case"NS":return cE;case"SOA":return uE;case"MX":return yE;case"OPT":return SE;case"DNSKEY":return kE;case"RRSIG":return AE;case"RP":return _E;case"NSEC":return xE;case"NSEC3":return CE;case"DS":return RE}return lE}const NE=oE({encode(e,t,n){t||(t=new Uint8Array(NE.encodingLength(e))),n||(n=0);const r=n;if(iE.encode(e.name,t,n),n+=iE.encode.bytes,tE(t,Lv(e.type),n),"OPT"===e.type.toUpperCase()){if("."!==e.name)throw new Error("OPT name must be root.");tE(t,e.udpPayloadSize||4096,n+2),t[n+4]=e.extendedRcode||0,t[n+5]=e.ednsVersion||0,tE(t,e.flags||0,n+6),n+=8,SE.encode(e.options||[],t,n),n+=SE.encode.bytes}else{let r=Mv(void 0===e.class?"IN":e.class);e.flush&&(r|=rE),tE(t,r,n+2),eE(t,e.ttl||0,n+4),n+=8;const o=TE(e.type);o.encode(e.data,t,n),n+=o.encode.bytes}return NE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n={},r=t;if(n.name=iE.decode(e,t),t+=iE.decode.bytes,n.type=Ov(Zv(e,t)),"OPT"===n.type)n.udpPayloadSize=Zv(e,t+2),n.extendedRcode=e[t+4],n.ednsVersion=e[t+5],n.flags=Zv(e,t+6),n.flag_do=1===(n.flags>>15&1),n.options=SE.decode(e,t+8),t+=8+SE.decode.bytes;else{const r=Zv(e,t+2);n.ttl=Xv(e,t+4),n.class=Uv(-32769&r),n.flush=!!(r&rE);const o=TE(n.type);n.data=o.decode(e,t+8),t+=8+o.decode.bytes}return NE.decode.bytes=t-r,n},encodingLength(e){const t=null!==e.data&&void 0!==e.data?e.data:e.options;return iE.encodingLength(e.name)+8+TE(e.type).encodingLength(t)}}),PE=oE({encode(e,t,n){t||(t=new Uint8Array(PE.encodingLength(e))),n||(n=0);const r=n;return iE.encode(e.name,t,n),n+=iE.encode.bytes,tE(t,Lv(e.type),n),n+=2,tE(t,Mv(void 0===e.class?"IN":e.class),n),n+=2,PE.encode.bytes=n-r,e},decode(e,t){t||(t=0);const n=t,r={};r.name=iE.decode(e,t),t+=iE.decode.bytes,r.type=Ov(Zv(e,t)),t+=2,r.class=Uv(Zv(e,t)),t+=2;return!!(32768&r.class)&&(r.class&=-32769),PE.decode.bytes=t-n,r},encodingLength:e=>iE.encodingLength(e.name)+4}),OE={encode:function(e,t,n){const r=!t;r&&(t=new Uint8Array(FE(e))),n||(n=0);const o=n;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),aE.encode(e,t,n),n+=aE.encode.bytes,n=HE(e.questions,PE,t,n),n=HE(e.answers,NE,t,n),n=HE(e.authorities,NE,t,n),n=HE(e.additionals,NE,t,n),OE.encode.bytes=n-o,r&&UE.bytes!==t.length?t.slice(0,UE.bytes):t},decode:function(e,t){t||(t=0);const n=t,r=aE.decode(e,t);return t+=aE.decode.bytes,t=qE(r.questions,PE,e,t),t=qE(r.answers,NE,e,t),t=qE(r.authorities,NE,e,t),t=qE(r.additionals,NE,e,t),OE.decode.bytes=t-n,r},encodingLength:function(e){return aE.encodingLength(e)+$E(e.questions||[],PE)+$E(e.answers||[],NE)+$E(e.authorities||[],NE)+$E(e.additionals||[],NE)}};function LE(e,t){if(e.questions)throw new Error("Only one .question object expected instead of a .questions array!");const n=Object.assign({type:t},e);return n.question&&(n.questions=[n.question],delete n.question),n}OE.encode.bytes=0,OE.decode.bytes=0;const DE={encode:function(e,t,n){return t=OE.encode(LE(e,"query"),t,n),DE.encode.bytes=OE.encode.bytes,t},decode:function(e,t){const n=OE.decode(e,t);return DE.decode.bytes=OE.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return OE.encodingLength(LE(e,"query"))}};DE.encode.bytes=0,DE.decode.bytes=0;const BE={encode:function(e,t,n){return t=OE.encode(LE(e,"response"),t,n),BE.encode.bytes=OE.encode.bytes,t},decode:function(e,t){const n=OE.decode(e,t);return BE.decode.bytes=OE.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return OE.encodingLength(LE(e,"response"))}};BE.encode.bytes=0,BE.decode.bytes=0;const UE=OE.encode,ME=OE.decode,FE=OE.encodingLength;function $E(e,t){let n=0;for(let r=0;r<e.length;r++)n+=t.encodingLength(e[r]);return n}function HE(e,t,n,r){for(let o=0;o<e.length;o++)t.encode(e[o],n,r),r+=t.encode.bytes;return r}function qE(e,t,n,r){for(let o=0;o<e.length;o++)e[o]=t.decode(n,r),r+=t.decode.bytes;return r}function jE(e,t,n,r){if(64!==t.length)throw new Error(`Charset needs to be 64 characters long! (${t.length})`);const o=new Uint8Array(256),i=new Uint8Array(64);for(let l=0;l<64;l+=1){const e=t.charCodeAt(l);if(e>255)throw new Error(`Character #${l} in charset [code=${e}, char=${t.charAt(l)}] is too high! (max=255)`);if(0!==o[e])throw new Error(`Character [code=${e}, char=${t.charAt(l)}] is more than once in the charset!`);o[e]=l,i[l]=e}const s=n.charCodeAt(0),a={name:e,encodingLength(e){const t=e.length,n=.75*t|0;return e.charCodeAt(t-1)===s?e.charCodeAt(t-2)===s?n-2:n-1:n},encode(e,t,n){null!==t&&void 0!==t||(t=new Uint8Array(a.encodingLength(e))),null!==n&&void 0!==n||(n=0);let r=e.length;e.charCodeAt(r-1)===s&&(e.charCodeAt(r-2)===s?r-=2:r-=1);const i=r%4,l=r-i;let c=n,u=0;for(;u<l;){const n=o[e.charCodeAt(u)]<<18|o[e.charCodeAt(u+1)]<<12|o[e.charCodeAt(u+2)]<<6|o[e.charCodeAt(u+3)];t[c++]=n>>16,t[c++]=n>>8,t[c++]=n,u+=4}if(3===i){const n=o[e.charCodeAt(u)]<<10|o[e.charCodeAt(u+1)]<<4|o[e.charCodeAt(u+2)]>>2;t[c++]=n>>8,t[c++]=n}else 2===i&&(t[c++]=o[e.charCodeAt(u)]<<2|o[e.charCodeAt(u+1)]>>4);return a.encode.bytes=c-n,t},decode(e,t,n){null!==t&&void 0!==t||(t=0),null!==n&&void 0!==n||(n=e.length);const o=n-t,l=o%3,c=t+o-l,u=[];for(let r=t;r<c;r+=3){const t=e[r]<<16|e[r+1]<<8|e[r+2];u.push(i[t>>18&63],i[t>>12&63],i[t>>6&63],i[63&t])}if(2===l){const t=(e[n-2]<<8)+e[n-1];u.push(i[t>>10],i[t>>4&63],i[t<<2&63]),1===r&&u.push(s)}else if(1===l){const t=e[n-1];u.push(i[t>>2],i[t<<4&63]),1===r&&u.push(s,s)}return a.decode.bytes=o,String.fromCharCode.apply(String,u)}};return a}jE("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",1);const VE=jE("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",2);let zE="undefined"!==typeof global?global.AbortError:"undefined"!==typeof window?window.AbortError:null;zE||(zE=class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Request aborted.")}}),zE.prototype.name="AbortError",zE.prototype.code="ABORT_ERR";const KE="undefined"!==typeof globalThis&&globalThis.URL||require("url").URL;class WE extends Error{constructor(e,t,n){super("status="+t+" while requesting "+e+" ["+n+"]"),this.uri=e,this.status=t,this.method=n}toJSON(){return{code:this.code,uri:this.uri,status:this.status,method:this.method,endpoint:this.endpoint}}}WE.prototype.name="HTTPStatusError",WE.prototype.code="HTTP_STATUS";class GE extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:XE(this.cause)}}}GE.prototype.name="ResponseError",GE.prototype.code="RESPONSE_ERR";class YE extends Error{constructor(e){super("Timeout (t="+e+")."),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}YE.prototype.name="TimeoutError",YE.prototype.code="ETIMEOUT";const QE=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,JE=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function XE(e){if("string"===typeof e)return{message:e};try{const t=JSON.stringify(e);if("{}"!==t)return JSON.parse(t)}catch(n){}const t={message:String(e.message||e)};return void 0!==e.code&&(t.code=String(e.code)),t}const ZE=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,eS=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,tS=/\[(((pk|name)=([^\]]+)))\]/gi;function nS(e,t){t.lastIndex=0;const n={};for(;;){const r=t.exec(e);if(!r)break;r[2]?n[r[3].toLowerCase()]=r[4]:n[r[1].toLowerCase()]=!0}return n}class rS extends Error{constructor(e,t){super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${oS.join(", ")}`),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}rS.prototype.name="InvalidProtocolError",rS.prototype.code="EPROTOCOL";const oS=["http:","https:","udp4:","udp6:"];class iS{constructor(e,t){this.name=e.name||null,this.protocol=e.protocol;const n="string"===typeof e.port?e.port=parseInt(e.port,10):e.port;if(void 0===n||null===n)this.port=t?"https:"===this.protocol?443:80:e.pk?443:53;else{if("number"!==typeof n&&!isNaN(n))throw new Error(`Invalid Endpoint: port "${e.port}" needs to be a number: ${JSON.stringify(e)}`);this.port=n}}toJSON(){return this.toString()}}class sS extends iS{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}]`:"",n=this.name?` [name=${this.name}]`:"";return`udp://${this.ipv4||`[${this.ipv6}]`}${e}${t}${n}`}}class aS extends sS{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 lS extends sS{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 cS(e){return JE.test(e)&&!QE.test(e)?`[${e}]`:e}class uS extends iS{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=JE.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||QE.test(this.host)&&(this.ipv4=this.host);const t=`${this.protocol}//${cS(this.host)}:${this.port}${this.path}`;try{this.url=new KE(t)}catch(n){throw new Error(n.message+` [${t}]`)}}toString(){const e="https:"===this.protocol?"":"http://",t=this.port!==("https:"===this.protocol?443:80)?`:${this.port}`:"",n="GET"!==this.method?" [post]":"",r="/dns-query"===this.path?"":this.path,o=this.name?` [name=${this.name}]`:"",i=this.ipv4&&this.ipv4!==this.host?` [ipv4=${this.ipv4}]`:"",s=this.ipv6&&this.ipv6!==this.host?` [ipv6=${this.ipv6}]`:"";return`${e}${cS(this.host)}${t}${r}${n}${i}${s}${o}`}}function dS(e){let t;if("string"===typeof e)t=function(e){const t=ZE.exec(e),n=t[2]||"https:",r=t[3],o=t[5],i=t[6],s=t[7];if("https:"===n||"http:"===n){const e=nS(s,eS);return{name:e.name,protocol:n,ipv4:e.ipv4,ipv6:e.ipv6,host:r,port:o,path:i,method:e.post?"POST":"GET"}}if("udp:"===n||"udp4:"===n||"udp6:"===n){const t=nS(s,tS),i=/^\[(.*)\]$/.exec(r);if(i&&"udp4:"===n)throw new Error(`Endpoint parsing error: Cannot use ipv6 host with udp4: (endpoint=${e})`);if(!i&&"udp6:"===n)throw new Error(`Endpoint parsing error: Incorrectly formatted host for udp6: (endpoint=${e})`);return i?new lS({protocol:"udp6:",ipv6:i[1],port:o,pk:t.pk,name:t.name}):new aS({protocol:"udp4:",ipv4:r,port:o,pk:t.pk,name:t.name})}throw new rS(n,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 iS)return e;t=e}null!==t.protocol&&void 0!==t.protocol||(t.protocol="https:");const n=t.protocol;if("udp4:"===n)return new aS(t);if("udp6:"===n)return new lS(t);if("https:"===n||"http:"===n)return new uS(t);throw new rS(n,JSON.stringify(t))}const hS="application/dns-message";function fS(){}function pS(e,t,n,r,o){return new Promise(((i,s)=>{const a=new KE(e);"GET"===t&&n&&(a.search="?dns="+VE.decode(n));const l=a.toString(),c=new XMLHttpRequest;c.open(t,l,!0),c.setRequestHeader("Accept",hS),"POST"===t&&c.setRequestHeader("Content-Type",hS),c.responseType="arraybuffer",c.timeout=r,c.ontimeout=function(){u(new YE(r));try{c.abort()}catch(e){}},c.onreadystatechange=function(){if(c.readyState>1&&200!==c.status&&0!==c.status){u(new WE(l,c.status,t));try{c.abort()}catch(e){}}},c.onerror=function(){u(200===c.status?new Error("Inexplicable XHR Error"):new WE(l,c.status,t))},c.onload=function(){if(200!==c.status)u(new WE(l,c.status,t));else{let e;if("string"===typeof c.response)e=jv(c.response);else if(c.response instanceof Uint8Array)e=c.response;else{if(!(Array.isArray(c.response)||c.response instanceof ArrayBuffer))throw new Error("Unprocessable response "+c.response);e=new Uint8Array(c.response)}u(null,e)}},"POST"===t?c.send(n):c.send(),o&&o.addEventListener("abort",d);let u=function(e,t){u=fS,o&&o.removeEventListener("abort",d),i(e?{error:e,response:c}:{data:t,response:c})};function d(){u(new zE);try{c.abort()}catch(e){}}}))}Error;function gS(e){const t=null===e.time||void 0===e.time?Date.now():e.time,n=function(e){return e.filter((e=>e.cors||e.endpoint.cors))}(e.data.map((e=>(e.endpoint=dS(Object.assign({name:e.name},e.endpoint)),e)))),r=n.map((e=>e.endpoint));return{data:{resolvers:n,resolverByName:n.reduce(((e,t)=>(e[t.name]=t,e)),{}),endpoints:r,endpointByName:r.reduce(((e,t)=>(e[t.name]=t,e)),{})},time:t}}const mS=gS({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 yS(e,t,n,r){return r&&r.aborted?Promise.reject(new zE):"udp4:"===e.protocol||"udp6:"===e.protocol?function(){throw new Error('Only "doh" endpoints are supported in the browser')}():function(e,t,n,r){return function(e,t,n,r,o){return pS(e,t,n,r,o)}(e.url,e.method,UE(Object.assign({flags:256},t)),n,r).then((function(e){const t=e.data,n=e.response;let r=e.error;if(void 0===r)if(0===t.length)r=new GE("Empty.");else try{const e=ME(t);return e.response=n,e}catch(o){r=new GE("Invalid packet (cause="+o.message+")",o)}throw Object.assign(r,{response:n})}))}(e,t,n,r)}const bS=new KE("https://martinheidegger.github.io/dns-query/resolvers.json");function wS(e){return/^@/.test(e)}const vS=new class{constructor(e){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:bS,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,n,r){const o=t?t.localStoragePrefix+t.name:null;if(o)try{const e=JSON.parse(localStorage.getItem(o));if(e&&e.time>t.maxTime)return e}catch(a){}const{data:i}=await pS(e,"GET",null,n,r),s={time:Date.now(),data:JSON.parse(Vv(i))};if(o)try{localStorage.setItem(o,JSON.stringify(s))}catch(a){s.time=null}return s}(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=>gS({data:e.data.resolvers,time:e.time}))).catch((()=>t||mS)):Promise.resolve(mS),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=kS),"dns"===e&&(e=AS),"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(wS))try{return Promise.resolve(e.map(dS))}catch(t){return Promise.reject(t)}return this.data().then((t=>e.map((e=>{if(wS(e)){const n=t.endpointByName[e.substring(1)];if(!n)throw new Error(`Endpoint ${e} is not known.`);return n}return dS(e)}))))}};function ES(e,t){return t=Object.assign({retries:5,timeout:3e4},t),e.question?(n=t.endpoints,function(e){return null!==e&&"object"===typeof e&&"function"===typeof e.then}(n)?n:Promise.resolve(n)).then((n=>{if(!Array.isArray(n)||0===n.length)throw new Error("No endpoints defined to lookup dns records.");return SS(n.map(dS),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 n}function SS(e,t,n){const r=1===e.length?e[0]:e[Math.floor(Math.random()*e.length)%e.length];return yS(r,t,n.timeout,n.signal).then((e=>(e.endpoint=r.toString(),e)),(o=>{if("AbortError"===o.name||0===n.retries)throw o.endpoint=r.toString(),o;return n.retries>0&&(n.retries-=1),SS(e,t,n)}))}function kS(e){return"https:"===e.protocol||"http:"===e.protocol}function AS(e){return"udp4:"===e.protocol||"udp6:"===e.protocol}const _S=new Cr("dns-over-https");class IS{endpoints;retries;static async create(e,t){const n=e??await vS.endpoints("doh");return new IS(n,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 ES({question:{type:"TXT",name:e}},{endpoints:this.endpoints,retries:this.retries})).answers}catch(o){throw _S.error("query failed: ",o),new Error("DNS query failed")}if(!t)throw new Error(`Could not resolve ${e}`);const n=t.map((e=>e.data)),r=[];return n.forEach((e=>{"string"===typeof e?r.push(e):Array.isArray(e)?e.forEach((e=>{"string"===typeof e?r.push(e):r.push(pr(e))})):r.push(pr(e))})),r}}var xS=__webpack_require__(5411);class CS{static RECORD_PREFIX=(()=>Xw.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 n=CS.parseRootValues(e),r=xS.decode.asBytes(t),o=e.split(" sig")[0],i=gr(o);if(!Uw(Dt(n.signature,"base64url").slice(0,64),Bw(i),new Uint8Array(r)))throw new Error("Unable to verify ENRTree root signature");return n.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[n,r,o,i]=t;if(!n)throw new Error("Could not parse 'e' value from ENRTree root entry");if(!r)throw new Error("Could not parse 'l' value from ENRTree root entry");if(!o)throw new Error("Could not parse 'seq' value from ENRTree root entry");if(!i)throw new Error("Could not parse 'sig' value from ENRTree root entry");return{eRoot:n,lRoot:r,seq:Number(o),signature:i}}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[n,r]=t;if(!n)throw new Error("Could not parse public key from ENRTree tree entry");if(!r)throw new Error("Could not parse domain from ENRTree tree entry");return{publicKey:n,domain:r}}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 RS=new Cr("discovery:fetch_nodes");function TS(e,t){return t.relay>=e.relay&&t.store>=e.store&&t.filter>=e.filter&&t.lightPush>=e.lightPush}function NS(e,t){if(!e.nodeId)return!1;for(const n of t)if(e.nodeId===n.nodeId)return!1;return!0}function PS(e,t){e.relay&&(t.relay+=1),e.store&&(t.store+=1),e.filter&&(t.filter+=1),e.lightPush&&(t.lightPush+=1)}function OS(e,t,n){if(TS(t,n))throw"Internal Error: Waku2 wanted capabilities are already fulfilled";const r=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,n);return r.relay&&e.relay||r.store&&e.store||r.filter&&e.filter||r.lightPush&&e.lightPush}const LS=new Cr("discovery:dns");class DS{dns;_DNSTreeCache;_errorTolerance=10;static async dnsOverHttp(e){return e||(e=await IS.create()),new DS(e)}async getPeers(e,t){const n=Math.floor(Math.random()*e.length),{publicKey:r,domain:o}=CS.parseTree(e[n]),i={domain:o,publicKey:r,visits:{}},s=await async function(e,t,n){const r={relay:e.relay??0,store:e.store??0,filter:e.filter??0,lightPush:e.lightPush??0},o=r.relay+r.store+r.filter+r.lightPush,i={relay:0,store:0,filter:0,lightPush:0};let s=0;const a=[];for(;!TS(r,i)&&s<o+t;){const e=await n();e&&NS(e,a)&&(e.waku2&&OS(e.waku2,r,i)&&(PS(e.waku2,i),a.push(e)),RS.info(`got new peer candidate from DNS address=${e.nodeId}@${e.ip}`)),s++}return a}(t,this._errorTolerance,(()=>this._search(o,i)));return LS.info("retrieved peers: ",s.map((e=>({id:e.peerId?.toString(),multiaddrs:e.multiaddrs?.map((e=>e.toString()))})))),s}constructor(e){this._DNSTreeCache={},this.dns=e}async*getNextPeer(e,t){const n=Math.floor(Math.random()*e.length),{publicKey:r,domain:o}=CS.parseTree(e[n]),i={domain:o,publicKey:r,visits:{}};for await(const s of async function*(e,t,n){const r={relay:e.relay??0,store:e.store??0,filter:e.filter??0,lightPush:e.lightPush??0},o=r.relay+r.store+r.filter+r.lightPush,i={relay:0,store:0,filter:0,lightPush:0};let s=0;const a=new Set;for(;!TS(r,i)&&s<o+t;){const e=await n();e&&e.nodeId&&!a.has(e.nodeId)&&(a.add(e.nodeId),e.waku2&&OS(e.waku2,r,i)&&(PS(e.waku2,i),yield e),RS.info(`got new peer candidate from DNS address=${e.nodeId}@${e.ip}`)),s++}}(t,this._errorTolerance,(()=>this._search(o,i))))yield s}async _search(e,t){try{const r=await this._getTXTRecord(e,t);let o,i;t.visits[e]=!0;const s=function(e){return e.startsWith(CS.ROOT_PREFIX)?CS.ROOT_PREFIX:e.startsWith(CS.BRANCH_PREFIX)?CS.BRANCH_PREFIX:e.startsWith(CS.RECORD_PREFIX)?CS.RECORD_PREFIX:""}(r);try{switch(s){case CS.ROOT_PREFIX:return o=CS.parseAndVerifyRoot(r,t.publicKey),await this._search(o,t);case CS.BRANCH_PREFIX:return i=CS.parseBranch(r),o=function(e,t){const n={};for(const[o,i]of e.entries())t.visits[i]&&(n[o]=!0);if(Object.keys(n).length===e.length)throw new Error("Unresolvable circular path detected");let r;do{r=Math.floor(Math.random()*e.length)}while(n[r]);return e[r]}(i,t),await this._search(o,t);case CS.RECORD_PREFIX:return xv.fromString(r);default:return null}}catch(n){return LS.error(`Failed to search DNS tree ${s} at subdomain ${e}: ${n}`),null}}catch(n){return LS.error(`Failed to retrieve TXT record at subdomain ${e}: ${n}`),null}}async _getTXTRecord(e,t){if(this._DNSTreeCache[e])return this._DNSTreeCache[e];const n=e!==t.domain?`${e}.${t.domain}`:t.domain,r=await this.dns.resolveTXT(n);if(!r.length)throw new Error("Received empty result array while fetching TXT record");if(!r[0].length)throw new Error("Received empty TXT record");const o=r.join("");return this._DNSTreeCache[e]=o,o}}const BS=new Cr("peer-discovery-dns");class US extends Yo{nextPeer;_started;_components;_options;constructor(e,t){super(),this._started=!1,this._components=e,this._options=t;const{enrUrls:n}=t;BS.info("Use following EIP-1459 ENR Tree URLs: ",n)}async start(){BS.info("Starting peer discovery via dns"),this._started=!0,await this.findPeers()}async findPeers(){if(!this.nextPeer){let{enrUrls:e}=this._options;Array.isArray(e)||(e=[e]);const{wantedNodeCapabilityCount:t}=this._options,n=await DS.dnsOverHttp();this.nextPeer=n.getNextPeer.bind(n,e,t)}for await(const e of this.nextPeer()){if(!this._started)return;const{peerInfo:t,shardInfo:n}=e;if(!t)continue;const r={[Tb]:{value:this._options.tagValue??50,ttl:this._options.tagTTL??1e8}};let o=!1;if(await this._components.peerStore.has(t.id)){(await this._components.peerStore.get(t.id)).tags.has(Tb)||(o=!0,await this._components.peerStore.merge(t.id,{tags:r}))}else o=!0,await this._components.peerStore.save(t.id,{tags:r,...n&&{metadata:{shardInfo:_r(n)}}});o&&this.dispatchEvent(new Qo("peer",{detail:t}))}}stop(){this._started=!1}get[nf](){return!0}get[Symbol.toStringTag](){return lr}}function MS(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Nb;return n=>new US(n,{enrUrls:e,wantedNodeCapabilityCount:t})}class FS{proto;constructor(e){this.proto=e}static createRequest(e){const{numPeers:t}=e;return new FS({query:{numPeers:t},response:void 0})}encode(){return An.encode(this.proto)}static decode(e){const t=An.decode(e);return new FS(t)}get query(){return this.proto.query}get response(){return this.proto.response}}const $S="/vac/waku/peer-exchange/2.0.0-alpha1",HS=new Cr("peer-exchange");class qS extends fo{constructor(e,t){super($S,e,HS,t)}async query(e){const{numPeers:t,peerId:n}=e,r=FS.createRequest({numPeers:BigInt(t)}),o=await this.components.peerStore.get(n);if(!o)return{peerInfos:null,error:or.NO_PEER_AVAILABLE};let i;try{i=await this.getStream(o)}catch(a){return HS.error("Failed to get stream",a),{peerInfos:null,error:or.NO_STREAM_AVAILABLE}}const s=await io([r.encode()],Vr,i,Jr,(async e=>await Dr(e)));try{const e=new Hr;s.forEach((t=>{e.append(t)}));const{response:t}=FS.decode(e);if(!t)return HS.error("PeerExchangeRPC message did not contains a `response` field"),{peerInfos:null,error:or.EMPTY_PAYLOAD};return{peerInfos:await Promise.all(t.peerInfos.map((e=>e.enr)).filter(Nn).map((async e=>({ENR:await xv.fromRLP(e)})))),error:null}}catch(a){return HS.error("Failed to decode push reply",a),{peerInfos:null,error:or.DECODE_FAILED}}}}const jS=new Cr("peer-exchange-discovery"),VS=1e4,zS=3,KS=ir.PEER_EXCHANGE;class WS extends Yo{components;peerExchange;options;isStarted;queryingPeers=(()=>new Set)();queryAttempts=(()=>new Map)();handleDiscoveredPeer=e=>{const{protocols:t,peerId:n}=e.detail;t.includes($S)&&!this.queryingPeers.has(n.toString())&&(this.queryingPeers.add(n.toString()),this.startRecurringQueries(n).catch((e=>jS.error(`Error querying peer ${e}`))))};constructor(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};super(),this.components=e,this.peerExchange=new qS(e,t),this.options=n,this.isStarted=!1}start(){this.isStarted||(this.dispatchEvent(new Qo("waku:peer-exchange:started",{detail:!0})),jS.info("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(jS.info("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[nf](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}startRecurringQueries=async e=>{const t=e.toString(),{queryInterval:n=VS,maxRetries:r=zS}=this.options;jS.info(`Querying peer: ${t} (attempt ${this.queryAttempts.get(t)??1})`),await this.query(e);const o=this.queryAttempts.get(t)??1;o>r?this.abortQueriesForPeer(t):setTimeout((()=>{this.queryAttempts.set(t,o+1),this.startRecurringQueries(e).catch((e=>{jS.error(`Error in startRecurringQueries: ${e}`)}))}),n*o)};async query(e){const{error:t,peerInfos:n}=await this.peerExchange.query({numPeers:10,peerId:e});if(t)return jS.error("Peer exchange query failed",t),{error:t,peerInfos:null};for(const r of n){const{ENR:e}=r;if(!e){jS.warn("No ENR in peerInfo object, skipping");continue}const{peerId:t,peerInfo:n,shardInfo:o}=e;if(!t||!n)continue;if(await this.components.peerStore.has(t)){const{hasMultiaddrDiff:e,hasShardDiff:r}=await this.checkPeerInfoDiff(n,o);if(e||r){jS.info(`Peer ${t.toString()} has updated multiaddrs or shardInfo, updating`),e&&(jS.info(`Peer ${t.toString()} has updated multiaddrs, updating`),await this.components.peerStore.patch(t,{multiaddrs:n.multiaddrs})),r&&o&&(jS.info(`Peer ${t.toString()} has updated shardInfo, updating`),await this.components.peerStore.merge(t,{metadata:{shardInfo:_r(o)}}),this.dispatchEvent(new Qo("peer",{detail:{id:t,multiaddrs:n.multiaddrs}})));continue}}await this.components.peerStore.save(t,{tags:{[KS]:{value:this.options.tagValue??50,ttl:this.options.tagTTL??1e8}},...o&&{metadata:{shardInfo:_r(o)}},...n.multiaddrs&&{multiaddrs:n.multiaddrs}}),jS.info(`Discovered peer: ${t.toString()}`),this.dispatchEvent(new Qo("peer",{detail:{id:t,multiaddrs:n.multiaddrs}}))}return{error:null,peerInfos:n}}abortQueriesForPeer(e){jS.info(`Aborting queries for peer: ${e}`),this.queryingPeers.delete(e),this.queryAttempts.delete(e)}async checkPeerInfoDiff(e,t){const{id:n}=e,r=await this.components.peerStore.get(n),o=r.addresses.map((e=>e.multiaddr.toString())),i=e.multiaddrs.map((e=>e.toString())),s=o.some((e=>!i.includes(e)));let a=!1;const l=r.metadata.get("shardInfo");if(l){const e=Ar(l);(e||t)&&(a=e.clusterId!==t?.clusterId||e.shards.some((e=>!t?.shards.includes(e))))}return{hasMultiaddrDiff:s,hasShardDiff:a}}}function GS(e){return t=>new WS(t,e)}const YS=new Cr("peer-exchange-discovery"),QS=ir.LOCAL;class JS extends Yo{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){YS.info("Starting Local Storage Discovery"),this.components.events.addEventListener("peer:identify",this.handleNewPeers);for(const{id:e,address:t}of this.peers){const n=await Jg({id:e});await this.components.peerStore.has(n)||(await this.components.peerStore.save(n,{multiaddrs:[ji(t)],tags:{[this.options?.tagName??QS]:{value:this.options?.tagValue??50,ttl:this.options?.tagTTL??1e8}}}),this.dispatchEvent(new Qo("peer",{detail:{id:n,multiaddrs:[ji(t)]}})))}YS.info(`Discovered ${this.peers.length} peers`),this.isStarted=!0}}stop(){this.isStarted&&(YS.info("Stopping Local Storage Discovery"),this.components.events.removeEventListener("peer:identify",this.handleNewPeers),this.isStarted=!1,this.savePeersToLocalStorage())}handleNewPeers=e=>{const{peerId:t,listenAddrs:n}=e.detail,r=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}(n),o=this.getPeersFromLocalStorage(),i=o.findIndex((e=>e.id===t.toString()));i>=0?o[i].address=r.toString():o.push({id:t.toString(),address:r.toString()}),this.peers=o,this.savePeersToLocalStorage()};getPeersFromLocalStorage(){try{const e=localStorage.getItem("waku:peers");if(!e)return[];return JSON.parse(e).filter(XS)}catch(e){return YS.error("Error parsing peers from local storage:",e),[]}}savePeersToLocalStorage(){try{localStorage.setItem("waku:peers",JSON.stringify(this.peers))}catch(e){YS.error("Error saving peers to local storage:",e)}}}function XS(e){return e&&"object"===typeof e&&"string"===typeof e.id&&"string"===typeof e.address}const ZS=new Cr("sdk:create");async function ek(e,t,n){t?.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 r=e?{metadata:si(e)}:{};return async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await xb(e);return!1!==e.start&&await t.start(),t}({connectionManager:{minConnections:1},transports:[Tg({filter:!1===t?.filterMultiaddrs?xg:Cg})],streamMuxers:[sg()],connectionEncryption:[tf()],...t,services:{identify:Dp({agentVersion:n??"js-waku"}),ping:ug({maxInboundStreams:t?.pingMaxInboundStreams??10}),...r,...t?.services}})}async function tk(e){const{networkConfig:t}=e,n=function(e){if("clusterId"in(t=e)&&"shards"in t&&!("contentTopics"in t)){if(0===e.shards.length)throw new Error("Invalid shards configuration: please provide at least one shard");return yr(e)}if(function(e){return"contentTopics"in e}(e)){if(0===e.contentTopics.length)throw new Error("Invalid content topics configuration: please provide at least one content topic");return e.contentTopics.map((t=>Sr(t,e.clusterId)))}throw new Error("Unknown shard config. Please use ShardInfo or ContentTopicInfo");var t}(t??cr);ZS.info("Creating Waku node with pubsub topics",n);const r=e?.libp2p??{},o=r.peerDiscovery??[];var i;e?.defaultBootstrap&&o.push(...function(e){return[MS([Cb,Rb]),(e,t)=>new JS(e,t),GS(e)]}(n)),e?.bootstrapPeers&&o.push((i={list:e.bootstrapPeers},e=>new Bf(e,i))),r.peerDiscovery=o;return{libp2p:await ek(n,r,e?.userAgent),pubsubTopics:n}}const nk="/js-waku-examples/1/message-ratio/utf8",rk=Sr(nk),ok={NODE_ENV:"production",PUBLIC_URL:"",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.REACT_APP_TELEMETRY_URL||"http://localhost:8080/waku-metrics",ik=["/dns4/node-01.do-ams3.waku.test.status.im/tcp/8000/wss","/dns4/node-01.ac-cn-hongkong-c.waku.test.status.im/tcp/8000/wss","/dns4/node-01.gc-us-central1-a.waku.test.status.im/tcp/8000/wss"];async function sk(){const e=await async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{libp2p:t,pubsubTopics:n}=await tk(e);return new gs(n,e,t,{store:!0,lightpush:!0,filter:!0})}({networkConfig:{contentTopics:[nk]},defaultBootstrap:!0});return await e.start(),await Promise.all(function(){return ik.map((e=>ji(e)))}().map((t=>e.dial(t)))),await zo(e),e}var ak=__webpack_require__(4412);const lk=new ak.Type("SequencedMessage").add(new ak.Field("hash",1,"string")).add(new ak.Field("total",2,"uint64")).add(new ak.Field("index",3,"uint64")).add(new ak.Field("sender",4,"string")),ck=async e=>{const t=(new TextEncoder).encode(e.toString()),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")},uk={sdk:"0.0.28"},dk=(JSON.stringify(uk),async(e,t)=>{const n=await e.libp2p.peerStore.get(Nd(t)),r=n.addresses.map((e=>e.multiaddr.toString())).some((e=>e.includes("ws")||e.includes("wss")));return JSON.stringify({...uk,peerId:t,hasWebsockes:r,enabledProtocols:n.protocols})});let hk=function(e){return e.LIGHT_PUSH_FILTER="LightPushFilter",e}({});async function fk(e,t,n,r,o,i){let s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:10,a=arguments.length>7&&void 0!==arguments[7]?arguments[7]:1e4;if(i.current)return void console.log("A sequence is already running. Skipping this call.");i.current=!0,console.info("Starting a new lightpush sequence");const l=await ck(Math.floor(1e6*Math.random()).toString()),c=s;let u=0;const d=Or({contentTopic:nk}),h=async()=>{try{const f=await ck(`${l}-${u}-${c}`),p=Math.floor((new Date).getTime()/1e3),g=lk.create({hash:f,total:c,index:u,sender:e.libp2p.peerId.toString()}),m=lk.encode(g).finish(),y=await e.lightPush.send(d,{payload:m,timestamp:new Date}),b=await Promise.all([...y.successes.map((async t=>{const n=await dk(e,t.toString());return{type:hk.LIGHT_PUSH_FILTER,protocol:"lightPush",timestamp:p,createdAt:p,seenTimestamp:p,peerId:t.toString(),contentTopic:nk,pubsubTopic:rk,ephemeral:!1,messageHash:f,errorMessage:"",extraData:n}})),...y.failures.map((async t=>{var n,r,o,i,s,a;const l=await dk(e,null!==(n=null===t||void 0===t||null===(r=t.peerId)||void 0===r?void 0:r.toString())&&void 0!==n?n:"");return{type:hk.LIGHT_PUSH_FILTER,protocol:"lightPush",timestamp:p,createdAt:p,seenTimestamp:p,peerId:null!==(o=null===t||void 0===t||null===(i=t.peerId)||void 0===i?void 0:i.toString())&&void 0!==o?o:"",contentTopic:nk,pubsubTopic:rk,ephemeral:!1,messageHash:f,errorMessage:null!==(s=null===t||void 0===t||null===(a=t.error)||void 0===a?void 0:a.toString())&&void 0!==s?s:"",extraData:l}}))]);b.length>0&&t.push(b);if(y.successes.length>0){const e=JSON.stringify({content:`${f} - ${u+1} of ${c}`,success:!0});n(e,!0),u++}else n(JSON.stringify({content:`Failed to send message ${u+1} of ${c}`,success:!1}),!1);if(u<c){let e=a/1e3;const t=setInterval((()=>{e-=1,o(e),e<=0&&(clearInterval(t),o(null))}),1e3);setTimeout((()=>{clearInterval(t),h()}),a)}else console.info("Lightpush sequence completed"),r(u+1),o(null),i.current=!1,setTimeout((()=>fk(e,t,n,r,o,i,s,a)),a)}catch(f){console.error("Error sending message",f),n(JSON.stringify({content:`Error sending message ${u+1} of ${c}`,success:!1}),!1),i.current=!1,setTimeout((()=>fk(e,t,n,r,o,i,s,a)),a)}};h()}async function pk(e,t,n){const r=new Lr(kr(o=nk,i),o);var o,i;const s=e.libp2p.peerId.toString();await e.filter.subscribe([r],(async r=>{var o,i;const a=lk.decode(r.payload),l=`${a.hash} - ${a.index+1} of ${a.total}`,c=a.sender===s;n(l,c);const u=await dk(e,s),d=Math.floor((new Date).getTime()/1e3);t.push([{type:hk.LIGHT_PUSH_FILTER,protocol:"filter",timestamp:d,createdAt:Math.floor(null!==(o=null===r||void 0===r||null===(i=r.timestamp)||void 0===i?void 0:i.getTime())&&void 0!==o?o:0),seenTimestamp:d,peerId:a.sender,contentTopic:r.contentTopic,pubsubTopic:r.pubsubTopic,ephemeral:r.ephemeral,messageHash:a.hash,errorMessage:"",extraData:u}])}))}class gk{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:5e3;this.url=e,this.intervalPeriod=t,this.queue=[],this.intervalId=null,this.requestId=0}push(e){this.queue.push(...e)}async start(){this.intervalId||(this.intervalId=setInterval((async()=>{if(this.queue.length>0){await this.send(this.queue)&&(console.log("Sent ",this.queue.length," telemetry logs"),this.queue=[])}}),this.intervalPeriod))}stop(){this.intervalId&&(clearInterval(this.intervalId),this.intervalId=null)}async send(e){const t=e.map((e=>({id:++this.requestId,telemetryType:e.type.toString(),telemetryData:e})));try{const e=await fetch(this.url,{method:"POST",body:JSON.stringify(t)});return 201===e.status||(console.error("Error sending messages to telemetry service: ",e.status,e.statusText,e.json),!1)}catch(n){return console.error("Error sending messages to telemetry service: ",n),console.error("Failed trying to send the following messages: ",t),!1}}}var mk=__webpack_require__(579);const yk=e=>{let{title:t,messages:n,showSequence:r}=e;const o=e=>{try{return JSON.parse(e).content||e}catch{return e}},i=e=>{const t=["bg-blue-100","bg-green-100","bg-yellow-100","bg-red-100","bg-indigo-100","bg-purple-100"];return t[e%t.length]},s=r?n.reduce(((e,t)=>(e[t.sequenceId]||(e[t.sequenceId]=[]),e[t.sequenceId].unshift(t),e)),{}):{0:n.slice().reverse()};return 0===n.length?(0,mk.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,mk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:t}),(0,mk.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 h-96 flex items-center justify-center",children:(0,mk.jsx)("p",{className:"text-gray-500",children:"Waiting for messages..."})})]}):(0,mk.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,mk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:t}),(0,mk.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 h-96 overflow-y-auto border border-gray-200",children:Object.entries(s).map((e=>{let[t,n]=e;return(0,mk.jsxs)("div",{className:`mb-4 p-2 rounded-lg ${r?i(Number(t)):""}`,children:[r&&(0,mk.jsxs)("div",{className:"text-xs font-semibold mb-2",children:["Sequence ",t]}),n.map(((e,t)=>(0,mk.jsx)("div",{className:"text-sm mb-2 font-mono bg-white p-2 rounded shadow-sm",children:o(e.content)},t))).reverse()]},t)}))})]})},bk=e=>{let{stats:t}=e;return(0,mk.jsxs)("div",{className:"mt-8",children:[(0,mk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:"Stats"}),(0,mk.jsxs)("div",{className:"grid grid-cols-3 gap-6",children:[(0,mk.jsxs)("div",{className:"bg-blue-50 p-4 rounded-lg shadow",children:[(0,mk.jsx)("p",{className:"text-sm font-medium text-blue-600",children:"Sent"}),(0,mk.jsx)("p",{className:"text-2xl font-bold text-blue-800",children:t.sent})]}),(0,mk.jsxs)("div",{className:"bg-green-50 p-4 rounded-lg shadow",children:[(0,mk.jsx)("p",{className:"text-sm font-medium text-green-600",children:"Received"}),(0,mk.jsx)("p",{className:"text-2xl font-bold text-green-800",children:t.received})]}),(0,mk.jsxs)("div",{className:"bg-yellow-50 p-4 rounded-lg shadow",children:[(0,mk.jsx)("p",{className:"text-sm font-medium text-yellow-600",children:"Self-Received"}),(0,mk.jsx)("p",{className:"text-2xl font-bold text-yellow-800",children:t.selfReceived})]})]})]})},wk=e=>{let{countdown:t}=e;return null===t?null:(0,mk.jsx)("div",{className:"text-center text-gray-600 mt-4",children:(0,mk.jsxs)("p",{children:["Next message in: ",t," seconds"]})})},vk=e=>{let{success:t}=e;const[n,r]=(0,b.useState)(!1);return(0,b.useEffect)((()=>{if(null!==t){r(!0);const e=setTimeout((()=>r(!1)),3e3);return()=>clearTimeout(e)}}),[t]),n?(0,mk.jsx)("div",{className:`fixed bottom-4 right-4 p-4 rounded-lg ${t?"bg-green-500":"bg-red-500"} text-white shadow-lg transition-opacity duration-300 ${n?"opacity-100":"opacity-0"}`,children:t?(0,mk.jsxs)("div",{className:"flex items-center",children:[(0,mk.jsx)("svg",{className:"w-6 h-6 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,mk.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,mk.jsx)("span",{children:"Message sent successfully"})]}):(0,mk.jsxs)("div",{className:"flex items-center",children:[(0,mk.jsx)("svg",{className:"w-6 h-6 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,mk.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),(0,mk.jsx)("span",{children:"Failed to send message"})]})}):null};let Ek=1;const Sk=function(){const[e,t]=(0,b.useState)([]),[n,r]=(0,b.useState)([]),[o,i]=(0,b.useState)([]),[s,a]=(0,b.useState)({sent:0,received:0,selfReceived:0}),[l,c]=(0,b.useState)(null),[u,d]=(0,b.useState)(null),[h,f]=(0,b.useState)({totalConnections:0,filterPeers:0,lightPushPeers:0,storePeers:0}),p=(0,b.useRef)(!1);return(0,b.useEffect)((()=>{(async()=>{const e=await sk(),n=new gk(ok);n.start();const o=()=>{f({totalConnections:e.libp2p.getConnections().length,filterPeers:e.filter.connectedPeers.length,lightPushPeers:e.lightPush.connectedPeers.length,storePeers:e.store.connectedPeers.length})};o();const s=setInterval(o,5e3);pk(e,n,((e,t)=>{const n={content:e,sequenceId:Ek,timestamp:Date.now()};t?(i((e=>[...e,n])),a((e=>({...e,selfReceived:e.selfReceived+1})))):(r((e=>[...e,n])),a((e=>({...e,received:e.received+1}))))}));fk(e,n,((e,n)=>{const r={content:e,sequenceId:Ek,timestamp:Date.now()};t((e=>[r,...e])),a((e=>({...e,sent:e.sent+1}))),d(n)}),(e=>{Ek=1===e?1:Ek+1,console.log("Updated sequence ID to:",Ek)}),c,p)})()}),[]),(0,mk.jsx)("div",{className:"min-h-screen bg-gray-100 p-8",children:(0,mk.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,mk.jsx)("h1",{className:"text-4xl font-bold text-gray-800 mb-8",children:"Waku Message Monitor"}),(0,mk.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[(0,mk.jsxs)("div",{className:"space-y-8",children:[(0,mk.jsx)(yk,{title:"Sent Messages",messages:e,showSequence:!0}),(0,mk.jsx)(yk,{title:"Received Messages",messages:n,showSequence:!1})]}),(0,mk.jsxs)("div",{className:"space-y-8",children:[(0,mk.jsx)(yk,{title:"Self-Received Messages",messages:o,showSequence:!0}),(0,mk.jsx)(bk,{stats:s}),(0,mk.jsxs)("div",{className:"bg-white rounded-lg shadow p-6",children:[(0,mk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:"Node Info"}),(0,mk.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,mk.jsxs)("div",{children:[(0,mk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"Total Connections"}),(0,mk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.totalConnections})]}),(0,mk.jsxs)("div",{children:[(0,mk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"Filter Peers"}),(0,mk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.filterPeers})]}),(0,mk.jsxs)("div",{children:[(0,mk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"LightPush Peers"}),(0,mk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.lightPushPeers})]}),(0,mk.jsxs)("div",{children:[(0,mk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"Store Peers"}),(0,mk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.storePeers})]})]})]})]})]}),(0,mk.jsx)(wk,{countdown:l}),(0,mk.jsx)(vk,{success:u})]})})};w.createRoot(document.getElementById("root")).render((0,mk.jsx)(b.StrictMode,{children:(0,mk.jsx)(Sk,{})}))})()})();
//# sourceMappingURL=main.4b50e294.js.map