status-im-auto 3b922bab4b Updates
2024-10-25 08:22:24 +00:00

3 lines
847 KiB
JavaScript

/*! For license information please see main.47860875.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(9020);t.PP=r.EventIterator,r.EventIterator},9020:(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:()=>Qs,e8:()=>Ls,DO:()=>Os,dJ:()=>Js,OG:()=>Xs,My:()=>Bs,Ph:()=>qs,lX:()=>js,Id:()=>Ws,fg:()=>ta,qj:()=>Ks,aT:()=>Hs,r4:()=>Ys,aY:()=>Ps,x:()=>oa,lq:()=>Vs,z:()=>zs,zW:()=>Us,Q5:()=>ra});var g={};__webpack_require__.r(g),__webpack_require__.d(g,{Ed25519PrivateKey:()=>ul,Ed25519PublicKey:()=>cl,generateKeyPair:()=>fl,generateKeyPairFromSeed:()=>pl,unmarshalEd25519PrivateKey:()=>dl,unmarshalEd25519PublicKey:()=>hl});var m={};__webpack_require__.r(m),__webpack_require__.d(m,{MAX_RSA_KEY_SIZE:()=>Du,RsaPrivateKey:()=>Uu,RsaPublicKey:()=>Bu,fromJwk:()=>$u,generateKeyPair:()=>Hu,unmarshalRsaPrivateKey:()=>Mu,unmarshalRsaPublicKey:()=>Fu});var y={};__webpack_require__.r(y),__webpack_require__.d(y,{Secp256k1PrivateKey:()=>ld,Secp256k1PublicKey:()=>ad,generateKeyPair:()=>dd,unmarshalSecp256k1PrivateKey:()=>cd,unmarshalSecp256k1PublicKey:()=>ud});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{_info;_warn;_error;static createDebugNamespace(e,t){return t?`${xr}:${e}:${t}`:`${xr}:${e}`}constructor(e){this._info=Ir(Cr.createDebugNamespace("info",e)),this._warn=Ir(Cr.createDebugNamespace("warn",e)),this._error=Ir(Cr.createDebugNamespace("error",e))}get info(){return this._info}get warn(){return this._warn}get error(){return this._error}log(e){const t=this[e];for(var 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};function ho(e){return e.filter((e=>"open"===e.status)).sort(((e,t)=>t.timeline.open-e.timeline.open)).at(0)}const fo="consumed";class po{multicodec;getConnections;addEventListener;log;ongoingCreation=(()=>new Set)();streamPool=(()=>new Map)();constructor(e,t,n){this.multicodec=e,this.getConnections=t,this.addEventListener=n,this.log=new Cr(`stream-manager:${e}`),this.addEventListener("peer:update",this.handlePeerUpdateStreamPool)}async getStream(e){const t=e.id.toString(),n=this.streamPool.get(t);n&&(this.streamPool.delete(t),await n);let r=this.getOpenStreamForCodec(e.id);return r?(this.log.info(`Found existing stream peerId=${e.id.toString()} multicodec=${this.multicodec}`),this.lockStream(e.id.toString(),r),r):(r=await this.createStream(e),this.lockStream(e.id.toString(),r),r)}async createStream(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;const n=ho(this.getConnections(e.id));if(!n)throw new Error(`Failed to get a connection to the peer peerId=${e.id.toString()} multicodec=${this.multicodec}`);let r,o;for(let s=0;s<t+1;s++)try{this.log.info(`Attempting to create a stream for peerId=${e.id.toString()} multicodec=${this.multicodec}`),o=await n.newStream(this.multicodec),this.log.info(`Created stream for peerId=${e.id.toString()} multicodec=${this.multicodec}`);break}catch(i){r=i}if(!o)throw new Error(`Failed to create a new stream for ${e.id.toString()} -- `+r);return o}async createStreamWithLock(e){const t=e.id.toString();if(this.ongoingCreation.has(t))this.log.info(`Skipping creation of a stream due to lock for peerId=${t} multicodec=${this.multicodec}`);else try{this.ongoingCreation.add(t),await this.createStream(e)}catch(n){this.log.error("Failed to createStreamWithLock:",n)}finally{this.ongoingCreation.delete(t)}}handlePeerUpdateStreamPool=e=>{const{peer:t}=e.detail;if(!t.protocols.includes(this.multicodec))return;this.getOpenStreamForCodec(t.id)||this.scheduleNewStream(t)};scheduleNewStream(e){this.log.info(`Scheduling creation of a stream for peerId=${e.id.toString()} multicodec=${this.multicodec}`),this.streamPool.has(e.id.toString())&&this.streamPool.delete(e.id.toString()),this.streamPool.set(e.id.toString(),this.createStreamWithLock(e))}getOpenStreamForCodec(e){const t=ho(this.getConnections(e));if(!t)return;const n=t.streams.find((e=>e.protocol===this.multicodec));if(!n)return;return["done","closed","closing"].includes(n.writeStatus||"")||this.isStreamLocked(n)?void 0:n}lockStream(e,t){this.log.info(`Locking stream for peerId:${e}\tstreamId:${t.id}`),t.metadata[fo]=!0}isStreamLocked(e){return!!e.metadata[fo]}}class go{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 po(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(){return(await this.allPeers()).filter((e=>this.components.connectionManager.getConnections(e.id).length>0))}async getPeers(){let{numPeers:e,maxBootstrapPeers:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{maxBootstrapPeers: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 mo={randomUUID:"undefined"!==typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};let yo;const bo=new Uint8Array(16);function wo(){if(!yo&&(yo="undefined"!==typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!yo))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return yo(bo)}const vo=[];for(let _k=0;_k<256;++_k)vo.push((_k+256).toString(16).slice(1));function Eo(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return vo[e[t+0]]+vo[e[t+1]]+vo[e[t+2]]+vo[e[t+3]]+"-"+vo[e[t+4]]+vo[e[t+5]]+"-"+vo[e[t+6]]+vo[e[t+7]]+"-"+vo[e[t+8]]+vo[e[t+9]]+"-"+vo[e[t+10]]+vo[e[t+11]]+vo[e[t+12]]+vo[e[t+13]]+vo[e[t+14]]+vo[e[t+15]]}const So=function(e,t,n){if(mo.randomUUID&&!t&&!e)return mo.randomUUID();const r=(e=e||{}).random||(e.rng||wo)();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 Eo(r)};class ko{proto;constructor(e){this.proto=e}static decode(e){const t=ln.decode(e);return new ko(t)}encode(){return ln.encode(this.proto)}get wakuMessage(){return this.proto.wakuMessage}get pubsubTopic(){return this.proto.pubsubTopic}}class Ao{proto;constructor(e){this.proto=e}static createSubscribeRequest(e,t){return new Ao({requestId:So(),filterSubscribeType:sn.FilterSubscribeType.SUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeRequest(e,t){return new Ao({requestId:So(),filterSubscribeType:sn.FilterSubscribeType.UNSUBSCRIBE,pubsubTopic:e,contentTopics:t})}static createUnsubscribeAllRequest(e){return new Ao({requestId:So(),filterSubscribeType:sn.FilterSubscribeType.UNSUBSCRIBE_ALL,pubsubTopic:e,contentTopics:[]})}static createSubscriberPingRequest(){return new Ao({requestId:So(),filterSubscribeType:sn.FilterSubscribeType.SUBSCRIBER_PING,pubsubTopic:"",contentTopics:[]})}static decode(e){const t=sn.decode(e);return new Ao(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 _o{proto;constructor(e){this.proto=e}static decode(e){const t=an.decode(e);return new _o(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 Io=new Cr("filter:v2"),xo="/vac/waku/filter-subscribe/2.0.0-beta1",Co="/vac/waku/filter-push/2.0.0-beta1";class Ro extends go{handleIncomingMessage;pubsubTopics;constructor(e,t,n){super(xo,n.components,Io,t),this.handleIncomingMessage=e,this.pubsubTopics=t,n.handle(Co,this.onRequest.bind(this),{maxInboundStreams:100}).catch((e=>{Io.error("Failed to register ",Co,e)}))}async subscribe(e,t,n){const r=await this.getStream(t),o=Ao.createSubscribeRequest(e,n);let i;try{i=await io([o.encode()],Vr,r,Jr,(async e=>await Dr(e)))}catch(c){return Io.error("Failed to send subscribe request",c),{success:null,failure:{error:or.GENERIC_FAIL,peerId:t.id}}}const{statusCode:s,requestId:a,statusDesc:l}=_o.decode(i[0].slice());return s<200||s>=300?(Io.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 Io.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=Ao.createUnsubscribeRequest(e,n);try{await io([o.encode()],Vr,r.sink)}catch(i){return Io.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=Ao.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}=_o.decode(o[0].slice());return i<200||i>=300?(Io.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 Io.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=Ao.createSubscriberPingRequest();let r;try{r=await io([n.encode()],Vr,t,Jr,(async e=>await Dr(e)))}catch(a){return Io.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}=_o.decode(r[0].slice());return o<200||o>=300?(Io.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;Io.info(`Received message from ${r.toString()}`);try{io(n,Jr,(async e=>{for await(const n of e){const e=ko.decode(n.slice()),{pubsubTopic:r,wakuMessage:o}=e;if(!o)return void Io.error("Received empty message");if(!r)return void Io.error("Pubsub topic missing from push message");await this.handleIncomingMessage(r,o,t.remotePeer.toString())}})).then((()=>{Io.info("Receiving pipe closed.")}),(async e=>{Io.error(`Error with receiving pipe on peer:${t.remotePeer.toString()} -- stream:${n.id} -- protocol:${n.protocol}: `,e)}))}catch(o){Io.error("Error decoding message",o)}}}class To{proto;constructor(e){this.proto=e}static createRequest(e,t){return new To({requestId:So(),request:{message:e,pubsubTopic:t},response:void 0})}static decode(e){const t=fn.decode(e);return new To(t)}encode(){return fn.encode(this.proto)}get query(){return this.proto.request}get response(){return this.proto.response}}const No=new Cr("light-push"),Po="/vac/waku/lightpush/2.0.0-beta1";class Oo extends go{pubsubTopics;constructor(e,t){super(Po,t.components,No,e),this.pubsubTopics=e}async preparePushMessage(e,t){try{if(!t.payload||0===t.payload.length)return No.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 No.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 No.error("Failed to encode to protoMessage, aborting push"),{query:null,error:or.ENCODE_FAILED};return{query:To.createRequest(n,e.pubsubTopic),error:null}}catch(n){return No.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 No.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 No.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=To.decode(a).response}catch(d){return No.error("Failed to decode push reply",d),{success:null,failure:{error:or.DECODE_FAILED,peerId:n.id}}}if(!l)return No.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 No.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}:(No.error("Remote peer rejected the message: ",l.info),{success:null,failure:{error:or.REMOTE_PEER_REJECTED,peerId:n.id}})}}const Lo={payload:new Uint8Array,contentTopic:"",version:void 0,timestamp:void 0,meta:void 0,rateLimitProof:void 0,ephemeral:void 0};const Do=1e6;class Bo{proto;constructor(e){this.proto=e}static create(e){const t=new Bo({...e,requestId:So(),timeStart:e.timeStart?BigInt(e.timeStart.getTime()*Do):void 0,timeEnd:e.timeEnd?BigInt(e.timeEnd.getTime()*Do):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 Bo(t)}encode(){return yn.encode(this.proto)}}class Uo{proto;constructor(e){this.proto=e}static decode(e){const t=bn.decode(e);return new Uo(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 Mo=new Cr("store"),Fo="/vac/waku/store-query/3.0.0";class $o extends go{pubsubTopics;constructor(e,t){super(Fo,t.components,Mo,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=Bo.create({...e,paginationCursor:r});let s;try{s=await this.getStream(n)}catch(o){Mo.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=Uo.decode(l);if(!c.statusCode||c.statusCode>=300){const e=`Store query failed with status code: ${c.statusCode}, description: ${c.statusDesc}`;throw Mo.error(e),new Error(e)}if(!c.messages||!c.messages.length){Mo.warn("Stopping pagination due to empty messages in response");break}Mo.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,{...Lo,...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}}}const Ho=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 qo extends EventTarget{#e=(()=>new Map)();constructor(){super(),Ho(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 jo(e,t))}}const jo=globalThis.CustomEvent,Vo=new Cr("keep-alive");class zo{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),Vo.info(`Ping succeeded (${r})`,n)}catch(o){return void Vo.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){Vo.error("Failed to update ping",i)}}catch(i){Vo.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((()=>{Vo.info("Sending Waku Relay ping message"),e.send(i,{payload:new Uint8Array([1])}).catch((e=>Vo.error("Failed to send relay ping",e)))}),1e3*t);r.push(s)}return r}}const Ko=new Cr("connection-manager");class Wo extends qo{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=Wo.instances.get(e);return s||(s=new Wo(t,n,r,o,i),Wo.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),Ko.info(`Dropped connection with peer ${e.toString()}`)}catch(t){Ko.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 zo({relay:r,libp2p:e,options:t}),this.startEventListeners().then((()=>Ko.info("Connection Manager is now running"))).catch((e=>Ko.error("Unexpected error while running service",e))),this.dialPeerStorePeers().catch((e=>Ko.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){Ko.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{Ko.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?Ko.error(`Error dialing peer ${e.toString()} - ${n.errors}`):Ko.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?Ko.warn("Errors array is empty for AggregateError"):n=JSON.stringify(t.errors[0]):Ko.warn("No errors array found for AggregateError"):n=t.message,Ko.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;Ko.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=>{Ko.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){Ko.error(`Error dialing peer ${t.toString()} : ${n}`)}})()},"peer:connect":e=>{(async()=>{Ko.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 jo(sr.PEER_CONNECT_BOOTSTRAP,{detail:t}))}else this.dispatchEvent(new jo(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 Ko.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 Ko.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 Ko.warn(`Peer ${e.toString()} is not dialable based on bootstrap status. Not dialing.`),!1;return!this.dialAttemptsForPeer.has(e.toString())||(Ko.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 jo(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 Ko.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){Ko.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){Ko.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 jo(ar.CONNECTION_STATUS,{detail:this.isConnected()}))}}class Go{static instance;health;constructor(){this.health={overallStatus:ur.Unhealthy,protocolStatuses:new Map}}static getInstance(){return Go.instance||(Go.instance=new Go),Go.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 Yo=()=>Go.getInstance(),Qo=new Cr("metadata"),Jo="/vac/waku/metadata/1.0.0";class Xo extends go{pubsubTopics;libp2pComponents;handshakesConfirmed=(()=>new Map)();constructor(e,t){super(Jo,t.components,Qo,e),this.pubsubTopics=e,this.libp2pComponents=t,t.registrar.handle(Jo,(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 Qo.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){Qo.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}:(Qo.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 Zo(e){return t=>new Xo(e,t)}const ei=Symbol.for("@libp2p/peer-id");function ti(e){return null!=e&&Boolean(e[ei])}const ni=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 ri(e){return Boolean(function(e){if(!(e.length>15))return ni.new(e).parseWith((()=>ni.readIPv4Addr()))}(e))}function oi(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>45))return ni.new(e).parseWith((()=>ni.readIPv6Addr()))}(e))}function ii(e){return Boolean(function(e){if(e.includes("%")&&(e=e.split("%")[0]),!(e.length>45))return ni.new(e).parseWith((()=>ni.readIPAddr()))}(e))}const si=ri,ai=oi,li=function(e){let t=0;if(e=e.toString().trim(),si(e)){const n=new Uint8Array(t+4);return e.split(/\./g).forEach((e=>{n[t++]=255&parseInt(e,10)})),n}if(ai(e)){const n=e.split(":",8);let r;for(r=0;r<n.length;r++){let e;si(n[r])&&(e=li(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")},ci=-1,ui={},di={};function hi(e){if("number"===typeof e){if(null!=di[e])return di[e];throw new Error(`no protocol with code: ${e}`)}if("string"===typeof e){if(null!=ui[e])return ui[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,ci,"ip6zone"],[43,8,"ipcidr"],[53,ci,"dns",!0],[54,ci,"dns4",!0],[55,ci,"dns6",!0],[56,ci,"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,ci,"unix",!1,!0],[421,ci,"ipfs"],[421,ci,"p2p"],[443,0,"https"],[444,96,"onion"],[445,296,"onion3"],[446,ci,"garlic64"],[448,0,"tls"],[449,ci,"sni"],[460,0,"quic"],[461,0,"quic-v1"],[465,0,"webtransport"],[466,ci,"certhash"],[477,0,"ws"],[478,0,"wss"],[479,0,"p2p-websocket-star"],[480,0,"http"],[481,ci,"http-path"],[777,ci,"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);di[t.code]=t,ui[t.name]=t}));hi("ip4"),hi("ip6"),hi("ipcidr");function fi(e,t){switch(hi(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(!ii(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 Ei(t);case 6:case 273:case 33:case 132:return wi(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 Si(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(Ei(t));default:return dr(t,"base16")}}function pi(e,t){switch(hi(e).code){case 4:case 41:return yi(t);case 42:case 53:case 54:case 55:case 56:case 400:case 449:case 777:return vi(t);case 6:case 273:case 33:case 132:return bi(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=bi(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=bi(r);return Br([n,o],n.length+o.length)}(t);case 466:return function(e){const t=mi.decode(e),n=Uint8Array.from(L(t.length));return Br([n,t],n.length+t.length)}(t);case 481:return vi(globalThis.decodeURIComponent(t));default:return Dt(t,"base16")}}const gi=Object.values(Tt).map((e=>e.decoder)),mi=function(){let e=gi[0].or(gi[1]);return gi.slice(2).forEach((t=>e=e.or(t))),e}();function yi(e){if(!ii(e))throw new Error("invalid ip address");return li(e)}function bi(e){const t=new ArrayBuffer(2);return new DataView(t).setUint16(0,e),new Uint8Array(t)}function wi(e){return new DataView(e.buffer).getUint16(e.byteOffset)}function vi(e){const t=Dt(e),n=Uint8Array.from(L(t.length));return Br([n,t],n.length+t.length)}function Ei(e){const t=D(e);if((e=e.slice(N(t))).length!==t)throw new Error("inconsistent lengths");return dr(e)}function Si(e){const t=e.slice(0,e.length-2),n=e.slice(e.length-2);return`${dr(t,"base32")}:${wi(n)}`}function ki(e){const t=[],n=[];let r=null,o=0;for(;o<e.length;){const i=D(e,o),s=N(i),a=hi(i),l=Ii(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 Ci("Invalid address Uint8Array: "+dr(e,"base16"));t.push([i,c]);const u=fi(i,c);if(n.push([i,u]),!0===a.path){r=u;break}}return{bytes:Uint8Array.from(e),string:Ai(n),tuples:t,stringTuples:n,path:r}}function Ai(e){const t=[];return e.map((e=>{const n=hi(e[0]);return t.push(n.name),e.length>1&&null!=e[1]&&t.push(e[1]),null})),xi(t.join("/"))}function _i(e){return Br(e.map((e=>{const t=hi(e[0]);let n=Uint8Array.from(L(t.code));return e.length>1&&null!=e[1]&&(n=Br([n,e[1]])),n})))}function Ii(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 xi(e){return"/"+e.trim().split("/").filter((e=>e)).join("/")}function Ci(e){return new Error("Error parsing address: "+e)}const Ri=Symbol.for("nodejs.util.inspect.custom"),Ti=Symbol.for("@multiformats/js-multiaddr/multiaddr"),Ni=[hi("dns").code,hi("dns4").code,hi("dns6").code,hi("dnsaddr").code];class Pi extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"No available resolver"),this.name="NoAvailableResolverError"}}class Oi{bytes;#t;#n;#r;#o;[Ti]=!0;constructor(e){let t;if(null==e&&(e=""),e instanceof Uint8Array)t=ki(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=xi(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=hi(o[i]);if(0===s.size){t.push([s.code]),n.push([s.code]);continue}if(i++,i>=o.length)throw Ci("invalid address: "+e);if(!0===s.path){r=xi(o.slice(i).join("/")),t.push([s.code,pi(s.code,r)]),n.push([s.code,r]);break}const a=pi(s.code,o[i]);t.push([s.code,a]),n.push([s.code,fi(s.code,a)])}return{string:Ai(n),bytes:_i(t),tuples:t,stringTuples:n,path:r}}(e)}else{if(!Di(e))throw new Error("addr must be a string, Buffer, or another Multiaddr");t=ki(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=hi("tcp"),s=hi("udp"),a=hi("ip4"),l=hi("ip6"),c=hi("dns6"),u=hi("ip6zone");for(const[d,h]of this.stringTuples())d===u.code&&(o=`%${h??""}`),Ni.includes(d)&&(t=i.name,r=443,n=`${h??""}${o}`,e=d===c.code?6:4),d!==i.code&&d!==s.code||(t=hi(d).name,r=parseInt(h??"")),d!==a.code&&d!==l.code||(t=hi(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({},hi(t))}))}protoCodes(){return this.#n.map((e=>{let[t]=e;return t}))}protoNames(){return this.#n.map((e=>{let[t]=e;return hi(t).name}))}tuples(){return this.#n}stringTuples(){return this.#r}encapsulate(e){return e=new Oi(e),new Oi(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 Oi(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 Oi(_i(t.slice(0,n)));return this}getPeerId(){try{let e=[];this.stringTuples().forEach((t=>{let[n,r]=t;n===ui.p2p.code&&e.push([n,r]),n===ui["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=Li.get(t.name);if(null==n)throw new Pi(`no available resolver for ${t.name}`);return(await n(this,e)).map((e=>Bi(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))}[Ri](){return`Multiaddr(${this.#t})`}}const Li=new Map;function Di(e){return Boolean(e?.[Ti])}function Bi(e){return new Oi(e)}new Error("timeout while waiting for mutex to become available"),new Error("mutex already locked");const Ui=new Error("request for lock canceled");var Mi=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 Fi{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ui;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=$i(this._queue,(e=>t<=e.priority));-1===i&&e<=this._value?this._dispatchItem(o):this._queue.splice(i+1,0,o)}))}runExclusive(e){return Mi(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=$i(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 $i(e,t){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return n;return-1}var Hi=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 qi{constructor(e){this._semaphore=new Fi(1,e)}acquire(){return Hi(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 ji{connectionManager;core;log;peers=(()=>new Map)();healthManager;readMutex=(()=>new qi)();writeMutex=(()=>new qi)();writeLockHolder=null;constructor(e,t,n){this.connectionManager=e,this.core=t,this.log=n,this.healthManager=Yo(),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 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 Vi{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 ji(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}`);const t=await this.peerManager.findPeers(1);if(0!==t.length)return await this.peerManager.removePeer(e),await this.peerManager.addPeer(t[0]),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.info("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;this.log.info(`Checking for peers. forceUseAllPeers: ${t}, maxAttempts: ${n}`);for(let r=0;r<n;r++){if(this.log.info(`Attempt ${r+1}/${n} to reach required number of peers`),await this.maintainPeers(),!t&&this.connectedPeers.length>0)return this.log.info(`At least one peer connected (${this.connectedPeers.length}), not forcing use of all peers`),!0;if(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.info("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.info(`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 zi=1e4,Ki={keepAlive:zi};function Wi(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 Gi=new Cr("sdk:receiver:reliability_monitor");class Yi{pubsubTopic;getPeers;renewPeer;getContentTopics;protocolSubscribe;addLibp2pEventListener;receivedMessagesHashes;missedMessagesByPeer=(()=>new Map)();maxMissedMessagesThreshold=3;peerFailures=(()=>new Map)();maxPingFailures=3;peerRenewalLocks=(()=>new Set)();constructor(e,t,n,r,o,i){this.pubsubTopic=e,this.getPeers=t,this.renewPeer=n,this.getContentTopics=r,this.protocolSubscribe=o,this.addLibp2pEventListener=i;const s=this.getPeers().map((e=>e.id.toString()));this.receivedMessagesHashes={all:new Set,nodes:{...Object.fromEntries(s.map((e=>[e,new Set])))}},s.forEach((e=>this.missedMessagesByPeer.set(e,0))),this.addLibp2pEventListener("peer:disconnect",(e=>{const t=e.detail;this.getPeers().some((e=>e.id.equals(t)))&&this.renewAndSubscribePeer(t)}))}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){Gi.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=Wi(e,t);return pr(n)}(t,e),o=this.receivedMessagesHashes.all.has(r);if(this.receivedMessagesHashes.all.add(r),n){this.receivedMessagesHashes.nodes[n]||(Gi.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))){Gi.info(`Peer ${n} has missed too many messages, renewing.`);const t=this.getPeers().find((e=>e.id.toString()===n))?.id;if(!t){Gi.error(`Unexpected Error: Peer ${n} not found in connected peers.`);continue}try{await this.renewAndSubscribePeer(t)}catch(e){Gi.error(`Failed to renew peer ${n}: ${e}`)}}}async renewAndSubscribePeer(e){const t=e.toString();try{if(this.peerRenewalLocks.has(t))return void Gi.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 Gi.warn(`Failed to renew peer ${t}: No new peer found.`)}catch(n){return void Gi.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 Qi=new Cr("sdk:sender:reliability_monitor");class Ji{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?(Qi.info(`Successfully sent message after retry to ${n}`),this.attempts.delete(n)):(Qi.error(`Failed to send message after retry to ${n}: ${r.failure}`),await this.attemptRetriesOrRenew(e,t))}catch(o){Qi.error(`Failed to send message after retry to ${n}: ${o}`),await this.attemptRetriesOrRenew(e,t)}else try{const r=await this.renewPeer(e);r?(Qi.info(`Renewed peer ${e.toString()} to ${r.id.toString()}`),this.attempts.delete(n),this.attempts.set(r.id.toString(),0),await t()):Qi.error(`Failed to renew peer ${e.toString()}: New peer is undefined`)}catch(o){Qi.error(`Failed to renew peer ${e.toString()}: ${o}`)}}}class Xi{static receiverMonitors=(()=>new Map)();static senderMonitor;static createReceiverMonitor(e,t,n,r,o,i){if(Xi.receiverMonitors.has(e))return Xi.receiverMonitors.get(e);const s=new Yi(e,t,n,r,o,i);return Xi.receiverMonitors.set(e,s),s}static createSenderMonitor(e){return Xi.senderMonitor||(Xi.senderMonitor=new Ji(e)),Xi.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 Zi=new Cr("sdk:filter:subscription_manager");class es{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=Xi.createReceiverMonitor(this.pubsubTopic,this.getPeers.bind(this),this.renewPeer.bind(this),(()=>Array.from(this.subscriptionCallbacks.keys())),this.protocol.subscribe.bind(this.protocol),this.protocol.addLibp2pEventListener.bind(this.protocol))}async subscribe(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ki;this.reliabilityMonitor.setMaxMissedMessagesThreshold(n.maxMissedMessagesThreshold),this.reliabilityMonitor.setMaxPingFailures(n.pingsBeforePeerRenewed),this.keepAliveTimer=n.keepAlive||zi;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){Zi.info("Sending keep-alive ping");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 Zi.info("Message already received, skipping");const{contentTopic:n}=e,r=this.subscriptionCallbacks.get(n);r?(Zi.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 Zi.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){Zi.error("Error decoding message",s)}}(r,this.pubsubTopic,e)):Zi.error("No subscription callback available for ",n)}handleResult(e,t){const n={failures:[],successes:[]};for(const r of e)if("rejected"===r.status)Zi.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){Zi.info("Starting subscriptions maintenance"),this.startKeepAlivePings(e),this.startConnectionListener()}stopSubscriptionsMaintenance(){Zi.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){Zi.error(`networkStateListener failed to recover: ${n}`)}this.startKeepAlivePings(this.keepAliveTimer||zi)}else this.stopKeepAlivePings()}startKeepAlivePings(e){this.keepAliveTimer?Zi.info("Recurring pings already set up."):this.keepAliveTimer=setInterval((()=>{this.ping().then((()=>Zi.info("Keep-alive ping successful"))).catch((e=>Zi.error("Error in keep-alive ping cycle:",e)))}),e)}stopKeepAlivePings(){this.keepAliveTimer?(Zi.info("Stopping recurring pings."),clearInterval(this.keepAliveTimer),this.keepAliveTimer=null):Zi.info("Already stopped recurring pings.")}}const ts=new Cr("sdk:filter");class ns extends Vi{protocol;activeSubscriptions=(()=>new Map)();constructor(e,t,n){super(new Ro((async(e,t,n)=>{const r=this.getActiveSubscription(e);r?await r.processIncomingMessage(t,n):ts.error(`No subscription locally registered for topic ${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]:Ki;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};ts.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 es(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]:Ki;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 rs=new Cr("sdk:light-push");class os extends Vi{libp2p;protocol;reliabilityMonitor;constructor(e,t,n){super(new Oo(e.configuredPubsubTopics,t),e,{numPeersToUse:n?.numPeersToUse}),this.libp2p=t,this.reliabilityMonitor=Xi.createSenderMonitor(this.renewPeer.bind(this)),this.protocol=this.core}async send(e,t,n){const r=[],o=[],{pubsubTopic:i}=e;try{vr(i,this.protocol.pubsubTopics)}catch(l){return rs.error("Failed to send waku light push: pubsub topic not configured"),{successes:r,failures:[{error:or.TOPIC_NOT_CONFIGURED}]}}const s=await this.getConnectedPeers();if(0===s.length)return{successes:r,failures:[{error:or.NO_PEER_AVAILABLE}]};const a=await Promise.allSettled(s.map((n=>this.protocol.send(e,t,n))));for(const c of a){if("fulfilled"!==c.status){rs.error("Failed unexpectedly while sending:",c.reason),o.push({error:or.GENERIC_FAIL});continue}const{failure:n,success:i}=c.value;if(i)r.push(i);else if(n){o.push(n);const r=this.connectedPeers.find((e=>e.id.equals(n.peerId)));r&&this.reliabilityMonitor.attemptRetriesOrRenew(r.id,(()=>this.protocol.send(e,t,r)))}}return Yo().updateProtocolHealth(this.protocol.multicodec,r.length),{successes:r,failures:o}}async getConnectedPeers(){const e=this.libp2p.getPeers();if(0===e.length)return[];return(await Promise.all(e.map((async e=>{try{return await this.libp2p.peerStore.get(e)}catch(t){return null}})))).filter((e=>!!e)).filter((e=>e.protocols.includes(Po))).slice(0,this.numPeersToUse)}}const is=new Cr("waku:store:sdk");class ss extends Vi{protocol;constructor(e,t){super(new $o(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 is.error("No peers available to query"),new Error("No peers available to query");is.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){is.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){is.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 Wi(e.pubsubTopic,e)}validateDecodersAndPubsubTopic(e){if(0===e.length)throw is.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 is.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 is.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 is.error(`No decoders found for topic ${n}`),new Error("No decoders found for topic "+n);return{pubsubTopic:n,contentTopics:o,decodersAsMap:r}}}const as=new Cr("wait-for-remote-peer");async function ls(e,t,n){t=t?.length?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);const r=e.libp2p.getConnections();if(!e.isStarted())throw Error("Waku node is not started");if(r.length>0&&!t.includes(rr.Relay)){const n=await async function(e,t){const n=e.libp2p.getPeers(),r=e.libp2p.services.metadata,o=function(e){const t=new Map,n={[rr.Filter]:xo,[rr.LightPush]:Po,[rr.Store]:Fo};for(const r of e)n[r]&&t.set(n[r],!1);return t}(t);if(!n.length||!r)return as.info(`Skipping waitForMetadata due to missing connections:${n.length} or metadataService:${!!r}`),!1;for(const s of n)try{const t=await e.libp2p.peerStore.get(s);if(t.protocols.some((e=>o.has(e)))){if(!(await r.confirmOrAttemptHandshake(s)).error){t.protocols.forEach((e=>{o.has(e)&&o.set(e,!0)}));if(Array.from(o.values()).every((e=>e)))return!0}}}catch(i){"ERR_CONNECTION_BEING_CLOSED"===i.code&&as.error("Connection closed. Some peers can be on different shard."),as.error(`Error while iterating through peers: ${i}`);continue}return!1}(e,t);if(n)return}const o=[];if(t.includes(rr.Relay)){if(!e.relay)throw Error("Cannot wait for Relay peer: protocol not mounted");o.push(e.relay.waitForPeers())}if(t.includes(rr.Store)){if(!e.store)throw Error("Cannot wait for Store peer: protocol not mounted");o.push(cs(Fo,e.libp2p))}if(t.includes(rr.LightPush)){if(!e.lightPush)throw Error("Cannot wait for LightPush peer: protocol not mounted");o.push(cs(Po,e.libp2p))}if(t.includes(rr.Filter)){if(!e.filter)throw new Error("Cannot wait for Filter peer: protocol not mounted");o.push(cs(xo,e.libp2p))}n?await async function(e,t,n){await Promise.race([e,us(t,n)])}(Promise.all(o),n,"Timed out waiting for a remote peer."):await Promise.all(o)}async function cs(e,t){as.info(`Waiting for ${e} peer.`),await new Promise((n=>{const r=async o=>{if(o.detail?.protocols?.includes(e)){const e=t.services.metadata;if(!e)return t.removeEventListener("peer:identify",r),void n();try{await e.confirmOrAttemptHandshake(o.detail.peerId),t.removeEventListener("peer:identify",r),n()}catch(i){"ERR_CONNECTION_BEING_CLOSED"===i.code&&as.error("Connection closed. Some peers can be on different shard."),as.error(`Error waiting for metadata: ${i}`)}}};t.addEventListener("peer:identify",r)}))}const us=(e,t)=>new Promise(((n,r)=>setTimeout((()=>r(Error(t))),e)));const ds=new Cr("waku");class hs{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=Wo.create(a,n,{pingKeepAlive:i,relayKeepAlive:s},this.pubsubTopics,this.relay),this.health=Yo(),r.store){const e=(l=this.connectionManager,e=>new ss(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 os(e,n,t)}(this.connectionManager);this.lightPush=e(n)}if(r.filter){const e=function(e,t){return n=>new ns(e,n,t)}(this.connectionManager);this.filter=e(n)}ds.info("Waku node created",a,`relay: ${!!this.relay}, store: ${!!this.store}, light push: ${!!this.lightPush}, filter: ${!!this.filter}`)}get peerId(){return this.libp2p.peerId}get protocols(){return this.libp2p.getProtocols()}async dial(e,t){const n=t??[],r=this.mapToPeerIdOrMultiaddr(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))):ds.error("Relay codec not included in dial codec: protocol not mounted locally")),n.includes(rr.Store)&&(this.store?o.push(this.store.protocol.multicodec):ds.error("Store codec not included in dial codec: protocol not mounted locally")),n.includes(rr.LightPush)&&(this.lightPush?o.push(this.lightPush.protocol.multicodec):ds.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):ds.error("Filter codec not included in dial codec: protocol not mounted locally")),ds.info(`Dialing to ${r.toString()} with protocols ${n}`),this.libp2p.dialProtocol(r,o)}async start(){await this.libp2p.start()}async stop(){Xi.stopAll(),this.connectionManager.stop(),await this.libp2p.stop()}async waitForPeers(e,t){return ls(this,e,t)}isStarted(){return"started"==this.libp2p.status}isConnected(){return this.connectionManager.isConnected()}mapToPeerIdOrMultiaddr(e){return ti(e)?e:Bi(e)}}class fs extends Error{code;type;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"The operation was aborted"),this.name="AbortError",this.code=fs.code,this.type=fs.type}static code="ABORT_ERR";static type="aborted"}class ps extends Error{code;props;constructor(e,t,n){super(e),this.code=t,this.name=n?.name??"CodeError",this.props=n??{}}}class gs 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 ms="ERR_TIMEOUT";function ys(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}const bs=BigInt(2**32-1),ws=BigInt(32);function vs(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{h:Number(e&bs),l:Number(e>>ws&bs)}:{h:0|Number(e>>ws&bs),l:0|Number(e&bs)}}const Es={fromBig:vs,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}=vs(e[o],t);[n[o],r[o]]=[i,s]}return[n,r]},toBig:(e,t)=>BigInt(e>>>0)<<ws|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)},Ss=Es,[ks,As]=(()=>Ss.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)))))(),_s=new Uint32Array(80),Is=new Uint32Array(80);class xs 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)_s[b]=e.getUint32(t),Is[b]=e.getUint32(t+=4);for(let b=16;b<80;b++){const e=0|_s[b-15],t=0|Is[b-15],n=Ss.rotrSH(e,t,1)^Ss.rotrSH(e,t,8)^Ss.shrSH(e,t,7),r=Ss.rotrSL(e,t,1)^Ss.rotrSL(e,t,8)^Ss.shrSL(e,t,7),o=0|_s[b-2],i=0|Is[b-2],s=Ss.rotrSH(o,i,19)^Ss.rotrBH(o,i,61)^Ss.shrSH(o,i,6),a=Ss.rotrSL(o,i,19)^Ss.rotrBL(o,i,61)^Ss.shrSL(o,i,6),l=Ss.add4L(r,a,Is[b-7],Is[b-16]),c=Ss.add4H(l,n,s,_s[b-7],_s[b-16]);_s[b]=0|c,Is[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=Ss.rotrSH(u,d,14)^Ss.rotrSH(u,d,18)^Ss.rotrBH(u,d,41),t=Ss.rotrSL(u,d,14)^Ss.rotrSL(u,d,18)^Ss.rotrBL(u,d,41),w=u&h^~u&p,v=d&f^~d&g,E=Ss.add5L(y,t,v,As[b],Is[b]),S=Ss.add5H(E,m,e,w,ks[b],_s[b]),k=0|E,A=Ss.rotrSH(n,r,28)^Ss.rotrBH(n,r,34)^Ss.rotrBH(n,r,39),_=Ss.rotrSL(n,r,28)^Ss.rotrBL(n,r,34)^Ss.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}=Ss.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=Ss.add3L(k,_,x);n=Ss.add3H(C,S,A,I),r=0|C}({h:n,l:r}=Ss.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:o,l:i}=Ss.add(0|this.Bh,0|this.Bl,0|o,0|i)),({h:s,l:a}=Ss.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:l,l:c}=Ss.add(0|this.Dh,0|this.Dl,0|l,0|c)),({h:u,l:d}=Ss.add(0|this.Eh,0|this.El,0|u,0|d)),({h:h,l:f}=Ss.add(0|this.Fh,0|this.Fl,0|h,0|f)),({h:p,l:g}=Ss.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=Ss.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(){_s.fill(0),Is.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 Cs=Gn((()=>new xs)),Rs=BigInt(0),Ts=BigInt(1),Ns=BigInt(2);function Ps(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}function Os(e){if(!Ps(e))throw new Error("Uint8Array expected")}function Ls(e,t){if("boolean"!==typeof t)throw new Error(`${e} must be valid boolean, got "${t}".`)}const Ds=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Bs(e){Os(e);let t="";for(let n=0;n<e.length;n++)t+=Ds[e[n]];return t}function Us(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function Ms(e){if("string"!==typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const Fs={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function $s(e){return e>=Fs._0&&e<=Fs._9?e-Fs._0:e>=Fs._A&&e<=Fs._F?e-(Fs._A-10):e>=Fs._a&&e<=Fs._f?e-(Fs._a-10):void 0}function Hs(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=$s(e.charCodeAt(i)),n=$s(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 qs(e){return Ms(Bs(e))}function js(e){return Os(e),Ms(Bs(Uint8Array.from(e).reverse()))}function Vs(e,t){return Hs(e.toString(16).padStart(2*t,"0"))}function zs(e,t){return Vs(e,t).reverse()}function Ks(e,t,n){let r;if("string"===typeof t)try{r=Hs(t)}catch(i){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${i}`)}else{if(!Ps(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 Ws(){let e=0;for(let n=0;n<arguments.length;n++){const t=n<0||arguments.length<=n?void 0:arguments[n];Os(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 Gs=e=>"bigint"===typeof e&&Rs<=e;function Ys(e,t,n){return Gs(e)&&Gs(t)&&Gs(n)&&t<=e&&e<n}function Qs(e,t,n,r){if(!Ys(t,n,r))throw new Error(`expected valid ${e}: ${n} <= n < ${r}, got ${typeof t} ${t}`)}function Js(e){let t;for(t=0;e>Rs;e>>=Ts,t+=1);return t}const Xs=e=>(Ns<<BigInt(e-1))-Ts,Zs=e=>new Uint8Array(e),ea=e=>Uint8Array.from(e);function ta(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=Zs(e),o=Zs(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]:Zs();o=a(ea([0]),e),r=a(),0!==e.length&&(o=a(ea([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 Ws(...n)};return(e,t)=>{let n;for(s(),l(e);!(n=t(c()));)l();return s(),n}}const na={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||Ps(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 ra(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const r=(t,n,r)=>{const o=na[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 oa(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 ia=BigInt(0),sa=BigInt(1),aa=BigInt(2),la=BigInt(3),ca=BigInt(4),ua=BigInt(5),da=BigInt(8);BigInt(9),BigInt(16);function ha(e,t){const n=e%t;return n>=ia?n:t+n}function fa(e,t,n){if(n<=ia||t<ia)throw new Error("Expected power/modulo > 0");if(n===sa)return ia;let r=sa;for(;t>ia;)t&sa&&(r=r*e%n),e=e*e%n,t>>=sa;return r}function pa(e,t,n){let r=e;for(;t-- >ia;)r*=r,r%=n;return r}function ga(e,t){if(e===ia||t<=ia)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=ha(e,t),r=t,o=ia,i=sa,s=sa,a=ia;for(;n!==ia;){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!==sa)throw new Error("invert: does not exist");return ha(o,t)}function ma(e){if(e%ca===la){const t=(e+sa)/ca;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%da===ua){const t=(e-ua)/da;return function(e,n){const r=e.mul(n,aa),o=e.pow(r,t),i=e.mul(n,o),s=e.mul(e.mul(i,aa),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-sa)/aa;let n,r,o;for(n=e-sa,r=0;n%aa===ia;n/=aa,r++);for(o=aa;o<e&&fa(o,t,e)!==e-sa;o++);if(1===r){const t=(e+sa)/ca;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+sa)/aa;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,sa<<BigInt(a-t-1));l=e.sqr(n),c=e.mul(c,n),u=e.mul(u,l),a=t}return c}}(e)}const ya=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ba(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function wa(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<=ia)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:o,nByteLength:i}=ba(e,t);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=ma(e),a=Object.freeze({ORDER:e,BITS:o,BYTES:i,MASK:Xs(o),ZERO:ia,ONE:sa,create:t=>ha(t,e),isValid:t=>{if("bigint"!==typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return ia<=t&&t<e},is0:e=>e===ia,isOdd:e=>(e&sa)===sa,neg:t=>ha(-t,e),eql:(e,t)=>e===t,sqr:t=>ha(t*t,e),add:(t,n)=>ha(t+n,e),sub:(t,n)=>ha(t-n,e),mul:(t,n)=>ha(t*n,e),pow:(e,t)=>function(e,t,n){if(n<ia)throw new Error("Expected power > 0");if(n===ia)return e.ONE;if(n===sa)return t;let r=e.ONE,o=t;for(;n>ia;)n&sa&&(r=e.mul(r,o)),o=e.sqr(o),n>>=sa;return r}(a,e,t),div:(t,n)=>ha(t*ga(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ga(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?zs(e,i):Vs(e,i),fromBytes:e=>{if(e.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${e.length}`);return n?js(e):qs(e)}});return Object.freeze(a)}function va(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 Ea(e){const t=va(e);return t+Math.ceil(t/2)}const Sa=BigInt(0),ka=BigInt(1),Aa=new WeakMap,_a=new WeakMap;function Ia(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>Sa;)n&ka&&(r=r.add(o)),o=o.double(),n>>=ka;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+=ka);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=_a.get(e)||1;let o=Aa.get(e);return o||(o=this.precomputeWindow(e,r),1!==r&&Aa.set(e,n(o))),this.wNAF(r,o,t)},setWindowSize(e,t){r(t),_a.set(e,t),Aa.delete(e)}}}function xa(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=Js(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 Ca(e){return function(e){const t=ya.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});ra(e,t)}(e.Fp),ra(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ba(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const Ra=BigInt(0),Ta=BigInt(1),Na=BigInt(2),Pa=BigInt(8),Oa={zip215:!0};function La(e){const t=function(e){const t=Ca(e);return ra(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=Na<<BigInt(8*a)-Ta,u=n.create,d=wa(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:Ra}}}),f=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,n)=>{if(Ls("phflag",n),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){Qs("coordinate "+e,t,Ra,c)}function m(e){if(!(e instanceof w))throw new Error("ExtendedPoint expected")}const y=oa(((e,t)=>{const{ex:r,ey:o,ez:i}=e,s=e.is0();null==t&&(t=s?Pa:n.inv(i));const a=u(r*t),l=u(o*t),c=u(i*t);if(s)return{x:Ra,y:Ta};if(c!==Ta)throw new Error("invZ was invalid");return{x:a,y:l}})),b=oa((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,Ta,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 xa(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(Na*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===Ra)return this.double();const r=u(s*Na*h),f=u(a*Na*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;Qs("scalar",t,Ta,r);const{p:n,f:o}=this.wNAF(t);return w.normalizeZ([n,o])[0]}multiplyUnsafe(e){const t=e;return Qs("scalar",t,Ra,r),t===Ra?E:this.equals(E)||t===Ta?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===Ta?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=Ks("pointHex",e,s),Ls("zip215",r);const a=e.slice(),l=e[s-1];a[s-1]=-129&l;const d=js(a),f=r?c:n.ORDER;Qs("pointHex.y",d,Ra,f);const p=u(d*d),g=u(p-Ta),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&Ta)===Ta,E=0!==(128&l);if(!r&&b===Ra&&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=zs(t,n.BYTES);return r[r.length-1]|=e&Ta?128:0,r}toHex(){return Bs(this.toRawBytes())}}w.BASE=new w(t.Gx,t.Gy,Ta,u(t.Gx*t.Gy)),w.ZERO=new w(Ra,Ta,Ta,Ra);const{BASE:v,ZERO:E}=w,S=Ia(w,8*a);function k(e){return ha(e,r)}function A(e){return k(js(e))}function _(e){const t=a;e=Ks("private key",e,t);const n=Ks("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=Ws(...n);return A(i(p(s,Ks("context",e),!!o)))}const x=Oa;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=Ks("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 Qs("signature.s",h,Ra,r),Ks("result",Ws(d,zs(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=Ks("signature",e,2*l),t=Ks("message",t),void 0!==a&&Ls("zip215",a),o&&(t=o(t));const c=js(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 Da=BigInt(0),Ba=BigInt(1);function Ua(e){const t=(ra(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=>ha(e,r),i=t.montgomeryBits,s=Math.ceil(i/8),a=t.nByteLength,l=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>fa(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 zs(o(e),s)}function f(e,t){const n=function(e){const t=Ks("u coordinate",e,s);return 32===a&&(t[31]&=127),js(t)}(t),f=function(e){const t=Ks("scalar",e),n=t.length;if(n!==s&&n!==a)throw new Error(`Expected ${s} or ${a} bytes, got ${n}`);return js(l(t))}(e),p=function(e,t){Qs("u",e,Da,r),Qs("scalar",t,Da,r);const n=t,s=e;let a,l=Ba,h=Da,f=e,p=Ba,g=Da;for(let r=BigInt(i-1);r>=Da;r--){const e=n>>r&Ba;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===Da)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 Ma=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Fa=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),$a=(BigInt(0),BigInt(1)),Ha=BigInt(2),qa=BigInt(3),ja=BigInt(5),Va=BigInt(8);function za(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),i=Ma,s=e*e%i*e%i,a=pa(s,Ha,i)*s%i,l=pa(a,$a,i)*e%i,c=pa(l,ja,i)*l%i,u=pa(c,t,i)*c%i,d=pa(u,n,i)*u%i,h=pa(d,r,i)*d%i,f=pa(h,o,i)*h%i,p=pa(f,o,i)*h%i,g=pa(p,t,i)*c%i;return{pow_p_5_8:pa(g,Ha,i)*e%i,b2:s}}function Ka(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function Wa(e,t){const n=Ma,r=ha(t*t*t,n),o=ha(r*r*t,n);let i=ha(e*r*za(e*o).pow_p_5_8,n);const s=ha(t*i*i,n),a=i,l=ha(i*Fa,n),c=s===e,u=s===ha(-e,n),d=s===ha(-e*Fa,n);return c&&(i=a),(u||d)&&(i=l),((e,t)=>(ha(e,t)&sa)===sa)(i,n)&&(i=ha(-i,n)),{isValid:c||u,value:i}}const Ga=(()=>wa(Ma,void 0,!0))(),Ya=(()=>({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Ga,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Va,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Cs,randomBytes:Yn,adjustScalarBytes:Ka,uvRatio:Wa}))(),Qa=(()=>La(Ya))();const Ja=(()=>Ua({P:Ma,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Ma,{pow_p_5_8:n,b2:r}=za(e);return ha(pa(n,qa,t)*r,t)},adjustScalarBytes:Ka,randomBytes:Yn}))();const Xa=32,Za=64,el=32;function tl(e,t){const n=new Uint8Array(Za);for(let r=0;r<el;r++)n[r]=e[r],n[el+r]=t[r];return n}const nl={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}},rl={alg:"A128GCM",ext:!0,k:"scm9jmO_4BJAgdwWGVulLg",key_ops:["encrypt","decrypt"],kty:"oct"};async function ol(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=nl.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",rl,{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",rl,{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",rl,{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 il,sl,al,ll;!function(e){e.RSA="RSA",e.Ed25519="Ed25519",e.Secp256k1="Secp256k1"}(il||(il={})),function(e){e[e.RSA=0]="RSA",e[e.Ed25519=1]="Ed25519",e[e.Secp256k1=2]="Secp256k1"}(sl||(sl={})),function(e){e.codec=()=>Cn(sl)}(il||(il={})),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),il.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=il.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())}(al||(al={})),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),il.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=il.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())}(ll||(ll={}));class cl{_key;constructor(e){this._key=gl(e,Xa)}verify(e,t){return function(e,t,n){return Qa.verify(t,n instanceof Uint8Array?n:n.subarray(),e)}(this._key,t,e)}marshal(){return this._key}get bytes(){return al.encode({Type:il.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return ys(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class ul{_key;_publicKey;constructor(e,t){this._key=gl(e,Za),this._publicKey=gl(t,Xa)}sign(e){return function(e,t){const n=e.subarray(0,el);return Qa.sign(t instanceof Uint8Array?t:t.subarray(),n)}(this._key,e)}get public(){return new cl(this._publicKey)}marshal(){return this._key}get bytes(){return ll.encode({Type:il.Ed25519,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}async hash(){const e=vt.digest(this.bytes);let t;return ys(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 ol(this.bytes,e);throw new ps(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function dl(e){if(e.length>Za){const t=(e=gl(e,Za+Xa)).subarray(0,Za),n=e.subarray(Za,e.length);return new ul(t,n)}const t=(e=gl(e,Za)).subarray(0,Za),n=e.subarray(Xa);return new ul(t,n)}function hl(e){return e=gl(e,Xa),new cl(e)}async function fl(){const{privateKey:e,publicKey:t}=function(){const e=Qa.utils.randomPrivateKey(),t=Qa.getPublicKey(e);return{privateKey:tl(e,t),publicKey:t}}();return new ul(e,t)}async function pl(e){const{privateKey:t,publicKey:n}=function(e){if(e.length!==el)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=Qa.getPublicKey(t);return{privateKey:tl(t,n),publicKey:n}}(e);return new ul(t,n)}function gl(e,t){if((e=Uint8Array.from(e??[])).length!==t)throw new ps(`Key must be a Uint8Array of length ${t}, got ${e.length}`,"ERR_INVALID_KEY_TYPE");return e}async function ml(e){const t=[await nl.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!0,["sign"]),await bl(e)],n=await yl({privateKey:t[0],publicKey:t[1]});return{privateKey:n[0],publicKey:n[1]}}async function yl(e){if(null==e.privateKey||null==e.publicKey)throw new ps("Private and public key are required","ERR_INVALID_PARAMETERS");return Promise.all([nl.get().subtle.exportKey("jwk",e.privateKey),nl.get().subtle.exportKey("jwk",e.publicKey)])}async function bl(e){return nl.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 wl(e){if("RSA"!==e.kty)throw new ps("invalid key type","ERR_INVALID_KEY_TYPE");if(null==e.n)throw new ps("invalid key modulus","ERR_INVALID_KEY_MODULUS");return 8*Dt(e.n,"base64url").length}class vl 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 El=(e,t,n)=>new vl(e,t).update(n).digest();function Sl(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=El.create(e,l),h=d._cloneInto().update(c);return{c:i,dkLen:s,asyncTick:a,DK:u,PRF:d,PRFSalt:h}}function kl(e,t,n,r,o){return e.destroy(),t.destroy(),r&&r.destroy(),o.fill(0),n}El.create=(e,t)=>new vl(e,t);var Al=__webpack_require__(8275);function _l(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 Il(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 xl(){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 Cl(){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=_l(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 _l(i,8)-r}function Rl(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 Tl(){if("undefined"===typeof BigInt)throw new Error("BigInt is not defined. Your environment doesn't implement BigInt.")}function Nl(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 Pl(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 Ol{constructor(){this.items=[]}write(e){this.items.push(e)}final(){return Nl(this.items)}}const Ll=[new Uint8Array([1])],Dl="0123456789",Bl="",Ul=new ArrayBuffer(0),Ml=new Uint8Array(0),Fl="EndOfContent",$l="OCTET STRING",Hl="BIT STRING";function ql(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?Al._H.toUint8Array(t.valueHex):Ml}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(!Pl(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",Ul)}toJSON(){return{...super.toJSON(),isHexOnly:this.isHexOnly,valueHex:Al.U$.ToHex(this.valueHexView)}}},t.NAME="hexBlock",t}class jl{constructor(){let{blockLength:e=0,error:t=Bl,warnings:n=[],valueBeforeDecode:r=Ml}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.blockLength=e,this.error=t,this.warnings=n,this.valueBeforeDecodeView=Al._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:Al.U$.ToHex(this.valueBeforeDecodeView)}}}jl.NAME="baseBlock";class Vl extends jl{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'")}}Vl.NAME="valueBlock";class zl extends(ql(jl)){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?Al._H.toUint8Array(e.valueHex):Ml,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",Ul}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=Il(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=Al._H.toUint8Array(e);if(!Pl(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=_l(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}}}zl.NAME="identificationBlock";class Kl extends jl{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=Al._H.toUint8Array(e);if(!Pl(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=_l(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=Il(this.length,8);if(r.byteLength>127)return this.error="Too big length",Ul;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}}}Kl.NAME="lengthBlock";const Wl={};class Gl extends jl{constructor(){let{name:e=Bl,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 zl(r),this.lenBlock=new Kl(r),this.valueBlock=o?new o(r):new Vl(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 Ol;t||Yl(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?Ul: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():Al.U$.ToHex(this.toBER())}onAsciiEncoding(){return`${this.constructor.NAME} : ${Al.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 Yl(e){if(e instanceof Wl.Constructed)for(const t of e.valueBlock.value)Yl(t)&&(e.lenBlock.isIndefiniteForm=!0);return!!e.lenBlock.isIndefiniteForm}Gl.NAME="BaseBlock";class Ql extends Gl{constructor(){let{value:e=Bl,...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}'`}}Ql.NAME="BaseStringBlock";class Jl extends(ql(Vl)){constructor(){let{isHexOnly:e=!0,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.isHexOnly=e}}var Xl,Zl,ec,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;Jl.NAME="PrimitiveValueBlock";class Nc extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Jl),this.idBlock.isConstructed=!1}}function Pc(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 Gl({},Vl);const i=new jl;if(!Pl(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=Gl;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=Wl.EndOfContent;break;case 1:a=Wl.Boolean;break;case 2:a=Wl.Integer;break;case 3:a=Wl.BitString;break;case 4:a=Wl.OctetString;break;case 5:a=Wl.Null;break;case 6:a=Wl.ObjectIdentifier;break;case 10:a=Wl.Enumerated;break;case 12:a=Wl.Utf8String;break;case 13:a=Wl.RelativeObjectIdentifier;break;case 14:a=Wl.TIME;break;case 15:return o.error="[UNIVERSAL 15] is reserved by ASN.1 standard",{offset:-1,result:o};case 16:a=Wl.Sequence;break;case 17:a=Wl.Set;break;case 18:a=Wl.NumericString;break;case 19:a=Wl.PrintableString;break;case 20:a=Wl.TeletexString;break;case 21:a=Wl.VideotexString;break;case 22:a=Wl.IA5String;break;case 23:a=Wl.UTCTime;break;case 24:a=Wl.GeneralizedTime;break;case 25:a=Wl.GraphicString;break;case 26:a=Wl.VisibleString;break;case 27:a=Wl.GeneralString;break;case 28:a=Wl.UniversalString;break;case 29:a=Wl.CharacterString;break;case 30:a=Wl.BmpString;break;case 31:a=Wl.DATE;break;case 32:a=Wl.TimeOfDay;break;case 33:a=Wl.DateTime;break;case 34:a=Wl.Duration;break;default:{const e=o.idBlock.isConstructed?new Wl.Constructed:new Wl.Primitive;e.idBlock=o.idBlock,e.lenBlock=o.lenBlock,e.warnings=o.warnings,o=e}}}else a=o.idBlock.isConstructed?Wl.Constructed:Wl.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 Oc(e){if(!e.byteLength){const e=new Gl({},Vl);return e.error="Input buffer has zero length",{offset:-1,result:e}}return Pc(Al._H.toUint8Array(e).slice(),0,e.byteLength)}Xl=Nc,Wl.Primitive=Xl,Nc.NAME="PRIMITIVE";class Lc extends Vl{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=Al._H.toUint8Array(e);if(!Pl(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=Pc(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===Fl)break}var i,s;return this.isIndefiniteForm&&(this.value[this.value.length-1].constructor.NAME===Fl?this.value.pop():this.warnings.push("No EndOfContent block encoded")),o}toBER(e,t){const n=t||new Ol;for(let r=0;r<this.value.length;r++)this.value[r].toBER(e,n);return t?Ul:n.final()}toJSON(){const e={...super.toJSON(),isIndefiniteForm:this.isIndefiniteForm,value:[]};for(const t of this.value)e.value.push(t.toJSON());return e}}Lc.NAME="ConstructedValueBlock";class Dc extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Lc),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} :`}}Zl=Dc,Wl.Constructed=Zl,Dc.NAME="CONSTRUCTED";class Bc extends Vl{fromBER(e,t,n){return t}toBER(e){return Ul}}Bc.override="EndOfContentValueBlock";class Uc extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Bc),this.idBlock.tagClass=1,this.idBlock.tagNumber=0}}ec=Uc,Wl.EndOfContent=ec,Uc.NAME=Fl;class Mc extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Vl),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}`}}tc=Mc,Wl.Null=tc,Mc.NAME="NULL";class Fc extends(ql(Vl)){constructor(){let{value:e,...t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),t.valueHex?this.valueHexView=Al._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=Al._H.toUint8Array(e);return Pl(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,Cl.call(this),this.blockLength=n,t+n):-1}toBER(){return this.valueHexView.slice()}toJSON(){return{...super.toJSON(),value:this.value}}}Fc.NAME="BooleanValueBlock";class $c extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Fc),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}`}}nc=$c,Wl.Boolean=nc,$c.NAME="BOOLEAN";class Hc extends(ql(Lc)){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=Lc.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===Fl){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, OCTET STRING may consists of OCTET STRINGs only",-1}if(t!==$l)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?Lc.prototype.toBER.call(this,e,t):e?new ArrayBuffer(this.valueHexView.byteLength):this.valueHexView.slice().buffer}toJSON(){return{...super.toJSON(),isConstructed:this.isConstructed}}}Hc.NAME="OctetStringValueBlock";class qc extends Gl{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},Hc),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=Pc(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?Dc.prototype.onAsciiEncoding.call(this):`${this.constructor.NAME} : ${Al.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 qc&&e.push(t.valueBlock.valueHexView);return Al._H.concat(e)}}rc=qc,Wl.OctetString=rc,qc.NAME=$l;class jc extends(ql(Lc)){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=Lc.prototype.fromBER.call(this,e,t,n),-1===r)return r;for(const e of this.value){const t=e.constructor.NAME;if(t===Fl){if(this.isIndefiniteForm)break;return this.error="EndOfContent is unexpected, BIT STRING may consists of BIT STRINGs only",-1}if(t!==Hl)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=Al._H.toUint8Array(e);if(!Pl(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=Pc(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 Lc.prototype.toBER.call(this,e,t);if(e)return new ArrayBuffer(this.valueHexView.byteLength+1);if(!this.valueHexView.byteLength)return Ul;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}}}jc.NAME="BitStringValueBlock";class Vc extends Gl{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},jc),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 Dc.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 zc(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=xl(new Uint8Array([c%10]),i);else i[s-u]=c%10}return n[0]>0&&(i=xl(n,i)),i}function Kc(e){if(e>=Ll.length)for(let t=Ll.length;t<=e;t++){const e=new Uint8Array([0]);let n=Ll[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=xl(e,n)),Ll.push(n)}return Ll[e]}function Wc(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()}oc=Vc,Wl.BitString=oc,Vc.NAME=Hl;class Gc extends(ql(Vl)){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=Cl.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=Il(n-t,8,r);return new Uint8Array(e)[0]|=128,e}let o=Il(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=Wc(Kc(r),n),i="-";else n=zc(n,Kc(r));r++,t>>=1}}for(let a=0;a<n.length;a++)n[a]&&(s=!0),s&&(i+=Dl.charAt(n[a]));return!1===s&&(i+=Dl.charAt(0)),i}}ic=Gc,Gc.NAME="IntegerValueBlock",Object.defineProperty(ic.prototype,"valueHex",{set:function(e){this.valueHexView=new Uint8Array(e),this.setValueHex()},get:function(){return this.valueHexView.slice().buffer}});class Yc extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Gc),this.idBlock.tagClass=1,this.idBlock.tagNumber=2}toBigInt(){return Tl(),BigInt(this.valueBlock.toString())}static fromBigInt(e){Tl();const t=BigInt(e),n=new Ol,r=t.toString(16).replace(/^-/,""),o=new Uint8Array(Al.U$.FromHex(r));if(t<0){const e=new Uint8Array(o.length+(128&o[0]?1:0));e[0]|=128;const r=BigInt(`0x${Al.U$.ToHex(e)}`)+t,i=Al._H.toUint8Array(Al.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 Yc({valueHex:n.final()})}convertToDER(){const e=new Yc({valueHex:this.valueBlock.valueHexView});return e.valueBlock.toDER(),e}convertFromDER(){return new Yc({valueHex:0===this.valueBlock.valueHexView[0]?this.valueBlock.valueHexView.subarray(1):this.valueBlock.valueHexView})}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()}`}}sc=Yc,Wl.Integer=sc,Yc.NAME="INTEGER";class Qc extends Yc{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=10}}ac=Qc,Wl.Enumerated=ac,Qc.NAME="ENUMERATED";class Jc extends(ql(Vl)){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=Al._H.toUint8Array(e);if(!Pl(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=_l(this.valueHexView,7):(this.isHexOnly=!0,this.warnings.push("Too big SID for decoding, hex only")),t+this.blockLength)}set valueBigInt(e){Tl();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=Il(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",Ul;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=Al.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}}}Jc.NAME="sidBlock";class Xc extends Vl{constructor(){let{value:e=Bl,...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 Jc;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,Ul;t.push(r)}return Nl(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 Jc;if(r>Number.MAX_SAFE_INTEGER){Tl();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}}Xc.NAME="ObjectIdentifierValueBlock";class Zc extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},Xc),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()}}}lc=Zc,Wl.ObjectIdentifier=lc,Zc.NAME="OBJECT IDENTIFIER";class eu extends(ql(jl)){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=Al._H.toUint8Array(e);if(!Pl(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=_l(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=Il(this.valueDec,7);if(0===t.byteLength)return this.error="Error during encoding SID value",Ul;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?Al.U$.ToHex(this.valueHexView):this.valueDec.toString(),e}toJSON(){return{...super.toJSON(),valueDec:this.valueDec}}}eu.NAME="relativeSidBlock";class tu extends Vl{constructor(){let{value:e=Bl,...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;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,Ul;n.push(t)}return Nl(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 eu;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}}tu.NAME="RelativeObjectIdentifierValueBlock";class nu extends Gl{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},tu),this.idBlock.tagClass=1,this.idBlock.tagNumber=13}getValue(){return this.valueBlock.toString()}setValue(e){this.valueBlock.fromString(e)}onAsciiEncoding(){return`${this.constructor.NAME} : ${this.valueBlock.toString()||"empty"}`}toJSON(){return{...super.toJSON(),value:this.getValue()}}}cc=nu,Wl.RelativeObjectIdentifier=cc,nu.NAME="RelativeObjectIdentifier";class ru extends Dc{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=16}}uc=ru,Wl.Sequence=uc,ru.NAME="SEQUENCE";class ou extends Dc{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=17}}dc=ou,Wl.Set=dc,ou.NAME="SET";class iu extends(ql(Vl)){constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.isHexOnly=!0,this.value=Bl}toJSON(){return{...super.toJSON(),value:this.value}}}iu.NAME="StringValueBlock";class su extends iu{}su.NAME="SimpleStringValueBlock";class au extends Ql{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e,su)}fromBuffer(e){this.valueBlock.value=String.fromCharCode.apply(null,Al._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}}au.NAME="SIMPLE STRING";class lu extends au{fromBuffer(e){this.valueBlock.valueHexView=Al._H.toUint8Array(e);try{this.valueBlock.value=Al.U$.ToUtf8String(e)}catch(t){this.warnings.push(`Error during "decodeURIComponent": ${t}, using raw string`),this.valueBlock.value=Al.U$.ToBinary(e)}}fromString(e){this.valueBlock.valueHexView=new Uint8Array(Al.U$.FromUtf8String(e)),this.valueBlock.value=e}}lu.NAME="Utf8StringValueBlock";class cu extends lu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=12}}hc=cu,Wl.Utf8String=hc,cu.NAME="UTF8String";class uu extends au{fromBuffer(e){this.valueBlock.value=Al.U$.ToUtf16String(e),this.valueBlock.valueHexView=Al._H.toUint8Array(e)}fromString(e){this.valueBlock.value=e,this.valueBlock.valueHexView=new Uint8Array(Al.U$.FromUtf16String(e))}}uu.NAME="BmpStringValueBlock";class du extends uu{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=30}}fc=du,Wl.BmpString=fc,du.NAME="BMPString";class hu extends au{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=Il(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}}hu.NAME="UniversalStringValueBlock";class fu extends hu{constructor(){let{...e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(e),this.idBlock.tagClass=1,this.idBlock.tagNumber=28}}pc=fu,Wl.UniversalString=pc,fu.NAME="UniversalString";class pu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=18}}gc=pu,Wl.NumericString=gc,pu.NAME="NumericString";class gu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=19}}mc=gu,Wl.PrintableString=mc,gu.NAME="PrintableString";class mu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=20}}yc=mu,Wl.TeletexString=yc,mu.NAME="TeletexString";class yu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=21}}bc=yu,Wl.VideotexString=bc,yu.NAME="VideotexString";class bu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=22}}wc=bu,Wl.IA5String=wc,bu.NAME="IA5String";class wu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=25}}vc=wu,Wl.GraphicString=vc,wu.NAME="GraphicString";class vu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=26}}Ec=vu,Wl.VisibleString=Ec,vu.NAME="VisibleString";class Eu extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=27}}Sc=Eu,Wl.GeneralString=Sc,Eu.NAME="GeneralString";class Su extends au{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=29}}kc=Su,Wl.CharacterString=kc,Su.NAME="CharacterString";class ku extends vu{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,Al._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]=Rl(this.year<2e3?this.year-1900:this.year-2e3,2),e[1]=Rl(this.month,2),e[2]=Rl(this.day,2),e[3]=Rl(this.hour,2),e[4]=Rl(this.minute,2),e[5]=Rl(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}}}Ac=ku,Wl.UTCTime=Ac,ku.NAME="UTCTime";class Au extends ku{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(Rl(this.year,4)),e.push(Rl(this.month,2)),e.push(Rl(this.day,2)),e.push(Rl(this.hour,2)),e.push(Rl(this.minute,2)),e.push(Rl(this.second,2)),0!==this.millisecond&&(e.push("."),e.push(Rl(this.millisecond,3))),e.push("Z"),e.join("")}return super.toString(e)}toJSON(){return{...super.toJSON(),millisecond:this.millisecond}}}_c=Au,Wl.GeneralizedTime=_c,Au.NAME="GeneralizedTime";class _u extends cu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=31}}Ic=_u,Wl.DATE=Ic,_u.NAME="DATE";class Iu extends cu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=32}}xc=Iu,Wl.TimeOfDay=xc,Iu.NAME="TimeOfDay";class xu extends cu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=33}}Cc=xu,Wl.DateTime=Cc,xu.NAME="DateTime";class Cu extends cu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=34}}Rc=Cu,Wl.Duration=Rc,Cu.NAME="Duration";class Ru extends cu{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),this.idBlock.tagClass=1,this.idBlock.tagNumber=14}}Tc=Ru,Wl.TIME=Tc,Ru.NAME="TIME";function Tu(e){if(isNaN(e)||e<=0)throw new ps("random bytes length must be a Number bigger than 0","ERR_INVALID_LENGTH");return Yn(e)}function Nu(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 Pu(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 Ou=1e4;async function Lu(e,t){const n=nl.get(),r=new ru({value:[new Yc({value:0}),new ru({value:[new Zc({value:"1.2.840.113549.1.1.1"}),new Mc]}),new qc({valueHex:e.marshal()})]}).toBER(),o=new Uint8Array(r,0,r.byteLength),i=Tu(16),s=await async function(e,t,n,r){const{c:o,dkLen:i,asyncTick:s,DK:a,PRF:l,PRFSalt:c}=Sl(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 kl(l,c,a,u,f)}(Cs,t,i,{c:Ou,dkLen:32}),a=Tu(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 ru({value:[new qc({valueHex:i}),new Yc({value:Ou}),new Yc({value:32}),new ru({value:[new Zc({value:"1.2.840.113549.2.11"}),new Mc]})]}),d=new ru({value:[new Zc({value:"1.2.840.113549.1.5.13"}),new ru({value:[new ru({value:[new Zc({value:"1.2.840.113549.1.5.12"}),u]}),new ru({value:[new Zc({value:"2.16.840.1.101.3.4.1.42"}),new qc({valueHex:a})]})]})]}),h=new ru({value:[d,new qc({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 Du=8192;class Bu{_key;constructor(e){this._key=e}verify(e,t){return async function(e,t,n){const r=await nl.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["verify"]);return nl.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 ps("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new ru({value:[new ru({value:[new Zc({value:"1.2.840.113549.1.1.1"}),new Mc]}),new Vc({valueHex:new ru({value:[Yc.fromBigInt(Pu(Dt(e.n,"base64url"))),Yc.fromBigInt(Pu(Dt(e.e,"base64url")))]}).toBER()})]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return al.encode({Type:il.RSA,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return ys(e)?e.then((e=>{let{bytes:t}=e;return t})):e.bytes}}class Uu{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t}genSecret(){return Tu(16)}sign(e){return async function(e,t){const n=await nl.get().subtle.importKey("jwk",e,{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}},!1,["sign"]),r=await nl.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 ps("public key not provided","ERR_PUBKEY_NOT_PROVIDED");return new Bu(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 ps("JWK was missing components","ERR_INVALID_PARAMETERS");const t=new ru({value:[new Yc({value:0}),Yc.fromBigInt(Pu(Dt(e.n,"base64url"))),Yc.fromBigInt(Pu(Dt(e.e,"base64url"))),Yc.fromBigInt(Pu(Dt(e.d,"base64url"))),Yc.fromBigInt(Pu(Dt(e.p,"base64url"))),Yc.fromBigInt(Pu(Dt(e.q,"base64url"))),Yc.fromBigInt(Pu(Dt(e.dp,"base64url"))),Yc.fromBigInt(Pu(Dt(e.dq,"base64url"))),Yc.fromBigInt(Pu(Dt(e.qi,"base64url")))]}).toBER();return new Uint8Array(t,0,t.byteLength)}(this._key)}get bytes(){return ll.encode({Type:il.RSA,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return ys(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 Lu(this,e);if("libp2p-key"===t)return ol(this.bytes,e);throw new ps(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}async function Mu(e){const t=function(e){const{result:t}=Oc(e),n=t.valueBlock.value;return{n:dr(Nu(n[1].toBigInt()),"base64url"),e:dr(Nu(n[2].toBigInt()),"base64url"),d:dr(Nu(n[3].toBigInt()),"base64url"),p:dr(Nu(n[4].toBigInt()),"base64url"),q:dr(Nu(n[5].toBigInt()),"base64url"),dp:dr(Nu(n[6].toBigInt()),"base64url"),dq:dr(Nu(n[7].toBigInt()),"base64url"),qi:dr(Nu(n[8].toBigInt()),"base64url"),kty:"RSA",alg:"RS256"}}(e);if(wl(t)>Du)throw new ps("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const n=await ml(t);return new Uu(n.privateKey,n.publicKey)}function Fu(e){const t=function(e){const{result:t}=Oc(e),n=t.valueBlock.value[1].valueBlock.value[0].valueBlock.value;return{kty:"RSA",n:dr(Nu(n[0].toBigInt()),"base64url"),e:dr(Nu(n[1].toBigInt()),"base64url")}}(e);if(wl(t)>Du)throw new ps("key size is too large","ERR_KEY_SIZE_TOO_LARGE");return new Bu(t)}async function $u(e){if(wl(e)>Du)throw new ps("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await ml(e);return new Uu(t.privateKey,t.publicKey)}async function Hu(e){if(e>Du)throw new ps("key size is too large","ERR_KEY_SIZE_TOO_LARGE");const t=await async function(e){const t=await nl.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 yl(t);return{privateKey:n[0],publicKey:n[1]}}(e);return new Uu(t.privateKey,t.publicKey)}function qu(e){void 0!==e.lowS&&Ls("lowS",e.lowS),void 0!==e.prehash&&Ls("prehash",e.prehash)}const{Ph:ju,aT:Vu}=p,zu={Err:class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}},_tlv:{encode:(e,t)=>{const{Err:n}=zu;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=Us(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const i=r>127?Us(o.length/2|128):"";return`${Us(e)}${i}${o}${t}`},decode(e,t){const{Err:n}=zu;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}=zu;if(e<Ku)throw new t("integer: negative integers are not allowed");let n=Us(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}=zu;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 ju(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=zu,o="string"===typeof e?Vu(e):e;Os(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}=zu,r=`${t.encode(2,n.encode(e.r))}${t.encode(2,n.encode(e.s))}`;return t.encode(48,r)}},Ku=BigInt(0),Wu=BigInt(1),Gu=(BigInt(2),BigInt(3));BigInt(4);function Yu(e){const t=function(e){const t=Ca(e);ra(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=wa(t.n,t.nBitLength),o=t.toBytes||((e,t,r)=>{const o=t.toAffine();return Ws(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(Ps(e)&&(e=Bs(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:qs(Ks("private key",e,r))}catch(a){throw new Error(`private key must be ${r} bytes, hex or bigint, not ${typeof e}`)}return o&&(s=ha(s,i)),Qs("private key",s,Wu,i),s}function l(e){if(!(e instanceof d))throw new Error("ProjectivePoint expected")}const c=oa(((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=oa((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(Ks("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return d.BASE.multiply(a(e))}static msm(e,t){return xa(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,Gu),{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,Gu);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){Qs("scalar",e,Ku,t.n);const r=d.ZERO;if(e===Ku)return r;if(e===Wu)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>Ku||l>Ku;)s&Wu&&(c=c.add(h)),l&Wu&&(u=u.add(h)),h=h.double(),s>>=Wu,l>>=Wu;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(Qs("scalar",e,Wu,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!==Ku&&t!==Wu&&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===Wu)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===Wu?this:n?n(d,this):this.multiplyUnsafe(t.h)}toRawBytes(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Ls("isCompressed",e),this.assertValidity(),o(d,this,e)}toHex(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Ls("isCompressed",e),Bs(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=Ia(d,t.endo?Math.ceil(h/2):h);return{CURVE:t,ProjectivePoint:d,normPrivateKeyToScalar:a,weierstrassEquation:s,isWithinCurveOrder:function(e){return Ys(e,Wu,t.n)}}}function Qu(e){const t=function(e){const t=Ca(e);return ra(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 ha(e,r)}function a(e){return ga(e,r)}const{ProjectivePoint:l,normPrivateKeyToScalar:c,weierstrassEquation:u,isWithinCurveOrder:d}=Yu({...t,toBytes(e,t,r){const o=t.toAffine(),i=n.toBytes(o.x),s=Ws;return Ls("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=qs(s);if(!Ys(e,Wu,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&Wu)===Wu)&&(o=n.neg(o)),{x:e,y:o}}}}),h=e=>Bs(Vs(e,t.nByteLength));function f(e){return e>r>>Wu}const p=(e,t,n)=>qs(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=Ks("compactSignature",e,2*n),new g(p(e,0,n),p(e,n,2*n))}static fromDER(e){const{r:t,s:n}=zu.toSig(Ks("DER",e));return new g(t,n)}assertValidity(){Qs("r",this.r,Wu,r),Qs("s",this.s,Wu,r)}addRecoveryBit(e){return new g(this.r,this.s,e)}recoverPublicKey(e){const{r:r,s:o,recovery:i}=this,c=w(Ks("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 Hs(this.toDERHex())}toDERHex(){return zu.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Hs(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=Ea(t.n);return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const r=e.length,o=va(t),i=Ea(t);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const s=ha(n?qs(e):js(e),t-sa)+sa;return n?zs(s,o):Vs(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=Ps(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=qs(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=Xs(t.nBitLength);function E(e){return Qs(`num < 2^${t.nBitLength}`,e,Ku,v),Vs(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=Ks("msgHash",e),qu(o),p&&(e=Ks("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(Ks("extraEntropy",e))}const A=Ws(...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===Ku)return;const i=s(n*s(_+o*v));if(i===Ku)return;let c=(r.x===o?0:2)|Number(r.y&Wu),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 ta(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=Ks("msgHash",n),r=Ks("publicKey",r),"strict"in o)throw new Error("options.strict was renamed to lowS");qu(o);const{lowS:c,prehash:u}=o;let d,h;try{if("string"===typeof i||Ps(i))try{d=g.fromDER(i)}catch(S){if(!(S instanceof zu.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 Ju(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 El(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 Xu=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),Zu=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),ed=BigInt(1),td=BigInt(2),nd=(e,t)=>(e+t/td)/t;function rd(e){const t=Xu,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=pa(u,n,t)*u%t,h=pa(d,n,t)*u%t,f=pa(h,td,t)*c%t,p=pa(f,o,t)*f%t,g=pa(p,i,t)*p%t,m=pa(g,a,t)*g%t,y=pa(m,l,t)*m%t,b=pa(y,a,t)*g%t,w=pa(b,n,t)*u%t,v=pa(w,s,t)*p%t,E=pa(v,r,t)*c%t,S=pa(E,td,t);if(!od.eql(od.sqr(S),e))throw new Error("Cannot find square root");return S}const od=wa(Xu,void 0,void 0,{sqrt:rd}),id=function(e,t){const n=t=>Qu({...e,...Ju(t)});return Object.freeze({...n(t),create:n})}({a:BigInt(0),b:BigInt(7),Fp:od,n:Zu,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=Zu,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-ed*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=nd(i*e,t),l=nd(-r*e,t);let c=ha(e-a*n-l*o,t),u=ha(-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);id.ProjectivePoint;function sd(e){try{id.ProjectivePoint.fromHex(e)}catch(t){throw new ps(String(t),"ERR_INVALID_PUBLIC_KEY")}}class ad{_key;constructor(e){sd(e),this._key=e}verify(e,t){return function(e,t,n){const r=vt.digest(n instanceof Uint8Array?n:n.subarray());if(ys(r))return r.then((n=>{let{digest:r}=n;return id.verify(t,r,e)})).catch((e=>{throw new ps(String(e),"ERR_INVALID_INPUT")}));try{return id.verify(t,r.digest,e)}catch(o){throw new ps(String(o),"ERR_INVALID_INPUT")}}(this._key,t,e)}marshal(){return e=this._key,id.ProjectivePoint.fromHex(e).toRawBytes(!0);var e}get bytes(){return al.encode({Type:il.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}async hash(){const e=vt.digest(this.bytes);let t;return ys(e)?({bytes:t}=await e):t=e.bytes,t}}class ld{_key;_publicKey;constructor(e,t){this._key=e,this._publicKey=t??function(e){try{return id.getPublicKey(e,!0)}catch(t){throw new ps(String(t),"ERR_INVALID_PRIVATE_KEY")}}(e),function(e){try{id.getPublicKey(e,!0)}catch(t){throw new ps(String(t),"ERR_INVALID_PRIVATE_KEY")}}(this._key),sd(this._publicKey)}sign(e){return function(e,t){const n=vt.digest(t instanceof Uint8Array?t:t.subarray());if(ys(n))return n.then((t=>{let{digest:n}=t;return id.sign(n,e).toDERRawBytes()})).catch((e=>{throw new ps(String(e),"ERR_INVALID_INPUT")}));try{return id.sign(n.digest,e).toDERRawBytes()}catch(r){throw new ps(String(r),"ERR_INVALID_INPUT")}}(this._key,e)}get public(){return new ad(this._publicKey)}marshal(){return this._key}get bytes(){return ll.encode({Type:il.Secp256k1,Data:this.marshal()}).subarray()}equals(e){return Ur(this.bytes,e.bytes)}hash(){const e=vt.digest(this.bytes);return ys(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 ol(this.bytes,e);throw new ps(`export format '${t}' is not supported`,"ERR_INVALID_EXPORT_FORMAT")}}function cd(e){return new ld(e)}function ud(e){return new ad(e)}async function dd(){const e=id.utils.randomPrivateKey();return new ld(e)}const hd={rsa:m,ed25519:g,secp256k1:y};function fd(e){const t=Object.keys(hd).join(" / ");return new ps(`invalid or unsupported key type ${e}. Must be ${t}`,"ERR_UNSUPPORTED_KEY_TYPE")}function pd(e){if("rsa"===(e=e.toLowerCase())||"ed25519"===e||"secp256k1"===e)return hd[e];throw fd(e)}function gd(e){const t=al.decode(e),n=t.Data??new Uint8Array;switch(t.Type){case il.RSA:return hd.rsa.unmarshalRsaPublicKey(n);case il.Ed25519:return hd.ed25519.unmarshalEd25519PublicKey(n);case il.Secp256k1:return hd.secp256k1.unmarshalSecp256k1PublicKey(n);default:throw fd(t.Type??"unknown")}}function md(e,t){return pd(t=(t??"rsa").toLowerCase()),e.bytes}async function yd(e){const t=ll.decode(e),n=t.Data??new Uint8Array;switch(t.Type){case il.RSA:return hd.rsa.unmarshalRsaPrivateKey(n);case il.Ed25519:return hd.ed25519.unmarshalEd25519PrivateKey(n);case il.Secp256k1:return hd.secp256k1.unmarshalSecp256k1PrivateKey(n);default:throw fd(t.Type??"RSA")}}const bd=Symbol.for("@libp2p/service-capabilities"),wd=Symbol.for("@libp2p/service-dependencies"),vd=Symbol.for("nodejs.util.inspect.custom"),Ed=Object.values(Tt).map((e=>e.decoder)).reduce(((e,t)=>e.or(t)),Tt.identity.decoder);class Sd{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()})`}[ei]=!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 Cd(e).equals(this);if(null!=e?.multihash?.bytes)return Ur(this.multihash.bytes,e.multihash.bytes);throw new Error("not valid Id")}[vd](){return`PeerId(${this.toString()})`}}class kd extends Sd{type="RSA";publicKey;constructor(e){super({...e,type:"RSA"}),this.publicKey=e.publicKey}}class Ad extends Sd{type="Ed25519";publicKey;constructor(e){super({...e,type:"Ed25519"}),this.publicKey=e.multihash.digest}}class _d extends Sd{type="secp256k1";publicKey;constructor(e){super({...e,type:"secp256k1"}),this.publicKey=e.multihash.digest}}const Id=2336;class xd{type="url";multihash;privateKey;publicKey;url;constructor(e){this.url=e.toString(),this.multihash=mt.digest(Dt(this.url))}[vd](){return`PeerId(${this.url})`}[ei]=!0;toString(){return this.toCID().toString()}toCID(){return _t.createV1(Id,this.multihash)}toBytes(){return this.toCID().bytes}equals(e){return null!=e&&(e instanceof Uint8Array&&(e=dr(e)),e.toString()===this.toString())}}function Cd(e,t){if(t=t??Ed,"1"===e.charAt(0)||"Q"===e.charAt(0)){const t=ft(Ce.decode(`z${e}`));return e.startsWith("12D")?new Ad({multihash:t}):e.startsWith("16U")?new _d({multihash:t}):new kd({multihash:t})}return Rd(Ed.decode(e))}function Rd(e){try{const t=ft(e);if(t.code===mt.code){if(36===t.digest.length)return new Ad({multihash:t});if(37===t.digest.length)return new _d({multihash:t})}if(t.code===vt.code)return new kd({multihash:t})}catch{return function(e){if(null==e?.multihash||null==e.version||1===e.version&&114!==e.code&&e.code!==Id)throw new Error("Supplied PeerID CID is invalid");if(e.code===Id){const t=dr(e.multihash.digest);return new xd(new URL(t))}const t=e.multihash;if(t.code===vt.code)return new kd({multihash:e.multihash});if(t.code===mt.code){if(36===t.digest.length)return new Ad({multihash:e.multihash});if(37===t.digest.length)return new _d({multihash:e.multihash})}throw new Error("Supplied PeerID CID is invalid")}(_t.decode(e))}throw new Error("Supplied PeerID CID is invalid")}async function Td(e,t){return 36===e.length?new Ad({multihash:ht(mt.code,e),privateKey:t}):37===e.length?new _d({multihash:ht(mt.code,e),privateKey:t}):new kd({multihash:await vt.digest(e),publicKey:e,privateKey:t})}class Nd 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 Pd(e,t,n){if(null==t)return e;if(t.aborted)return Promise.reject(new Nd(n?.errorMessage,n?.errorCode,n?.errorName));let r;const o=new Nd(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 Od{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 Pd(this.readNext.promise,t?.signal,t)}}class Ld extends Error{name="UnexpectedEOFError";code="ERR_UNEXPECTED_EOF"}class Dd extends Error{code;constructor(e,t){super(e),this.code=t}}class Bd extends Dd{type;constructor(e){super(e,"ABORT_ERR"),this.type="aborted",this.name="AbortError"}}function Ud(e,t){const n=new Od;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 Bd("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 Ld("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 Md extends Error{name="InvalidMessageLengthError";code="ERR_INVALID_MSG_LENGTH"}class Fd extends Error{name="InvalidDataLengthError";code="ERR_MSG_DATA_TOO_LONG"}class $d extends Error{name="InvalidDataLengthLengthError";code="ERR_MSG_LENGTH_TOO_LONG"}function Hd(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=Ud(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 Md("Invalid message length");if(null!=t?.maxLengthLength&&i.byteLength>t.maxLengthLength)throw new $d("message length length too long");if(o>-1)break}if(null!=t?.maxDataLength&&o>t.maxDataLength)throw new Fd("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 qd(){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 jd=65535,Vd=Boolean(globalThis.process?.env?.DUMP_SESSION_KEYS);function zd(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Kd(e){if("boolean"!==typeof e)throw new Error(`boolean expected, not ${e}`)}function Wd(e){return e instanceof Uint8Array||null!=e&&"object"===typeof e&&"Uint8Array"===e.constructor.name}function Gd(e){if(!Wd(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 Yd(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 Qd(e,t){Gd(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}const Jd=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Xd=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 Zd(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(!Wd(e))throw new Error("Uint8Array expected, got "+typeof e);e=nh(e)}return e}const eh=(e,t)=>(Object.assign(t,e),t);function th(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 nh(e){return Uint8Array.from(e)}function rh(){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 oh=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),ih=oh("expand 16-byte k"),sh=oh("expand 32-byte k"),ah=Jd(ih),lh=Jd(sh);lh.slice();function ch(e,t){return e<<t|e>>>32-t}function uh(e){return e.byteOffset%4===0}const dh=2**32-1,hh=new Uint32Array;function fh(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 zd(o),zd(s),Kd(i),Kd(n),function(t,a,l,c){let u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;Gd(t),Gd(a),Gd(l);const d=l.length;if(void 0===c&&(c=new Uint8Array(d)),Gd(c),zd(u),u<0||u>=dh)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=nh(t)),p=lh;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=ah,h.push(f)}uh(a)||h.push(a=nh(a));const m=Jd(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,Jd(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=Jd(a);return function(e,t,n,r,o,i,s,a){const l=o.length,c=new Uint8Array(64),u=Jd(c),d=uh(o)&&uh(i),h=d?Jd(o):hh,f=d?Jd(i):hh;for(let p=0;p<l;s++){if(e(t,n,r,u,s,a),s>=dh)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),rh(...h),c}}const ph=(e,t)=>255&e[t++]|(255&e[t++])<<8;class gh{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,Gd(e=Zd(e),32);const t=ph(e,0),n=ph(e,2),r=ph(e,4),o=ph(e,6),i=ph(e,8),s=ph(e,10),a=ph(e,12),l=ph(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]=ph(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=ph(e,t+0),m=ph(e,t+2),y=ph(e,t+4),b=ph(e,t+6),w=ph(e,t+8),v=ph(e,t+10),E=ph(e,t+12),S=ph(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;rh(n)}update(e){Yd(this);const{buffer:t,blockLen:n}=this,r=(e=Zd(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(){rh(this.h,this.r,this.buffer,this.pad)}digestInto(e){Yd(this),Qd(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 mh=function(e){const t=(t,n)=>e(n).update(Zd(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}((e=>new gh(e)));function yh(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=ch(L^S,16),T=T+L|0,I=ch(I^T,12),S=S+I|0,L=ch(L^S,8),T=T+L|0,I=ch(I^T,7),k=k+x|0,D=ch(D^k,16),N=N+D|0,x=ch(x^N,12),k=k+x|0,D=ch(D^k,8),N=N+D|0,x=ch(x^N,7),A=A+C|0,B=ch(B^A,16),P=P+B|0,C=ch(C^P,12),A=A+C|0,B=ch(B^A,8),P=P+B|0,C=ch(C^P,7),_=_+R|0,U=ch(U^_,16),O=O+U|0,R=ch(R^O,12),_=_+R|0,U=ch(U^_,8),O=O+U|0,R=ch(R^O,7),S=S+x|0,U=ch(U^S,16),P=P+U|0,x=ch(x^P,12),S=S+x|0,U=ch(U^S,8),P=P+U|0,x=ch(x^P,7),k=k+C|0,L=ch(L^k,16),O=O+L|0,C=ch(C^O,12),k=k+C|0,L=ch(L^k,8),O=O+L|0,C=ch(C^O,7),A=A+R|0,D=ch(D^A,16),T=T+D|0,R=ch(R^T,12),A=A+R|0,D=ch(D^A,8),T=T+D|0,R=ch(R^T,7),_=_+I|0,B=ch(B^_,16),N=N+B|0,I=ch(I^N,12),_=_+I|0,B=ch(B^_,8),N=N+B|0,I=ch(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 bh=fh(yh,{counterRight:!1,counterLength:4,allowShortKeys:!1}),wh=fh(yh,{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=ch(m^o,16),h=h+m|0,l=ch(l^h,12),o=o+l|0,m=ch(m^o,8),h=h+m|0,l=ch(l^h,7),i=i+c|0,y=ch(y^i,16),f=f+y|0,c=ch(c^f,12),i=i+c|0,y=ch(y^i,8),f=f+y|0,c=ch(c^f,7),s=s+u|0,b=ch(b^s,16),p=p+b|0,u=ch(u^p,12),s=s+u|0,b=ch(b^s,8),p=p+b|0,u=ch(u^p,7),a=a+d|0,w=ch(w^a,16),g=g+w|0,d=ch(d^g,12),a=a+d|0,w=ch(w^a,8),g=g+w|0,d=ch(d^g,7),o=o+c|0,w=ch(w^o,16),p=p+w|0,c=ch(c^p,12),o=o+c|0,w=ch(w^o,8),p=p+w|0,c=ch(c^p,7),i=i+u|0,m=ch(m^i,16),g=g+m|0,u=ch(u^g,12),i=i+u|0,m=ch(m^i,8),g=g+m|0,u=ch(u^g,7),s=s+d|0,y=ch(y^s,16),h=h+y|0,d=ch(d^h,12),s=s+d|0,y=ch(y^s,8),h=h+y|0,d=ch(d^h,7),a=a+l|0,b=ch(b^a,16),f=f+b|0,l=ch(l^f,12),a=a+l|0,b=ch(b^a,8),f=f+b|0,l=ch(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}),vh=new Uint8Array(16),Eh=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(vh.subarray(n))},Sh=new Uint8Array(32);function kh(e,t,n,r,o){const i=e(t,n,Sh),s=mh.create(i);o&&Eh(s,o),Eh(s,r);const a=new Uint8Array(16),l=Xd(a);th(l,0,BigInt(o?o.length:0),!0),th(l,8,BigInt(r.length),!0),s.update(a);const c=s.digest();return rh(i,a),c}const Ah=e=>(t,n,r)=>{const o=16;return Gd(t,32),Gd(n),{encrypt(i,s){const a=i.length,l=a+o;s?Gd(s,l):s=new Uint8Array(l),e(t,n,i,s,1);const c=kh(e,t,n,s.subarray(0,-16),r);return s.set(c,a),rh(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?Gd(s,l):s=new Uint8Array(l);const c=i.subarray(0,-16),u=i.subarray(-16),d=kh(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),rh(d),s}}},_h=eh({blockSize:64,nonceLength:12,tagLength:16},Ah(bh));Ah(wh);function Ih(e,t,n){return Un(e),void 0===n&&(n=new Uint8Array(e.outputLen)),El(e,zn(n),zn(t))}const xh=new Uint8Array([0]),Ch=new Uint8Array;function Rh(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=Ch);const i=new Uint8Array(o*e.outputLen),s=El.create(e,t),a=s._cloneInto(),l=new Uint8Array(s.outputLen);for(let c=0;c<o;c++)xh[0]=c+1,a.update(0===c?Ch:l).update(n).update(xh).digestInto(l),i.set(l,e.outputLen*c),s._cloneInto(a);return s.destroy(),a.destroy(),l.fill(0),xh.fill(0),i.slice(0,r)}const Th={hashSHA256:e=>nr(e.subarray()),getHKDF(e,t){const n=Ih(nr,t,e),r=Rh(nr,n,void 0,96);return[r.subarray(0,32),r.subarray(32,64),r.subarray(64,96)]},generateX25519KeyPair(){const e=Ja.utils.randomPrivateKey();return{publicKey:Ja.getPublicKey(e),privateKey:e}},generateX25519KeyPairFromSeed:e=>({publicKey:Ja.getPublicKey(e),privateKey:e}),generateX25519SharedKey:(e,t)=>Ja.getSharedSecret(e.subarray(),t.subarray()),chaCha20Poly1305Encrypt:(e,t,n,r)=>_h(r,t,n).encrypt(e.subarray()),chaCha20Poly1305Decrypt:(e,t,n,r,o)=>_h(r,t,n).decrypt(e.subarray(),o)};const Nh=e=>{const t=E(2);return t[0]=e>>8,t[1]=e,t};Nh.bytes=2;const Ph=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 Oh(e,t){t.enabled&&Vd&&(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 Lh(e,t){t.enabled&&Vd&&(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 Dh(e,t){t.enabled&&Vd&&t(e?`REMOTE_EPHEMERAL_PUBLIC_KEY ${dr(e.subarray(),"hex")}`:"Missing remote ephemeral keys.")}function Bh(e,t,n){n.enabled&&Vd&&(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")}`))}Ph.bytes=2;class Uh extends Error{code;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Unexpected Peer"),this.code=Uh.code}static code="ERR_UNEXPECTED_PEER"}class Mh extends Error{code;constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Invalid crypto exchange"),this.code=Mh.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"}class Fh{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 $h=v(0);class Hh{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 Fh(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 qh{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 Hh(e)}mixKey(e){const[t,n]=this.crypto.hkdf(this.ck,e);this.ck=t,this.cs=new Hh(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,$h);return[new Hh(this.crypto,e),new Hh(this.crypto,t)]}}class jh{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 qh(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 Vh extends jh{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 Mh(`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 Mh(`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 Mh(`handshake stage 2 validation fail: ${t.message}`)}}}var zh,Kh;async function Wh(e,t,n){const r=await e.sign(Yh(t));return Kh.encode({identityKey:e.public.bytes,identitySig:r,extensions:n})}async function Gh(e,t,n){try{const r=Kh.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=Yh(t),i=gd(r.identityKey);if(!await i.verify(o,r.identitySig))throw new Error("Invalid payload signature");return r}catch(r){throw new Uh(r.message)}}function Yh(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 Qh(e,t){const{log:n,connection:r,crypto:o,privateKey:i,prologue:s,s:a,remoteIdentityKey:l,extensions:c}=e,u=await Wh(i,a.publicKey,c),d=new Vh({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!0,prologue:s,s:a});Oh(d.s,n),n.trace("Stage 0 - Initiator starting to send first message."),await r.write(d.writeMessageA($h),t),n.trace("Stage 0 - Initiator finished sending first message."),Lh(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."),Dh(d.re,n),f=d.rs,(p=n).enabled&&Vd&&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 Gh(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 Bh(m,y,n),{payload:g,encrypt:e=>m.encryptWithAd($h,e),decrypt:(e,t)=>y.decryptWithAd($h,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())}(zh||(zh={})),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),zh.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=zh.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())}(Kh||(Kh={}));class Jh{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??Th;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";[bd]=["@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=Hd(o,{lengthEncoder:Nh,lengthDecoder:Ph,maxDataLength:jd});if(!r.privateKey)throw new ps("local peerId does not contain private key","ERR_NO_PRIVATE_KEY");const l=await yd(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 Td(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=Hd(o,{lengthEncoder:Nh,lengthDecoder:Ph,maxDataLength:jd});if(!r.privateKey)throw new ps("local peerId does not contain private key","ERR_NO_PRIVATE_KEY");const l=await yd(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 Td(u.payload.identityKey)}}async performHandshakeInitiator(e,t,n,r){let o;try{o=await Qh({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 Wh(i,a.publicKey,c),d=new Vh({crypto:o,protocolName:"Noise_XX_25519_ChaChaPoly_SHA256",initiator:!1,prologue:s,s:a});Oh(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."),Dh(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."),Lh(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 Gh(h,d.rs,l),[p,g]=d.ss.split();return Bh(p,g,n),{payload:f,encrypt:e=>g.encryptWithAd($h,e),decrypt:(e,t)=>p.decryptWithAd($h,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=qd(),t=qd();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(Nh(o.byteLength),o)}}}(t,this.metrics),o,(e=>Jr(e,{lengthDecoder:Ph})),function(e,t){return async function*(n){for await(const o of n)for(let n=0;n<o.length;n+=jd){let i=n+jd;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 ti(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 Xh(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Jh(t,e)}const Zh=Symbol.for("@libp2p/peer-discovery"),ef=Pf("dns4"),tf=Pf("dns6"),nf=Pf("dnsaddr"),rf=Nf(Pf("dns"),nf,ef,tf),of=Nf(Pf("ip4"),Pf("ip6")),sf=Nf(Tf(of,Pf("tcp")),Tf(rf,Pf("tcp"))),af=Tf(of,Pf("udp")),lf=Tf(af,Pf("utp")),cf=Tf(af,Pf("quic")),uf=Tf(af,Pf("quic-v1")),df=Nf(Tf(sf,Pf("ws")),Tf(rf,Pf("ws"))),hf=Nf(Tf(df,Pf("p2p")),df),ff=Nf(Tf(sf,Pf("wss")),Tf(rf,Pf("wss")),Tf(sf,Pf("tls"),Pf("ws")),Tf(rf,Pf("tls"),Pf("ws"))),pf=Nf(Tf(ff,Pf("p2p")),ff),gf=Nf(Tf(sf,Pf("http")),Tf(of,Pf("http")),Tf(rf,Pf("http"))),mf=Nf(Tf(sf,Pf("https")),Tf(of,Pf("https")),Tf(rf,Pf("https"))),yf=Tf(af,Pf("webrtc-direct"),Pf("certhash")),bf=Nf(Tf(yf,Pf("p2p")),yf),wf=Tf(uf,Pf("webtransport"),Pf("certhash"),Pf("certhash")),vf=Nf(Tf(wf,Pf("p2p")),wf),Ef=Nf(Tf(hf,Pf("p2p-webrtc-star"),Pf("p2p")),Tf(pf,Pf("p2p-webrtc-star"),Pf("p2p")),Tf(hf,Pf("p2p-webrtc-star")),Tf(pf,Pf("p2p-webrtc-star"))),Sf=(Nf(Tf(hf,Pf("p2p-websocket-star"),Pf("p2p")),Tf(pf,Pf("p2p-websocket-star"),Pf("p2p")),Tf(hf,Pf("p2p-websocket-star")),Tf(pf,Pf("p2p-websocket-star"))),Nf(Tf(gf,Pf("p2p-webrtc-direct"),Pf("p2p")),Tf(mf,Pf("p2p-webrtc-direct"),Pf("p2p")),Tf(gf,Pf("p2p-webrtc-direct")),Tf(mf,Pf("p2p-webrtc-direct")))),kf=Nf(df,ff,gf,mf,Ef,Sf,sf,lf,cf,rf,bf,vf),Af=(Nf(Tf(kf,Pf("p2p-stardust"),Pf("p2p")),Tf(kf,Pf("p2p-stardust"))),Nf(Tf(kf,Pf("p2p")),Ef,Sf,bf,vf,Pf("p2p"))),_f=Nf(Tf(Af,Pf("p2p-circuit"),Af),Tf(Af,Pf("p2p-circuit")),Tf(Pf("p2p-circuit"),Af),Tf(kf,Pf("p2p-circuit")),Tf(Pf("p2p-circuit"),kf),Pf("p2p-circuit")),If=()=>Nf(Tf(_f,If),_f),xf=If(),Cf=Nf(Tf(xf,Af,xf),Tf(Af,xf),Tf(xf,Af),xf,Af);Nf(Tf(xf,Pf("webrtc"),Pf("p2p")),Tf(xf,Pf("webrtc")),Tf(kf,Pf("webrtc"),Pf("p2p")),Tf(kf,Pf("webrtc")),Pf("webrtc"));function Rf(e){return function(t){let n;try{n=Bi(t)}catch(o){return!1}const r=e(n.protoNames());return null!==r&&(!0===r||!1===r?r:0===r.length)}}function Tf(){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:Rf(r),partialMatch:r}}function Nf(){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:Rf(r),partialMatch:r}}function Pf(e){const t=e;return{toString:function(){return t},matches:function(e){let n;try{n=Bi(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 Of extends qo{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(!Cf.matches(n)){this.log.error("Invalid multiaddr");continue}const e=Bi(n),t=e.getPeerId();if(null==t){this.log.error("Invalid bootstrap multiaddr without peer id");continue}const r={id:Cd(t),multiaddrs:[e]};this.list.push(r)}this._init=t}[Zh]=this;[Symbol.toStringTag]="@libp2p/bootstrap";[bd]=["@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 Lf=Uint8Array.from([3,1]);var Df;!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())}(Df||(Df={}));class Bf{static createFromProtobuf=e=>{const t=Df.decode(e),n=Rd(t.peerId),r=(t.addresses??[]).map((e=>Bi(e.multiaddr))),o=t.seq;return new Bf({peerId:n,multiaddrs:r,seqNumber:o})};static DOMAIN="libp2p-peer-record";static CODEC=(()=>Lf)();peerId;multiaddrs;seqNumber;domain=(()=>Bf.DOMAIN)();codec=(()=>Bf.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=Df.encode({peerId:this.peerId.toBytes(),seq:BigInt(this.seqNumber),addresses:this.multiaddrs.map((e=>({multiaddr:e.bytes})))})),this.marshaled}equals(e){return e instanceof Bf&&(!!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 Uf="ERR_SIGNATURE_NOT_VALID";var Mf;!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())}(Mf||(Mf={}));class Ff{static createFromProtobuf=async e=>{const t=Mf.decode(e),n=await Td(t.publicKey);return new Ff({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=$f(n,r,o),s=await yd(t.privateKey),a=await s.sign(i.subarray());return new Ff({peerId:t,payloadType:r,payload:o,signature:a})};static openAndCertify=async(e,t)=>{const n=await Ff.createFromProtobuf(e);if(!await n.validate(t))throw new ps("envelope signature is not valid for the given domain",Uf);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=Mf.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=$f(e,this.payloadType,this.payload);if(null==this.peerId.publicKey)throw new Error("Missing public key");return gd(this.peerId.publicKey).verify(t.subarray(),this.signature)}}const $f=(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)},Hf=e=>({match:t=>!(t.length<1)&&(!!e(t[0])&&t.slice(1)),pattern:"fn"}),qf=e=>({match:t=>Hf((t=>t===e)).match(t),pattern:e}),jf=()=>({match:e=>Hf((e=>"string"===typeof e)).match(e),pattern:"{string}"}),Vf=()=>({match:e=>Hf((e=>!isNaN(parseInt(e)))).match(e),pattern:"{number}"}),zf=()=>({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}"}),Kf=()=>({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}"}),Wf=e=>({match:t=>{const n=e.match(t);return!1===n?t:n},pattern:`optional(${e.pattern})`}),Gf=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(", ")})`}},Yf=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 Qf(){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 Jf=Yf(qf("dns4"),jf()),Xf=Yf(qf("dns6"),jf()),Zf=Yf(qf("dnsaddr"),jf()),ep=Yf(qf("dns"),jf()),tp=(Qf(Jf),Qf(Xf),Qf(Zf),Qf(Gf(ep,Zf,Jf,Xf)),Yf(qf("ip4"),Hf(ri))),np=Yf(qf("ip6"),Hf(oi)),rp=Gf(tp,np),op=Gf(rp,ep,Jf,Xf,Zf),ip=Qf(op),sp=(Qf(tp),Qf(np),Qf(rp),Yf(op,qf("tcp"),Vf())),ap=Yf(op,qf("udp"),Vf()),lp=(Qf(sp),Qf(ap),Yf(ap,qf("quic"))),cp=Yf(ap,qf("quic-v1")),up=Gf(lp,cp),dp=(Qf(lp),Qf(cp),Gf(op,sp,ap,lp,cp)),hp=Gf(Yf(dp,qf("ws"),Wf(zf()))),fp=(Qf(hp),Gf(Yf(dp,qf("wss"),Wf(zf())),Yf(dp,qf("tls"),qf("ws"),Wf(zf())))),pp=(Qf(fp),Yf(ap,qf("webrtc-direct"),Wf(Kf()),Wf(Kf()),Wf(zf()))),gp=(Qf(pp),Yf(cp,qf("webtransport"),Wf(Kf()),Wf(Kf()),Wf(zf()))),mp=(Qf(gp),Gf(hp,fp,Yf(sp,Wf(zf())),Yf(up,Wf(zf())),Yf(op,Wf(zf())),pp,gp,zf())),yp=(Qf(mp),Qf(Yf(mp,qf("p2p-circuit"),zf())));Qf(Gf(Yf(mp,qf("p2p-circuit"),qf("webrtc"),Wf(zf())),Yf(mp,qf("webrtc"),Wf(zf())),qf("webrtc"))),Qf(Gf(Yf(op,qf("tcp"),Vf(),qf("http"),Wf(zf())),Yf(op,qf("http"),Wf(zf())))),Qf(Gf(Yf(op,qf("tcp"),Gf(Yf(qf("443"),qf("http")),Yf(Vf(),qf("https"))),Wf(zf())),Yf(op,qf("tls"),qf("http"),Wf(zf())),Yf(op,qf("https"),Wf(zf()))));function bp(e,t){const n=Hd(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 wp;!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())}(wp||(wp={}));var vp=__webpack_require__(4053);const Ep="object"===typeof window&&"object"===typeof document&&9===document.nodeType,Sp=vp(),kp=Ep&&!Sp,Ap=Sp&&!Ep,_p=Sp&&Ep,Ip="undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.release&&"node"===globalThis.process.release.name&&!Sp,xp="function"===typeof importScripts&&"undefined"!==typeof self&&"undefined"!==typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope,Cp=("undefined"!==typeof globalThis.process&&"undefined"!==typeof globalThis.process.env&&globalThis.process.env.NODE_ENV,"undefined"!==typeof navigator&&"ReactNative"===navigator.product),Rp={protocolPrefix:"ipfs",timeout:5e3,maxInboundStreams:1,maxOutboundStreams:1,maxObservedAddresses:10,maxMessageSize:8192,runOnConnectionOpen:!0,runOnSelfUpdate:!0,runOnTransientConnection:!0,concurrency:32};class Tp{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??Rp.timeout,this.maxInboundStreams=t.maxInboundStreams??Rp.maxInboundStreams,this.maxOutboundStreams=t.maxOutboundStreams??Rp.maxOutboundStreams,this.maxMessageSize=t.maxMessageSize??Rp.maxMessageSize,this.maxObservedAddresses=t.maxObservedAddresses??Rp.maxObservedAddresses,this.runOnTransientConnection=t.runOnTransientConnection??Rp.runOnTransientConnection,this.host={protocolVersion:`${t.protocolPrefix??Rp.protocolPrefix}/0.1.0`,agentVersion:(n=e.nodeInfo,r=t.agentVersion,null!=r||(r=`${n.name}/${n.version}`,Ip||Ap?r+=` UserAgent=${globalThis.process.version}`:(kp||xp||_p||Cp)&&(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 Np extends Tp{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(e,{...t,protocol:`/${t.protocolPrefix??Rp.protocolPrefix}/id/1.0.0`,log:e.logger.forComponent("libp2p:identify")}),(t.runOnConnectionOpen??Rp.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)}))}))}[bd]=["@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);Ho(1/0,e),n={...n,signal:e}}try{t=await e.newStream(this.protocol,{...n,runOnTransientConnection:this.runOnTransientConnection});const r=bp(t,{maxDataLength:this.maxMessageSize}).pb(wp),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 ps("public key was missing from identify message","ERR_MISSING_PUBLIC_KEY");const s=await Td(r);if(!e.remotePeer.equals(s))throw new ps("identified peer does not match the expected peer","ERR_INVALID_PEER");if(this.peerId.equals(s))throw new ps("identified peer is our own peer id?","ERR_INVALID_PEER");const a=function(e){if(null!=e&&e.length>0)try{return Bi(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 ps("message was null or undefined","ERR_INVALID_MESSAGE");const i={};if(o.listenAddrs.length>0&&(i.addresses=o.listenAddrs.map((e=>({isCertified:!1,multiaddr:Bi(e)})))),o.protocols.length>0&&(i.protocols=o.protocols),null!=o.publicKey&&(i.publicKey=o.publicKey,!(await Td(o.publicKey)).equals(r.remotePeer)))throw new ps("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 Ff.openAndCertify(t,Bf.DOMAIN);let c,u=Bf.createFromProtobuf(a.payload);if(!u.peerId.equals(a.peerId))throw new ps("signing key does not match PeerId in the PeerRecord","ERR_INVALID_SIGNING_KEY");if(!r.remotePeer.equals(u.peerId))throw new ps("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 Ff.createFromProtobuf(c.peerRecordEnvelope),r=Bf.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=>Bi(e))),observedAddr:null==o.observedAddr?void 0:Bi(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);Ho(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(hi("p2p").code)));let s=o.peerRecordEnvelope;if(i.length>0&&null==s){const e=new Bf({peerId:this.peerId,multiaddrs:i});s=(await Ff.seal(e,this.peerId)).marshal().subarray()}let a=t.remoteAddr.bytes;ip.matches(t.remoteAddr)||(a=void 0);const l=bp(n).pb(wp);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 Pp(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Np(t,e)}function Op(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 Lp=()=>{const e=new Error("Delay aborted");return e.name="AbortError",e},Dp=new WeakMap;const Bp=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(Lp());const l=e??clearTimeout,c=()=>{l(r),i(Lp())},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}),Dp.set(u,(()=>{l(r),r=null,o()})),u}}(),Up=Bp;class Mp{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 Fp}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 ps("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 Up(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 Fp{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 $p;!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"}($p||($p={}));const Hp=Object.freeze({0:"NEW_STREAM",1:"MESSAGE_RECEIVER",2:"MESSAGE_INITIATOR",3:"CLOSE_RECEIVER",4:"CLOSE_INITIATOR",5:"RESET_RECEIVER",6:"RESET_INITIATOR"}),qp=Object.freeze({NEW_STREAM:$p.NEW_STREAM,MESSAGE:$p.MESSAGE_INITIATOR,CLOSE:$p.CLOSE_INITIATOR,RESET:$p.RESET_INITIATOR}),jp=Object.freeze({MESSAGE:$p.MESSAGE_RECEIVER,CLOSE:$p.CLOSE_RECEIVER,RESET:$p.RESET_RECEIVER}),Vp=1<<20;class zp{_buffer;_headerInfo;_maxMessageSize;_maxUnprocessedMessageQueueSize;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Vp,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!==$p.NEW_STREAM&&r!==$p.MESSAGE_INITIATOR&&r!==$p.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}=Gp(e),{value:r,offset:o}=Gp(e,n),i=7&t;if(null==Hp[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 Kp=128,Wp=127;function Gp(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&Wp)<<o:(t&Wp)*Math.pow(2,o),o+=7}while(t>=Kp);return n=i-n,{value:r,offset:n}}const Yp=10240;const Qp=new class{_pool;_poolOffset;constructor(){this._pool=E(Yp),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!==$p.NEW_STREAM&&e.type!==$p.MESSAGE_INITIATOR&&e.type!==$p.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);Yp-r<100?(this._pool=E(Yp),this._poolOffset=0):this._poolOffset=r,t.append(o),e.type!==$p.NEW_STREAM&&e.type!==$p.MESSAGE_INITIATOR&&e.type!==$p.MESSAGE_RECEIVER||null==e.data||t.append(e.data)}};function Jp(e){return null!=e&&("function"===typeof e.then&&"function"===typeof e.catch&&"function"===typeof e.finally)}class Xp{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 ps(`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);Jp(e)&&await e}const n=()=>{Op(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);Jp(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 Pd(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 Pd(this.sink([]),e.signal)),"writing"===this.writeStatus&&(null!=this.sendingData&&await Pd(this.sendingData.promise,e.signal),this.log.trace("aborting source passed to .sink"),this.sinkController.abort(),await Pd(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();Jp(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 ps("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 Zp extends Xp{name;streamId;send;types;maxDataSize;constructor(e){super(e),this.types="outbound"===e.direction?qp:jp,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:qp.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 eg(e){const t={...e,type:`${Hp[e.type]} (${e.type})`};return e.type===$p.NEW_STREAM&&(t.data=dr(e.data instanceof Uint8Array?e.data:e.data.subarray())),e.type!==$p.MESSAGE_INITIATOR&&e.type!==$p.MESSAGE_RECEIVER||(t.data=dr(e.data instanceof Uint8Array?e.data:e.data.subarray(),"base16")),t}class tg{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;Qp.write(t,e),yield e}}(e))),this.closeController=new AbortController,this.rateLimiter=new Mp({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 ps("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=Vp}=e;return new Zp({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,eg(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=()=>{Op(e,this.log)};this.closeController.signal.addEventListener("abort",t);try{const t=new zp(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",eg(e)),e.type===$p.NEW_STREAM){if(this._streams.receivers.size===(this._init.maxInboundStreams??1024)){this.log("too many inbound streams open"),this._source.push({id:t,type:$p.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,Hp[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 $p.MESSAGE_INITIATOR:case $p.MESSAGE_RECEIVER:if(r.sourceReadableLength()>o)throw this._source.push({id:e.id,type:n===$p.MESSAGE_INITIATOR?$p.RESET_RECEIVER:$p.RESET_INITIATOR}),new ps("Input buffer full - increase Mplex maxBufferSize to accommodate slow consumers","ERR_STREAM_INPUT_BUFFER_FULL");r.sourcePush(e.data);break;case $p.CLOSE_INITIATOR:case $p.CLOSE_RECEIVER:r.remoteCloseWrite();break;case $p.RESET_INITIATOR:case $p.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 ng{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";[bd]=["@libp2p/stream-multiplexing"];createStreamMuxer(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return new tg(this.components,{...e,...this._init})}}function rg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new ng(t,e)}const og=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e)return t})();for(const t of e)return t},ig="ERR_WRONG_PING_ACK";class sg{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 ps("ping timeout",ms))})),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 ps("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=Tu(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 ps("ping timeout",ms))},t.signal?.addEventListener("abort",s,{once:!0});const e=await io([r],i,(async e=>og(e))),a=Date.now()-n;if(null==e)throw new ps(`Did not receive a ping ack after ${a}ms`,ig);if(!Ur(r,e.subarray()))throw new ps(`Received wrong ping ack after ${a}ms`,ig);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 ag(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new sg(t,e)}const lg=Symbol.for("@libp2p/transport");var cg;!function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"}(cg||(cg={}));const ug=[hi("tcp").code,hi("dns").code,hi("dnsaddr").code,hi("dns4").code,hi("dns6").code];function dg(e){let t;try{t=hi("sni").code}catch(n){return null}for(const[r,o]of e)if(r===t&&void 0!==o)return o;return null}function hg(e){return e.some((e=>{let[t,n]=e;return t===hi("tls").code}))}function fg(e,t,n){const r=pg[hi(e).name];if(void 0===r)throw new Error(`Can't interpret protocol ${hi(e).name}`);const o=r(t,n);return e===hi("ip6").code?`[${o}]`:o}const pg={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://${fg(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://${fg(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`${fg(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`${fg(n[0],n[1]??"",t)}/p2p/${e}`},http:(e,t)=>{const n=hg(t),r=dg(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=fg(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`${fg(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 fg(n[0],n[1]??"",t)},sni:(e,t)=>{const n=t.pop();if(void 0===n)throw new Error("Unexpected end of multiaddr");return fg(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=fg(n[0],n[1]??"",t);return r=r.replace("tcp://",""),`https://${r}`},ws:(e,t)=>{const n=hg(t),r=dg(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=fg(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=fg(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`${fg(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`${fg(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`${fg(n[0],n[1]??"",t)}/p2p-webrtc-direct`}};const gg=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)}))},mg=(e,t)=>{(t=t??{}).closeOnEnd=!1!==t.closeOnEnd;return async n=>{for await(const t of n){try{await gg(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 yg=__webpack_require__(2605);function bg(e){return e instanceof ArrayBuffer||"ArrayBuffer"===e?.constructor?.name&&"number"===typeof e?.byteLength}const wg=(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 yg.PP((t=>{let{push:n,stop:r,fail:o}=t;const i=e=>{let t=null;"string"===typeof e.data&&(t=Dt(e.data)),bg(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 bg(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:mg(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}},vg=WebSocket,Eg={"http:":"ws:","https:":"wss:"};function Sg(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(Eg))n.protocol===r&&(n.protocol=o);return n})(e,"undefined"===typeof window?void 0:window.location),r=new vg(n.toString(),t.websocket);return wg(r,t)}class kg extends Event{type;detail;constructor(e,t){super(e),this.type=e,this.detail=t}}function Ag(e){return e.filter((e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return hf.matches(t)||pf.matches(t)}))}function _g(e){return e.filter((e=>{if(e.protoCodes().includes(290))return!1;const t=e.decapsulateCode(421);return pf.matches(t)}))}class Ig{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"})})}[lg]=!0;[Symbol.toStringTag]="@libp2p/websockets";[bd]=["@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 ps("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=Sg(function(e,t){const n=Bi(e).stringTuples(),r=n.pop();if(void 0===r)throw new Error("Unexpected end of multiaddr");const o=hi(r[0]),i=pg[o.name];if(null==i)throw new Error(`No interpreter found for ${o.name}`);let s=i(r[1]??"",n);return!1!==t?.assumeHttp&&ug.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 ps(`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 kg("websockets:open-connection")),await Pd(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):kp||xp?_g(e):Ag(e)}dialFilter(e){return this.listenFilter(e)}}function xg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return t=>new Ig(t,e)}const Cg=Symbol.for("@libp2p/content-routing"),Rg=Symbol.for("@libp2p/peer-routing"),Tg=1e3,Ng=60*Tg,Pg=60*Ng,Og=24*Pg,Lg=7*Og,Dg=365.25*Og;const Bg=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*Dg;case"weeks":case"week":case"w":return n*Lg;case"days":case"day":case"d":return n*Og;case"hours":case"hour":case"hrs":case"hr":case"h":return n*Pg;case"minutes":case"minute":case"mins":case"min":case"m":return n*Ng;case"seconds":case"second":case"secs":case"sec":case"s":return n*Tg;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>=Og)return Ug(e,t,Og,"day");if(t>=Pg)return Ug(e,t,Pg,"hour");if(t>=Ng)return Ug(e,t,Ng,"minute");if(t>=Tg)return Ug(e,t,Tg,"second");return`${e} ms`}(e):function(e){const t=Math.abs(e);if(t>=Og)return`${Math.round(e/Og)}d`;if(t>=Pg)return`${Math.round(e/Pg)}h`;if(t>=Ng)return`${Math.round(e/Ng)}m`;if(t>=Tg)return`${Math.round(e/Tg)}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 Ug(e,t,n,r){const o=t>=1.5*n;return`${Math.round(e/n)} ${r}${o?"s":""}`}const Mg=function(){try{return localStorage}catch(e){}}();const Fg=console.debug??console.log??(()=>{});const $g=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=Bg,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 ":" ")+"+"+Bg(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?Mg?.setItem("debug",e):Mg?.removeItem("debug")}catch(t){}},load:function(){let e;try{e=Mg?.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:Mg,log:Fg}),Hg=$g;function qg(){return{forComponent:e=>jg(e)}}function jg(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 Hg.enabled(`${e}:trace`)&&null!=Hg.names.map((e=>e.toString())).find((e=>e.includes(":trace")))&&(t=Hg(`${e}:trace`)),Object.assign(Hg(e),{error:Hg(`${e}:error`),trace:t})}function Vg(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}Hg.formatters.b=e=>null==e?"undefined":Ce.baseEncode(e),Hg.formatters.t=e=>null==e?"undefined":ye.baseEncode(e),Hg.formatters.m=e=>null==e?"undefined":Te.baseEncode(e),Hg.formatters.p=e=>null==e?"undefined":e.toString(),Hg.formatters.c=e=>null==e?"undefined":e.toString(),Hg.formatters.k=e=>null==e?"undefined":e.toString(),Hg.formatters.a=e=>null==e?"undefined":e.toString();class zg{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 Vg(this.set.entries(),(e=>{const t=Cd(e[0]);return[t,t]}))}forEach(e){this.set.forEach((t=>{const n=Cd(t);e(n,n,this)}))}has(e){return this.set.has(e.toString())}values(){return Vg(this.set.values(),(e=>Cd(e)))}intersection(e){const t=new zg;for(const n of e)this.has(n)&&t.add(n);return t}difference(e){const t=new zg;for(const n of this)e.has(n)||t.add(n);return t}union(e){const t=new zg;for(const n of e)t.add(n);for(const n of this)t.add(n);return t}}const Kg=async()=>{const e=await async function(e,t){return pd(e).generateKeyPair(t??2048)}("Ed25519"),t=await Wg(e);if("Ed25519"===t.type)return t;throw new Error(`Generated unexpected PeerId type "${t.type}"`)};async function Wg(e){return Td(md(e.public),(t=e,pd(n=(n??"rsa").toLowerCase()),t.bytes));var t,n}async function Gg(e){return Yg(Dt(e.id,"base58btc"),null!=e.privKey?Dt(e.privKey,"base64pad"):void 0,null!=e.pubKey?Dt(e.pubKey,"base64pad"):void 0)}async function Yg(e,t,n){if(null!=t){return Wg(await yd(t))}if(null!=n){return async function(e){return Td(md(e))}(gd(n))}const r=Rd(e);if("Ed25519"!==r.type&&"secp256k1"!==r.type&&"RSA"!==r.type)throw new Error("Supplied PeerID is invalid");return r}class Qg{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 Vg(this.map.entries(),(e=>[Cd(e[0]),e[1]]))}forEach(e){this.map.forEach(((t,n)=>{e(t,Cd(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 Vg(this.map.keys(),(e=>Cd(e)))}values(){return this.map.values()}get size(){return this.map.size}}var Jg=__webpack_require__(7465);class Xg extends Error{constructor(e){super(e),this.name="TimeoutError"}}class Zg extends Error{constructor(e){super(),this.name="AbortError",this.message=e}}const em=e=>void 0===globalThis.DOMException?new Zg(e):new DOMException(e),tm=e=>{const t=void 0===e.reason?em("This operation was aborted."):e.reason;return t instanceof Error?t:em(t)};function nm(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(tm(e)),e.addEventListener("abort",(()=>{l(tm(e))}))}if(n===Number.POSITIVE_INFINITY)return void e.then(a,l);const c=new Xg;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}class rm{#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 om extends Jg{#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:rm,...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=nm(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 Xg&&!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 im={},sm=e=>{e.addEventListener("message",(t=>{sm.dispatchEvent("message",e,t)})),null!=e.port&&e.port.addEventListener("message",(t=>{sm.dispatchEvent("message",e,t)}))};sm.addEventListener=(e,t)=>{null==im[e]&&(im[e]=[]),im[e].push(t)},sm.removeEventListener=(e,t)=>{null!=im[e]&&(im[e]=im[e].filter((e=>e===t)))},sm.dispatchEvent=function(e,t,n){null!=im[e]&&im[e].forEach((e=>e(t,n)))};const am=sm,lm="lock:worker:request-read",cm="lock:worker:release-read",um="lock:master:grant-read",dm="lock:worker:request-write",hm="lock:worker:release-write",fm="lock:master:grant-write",pm=(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?.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)}))}}}))},gm=(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?.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)}))},mm={singleProcess:!1},ym={};let bm;async function wm(e,t){let n;const r=new Promise((e=>{n=e}));return e.add((async()=>nm((async()=>{await new Promise((e=>{n((()=>{e()}))}))})(),{milliseconds:t.timeout}))),r}const vm={name:"lock",concurrency:1/0,timeout:846e5,singleProcess:!1};function Em(e){const t=Object.assign({},vm,e);return null==bm&&(bm=(e=>{if(e=Object.assign({},mm,e),Boolean(globalThis.document)||e.singleProcess){const e=new EventTarget;return am.addEventListener("message",pm(e,"requestReadLock",lm,cm,um)),am.addEventListener("message",pm(e,"requestWriteLock",dm,hm,fm)),e}return{isWorker:!0,readLock:e=>gm(e,lm,um,cm),writeLock:e=>gm(e,dm,fm,hm)}})(t),!0!==bm.isWorker&&(bm.addEventListener("requestReadLock",(e=>{null!=ym[e.data.name]&&ym[e.data.name].readLock().then((async t=>e.data.handler().finally((()=>{t()}))))})),bm.addEventListener("requestWriteLock",(async e=>{null!=ym[e.data.name]&&ym[e.data.name].writeLock().then((async t=>e.data.handler().finally((()=>{t()}))))})))),null==ym[t.name]&&(ym[t.name]=((e,t)=>{if(!0===bm.isWorker)return{readLock:bm.readLock(e,t),writeLock:bm.writeLock(e,t)};const n=new om({concurrency:1});let r;return{async readLock(){if(null!=r)return wm(r,t);r=new om({concurrency:t.concurrency,autoStart:!1});const e=r,o=wm(r,t);return n.add((async()=>{e.start(),await e.onIdle().then((()=>{r===e&&(r=null)}))})),o},writeLock:async()=>(r=null,wm(n,t))}})(t.name,t)),ym[t.name]}const Sm="ERR_INVALID_PARAMETERS";var km,Am,_m;function Im(e,t){const n=km.decode(t);null!=n.publicKey&&null==e.publicKey&&(e=function(e){if("RSA"===e.type)return new kd(e);if("Ed25519"===e.type)return new Ad(e);if("secp256k1"===e.type)return new _d(e);throw new ps("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:Bi(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),_m.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=_m.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),Am.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(Am.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())}(km||(km={})),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())}(Am||(Am={})),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())}(_m||(_m={}));const xm="/",Cm=(new TextEncoder).encode(xm),Rm=Cm[0];class Tm{_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]!==Rm)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 Tm(e.join(xm))}static random(){return new Tm(Math.random().toString().substring(2))}static asKey(e){return e instanceof Uint8Array||"string"===typeof e?new Tm(e):"function"===typeof e.uint8Array?new Tm(e.uint8Array()):null}clean(){if(null!=this._buf&&0!==this._buf.byteLength||(this._buf=Cm),this._buf[0]!==Rm){const e=new Uint8Array(this._buf.byteLength+1);e.fill(Rm,0,1),e.set(this._buf,1),this._buf=e}for(;this._buf.byteLength>1&&this._buf[this._buf.byteLength-1]===Rm;)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 Tm.withNamespaces(this.list().slice().reverse())}namespaces(){return this.list()}baseNamespace(){const e=this.namespaces();return e[e.length-1]}list(){return this.toString().split(xm).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 Tm(this.toString()+":"+e)}path(){let e=this.parent().toString();return e.endsWith(xm)||(e+=xm),e+=this.type(),new Tm(e)}parent(){const e=this.list();return 1===e.length?new Tm(xm):new Tm(e.slice(0,-1).join(xm))}child(e){return this.toString()===xm?e:e.toString()===xm?this:new Tm(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 Tm.withNamespaces([...this.namespaces(),...(r=t.map((e=>e.namespaces())),[].concat(...r))]);var r}}const Nm="/peers/";function Pm(e){if(!ti(e)||null==e.type)throw new ps("Invalid PeerId",Sm);const t=e.toCID().toString();return new Tm(`${Nm}${t}`)}async function Om(e,t,n){const r=new Map;for(const o of n){if(null==o)continue;if(o.multiaddr instanceof Uint8Array&&(o.multiaddr=Bi(o.multiaddr)),!Di(o.multiaddr))throw new ps("Multiaddr was invalid",Sm);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 Lm(e,t,n,r){if(null==t)throw new ps("Invalid PeerData",Sm);if(null!=t.publicKey&&null!=e.publicKey&&!Ur(t.publicKey,e.publicKey))throw new ps("publicKey bytes do not match peer id publicKey bytes",Sm);const o=r.existingPeer;if(null!=o&&!e.equals(o.id))throw new ps("peer id did not match existing peer id",Sm);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=Dm(t.metadata instanceof Map?[...t.metadata.entries()]:Object.entries(t.metadata),{validate:Bm})}if(null!=t.tags){l=Dm(t.tags instanceof Map?[...t.tags.entries()]:Object.entries(t.tags),{validate:Um,map:Mm})}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=Dm([...a.entries()],{validate:Bm})}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=Dm([...n.entries()],{validate:Um,map:Mm})}null!=t.peerRecordEnvelope&&(c=t.peerRecordEnvelope)}const u={addresses:await Om(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 Dm(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 Bm(e,t){if("string"!==typeof e)throw new ps("Metadata key must be a string",Sm);if(!(t instanceof Uint8Array))throw new ps("Metadata value must be a Uint8Array",Sm)}function Um(e,t){if("string"!==typeof e)throw new ps("Tag name must be a string",Sm);if(null!=t.value){if(parseInt(`${t.value}`,10)!==t.value)throw new ps("Tag value must be an integer",Sm);if(t.value<0||t.value>100)throw new ps("Tag value must be between 0-100",Sm)}if(null!=t.ttl){if(parseInt(`${t.ttl}`,10)!==t.ttl)throw new ps("Tag ttl must be an integer",Sm);if(t.ttl<0)throw new ps("Tag ttl must be between greater than 0",Sm)}}function Mm(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 Fm(e,t,n){const r=e.toString().split("/")[2],o=Rd(ye.decode(r)),i=n.get(o);if(null!=i)return i;const s=Im(o,t);return n.set(o,s),s}class $m{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=Em({name:"peer-store",singleProcess:!0})}async has(e){return this.datastore.has(Pm(e))}async delete(e){if(this.peerId.equals(e))throw new ps("Cannot delete self peer",Sm);await this.datastore.delete(Pm(e))}async load(e){return Im(e,await this.datastore.get(Pm(e)))}async save(e,t){const{existingBuf:n,existingPeer:r}=await this.#T(e),o=await Lm(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 Lm(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 Lm(e,t,"merge",{addressFilter:this.addressFilter,existingPeer:r});return this.#N(e,o,n,r)}async*all(e){const t=new Qg;for await(const{key:n,value:r}of this.datastore.query(function(e,t){return null==e?{}:{prefix:Nm,filters:(e.filters??[]).map((e=>n=>{let{key:r,value:o}=n;return e(Fm(r,o,t))})),orders:(e.orders??[]).map((e=>(n,r)=>e(Fm(n.key,n.value,t),Fm(r.key,r.value,t))))}}(e??{},t))){const e=Fm(n,r,t);e.id.equals(this.peerId)||(yield e)}}async#T(e){try{const t=await this.datastore.get(Pm(e));return{existingBuf:t,existingPeer:Im(e,t)}}catch(t){if("ERR_NOT_FOUND"!==t.code)throw t}return{}}async#N(e,t,n,r){const o=km.encode(t);return null!=n&&Ur(o,n)?{peer:Im(e,o),previous:r,updated:!1}:(await this.datastore.put(Pm(e),o),{peer:Im(e,o),previous:r,updated:!0})}}class Hm{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 $m(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 Ff.openAndCertify(e,Bf.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=Bf.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 Ff.createFromProtobuf(o.peerRecordEnvelope),t=Bf.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 qm=function(e){if(null!=e[Symbol.asyncIterator])return(async()=>{for await(const t of e);})();for(const t of e);};const jm=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 Vm=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=jm(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 zm=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 Km=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 Wm{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 qm(this.putMany(e,n)),e=[],await qm(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=Vm(n,(e=>e.key.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(n=e.filters.reduce(((e,t)=>Vm(e,t)),n)),Array.isArray(e.orders)&&(n=e.orders.reduce(((e,t)=>zm(e,t)),n)),null!=e.offset){let t=0;const r=e.offset;n=Vm(n,(()=>t++>=r))}return null!=e.limit&&(n=Km(n,e.limit)),n}queryKeys(e,t){let n=this._allKeys(e,t);if(null!=e.prefix){const t=e.prefix;n=Vm(n,(e=>e.toString().startsWith(t)))}if(Array.isArray(e.filters)&&(n=e.filters.reduce(((e,t)=>Vm(e,t)),n)),Array.isArray(e.orders)&&(n=e.orders.reduce(((e,t)=>zm(e,t)),n)),null!=e.offset){const t=e.offset;let r=0;n=Vm(n,(()=>r++>=t))}return null!=e.limit&&(n=Km(n,e.limit)),n}}var Gm=__webpack_require__(4823);class Ym extends Wm{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"),Gm(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 Tm(e),value:t}}*_allKeys(){for(const e of this.data.keys())yield new Tm(e)}}const Qm=e=>e;function Jm(e,t){const n=e.getPeerId();if(null!=n){Cd(n).equals(t)&&(e=e.decapsulate(Bi(`/p2p/${t.toString()}`)))}return e}class Xm{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??Qm,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 Bi(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=>Bi(e)))}getAnnounceAddrs(){return Array.from(this.announce).map((e=>Bi(e)))}getObservedAddrs(){return Array.from(this.observed).map((e=>{let[t]=e;return Bi(t)}))}addObservedAddr(e){const t=(e=Jm(e,this.components.peerId)).toString();this.observed.has(t)||this.observed.set(t,{confident:!1})}confirmObservedAddr(e){const t=(e=Jm(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=Jm(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=>Bi(e)))).map((e=>!0===e.protos().pop()?.path||e.getPeerId()===this.components.peerId.toString()?e:e.encapsulate(`/p2p/${this.components.peerId.toString()}`)))}}function Zm(e){return null!=e&&"function"===typeof e.start&&"function"===typeof e.stop}class ey{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=qg())}isStarted(){return this._started}async _invokeStartableMethod(e){await Promise.all(Object.values(this.components).filter((e=>Zm(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 ty=["metrics","connectionProtector","dns"],ny=["components","isStarted","beforeStart","start","afterStart","beforeStop","stop","afterStop","then","_invokeStartableMethod"];function ry(e){return Array.isArray(e?.[bd])?e[bd]:[]}function oy(e){return Array.isArray(e?.[wd])?e[wd]:[]}function iy(e){return e?.[Symbol.toStringTag]??e?.toString()??"unknown"}var sy=__webpack_require__(7364);const ay=["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 sy.Netmask(e)));function ly(e){for(const t of ay)if(t.contains(e))return!0;return!1}function cy(e){return ri(e)?ly(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 ly(`${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 ly(t[t.length-1])}(e):oi(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 uy(){return{denyDialPeer:async()=>!1,denyDialMultiaddr:async e=>{const t=e.stringTuples();return(4===t[0][0]||41===t[0][0])&&Boolean(cy(`${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 dy(e){try{const{address:t}=e.nodeAddress();return Boolean(cy(t))}catch{return!0}}function hy(e,t){const n=function(e,t){const n=dy(e.multiaddr),r=dy(t.multiaddr);return n&&!r?1:!n&&r?-1:0}(e,t);if(0!==n)return n;const r=function(e,t){const n=yp.exactMatch(e.multiaddr),r=yp.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 fy(e){const t=[wy.A];return null==e?t:Array.isArray(e)?0===e.length?t:e:[e]}function py(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:wy[e.type]}))),Answer:(e.Answer??e.answers??[]).map((e=>({name:e.name,type:wy[e.type],TTL:e.TTL??e.ttl??60,data:e.data instanceof Uint8Array?dr(e.data):e.data})))}}function gy(e){const t=new om({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),fy(r.types).forEach((e=>{o.append("type",wy[e])})),r.onProgress?.(new kg("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=py(await t.json());return r.onProgress?.(new kg("dns:response",{detail:n})),n}),{signal:r.signal});if(null==i)throw new Error("No DNS response received");return i}}var my=__webpack_require__(101);class yy{lru;constructor(e){this.lru=my(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 py({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:wy[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 by{resolvers;cache;constructor(e){var t;this.resolvers={},this.cache=(t=e.cacheSize??1e3,new yy(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["."]=[gy("https://cloudflare-dns.com/dns-query"),gy("https://dns.google/resolve")])}async query(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=fy(t.types),r=!1!==t.cached?this.cache.get(e,n):void 0;if(null!=r)return t.onProgress?.(new kg("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 kg("dns:error",{detail:a}))}}if(1===s.length)throw s[0];throw new AggregateError(s,`DNS lookup of ${e} ${n} failed`)}}var wy;!function(e){e[e.A=1]="A",e[e.CNAME=5]="CNAME",e[e.TXT=16]="TXT",e[e.AAAA=28]="AAAA"}(wy||(wy={}));const{code:vy}=hi("dnsaddr");class Ey extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Max recursive depth reached"),this.name="RecursionLimitError"}}const Sy=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=t.maxRecursiveDepth??32;if(0===n)throw new Ey("Max recursive depth reached");const[,r]=e.stringTuples().find((e=>{let[t]=e;return t===vy}))??[],o=t?.dns??function(){return new by(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}(),i=await o.query(`_dnsaddr.${r}`,{signal:t?.signal,types:[wy.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=Bi(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 ky=__webpack_require__(8355);var Ay,_y;!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"}(Ay||(Ay={})),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"}(_y||(_y={}));const Iy={addresses:{listen:[],announce:[],noAnnounce:[],announceFilter:e=>e},connectionManager:{resolvers:{dnsaddr:Sy},addressSorter:hy},transportManager:{faultTolerance:cg.FATAL_ALL}};function xy(e){if(ti(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:Cd(n),e.forEach((e=>{if(!Di(e))throw new ps("Invalid Multiaddr",_y.ERR_INVALID_MULTIADDR);const n=e.getPeerId();if(null==n){if(null!=t)throw new ps("Multiaddrs must all have the same peer id or have no peer id",_y.ERR_INVALID_PARAMETERS)}else{const e=Cd(n);if(!0!==t?.equals(e))throw new ps("Multiaddrs must all have the same peer id or have no peer id",_y.ERR_INVALID_PARAMETERS)}}))}return{peerId:t,multiaddrs:e}}class Cy 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 Ry(e,t,n,r){const o=new Cy(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 Ty{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 fs)}cleanup(){this.signal?.removeEventListener("abort",this.onAbort)}}class Ny{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,Ho(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 fs),this.cleanup())}async join(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=new Ty(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 Pd(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 Py extends qo{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 Ny(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 fs)})),this.clear()}async onEmpty(e){0!==this.size&&await Ry(this,"empty",e?.signal)}async onSizeLessThan(e,t){this.size<e||await Ry(this,"next",t?.signal,{filter:()=>this.size<e})}async onIdle(e){0===this.pending&&0===this.size||await Ry(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 ps("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 Oy extends Py{has(e){return null!=this.find(e)}find(e){return this.queue.find((t=>e.equals(t.options.peerId)))}}const Ly=42e4,Dy="last-dial-failure",By={minConnections:5,maxQueueLength:100,autoDialConcurrency:25,autoDialPriority:0,autoDialInterval:5e3,autoDialPeerRetryThreshold:Ly,autoDialDiscoveredPeersDebounce:10};class Uy{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??By.minConnections,this.autoDialPriority=t.autoDialPriority??By.autoDialPriority,this.autoDialIntervalMs=t.autoDialInterval??By.autoDialInterval,this.autoDialMaxQueueLength=t.maxQueueLength??By.maxQueueLength,this.autoDialPeerRetryThresholdMs=t.autoDialPeerRetryThreshold??By.autoDialPeerRetryThreshold,this.autoDialDiscoveredPeersDebounce=t.autoDialDiscoveredPeersDebounce??By.autoDialDiscoveredPeersDebounce,this.log=e.logger.forComponent("libp2p:connection-manager:auto-dial"),this.started=!1,this.running=!1,this.queue=new Oy({concurrency:t.autoDialConcurrency??By.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 zg(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 Qg;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(Dy);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 My=["/ipfs/id/1.0.0","/ipfs/id/push/1.0.0","/libp2p/autonat/1.0.0","/libp2p/dcutr"];const Fy={maxConnections:100,allow:[]};class $y{maxConnections;connectionManager;peerStore;allow;events;log;constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.maxConnections=t.maxConnections??Fy.maxConnections,this.allow=t.allow??Fy.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 Qg;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??My;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 Hy extends Py{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 qy(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 jy={addressSorter:hy,maxParallelDials:50,maxDialQueueLength:500,maxPeerAddrsToDial:25,dialTimeout:5e3,resolvers:{dnsaddr:Sy}};class Vy{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??jy.addressSorter,this.maxPeerAddrsToDial=t.maxPeerAddrsToDial??jy.maxPeerAddrsToDial,this.maxDialQueueLength=t.maxDialQueueLength??jy.maxDialQueueLength,this.dialTimeout=t.dialTimeout??jy.dialTimeout,this.connections=t.connections??new Qg,this.log=e.logger.forComponent("libp2p:connection-manager:dial-queue"),this.components=e,this.shutDownController=new AbortController,Ho(1/0,this.shutDownController.signal);for(const[n,r]of Object.entries(t.resolvers??{}))Li.set(n,r);this.queue=new Hy({concurrency:t.maxParallelDials??jy.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,Ho(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}=xy(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 kg("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 kg("dial-queue:already-in-dial-queue")),i.join(t)}if(this.queue.size>=this.maxDialQueueLength)throw new ps("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 kg("dial-queue:add-to-dial-queue")),this.queue.add((async e=>{e?.onProgress?.(new kg("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 kg("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 ps("Peer had more than maxPeerAddrsToDial",_y.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:{[Dy]: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 ps(o.message,ms);s.push(o)}}if(1===s.length)throw s[0];throw new gs(s,"All multiaddr dials failed",_y.ERR_TRANSPORT_DIAL_FAILED)}finally{t.clear()}}),{peerId:n,priority:t.priority??zy,multiaddrs:new Set(r.map((e=>e.toString()))),signal:t.signal,onProgress:t.onProgress})}createDialAbortController(e){const t=qy([AbortSignal.timeout(this.dialTimeout),this.shutDownController.signal,e]);return Ho(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:Bi(e),isCertified:!1})));if(null!=e){if(this.components.peerId.equals(e))throw new ps("Tried to dial self",_y.ERR_DIALED_SELF);if(!0===await(this.components.connectionGater.denyDialPeer?.(e)))throw new ps("The dial request is blocked by gater.allowDialPeer",_y.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!==_y.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!==_y.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 Li.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 ps("The dial request has no valid addresses",_y.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 ps("The connection gater denied all addresses in the dial request",_y.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=>!yp.matches(e.multiaddr)))}catch(n){this.log.trace("error calculating if multiaddr(s) were dialable",n)}return!1}}const zy=50,Ky={minConnections:5,maxConnections:100,inboundConnectionThreshold:5,maxIncomingPendingConnections:10,autoDialConcurrency:25,autoDialPriority:0,autoDialMaxQueueLength:100,autoDialPeerRetryThreshold:Ly,autoDialDiscoveredPeersDebounce:10};class Wy{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??Ky.maxConnections;const n=t.minConnections??Ky.minConnections;if(this.maxConnections<n)throw new ps("Connection Manager maxConnections must be greater than minConnections",_y.ERR_INVALID_PARAMETERS);this.connections=new Qg,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=>Bi(e))),this.deny=(t.deny??[]).map((e=>Bi(e))),this.incomingPendingConnections=0,this.maxIncomingPendingConnections=t.maxIncomingPendingConnections??Ky.maxIncomingPendingConnections,this.inboundConnectionRateLimiter=new Mp({points:t.inboundConnectionThreshold??Ky.inboundConnectionThreshold,duration:1}),this.autoDial=new Uy({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{minConnections:n,autoDialConcurrency:t.autoDialConcurrency??Ky.autoDialConcurrency,autoDialPriority:t.autoDialPriority??Ky.autoDialPriority,autoDialPeerRetryThreshold:t.autoDialPeerRetryThreshold??Ky.autoDialPeerRetryThreshold,autoDialDiscoveredPeersDebounce:t.autoDialDiscoveredPeersDebounce??Ky.autoDialDiscoveredPeersDebounce,maxQueueLength:t.autoDialMaxQueueLength??Ky.autoDialMaxQueueLength}),this.connectionPruner=new $y({connectionManager:this,peerStore:e.peerStore,events:e.events,logger:e.logger},{maxConnections:this.maxConnections,allow:this.allow}),this.dialQueue=new Vy(e,{addressSorter:t.addressSorter??hy,maxParallelDials:t.maxParallelDials??50,maxDialQueueLength:t.maxDialQueueLength??500,maxPeerAddrsToDial:t.maxPeerAddrsToDial??25,dialTimeout:t.dialTimeout??5e3,resolvers:t.resolvers??{dnsaddr:Sy},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 ps("Not started",_y.ERR_NODE_NOT_STARTED);t.signal?.throwIfAborted();const{peerId:n}=xy(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 kg("dial-queue:already-connected")),e}const r=await this.dialQueue.dial(e,{...t,priority:t.priority??zy});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=>Bi(e)))})))}async isDialable(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.dialQueue.isDialable(e,t)}}class Gy{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 Yy{success;failure;next;metric;timeoutMultiplier;failureMultiplier;minTimeout;constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.success=new Gy(e.interval??5e3),this.failure=new Gy(e.interval??5e3),this.next=new Gy(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=qy([e.signal,n]);return Ho(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 Qy{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 Yy({...t.pingTimeout??{},metrics:e.metrics,metricName:"libp2p_connection_monitor_ping_time_milliseconds"})}[Symbol.toStringTag]="@libp2p/connection-monitor";[bd]=["@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=Ud(await e.newStream(this.protocol,{signal:n,runOnTransientConnection:!0}));t=Date.now(),await Promise.all([r.write(Tu(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 Jy{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 ps("No content routers available",_y.ERR_NO_ROUTERS_AVAILABLE);const r=t,o=new zg;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 ps("No content routers available",_y.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 ps(Ay.NOT_STARTED_YET,_y.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 ps(Ay.NOT_STARTED_YET,_y.ERR_NODE_NOT_STARTED);return Promise.any(this.routers.map((async n=>n.get(e,t))))}}class Xy{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 Zy(e,t){return Math.floor(Math.random()*(t-e))+e}class eb{contents;constructor(e){this.contents=new Array(e).fill(null)}has(e){if(!(e instanceof Xy))throw new TypeError("Invalid Fingerprint");return this.contents.some((t=>e.equals(t)))}add(e){if(!(e instanceof Xy))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 Xy))throw new TypeError("Invalid Fingerprint");const t=Zy(0,this.contents.length-1),n=this.contents[t];return this.contents[t]=e,n}remove(e){if(!(e instanceof Xy))throw new TypeError("Invalid Fingerprint");const t=this.contents.findIndex((t=>e.equals(t)));return t>-1&&(this.contents[t]=null,!0)}}const tb={32:16777619n,64:1099511628211n,128:309485009821345068724781371n,256:374144419156711147060143317175368453031918731002211n,512:35835915874844867368919076489095108449946327955754392558399825615420669938882575126094039892345713852759n,1024:5016456510113118655434598811035278955030765345404790744303017523831112055108147451509157692220295382716162651878526895249385292291816524375083746691371804094271873160484737966720260389217684476157468082573n},nb={32:2166136261n,64:14695981039346656037n,128:144066263297769815596495629667062367629n,256:100029257958052580907070968620625704837092796014241193945225284501741471925557n,512:9659303129496669498009435400716310466090418745672637896108374329434462657994582932197716438449813051892206539805784495328239340083876191928701583869517785n,1024:14197795064947621068722070641403218320880622795441933960878474914617582723252296732303717722150864096521202355549365628174669108571814760471015076148029755969804077320157692458563003215304957150157403644460363550505412711285966361610267868082893823963790439336411086884584107735010676915n},rb=new globalThis.TextEncoder;function ob(e){let{size:t=32,utf8Buffer:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!tb[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=tb[t];let o=nb[t],i=e;for(;i.length>0;){const e=rb.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=rb.encode(e)}return function(e,t){const n=tb[t];let r=nb[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 ib={hash:e=>Number(ob(e,{size:32})),hashV:(e,t)=>sb(ib.hash(e,t))};function sb(e){let t=e.toString(16);return t.length%2===1&&(t=`0${t}`),Dt(t,"base16")}class ab{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??ib,this.seed=e.seed??Zy(0,Math.pow(2,10))}add(e){"string"===typeof e&&(e=Dt(e));const t=new Xy(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 eb(this.bucketSize)),null==this.buckets[r]&&(this.buckets[r]=new eb(this.bucketSize)),this.buckets[n].add(t)||this.buckets[r].add(t))return this.count++,!0;const o=[n,r];let i=o[Zy(0,o.length-1)];null==this.buckets[i]&&(this.buckets[i]=new eb(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 eb(this.bucketSize)),this.buckets[i].add(e)))return this.count++,!0}return!1}has(e){"string"===typeof e&&(e=Dt(e));const t=new Xy(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 Xy(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 lb={1:.5,2:.84,4:.95,8:.98};function cb(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=lb[n];return{filterSize:Math.round(e/r),bucketSize:n,fingerprintSize:Math.min(Math.ceil(Math.log2(1/t)+Math.log2(2*n)),64)}}class ub{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??ib,this.seed=e.seed??Zy(0,Math.pow(2,10)),this.filterSeries=[new ab({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 ab({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 db=globalThis.CustomEvent??Event;class hb{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 ps("No peer routers available",_y.ERR_NO_ROUTERS_AVAILABLE);if(e.toString()===this.peerId.toString())throw new ps("Should not try to find self",_y.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 ps(Ay.NOT_FOUND,_y.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 ps("No peer routers available",_y.ERR_NO_ROUTERS_AVAILABLE);const r=t,o=function(e){let t=arguments.length>2?arguments[2]:void 0;return new ub({...cb(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 db("task-complete"))}),(t=>{e.done=!0,e.err=t,o.dispatchEvent(new db("task-complete"))}))}c=!0,o.dispatchEvent(new db("task-complete"))}catch(t){s=t,o.dispatchEvent(new db("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 fb extends qo{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,Ho(1/0,this.shutdownController.signal)}[Symbol.toStringTag]="@libp2p/random-walk";start(){this.shutdownController=new AbortController,Ho(1/0,this.shutdownController.signal)}stop(){this.shutdownController.abort()}async*walk(e){this.walking||this.startWalk(),this.walkers++;const t=qy([this.shutdownController.signal,e?.signal]);Ho(1/0,t);try{for(;;){this.needNext?.resolve(),this.needNext=Xr();const e=await Ry(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,Ho(1/0,this.walkController.signal);const e=qy([this.walkController.signal,this.shutdownController.signal]);Ho(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=Tu(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 Pd(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 pb{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 ps(`No handler registered for protocol ${e}`,_y.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 ps(`Handler already registered for protocol ${e}`,_y.ERR_PROTOCOL_HANDLER_ALREADY_REGISTERED);const r=ky.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 ps("invalid topology",_y.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!==_y.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 gb 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 mb{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 gb({name:t,metrics:n}):new Map,r}({name:"libp2p_transport_manager_listeners",metrics:this.components.metrics}),this.faultTolerance=t.faultTolerance??cg.FATAL_ALL}[Symbol.toStringTag]="@libp2p/transport-manager";add(e){const t=e[Symbol.toStringTag];if(null==t)throw new ps("Transport must have a valid tag",_y.ERR_INVALID_KEY);if(this.transports.has(t))throw new ps(`There is already a transport with the tag ${t}`,_y.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 ps(`No transport available for address ${String(e)}`,_y.ERR_TRANSPORT_UNAVAILABLE);t?.onProgress?.(new kg("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=_y.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 ps("Not started",_y.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!==cg.NO_FATAL)throw new ps(`Transport (${n}) could not listen on any available address`,_y.ERR_NO_VALID_ADDRESSES)}if(t.length===this.transports.size){const e=`no valid addresses were provided for transports [${t.join(", ")}]`;if(this.faultTolerance===cg.FATAL_ALL)throw new ps(e,_y.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 yb="/multistream/1.0.0",bb=1024,wb=Dt("\n");async function vb(e,t,n){await e.write(t,n)}async function Eb(e,t){const n=await async function(e,t){const n=await e.read(t);if(0===n.byteLength||n.get(n.byteLength-1)!==wb[0])throw t.log.error("Invalid mss message - missing newline",n),new ps("missing newline","ERR_INVALID_MULTISTREAM_SELECT_MESSAGE");return n.sublist(0,-1)}(e,t);return dr(n.subarray())}async function Sb(e,t,n){t=Array.isArray(t)?t:[t],n.log.trace("handle: available protocols %s",t);const r=Hd(e,{...n,maxDataLength:bb,maxLengthLength:2});for(;;){n.log.trace("handle: reading incoming string");const e=await Eb(r,n);if(n.log.trace('handle: read "%s"',e),e!==yb){if(t.includes(e))return n.log.trace('handle: respond with "%s" for "%s"',e,e),await vb(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 vb(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 vb(r,o,n),n.log.trace('handle: responded with "%s" for %s',t,e)}}else n.log.trace('handle: respond with "%s" for "%s"',yb,e),await vb(r,Dt(`${yb}\n`),n),n.log.trace('handle: responded with "%s" for "%s"',yb,e)}}async function kb(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=Hd({sink:r,source:o},{...n,maxDataLength:bb});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',yb,t),await p.writeV([Dt(`${yb}\n`),Dt(`${t}\n`)]),n.log.trace('optimistic: wrote ["%s", "%s", data] in source',yb,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 Eb(p,n);if(n.log.trace('optimistic: read multistream select header "%s"',e),e===yb&&(e=await Eb(p,n)),n.log.trace('optimistic: read protocol "%s", expecting "%s"',e,t),e!==t)throw new ps("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',yb,t,o.byteLength);const e=`${t}\n`;yield new Hr(Uint8Array.from([19]),Dt(`${yb}\n`),L(e.length),Dt(e),o).subarray(),n.log.trace('optimistic: wrote ["%s", "%s", data(%d)] in sink',yb,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 Pd(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=Hd(e,{...n,maxDataLength:bb}),o=t.shift();if(null==o)throw new Error("At least one protocol must be specified");n.log.trace('select: write ["%s", "%s"]',yb,o);const i=Dt(`${yb}\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 Eb(r,n);if(n.log.trace('select: read "%s"',a),a===yb&&(n.log.trace("select: reading protocol response"),a=await Eb(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 vb(r,Dt(`${l}\n`),n),n.log.trace("select: reading protocol response");const e=await Eb(r,n);if(n.log.trace('select: read "%s" for "%s"',e,l),e===l)return{stream:r.unwrap(),protocol:l}}throw new ps("protocol selection failed","ERR_UNSUPPORTED_PROTOCOL")}const Ab=Symbol.for("@libp2p/connection");class _b{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";[Ab]=!0;get streams(){return this._getStreams()}async newStream(e,t){if("closing"===this.status)throw new ps("the connection is being closed","ERR_CONNECTION_BEING_CLOSED");if("closed"===this.status)throw new ps("the connection is closed","ERR_CONNECTION_CLOSED");if(Array.isArray(e)||(e=[e]),this.transient&&!0!==t?.runOnTransientConnection)throw new ps("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);Ho(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 Ib(e,t,n){let r=0;return n.streams.forEach((n=>{n.direction===t&&n.protocol===e&&r++})),r}class xb{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 ps(`The multiaddr connection is blocked by gater.${n}`,_y.ERR_CONNECTION_INTERCEPTED)}async upgradeInbound(e,t){if(!await this.components.connectionManager.acceptIncomingConnection(e))throw new ps("connection denied",_y.ERR_CONNECTION_DENIED);let n,r,o,i,s;const a=AbortSignal.timeout(this.inboundUpgradeTimeout),l=()=>{e.abort(new ps("inbound upgrade timeout",ms))};a.addEventListener("abort",l,{once:!0}),Ho(1/0,a);try{if(!0===await(this.components.connectionGater.denyInboundConnection?.(e)))throw new ps("The multiaddr connection is blocked by gater.acceptConnection",_y.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 kg("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 ps("inbound connection that skipped encryption must have a peer id",_y.ERR_INVALID_MULTIADDR);const n=Cd(t);s="native",r=n}if(o=n,null!=t?.muxerFactory)i=t.muxerFactory;else if(this.muxers.size>0){t?.onProgress?.(new kg("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=Cd(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 ps("Encryption was skipped but no peer id was passed",_y.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 Sb(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!==_y.ERR_NO_HANDLER_FOR_PROTOCOL)throw n}return 32}(r,this.components.registrar);if(Ib(r,"inbound",d)===o){const t=new ps(`Too many inbound protocol streams for protocol "${r}" - limit ${o}`,_y.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 ps("Stream is not multiplexed",_y.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);Ho(1/0,t),n={...n,signal:t}}r.log.trace("selecting protocol from protocols %s",e);const{stream:o,protocol:i}=await kb(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!==_y.ERR_NO_HANDLER_FOR_PROTOCOL)throw r}return n.maxOutboundStreams??64}(i,t.components.registrar,n),l=Ib(i,"outbound",d);if(l>=a){const e=new ps(`Too many outbound protocol streams for protocol "${i}" - ${l}/${a}`,_y.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 ps(String(o),_y.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 ps("connection is not multiplexed",_y.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 _b(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 ps("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 Sb(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 ps(n.message,_y.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 kb(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 ps(r.message,_y.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 kb(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 ps(String(r),_y.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 Sb(e,n,{log:e.log});return{stream:r,muxerFactory:t.get(o)}}catch(r){throw e.log.error("error multiplexing inbound connection",r),new ps(String(r),_y.ERR_MUXER_UNAVAILABLE)}}}class Cb extends qo{peerId;peerStore;contentRouting;peerRouting;metrics;services;logger;status;components;log;constructor(e){super(),this.status="stopped";const t=new qo,n=t.dispatchEvent.bind(t);t.dispatchEvent=e=>{const t=n(e),r=this.dispatchEvent(new jo(e.type,{detail:e.detail}));return t||r},Ho(1/0,t),this.peerId=e.peerId,this.logger=e.logger??qg(),this.log=this.logger.forComponent("libp2p"),this.services={};const r=this.components=function(){const e=new ey(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{});return new Proxy(e,{get(t,n,r){if("string"===typeof n&&!ny.includes(n)){const t=e.components[n];if(null==t&&!ty.includes(n))throw new ps(`${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 Ym,connectionGater:uy(e.connectionGater),dns:e.dns});this.peerStore=this.configureComponent("peerStore",new Hm(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 xb(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 mb(this.components,e.transportManager)),this.configureComponent("connectionManager",new Wy(this.components,e.connectionManager)),!1!==e.connectionMonitor?.enabled&&this.configureComponent("connectionMonitor",new Qy(this.components,e.connectionMonitor)),this.configureComponent("registrar",new pb(this.components)),this.configureComponent("addressManager",new Xm(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 hb(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 Jy(this.components,{routers:i})),this.configureComponent("randomWalk",new fb(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[Cg]&&(this.log("registering service %s for content routing",s),i.push(t[Cg])),null!=t[Rg]&&(this.log("registering service %s for peer routing",s),o.push(t[Rg])),null!=t[Zh]&&(this.log("registering service %s for peer discovery",s),t[Zh].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 ry(n))t[e]=!0;for(const n of Object.values(e.components))for(const e of oy(n))if(!0!==t[e])throw new ps(`Service "${iy(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 zg;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 ps("no protocols were provided to open a stream",_y.ERR_INVALID_PROTOCOLS_FOR_STREAM);if(0===(t=Array.isArray(t)?t:[t]).length)throw new ps("no protocols were provided to open a stream",_y.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]:{};Di(e)&&(e=Cd(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!==_y.ERR_NOT_FOUND)throw o}const n=Br([Dt("/pk/"),e.multihash.digest]),r=await this.contentRouting.get(n,t);return gd(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(_y.ERR_DISCOVERED_SELF))}}async function Rb(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.peerId??=await Kg();if(null==t.privateKey)throw new ps("peer id was missing private key","ERR_MISSING_PRIVATE_KEY");return e.privateKey??=await yd(t.privateKey),new Cb(await async function(e){const t=ky(Iy,e);if(null===t.connectionProtector&&null!=globalThis.process?.env?.LIBP2P_FORCE_PNET)throw new ps(Ay.ERR_PROTECTOR_REQUIRED,_y.ERR_PROTECTOR_REQUIRED);if(null!=t.privateKey&&!(await Td(t.privateKey.public.bytes,t.privateKey.bytes)).equals(t.peerId))throw new ps("Private key doesn't match peer id",_y.ERR_INVALID_KEY);return t}(e))}const Tb="enrtree://AIRVQ5DDA4FFWLRBCHJWUWOO6X6S4ZTZ5B667LQ6AJU6PEYDLRD5O@sandbox.waku.nodes.status.im",Nb="enrtree://AOGYWMBYOUIMOENHXCHILPKY3ZRFEULMFI4DOM442QSZ73TT2A7VI@test.waku.nodes.status.im",Pb="bootstrap",Ob={store:1,filter:2,lightPush:2};var Lb=__webpack_require__(495),Db=__webpack_require__.t(Lb,2);const Bb=BigInt(0),Ub=BigInt(1),Mb=BigInt(2),Fb=BigInt(3),$b=BigInt(8),Hb=Object.freeze({a:Bb,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:Ub,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),qb=(e,t)=>(e+t/Mb)/t,jb={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(e){const{n:t}=Hb,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-Ub*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),o=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=n,s=BigInt("0x100000000000000000000000000000000"),a=qb(i*e,t),l=qb(-r*e,t);let c=gw(e-a*n-l*o,t),u=gw(-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}}},Vb=32,zb=32;function Kb(e){const{a:t,b:n}=Hb,r=gw(e*e),o=gw(r*e);return gw(o+t*e+n)}const Wb=Hb.a===Bb;class Gb extends Error{constructor(e){super(e)}}function Yb(e){if(!(e instanceof Qb))throw new TypeError("JacobianPoint expected")}class Qb{constructor(e,t,n){this.x=e,this.y=t,this.z=n}static fromAffine(e){if(!(e instanceof Zb))throw new TypeError("JacobianPoint#fromAffine: expected Point");return e.equals(Zb.ZERO)?Qb.ZERO:new Qb(e.x,e.y,Ub)}static toAffineBatch(e){const t=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hb.P;const n=new Array(e.length),r=e.reduce(((e,r,o)=>r===Bb?e:(n[o]=e,gw(e*r,t))),Ub),o=yw(r,t);return e.reduceRight(((e,r,o)=>r===Bb?e:(n[o]=gw(e*n[o],t),gw(e*r,t))),o),n}(e.map((e=>e.z)));return e.map(((e,n)=>e.toAffine(t[n])))}static normalizeZ(e){return Qb.toAffineBatch(e).map(Qb.fromAffine)}equals(e){Yb(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e,a=gw(r*r),l=gw(s*s),c=gw(t*l),u=gw(o*a),d=gw(gw(n*s)*l),h=gw(gw(i*r)*a);return c===u&&d===h}negate(){return new Qb(this.x,gw(-this.y),this.z)}double(){const{x:e,y:t,z:n}=this,r=gw(e*e),o=gw(t*t),i=gw(o*o),s=e+o,a=gw(Mb*(gw(s*s)-r-i)),l=gw(Fb*r),c=gw(l*l),u=gw(c-Mb*a),d=gw(l*(a-u)-$b*i),h=gw(Mb*t*n);return new Qb(u,d,h)}add(e){Yb(e);const{x:t,y:n,z:r}=this,{x:o,y:i,z:s}=e;if(o===Bb||i===Bb)return this;if(t===Bb||n===Bb)return e;const a=gw(r*r),l=gw(s*s),c=gw(t*l),u=gw(o*a),d=gw(gw(n*s)*l),h=gw(gw(i*r)*a),f=gw(u-c),p=gw(h-d);if(f===Bb)return p===Bb?this.double():Qb.ZERO;const g=gw(f*f),m=gw(f*g),y=gw(c*g),b=gw(p*p-m-Mb*y),w=gw(p*(y-b)-d*m),v=gw(r*s*f);return new Qb(b,w,v)}subtract(e){return this.add(e.negate())}multiplyUnsafe(e){const t=Qb.ZERO;if("bigint"===typeof e&&e===Bb)return t;let n=pw(e);if(n===Ub)return this;if(!Wb){let e=t,r=this;for(;n>Bb;)n&Ub&&(e=e.add(r)),r=r.double(),n>>=Ub;return e}let{k1neg:r,k1:o,k2neg:i,k2:s}=jb.splitScalar(n),a=t,l=t,c=this;for(;o>Bb||s>Bb;)o&Ub&&(a=a.add(c)),s&Ub&&(l=l.add(c)),c=c.double(),o>>=Ub,s>>=Ub;return r&&(a=a.negate()),i&&(l=l.negate()),l=new Qb(gw(l.x*jb.beta),l.y,l.z),a.add(l)}precomputeWindow(e){const t=Wb?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(Qb.BASE)&&(t=Zb.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&&Xb.get(t);r||(r=this.precomputeWindow(n),t&&1!==n&&(r=Qb.normalizeZ(r),Xb.set(t,r)));let o=Qb.ZERO,i=Qb.BASE;const s=1+(Wb?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+=Ub);const s=t,h=t+Math.abs(n)-1,f=d%2!==0,p=n<0;0===n?i=i.add(Jb(f,r[s])):o=o.add(Jb(p,r[h]))}return{p:o,f:i}}multiply(e,t){let n,r,o=pw(e);if(Wb){const{k1neg:e,k1:i,k2neg:s,k2:a}=jb.splitScalar(o);let{p:l,f:c}=this.wNAF(i,t),{p:u,f:d}=this.wNAF(a,t);l=Jb(e,l),u=Jb(s,u),u=new Qb(gw(u.x*jb.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 Qb.normalizeZ([n,r])[0]}toAffine(e){const{x:t,y:n,z:r}=this,o=this.equals(Qb.ZERO);null==e&&(e=o?$b:yw(r));const i=e,s=gw(i*i),a=gw(s*i),l=gw(t*s),c=gw(n*a),u=gw(r*i);if(o)return Zb.ZERO;if(u!==Ub)throw new Error("invZ was invalid");return new Zb(l,c)}}function Jb(e,t){const n=t.negate();return e?n:t}Qb.BASE=new Qb(Hb.Gx,Hb.Gy,Ub),Qb.ZERO=new Qb(Bb,Ub,Bb);const Xb=new WeakMap;class Zb{constructor(e,t){this.x=e,this.y=t}_setWindowSize(e){this._WINDOW_SIZE=e,Xb.delete(this)}hasEvenY(){return this.y%Mb===Bb}static fromCompressedHex(e){const t=32===e.length,n=hw(t?e:e.subarray(1));if(!kw(n))throw new Error("Point is not on curve");let r=function(e){const{P:t}=Hb,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=mw(c,Fb)*c%t,d=mw(u,Fb)*c%t,h=mw(d,Mb)*l%t,f=mw(h,r)*h%t,p=mw(f,o)*f%t,g=mw(p,s)*p%t,m=mw(g,a)*g%t,y=mw(m,s)*p%t,b=mw(y,Fb)*c%t,w=mw(b,i)*f%t,v=mw(w,n)*l%t,E=mw(v,Mb);if(E*E%t!==e)throw new Error("Cannot find square root");return E}(Kb(n));const o=(r&Ub)===Ub;if(t)o&&(r=gw(-r));else{1===(1&e[0])!==o&&(r=gw(-r))}const i=new Zb(n,r);return i.assertValidity(),i}static fromUncompressedHex(e){const t=hw(e.subarray(1,33)),n=hw(e.subarray(33,65)),r=new Zb(t,n);return r.assertValidity(),r}static fromHex(e){const t=fw(e),n=t.length,r=t[0];if(n===Vb)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 Zb.BASE.multiply(_w(e))}static fromSignature(e,t,n){const{r:r,s:o}=xw(t);if(![0,1,2,3].includes(n))throw new Error("Cannot recover: invalid recovery bit");const i=bw(fw(e)),{n:s}=Hb,a=2===n||3===n?r+s:r,l=yw(a,s),c=gw(-i*l,s),u=gw(o*l,s),d=1&n?"03":"02",h=Zb.fromHex(d+aw(a)),f=Zb.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 dw(this.toHex(e))}toHex(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];const t=aw(this.x);if(e){return`${this.hasEvenY()?"02":"03"}${t}`}return`04${t}${aw(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(!kw(t)||!kw(n))throw new Error(e);const r=gw(n*n);if(gw(r-Kb(t))!==Bb)throw new Error(e)}equals(e){return this.x===e.x&&this.y===e.y}negate(){return new Zb(this.x,gw(-this.y))}double(){return Qb.fromAffine(this).double().toAffine()}add(e){return Qb.fromAffine(this).add(Qb.fromAffine(e)).toAffine()}subtract(e){return this.add(e.negate())}multiply(e){return Qb.fromAffine(this).multiply(e,this).toAffine()}multiplyAndAddUnsafe(e,t,n){const r=Qb.fromAffine(this),o=t===Bb||t===Ub||this!==Zb.BASE?r.multiplyUnsafe(t):r.multiply(t),i=Qb.fromAffine(e).multiplyUnsafe(n),s=o.add(i);return s.equals(Qb.ZERO)?void 0:s.toAffine()}}function ew(e){return Number.parseInt(e[0],16)>=8?"00"+e:e}function tw(e){if(e.length<2||2!==e[0])throw new Error(`Invalid signature integer tag: ${iw(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:hw(n),left:e.subarray(t+2)}}Zb.BASE=new Zb(Hb.Gx,Hb.Gy),Zb.ZERO=new Zb(Bb,Bb);class nw{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?iw(e):e;if(128!==r.length)throw new Error(`${n}: Expected 64-byte hex`);return new nw(uw(r.slice(0,64)),uw(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: ${iw(e)}`);if(e[1]!==e.length-2)throw new Error("Invalid signature: incorrect length");const{data:t,left:n}=tw(e.subarray(2)),{data:r,left:o}=tw(n);if(o.length)throw new Error(`Invalid signature: left bytes after parsing: ${iw(o)}`);return{r:t,s:r}}(t?e:dw(e));return new nw(n,r)}static fromHex(e){return this.fromDER(e)}assertValidity(){const{r:e,s:t}=this;if(!Sw(e))throw new Error("Invalid Signature: r must be 0 < r < n");if(!Sw(t))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const e=Hb.n>>Ub;return this.s>e}normalizeS(){return this.hasHighS()?new nw(this.r,gw(-this.s,Hb.n)):this}toDERRawBytes(){return dw(this.toDERHex())}toDERHex(){const e=ew(cw(this.s)),t=ew(cw(this.r)),n=e.length/2,r=t.length/2,o=cw(n),i=cw(r);return`30${cw(r+n+4)}02${i}${t}02${o}${e}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return dw(this.toCompactHex())}toCompactHex(){return aw(this.r)+aw(this.s)}}function rw(){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 ow=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function iw(e){if(!(e instanceof Uint8Array))throw new Error("Expected Uint8Array");let t="";for(let n=0;n<e.length;n++)t+=ow[e[n]];return t}const sw=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function aw(e){if("bigint"!==typeof e)throw new Error("Expected bigint");if(!(Bb<=e&&e<sw))throw new Error("Expected number 0 <= n < 2^256");return e.toString(16).padStart(64,"0")}function lw(e){const t=dw(aw(e));if(32!==t.length)throw new Error("Error: expected 32 bytes");return t}function cw(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function uw(e){if("string"!==typeof e)throw new TypeError("hexToNumber: expected string, got "+typeof e);return BigInt(`0x${e}`)}function dw(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 hw(e){return uw(iw(e))}function fw(e){return e instanceof Uint8Array?Uint8Array.from(e):dw(e)}function pw(e){if("number"===typeof e&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if("bigint"===typeof e&&Sw(e))return e;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function gw(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hb.P;const n=e%t;return n>=Bb?n:t+n}function mw(e,t){const{P:n}=Hb;let r=e;for(;t-- >Bb;)r*=r,r%=n;return r}function yw(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Hb.P;if(e===Bb||t<=Bb)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=gw(e,t),r=t,o=Bb,i=Ub,s=Ub,a=Bb;for(;n!==Bb;){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!==Ub)throw new Error("invert: does not exist");return gw(o,t)}function bw(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=function(e){const t=8*e.length-256,n=hw(e);return t>0?n>>BigInt(t):n}(e);if(t)return n;const{n:r}=Hb;return n>=r?n-r:n}let ww,vw;class Ew{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 Bw.hmacSha256(this.k,...t)}hmacSync(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return vw(this.k,...t)}checkSync(){if("function"!==typeof vw)throw new Gb("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 rw(...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 rw(...t)}}function Sw(e){return Bb<e&&e<Hb.n}function kw(e){return Bb<e&&e<Hb.P}function Aw(e,t,n){let r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];const{n:o}=Hb,i=bw(e,!0);if(!Sw(i))return;const s=yw(i,o),a=Zb.BASE.multiply(i),l=gw(a.x,o);if(l===Bb)return;const c=gw(s*gw(t+n*l,o),o);if(c===Bb)return;let u=new nw(l,c),d=(a.x===u.r?0:2)|Number(a.y&Ub);return r&&u.hasHighS()&&(u=u.normalizeS(),d^=1),{sig:u,recovery:d}}function _w(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=uw(e)}else{if(!(e instanceof Uint8Array))throw new TypeError("Expected valid private key");if(e.length!==zb)throw new Error("Expected 32 bytes of private key");t=hw(e)}if(!Sw(t))throw new Error("Expected private key: 0 < key < n");return t}function Iw(e){return e instanceof Zb?(e.assertValidity(),e):Zb.fromHex(e)}function xw(e){if(e instanceof nw)return e.assertValidity(),e;try{return nw.fromDER(e)}catch(t){return nw.fromCompact(e)}}function Cw(e){return hw(e.length>Vb?e.slice(0,Vb):e)}function Rw(e){const t=Cw(e),n=gw(t,Hb.n);return Tw(n<Bb?t:n)}function Tw(e){return lw(e)}function Nw(e,t,n){if(null==e)throw new Error(`sign: expected valid message hash, not "${e}"`);const r=fw(e),o=_w(t),i=[Tw(o),Rw(r)];if(null!=n){!0===n&&(n=Bw.randomBytes(Vb));const e=fw(n);if(e.length!==Vb)throw new Error("sign: Expected 32 bytes of extra data");i.push(e)}return{seed:rw(...i),m:Cw(r),d:o}}function Pw(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 Ow={strict:!0};Zb.BASE._setWindowSize(8);const Lw={node:Db,web:"object"===typeof self&&"crypto"in self?self.crypto:void 0},Dw={},Bw={bytesToHex:iw,hexToBytes:dw,concatBytes:rw,mod:gw,invert:yw,isValidPrivateKey(e){try{return _w(e),!0}catch(t){return!1}},_bigintTo32Bytes:lw,_normalizePrivateKey:_w,hashToPrivateKey:e=>{if((e=fw(e)).length<40||e.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return lw(gw(hw(e),Hb.n-Ub)+Ub)},randomBytes:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(Lw.web)return Lw.web.getRandomValues(new Uint8Array(e));if(Lw.node){const{randomBytes:t}=Lw.node;return Uint8Array.from(t(e))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>Bw.hashToPrivateKey(Bw.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]:Zb.BASE;const n=t===Zb.BASE?t:new Zb(t.x,t.y);return n._setWindowSize(e),n.multiply(Fb),n},sha256:async function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];if(Lw.web){const e=await Lw.web.subtle.digest("SHA-256",rw(...t));return new Uint8Array(e)}if(Lw.node){const{createHash:e}=Lw.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(Lw.web){const t=await Lw.web.subtle.importKey("raw",e,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),r=rw(...n),o=await Lw.web.subtle.sign("HMAC",t,r);return new Uint8Array(o)}if(Lw.node){const{createHmac:t}=Lw.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=Dw[e];if(void 0===t){const n=await Bw.sha256(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=rw(n,n),Dw[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 Bw.sha256(t,...r)},taggedHashSync:function(e){if("function"!==typeof ww)throw new Gb("sha256Sync is undefined, you need to set it");let t=Dw[e];if(void 0===t){const n=ww(Uint8Array.from(e,(e=>e.charCodeAt(0))));t=rw(n,n),Dw[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 ww(t,...r)},_JacobianPoint:Qb};Object.defineProperties(Bw,{sha256Sync:{configurable:!1,get:()=>ww,set(e){ww||(ww=e)}},hmacSha256Sync:{configurable:!1,get:()=>vw,set(e){vw||(vw=e)}}});var Uw=__webpack_require__(2161);function Mw(e){return new Uint8Array(Uw.keccak256.arrayBuffer(e))}function Fw(e,t,n){try{return function(e,t,n){let r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:Ow;try{r=xw(e),t=fw(t)}catch(p){return!1}const{r:i,s:s}=r;if(o.strict&&r.hasHighS())return!1;const a=bw(t);let l;try{l=Iw(n)}catch(p){return!1}const{n:c}=Hb,u=yw(s,c),d=gw(a*u,c),h=gw(i*u,c),f=Zb.BASE.multiplyAndAddUnsafe(l,d,h);return!!f&&gw(f.x,c)===i}(nw.fromCompact(e.slice(0,64)),t,n)}catch{return!1}}const $w="Invalid record id";function Hw(e,t){switch(t){case"udp":return Hw(e,"udp4")||Hw(e,"udp6");case"tcp":return Hw(e,"tcp4")||Hw(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=Bi("/"+e+"/"+fi(e,n));return o=o.encapsulate(Bi("/"+t+"/"+fi(t,r))),o}(n?"ip6":"ip4",o,r,i):void 0}function qw(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 jw(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 Vw 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($w)}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 zw(this,"ip","ip4")}set ip(e){Ww(this,"ip","ip4",e)}get tcp(){return Kw(this,"tcp","tcp")}set tcp(e){Gw(this,"tcp","tcp",e)}get udp(){return Kw(this,"udp","udp")}set udp(e){Gw(this,"udp","udp",e)}get ip6(){return zw(this,"ip6","ip6")}set ip6(e){Ww(this,"ip6","ip6",e)}get tcp6(){return Kw(this,"tcp6","tcp")}set tcp6(e){Gw(this,"tcp6","tcp",e)}get udp6(){return Kw(this,"udp6","udp")}set udp6(e){Gw(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(Bi(o))}return t}(e)}set multiaddrs(e){Yw(this,"multiaddrs",e,qw)}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){Yw(this,"waku2",e,(e=>new Uint8Array([jw(e)])))}}function zw(e,t,n){const r=e.get(t);if(r)return fi(n,r)}function Kw(e,t,n){const r=e.get(t);if(r)return Number(fi(n,r))}function Ww(e,t,n,r){Yw(e,t,r,pi.bind({},n))}function Gw(e,t,n,r){Ww(e,t,n,r?.toString(10))}function Yw(e,t,n,r){void 0!==n?e.set(t,r(n)):e.delete(t)}async function Qw(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}=Nw(e,t,n.extraEntropy),s=new Ew(32,zb);let a;for(await s.reseed(r);!(a=Aw(await s.generate(),o,i,n.canonical));)await s.reseed();return Pw(a,n)}(Mw(t),e,{der:!1})}const Jw=new Cr("enr");var Xw,Zw;!function(e){e.TCP="tcp",e.UDP="udp"}(Xw||(Xw={})),function(e){e.TCP4="tcp4",e.UDP4="udp4",e.TCP6="tcp6",e.UDP6="udp6"}(Zw||(Zw={}));class ev extends Vw{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 ev(e,t,arguments.length>2?arguments[2]:void 0);try{const e=n.publicKey;e&&(n.peerId=await function(e){return Td(new hd.secp256k1.Secp256k1PublicKey(e).bytes,void 0)}(e))}catch(r){Jw.error("Could not calculate peer id for ENR",r)}return n}get nodeId(){if("v4"===this.id)return this.publicKey?function(e){const t=Zb.fromHex(e).toRawBytes(!1);return fr(Mw(t.slice(1)))}(this.publicKey):void 0;throw new Error($w)}getLocationMultiaddr=(()=>Hw.bind({},this))();get shardInfo(){return this.rs&&this.rsv&&Jw.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(Zw)){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($w);if(!this.publicKey)throw new Error("Failed to verify ENR: No public key");return Fw(t,Mw(e),this.publicKey)}async sign(e,t){if("v4"!==this.id)throw new Error($w);return this.signature=await Qw(t,e),this.signature}}let tv=!1,nv=!1;const rv={debug:1,default:2,info:2,warning:3,error:4,off:5};let ov=rv.default,iv=null;const sv=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 av,lv;!function(e){e.DEBUG="DEBUG",e.INFO="INFO",e.WARNING="WARNING",e.ERROR="ERROR",e.OFF="OFF"}(av||(av={})),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"}(lv||(lv={}));const cv="0123456789abcdef";class uv{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){const n=e.toLowerCase();null==rv[n]&&this.throwArgumentError("invalid log level name","logLevel",e),ov>rv[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(uv.levels.DEBUG,t)}info(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log(uv.levels.INFO,t)}warn(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];this._log(uv.levels.WARNING,t)}makeError(e,t,n){if(nv)return this.makeError("censored error",t,{});t||(t=uv.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+=cv[t[e]>>4],n+=cv[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 lv.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 lv.CALL_EXCEPTION:case lv.INSUFFICIENT_FUNDS:case lv.MISSING_NEW:case lv.NONCE_EXPIRED:case lv.REPLACEMENT_UNDERPRICED:case lv.TRANSACTION_REPLACED:case lv.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,uv.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"),sv&&this.throwError("platform missing String.prototype.normalize",uv.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:sv})}checkSafeUint53(e,t){"number"===typeof e&&(null==t&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,uv.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,uv.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,n){n=n?": "+n:"",e<t&&this.throwError("missing argument"+n,uv.errors.MISSING_ARGUMENT,{count:e,expectedCount:t}),e>t&&this.throwError("too many arguments"+n,uv.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){e!==Object&&null!=e||this.throwError("missing new",uv.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",uv.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):e!==Object&&null!=e||this.throwError("missing new",uv.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return iv||(iv=new uv("logger/5.7.0")),iv}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",uv.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),tv){if(!e)return;this.globalLogger().throwError("error censorship permanent",uv.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}nv=!!e,tv=!!t}static setLogLevel(e){const t=rv[e.toLowerCase()];null!=t?ov=t:uv.globalLogger().warn("invalid log level - "+e)}static from(e){return new uv(e)}}uv.errors=lv,uv.levels=av;const dv=new uv("bytes/5.7.0");function hv(e){return!!e.toHexString}function fv(e){return e.slice||(e.slice=function(){const t=Array.prototype.slice.call(arguments);return fv(new Uint8Array(Array.prototype.slice.apply(e,t)))}),e}function pv(e){return bv(e)&&!(e.length%2)||mv(e)}function gv(e){return"number"===typeof e&&e==e&&e%1===0}function mv(e){if(null==e)return!1;if(e.constructor===Uint8Array)return!0;if("string"===typeof e)return!1;if(!gv(e.length)||e.length<0)return!1;for(let t=0;t<e.length;t++){const n=e[t];if(!gv(n)||n<0||n>=256)return!1}return!0}function yv(e,t){if(t||(t={}),"number"===typeof e){dv.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),fv(new Uint8Array(t))}if(t.allowMissingPrefix&&"string"===typeof e&&"0x"!==e.substring(0,2)&&(e="0x"+e),hv(e)&&(e=e.toHexString()),bv(e)){let n=e.substring(2);n.length%2&&("left"===t.hexPad?n="0"+n:"right"===t.hexPad?n+="0":dv.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 fv(new Uint8Array(r))}return mv(e)?fv(new Uint8Array(e)):dv.throwArgumentError("invalid arrayify value","value",e)}function bv(e,t){return!("string"!==typeof e||!e.match(/^0x[0-9A-Fa-f]*$/))&&(!t||e.length===2+2*t)}const wv="0123456789abcdef";function vv(e,t){if(t||(t={}),"number"===typeof e){dv.checkSafeUint53(e,"invalid hexlify value");let t="";for(;e;)t=wv[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),hv(e))return e.toHexString();if(bv(e))return e.length%2&&("left"===t.hexPad?e="0x0"+e.substring(2):"right"===t.hexPad?e+="0":dv.throwArgumentError("hex data is odd-length","value",e)),e.toLowerCase();if(mv(e)){let t="0x";for(let n=0;n<e.length;n++){let r=e[n];t+=wv[(240&r)>>4]+wv[15&r]}return t}return dv.throwArgumentError("invalid hexlify value","value",e)}const Ev=new uv("rlp/5.7.0");function Sv(e){const t=[];for(;e;)t.unshift(255&e),e>>=8;return t}function kv(e,t,n){let r=0;for(let o=0;o<n;o++)r=256*r+e[t+o];return r}function Av(e){if(Array.isArray(e)){let t=[];if(e.forEach((function(e){t=t.concat(Av(e))})),t.length<=55)return t.unshift(192+t.length),t;const n=Sv(t.length);return n.unshift(247+n.length),n.concat(t)}pv(e)||Ev.throwArgumentError("RLP object must be BytesLike","object",e);const t=Array.prototype.slice.call(yv(e));if(1===t.length&&t[0]<=127)return t;if(t.length<=55)return t.unshift(128+t.length),t;const n=Sv(t.length);return n.unshift(183+n.length),n.concat(t)}function _v(e){return vv(Av(e))}function Iv(e,t,n,r){const o=[];for(;n<t+1+r;){const i=xv(e,n);o.push(i.result),(n+=i.consumed)>t+1+r&&Ev.throwError("child data too short",uv.errors.BUFFER_OVERRUN,{})}return{consumed:1+r,result:o}}function xv(e,t){if(0===e.length&&Ev.throwError("data too short",uv.errors.BUFFER_OVERRUN,{}),e[t]>=248){const n=e[t]-247;t+1+n>e.length&&Ev.throwError("data short segment too short",uv.errors.BUFFER_OVERRUN,{});const r=kv(e,t+1,n);return t+1+n+r>e.length&&Ev.throwError("data long segment too short",uv.errors.BUFFER_OVERRUN,{}),Iv(e,t,t+1+n,n+r)}if(e[t]>=192){const n=e[t]-192;return t+1+n>e.length&&Ev.throwError("data array too short",uv.errors.BUFFER_OVERRUN,{}),Iv(e,t,t+1,n)}if(e[t]>=184){const n=e[t]-183;t+1+n>e.length&&Ev.throwError("data array too short",uv.errors.BUFFER_OVERRUN,{});const r=kv(e,t+1,n);t+1+n+r>e.length&&Ev.throwError("data array too short",uv.errors.BUFFER_OVERRUN,{});return{consumed:1+n+r,result:vv(e.slice(t+1+n,t+1+n+r))}}if(e[t]>=128){const n=e[t]-128;t+1+n>e.length&&Ev.throwError("data too short",uv.errors.BUFFER_OVERRUN,{});return{consumed:1+n,result:vv(e.slice(t+1,t+1+n))}}return{consumed:1,result:vv(e[t])}}const Cv=new Cr("enr:decoder");class Rv{static fromString(e){if(!e.startsWith(ev.RECORD_PREFIX))throw new Error(`"string encoded ENR must start with '${ev.RECORD_PREFIX}'`);return Rv.fromRLP(Dt(e.slice(4),"base64url"))}static fromRLP(e){const t=function(e){const t=yv(e),n=xv(t,0);return n.consumed!==t.length&&Ev.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){Cv.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 ev.create(o,i,t);return function(e,t,n,r){const o=hr(_v([e,...t]));if(!n.verify(o,r))throw new Error("Unable to verify ENR signature")}(n,r,s,t),s}(t)}}const Tv=/^(\d{1,3}\.){3,3}\d{1,3}$/,Nv=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,Pv={name:"v4",size:4,isFormat:e=>Tv.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]}`)},Ov={name:"v6",size:16,isFormat:e=>e.length>0&&Nv.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 Lv(e){if(Pv.isFormat(e))return Pv.size;if(Ov.isFormat(e))return Ov.size;throw Error(`Invalid ip address: ${e}`)}function Dv(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 Bv(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 Uv(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 Mv(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 Fv(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 $v(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 Hv(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 qv=55296,jv=56320;function Vv(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)!==qv)t+=3;else{const i=r+1;if(i===n||o>=jv)t+=3;else{(64512&e.charCodeAt(i))!==jv?t+=3:(r=i,t+=4)}}}return t}function zv(e,t,n){const r=e.length;void 0!==n&&null!==n||(n=0),void 0===t&&(t=new Uint8Array(Vv(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)!==qv)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>=jv)t[o++]=239,t[o++]=191,t[o++]=189;else{const r=e.charCodeAt(s);(64512&r)!==jv?(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 zv.bytes=o-n,t}function Kv(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=qv|n>>10&1023;r+=String.fromCharCode(i),n=jv|1023&n}else n=(15&t)<<12|(63&e[o++])<<6|63&e[o++];r+=String.fromCharCode(n)}return Kv.bytes=n-t,r}zv.bytes=0,Kv.bytes=0;const Wv=e=>e instanceof Uint8Array;function Gv(e){return"string"===typeof e?Vv(e):e.byteLength}function Yv(e){return e instanceof Uint8Array?e:Array.isArray(e)?new Uint8Array(e):zv(e)}function Qv(e,t,n){if("string"!==typeof t)throw new Error("unknown input type");return zv(t,e,n),zv.bytes}const Jv=Math.pow(2,24),Xv=Math.pow(2,16),Zv=Math.pow(2,8),eE=(e,t)=>e[t]*Jv+e[t+1]*Xv+e[t+2]*Zv+e[t+3],tE=(e,t)=>e[t]<<8|e[t+1],nE=(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),rE=(e,t,n)=>(e[n]=t>>8,e[n+1]=255&t,n+2);function oE(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 iE=32768;function sE(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 aE=sE({encode(e,t,n){t||(t=new Uint8Array(aE.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=Qv(t,e[r],n+1);t[n]=o,n+=o+1}}return t[n++]=0,aE.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(Kv(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=tE(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 aE.decode.bytes=i,0===n.length?".":n.join(".")},encodingLength:e=>"."===e||".."===e?1:Gv(e.replace(/^\.|\.$/gm,""))+2}),lE=sE({encode(e,t,n){t||(t=new Uint8Array(lE.encodingLength(e))),n||(n=0);const r=Qv(t,e,n+1);return t[n]=r,lE.encode.bytes=r+1,t},decode(e,t){t||(t=0);const n=e[t],r=Kv(e,t+1,t+1+n);return lE.decode.bytes=n+1,r},encodingLength:e=>Gv(e)+1}),cE=sE({bytes:12,encode(e,t,n){t||(t=new Uint8Array(cE.encodingLength(e))),n||(n=0);const r=32767&(e.flags||0),o="response"===e.type?32768:0;return rE(t,e.id||0,n),rE(t,r|o,n+2),rE(t,e.questions.length,n+4),rE(t,e.answers.length,n+6),rE(t,e.authorities.length,n+8),rE(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=tE(e,t+2);return{id:tE(e,t),type:32768&n?"response":"query",flags:32767&n,flag_qr:1===(n>>15&1),opcode:Mv(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:Uv(15&n),questions:new Array(tE(e,t+4)),answers:new Array(tE(e,t+6)),authorities:new Array(tE(e,t+8)),additionals:new Array(tE(e,t+10))}},encodingLength:()=>12}),uE=sE({encode(e,t,n){t||(t=new Uint8Array(uE.encodingLength(e))),n||(n=0);const r=e.length;return rE(t,r,n),oE(e,t,n+2,0,r),uE.encode.bytes=r+2,t},decode(e,t){t||(t=0);const n=tE(e,t),r=e.slice(t+2,t+2+n);return uE.decode.bytes=n+2,r},encodingLength:e=>e.length+2}),dE=sE({encode:(e,t,n)=>(t||(t=new Uint8Array(dE.encodingLength(e))),n||(n=0),aE.encode(e,t,n+2),rE(t,aE.encode.bytes,n),dE.encode.bytes=aE.encode.bytes+2,t),decode(e,t){t||(t=0);const n=tE(e,t),r=aE.decode(e,t+2);return dE.decode.bytes=n+2,r},encodingLength:e=>aE.encodingLength(e)+2}),hE=sE({encode(e,t,n){t||(t=new Uint8Array(hE.encodingLength(e))),n||(n=0);const r=n;return n+=2,aE.encode(e.mname,t,n),n+=aE.encode.bytes,aE.encode(e.rname,t,n),n+=aE.encode.bytes,nE(t,e.serial||0,n),n+=4,nE(t,e.refresh||0,n),n+=4,nE(t,e.retry||0,n),n+=4,nE(t,e.expire||0,n),n+=4,nE(t,e.minimum||0,n),rE(t,(n+=4)-r-2,r),hE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.mname=aE.decode(e,t),t+=aE.decode.bytes,r.rname=aE.decode(e,t),t+=aE.decode.bytes,r.serial=eE(e,t),t+=4,r.refresh=eE(e,t),t+=4,r.retry=eE(e,t),t+=4,r.expire=eE(e,t),t+=4,r.minimum=eE(e,t),t+=4,hE.decode.bytes=t-n,r},encodingLength:e=>22+aE.encodingLength(e.mname)+aE.encodingLength(e.rname)}),fE=sE({encode(e,t,n){Array.isArray(e)||(e=[e]);for(let o=0;o<e.length;o++)if("string"===typeof e[o]&&(e[o]=Yv(e[o])),!Wv(e[o]))throw new Error("Must be a Buffer");t||(t=new Uint8Array(fE.encodingLength(e))),n||(n=0);const r=n;return n+=2,e.forEach((function(e){t[n++]=e.length,oE(e,t,n,0,e.length),n+=e.length})),rE(t,n-r-2,r),fE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t;let r=tE(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 fE.decode.bytes=t-n,o},encodingLength(e){Array.isArray(e)||(e=[e]);let t=2;return e.forEach((function(e){t+="string"===typeof e?Gv(e)+1:e.length+1})),t}}),pE=sE({encode(e,t,n){t||(t=new Uint8Array(pE.encodingLength(e))),n||(n=0),"string"===typeof e&&(e=Yv(e)),e||(e=new Uint8Array(0));const r=n;n+=2;const o=e.length;return oE(e,t,n,0,o),rE(t,(n+=o)-r-2,r),pE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r=tE(e,t);t+=2;const o=e.slice(t,t+r);return t+=r,pE.decode.bytes=t-n,o},encodingLength:e=>e?(Wv(e)?e.length:Gv(e))+2:2}),gE=sE({encode(e,t,n){t||(t=new Uint8Array(gE.encodingLength(e))),n||(n=0);const r=n;return n+=2,lE.encode(e.cpu,t,n),n+=lE.encode.bytes,lE.encode(e.os,t,n),n+=lE.encode.bytes,rE(t,n-r-2,r),gE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.cpu=lE.decode(e,t),t+=lE.decode.bytes,r.os=lE.decode(e,t),t+=lE.decode.bytes,gE.decode.bytes=t-n,r},encodingLength:e=>lE.encodingLength(e.cpu)+lE.encodingLength(e.os)+2}),mE=sE({encode:(e,t,n)=>(t||(t=new Uint8Array(mE.encodingLength(e))),n||(n=0),aE.encode(e,t,n+2),rE(t,aE.encode.bytes,n),mE.encode.bytes=aE.encode.bytes+2,t),decode(e,t){t||(t=0);const n=aE.decode(e,t+2);return mE.decode.bytes=aE.decode.bytes+2,n},encodingLength:e=>aE.encodingLength(e)+2}),yE=sE({encode(e,t,n){t||(t=new Uint8Array(yE.encodingLength(e))),n||(n=0),rE(t,e.priority||0,n+2),rE(t,e.weight||0,n+4),rE(t,e.port||0,n+6),aE.encode(e.target,t,n+8);const r=aE.encode.bytes+6;return rE(t,r,n),yE.encode.bytes=r+2,t},decode(e,t){t||(t=0);const n=tE(e,t),r={};return r.priority=tE(e,t+2),r.weight=tE(e,t+4),r.port=tE(e,t+6),r.target=aE.decode(e,t+8),yE.decode.bytes=n+2,r},encodingLength:e=>8+aE.encodingLength(e.target)}),bE=sE({encode(e,t,n){const r=bE.encodingLength(e);return t||(t=new Uint8Array(bE.encodingLength(e))),n||(n=0),e.issuerCritical&&(e.flags=bE.ISSUER_CRITICAL),rE(t,r-2,n),t[n+=2]=e.flags||0,n+=1,lE.encode(e.tag,t,n),n+=lE.encode.bytes,Qv(t,e.value,n),n+=Gv(e.value),bE.encode.bytes=r,t},decode(e,t){t||(t=0);const n=tE(e,t),r=t+=2,o={};return o.flags=e[t],t+=1,o.tag=lE.decode(e,t),t+=lE.decode.bytes,o.value=Kv(e,t,r+n),o.issuerCritical=!!(o.flags&bE.ISSUER_CRITICAL),bE.decode.bytes=n+2,o},encodingLength:e=>lE.encodingLength(e.tag)+lE.encodingLength(e.value)+2});bE.ISSUER_CRITICAL=128;const wE=sE({encode(e,t,n){t||(t=new Uint8Array(wE.encodingLength(e))),n||(n=0);const r=n;return n+=2,rE(t,e.preference||0,n),n+=2,aE.encode(e.exchange,t,n),n+=aE.encode.bytes,rE(t,n-r-2,r),wE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.preference=tE(e,t),t+=2,r.exchange=aE.decode(e,t),t+=aE.decode.bytes,wE.decode.bytes=t-n,r},encodingLength:e=>4+aE.encodingLength(e.exchange)}),vE=sE({encode:(e,t,n)=>(t||(t=new Uint8Array(vE.encodingLength(e))),n||(n=0),rE(t,4,n),n+=2,Pv.encode(e,t,n),t),decode(e,t){t||(t=0),t+=2;return Pv.decode(e,t)},bytes:6}),EE=sE({encode:(e,t,n)=>(t||(t=new Uint8Array(EE.encodingLength(e))),n||(n=0),rE(t,16,n),n+=2,Ov.encode(e,t,n),EE.encode.bytes=18,t),decode(e,t){t||(t=0),t+=2;const n=Ov.decode(e,t);return EE.decode.bytes=18,n},bytes:18}),SE=e=>new Uint8Array(e),kE=sE({encode(e,t,n){t||(t=new Uint8Array(kE.encodingLength(e))),n||(n=0);const r=n,o=Hv(e.code);if(rE(t,o,n),n+=2,e.data)rE(t,e.data.length,n),n+=2,oE(e.data,t,n),n+=e.data.length;else switch(o){case 8:{const r=e.sourcePrefixLength||0,o=e.family||function(e){return Lv(e)===Pv.size?1:2}(e.ip),i=function(e,t,n){n=~~n;const r=Lv(e);return"function"===typeof t&&(t=t(n+r)),r===Pv.size?Pv.encode(e,t,n):Ov.encode(e,t,n)}(e.ip,SE),s=Math.ceil(r/8);rE(t,s+4,n),rE(t,o,n+=2),n+=2,t[n++]=r,t[n++]=e.scopePrefixLength||0,oE(i,t,n,0,s),n+=s}break;case 11:e.timeout?(rE(t,2,n),n+=2,rE(t,e.timeout,n),n+=2):(rE(t,0,n),n+=2);break;case 12:{const r=e.length||0;rE(t,r,n),n+=2,t.fill(0,n,n+r),n+=r}break;case 14:{const r=2*e.tags.length;rE(t,r,n),n+=2;for(const o of e.tags)rE(t,o,n),n+=2}break;default:throw new Error(`Unknown roption code: ${e.code}`)}return kE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n={};n.code=tE(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=tE(e,t+=2);switch(t+=2,n.data=e.slice(t,t+r),n.code){case 8:n.family=tE(e,t),t+=2,n.sourcePrefixLength=e[t++],n.scopePrefixLength=e[t++];{const o=new Uint8Array(1===n.family?4:16);oE(e,o,0,t,t+r-4),n.ip=function(e,t,n){if(t=~~t,(n=n||e.length-t)===Pv.size)return Pv.decode(e,t,n);if(n===Ov.size)return Ov.decode(e,t,n);throw Error(`Invalid buffer size needs to be ${Pv.size} for v4 or ${Ov.size} for v6.`)}(o)}break;case 11:r>0&&(n.timeout=tE(e,t),t+=2);break;case 14:n.tags=[];for(let o=0;o<r;o+=2)n.tags.push(tE(e,t)),t+=2}return kE.decode.bytes=r+4,n},encodingLength(e){if(e.data)return e.data.length+4;switch(Hv(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}`)}}),AE=sE({encode(e,t,n){t||(t=new Uint8Array(AE.encodingLength(e))),n||(n=0);const r=n,o=qE(e,kE);return rE(t,o,n),n=jE(e,kE,t,n+2),AE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n=t,r=[];let o=tE(e,t);t+=2;let i=0;for(;o>0;)r[i++]=kE.decode(e,t),t+=kE.decode.bytes,o-=kE.decode.bytes;return AE.decode.bytes=t-n,r},encodingLength:e=>2+qE(e||[],kE)}),_E=sE({encode(e,t,n){t||(t=new Uint8Array(_E.encodingLength(e))),n||(n=0);const r=n,o=e.key;if(!Wv(o))throw new Error("Key must be a Buffer");return n+=2,rE(t,e.flags,n),t[n+=2]=_E.PROTOCOL_DNSSEC,t[n+=1]=e.algorithm,oE(o,t,n+=1,0,o.length),n+=o.length,_E.encode.bytes=n-r,rE(t,_E.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=tE(e,t);if(t+=2,r.flags=tE(e,t),e[t+=2]!==_E.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,_E.decode.bytes=t-n,r},encodingLength:e=>6+Gv(e.key)});_E.PROTOCOL_DNSSEC=3,_E.ZONE_KEY=128,_E.SECURE_ENTRYPOINT=32768;const IE=sE({encode(e,t,n){t||(t=new Uint8Array(IE.encodingLength(e))),n||(n=0);const r=n,o=e.signature;if(!Wv(o))throw new Error("Signature must be a Buffer");return n+=2,rE(t,Bv(e.typeCovered),n),t[n+=2]=e.algorithm,t[n+=1]=e.labels,n+=1,nE(t,e.originalTTL,n),n+=4,nE(t,e.expiration,n),n+=4,nE(t,e.inception,n),n+=4,rE(t,e.keyTag,n),n+=2,aE.encode(e.signersName,t,n),oE(o,t,n+=aE.encode.bytes,0,o.length),n+=o.length,IE.encode.bytes=n-r,rE(t,IE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=tE(e,t);return t+=2,r.typeCovered=Dv(tE(e,t)),t+=2,r.algorithm=e[t],t+=1,r.labels=e[t],t+=1,r.originalTTL=eE(e,t),t+=4,r.expiration=eE(e,t),t+=4,r.inception=eE(e,t),t+=4,r.keyTag=tE(e,t),t+=2,r.signersName=aE.decode(e,t),t+=aE.decode.bytes,r.signature=e.slice(t,n+o+2),t+=r.signature.length,IE.decode.bytes=t-n,r},encodingLength:e=>20+aE.encodingLength(e.signersName)+Gv(e.signature)}),xE=sE({encode(e,t,n){t||(t=new Uint8Array(xE.encodingLength(e))),n||(n=0);const r=n;return n+=2,aE.encode(e.mbox||".",t,n),n+=aE.encode.bytes,aE.encode(e.txt||".",t,n),n+=aE.encode.bytes,xE.encode.bytes=n-r,rE(t,xE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={};return t+=2,r.mbox=aE.decode(e,t)||".",t+=aE.decode.bytes,r.txt=aE.decode(e,t)||".",t+=aE.decode.bytes,xE.decode.bytes=t-n,r},encodingLength:e=>2+aE.encodingLength(e.mbox||".")+aE.encodingLength(e.txt||".")}),CE=sE({encode(e,t,n){t||(t=new Uint8Array(CE.encodingLength(e))),n||(n=0);const r=n,o=[];for(let i=0;i<e.length;i++){const t=Bv(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=Yv(o[i]);t[n]=i,t[n+=1]=e.length,oE(e,t,n+=1,0,e.length),n+=e.length}return CE.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=Dv(n<<8|i<<3|e);o.push(t)}}t+=r}return CE.decode.bytes=t-r,o},encodingLength(e){const t=[];for(let r=0;r<e.length;r++){const n=Bv(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}}),RE=sE({encode(e,t,n){t||(t=new Uint8Array(RE.encodingLength(e))),n||(n=0);const r=n;return n+=2,aE.encode(e.nextDomain,t,n),n+=aE.encode.bytes,CE.encode(e.rrtypes,t,n),n+=CE.encode.bytes,RE.encode.bytes=n-r,rE(t,RE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=tE(e,t);return t+=2,r.nextDomain=aE.decode(e,t),t+=aE.decode.bytes,r.rrtypes=CE.decode(e,t,o-(t-n)),t+=CE.decode.bytes,RE.decode.bytes=t-n,r},encodingLength:e=>2+aE.encodingLength(e.nextDomain)+CE.encodingLength(e.rrtypes)}),TE=sE({encode(e,t,n){t||(t=new Uint8Array(TE.encodingLength(e))),n||(n=0);const r=n,o=e.salt;if(!Wv(o))throw new Error("salt must be a Buffer");const i=e.nextDomain;if(!Wv(i))throw new Error("nextDomain must be a Buffer");return t[n+=2]=e.algorithm,t[n+=1]=e.flags,n+=1,rE(t,e.iterations,n),t[n+=2]=o.length,oE(o,t,n+=1,0,o.length),t[n+=o.length]=i.length,oE(i,t,n+=1,0,i.length),n+=i.length,CE.encode(e.rrtypes,t,n),n+=CE.encode.bytes,TE.encode.bytes=n-r,rE(t,TE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=tE(e,t);t+=2,r.algorithm=e[t],t+=1,r.flags=e[t],t+=1,r.iterations=tE(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=CE.decode(e,t,o-(t-n)),t+=CE.decode.bytes,TE.decode.bytes=t-n,r},encodingLength:e=>8+e.salt.length+e.nextDomain.length+CE.encodingLength(e.rrtypes)}),NE=sE({encode(e,t,n){t||(t=new Uint8Array(NE.encodingLength(e))),n||(n=0);const r=n,o=e.digest;if(!Wv(o))throw new Error("Digest must be a Buffer");return n+=2,rE(t,e.keyTag,n),t[n+=2]=e.algorithm,t[n+=1]=e.digestType,oE(o,t,n+=1,0,o.length),n+=o.length,NE.encode.bytes=n-r,rE(t,NE.encode.bytes-2,r),t},decode(e,t){t||(t=0);const n=t,r={},o=tE(e,t);return t+=2,r.keyTag=tE(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,NE.decode.bytes=t-n,r},encodingLength:e=>6+Gv(e.digest)});function PE(e){switch(e.toUpperCase()){case"A":return vE;case"PTR":case"CNAME":case"DNAME":return mE;case"TXT":return fE;case"NULL":return pE;case"AAAA":return EE;case"SRV":return yE;case"HINFO":return gE;case"CAA":return bE;case"NS":return dE;case"SOA":return hE;case"MX":return wE;case"OPT":return AE;case"DNSKEY":return _E;case"RRSIG":return IE;case"RP":return xE;case"NSEC":return RE;case"NSEC3":return TE;case"DS":return NE}return uE}const OE=sE({encode(e,t,n){t||(t=new Uint8Array(OE.encodingLength(e))),n||(n=0);const r=n;if(aE.encode(e.name,t,n),n+=aE.encode.bytes,rE(t,Bv(e.type),n),"OPT"===e.type.toUpperCase()){if("."!==e.name)throw new Error("OPT name must be root.");rE(t,e.udpPayloadSize||4096,n+2),t[n+4]=e.extendedRcode||0,t[n+5]=e.ednsVersion||0,rE(t,e.flags||0,n+6),n+=8,AE.encode(e.options||[],t,n),n+=AE.encode.bytes}else{let r=$v(void 0===e.class?"IN":e.class);e.flush&&(r|=iE),rE(t,r,n+2),nE(t,e.ttl||0,n+4),n+=8;const o=PE(e.type);o.encode(e.data,t,n),n+=o.encode.bytes}return OE.encode.bytes=n-r,t},decode(e,t){t||(t=0);const n={},r=t;if(n.name=aE.decode(e,t),t+=aE.decode.bytes,n.type=Dv(tE(e,t)),"OPT"===n.type)n.udpPayloadSize=tE(e,t+2),n.extendedRcode=e[t+4],n.ednsVersion=e[t+5],n.flags=tE(e,t+6),n.flag_do=1===(n.flags>>15&1),n.options=AE.decode(e,t+8),t+=8+AE.decode.bytes;else{const r=tE(e,t+2);n.ttl=eE(e,t+4),n.class=Fv(-32769&r),n.flush=!!(r&iE);const o=PE(n.type);n.data=o.decode(e,t+8),t+=8+o.decode.bytes}return OE.decode.bytes=t-r,n},encodingLength(e){const t=null!==e.data&&void 0!==e.data?e.data:e.options;return aE.encodingLength(e.name)+8+PE(e.type).encodingLength(t)}}),LE=sE({encode(e,t,n){t||(t=new Uint8Array(LE.encodingLength(e))),n||(n=0);const r=n;return aE.encode(e.name,t,n),n+=aE.encode.bytes,rE(t,Bv(e.type),n),n+=2,rE(t,$v(void 0===e.class?"IN":e.class),n),n+=2,LE.encode.bytes=n-r,e},decode(e,t){t||(t=0);const n=t,r={};r.name=aE.decode(e,t),t+=aE.decode.bytes,r.type=Dv(tE(e,t)),t+=2,r.class=Fv(tE(e,t)),t+=2;return!!(32768&r.class)&&(r.class&=-32769),LE.decode.bytes=t-n,r},encodingLength:e=>aE.encodingLength(e.name)+4}),DE={encode:function(e,t,n){const r=!t;r&&(t=new Uint8Array(HE(e))),n||(n=0);const o=n;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),cE.encode(e,t,n),n+=cE.encode.bytes,n=jE(e.questions,LE,t,n),n=jE(e.answers,OE,t,n),n=jE(e.authorities,OE,t,n),n=jE(e.additionals,OE,t,n),DE.encode.bytes=n-o,r&&FE.bytes!==t.length?t.slice(0,FE.bytes):t},decode:function(e,t){t||(t=0);const n=t,r=cE.decode(e,t);return t+=cE.decode.bytes,t=VE(r.questions,LE,e,t),t=VE(r.answers,OE,e,t),t=VE(r.authorities,OE,e,t),t=VE(r.additionals,OE,e,t),DE.decode.bytes=t-n,r},encodingLength:function(e){return cE.encodingLength(e)+qE(e.questions||[],LE)+qE(e.answers||[],OE)+qE(e.authorities||[],OE)+qE(e.additionals||[],OE)}};function BE(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}DE.encode.bytes=0,DE.decode.bytes=0;const UE={encode:function(e,t,n){return t=DE.encode(BE(e,"query"),t,n),UE.encode.bytes=DE.encode.bytes,t},decode:function(e,t){const n=DE.decode(e,t);return UE.decode.bytes=DE.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return DE.encodingLength(BE(e,"query"))}};UE.encode.bytes=0,UE.decode.bytes=0;const ME={encode:function(e,t,n){return t=DE.encode(BE(e,"response"),t,n),ME.encode.bytes=DE.encode.bytes,t},decode:function(e,t){const n=DE.decode(e,t);return ME.decode.bytes=DE.decode.bytes,n.questions&&(n.question=n.questions[0],delete n.questions),n},encodingLength:function(e){return DE.encodingLength(BE(e,"response"))}};ME.encode.bytes=0,ME.decode.bytes=0;const FE=DE.encode,$E=DE.decode,HE=DE.encodingLength;function qE(e,t){let n=0;for(let r=0;r<e.length;r++)n+=t.encodingLength(e[r]);return n}function jE(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 VE(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 zE(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}zE("base64","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/","=",1);const KE=zE("base64-url","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_","=",2);let WE="undefined"!==typeof global?global.AbortError:"undefined"!==typeof window?window.AbortError:null;WE||(WE=class extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Request aborted.")}}),WE.prototype.name="AbortError",WE.prototype.code="ABORT_ERR";const GE="undefined"!==typeof globalThis&&globalThis.URL||require("url").URL;class YE 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}}}YE.prototype.name="HTTPStatusError",YE.prototype.code="HTTP_STATUS";class QE extends Error{constructor(e,t){super(e),this.cause=t}toJSON(){return{message:this.message,endpoint:this.endpoint,code:this.code,cause:eS(this.cause)}}}QE.prototype.name="ResponseError",QE.prototype.code="RESPONSE_ERR";class JE extends Error{constructor(e){super("Timeout (t="+e+")."),this.timeout=e}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}JE.prototype.name="TimeoutError",JE.prototype.code="ETIMEOUT";const XE=/^((\d{1,3}\.){3,3}\d{1,3})(:(\d{2,5}))?$/,ZE=/^((::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?)(:(\d{2,5}))?$/i;function eS(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 tS=/^(([a-z0-9]+:)\/\/)?([^/[\s:]+|\[[^\]]+\])?(:([^/\s]+))?(\/[^\s]*)?(.*)$/,nS=/\[(post|get|((ipv4|ipv6|name)=([^\]]+)))\]/gi,rS=/\[(((pk|name)=([^\]]+)))\]/gi;function oS(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 iS extends Error{constructor(e,t){super(`Invalid Endpoint: unsupported protocol "${e}" for endpoint: ${t}, supported protocols: ${sS.join(", ")}`),this.protocol=e,this.endpoint=t}toJSON(){return{code:this.code,endpoint:this.endpoint,timeout:this.timeout}}}iS.prototype.name="InvalidProtocolError",iS.prototype.code="EPROTOCOL";const sS=["http:","https:","udp4:","udp6:"];class aS{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 lS extends aS{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 cS extends lS{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 uS extends lS{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 dS(e){return ZE.test(e)&&!XE.test(e)?`[${e}]`:e}class hS extends aS{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=ZE.exec(this.host);e&&(this.ipv6=e[1])}this.ipv4||XE.test(this.host)&&(this.ipv4=this.host);const t=`${this.protocol}//${dS(this.host)}:${this.port}${this.path}`;try{this.url=new GE(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}${dS(this.host)}${t}${r}${n}${i}${s}${o}`}}function fS(e){let t;if("string"===typeof e)t=function(e){const t=tS.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=oS(s,nS);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=oS(s,rS),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 uS({protocol:"udp6:",ipv6:i[1],port:o,pk:t.pk,name:t.name}):new cS({protocol:"udp4:",ipv4:r,port:o,pk:t.pk,name:t.name})}throw new iS(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 aS)return e;t=e}null!==t.protocol&&void 0!==t.protocol||(t.protocol="https:");const n=t.protocol;if("udp4:"===n)return new cS(t);if("udp6:"===n)return new uS(t);if("https:"===n||"http:"===n)return new hS(t);throw new iS(n,JSON.stringify(t))}const pS="application/dns-message";function gS(){}function mS(e,t,n,r,o){return new Promise(((i,s)=>{const a=new GE(e);"GET"===t&&n&&(a.search="?dns="+KE.decode(n));const l=a.toString(),c=new XMLHttpRequest;c.open(t,l,!0),c.setRequestHeader("Accept",pS),"POST"===t&&c.setRequestHeader("Content-Type",pS),c.responseType="arraybuffer",c.timeout=r,c.ontimeout=function(){u(new JE(r));try{c.abort()}catch(e){}},c.onreadystatechange=function(){if(c.readyState>1&&200!==c.status&&0!==c.status){u(new YE(l,c.status,t));try{c.abort()}catch(e){}}},c.onerror=function(){u(200===c.status?new Error("Inexplicable XHR Error"):new YE(l,c.status,t))},c.onload=function(){if(200!==c.status)u(new YE(l,c.status,t));else{let e;if("string"===typeof c.response)e=zv(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=gS,o&&o.removeEventListener("abort",d),i(e?{error:e,response:c}:{data:t,response:c})};function d(){u(new WE);try{c.abort()}catch(e){}}}))}Error;function yS(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=fS(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 bS=yS({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 wS(e,t,n,r){return r&&r.aborted?Promise.reject(new WE):"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 mS(e,t,n,r,o)}(e.url,e.method,FE(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 QE("Empty.");else try{const e=$E(t);return e.response=n,e}catch(o){r=new QE("Invalid packet (cause="+o.message+")",o)}throw Object.assign(r,{response:n})}))}(e,t,n,r)}const vS=new GE("https://martinheidegger.github.io/dns-query/resolvers.json");function ES(e){return/^@/.test(e)}const SS=new class{constructor(e){this.opts=Object.assign({timeout:5e3,update:!0,updateURL:vS,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 mS(e,"GET",null,n,r),s={time:Date.now(),data:JSON.parse(Kv(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=>yS({data:e.data.resolvers,time:e.time}))).catch((()=>t||bS)):Promise.resolve(bS),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=_S),"dns"===e&&(e=IS),"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(ES))try{return Promise.resolve(e.map(fS))}catch(t){return Promise.reject(t)}return this.data().then((t=>e.map((e=>{if(ES(e)){const n=t.endpointByName[e.substring(1)];if(!n)throw new Error(`Endpoint ${e} is not known.`);return n}return fS(e)}))))}};function kS(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 AS(n.map(fS),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 AS(e,t,n){const r=1===e.length?e[0]:e[Math.floor(Math.random()*e.length)%e.length];return wS(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),AS(e,t,n)}))}function _S(e){return"https:"===e.protocol||"http:"===e.protocol}function IS(e){return"udp4:"===e.protocol||"udp6:"===e.protocol}const xS=new Cr("dns-over-https");class CS{endpoints;retries;static async create(e,t){const n=e??await SS.endpoints("doh");return new CS(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 kS({question:{type:"TXT",name:e}},{endpoints:this.endpoints,retries:this.retries})).answers}catch(o){throw xS.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 RS=__webpack_require__(5411);class TS{static RECORD_PREFIX=(()=>ev.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=TS.parseRootValues(e),r=RS.decode.asBytes(t),o=e.split(" sig")[0],i=gr(o);if(!Fw(Dt(n.signature,"base64url").slice(0,64),Mw(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 NS=new Cr("discovery:fetch_nodes");function PS(e,t){return t.relay>=e.relay&&t.store>=e.store&&t.filter>=e.filter&&t.lightPush>=e.lightPush}function OS(e,t){if(!e.nodeId)return!1;for(const n of t)if(e.nodeId===n.nodeId)return!1;return!0}function LS(e,t){e.relay&&(t.relay+=1),e.store&&(t.store+=1),e.filter&&(t.filter+=1),e.lightPush&&(t.lightPush+=1)}function DS(e,t,n){if(PS(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 BS=new Cr("discovery:dns");class US{dns;_DNSTreeCache;_errorTolerance=10;static async dnsOverHttp(e){return e||(e=await CS.create()),new US(e)}async getPeers(e,t){const n=Math.floor(Math.random()*e.length),{publicKey:r,domain:o}=TS.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(;!PS(r,i)&&s<o+t;){const e=await n();e&&OS(e,a)&&(e.waku2&&DS(e.waku2,r,i)&&(LS(e.waku2,i),a.push(e)),NS.info(`got new peer candidate from DNS address=${e.nodeId}@${e.ip}`)),s++}return a}(t,this._errorTolerance,(()=>this._search(o,i)));return BS.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}=TS.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(;!PS(r,i)&&s<o+t;){const e=await n();e&&e.nodeId&&!a.has(e.nodeId)&&(a.add(e.nodeId),e.waku2&&DS(e.waku2,r,i)&&(LS(e.waku2,i),yield e),NS.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(TS.ROOT_PREFIX)?TS.ROOT_PREFIX:e.startsWith(TS.BRANCH_PREFIX)?TS.BRANCH_PREFIX:e.startsWith(TS.RECORD_PREFIX)?TS.RECORD_PREFIX:""}(r);try{switch(s){case TS.ROOT_PREFIX:return o=TS.parseAndVerifyRoot(r,t.publicKey),await this._search(o,t);case TS.BRANCH_PREFIX:return i=TS.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 TS.RECORD_PREFIX:return Rv.fromString(r);default:return null}}catch(n){return BS.error(`Failed to search DNS tree ${s} at subdomain ${e}: ${n}`),null}}catch(n){return BS.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 MS=new Cr("peer-discovery-dns");class FS extends qo{nextPeer;_started;_components;_options;constructor(e,t){super(),this._started=!1,this._components=e,this._options=t;const{enrUrls:n}=t;MS.info("Use following EIP-1459 ENR Tree URLs: ",n)}async start(){MS.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 US.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={[Pb]:{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(Pb)||(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 jo("peer",{detail:t}))}}stop(){this._started=!1}get[Zh](){return!0}get[Symbol.toStringTag](){return lr}}function $S(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Ob;return n=>new FS(n,{enrUrls:e,wantedNodeCapabilityCount:t})}class HS{proto;constructor(e){this.proto=e}static createRequest(e){const{numPeers:t}=e;return new HS({query:{numPeers:t},response:void 0})}encode(){return An.encode(this.proto)}static decode(e){const t=An.decode(e);return new HS(t)}get query(){return this.proto.query}get response(){return this.proto.response}}const qS="/vac/waku/peer-exchange/2.0.0-alpha1",jS=new Cr("peer-exchange");class VS extends go{constructor(e,t){super(qS,e,jS,t)}async query(e){const{numPeers:t,peerId:n}=e,r=HS.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 jS.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}=HS.decode(e);if(!t)return jS.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 Rv.fromRLP(e)})))),error:null}}catch(a){return jS.error("Failed to decode push reply",a),{peerInfos:null,error:or.DECODE_FAILED}}}}const zS=new Cr("peer-exchange-discovery"),KS=1e4,WS=3,GS=ir.PEER_EXCHANGE;class YS extends qo{components;peerExchange;options;isStarted;queryingPeers=(()=>new Set)();queryAttempts=(()=>new Map)();handleDiscoveredPeer=e=>{const{protocols:t,peerId:n}=e.detail;t.includes(qS)&&!this.queryingPeers.has(n.toString())&&(this.queryingPeers.add(n.toString()),this.startRecurringQueries(n).catch((e=>zS.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 VS(e,t),this.options=n,this.isStarted=!1}start(){this.isStarted||(this.dispatchEvent(new jo("waku:peer-exchange:started",{detail:!0})),zS.info("Starting peer exchange node discovery, discovering peers"),this.components.events.addEventListener("peer:identify",this.handleDiscoveredPeer))}stop(){this.isStarted&&(zS.info("Stopping peer exchange node discovery"),this.isStarted=!1,this.queryingPeers.clear(),this.components.events.removeEventListener("peer:identify",this.handleDiscoveredPeer))}get[Zh](){return!0}get[Symbol.toStringTag](){return"@waku/peer-exchange"}startRecurringQueries=async e=>{const t=e.toString(),{queryInterval:n=KS,maxRetries:r=WS}=this.options;zS.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=>{zS.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 zS.error("Peer exchange query failed",t),{error:t,peerInfos:null};for(const r of n){const{ENR:e}=r;if(!e){zS.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){zS.info(`Peer ${t.toString()} has updated multiaddrs or shardInfo, updating`),e&&(zS.info(`Peer ${t.toString()} has updated multiaddrs, updating`),await this.components.peerStore.patch(t,{multiaddrs:n.multiaddrs})),r&&o&&(zS.info(`Peer ${t.toString()} has updated shardInfo, updating`),await this.components.peerStore.merge(t,{metadata:{shardInfo:_r(o)}}),this.dispatchEvent(new jo("peer",{detail:{id:t,multiaddrs:n.multiaddrs}})));continue}}await this.components.peerStore.save(t,{tags:{[GS]:{value:this.options.tagValue??50,ttl:this.options.tagTTL??1e8}},...o&&{metadata:{shardInfo:_r(o)}},...n.multiaddrs&&{multiaddrs:n.multiaddrs}}),zS.info(`Discovered peer: ${t.toString()}`),this.dispatchEvent(new jo("peer",{detail:{id:t,multiaddrs:n.multiaddrs}}))}return{error:null,peerInfos:n}}abortQueriesForPeer(e){zS.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 QS(e){return t=>new YS(t,e)}const JS=new Cr("peer-exchange-discovery"),XS=ir.LOCAL;class ZS extends qo{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){JS.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 Gg({id:e});await this.components.peerStore.has(n)||(await this.components.peerStore.save(n,{multiaddrs:[Bi(t)],tags:{[this.options?.tagName??XS]:{value:this.options?.tagValue??50,ttl:this.options?.tagTTL??1e8}}}),this.dispatchEvent(new jo("peer",{detail:{id:n,multiaddrs:[Bi(t)]}})))}JS.info(`Discovered ${this.peers.length} peers`),this.isStarted=!0}}stop(){this.isStarted&&(JS.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(ek)}catch(e){return JS.error("Error parsing peers from local storage:",e),[]}}savePeersToLocalStorage(){try{localStorage.setItem("waku:peers",JSON.stringify(this.peers))}catch(e){JS.error("Error saving peers to local storage:",e)}}}function ek(e){return e&&"object"===typeof e&&"string"===typeof e.id&&"string"===typeof e.address}const tk=new Cr("sdk:create");async function nk(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:Zo(e)}:{};return async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=await Rb(e);return!1!==e.start&&await t.start(),t}({connectionManager:{minConnections:1},transports:[xg({filter:!1===t?.filterMultiaddrs?Ag:_g})],streamMuxers:[rg()],connectionEncryption:[Xh()],...t,services:{identify:Pp({agentVersion:n??"js-waku"}),ping:ag({maxInboundStreams:t?.pingMaxInboundStreams??10}),...r,...t?.services}})}async function rk(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);tk.info("Creating Waku node with pubsub topics",n);const r=e?.libp2p??{},o=r.peerDiscovery??[];var i;e?.defaultBootstrap&&o.push(...function(e){return[$S([Tb,Nb]),(e,t)=>new ZS(e,t),QS(e)]}(n)),e?.bootstrapPeers&&o.push((i={list:e.bootstrapPeers},e=>new Of(e,i))),r.peerDiscovery=o;return{libp2p:await nk(n,r,e?.userAgent),pubsubTopics:n}}const ok="/js-waku-examples/1/message-ratio/utf8",ik=Sr(ok),sk={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",ak=["/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 lk(){const e=await async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{libp2p:t,pubsubTopics:n}=await rk(e);return new hs(n,e,t,{store:!0,lightpush:!0,filter:!0})}({networkConfig:{contentTopics:[ok]},defaultBootstrap:!0});return await e.start(),await Promise.all(function(){return ak.map((e=>Bi(e)))}().map((t=>e.dial(t)))),await ls(e),e}var ck=__webpack_require__(4412);const uk=new ck.Type("SequencedMessage").add(new ck.Field("hash",1,"string")).add(new ck.Field("total",2,"uint64")).add(new ck.Field("index",3,"uint64")).add(new ck.Field("sender",4,"string")),dk=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("")},hk={sdk:"0.0.28"},fk=(JSON.stringify(hk),async(e,t)=>{const n=await e.libp2p.peerStore.get(Cd(t)),r=n.addresses.map((e=>e.multiaddr.toString())).some((e=>e.includes("ws")||e.includes("wss")));return JSON.stringify({...hk,peerId:t,hasWebsockes:r,enabledProtocols:n.protocols})});let pk=function(e){return e.LIGHT_PUSH_FILTER="LightPushFilter",e}({});async function gk(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 dk(Math.floor(1e6*Math.random()).toString()),c=s;let u=0;const d=Or({contentTopic:ok}),h=async()=>{try{const f=await dk(`${l}-${u}-${c}`),p=Math.floor((new Date).getTime()/1e3),g=uk.create({hash:f,total:c,index:u,sender:e.libp2p.peerId.toString()}),m=uk.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 fk(e,t.toString());return{type:pk.LIGHT_PUSH_FILTER,protocol:"lightPush",timestamp:p,createdAt:p,seenTimestamp:p,peerId:t.toString(),contentTopic:ok,pubsubTopic:ik,ephemeral:!1,messageHash:f,errorMessage:"",extraData:n}})),...y.failures.map((async t=>{var n,r,o,i,s,a;const l=await fk(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:pk.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:ok,pubsubTopic:ik,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)}else{const e=JSON.stringify({content:`Failed to send message ${u+1} of ${c}`,success:!1});n(e,!1)}if(u++,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),o(null),i.current=!1,setTimeout((()=>gk(e,t,n,r,o,i,s,a)),a)}catch(f){console.error("Error sending message",f);const l=JSON.stringify({content:`Error sending message ${u+1} of ${c}`,success:!1});n(l,!1),u++,u<c?setTimeout((()=>h()),a):(console.info("Lightpush sequence completed with errors"),r(u),o(null),i.current=!1,setTimeout((()=>gk(e,t,n,r,o,i,s,a)),a))}};h()}async function mk(e,t,n){const r=new Lr(kr(o=ok,i),o);var o,i;const s=e.libp2p.peerId.toString();await e.filter.subscribe([r],(async r=>{var o,i;const a=uk.decode(r.payload),l=`${a.hash} - ${a.index+1} of ${a.total}`,c=a.sender===s;n(l,c);const u=await fk(e,s),d=Math.floor((new Date).getTime()/1e3);t.push([{type:pk.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 yk{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 bk=__webpack_require__(579);const wk=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].push(t),e)),{}):{0:n},a=Object.entries(s).sort(((e,t)=>Number(t[0])-Number(e[0])));return 0===n.length?(0,bk.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,bk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:t}),(0,bk.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 h-96 flex items-center justify-center",children:(0,bk.jsx)("p",{className:"text-gray-500",children:"Waiting for messages..."})})]}):(0,bk.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,bk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:t}),(0,bk.jsx)("div",{className:"bg-gray-50 rounded-lg p-4 h-96 overflow-y-auto border border-gray-200",children:a.map((e=>{let[t,n]=e;return(0,bk.jsxs)("div",{className:`mb-4 p-2 rounded-lg ${r?i(Number(t)):""}`,children:[r&&(0,bk.jsxs)("div",{className:"text-xs font-semibold mb-2",children:["Sequence ",t]}),n.sort(((e,t)=>t.timestamp-e.timestamp)).map(((e,t)=>(0,bk.jsx)("div",{className:"text-sm mb-2 font-mono bg-white p-2 rounded shadow-sm",children:o(e.content)},t)))]},t)}))})]})},vk=e=>{let{stats:t}=e;return(0,bk.jsxs)("div",{className:"mt-8",children:[(0,bk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:"Stats"}),(0,bk.jsxs)("div",{className:"grid grid-cols-3 gap-6",children:[(0,bk.jsxs)("div",{className:"bg-blue-50 p-4 rounded-lg shadow",children:[(0,bk.jsx)("p",{className:"text-sm font-medium text-blue-600",children:"Sent"}),(0,bk.jsx)("p",{className:"text-2xl font-bold text-blue-800",children:t.sent})]}),(0,bk.jsxs)("div",{className:"bg-green-50 p-4 rounded-lg shadow",children:[(0,bk.jsx)("p",{className:"text-sm font-medium text-green-600",children:"Received"}),(0,bk.jsx)("p",{className:"text-2xl font-bold text-green-800",children:t.received})]}),(0,bk.jsxs)("div",{className:"bg-yellow-50 p-4 rounded-lg shadow",children:[(0,bk.jsx)("p",{className:"text-sm font-medium text-yellow-600",children:"Self-Received"}),(0,bk.jsx)("p",{className:"text-2xl font-bold text-yellow-800",children:t.selfReceived})]})]})]})},Ek=e=>{let{countdown:t}=e;return null===t?null:(0,bk.jsx)("div",{className:"text-center text-gray-600 mt-4",children:(0,bk.jsxs)("p",{children:["Next message in: ",t," seconds"]})})},Sk=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,bk.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,bk.jsxs)("div",{className:"flex items-center",children:[(0,bk.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,bk.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),(0,bk.jsx)("span",{children:"Message sent successfully"})]}):(0,bk.jsxs)("div",{className:"flex items-center",children:[(0,bk.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,bk.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),(0,bk.jsx)("span",{children:"Failed to send message"})]})}):null};let kk=1;const Ak=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 lk(),n=new yk(sk);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);mk(e,n,((e,t)=>{const n={content:e,sequenceId:kk,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}))))}));gk(e,n,((e,n)=>{const r={content:e,sequenceId:kk,timestamp:Date.now()};t((e=>[r,...e])),a((e=>({...e,sent:e.sent+1}))),d(n)}),(e=>{kk=1===e?1:kk+1,console.log("Updated sequence ID to:",kk)}),c,p)})()}),[]),(0,bk.jsx)("div",{className:"min-h-screen bg-gray-100 p-8",children:(0,bk.jsxs)("div",{className:"max-w-7xl mx-auto",children:[(0,bk.jsx)("h1",{className:"text-4xl font-bold text-gray-800 mb-8",children:"Waku Message Monitor"}),(0,bk.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[(0,bk.jsxs)("div",{className:"space-y-8",children:[(0,bk.jsx)(wk,{title:"Sent Messages",messages:e.reverse(),showSequence:!0}),(0,bk.jsx)(wk,{title:"Received Messages",messages:n,showSequence:!1})]}),(0,bk.jsxs)("div",{className:"space-y-8",children:[(0,bk.jsx)(wk,{title:"Self-Received Messages",messages:o,showSequence:!0}),(0,bk.jsx)(vk,{stats:s}),(0,bk.jsxs)("div",{className:"bg-white rounded-lg shadow p-6",children:[(0,bk.jsx)("h2",{className:"text-xl font-semibold mb-4 text-gray-700",children:"Node Info"}),(0,bk.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,bk.jsxs)("div",{children:[(0,bk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"Total Connections"}),(0,bk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.totalConnections})]}),(0,bk.jsxs)("div",{children:[(0,bk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"Filter Peers"}),(0,bk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.filterPeers})]}),(0,bk.jsxs)("div",{children:[(0,bk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"LightPush Peers"}),(0,bk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.lightPushPeers})]}),(0,bk.jsxs)("div",{children:[(0,bk.jsx)("p",{className:"text-sm font-medium text-gray-500",children:"Store Peers"}),(0,bk.jsx)("p",{className:"text-lg font-semibold text-gray-800",children:h.storePeers})]})]})]})]})]}),(0,bk.jsx)(Ek,{countdown:l}),(0,bk.jsx)(Sk,{success:u})]})})};w.createRoot(document.getElementById("root")).render((0,bk.jsx)(b.StrictMode,{children:(0,bk.jsx)(Ak,{})}))})()})();
//# sourceMappingURL=main.47860875.js.map