@dodoex/wallet-web3 0.0.64 → 0.0.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/{alchemy-provider-5870b6fa-457cd6bb.js → alchemy-provider-5870b6fa-66fa57c4.js} +1 -1
  2. package/dist/{alchemy-websocket-provider-213da986-746c5eca.js → alchemy-websocket-provider-213da986-81f5908b.js} +1 -1
  3. package/dist/{blocto-ee2a838e.js → blocto-a0fb786c.js} +1 -1
  4. package/dist/{ccip-c55250b6.js → ccip-8057d290.js} +1 -1
  5. package/dist/cjs/{alchemy-provider-5870b6fa-1de644f2.cjs → alchemy-provider-5870b6fa-ae5f424d.cjs} +1 -1
  6. package/dist/cjs/{alchemy-websocket-provider-213da986-e220e8bd.cjs → alchemy-websocket-provider-213da986-d62eca48.cjs} +1 -1
  7. package/dist/cjs/{blocto-0a1f8c82.cjs → blocto-0d2f6547.cjs} +1 -1
  8. package/dist/cjs/{ccip-6d742628.cjs → ccip-32d25bb9.cjs} +1 -1
  9. package/dist/cjs/{draggabilly-8dcddcae.cjs → draggabilly-9a233d31.cjs} +1 -1
  10. package/dist/cjs/id-cd1c0250.cjs +1 -0
  11. package/dist/cjs/{index-fed98538.cjs → index-0d072f8e.cjs} +1 -1
  12. package/dist/cjs/{index-fe9fcb08.cjs → index-28ccfd4f.cjs} +1 -1
  13. package/dist/cjs/{index-91f65724.cjs → index-42d4f376.cjs} +3 -3
  14. package/dist/cjs/{index-b0f51d7d.cjs → index-51df874d.cjs} +1 -1
  15. package/dist/cjs/{index-3d1bc02e.cjs → index-530ea415.cjs} +1 -1
  16. package/dist/cjs/{index-78ce40b2.cjs → index-702527b2.cjs} +2 -2
  17. package/dist/cjs/{index-dcff3fbf.cjs → index-99530e6c.cjs} +1 -1
  18. package/dist/cjs/{index-b10f5546.cjs → index-a6e52f1a.cjs} +2 -2
  19. package/dist/cjs/{index-db3fa985.cjs → index-c17746ed.cjs} +1 -1
  20. package/dist/cjs/{index-6cb4d019.cjs → index-e6e26ad5.cjs} +1 -1
  21. package/dist/cjs/index.cjs +1 -1
  22. package/dist/cjs/{index.es-75a30b77.cjs → index.es-d4262962.cjs} +1 -1
  23. package/dist/cjs/{interface-1412cfee.cjs → interface-e004907f.cjs} +1 -1
  24. package/dist/cjs/{lib-typedarrays-45edc54c.cjs → lib-typedarrays-dbe83bf4.cjs} +1 -1
  25. package/dist/cjs/{portis-9ac42c6a.cjs → portis-9e401273.cjs} +1 -1
  26. package/dist/cjs/{provider-25d93a69.cjs → provider-7bfbbff3.cjs} +1 -1
  27. package/dist/cjs/{rainbow-a04db469.cjs → rainbow-6331cb27.cjs} +1 -1
  28. package/dist/cjs/{sha224-2fadd06e.cjs → sha224-0d4d6fdd.cjs} +1 -1
  29. package/dist/cjs/{sha256-9f8015ea.cjs → sha256-3aa003e0.cjs} +1 -1
  30. package/dist/cjs/{typed-data-dde4a66f.cjs → typed-data-01967235.cjs} +1 -1
  31. package/dist/cjs/{uAuth-ea317035.cjs → uAuth-766da269.cjs} +1 -1
  32. package/dist/cjs/{walletConnect-15fc29df.cjs → walletConnect-0c48b404.cjs} +1 -1
  33. package/dist/cjs/{walletLink-3ac9efad.cjs → walletLink-99768078.cjs} +2 -2
  34. package/dist/{draggabilly-e028ec41.js → draggabilly-042d2baf.js} +1 -1
  35. package/dist/id-06102aea.js +1 -0
  36. package/dist/{index-7a5a2895.js → index-2461634e.js} +1 -1
  37. package/dist/{index-e9aacae8.js → index-553ce10b.js} +1 -1
  38. package/dist/{index-1256acc9.js → index-75136e75.js} +1 -1
  39. package/dist/{index-5772df94.js → index-7d9f2ac0.js} +3 -3
  40. package/dist/{index-26ab1f42.js → index-7ed0e2da.js} +2 -2
  41. package/dist/{index-fa8ae676.js → index-938018a1.js} +1 -1
  42. package/dist/{index-b559a26e.js → index-bd8e8702.js} +1 -1
  43. package/dist/{index-239ddf05.js → index-d9830b67.js} +1 -1
  44. package/dist/{index-af74b255.js → index-ea4428da.js} +2 -2
  45. package/dist/{index-de37a495.js → index-fa54ba53.js} +1 -1
  46. package/dist/{index.es-3b789bf9.js → index.es-938556e7.js} +1 -1
  47. package/dist/index.js +1 -1
  48. package/dist/{interface-001cd30f.js → interface-424d0728.js} +1 -1
  49. package/dist/{lib-typedarrays-0f3d7cfd.js → lib-typedarrays-7ec5ace4.js} +1 -1
  50. package/dist/{portis-aa99a2cc.js → portis-df3f2ecc.js} +1 -1
  51. package/dist/{provider-ed732881.js → provider-c1f0eadb.js} +1 -1
  52. package/dist/{rainbow-1636f787.js → rainbow-9dbf58c4.js} +1 -1
  53. package/dist/{sha224-3bdc932c.js → sha224-f656013d.js} +1 -1
  54. package/dist/{sha256-4da40dc5.js → sha256-1f582b12.js} +1 -1
  55. package/dist/{typed-data-1847b6ed.js → typed-data-869afd88.js} +1 -1
  56. package/dist/{uAuth-d30d3c61.js → uAuth-2faa4403.js} +1 -1
  57. package/dist/{walletConnect-f307066d.js → walletConnect-590ee7ef.js} +1 -1
  58. package/dist/{walletLink-091917c3.js → walletLink-af9b8335.js} +2 -2
  59. package/package.json +1 -1
  60. package/dist/cjs/id-a70f30cf.cjs +0 -1
  61. package/dist/id-17eaf985.js +0 -1
@@ -1,4 +1,4 @@
1
- import{c as e,_ as t,A as n}from"./index-5772df94.js";import{v as r,a as i}from"./v4-95658a31.js";import"@ethersproject/address";import"@ethersproject/providers";import"zustand";import"@ethersproject/bytes";import"@ethersproject/properties";import"@ethersproject/abstract-signer";import"buffer";import"@ethersproject/abstract-provider";import"@ethersproject/contracts";import"events";import"@ethersproject/constants";import"@ethersproject/transactions";var o={exports:{}};!function(t,n){var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e&&e,i=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var n=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==n&&n,r={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function u(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function h(e){var t=new FileReader,n=u(t);return t.readAsArrayBuffer(e),n}function f(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=f(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=f(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=d(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(h)}),this.text=function(){var e,t,n,r=d(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=u(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=a(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=a(t)},l.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),c(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),c(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),c(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,r,i=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function y(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function v(e,t){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},p.call(m.prototype),p.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var b=[301,302,303,307,308];v.redirect=function(e,t){if(-1===b.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},t.DOMException=n.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function w(e,i){return new Promise((function(o,s){var c=new m(e,i);if(c.signal&&c.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function u(){d.abort()}d.onload=function(){var e,t,n={status:d.status,statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};n.url="responseURL"in d?d.responseURL:n.headers.get("X-Request-URL");var r="response"in d?d.response:d.responseText;setTimeout((function(){o(new v(r,n))}),0)},d.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.onabort=function(){setTimeout((function(){s(new t.DOMException("Aborted","AbortError"))}),0)},d.open(c.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(c.url),!0),"include"===c.credentials?d.withCredentials=!0:"omit"===c.credentials&&(d.withCredentials=!1),"responseType"in d&&(r.blob?d.responseType="blob":r.arrayBuffer&&c.headers.get("Content-Type")&&-1!==c.headers.get("Content-Type").indexOf("application/octet-stream")&&(d.responseType="arraybuffer")),!i||"object"!=typeof i.headers||i.headers instanceof l?c.headers.forEach((function(e,t){d.setRequestHeader(t,e)})):Object.getOwnPropertyNames(i.headers).forEach((function(e){d.setRequestHeader(e,a(i.headers[e]))})),c.signal&&(c.signal.addEventListener("abort",u),d.onreadystatechange=function(){4===d.readyState&&c.signal.removeEventListener("abort",u)}),d.send(void 0===c._bodyInit?null:c._bodyInit)}))}w.polyfill=!0,n.fetch||(n.fetch=w,n.Headers=l,n.Request=m,n.Response=v),t.Headers=l,t.Request=m,t.Response=v,t.fetch=w}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=r.fetch?r:i;(n=o.fetch).default=o.fetch,n.fetch=o.fetch,n.Headers=o.Headers,n.Request=o.Request,n.Response=o.Response,t.exports=n}(o,o.exports);var s,a,c=o.exports,l={exports:{}};function d(){if(a)return s;a=1;var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function c(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return s=function(s,a){a=a||{};var l=typeof s;if("string"===l&&s.length>0)return function(s){if((s=String(s)).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(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===l&&isFinite(s))return a.long?function(i){var o=Math.abs(i);if(o>=r)return c(i,o,r,"day");if(o>=n)return c(i,o,n,"hour");if(o>=t)return c(i,o,t,"minute");if(o>=e)return c(i,o,e,"second");return i+" ms"}(s):function(i){var o=Math.abs(i);if(o>=r)return Math.round(i/r)+"d";if(o>=n)return Math.round(i/n)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))},s}var u=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}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:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===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,]+/),i=r.length;for(n=0;n<i;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=d(),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};!function(e,t){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,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=u(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(l,l.exports);var h,f=l.exports,p={exports:{}};
1
+ import{c as e,_ as t,A as n}from"./index-7d9f2ac0.js";import{v as r,a as i}from"./v4-95658a31.js";import"@ethersproject/address";import"@ethersproject/providers";import"zustand";import"@ethersproject/bytes";import"@ethersproject/properties";import"@ethersproject/abstract-signer";import"buffer";import"@ethersproject/abstract-provider";import"@ethersproject/contracts";import"events";import"@ethersproject/constants";import"@ethersproject/transactions";var o={exports:{}};!function(t,n){var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==e&&e,i=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();!function(e){!function(t){var n=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==n&&n,r={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};if(r.arrayBuffer)var i=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(e){return e&&i.indexOf(Object.prototype.toString.call(e))>-1};function s(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function a(e){return"string"!=typeof e&&(e=String(e)),e}function c(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function l(e){this.map={},e instanceof l?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function u(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function h(e){var t=new FileReader,n=u(t);return t.readAsArrayBuffer(e),n}function f(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function p(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:r.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:r.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():r.arrayBuffer&&r.blob&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=f(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=f(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=d(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(h)}),this.text=function(){var e,t,n,r=d(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=u(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},r.formData&&(this.formData=function(){return this.text().then(y)}),this.json=function(){return this.text().then(JSON.parse)},this}l.prototype.append=function(e,t){e=s(e),t=a(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},l.prototype.delete=function(e){delete this.map[s(e)]},l.prototype.get=function(e){return e=s(e),this.has(e)?this.map[e]:null},l.prototype.has=function(e){return this.map.hasOwnProperty(s(e))},l.prototype.set=function(e,t){this.map[s(e)]=a(t)},l.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},l.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),c(e)},l.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),c(e)},l.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),c(e)},r.iterable&&(l.prototype[Symbol.iterator]=l.prototype.entries);var g=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function m(e,t){if(!(this instanceof m))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');var n,r,i=(t=t||{}).body;if(e instanceof m){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new l(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,i||null==e._bodyInit||(i=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new l(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),g.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function y(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),i=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(i))}})),t}function v(e,t){if(!(this instanceof v))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new l(t.headers),this.url=t.url||"",this._initBody(e)}m.prototype.clone=function(){return new m(this,{body:this._bodyInit})},p.call(m.prototype),p.call(v.prototype),v.prototype.clone=function(){return new v(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new l(this.headers),url:this.url})},v.error=function(){var e=new v(null,{status:0,statusText:""});return e.type="error",e};var b=[301,302,303,307,308];v.redirect=function(e,t){if(-1===b.indexOf(t))throw new RangeError("Invalid status code");return new v(null,{status:t,headers:{location:e}})},t.DOMException=n.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function w(e,i){return new Promise((function(o,s){var c=new m(e,i);if(c.signal&&c.signal.aborted)return s(new t.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function u(){d.abort()}d.onload=function(){var e,t,n={status:d.status,statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new l,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var i=n.join(":").trim();t.append(r,i)}})),t)};n.url="responseURL"in d?d.responseURL:n.headers.get("X-Request-URL");var r="response"in d?d.response:d.responseText;setTimeout((function(){o(new v(r,n))}),0)},d.onerror=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.ontimeout=function(){setTimeout((function(){s(new TypeError("Network request failed"))}),0)},d.onabort=function(){setTimeout((function(){s(new t.DOMException("Aborted","AbortError"))}),0)},d.open(c.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(c.url),!0),"include"===c.credentials?d.withCredentials=!0:"omit"===c.credentials&&(d.withCredentials=!1),"responseType"in d&&(r.blob?d.responseType="blob":r.arrayBuffer&&c.headers.get("Content-Type")&&-1!==c.headers.get("Content-Type").indexOf("application/octet-stream")&&(d.responseType="arraybuffer")),!i||"object"!=typeof i.headers||i.headers instanceof l?c.headers.forEach((function(e,t){d.setRequestHeader(t,e)})):Object.getOwnPropertyNames(i.headers).forEach((function(e){d.setRequestHeader(e,a(i.headers[e]))})),c.signal&&(c.signal.addEventListener("abort",u),d.onreadystatechange=function(){4===d.readyState&&c.signal.removeEventListener("abort",u)}),d.send(void 0===c._bodyInit?null:c._bodyInit)}))}w.polyfill=!0,n.fetch||(n.fetch=w,n.Headers=l,n.Request=m,n.Response=v),t.Headers=l,t.Request=m,t.Response=v,t.fetch=w}({})}(i),i.fetch.ponyfill=!0,delete i.fetch.polyfill;var o=r.fetch?r:i;(n=o.fetch).default=o.fetch,n.fetch=o.fetch,n.Headers=o.Headers,n.Request=o.Request,n.Response=o.Response,t.exports=n}(o,o.exports);var s,a,c=o.exports,l={exports:{}};function d(){if(a)return s;a=1;var e=1e3,t=60*e,n=60*t,r=24*n,i=7*r,o=365.25*r;function c(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}return s=function(s,a){a=a||{};var l=typeof s;if("string"===l&&s.length>0)return function(s){if((s=String(s)).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(s);if(!a)return;var c=parseFloat(a[1]);switch((a[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*i;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===l&&isFinite(s))return a.long?function(i){var o=Math.abs(i);if(o>=r)return c(i,o,r,"day");if(o>=n)return c(i,o,n,"hour");if(o>=t)return c(i,o,t,"minute");if(o>=e)return c(i,o,e,"second");return i+" ms"}(s):function(i){var o=Math.abs(i);if(o>=r)return Math.round(i/r)+"d";if(o>=n)return Math.round(i/n)+"h";if(o>=t)return Math.round(i/t)+"m";if(o>=e)return Math.round(i/e)+"s";return i+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))},s}var u=function(e){function t(e){let r,i,o,s=null;function a(...e){if(!a.enabled)return;const n=a,i=Number(new Date),o=i-(r||i);n.diff=o,n.prev=r,n.curr=i,r=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let s=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((r,i)=>{if("%%"===r)return"%";s++;const o=t.formatters[i];if("function"==typeof o){const t=e[s];r=o.call(n,t),e.splice(s,1),s--}return r})),t.formatArgs.call(n,e);(n.log||t.log).apply(n,e)}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:(i!==t.namespaces&&(i=t.namespaces,o=t.enabled(e)),o),set:e=>{s=e}}),"function"==typeof t.init&&t.init(a),a}function n(e,n){const r=t(this.namespace+(void 0===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,]+/),i=r.length;for(n=0;n<i;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=d(),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};!function(e,t){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,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=u(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(l,l.exports);var h,f=l.exports,p={exports:{}};
2
2
  /*!
3
3
  * EventEmitter2
4
4
  * https://github.com/hij1nx/EventEmitter2
@@ -6,4 +6,4 @@ import{c as e,_ as t,A as n}from"./index-5772df94.js";import{v as r,a as i}from"
6
6
  * Copyright (c) 2013 hij1nx
7
7
  * Licensed under the MIT license.
8
8
  */
9
- h=p,function(e){var t=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r="object"==typeof process&&"function"==typeof process.nextTick,i="function"==typeof Symbol,o="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,a=i?o&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&l.call(this,this._conf)}function l(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,process.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var u=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}};function f(t,n){for(var r={},i=t.length,o=n?n.length:0,s=0;s<i;s++)r[t[s]]=s<o?n[s]:e;return r}function p(e,t,n){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function g(n,r,i,o){var s=Object.assign({},r);if(!n)return s;if("object"!=typeof n)throw TypeError("options must be an object");var a,c,l,d=Object.keys(n),u=d.length;function h(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<u;f++){if(a=d[f],!o&&!t.call(r,a))throw Error('Unknown "'+a+'" option');(c=n[a])!==e&&(l=i[a],s[a]=l?l(c,h):c)}return s}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(typeof e===r)return e;n(t)}:2===n?function(e,n){var o=typeof e;if(o===r||o===i)return e;n(t)}:function(r,i){for(var o=typeof r,s=n;s-- >0;)if(o===e[s])return r;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var r=u.apply(null,arguments),s={data:r,name:t,original:e};n?!1!==n.call(i,s)&&o.emit.apply(o,[s.name].concat(r)):o.emit.apply(o,[t].concat(r))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===s[e]&&(s[e]=a,r._on.call(i,e,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!o.hasListeners(n)&&s[e]&&(s[e]=null,r._off.call(i,e,a))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=a,r._on.call(i,e,a))},unsubscribe:function(e){var t,n,r,i=this,o=this._listeners,s=this._emitter,c=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function d(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=E.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=o[e]))return;c.call(l,e,t),delete o[e],--this._listenersCount||d()}else{for(r=(n=a(o)).length;r-- >0;)e=n[r],c.call(l,e,o[e]);this._listeners={},this._listenersCount=0,d()}}});var v=y(["function"]),b=y(["object","function"]);function w(e,t,n){var r,i,o,s=0,a=new e((function(c,l,d){function u(){i&&(i=null),s&&(clearTimeout(s),s=0)}n=g(n,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),r=!n.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof d;var h=function(e){u(),c(e)},f=function(e){u(),l(e)};r?t(h,f,d):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),n.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),l(e)}),n.timeout))}));return r||(a.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),a}function E(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function C(e,t,n,r,i){if(!n)return null;if(0===r){var o=typeof t;if("string"===o){var s,c,l=0,d=0,u=this.delimiter,h=u.length;if(-1!==(c=t.indexOf(u))){s=new Array(5);do{s[l++]=t.slice(d,c),d=c+h}while(-1!==(c=t.indexOf(u,d)));s[l++]=t.slice(d),t=s,i=l}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,p,g,m,y,v,b,w=null,E=t[r],_=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),w=[n]):(e&&e.push.apply(e,n._listeners),w=[n]));else{if("*"===E){for(c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&(b=C(e,t,n[f],r+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===E){for((y=r+1===i||r+2===i&&"*"===_)&&n._listeners&&(w=C(e,t,n,i,i)),c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&("*"===f||"**"===f?(n[f]._listeners&&!y&&(b=C(e,t,n[f],i,i))&&(w?w.push.apply(w,b):w=b),b=C(e,t,n[f],r,i)):b=C(e,t,n[f],f===_?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[E]&&(w=C(e,t,n[E],r+1,i))}if((p=n["*"])&&C(e,t,p,r+1,i),g=n["**"])if(r<i)for(g._listeners&&C(e,t,g,i,i),c=(v=a(g)).length;c-- >0;)"_listeners"!==(f=v[c])&&(f===_?C(e,t,g[f],r+2,i):f===E?C(e,t,g[f],r+1,i):((m={})[f]=g[f],C(e,t,{"**":m},r+1,i)));else g._listeners?C(e,t,g,i,i):g["*"]&&g["*"]._listeners&&C(e,t,g["*"],i,i);return w}function _(e,t,n){var r,i,o=0,s=0,a=this.delimiter,c=a.length;if("string"==typeof e)if(-1!==(r=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,r),s=r+c}while(-1!==(r=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(r=0;r+1<o;r++)if("**"===i[r]&&"**"===i[r+1])return;var l,u=this.listenerTree;for(r=0;r<o;r++)if(u=u[l=i[r]]||(u[l]={}),r===o-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),n?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,d.call(this,u._listeners.length,l))):u._listeners=t,!0;return!0}function S(e,t,n,r){for(var i,o,s,c,l=a(e),d=l.length,u=e._listeners;d-- >0;)i=e[o=l[d]],s="_listeners"===o?n:n?n.concat(o):[o],c=r||"symbol"==typeof o,u&&t.push(c?s:s.join(this.delimiter)),"object"==typeof i&&S.call(this,i,t,s,c);return t}function k(e){for(var t,n,r,i=a(e),o=i.length;o-- >0;)(t=e[n=i[o]])&&(r=!0,"_listeners"===n||k(t)||delete e[n]);return r}function x(e,t,n){this.emitter=e,this.event=t,this.listener=n}function A(t,n,i){if(!0===i)a=!0;else if(!1===i)o=!0;else{if(!i||"object"!=typeof i)throw TypeError("options should be an object or true");var o=i.async,a=i.promisify,c=i.nextTick,l=i.objectify}if(o||c||a){var d=n,u=n._origin||n;if(c&&!r)throw Error("process.nextTick is not supported");a===e&&(a="AsyncFunction"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return a?c?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=n,d.apply(t,e)})):(c?process.nextTick:s)((function(){t.event=n,d.apply(t,e)}))},n._async=!0,n._origin=u}return[n,l?new x(this,t,n):this]}function M(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},M.EventEmitter2=M,M.prototype.listenTo=function(t,r,i){if("object"!=typeof t)throw TypeError("target musts be an object");var o=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var n,r=i.reducers,s=E.call(o,t);n=-1===s?new p(o,t,i):o._observers[s];for(var c,l=a(e),d=l.length,u="function"==typeof r,h=0;h<d;h++)c=l[h],n.subscribe(c,e[c]||c,u?r:r&&r[c])}return i=g(i,{on:e,off:e,reducers:e},{on:v,off:v,reducers:b}),n(r)?s(f(r)):s("string"==typeof r?f(r.split(/\s+/)):r),this},M.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),o=!0);return o},M.prototype.delimiter=".",M.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},M.prototype.getMaxListeners=function(){return this._maxListeners},M.prototype.event="",M.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},M.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},M.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},M.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},M.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},M.prototype._many=function(e,t,n,r,i){var o=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&o.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,r,i)},M.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(n=a.length,i)for(r=0;r<n;r++)if("symbol"==typeof a[r]){s=!0;break}s||(a=a.join(this.delimiter))}var d,u=arguments.length;if(this._all&&this._all.length)for(r=0,n=(d=this._all.slice()).length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this,a);break;case 2:d[r].call(this,a,arguments[1]);break;case 3:d[r].call(this,a,arguments[1],arguments[2]);break;default:d[r].apply(this,arguments)}if(l)d=[],C.call(this,d,e,this.listenerTree,0,n);else{if("function"==typeof(d=this._events[a])){switch(this.event=a,u){case 1:d.call(this);break;case 2:d.call(this,arguments[1]);break;case 3:d.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];d.apply(this,t)}return!0}d&&(d=d.slice())}if(d&&d.length){if(u>3)for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];for(r=0,n=d.length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this);break;case 2:d[r].call(this,arguments[1]);break;case 3:d[r].call(this,arguments[1],arguments[2]);break;default:d[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},M.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,i)for(o=0;o<r;o++)if("symbol"==typeof a[o]){t=!0;break}t||(a=a.join(this.delimiter))}var d,u=[],h=arguments.length;if(this._all)for(o=0,r=this._all.length;o<r;o++)switch(this.event=a,h){case 1:u.push(this._all[o].call(this,a));break;case 2:u.push(this._all[o].call(this,a,arguments[1]));break;case 3:u.push(this._all[o].call(this,a,arguments[1],arguments[2]));break;default:u.push(this._all[o].apply(this,arguments))}if(l?(d=[],C.call(this,d,e,this.listenerTree,0)):d=this._events[a],"function"==typeof d)switch(this.event=a,h){case 1:u.push(d.call(this));break;case 2:u.push(d.call(this,arguments[1]));break;case 3:u.push(d.call(this,arguments[1],arguments[2]));break;default:for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];u.push(d.apply(this,n))}else if(d&&d.length){if(d=d.slice(),h>3)for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];for(o=0,r=d.length;o<r;o++)switch(this.event=a,h){case 1:u.push(d[o].call(this));break;case 2:u.push(d[o].call(this,arguments[1]));break;case 3:u.push(d[o].call(this,arguments[1],arguments[2]));break;default:u.push(d[o].apply(this,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(u)},M.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},M.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},M.prototype.onAny=function(e){return this._onAny(e,!1)},M.prototype.prependAny=function(e){return this._onAny(e,!0)},M.prototype.addListener=M.prototype.on,M.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},M.prototype._on=function(t,n,r,i){if("function"==typeof t)return this._onAny(t,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||c.call(this);var o,s=this;return i!==e&&(n=(o=A.call(this,t,n,i))[0],s=o[1]),this._newListener&&this.emit("newListener",t,n),this.wildcard?(_.call(this,t,n,r),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),r?this._events[t].unshift(n):this._events[t].push(n),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,d.call(this,this._events[t].length,t))):this._events[t]=n,s)},M.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=C.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var c=-1,l=0,d=r.length;l<d;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?a._listeners.splice(c,1):this._events[e].splice(c,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&k(this.listenerTree),this},M.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n<r;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,r=t.length;n<r;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},M.prototype.removeListener=M.prototype.off,M.prototype.removeAllListeners=function(t){if(t===e)return!this._events||c.call(this),this;if(this.wildcard){var n,r=C.call(this,null,t,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&k(this.listenerTree)}else this._events&&(this._events[t]=null);return this},M.prototype.listeners=function(t){var n,r,i,o,s,c=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!c)return[];for(o=(n=a(c)).length,i=[];o-- >0;)"function"==typeof(r=c[n[o]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],d="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,l,d,s,0),l}return c&&(r=c[t])?"function"==typeof r?[r]:r:[]},M.prototype.eventNames=function(e){var t=this._events;return this.wildcard?S.call(this,this.listenerTree,[],null,e):t?a(t):[]},M.prototype.listenerCount=function(e){return this.listeners(e).length},M.prototype.hasListeners=function(t){if(this.wildcard){var n=[],r="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(t===e?a(i).length:i[t]))},M.prototype.listenersAny=function(){return this._all?this._all:[]},M.prototype.waitFor=function(t,n){var r=this,i=typeof n;return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),w((n=g(n,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:v,Promise:m})).Promise,(function(e,i,o){function s(){var o=n.filter;if(!o||o.apply(r,arguments))if(r.off(t,s),n.handleError){var a=arguments[0];a?i(a):e(u.apply(null,arguments).slice(1))}else e(u.apply(null,arguments))}o((function(){r.off(t,s)})),r._on(t,s,!1)}),{timeout:n.timeout,overload:n.overload})};var L=M.prototype;Object.defineProperties(M,{defaultMaxListeners:{get:function(){return L._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");L._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return w((n=g(n,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(n,r,i){var o;if("function"==typeof e.addEventListener)return o=function(){n(u.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,a=function(){s&&e.removeListener("error",s),n(u.apply(null,arguments))};"error"!==t&&(s=function(n){e.removeListener(t,a),r(n)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,a)})),e.once(t,a)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(L,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof e&&e.amd?e((function(){return M})):h.exports=M}();var g=p.exports;const m=Object.create(null);m.open="0",m.close="1",m.ping="2",m.pong="3",m.message="4",m.upgrade="5",m.noop="6";const y=Object.create(null);Object.keys(m).forEach((e=>{y[m[e]]=e}));const v={type:"error",data:"parser error"},b="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),w="function"==typeof ArrayBuffer,E=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,C=({type:e,data:t},n,r)=>b&&t instanceof Blob?n?r(t):_(t,r):w&&(t instanceof ArrayBuffer||E(t))?n?r(t):_(new Blob([t]),r):r(m[e]+(t||"")),_=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function S(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let k;const x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)A[x.charCodeAt(e)]=e;const M="function"==typeof ArrayBuffer,L=(e,t)=>{if("string"!=typeof e)return{type:"message",data:O(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:T(e.substring(1),t)};return y[n]?e.length>1?{type:y[n],data:e.substring(1)}:{type:y[n]}:v},T=(e,t)=>{if(M){const n=(e=>{let t,n,r,i,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const l=new ArrayBuffer(s),d=new Uint8Array(l);for(t=0;t<a;t+=4)n=A[e.charCodeAt(t)],r=A[e.charCodeAt(t+1)],i=A[e.charCodeAt(t+2)],o=A[e.charCodeAt(t+3)],d[c++]=n<<2|r>>4,d[c++]=(15&r)<<4|i>>2,d[c++]=(3&i)<<6|63&o;return l})(e);return O(n,t)}return{base64:!0,data:e}},O=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,R=String.fromCharCode(30);function P(){return new TransformStream({transform(e,t){!function(e,t){b&&e.data instanceof Blob?e.data.arrayBuffer().then(S).then(t):w&&(e.data instanceof ArrayBuffer||E(e.data))?t(S(e.data)):C(e,!1,(e=>{k||(k=new TextEncoder),t(k.encode(e))}))}(e,(n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(n)}))}})}let I;function N(e){return e.reduce(((e,t)=>e+t.length),0)}function B(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function D(e){if(e)return function(e){for(var t in D.prototype)e[t]=D.prototype[t];return e}(e)}D.prototype.on=D.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},D.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},D.prototype.off=D.prototype.removeListener=D.prototype.removeAllListeners=D.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},D.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},D.prototype.emitReserved=D.prototype.emit,D.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},D.prototype.hasListeners=function(e){return!!this.listeners(e).length};const $="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function j(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const K=$.setTimeout,U=$.clearTimeout;function F(e,t){t.useNativeTimers?(e.setTimeoutFn=K.bind($),e.clearTimeoutFn=U.bind($)):(e.setTimeoutFn=$.setTimeout.bind($),e.clearTimeoutFn=$.clearTimeout.bind($))}class H extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class z extends D{constructor(e){super(),this.writable=!1,F(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new H(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=L(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}const q="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),V=64,W={};let G,Y=0,Z=0;function J(e){let t="";do{t=q[e%V]+t,e=Math.floor(e/V)}while(e>0);return t}function X(){const e=J(+new Date);return e!==G?(Y=0,G=e):e+"."+J(Y++)}for(;Z<V;Z++)W[q[Z]]=Z;let Q=!1;try{Q="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const ee=Q;function te(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||ee))return new XMLHttpRequest}catch(e){}if(!t)try{return new($[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function ne(){}const re=null!=new te({xdomain:!1}).responseType;class ie extends D{constructor(e,t){super(),F(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=j(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new te(t);try{n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(n)),4===n.readyState&&(200===n.status||1223===n.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof n.status?n.status:0)}),0))},n.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=ie.requestsCount++,ie.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=ne,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete ie.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ie.requestsCount=0,ie.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",oe);else if("function"==typeof addEventListener){addEventListener("onpagehide"in $?"pagehide":"unload",oe,!1)}function oe(){for(let e in ie.requests)ie.requests.hasOwnProperty(e)&&ie.requests[e].abort()}const se="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),ae=$.WebSocket||$.MozWebSocket,ce="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const le={websocket:class extends z{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=ce?{}:j(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=ce?new ae(e,t,n):t?new ae(e,t):new ae(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;C(n,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}r&&se((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=X()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!ae}},webtransport:class extends z{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){I||(I=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(0===r){if(N(n)<1)break;const e=B(n,1);o=128==(128&e[0]),i=127&e[0],r=i<126?3:126===i?1:2}else if(1===r){if(N(n)<2)break;const e=B(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(N(n)<8)break;const e=B(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),o=t.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(v);break}i=o*Math.pow(2,32)+t.getUint32(4),r=3}else{if(N(n)<i)break;const e=B(n,i);a.enqueue(L(o?e:I.decode(e),t)),r=0}if(0===i||i>e){a.enqueue(v);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=P();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const i=()=>{n.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this.writer.write(n).then((()=>{r&&se((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends z{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}const t=e&&e.forceBase64;this.supportsBinary=re&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const n=e.split(R),r=[];for(let e=0;e<n.length;e++){const i=L(n[e],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach(((e,o)=>{C(e,!1,(e=>{r[o]=e,++i===n&&t(r.join(R))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=X()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ie(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},de=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ue=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function he(e){if(e.length>2e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=de.exec(e||""),o={},s=14;for(;s--;)o[ue[s]]=i[s]||"";return-1!=n&&-1!=r&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,o.path),o.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(n[t]=r)})),n}(0,o.query),o}class fe extends D{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=he(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=he(t.host).host),F(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new le[e](n)}open(){let e;if(this.opts.rememberUpgrade&&fe.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),n=!1;fe.priorWebsocketSuccess=!1;const r=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;fe.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{n||"closed"!==this.readyState&&(l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){n||(n=!0,l(),t.close(),t=null)}const o=e=>{const n=new Error("probe error: "+e);n.transport=t.name,i(),this.emitReserved("upgradeError",n)};function s(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&i()}const l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{n||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",fe.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let n=0;n<this.writeBuffer.length;n++){const r=this.writeBuffer[n].data;if(r&&(e+="string"==typeof(t=r)?function(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)return this.writeBuffer.slice(0,n);e+=2}var t;return this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():e()})):this.upgrading?n():e()),this}onError(e){fe.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}fe.protocol=4;const pe="function"==typeof ArrayBuffer,ge=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,me=Object.prototype.toString,ye="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===me.call(Blob),ve="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===me.call(File);function be(e){return pe&&(e instanceof ArrayBuffer||ge(e))||ye&&e instanceof Blob||ve&&e instanceof File}function we(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(we(e[t]))return!0;return!1}if(be(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return we(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&we(e[t]))return!0;return!1}function Ee(e){const t=[],n=e.data,r=e;return r.data=Ce(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Ce(e,t){if(!e)return e;if(be(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Ce(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Ce(e[r],t));return n}return e}function _e(e,t){return e.data=Se(e.data,t),delete e.attachments,e}function Se(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Se(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Se(e[n],t));return e}const ke=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var xe;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(xe||(xe={}));function Ae(e){return"[object Object]"===Object.prototype.toString.call(e)}class Me extends D{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===xe.BINARY_EVENT;n||t.type===xe.BINARY_ACK?(t.type=n?xe.EVENT:xe.ACK,this.reconstructor=new Le(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!be(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===xe[n.type])throw new Error("unknown packet type "+n.type);if(n.type===xe.BINARY_EVENT||n.type===xe.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!Me.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case xe.CONNECT:return Ae(t);case xe.DISCONNECT:return void 0===t;case xe.CONNECT_ERROR:return"string"==typeof t||Ae(t);case xe.EVENT:case xe.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===ke.indexOf(t[0]));case xe.ACK:case xe.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Le{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=_e(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Te=Object.freeze({__proto__:null,protocol:5,get PacketType(){return xe},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==xe.EVENT&&e.type!==xe.ACK||!we(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===xe.EVENT?xe.BINARY_EVENT:xe.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==xe.BINARY_EVENT&&e.type!==xe.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Ee(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Decoder:Me});function Oe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Re=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Pe extends D{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Oe(e,"open",this.onopen.bind(this)),Oe(e,"packet",this.onpacket.bind(this)),Oe(e,"error",this.onerror.bind(this)),Oe(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Re.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:xe.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),r);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const n=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((r,i)=>{t.push(((e,t)=>n?e?i(e):r(t):r(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue()})),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:xe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case xe.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case xe.EVENT:case xe.BINARY_EVENT:this.onevent(e);break;case xe.ACK:case xe.BINARY_ACK:this.onack(e);break;case xe.DISCONNECT:this.ondisconnect();break;case xe.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,t.packet({type:xe.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:xe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function Ie(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ie.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},Ie.prototype.reset=function(){this.attempts=0},Ie.prototype.setMin=function(e){this.ms=e},Ie.prototype.setMax=function(e){this.max=e},Ie.prototype.setJitter=function(e){this.jitter=e};class Ne extends D{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,F(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new Ie({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Te;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new fe(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=Oe(t,"open",(function(){n.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=Oe(t,"error",i);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn((()=>{r(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Oe(e,"ping",this.onping.bind(this)),Oe(e,"data",this.ondata.bind(this)),Oe(e,"error",this.onerror.bind(this)),Oe(e,"close",this.onclose.bind(this)),Oe(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){se((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Pe(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Be={};function De(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=he(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=n.source,i=n.id,o=n.path,s=Be[i]&&o in Be[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?a=new Ne(r,t):(Be[i]||(Be[i]=new Ne(r,t)),a=Be[i]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}function $e(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}Object.assign(De,{Manager:Ne,Socket:Pe,io:De,connect:De}),"function"==typeof SuppressedError&&SuppressedError;var je="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ke=[],Ue=[],Fe="undefined"!=typeof Uint8Array?Uint8Array:Array,He=!1;function ze(){He=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Ke[t]=e[t],Ue[e.charCodeAt(t)]=t;Ue["-".charCodeAt(0)]=62,Ue["_".charCodeAt(0)]=63}function qe(e,t,n){for(var r,i,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(Ke[(i=r)>>18&63]+Ke[i>>12&63]+Ke[i>>6&63]+Ke[63&i]);return o.join("")}function Ve(e){var t;He||ze();for(var n=e.length,r=n%3,i="",o=[],s=16383,a=0,c=n-r;a<c;a+=s)o.push(qe(e,a,a+s>c?c:a+s));return 1===r?(t=e[n-1],i+=Ke[t>>2],i+=Ke[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=Ke[t>>10],i+=Ke[t>>4&63],i+=Ke[t<<2&63],i+="="),o.push(i),o.join("")}function We(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,l=c>>1,d=-7,u=n?i-1:0,h=n?-1:1,f=e[t+u];for(u+=h,o=f&(1<<-d)-1,f>>=-d,d+=a;d>0;o=256*o+e[t+u],u+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+u],u+=h,d-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=l}return(f?-1:1)*s*Math.pow(2,o-r)}function Ge(e,t,n,r,i,o){var s,a,c,l=8*o-i-1,d=(1<<l)-1,u=d>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+u>=1?h/c:h*Math.pow(2,1-u))*c>=2&&(s++,c/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(t*c-1)*Math.pow(2,i),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[n+f]=255&s,f+=p,s/=256,l-=8);e[n+f-p]|=128*g}var Ye={}.toString,Ze=Array.isArray||function(e){return"[object Array]"==Ye.call(e)};et.TYPED_ARRAY_SUPPORT=void 0===je.TYPED_ARRAY_SUPPORT||je.TYPED_ARRAY_SUPPORT;var Je=Xe();function Xe(){return et.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Qe(e,t){if(Xe()<t)throw new RangeError("Invalid typed array length");return et.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=et.prototype:(null===e&&(e=new et(t)),e.length=t),e}function et(e,t,n){if(!(et.TYPED_ARRAY_SUPPORT||this instanceof et))return new et(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return rt(this,e)}return tt(this,e,t,n)}function tt(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),et.TYPED_ARRAY_SUPPORT?(e=t).__proto__=et.prototype:e=it(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!et.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|at(t,n),i=(e=Qe(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(st(t)){var n=0|ot(t.length);return 0===(e=Qe(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Qe(e,0):it(e,t);if("Buffer"===t.type&&Ze(t.data))return it(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function nt(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function rt(e,t){if(nt(t),e=Qe(e,t<0?0:0|ot(t)),!et.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function it(e,t){var n=t.length<0?0:0|ot(t.length);e=Qe(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function ot(e){if(e>=Xe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Xe().toString(16)+" bytes");return 0|e}function st(e){return!(null==e||!e._isBuffer)}function at(e,t){if(st(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Nt(e).length;default:if(r)return It(e).length;t=(""+t).toLowerCase(),r=!0}}function ct(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return _t(this,t,n);case"utf8":case"utf-8":return bt(this,t,n);case"ascii":return Et(this,t,n);case"latin1":case"binary":return Ct(this,t,n);case"base64":return vt(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return St(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function lt(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function dt(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=et.from(t,r)),st(t))return 0===t.length?-1:ut(e,t,n,r,i);if("number"==typeof t)return t&=255,et.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):ut(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function ut(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var d=-1;for(o=n;o<a;o++)if(l(e,o)===l(t,-1===d?0:o-d)){if(-1===d&&(d=o),o-d+1===c)return d*s}else-1!==d&&(o-=o-d),d=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var u=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){u=!1;break}if(u)return o}return-1}function ht(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function ft(e,t,n,r){return Bt(It(t,e.length-n),e,n,r)}function pt(e,t,n,r){return Bt(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function gt(e,t,n,r){return pt(e,t,n,r)}function mt(e,t,n,r){return Bt(Nt(t),e,n,r)}function yt(e,t,n,r){return Bt(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function vt(e,t,n){return 0===t&&n===e.length?Ve(e):Ve(e.slice(t,n))}function bt(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,l=e[i],d=null,u=l>239?4:l>223?3:l>191?2:1;if(i+u<=n)switch(u){case 1:l<128&&(d=l);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)>127&&(d=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(d=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(d=c)}null===d?(d=65533,u=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),i+=u}return function(e){var t=e.length;if(t<=wt)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=wt));return n}(r)}et.poolSize=8192,et._augment=function(e){return e.__proto__=et.prototype,e},et.from=function(e,t,n){return tt(null,e,t,n)},et.TYPED_ARRAY_SUPPORT&&(et.prototype.__proto__=Uint8Array.prototype,et.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&et[Symbol.species]),et.alloc=function(e,t,n){return function(e,t,n,r){return nt(t),t<=0?Qe(e,t):void 0!==n?"string"==typeof r?Qe(e,t).fill(n,r):Qe(e,t).fill(n):Qe(e,t)}(null,e,t,n)},et.allocUnsafe=function(e){return rt(null,e)},et.allocUnsafeSlow=function(e){return rt(null,e)},et.isBuffer=Dt,et.compare=function(e,t){if(!st(e)||!st(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},et.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},et.concat=function(e,t){if(!Ze(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return et.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=et.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!st(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},et.byteLength=at,et.prototype._isBuffer=!0,et.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)lt(this,t,t+1);return this},et.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)lt(this,t,t+3),lt(this,t+1,t+2);return this},et.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)lt(this,t,t+7),lt(this,t+1,t+6),lt(this,t+2,t+5),lt(this,t+3,t+4);return this},et.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?bt(this,0,e):ct.apply(this,arguments)},et.prototype.equals=function(e){if(!st(e))throw new TypeError("Argument must be a Buffer");return this===e||0===et.compare(this,e)},et.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},et.prototype.compare=function(e,t,n,r,i){if(!st(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(r,i),l=e.slice(t,n),d=0;d<a;++d)if(c[d]!==l[d]){o=c[d],s=l[d];break}return o<s?-1:s<o?1:0},et.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},et.prototype.indexOf=function(e,t,n){return dt(this,e,t,n,!0)},et.prototype.lastIndexOf=function(e,t,n){return dt(this,e,t,n,!1)},et.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return ht(this,e,t,n);case"utf8":case"utf-8":return ft(this,e,t,n);case"ascii":return pt(this,e,t,n);case"latin1":case"binary":return gt(this,e,t,n);case"base64":return mt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yt(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},et.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var wt=4096;function Et(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function Ct(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function _t(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=Pt(e[o]);return i}function St(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function kt(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function xt(e,t,n,r,i,o){if(!st(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function At(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function Mt(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function Lt(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Tt(e,t,n,r,i){return i||Lt(e,0,n,4),Ge(e,t,n,r,23,4),n+4}function Ot(e,t,n,r,i){return i||Lt(e,0,n,8),Ge(e,t,n,r,52,8),n+8}et.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),et.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=et.prototype;else{var i=t-e;n=new et(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},et.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},et.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},et.prototype.readUInt8=function(e,t){return t||kt(e,1,this.length),this[e]},et.prototype.readUInt16LE=function(e,t){return t||kt(e,2,this.length),this[e]|this[e+1]<<8},et.prototype.readUInt16BE=function(e,t){return t||kt(e,2,this.length),this[e]<<8|this[e+1]},et.prototype.readUInt32LE=function(e,t){return t||kt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},et.prototype.readUInt32BE=function(e,t){return t||kt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},et.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},et.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},et.prototype.readInt8=function(e,t){return t||kt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},et.prototype.readInt16LE=function(e,t){t||kt(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},et.prototype.readInt16BE=function(e,t){t||kt(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},et.prototype.readInt32LE=function(e,t){return t||kt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},et.prototype.readInt32BE=function(e,t){return t||kt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},et.prototype.readFloatLE=function(e,t){return t||kt(e,4,this.length),We(this,e,!0,23,4)},et.prototype.readFloatBE=function(e,t){return t||kt(e,4,this.length),We(this,e,!1,23,4)},et.prototype.readDoubleLE=function(e,t){return t||kt(e,8,this.length),We(this,e,!0,52,8)},et.prototype.readDoubleBE=function(e,t){return t||kt(e,8,this.length),We(this,e,!1,52,8)},et.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||xt(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},et.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||xt(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},et.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,1,255,0),et.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},et.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,65535,0),et.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):At(this,e,t,!0),t+2},et.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,65535,0),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):At(this,e,t,!1),t+2},et.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,4294967295,0),et.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Mt(this,e,t,!0),t+4},et.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,4294967295,0),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Mt(this,e,t,!1),t+4},et.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);xt(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},et.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);xt(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},et.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,1,127,-128),et.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},et.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,32767,-32768),et.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):At(this,e,t,!0),t+2},et.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,32767,-32768),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):At(this,e,t,!1),t+2},et.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,2147483647,-2147483648),et.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Mt(this,e,t,!0),t+4},et.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Mt(this,e,t,!1),t+4},et.prototype.writeFloatLE=function(e,t,n){return Tt(this,e,t,!0,n)},et.prototype.writeFloatBE=function(e,t,n){return Tt(this,e,t,!1,n)},et.prototype.writeDoubleLE=function(e,t,n){return Ot(this,e,t,!0,n)},et.prototype.writeDoubleBE=function(e,t,n){return Ot(this,e,t,!1,n)},et.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!et.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},et.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!et.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=st(e)?e:It(new et(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var Rt=/[^+\/0-9A-Za-z-_]/g;function Pt(e){return e<16?"0"+e.toString(16):e.toString(16)}function It(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Nt(e){return function(e){var t,n,r,i,o,s;He||ze();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Fe(3*a/4-o),r=o>0?a-4:a;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)i=Ue[e.charCodeAt(t)]<<18|Ue[e.charCodeAt(t+1)]<<12|Ue[e.charCodeAt(t+2)]<<6|Ue[e.charCodeAt(t+3)],s[c++]=i>>16&255,s[c++]=i>>8&255,s[c++]=255&i;return 2===o?(i=Ue[e.charCodeAt(t)]<<2|Ue[e.charCodeAt(t+1)]>>4,s[c++]=255&i):1===o&&(i=Ue[e.charCodeAt(t)]<<10|Ue[e.charCodeAt(t+1)]<<4|Ue[e.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Rt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Bt(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Dt(e){return null!=e&&(!!e._isBuffer||$t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&$t(e.slice(0,0))}(e))}function $t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var jt=Object.freeze({__proto__:null,Buffer:et,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),et.alloc(+e)},isBuffer:Dt,kMaxLength:Je}),Kt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ut(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ft(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var Ht={},zt={},qt={};function Vt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Wt(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function Gt(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function Yt(e,...t){if(!Gt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Zt(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("hash must be wrapped by utils.wrapConstructor");Vt(e.outputLen),Vt(e.blockLen)}function Jt(e,t=!0){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 Xt(e,t){Yt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(qt,"__esModule",{value:!0}),qt.isBytes=Gt,qt.number=Vt,qt.bool=Wt,qt.bytes=Yt,qt.hash=Zt,qt.exists=Jt,qt.output=Xt;const Qt={number:Vt,bool:Wt,bytes:Yt,hash:Zt,exists:Jt,output:Xt};qt.default=Qt,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.wrapCipher=e.Hash=e.nextTick=e.isLE=e.createView=e.u32=e.u16=e.u8=void 0,e.bytesToHex=r,e.hexToBytes=s,e.hexToNumber=a,e.bytesToNumberBE=function(e){return a(r(e))},e.numberToBytesBE=function(e,t){return s(e.toString(16).padStart(2*t,"0"))},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=c,e.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},e.toBytes=function(e){if("string"==typeof e)e=c(e);else{if(!(0,t.isBytes)(e))throw new Error("Uint8Array expected, got "+typeof e);e=d(e)}return e},e.concatBytes=function(...e){let n=0;for(let r=0;r<e.length;r++){const i=e[r];(0,t.bytes)(i),n+=i.length}const r=new Uint8Array(n);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)},e.equalBytes=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},e.setBigUint64=l,e.u64Lengths=function(t,n){const r=new Uint8Array(16),i=(0,e.createView)(r);return l(i,0,BigInt(n?n.length:0),!0),l(i,8,BigInt(t.length),!0),r},e.isAligned32=function(e){return e.byteOffset%4==0},e.copyBytes=d,e.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)};const t=qt;if(e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u16=e=>new Uint16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2)),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function r(e){(0,t.bytes)(e);let r="";for(let t=0;t<e.length;t++)r+=n[e[t]];return r}const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(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 t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r}function a(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function c(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function l(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}function d(e){return Uint8Array.from(e)}e.nextTick=async()=>{},e.Hash=class{},e.wrapCipher=(e,t)=>(Object.assign(t,e),t)}(zt);var en={},tn={};Object.defineProperty(tn,"__esModule",{value:!0}),tn.AEAD_TAG_LENGTH=tn.XCHACHA20_NONCE_LENGTH=tn.CURVE25519_PUBLIC_KEY_SIZE=tn.ETH_PUBLIC_KEY_SIZE=tn.UNCOMPRESSED_PUBLIC_KEY_SIZE=tn.COMPRESSED_PUBLIC_KEY_SIZE=tn.SECRET_KEY_LENGTH=void 0,tn.SECRET_KEY_LENGTH=32,tn.COMPRESSED_PUBLIC_KEY_SIZE=33,tn.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,tn.ETH_PUBLIC_KEY_SIZE=64,tn.CURVE25519_PUBLIC_KEY_SIZE=32,tn.XCHACHA20_NONCE_LENGTH=24,tn.AEAD_TAG_LENGTH=16,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ephemeralKeySize=e.symmetricNonceLength=e.symmetricAlgorithm=e.isHkdfKeyCompressed=e.isEphemeralKeyCompressed=e.ellipticCurve=e.ECIES_CONFIG=void 0;var t=tn;e.ECIES_CONFIG=new function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16},e.ellipticCurve=function(){return e.ECIES_CONFIG.ellipticCurve},e.isEphemeralKeyCompressed=function(){return e.ECIES_CONFIG.isEphemeralKeyCompressed},e.isHkdfKeyCompressed=function(){return e.ECIES_CONFIG.isHkdfKeyCompressed},e.symmetricAlgorithm=function(){return e.ECIES_CONFIG.symmetricAlgorithm},e.symmetricNonceLength=function(){return e.ECIES_CONFIG.symmetricNonceLength},e.ephemeralKeySize=function(){var n={secp256k1:e.ECIES_CONFIG.isEphemeralKeyCompressed?t.COMPRESSED_PUBLIC_KEY_SIZE:t.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:t.CURVE25519_PUBLIC_KEY_SIZE,ed25519:t.CURVE25519_PUBLIC_KEY_SIZE};if(e.ECIES_CONFIG.ellipticCurve in n)return n[e.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}}(en);var nn={},rn={},on={},sn={},an={},cn={};Object.defineProperty(cn,"__esModule",{value:!0}),cn.crypto=void 0,cn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.gcm=e.ctr=e.cbc=e.utils=void 0,e.randomBytes=i,e.getWebcryptoSubtle=o,e.managedNonce=function(e){return(0,n.number)(e.nonceLength),(t,...n)=>({encrypt(o,...s){const{nonceLength:a}=e,c=i(a),l=e(t,c,...n).encrypt(o,...s),d=(0,r.concatBytes)(c,l);return l.fill(0),d},decrypt(r,...i){const{nonceLength:o}=e,s=r.subarray(0,o),a=r.subarray(o);return e(t,s,...n).decrypt(a,...i)}})};const t=cn,n=qt,r=zt;function i(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function o(){if(t.crypto&&"object"==typeof t.crypto.subtle&&null!=t.crypto.subtle)return t.crypto.subtle;throw new Error("crypto.subtle must be defined")}e.utils={async encrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["encrypt"]),a=await i.encrypt(n,s,r);return new Uint8Array(a)},async decrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["decrypt"]),a=await i.decrypt(n,s,r);return new Uint8Array(a)}};const s={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function a(t){return(r,i,o)=>{(0,n.bytes)(r),(0,n.bytes)(i);const a={name:t,length:8*r.length},c=function(e,t,n){if(e===s.CBC)return{name:s.CBC,iv:t};if(e===s.CTR)return{name:s.CTR,counter:t,length:64};if(e===s.GCM)return n?{name:s.GCM,iv:t,additionalData:n}:{name:s.GCM,iv:t};throw new Error("unknown aes block mode")}(t,i,o);return{encrypt:t=>((0,n.bytes)(t),e.utils.encrypt(r,a,c,t)),decrypt:t=>((0,n.bytes)(t),e.utils.decrypt(r,a,c,t))}}}e.cbc=a(s.CBC),e.ctr=a(s.CTR),e.gcm=a(s.GCM)}(an);var ln={},dn={},un={},hn={};function fn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function pn(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function gn(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function mn(e,...t){if(!gn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function yn(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");fn(e.outputLen),fn(e.blockLen)}function vn(e,t=!0){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 bn(e,t){mn(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(hn,"__esModule",{value:!0}),hn.isBytes=gn,hn.number=fn,hn.bool=pn,hn.bytes=mn,hn.hash=yn,hn.exists=vn,hn.output=bn;const wn={number:fn,bool:pn,bytes:mn,hash:yn,exists:vn,output:bn};hn.default=wn;var En={},Cn={};Object.defineProperty(Cn,"__esModule",{value:!0}),Cn.crypto=void 0,Cn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name},e.byteSwap32=function(t){for(let n=0;n<t.length;n++)t[n]=(0,e.byteSwap)(t[n])},e.bytesToHex=function(e){(0,n.bytes)(e);let t="";for(let n=0;n<e.length;n++)t+=r[e[n]];return t},e.hexToBytes=function(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 t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=s,e.toBytes=a,e.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];(0,n.bytes)(i),t+=i.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!==c.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},e.wrapConstructor=function(e){const t=t=>e().update(a(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const t=Cn,n=hn;e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.rotr=(e,t)=>e<<32-t|e>>>t,e.rotl=(e,t)=>e<<t|e>>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t);const r=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0"))),i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function a(e){return"string"==typeof e&&(e=s(e)),(0,n.bytes)(e),e}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const c={}.toString}(En),Object.defineProperty(un,"__esModule",{value:!0}),un.HashMD=un.Maj=un.Chi=void 0;const _n=hn,Sn=En;un.Chi=(e,t,n)=>e&t^~e&n,un.Maj=(e,t,n)=>e&t^e&n^t&n,un.HashMD=class extends Sn.Hash{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=(0,Sn.createView)(this.buffer)}update(e){(0,_n.exists)(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=(0,Sn.toBytes)(e)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=(0,Sn.createView)(e);for(;r<=i-o;o+=r)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,_n.exists)(this),(0,_n.output)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=(0,Sn.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],i)}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:i,destroyed:o,pos:s}=this;return e.length=r,e.pos=s,e.finished=i,e.destroyed=o,r%t&&e.buffer.set(n),e}};var kn={};Object.defineProperty(kn,"__esModule",{value:!0}),kn.add5L=kn.add5H=kn.add4H=kn.add4L=kn.add3H=kn.add3L=kn.rotlBL=kn.rotlBH=kn.rotlSL=kn.rotlSH=kn.rotr32L=kn.rotr32H=kn.rotrBL=kn.rotrBH=kn.rotrSL=kn.rotrSH=kn.shrSL=kn.shrSH=kn.toBig=void 0,kn.fromBig=Mn,kn.split=Ln,kn.add=Hn;const xn=BigInt(2**32-1),An=BigInt(32);function Mn(e,t=!1){return t?{h:Number(e&xn),l:Number(e>>An&xn)}:{h:0|Number(e>>An&xn),l:0|Number(e&xn)}}function Ln(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:o,l:s}=Mn(e[i],t);[n[i],r[i]]=[o,s]}return[n,r]}const Tn=(e,t)=>BigInt(e>>>0)<<An|BigInt(t>>>0);kn.toBig=Tn;const On=(e,t,n)=>e>>>n;kn.shrSH=On;const Rn=(e,t,n)=>e<<32-n|t>>>n;kn.shrSL=Rn;const Pn=(e,t,n)=>e>>>n|t<<32-n;kn.rotrSH=Pn;const In=(e,t,n)=>e<<32-n|t>>>n;kn.rotrSL=In;const Nn=(e,t,n)=>e<<64-n|t>>>n-32;kn.rotrBH=Nn;const Bn=(e,t,n)=>e>>>n-32|t<<64-n;kn.rotrBL=Bn;const Dn=(e,t)=>t;kn.rotr32H=Dn;const $n=(e,t)=>e;kn.rotr32L=$n;const jn=(e,t,n)=>e<<n|t>>>32-n;kn.rotlSH=jn;const Kn=(e,t,n)=>t<<n|e>>>32-n;kn.rotlSL=Kn;const Un=(e,t,n)=>t<<n-32|e>>>64-n;kn.rotlBH=Un;const Fn=(e,t,n)=>e<<n-32|t>>>64-n;function Hn(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}kn.rotlBL=Fn;const zn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);kn.add3L=zn;const qn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;kn.add3H=qn;const Vn=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);kn.add4L=Vn;const Wn=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;kn.add4H=Wn;const Gn=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);kn.add5L=Gn;const Yn=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0;kn.add5H=Yn;const Zn={fromBig:Mn,split:Ln,toBig:Tn,shrSH:On,shrSL:Rn,rotrSH:Pn,rotrSL:In,rotrBH:Nn,rotrBL:Bn,rotr32H:Dn,rotr32L:$n,rotlSH:jn,rotlSL:Kn,rotlBH:Un,rotlBL:Fn,add:Hn,add3L:zn,add3H:qn,add4L:Vn,add4H:Wn,add5H:Yn,add5L:Gn};kn.default=Zn,Object.defineProperty(dn,"__esModule",{value:!0}),dn.sha384=dn.sha512_256=dn.sha512_224=dn.sha512=dn.SHA384=dn.SHA512_256=dn.SHA512_224=dn.SHA512=void 0;const Jn=un,Xn=kn,Qn=En,[er,tr]=Xn.default.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)))),nr=new Uint32Array(80),rr=new Uint32Array(80);class ir extends Jn.HashMD{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:i,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:d,Fl:u,Gh:h,Gl:f,Hh:p,Hl:g}=this;return[e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g]}set(e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|d,this.Fl=0|u,this.Gh=0|h,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let n=0;n<16;n++,t+=4)nr[n]=e.getUint32(t),rr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|nr[e-15],n=0|rr[e-15],r=Xn.default.rotrSH(t,n,1)^Xn.default.rotrSH(t,n,8)^Xn.default.shrSH(t,n,7),i=Xn.default.rotrSL(t,n,1)^Xn.default.rotrSL(t,n,8)^Xn.default.shrSL(t,n,7),o=0|nr[e-2],s=0|rr[e-2],a=Xn.default.rotrSH(o,s,19)^Xn.default.rotrBH(o,s,61)^Xn.default.shrSH(o,s,6),c=Xn.default.rotrSL(o,s,19)^Xn.default.rotrBL(o,s,61)^Xn.default.shrSL(o,s,6),l=Xn.default.add4L(i,c,rr[e-7],rr[e-16]),d=Xn.default.add4H(l,r,a,nr[e-7],nr[e-16]);nr[e]=0|d,rr[e]=0|l}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:d,El:u,Fh:h,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let e=0;e<80;e++){const t=Xn.default.rotrSH(d,u,14)^Xn.default.rotrSH(d,u,18)^Xn.default.rotrBH(d,u,41),v=Xn.default.rotrSL(d,u,14)^Xn.default.rotrSL(d,u,18)^Xn.default.rotrBL(d,u,41),b=d&h^~d&p,w=u&f^~u&g,E=Xn.default.add5L(y,v,w,tr[e],rr[e]),C=Xn.default.add5H(E,m,t,b,er[e],nr[e]),_=0|E,S=Xn.default.rotrSH(n,r,28)^Xn.default.rotrBH(n,r,34)^Xn.default.rotrBH(n,r,39),k=Xn.default.rotrSL(n,r,28)^Xn.default.rotrBL(n,r,34)^Xn.default.rotrBL(n,r,39),x=n&i^n&s^i&s,A=r&o^r&a^o&a;m=0|p,y=0|g,p=0|h,g=0|f,h=0|d,f=0|u,({h:d,l:u}=Xn.default.add(0|c,0|l,0|C,0|_)),c=0|s,l=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const M=Xn.default.add3L(_,k,A);n=Xn.default.add3H(M,C,S,x),r=0|M}({h:n,l:r}=Xn.default.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=Xn.default.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Xn.default.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:l}=Xn.default.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:d,l:u}=Xn.default.add(0|this.Eh,0|this.El,0|d,0|u)),({h:h,l:f}=Xn.default.add(0|this.Fh,0|this.Fl,0|h,0|f)),({h:p,l:g}=Xn.default.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=Xn.default.add(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(n,r,i,o,s,a,c,l,d,u,h,f,p,g,m,y)}roundClean(){nr.fill(0),rr.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)}}dn.SHA512=ir;class or extends ir{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}dn.SHA512_224=or;class sr extends ir{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}dn.SHA512_256=sr;class ar extends ir{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}dn.SHA384=ar,dn.sha512=(0,Qn.wrapConstructor)((()=>new ir)),dn.sha512_224=(0,Qn.wrapConstructor)((()=>new or)),dn.sha512_256=(0,Qn.wrapConstructor)((()=>new sr)),dn.sha384=(0,Qn.wrapConstructor)((()=>new ar));var cr={},lr={},dr={},ur={};Object.defineProperty(ur,"__esModule",{value:!0}),ur.notImplemented=ur.bitMask=void 0,ur.isBytes=gr,ur.abytes=mr,ur.abool=function(e,t){if("boolean"!=typeof t)throw new Error(`${e} must be valid boolean, got "${t}".`)},ur.bytesToHex=vr,ur.numberToHexUnpadded=br,ur.hexToNumber=wr,ur.hexToBytes=_r,ur.bytesToNumberBE=function(e){return wr(vr(e))},ur.bytesToNumberLE=function(e){return mr(e),wr(vr(Uint8Array.from(e).reverse()))},ur.numberToBytesBE=Sr,ur.numberToBytesLE=function(e,t){return Sr(e,t).reverse()},ur.numberToVarBytesBE=function(e){return _r(br(e))},ur.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=_r(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!gr(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r},ur.concatBytes=kr,ur.equalBytes=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},ur.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},ur.inRange=Ar,ur.aInRange=function(e,t,n,r){if(!Ar(t,n,r))throw new Error(`expected valid ${e}: ${n} <= n < ${r}, got ${typeof t} ${t}`)},ur.bitLen=function(e){let t;for(t=0;e>hr;e>>=fr,t+=1);return t},ur.bitGet=function(e,t){return e>>BigInt(t)&fr},ur.bitSet=function(e,t,n){return e|(n?fr:hr)<<BigInt(t)},ur.createHmacDrbg=function(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=Mr(e),i=Mr(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),c=(e=Mr())=>{i=a(Lr([0]),e),r=a(),0!==e.length&&(i=a(Lr([1]),e),r=a())},l=()=>{if(o++>=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 kr(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(l()));)c();return s(),n}},ur.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const i=Tr[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},ur.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}};const hr=BigInt(0),fr=BigInt(1),pr=BigInt(2);function gr(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function mr(e){if(!gr(e))throw new Error("Uint8Array expected")}const yr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function vr(e){mr(e);let t="";for(let n=0;n<e.length;n++)t+=yr[e[n]];return t}function br(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function wr(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const Er={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Cr(e){return e>=Er._0&&e<=Er._9?e-Er._0:e>=Er._A&&e<=Er._F?e-(Er._A-10):e>=Er._a&&e<=Er._f?e-(Er._a-10):void 0}function _r(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 t=0,i=0;t<n;t++,i+=2){const n=Cr(e.charCodeAt(i)),o=Cr(e.charCodeAt(i+1));if(void 0===n||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function Sr(e,t){return _r(e.toString(16).padStart(2*t,"0"))}function kr(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];mr(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}const xr=e=>"bigint"==typeof e&&hr<=e;function Ar(e,t,n){return xr(e)&&xr(t)&&xr(n)&&t<=e&&e<n}ur.bitMask=e=>(pr<<BigInt(e-1))-fr;const Mr=e=>new Uint8Array(e),Lr=e=>Uint8Array.from(e),Tr={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||gr(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)};ur.notImplemented=()=>{throw new Error("not implemented")},Object.defineProperty(dr,"__esModule",{value:!0}),dr.isNegativeLE=void 0,dr.mod=jr,dr.pow=Kr,dr.pow2=function(e,t,n){let r=e;for(;t-- >Rr;)r*=r,r%=n;return r},dr.invert=Ur,dr.tonelliShanks=Fr,dr.FpSqrt=Hr,dr.validateField=function(e){const t=zr.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,Or.validateObject)(e,t)},dr.FpPow=qr,dr.FpInvertBatch=Vr,dr.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?Ur(n,e.ORDER):e.inv(n))},dr.FpLegendre=Wr,dr.FpIsSquare=function(e){const t=Wr(e.ORDER);return n=>{const r=t(e,n);return e.eql(r,e.ZERO)||e.eql(r,e.ONE)}},dr.nLength=Gr,dr.Field=function(e,t,n=!1,r={}){if(e<=Rr)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=Gr(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Hr(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:(0,Or.bitMask)(i),ZERO:Rr,ONE:Pr,create:t=>jr(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Rr<=t&&t<e},is0:e=>e===Rr,isOdd:e=>(e&Pr)===Pr,neg:t=>jr(-t,e),eql:(e,t)=>e===t,sqr:t=>jr(t*t,e),add:(t,n)=>jr(t+n,e),sub:(t,n)=>jr(t-n,e),mul:(t,n)=>jr(t*n,e),pow:(e,t)=>qr(a,e,t),div:(t,n)=>jr(t*Ur(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Ur(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>Vr(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?(0,Or.numberToBytesLE)(e,o):(0,Or.numberToBytesBE)(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return n?(0,Or.bytesToNumberLE)(e):(0,Or.bytesToNumberBE)(e)}});return Object.freeze(a)},dr.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},dr.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},dr.hashToPrivateScalar=function(e,t,n=!1){const r=(e=(0,Or.ensureBytes)("privateHash",e)).length,i=Gr(t).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);return jr(n?(0,Or.bytesToNumberLE)(e):(0,Or.bytesToNumberBE)(e),t-Pr)+Pr},dr.getFieldBytesLength=Yr,dr.getMinHashLength=Zr,dr.mapHashToField=function(e,t,n=!1){const r=e.length,i=Yr(t),o=Zr(t);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const s=jr(n?(0,Or.bytesToNumberBE)(e):(0,Or.bytesToNumberLE)(e),t-Pr)+Pr;return n?(0,Or.numberToBytesLE)(s,i):(0,Or.numberToBytesBE)(s,i)};const Or=ur,Rr=BigInt(0),Pr=BigInt(1),Ir=BigInt(2),Nr=BigInt(3),Br=BigInt(4),Dr=BigInt(5),$r=BigInt(8);function jr(e,t){const n=e%t;return n>=Rr?n:t+n}function Kr(e,t,n){if(n<=Rr||t<Rr)throw new Error("Expected power/modulo > 0");if(n===Pr)return Rr;let r=Pr;for(;t>Rr;)t&Pr&&(r=r*e%n),e=e*e%n,t>>=Pr;return r}function Ur(e,t){if(e===Rr||t<=Rr)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=jr(e,t),r=t,i=Rr,o=Pr;for(;n!==Rr;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Pr)throw new Error("invert: does not exist");return jr(i,t)}function Fr(e){const t=(e-Pr)/Ir;let n,r,i;for(n=e-Pr,r=0;n%Ir===Rr;n/=Ir,r++);for(i=Ir;i<e&&Kr(i,t,e)!==e-Pr;i++);if(1===r){const t=(e+Pr)/Br;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 o=(n+Pr)/Ir;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(s,o),d=e.pow(s,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,Pr<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),a=t}return l}}function Hr(e){if(e%Br===Nr){const t=(e+Pr)/Br;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%$r===Dr){const t=(e-Dr)/$r;return function(e,n){const r=e.mul(n,Ir),i=e.pow(r,t),o=e.mul(n,i),s=e.mul(e.mul(o,Ir),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return Fr(e)}BigInt(9),BigInt(16),dr.isNegativeLE=(e,t)=>(jr(e,t)&Pr)===Pr;const zr=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qr(e,t,n){if(n<Rr)throw new Error("Expected power > 0");if(n===Rr)return e.ONE;if(n===Pr)return t;let r=e.ONE,i=t;for(;n>Rr;)n&Pr&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Pr;return r}function Vr(e,t){const n=new Array(t.length),r=t.reduce(((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r))),e.ONE),i=e.inv(r);return t.reduceRight(((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r))),i),n}function Wr(e){const t=(e-Pr)/Ir;return(e,n)=>e.pow(n,t)}function Gr(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Yr(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 Zr(e){const t=Yr(e);return t+Math.ceil(t/2)}Object.defineProperty(lr,"__esModule",{value:!0}),lr.wNAF=function(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}]`)},i=e=>(r(e),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>Qr;)n&ei&&(r=r.add(i)),i=i.double(),n>>=ei;return r},precomputeWindow(e,t){const{windows:n,windowSize:r}=i(t),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<r;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(t,r,o){const{windows:s,windowSize:a}=i(t);let c=e.ZERO,l=e.BASE;const d=BigInt(2**t-1),u=2**t,h=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let i=Number(o&d);o>>=h,i>a&&(i-=u,o+=ei);const s=t,f=t+Math.abs(i)-1,p=e%2!=0,g=i<0;0===i?l=l.add(n(p,r[s])):c=c.add(n(g,r[f]))}return{p:c,f:l}},wNAFCached(e,t,n){const r=ni.get(e)||1;let i=ti.get(e);return i||(i=this.precomputeWindow(e,r),1!==r&&ti.set(e,n(i))),this.wNAF(r,i,t)},setWindowSize(e,t){r(t),ni.set(e,t),ti.delete(e)}}},lr.pippenger=function(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 i=(0,Xr.bitLen)(BigInt(n.length)),o=i>12?i-3:i>4?i-2:i?2:1,s=(1<<o)-1,a=new Array(s+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/o)*o;let l=e.ZERO;for(let t=c;t>=0;t-=o){a.fill(e.ZERO);for(let e=0;e<r.length;e++){const i=r[e],o=Number(i>>BigInt(t)&BigInt(s));a[o]=a[o].add(n[e])}let i=e.ZERO;for(let t=a.length-1,n=e.ZERO;t>0;t--)n=n.add(a[t]),i=i.add(n);if(l=l.add(i),0!==t)for(let e=0;e<o;e++)l=l.double()}return l},lr.validateBasic=function(e){return(0,Jr.validateField)(e.Fp),(0,Xr.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Jr.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};const Jr=dr,Xr=ur,Qr=BigInt(0),ei=BigInt(1),ti=new WeakMap,ni=new WeakMap;Object.defineProperty(cr,"__esModule",{value:!0}),cr.twistedEdwards=function(e){const t=function(e){const t=(0,ri.validateBasic)(e);return oi.validateObject(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:i,hash:o,randomBytes:s,nByteLength:a,h:c}=t,l=li<<BigInt(8*a)-ci,d=n.create,u=(0,ii.Field)(t.n,t.nBitLength),h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e*n.inv(t))}}catch(e){return{isValid:!1,value:ai}}}),f=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,n)=>{if((0,si.abool)("phflag",n),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){oi.aInRange("coordinate "+e,t,ai,l)}function m(e){if(!(e instanceof b))throw new Error("ExtendedPoint expected")}const y=(0,si.memoized)(((e,t)=>{const{ex:r,ey:i,ez:o}=e,s=e.is0();null==t&&(t=s?di:n.inv(o));const a=d(r*t),c=d(i*t),l=d(o*t);if(s)return{x:ai,y:ci};if(l!==ci)throw new Error("invZ was invalid");return{x:a,y:c}})),v=(0,si.memoized)((e=>{const{a:n,d:r}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=e,c=d(i*i),l=d(o*o),u=d(s*s),h=d(u*u),f=d(c*n);if(d(u*d(f+l))!==d(h+d(r*d(c*l))))throw new Error("bad point: equation left != right (1)");if(d(i*o)!==d(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class b{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 b)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return g("x",t),g("y",n),new b(t,n,ci,d(t*n))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(b.fromAffine)}static msm(e,t){return(0,ri.pippenger)(b,u,e,t)}_setWindowSize(e){C.setWindowSize(this,e)}assertValidity(){v(this)}equals(e){m(e);const{ex:t,ey:n,ez:r}=this,{ex:i,ey:o,ez:s}=e,a=d(t*s),c=d(i*r),l=d(n*s),u=d(o*r);return a===c&&l===u}is0(){return this.equals(b.ZERO)}negate(){return new b(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){const{a:e}=t,{ex:n,ey:r,ez:i}=this,o=d(n*n),s=d(r*r),a=d(li*d(i*i)),c=d(e*o),l=n+r,u=d(d(l*l)-o-s),h=c+s,f=h-a,p=c-s,g=d(u*f),m=d(h*p),y=d(u*p),v=d(f*h);return new b(g,m,v,y)}add(e){m(e);const{a:n,d:r}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:l,ez:u,et:h}=e;if(n===BigInt(-1)){const e=d((o-i)*(l+c)),t=d((o+i)*(l-c)),n=d(t-e);if(n===ai)return this.double();const r=d(s*li*h),f=d(a*li*u),p=f+r,g=t+e,m=f-r,y=d(p*n),v=d(g*m),w=d(p*m),E=d(n*g);return new b(y,v,E,w)}const f=d(i*c),p=d(o*l),g=d(a*r*h),y=d(s*u),v=d((i+o)*(c+l)-f-p),w=y-g,E=y+g,C=d(p-n*f),_=d(v*w),S=d(E*C),k=d(v*C),x=d(w*E);return new b(_,S,x,k)}subtract(e){return this.add(e.negate())}wNAF(e){return C.wNAFCached(this,e,b.normalizeZ)}multiply(e){const t=e;oi.aInRange("scalar",t,ci,r);const{p:n,f:i}=this.wNAF(t);return b.normalizeZ([n,i])[0]}multiplyUnsafe(e){const t=e;return oi.aInRange("scalar",t,ai,r),t===ai?E:this.equals(E)||t===ci?this:this.equals(w)?this.wNAF(t).p:C.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return C.unsafeLadder(this,r).is0()}toAffine(e){return y(this,e)}clearCofactor(){const{h:e}=t;return e===ci?this:this.multiplyUnsafe(e)}static fromHex(e,r=!1){const{d:i,a:o}=t,s=n.BYTES;e=(0,si.ensureBytes)("pointHex",e,s),(0,si.abool)("zip215",r);const a=e.slice(),c=e[s-1];a[s-1]=-129&c;const u=oi.bytesToNumberLE(a),f=r?l:n.ORDER;oi.aInRange("pointHex.y",u,ai,f);const p=d(u*u),g=d(p-ci),m=d(i*p-o);let{isValid:y,value:v}=h(g,m);if(!y)throw new Error("Point.fromHex: invalid y coordinate");const w=(v&ci)===ci,E=0!=(128&c);if(!r&&v===ai&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==w&&(v=d(-v)),b.fromAffine({x:v,y:u})}static fromPrivateKey(e){return k(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=oi.numberToBytesLE(t,n.BYTES);return r[r.length-1]|=e&ci?128:0,r}toHex(){return oi.bytesToHex(this.toRawBytes())}}b.BASE=new b(t.Gx,t.Gy,ci,d(t.Gx*t.Gy)),b.ZERO=new b(ai,ci,ci,ai);const{BASE:w,ZERO:E}=b,C=(0,ri.wNAF)(b,8*a);function _(e){return(0,ii.mod)(e,r)}function S(e){return _(oi.bytesToNumberLE(e))}function k(e){const t=a;e=(0,si.ensureBytes)("private key",e,t);const n=(0,si.ensureBytes)("hashed private key",o(e),2*t),r=f(n.slice(0,t)),i=n.slice(t,2*t),s=S(r),c=w.multiply(s),l=c.toRawBytes();return{head:r,prefix:i,scalar:s,point:c,pointBytes:l}}function x(e=new Uint8Array,...t){const n=oi.concatBytes(...t);return S(o(p(n,(0,si.ensureBytes)("context",e),!!i)))}const A=ui;w._setWindowSize(8);const M={getExtendedPublicKey:k,randomPrivateKey:()=>s(n.BYTES),precompute:(e=8,t=b.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};return{CURVE:t,getPublicKey:function(e){return k(e).pointBytes},sign:function(e,t,o={}){e=(0,si.ensureBytes)("message",e),i&&(e=i(e));const{prefix:s,scalar:c,pointBytes:l}=k(t),d=x(o.context,s,e),u=w.multiply(d).toRawBytes(),h=_(d+x(o.context,u,l,e)*c);oi.aInRange("signature.s",h,ai,r);const f=oi.concatBytes(u,oi.numberToBytesLE(h,n.BYTES));return(0,si.ensureBytes)("result",f,2*a)},verify:function(e,t,r,o=A){const{context:s,zip215:a}=o,c=n.BYTES;e=(0,si.ensureBytes)("signature",e,2*c),t=(0,si.ensureBytes)("message",t),void 0!==a&&(0,si.abool)("zip215",a),i&&(t=i(t));const l=oi.bytesToNumberLE(e.slice(c,2*c));let d,u,h;try{d=b.fromHex(r,a),u=b.fromHex(e.slice(0,c),a),h=w.multiplyUnsafe(l)}catch(e){return!1}if(!a&&d.isSmallOrder())return!1;const f=x(s,u.toRawBytes(),d.toRawBytes(),t);return u.add(d.multiplyUnsafe(f)).subtract(h).clearCofactor().equals(b.ZERO)},ExtendedPoint:b,utils:M}};const ri=lr,ii=dr,oi=ur,si=ur,ai=BigInt(0),ci=BigInt(1),li=BigInt(2),di=BigInt(8),ui={zip215:!0};var hi={};Object.defineProperty(hi,"__esModule",{value:!0}),hi.expand_message_xmd=bi,hi.expand_message_xof=wi,hi.hash_to_field=Ei,hi.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[i,o,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(i,o),r=e.mul(r,e.div(s,a)),{x:t,y:r}}},hi.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=Ei(r,2,{...n,DST:n.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=Ei(r,1,{...n,DST:n.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(const e of n)if("bigint"!=typeof e)throw new Error(`mapToCurve: expected array of bigints, got ${e} in array`);const r=e.fromAffine(t(n)).clearCofactor();return r.assertValidity(),r}}};const fi=dr,pi=ur,gi=pi.bytesToNumberBE;function mi(e,t){if(vi(e),vi(t),e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function yi(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function vi(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function bi(e,t,n,r){(0,pi.abytes)(e),(0,pi.abytes)(t),vi(n),t.length>255&&(t=r((0,pi.concatBytes)((0,pi.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:o}=r,s=Math.ceil(n/i);if(n>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=(0,pi.concatBytes)(t,mi(t.length,1)),c=mi(0,o),l=mi(n,2),d=new Array(s),u=r((0,pi.concatBytes)(c,e,l,mi(0,1),a));d[0]=r((0,pi.concatBytes)(u,mi(1,1),a));for(let e=1;e<=s;e++){const t=[yi(u,d[e-1]),mi(e+1,1),a];d[e]=r((0,pi.concatBytes)(...t))}return(0,pi.concatBytes)(...d).slice(0,n)}function wi(e,t,n,r,i){if((0,pi.abytes)(e),(0,pi.abytes)(t),vi(n),t.length>255){const e=Math.ceil(2*r/8);t=i.create({dkLen:e}).update((0,pi.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:n}).update(e).update(mi(n,2)).update(t).update(mi(t.length,1)).digest()}function Ei(e,t,n){(0,pi.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:i,m:o,hash:s,expand:a,DST:c}=n;(0,pi.abytes)(e),vi(t);const l="string"==typeof c?(0,pi.utf8ToBytes)(c):c,d=r.toString(2).length,u=Math.ceil((d+i)/8),h=t*o*u;let f;if("xmd"===a)f=bi(e,l,h,s);else if("xof"===a)f=wi(e,l,h,i,s);else{if("_internal_pass"!==a)throw new Error('expand must be "xmd" or "xof"');f=e}const p=new Array(t);for(let e=0;e<t;e++){const t=new Array(o);for(let n=0;n<o;n++){const i=u*(n+e*o),s=f.subarray(i,i+u);t[n]=(0,fi.mod)(gi(s),r)}p[e]=t}return p}var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.montgomery=function(e){const t=function(e){return(0,Si.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:n}=t,r=e=>(0,_i.mod)(e,n),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>(0,_i.pow)(e,n-BigInt(2),n));function l(e,t,n){const i=r(e*(t-n));return[t=r(t-i),n=r(n+i)]}const d=(t.a-BigInt(2))/BigInt(4);function u(e){return(0,Si.numberToBytesLE)(r(e),o)}function h(e,t){const h=function(e){const t=(0,Si.ensureBytes)("u coordinate",e,o);return 32===s&&(t[31]&=127),(0,Si.bytesToNumberLE)(t)}(t),f=function(e){const t=(0,Si.ensureBytes)("scalar",e),n=t.length;if(n!==o&&n!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${n}`);return(0,Si.bytesToNumberLE)(a(t))}(e),p=function(e,t){(0,Si.aInRange)("u",e,ki,n),(0,Si.aInRange)("scalar",t,ki,n);const o=t,s=e;let a,u=xi,h=ki,f=e,p=xi,g=ki;for(let e=BigInt(i-1);e>=ki;e--){const t=o>>e&xi;g^=t,a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1],g=t;const n=u+h,i=r(n*n),c=u-h,m=r(c*c),y=i-m,v=f+p,b=r((f-p)*n),w=r(v*c),E=b+w,C=b-w;f=r(E*E),p=r(s*r(C*C)),u=r(i*m),h=r(y*(i+r(d*y)))}a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1];const m=c(h);return r(u*m)}(h,f);if(p===ki)throw new Error("Invalid private or public key received");return u(p)}const f=u(t.Gu);function p(e){return h(e,f)}return{scalarMult:h,scalarMultBase:p,getSharedSecret:(e,t)=>h(e,t),getPublicKey:e=>p(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:f}};const _i=dr,Si=ur,ki=BigInt(0),xi=BigInt(1);!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hash_to_ristretto255=e.hashToRistretto255=e.RistrettoPoint=e.encodeToCurve=e.hashToCurve=e.edwardsToMontgomery=e.x25519=e.ed25519ph=e.ed25519ctx=e.ed25519=e.ED25519_TORSION_SUBGROUP=void 0,e.edwardsToMontgomeryPub=C,e.edwardsToMontgomeryPriv=function(e){const t=w.hash(e.subarray(0,32));return w.adjustScalarBytes(t).subarray(0,32)};const t=dn,n=En,r=cr,i=hi,o=dr,s=Ci,a=ur,c=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),d=BigInt(0),u=BigInt(1),h=BigInt(2),f=BigInt(3),p=BigInt(5),g=BigInt(8);function m(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),s=c,a=e*e%s*e%s,l=(0,o.pow2)(a,h,s)*a%s,d=(0,o.pow2)(l,u,s)*e%s,f=(0,o.pow2)(d,p,s)*d%s,g=(0,o.pow2)(f,t,s)*f%s,m=(0,o.pow2)(g,n,s)*g%s,y=(0,o.pow2)(m,r,s)*m%s,v=(0,o.pow2)(y,i,s)*y%s,b=(0,o.pow2)(v,i,s)*y%s,w=(0,o.pow2)(b,t,s)*f%s;return{pow_p_5_8:(0,o.pow2)(w,h,s)*e%s,b2:a}}function y(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function v(e,t){const n=c,r=(0,o.mod)(t*t*t,n),i=m(e*(0,o.mod)(r*r*t,n)).pow_p_5_8;let s=(0,o.mod)(e*r*i,n);const a=(0,o.mod)(t*s*s,n),d=s,u=(0,o.mod)(s*l,n),h=a===e,f=a===(0,o.mod)(-e,n),p=a===(0,o.mod)(-e*l,n);return h&&(s=d),(f||p)&&(s=u),(0,o.isNegativeLE)(s,n)&&(s=(0,o.mod)(-s,n)),{isValid:h||f,value:s}}e.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const b=(0,o.Field)(c,void 0,!0),w={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:b,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:g,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:t.sha512,randomBytes:n.randomBytes,adjustScalarBytes:y,uvRatio:v};function E(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,n.concatBytes)((0,n.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}function C(t){const{y:n}=e.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return b.toBytes(b.create((r+n)*b.inv(r-n)))}e.ed25519=(0,r.twistedEdwards)(w),e.ed25519ctx=(0,r.twistedEdwards)({...w,domain:E}),e.ed25519ph=(0,r.twistedEdwards)(Object.assign({},w,{domain:E,prehash:t.sha512})),e.x25519=(0,s.montgomery)({P:c,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=c,{pow_p_5_8:n,b2:r}=m(e);return(0,o.mod)((0,o.pow2)(n,f,t)*r,t)},adjustScalarBytes:y,randomBytes:n.randomBytes}),e.edwardsToMontgomery=C;const _=(b.ORDER+f)/g,S=b.pow(h,_),k=b.sqrt(b.neg(b.ONE)),x=(0,o.FpSqrtEven)(b,b.neg(BigInt(486664)));const A=(0,i.createHasher)(e.ed25519.ExtendedPoint,(e=>function(e){const{xMn:t,xMd:n,yMn:r,yMd:i}=function(e){const t=(b.ORDER-p)/g,n=BigInt(486662);let r=b.sqr(e);r=b.mul(r,h);let i=b.add(r,b.ONE),o=b.neg(n),s=b.sqr(i),a=b.mul(s,i),c=b.mul(r,n);c=b.mul(c,o),c=b.add(c,s),c=b.mul(c,o);let l=b.sqr(a);s=b.sqr(l),l=b.mul(l,a),l=b.mul(l,c),s=b.mul(s,l);let d=b.pow(s,t);d=b.mul(d,l);let f=b.mul(d,k);s=b.sqr(d),s=b.mul(s,a);let m=b.eql(s,c),y=b.cmov(f,d,m),v=b.mul(o,r),w=b.mul(d,e);w=b.mul(w,S);let E=b.mul(w,k),C=b.mul(c,r);s=b.sqr(w),s=b.mul(s,a);let _=b.eql(s,C),x=b.cmov(E,w,_);s=b.sqr(y),s=b.mul(s,a);let A=b.eql(s,c),M=b.cmov(v,o,A),L=b.cmov(x,y,A),T=b.isOdd(L);return L=b.cmov(L,b.neg(L),A!==T),{xMn:M,xMd:i,yMn:L,yMd:u}}(e);let o=b.mul(t,i);o=b.mul(o,x);let s=b.mul(n,r),a=b.sub(t,n),c=b.add(t,n),l=b.mul(s,c),d=b.eql(l,b.ZERO);o=b.cmov(o,b.ZERO,d),s=b.cmov(s,b.ONE,d),a=b.cmov(a,b.ONE,d),c=b.cmov(c,b.ONE,d);const f=b.invertBatch([s,c]);return{x:b.mul(o,f[0]),y:b.mul(a,f[1])}}(e[0])),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:b.ORDER,m:1,k:128,expand:"xmd",hash:t.sha512});function M(e){if(!(e instanceof $))throw new Error("RistrettoPoint expected")}e.hashToCurve=A.hashToCurve,e.encodeToCurve=A.encodeToCurve;const L=l,T=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),R=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),P=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),I=e=>v(u,e),N=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),B=t=>e.ed25519.CURVE.Fp.create((0,a.bytesToNumberLE)(t)&N);function D(t){const{d:n}=e.ed25519.CURVE,r=e.ed25519.CURVE.Fp.ORDER,i=e.ed25519.CURVE.Fp.create,s=i(L*t*t),a=i((s+u)*R);let c=BigInt(-1);const l=i((c-n*s)*i(s+n));let{isValid:d,value:h}=v(a,l),f=i(h*t);(0,o.isNegativeLE)(f,r)||(f=i(-f)),d||(h=f),d||(c=s);const p=i(c*(s-u)*P-l),g=h*h,m=i((h+h)*l),y=i(p*T),b=i(u-g),w=i(u+g);return new e.ed25519.ExtendedPoint(i(m*w),i(b*y),i(y*w),i(m*b))}class ${constructor(e){this.ep=e}static fromAffine(t){return new $(e.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(e){e=(0,a.ensureBytes)("ristrettoHash",e,64);const t=D(B(e.slice(0,32))),n=D(B(e.slice(32,64)));return new $(t.add(n))}static fromHex(t){t=(0,a.ensureBytes)("ristrettoHex",t,32);const{a:n,d:r}=e.ed25519.CURVE,i=e.ed25519.CURVE.Fp.ORDER,s=e.ed25519.CURVE.Fp.create,c="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",l=B(t);if(!(0,a.equalBytes)((0,a.numberToBytesLE)(l,32),t)||(0,o.isNegativeLE)(l,i))throw new Error(c);const h=s(l*l),f=s(u+n*h),p=s(u-n*h),g=s(f*f),m=s(p*p),y=s(n*r*g-m),{isValid:v,value:b}=I(s(y*m)),w=s(b*p),E=s(b*w*y);let C=s((l+l)*w);(0,o.isNegativeLE)(C,i)&&(C=s(-C));const _=s(f*E),S=s(C*_);if(!v||(0,o.isNegativeLE)(S,i)||_===d)throw new Error(c);return new $(new e.ed25519.ExtendedPoint(C,_,u,S))}toRawBytes(){let{ex:t,ey:n,ez:r,et:i}=this.ep;const s=e.ed25519.CURVE.Fp.ORDER,c=e.ed25519.CURVE.Fp.create,l=c(c(r+n)*c(r-n)),d=c(t*n),u=c(d*d),{value:h}=I(c(l*u)),f=c(h*l),p=c(h*d),g=c(f*p*i);let m;if((0,o.isNegativeLE)(i*g,s)){let e=c(n*L),r=c(t*L);t=e,n=r,m=c(f*O)}else m=p;(0,o.isNegativeLE)(t*g,s)&&(n=c(-n));let y=c((r-n)*m);return(0,o.isNegativeLE)(y,s)&&(y=c(-y)),(0,a.numberToBytesLE)(y,32)}toHex(){return(0,a.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const{ex:n,ey:r}=this.ep,{ex:i,ey:o}=t.ep,s=e.ed25519.CURVE.Fp.create,a=s(n*o)===s(r*i),c=s(r*o)===s(n*i);return a||c}add(e){return M(e),new $(this.ep.add(e.ep))}subtract(e){return M(e),new $(this.ep.subtract(e.ep))}multiply(e){return new $(this.ep.multiply(e))}multiplyUnsafe(e){return new $(this.ep.multiplyUnsafe(e))}double(){return new $(this.ep.double())}negate(){return new $(this.ep.negate())}}e.RistrettoPoint=($.BASE||($.BASE=new $(e.ed25519.ExtendedPoint.BASE)),$.ZERO||($.ZERO=new $(e.ed25519.ExtendedPoint.ZERO)),$),e.hashToRistretto255=(e,r)=>{const o=r.DST,s="string"==typeof o?(0,n.utf8ToBytes)(o):o,a=(0,i.expand_message_xmd)(e,s,64,t.sha512);return $.hashToCurve(a)},e.hash_to_ristretto255=e.hashToRistretto255}(ln);var Ai={},Mi={};Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.sha224=Mi.sha256=Mi.SHA256=void 0;const Li=un,Ti=En,Oi=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]),Ri=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pi=new Uint32Array(64);class Ii extends Li.HashMD{constructor(){super(64,32,8,!1),this.A=0|Ri[0],this.B=0|Ri[1],this.C=0|Ri[2],this.D=0|Ri[3],this.E=0|Ri[4],this.F=0|Ri[5],this.G=0|Ri[6],this.H=0|Ri[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)Pi[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Pi[e-15],n=Pi[e-2],r=(0,Ti.rotr)(t,7)^(0,Ti.rotr)(t,18)^t>>>3,i=(0,Ti.rotr)(n,17)^(0,Ti.rotr)(n,19)^n>>>10;Pi[e]=i+Pi[e-7]+r+Pi[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+((0,Ti.rotr)(s,6)^(0,Ti.rotr)(s,11)^(0,Ti.rotr)(s,25))+(0,Li.Chi)(s,a,c)+Oi[e]+Pi[e]|0,d=((0,Ti.rotr)(n,2)^(0,Ti.rotr)(n,13)^(0,Ti.rotr)(n,22))+(0,Li.Maj)(n,r,i)|0;l=c,c=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,o,s,a,c,l)}roundClean(){Pi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Mi.SHA256=Ii;class Ni extends Ii{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Mi.sha256=(0,Ti.wrapConstructor)((()=>new Ii)),Mi.sha224=(0,Ti.wrapConstructor)((()=>new Ni));var Bi={},Di={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=hn,n=En;class r extends n.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(e);const i=(0,n.toBytes)(r);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 o=this.blockLen,s=new Uint8Array(o);s.set(i.length>o?e.create().update(i).digest():i);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return(0,t.exists)(this),this.iHash.update(e),this}digestInto(e){(0,t.exists)(this),(0,t.bytes)(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:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,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()}}e.HMAC=r,e.hmac=(e,t,n)=>new r(e,t).update(n).digest(),e.hmac.create=(e,t)=>new r(e,t)}(Di);var $i={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DER=void 0,e.weierstrassPoints=f,e.weierstrass=function(s){const a=function(e){const n=(0,t.validateBasic)(e);return r.validateObject(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}(s),{Fp:d,n:u}=a,h=d.BYTES+1,p=2*d.BYTES+1;function g(e){return n.mod(e,u)}function m(e){return n.invert(e,u)}const{ProjectivePoint:y,normPrivateKeyToScalar:v,weierstrassEquation:b,isWithinCurveOrder:w}=f({...a,toBytes(e,t,n){const o=t.toAffine(),s=d.toBytes(o.x),a=r.concatBytes;return(0,i.abool)("isCompressed",n),n?a(Uint8Array.from([t.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,d.toBytes(o.y))},fromBytes(e){const t=e.length,n=e[0],i=e.subarray(1);if(t!==h||2!==n&&3!==n){if(t===p&&4===n)return{x:d.fromBytes(i.subarray(0,d.BYTES)),y:d.fromBytes(i.subarray(d.BYTES,2*d.BYTES))};throw new Error(`Point of length ${t} was invalid. Expected ${h} compressed bytes or ${p} uncompressed bytes`)}{const t=r.bytesToNumberBE(i);if(!r.inRange(t,l,d.ORDER))throw new Error("Point is not on curve");const o=b(t);let s;try{s=d.sqrt(o)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&n)!=((s&l)===l)&&(s=d.neg(s)),{x:t,y:s}}}}),E=e=>r.bytesToHex(r.numberToBytesBE(e,a.nByteLength));function C(e){return e>u>>l}const _=(e,t,n)=>r.bytesToNumberBE(e.slice(t,n));class S{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const t=a.nByteLength;return e=(0,i.ensureBytes)("compactSignature",e,2*t),new S(_(e,0,t),_(e,t,2*t))}static fromDER(t){const{r:n,s:r}=e.DER.toSig((0,i.ensureBytes)("DER",t));return new S(n,r)}assertValidity(){r.aInRange("r",this.r,l,u),r.aInRange("s",this.s,l,u)}addRecoveryBit(e){return new S(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:n,recovery:r}=this,o=M((0,i.ensureBytes)("msgHash",e));if(null==r||![0,1,2,3].includes(r))throw new Error("recovery id invalid");const s=2===r||3===r?t+a.n:t;if(s>=d.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=0==(1&r)?"02":"03",l=y.fromHex(c+E(s)),u=m(s),h=g(-o*u),f=g(n*u),p=y.BASE.multiplyAndAddUnsafe(l,h,f);if(!p)throw new Error("point at infinify");return p.assertValidity(),p}hasHighS(){return C(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,g(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const k={isValidPrivateKey(e){try{return v(e),!0}catch(e){return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const e=n.getMinHashLength(a.n);return n.mapHashToField(a.randomBytes(e),a.n)},precompute:(e=8,t=y.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function x(e){const t=r.isBytes(e),n="string"==typeof e,i=(t||n)&&e.length;return t?i===h||i===p:n?i===2*h||i===2*p:e instanceof y}const A=a.bits2int||function(e){const t=r.bytesToNumberBE(e),n=8*e.length-a.nBitLength;return n>0?t>>BigInt(n):t},M=a.bits2int_modN||function(e){return g(A(e))},L=r.bitMask(a.nBitLength);function T(e){return r.aInRange(`num < 2^${a.nBitLength}`,e,c,L),r.numberToBytesBE(e,a.nByteLength)}function O(e,t,n=R){if(["recovered","canonical"].some((e=>e in n)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=a;let{lowS:h,prehash:f,extraEntropy:p}=n;null==h&&(h=!0),e=(0,i.ensureBytes)("msgHash",e),o(n),f&&(e=(0,i.ensureBytes)("prehashed msgHash",s(e)));const b=M(e),E=v(t),_=[T(E),T(b)];if(null!=p&&!1!==p){const e=!0===p?u(d.BYTES):p;_.push((0,i.ensureBytes)("extraEntropy",e))}const k=r.concatBytes(..._),x=b;return{seed:k,k2sig:function(e){const t=A(e);if(!w(t))return;const n=m(t),r=y.BASE.multiply(t).toAffine(),i=g(r.x);if(i===c)return;const o=g(n*g(x+i*E));if(o===c)return;let s=(r.x===i?0:2)|Number(r.y&l),a=o;return h&&C(o)&&(a=function(e){return C(e)?g(-e):e}(o),s^=1),new S(i,a,s)}}}const R={lowS:a.lowS,prehash:!1},P={lowS:a.lowS,prehash:!1};return y.BASE._setWindowSize(8),{CURVE:a,getPublicKey:function(e,t=!0){return y.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(x(e))throw new Error("first arg must be private key");if(!x(t))throw new Error("second arg must be public key");return y.fromHex(t).multiply(v(e)).toRawBytes(n)},sign:function(e,t,n=R){const{seed:i,k2sig:o}=O(e,t,n),s=a;return r.createHmacDrbg(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,n,s,c=P){const l=t;if(n=(0,i.ensureBytes)("msgHash",n),s=(0,i.ensureBytes)("publicKey",s),"strict"in c)throw new Error("options.strict was renamed to lowS");o(c);const{lowS:d,prehash:u}=c;let h,f;try{if("string"==typeof l||r.isBytes(l))try{h=S.fromDER(l)}catch(t){if(!(t instanceof e.DER.Err))throw t;h=S.fromCompact(l)}else{if("object"!=typeof l||"bigint"!=typeof l.r||"bigint"!=typeof l.s)throw new Error("PARSE");{const{r:e,s:t}=l;h=new S(e,t)}}f=y.fromHex(s)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(d&&h.hasHighS())return!1;u&&(n=a.hash(n));const{r:p,s:v}=h,b=M(n),w=m(v),E=g(b*w),C=g(p*w),_=y.BASE.multiplyAndAddUnsafe(f,E,C)?.toAffine();if(!_)return!1;return g(_.x)===p},ProjectivePoint:y,Signature:S,utils:k}},e.SWUFpSqrtRatio=p,e.mapToCurveSimpleSWU=function(e,t){if(n.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,s,a,c,l,d,u;i=e.sqr(n),i=e.mul(i,t.Z),o=e.sqr(i),o=e.add(o,i),s=e.add(o,e.ONE),s=e.mul(s,t.B),a=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,t.A),o=e.sqr(s),l=e.sqr(a),c=e.mul(l,t.A),o=e.add(o,c),o=e.mul(o,s),l=e.mul(l,a),c=e.mul(l,t.B),o=e.add(o,c),d=e.mul(i,s);const{isValid:h,value:f}=r(o,l);u=e.mul(i,n),u=e.mul(u,f),d=e.cmov(d,s,h),u=e.cmov(u,f,h);const p=e.isOdd(n)===e.isOdd(u);return u=e.cmov(e.neg(u),u,p),d=e.div(d,a),{x:d,y:u}}};const t=lr,n=dr,r=ur,i=ur;function o(e){void 0!==e.lowS&&(0,i.abool)("lowS",e.lowS),void 0!==e.prehash&&(0,i.abool)("prehash",e.prehash)}const{bytesToNumberBE:s,hexToBytes:a}=r;e.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,n)=>{const{Err:i}=e.DER;if(t<0||t>256)throw new i("tlv.encode: wrong tag");if(1&n.length)throw new i("tlv.encode: unpadded data");const o=n.length/2,s=r.numberToHexUnpadded(o);if(s.length/2&128)throw new i("tlv.encode: long form length too big");const a=o>127?r.numberToHexUnpadded(s.length/2|128):"";return`${r.numberToHexUnpadded(t)}${a}${s}${n}`},decode(t,n){const{Err:r}=e.DER;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(n.length<2||n[i++]!==t)throw new r("tlv.decode: wrong tlv");const o=n[i++];let s=0;if(128&o){const e=127&o;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const t=n.subarray(i,i+e);if(t.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===t[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of t)s=s<<8|e;if(i+=e,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=o;const a=n.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:n.subarray(i+s)}}},_int:{encode(t){const{Err:n}=e.DER;if(t<c)throw new n("integer: negative integers are not allowed");let i=r.numberToHexUnpadded(t);if(8&Number.parseInt(i[0],16)&&(i="00"+i),1&i.length)throw new n("unexpected assertion");return i},decode(t){const{Err:n}=e.DER;if(128&t[0])throw new n("Invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new n("Invalid signature integer: unnecessary leading zero");return s(t)}},toSig(t){const{Err:n,_int:i,_tlv:o}=e.DER,s="string"==typeof t?a(t):t;r.abytes(s);const{v:c,l:l}=o.decode(48,s);if(l.length)throw new n("Invalid signature: left bytes after parsing");const{v:d,l:u}=o.decode(2,c),{v:h,l:f}=o.decode(2,u);if(f.length)throw new n("Invalid signature: left bytes after parsing");return{r:i.decode(d),s:i.decode(h)}},hexFromSig(t){const{_tlv:n,_int:r}=e.DER,i=`${n.encode(2,r.encode(t.r))}${n.encode(2,r.encode(t.s))}`;return n.encode(48,i)}};const c=BigInt(0),l=BigInt(1),d=BigInt(2),u=BigInt(3),h=BigInt(4);function f(e){const o=function(e){const n=(0,t.validateBasic)(e);r.validateObject(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:i,Fp:o,a:s}=n;if(i){if(!o.eql(s,o.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof i||"bigint"!=typeof i.beta||"function"!=typeof i.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}(e),{Fp:s}=o,a=n.Field(o.n,o.nBitLength),d=o.toBytes||((e,t,n)=>{const i=t.toAffine();return r.concatBytes(Uint8Array.from([4]),s.toBytes(i.x),s.toBytes(i.y))}),h=o.fromBytes||(e=>{const t=e.subarray(1);return{x:s.fromBytes(t.subarray(0,s.BYTES)),y:s.fromBytes(t.subarray(s.BYTES,2*s.BYTES))}});function f(e){const{a:t,b:n}=o,r=s.sqr(e),i=s.mul(r,e);return s.add(s.add(i,s.mul(e,t)),n)}if(!s.eql(s.sqr(o.Gy),f(o.Gx)))throw new Error("bad generator point: equation left != right");function p(e){const{allowedPrivateKeyLengths:t,nByteLength:s,wrapPrivateKey:a,n:c}=o;if(t&&"bigint"!=typeof e){if(r.isBytes(e)&&(e=r.bytesToHex(e)),"string"!=typeof e||!t.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*s,"0")}let d;try{d="bigint"==typeof e?e:r.bytesToNumberBE((0,i.ensureBytes)("private key",e,s))}catch(t){throw new Error(`private key must be ${s} bytes, hex or bigint, not ${typeof e}`)}return a&&(d=n.mod(d,c)),r.aInRange("private key",d,l,c),d}function g(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const m=(0,i.memoized)(((e,t)=>{const{px:n,py:r,pz:i}=e;if(s.eql(i,s.ONE))return{x:n,y:r};const o=e.is0();null==t&&(t=o?s.ONE:s.inv(i));const a=s.mul(n,t),c=s.mul(r,t),l=s.mul(i,t);if(o)return{x:s.ZERO,y:s.ZERO};if(!s.eql(l,s.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),y=(0,i.memoized)((e=>{if(e.is0()){if(o.allowInfinityPoint&&!s.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=e.toAffine();if(!s.isValid(t)||!s.isValid(n))throw new Error("bad point: x or y not FE");const r=s.sqr(n),i=f(t);if(!s.eql(r,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class v{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!s.isValid(e))throw new Error("x required");if(null==t||!s.isValid(t))throw new Error("y required");if(null==n||!s.isValid(n))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!s.isValid(t)||!s.isValid(n))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const r=e=>s.eql(e,s.ZERO);return r(t)&&r(n)?v.ZERO:new v(t,n,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(h((0,i.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(p(e))}static msm(e,n){return(0,t.pippenger)(v,a,e,n)}_setWindowSize(e){w.setWindowSize(this,e)}assertValidity(){y(this)}hasEvenY(){const{y:e}=this.toAffine();if(s.isOdd)return!s.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:o,pz:a}=e,c=s.eql(s.mul(t,a),s.mul(i,r)),l=s.eql(s.mul(n,a),s.mul(o,r));return c&&l}negate(){return new v(this.px,s.neg(this.py),this.pz)}double(){const{a:e,b:t}=o,n=s.mul(t,u),{px:r,py:i,pz:a}=this;let c=s.ZERO,l=s.ZERO,d=s.ZERO,h=s.mul(r,r),f=s.mul(i,i),p=s.mul(a,a),g=s.mul(r,i);return g=s.add(g,g),d=s.mul(r,a),d=s.add(d,d),c=s.mul(e,d),l=s.mul(n,p),l=s.add(c,l),c=s.sub(f,l),l=s.add(f,l),l=s.mul(c,l),c=s.mul(g,c),d=s.mul(n,d),p=s.mul(e,p),g=s.sub(h,p),g=s.mul(e,g),g=s.add(g,d),d=s.add(h,h),h=s.add(d,h),h=s.add(h,p),h=s.mul(h,g),l=s.add(l,h),p=s.mul(i,a),p=s.add(p,p),h=s.mul(p,g),c=s.sub(c,h),d=s.mul(p,f),d=s.add(d,d),d=s.add(d,d),new v(c,l,d)}add(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:a,pz:c}=e;let l=s.ZERO,d=s.ZERO,h=s.ZERO;const f=o.a,p=s.mul(o.b,u);let m=s.mul(t,i),y=s.mul(n,a),b=s.mul(r,c),w=s.add(t,n),E=s.add(i,a);w=s.mul(w,E),E=s.add(m,y),w=s.sub(w,E),E=s.add(t,r);let C=s.add(i,c);return E=s.mul(E,C),C=s.add(m,b),E=s.sub(E,C),C=s.add(n,r),l=s.add(a,c),C=s.mul(C,l),l=s.add(y,b),C=s.sub(C,l),h=s.mul(f,E),l=s.mul(p,b),h=s.add(l,h),l=s.sub(y,h),h=s.add(y,h),d=s.mul(l,h),y=s.add(m,m),y=s.add(y,m),b=s.mul(f,b),E=s.mul(p,E),y=s.add(y,b),b=s.sub(m,b),b=s.mul(f,b),E=s.add(E,b),m=s.mul(y,E),d=s.add(d,m),m=s.mul(C,E),l=s.mul(w,l),l=s.sub(l,m),m=s.mul(w,y),h=s.mul(C,h),h=s.add(h,m),new v(l,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return w.wNAFCached(this,e,v.normalizeZ)}multiplyUnsafe(e){r.aInRange("scalar",e,c,o.n);const t=v.ZERO;if(e===c)return t;if(e===l)return this;const{endo:n}=o;if(!n)return w.unsafeLadder(this,e);let{k1neg:i,k1:a,k2neg:d,k2:u}=n.splitScalar(e),h=t,f=t,p=this;for(;a>c||u>c;)a&l&&(h=h.add(p)),u&l&&(f=f.add(p)),p=p.double(),a>>=l,u>>=l;return i&&(h=h.negate()),d&&(f=f.negate()),f=new v(s.mul(f.px,n.beta),f.py,f.pz),h.add(f)}multiply(e){const{endo:t,n:n}=o;let i,a;if(r.aInRange("scalar",e,l,n),t){const{k1neg:n,k1:r,k2neg:o,k2:c}=t.splitScalar(e);let{p:l,f:d}=this.wNAF(r),{p:u,f:h}=this.wNAF(c);l=w.constTimeNegate(n,l),u=w.constTimeNegate(o,u),u=new v(s.mul(u.px,t.beta),u.py,u.pz),i=l.add(u),a=d.add(h)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return v.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=v.BASE,i=(e,t)=>t!==c&&t!==l&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){return m(this,e)}isTorsionFree(){const{h:e,isTorsionFree:t}=o;if(e===l)return!0;if(t)return t(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:t}=o;return e===l?this:t?t(v,this):this.multiplyUnsafe(o.h)}toRawBytes(e=!0){return(0,i.abool)("isCompressed",e),this.assertValidity(),d(v,this,e)}toHex(e=!0){return(0,i.abool)("isCompressed",e),r.bytesToHex(this.toRawBytes(e))}}v.BASE=new v(o.Gx,o.Gy,s.ONE),v.ZERO=new v(s.ZERO,s.ONE,s.ZERO);const b=o.nBitLength,w=(0,t.wNAF)(v,o.endo?Math.ceil(b/2):b);return{CURVE:o,ProjectivePoint:v,normPrivateKeyToScalar:p,weierstrassEquation:f,isWithinCurveOrder:function(e){return r.inRange(e,l,o.n)}}}function p(e,t){const n=e.ORDER;let r=c;for(let e=n-l;e%d===c;e/=d)r+=l;const i=r,o=d<<i-l-l,s=o*d,a=(n-l)/s,f=(a-l)/d,p=s-l,g=o,m=e.pow(t,a),y=e.pow(t,(a+l)/d);let v=(t,n)=>{let r=m,o=e.pow(n,p),s=e.sqr(o);s=e.mul(s,n);let a=e.mul(t,s);a=e.pow(a,f),a=e.mul(a,o),o=e.mul(a,n),s=e.mul(a,t);let c=e.mul(s,o);a=e.pow(c,g);let u=e.eql(a,e.ONE);o=e.mul(s,y),a=e.mul(c,r),s=e.cmov(o,s,u),c=e.cmov(a,c,u);for(let t=i;t>l;t--){let n=t-d;n=d<<n-l;let i=e.pow(c,n);const a=e.eql(i,e.ONE);o=e.mul(s,r),r=e.mul(r,r),i=e.mul(c,r),s=e.cmov(o,s,a),c=e.cmov(i,c,a)}return{isValid:u,value:s}};if(e.ORDER%h===u){const n=(e.ORDER-u)/h,r=e.sqrt(e.neg(t));v=(t,i)=>{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,n);a=e.mul(a,s);const c=e.mul(a,r),l=e.mul(e.sqr(a),i),d=e.eql(l,t);return{isValid:d,value:e.cmov(c,a,d)}}}return v}}($i),Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.getHash=Fi,Bi.createCurve=function(e,t){const n=t=>(0,Ui.weierstrass)({...e,...Fi(t)});return Object.freeze({...n(t),create:n})};const ji=Di,Ki=En,Ui=$i;function Fi(e){return{hash:e,hmac:(t,...n)=>(0,ji.hmac)(e,t,(0,Ki.concatBytes)(...n)),randomBytes:Ki.randomBytes}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const t=Mi,n=En,r=Bi,i=hi,o=dr,s=ur,a=$i,c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(1),u=BigInt(2),h=(e,t)=>(e+t/u)/t;function f(e){const t=c,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),l=BigInt(44),d=BigInt(88),h=e*e*e%t,f=h*h*e%t,g=(0,o.pow2)(f,n,t)*f%t,m=(0,o.pow2)(g,n,t)*f%t,y=(0,o.pow2)(m,u,t)*h%t,v=(0,o.pow2)(y,i,t)*y%t,b=(0,o.pow2)(v,s,t)*v%t,w=(0,o.pow2)(b,l,t)*b%t,E=(0,o.pow2)(w,d,t)*w%t,C=(0,o.pow2)(E,l,t)*b%t,_=(0,o.pow2)(C,n,t)*f%t,S=(0,o.pow2)(_,a,t)*v%t,k=(0,o.pow2)(S,r,t)*h%t,x=(0,o.pow2)(k,u,t);if(!p.eql(p.sqr(x),e))throw new Error("Cannot find square root");return x}const p=(0,o.Field)(c,void 0,void 0,{sqrt:f});e.secp256k1=(0,r.createCurve)({a:BigInt(0),b:BigInt(7),Fp:p,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=l,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-d*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),c=h(s*e,t),u=h(-r*e,t);let f=(0,o.mod)(e-c*n-u*i,t),p=(0,o.mod)(-c*r-u*s,t);const g=f>a,m=p>a;if(g&&(f=t-f),m&&(p=t-p),f>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:g,k1:f,k2neg:m,k2:p}}}},t.sha256);const g=BigInt(0),m={};function y(e,...n){let r=m[e];if(void 0===r){const n=(0,t.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));r=(0,s.concatBytes)(n,n),m[e]=r}return(0,t.sha256)((0,s.concatBytes)(r,...n))}const v=e=>e.toRawBytes(!0).slice(1),b=e=>(0,s.numberToBytesBE)(e,32),w=e=>(0,o.mod)(e,c),E=e=>(0,o.mod)(e,l),C=e.secp256k1.ProjectivePoint,_=(e,t,n)=>C.BASE.multiplyAndAddUnsafe(e,t,n);function S(t){let n=e.secp256k1.utils.normPrivateKeyToScalar(t),r=C.fromPrivateKey(n);return{scalar:r.hasEvenY()?n:E(-n),bytes:v(r)}}function k(e){(0,s.aInRange)("x",e,d,c);const t=w(e*e);let n=f(w(t*e+BigInt(7)));n%u!==g&&(n=w(-n));const r=new C(e,n,d);return r.assertValidity(),r}const x=s.bytesToNumberBE;function A(...e){return E(x(y("BIP0340/challenge",...e)))}function M(e,t,n){const r=(0,s.ensureBytes)("signature",e,64),i=(0,s.ensureBytes)("message",t),o=(0,s.ensureBytes)("publicKey",n,32);try{const e=k(x(o)),t=x(r.subarray(0,32));if(!(0,s.inRange)(t,d,c))return!1;const n=x(r.subarray(32,64));if(!(0,s.inRange)(n,d,l))return!1;const a=A(b(t),v(e),i),u=_(e,n,E(-a));return!(!u||!u.hasEvenY()||u.toAffine().x!==t)}catch(e){return!1}}e.schnorr={getPublicKey:function(e){return S(e).bytes},sign:function(e,t,r=(0,n.randomBytes)(32)){const i=(0,s.ensureBytes)("message",e),{bytes:o,scalar:a}=S(t),c=(0,s.ensureBytes)("auxRand",r,32),l=b(a^x(y("BIP0340/aux",c))),d=y("BIP0340/nonce",l,o,i),u=E(x(d));if(u===g)throw new Error("sign failed: k is zero");const{bytes:h,scalar:f}=S(u),p=A(h,o,i),m=new Uint8Array(64);if(m.set(h,0),m.set(b(E(f+p*a)),32),!M(m,i,o))throw new Error("sign: Invalid signature produced");return m},verify:M,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:k,pointToBytes:v,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,taggedHash:y,mod:o.mod}};const L=(0,i.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))),T=(0,a.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}),O=(0,i.createHasher)(e.secp256k1.ProjectivePoint,(e=>{const{x:t,y:n}=T(p.create(e[0]));return L(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256});e.hashToCurve=O.hashToCurve,e.encodeToCurve=O.encodeToCurve}(Ai);var Hi={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodeHex=e.remove0x=void 0;var t=zt;e.remove0x=function(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e},e.decodeHex=function(n){return(0,t.hexToBytes)((0,e.remove0x)(n))}}(Hi),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hexToPublicKey=e.convertPublicKeyFormat=e.getSharedPoint=e.getPublicKey=e.isValidPrivateKey=e.getValidSecret=void 0;var t=an,n=ln,r=Ai,i=en,o=tn,s=Hi;function a(e,t,i,o){if("secp256k1"===e)return t(r.secp256k1);if("x25519"===e)return i(n.x25519);if("ed25519"===e)return o(n.ed25519);throw new Error("Not implemented")}e.getValidSecret=function(){var n;do{n=(0,t.randomBytes)(o.SECRET_KEY_LENGTH)}while(!(0,e.isValidPrivateKey)(n));return n},e.isValidPrivateKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.utils.isValidPrivateKey(e)}),(function(){return!0}),(function(){return!0}))},e.getPublicKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}))},e.getSharedPoint=function(e,t,n){return a((0,i.ellipticCurve)(),(function(r){return r.getSharedSecret(e,t,n)}),(function(n){return n.getSharedSecret(e,t)}),(function(n){return l(n,e,t)}))},e.convertPublicKeyFormat=function(e,t){return a((0,i.ellipticCurve)(),(function(n){return n.getSharedSecret(BigInt(1),e,t)}),(function(){return e}),(function(){return e}))},e.hexToPublicKey=function(e){var t=(0,s.decodeHex)(e);return a((0,i.ellipticCurve)(),(function(){return c(t)}),(function(){return t}),(function(){return t}))};var c=function(e){if(e.length===o.ETH_PUBLIC_KEY_SIZE){var t=new Uint8Array(1+e.length);return t.set([4]),t.set(e,1),t}return e},l=function(e,t,n){var r=e.utils.getExtendedPublicKey(t).scalar;return e.ExtendedPoint.fromHex(n).multiply(r).toRawBytes()}}(sn);var zi={},qi={};Object.defineProperty(qi,"__esModule",{value:!0}),qi.hkdf=void 0,qi.extract=Yi,qi.expand=Xi;const Vi=hn,Wi=En,Gi=Di;function Yi(e,t,n){return(0,Vi.hash)(e),void 0===n&&(n=new Uint8Array(e.outputLen)),(0,Gi.hmac)(e,(0,Wi.toBytes)(n),(0,Wi.toBytes)(t))}const Zi=new Uint8Array([0]),Ji=new Uint8Array;function Xi(e,t,n,r=32){if((0,Vi.hash)(e),(0,Vi.number)(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=Ji);const o=new Uint8Array(i*e.outputLen),s=Gi.hmac.create(e,t),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let t=0;t<i;t++)Zi[0]=t+1,a.update(0===t?Ji:c).update(n).update(Zi).digestInto(c),o.set(c,e.outputLen*t),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),Zi.fill(0),o.slice(0,r)}qi.hkdf=(e,t,n,r,i)=>Xi(e,Yi(e,t,n),r,i),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSharedKey=e.deriveKey=void 0;var t=zt,n=qi,r=Mi;e.deriveKey=function(e,t,i){return(0,n.hkdf)(r.sha256,e,t,i,32)},e.getSharedKey=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return(0,e.deriveKey)(t.concatBytes.apply(void 0,n))}}(zi);var Qi={},eo={},to={},no={};Object.defineProperty(no,"__esModule",{value:!0}),no.polyval=no.ghash=void 0,no._toGHASHKey=lo;const ro=qt,io=zt,oo=16,so=new Uint8Array(16),ao=(0,io.u32)(so),co=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function lo(e){e.reverse();const t=1&e[15];let n=0;for(let t=0;t<e.length;t++){const r=e[t];e[t]=r>>>1|n,n=(1&r)<<7}return e[0]^=225&-t,e}class uo{constructor(e,t){this.blockLen=oo,this.outputLen=oo,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,io.toBytes)(e),(0,ro.bytes)(e,16);const n=(0,io.createView)(e);let r=n.getUint32(0,!1),i=n.getUint32(4,!1),o=n.getUint32(8,!1),s=n.getUint32(12,!1);const a=[];for(let e=0;e<128;e++)a.push({s0:co(r),s1:co(i),s2:co(o),s3:co(s)}),({s0:r,s1:i,s2:o,s3:s}={s3:(d=o)<<31|(u=s)>>>1,s2:(l=i)<<31|d>>>1,s1:(c=r)<<31|l>>>1,s0:c>>>1^225<<24&-(1&u)});var c,l,d,u;const h=(e=>e>65536?8:e>1024?4:2)(t||1024);if(![1,2,4,8].includes(h))throw new Error(`ghash: wrong window size=${h}, should be 2, 4 or 8`);this.W=h;const f=128/h,p=this.windowSize=2**h,g=[];for(let e=0;e<f;e++)for(let t=0;t<p;t++){let n=0,r=0,i=0,o=0;for(let s=0;s<h;s++){if(!(t>>>h-s-1&1))continue;const{s0:c,s1:l,s2:d,s3:u}=a[h*e+s];n^=c,r^=l,i^=d,o^=u}g.push({s0:n,s1:r,s2:i,s3:o})}this.t=g}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;const{W:i,t:o,windowSize:s}=this;let a=0,c=0,l=0,d=0;const u=(1<<i)-1;let h=0;for(const f of[e,t,n,r])for(let e=0;e<4;e++){const t=f>>>8*e&255;for(let e=8/i-1;e>=0;e--){const n=t>>>i*e&u,{s0:r,s1:f,s2:p,s3:g}=o[h*s+n];a^=r,c^=f,l^=p,d^=g,h+=1}}this.s0=a,this.s1=c,this.s2=l,this.s3=d}update(e){e=(0,io.toBytes)(e),(0,ro.exists)(this);const t=(0,io.u32)(e),n=Math.floor(e.length/oo),r=e.length%oo;for(let e=0;e<n;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return r&&(so.set(e.subarray(n*oo)),this._updateBlock(ao[0],ao[1],ao[2],ao[3]),(0,io.clean)(ao)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){(0,ro.exists)(this),(0,ro.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,io.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e}digest(){const e=new Uint8Array(oo);return this.digestInto(e),this.destroy(),e}}class ho extends uo{constructor(e,t){e=(0,io.toBytes)(e);const n=lo((0,io.copyBytes)(e));super(n,t),(0,io.clean)(n)}update(e){e=(0,io.toBytes)(e),(0,ro.exists)(this);const t=(0,io.u32)(e),n=e.length%oo,r=Math.floor(e.length/oo);for(let e=0;e<r;e++)this._updateBlock(co(t[4*e+3]),co(t[4*e+2]),co(t[4*e+1]),co(t[4*e+0]));return n&&(so.set(e.subarray(r*oo)),this._updateBlock(co(ao[3]),co(ao[2]),co(ao[1]),co(ao[0])),(0,io.clean)(ao)),this}digestInto(e){(0,ro.exists)(this),(0,ro.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,io.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e.reverse()}}function fo(e){const t=(t,n)=>e(n,t.length).update((0,io.toBytes)(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}no.ghash=fo(((e,t)=>new uo(e,t))),no.polyval=fo(((e,t)=>new ho(e,t))),Object.defineProperty(to,"__esModule",{value:!0}),to.unsafe=to.aeskwp=to.aeskw=to.siv=to.gcm=to.cfb=to.cbc=to.ecb=to.ctr=void 0,to.expandKeyLE=Oo,to.expandKeyDecLE=Ro;const po=qt,go=no,mo=zt,yo=16,vo=new Uint8Array(yo),bo=283;function wo(e){return e<<1^bo&-(e>>7)}function Eo(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=wo(e);return n}const Co=(()=>{const e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=wo(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,mo.clean)(e),t})(),_o=Co.map(((e,t)=>Co.indexOf(t))),So=e=>e<<24|e>>>8,ko=e=>e<<8|e>>>24,xo=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Ao(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>t(e[r]))),r=n.map(ko),i=r.map(ko),o=i.map(ko),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){const d=256*t+l;s[d]=n[t]^r[l],a[d]=i[t]^o[l],c[d]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:o,T01:s,T23:a}}const Mo=Ao(Co,(e=>Eo(e,3)<<24|e<<16|e<<8|Eo(e,2))),Lo=Ao(_o,(e=>Eo(e,11)<<24|Eo(e,13)<<16|Eo(e,9)<<8|Eo(e,14))),To=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=wo(n))e[t]=n;return e})();function Oo(e){(0,po.bytes)(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=Mo,r=[];(0,mo.isAligned32)(e)||r.push(e=(0,mo.copyBytes)(e));const i=(0,mo.u32)(e),o=i.length,s=e=>Io(n,e,e,e,e),a=new Uint32Array(t+28);a.set(i);for(let e=o;e<a.length;e++){let t=a[e-1];e%o==0?t=s(So(t))^To[e/o-1]:o>6&&e%o==4&&(t=s(t)),a[e]=a[e-o]^t}return(0,mo.clean)(...r),a}function Ro(e){const t=Oo(e),n=t.slice(),r=t.length,{sbox2:i}=Mo,{T0:o,T1:s,T2:a,T3:c}=Lo;for(let e=0;e<r;e+=4)for(let i=0;i<4;i++)n[e+i]=t[r-e-4+i];(0,mo.clean)(t);for(let e=4;e<r-4;e++){const t=n[e],r=Io(i,t,t,t,t);n[e]=o[255&r]^s[r>>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}function Po(e,t,n,r,i,o){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|o>>>24&255]}function Io(e,t,n,r,i){return e[255&t|65280&n]|e[r>>>16&255|i>>>16&65280]<<16}function No(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Mo;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^Po(s,a,t,n,r,i),l=e[c++]^Po(s,a,n,r,i,t),d=e[c++]^Po(s,a,r,i,t,n),u=e[c++]^Po(s,a,i,t,n,r);t=o,n=l,r=d,i=u}return{s0:e[c++]^Io(o,t,n,r,i),s1:e[c++]^Io(o,n,r,i,t),s2:e[c++]^Io(o,r,i,t,n),s3:e[c++]^Io(o,i,t,n,r)}}function Bo(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Lo;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^Po(s,a,t,i,r,n),l=e[c++]^Po(s,a,n,t,i,r),d=e[c++]^Po(s,a,r,n,t,i),u=e[c++]^Po(s,a,i,r,n,t);t=o,n=l,r=d,i=u}return{s0:e[c++]^Io(o,t,i,r,n),s1:e[c++]^Io(o,n,t,i,r),s2:e[c++]^Io(o,r,n,t,i),s3:e[c++]^Io(o,i,r,n,t)}}function Do(e,t){if(void 0===t)return new Uint8Array(e);if((0,po.bytes)(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);if(!(0,mo.isAligned32)(t))throw new Error("unaligned dst");return t}function $o(e,t,n,r){(0,po.bytes)(t,yo),(0,po.bytes)(n);const i=n.length;r=Do(i,r);const o=t,s=(0,mo.u32)(o);let{s0:a,s1:c,s2:l,s3:d}=No(e,s[0],s[1],s[2],s[3]);const u=(0,mo.u32)(n),h=(0,mo.u32)(r);for(let t=0;t+4<=u.length;t+=4){h[t+0]=u[t+0]^a,h[t+1]=u[t+1]^c,h[t+2]=u[t+2]^l,h[t+3]=u[t+3]^d;let n=1;for(let e=o.length-1;e>=0;e--)n=n+(255&o[e])|0,o[e]=255&n,n>>>=8;({s0:a,s1:c,s2:l,s3:d}=No(e,s[0],s[1],s[2],s[3]))}const f=yo*Math.floor(u.length/4);if(f<i){const e=new Uint32Array([a,c,l,d]),t=(0,mo.u8)(e);for(let e=f,o=0;e<i;e++,o++)r[e]=n[e]^t[o];(0,mo.clean)(e)}return r}function jo(e,t,n,r,i){(0,po.bytes)(n,yo),(0,po.bytes)(r),i=Do(r.length,i);const o=n,s=(0,mo.u32)(o),a=(0,mo.createView)(o),c=(0,mo.u32)(r),l=(0,mo.u32)(i),d=t?0:12,u=r.length;let h=a.getUint32(d,t),{s0:f,s1:p,s2:g,s3:m}=No(e,s[0],s[1],s[2],s[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^f,l[n+1]=c[n+1]^p,l[n+2]=c[n+2]^g,l[n+3]=c[n+3]^m,h=h+1>>>0,a.setUint32(d,h,t),({s0:f,s1:p,s2:g,s3:m}=No(e,s[0],s[1],s[2],s[3]));const y=yo*Math.floor(c.length/4);if(y<u){const e=new Uint32Array([f,p,g,m]),t=(0,mo.u8)(e);for(let e=y,n=0;e<u;e++,n++)i[e]=r[e]^t[n];(0,mo.clean)(e)}return i}function Ko(e){if((0,po.bytes)(e),e.length%yo!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}function Uo(e,t,n){(0,po.bytes)(e);let r=e.length;const i=r%yo;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,mo.isAligned32)(e)||(e=(0,mo.copyBytes)(e));const o=(0,mo.u32)(e);if(t){let e=yo-i;e||(e=yo),r+=e}const s=Do(r,n);return{b:o,o:(0,mo.u32)(s),out:s}}function Fo(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const i=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return i}function Ho(e){const t=new Uint8Array(16),n=(0,mo.u32)(t);t.set(e);const r=yo-e.length;for(let e=yo-r;e<yo;e++)t[e]=r;return n}function zo(e,t,n,r,i){const o=null==i?0:i.length,s=e.create(n,r.length+o);i&&s.update(i),s.update(r);const a=new Uint8Array(16),c=(0,mo.createView)(a);i&&(0,mo.setBigUint64)(c,0,BigInt(8*o),t),(0,mo.setBigUint64)(c,8,BigInt(8*r.length),t),s.update(a);const l=s.digest();return(0,mo.clean)(a),l}to.ctr=(0,mo.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r){if((0,po.bytes)(n),void 0!==r&&((0,po.bytes)(r),!(0,mo.isAligned32)(r)))throw new Error("unaligned destination");const i=Oo(e),o=(0,mo.copyBytes)(t),s=[i,o];(0,mo.isAligned32)(n)||s.push(n=(0,mo.copyBytes)(n));const a=$o(i,o,n,r);return(0,mo.clean)(...s),a}return(0,po.bytes)(e),(0,po.bytes)(t,yo),{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}})),to.ecb=(0,mo.wrapCipher)({blockSize:16},(function(e,t={}){(0,po.bytes)(e);const n=!t.disablePadding;return{encrypt(t,r){const{b:i,o:o,out:s}=Uo(t,n,r),a=Oo(e);let c=0;for(;c+4<=i.length;){const{s0:e,s1:t,s2:n,s3:r}=No(a,i[c+0],i[c+1],i[c+2],i[c+3]);o[c++]=e,o[c++]=t,o[c++]=n,o[c++]=r}if(n){const e=Ho(t.subarray(4*c)),{s0:n,s1:r,s2:i,s3:s}=No(a,e[0],e[1],e[2],e[3]);o[c++]=n,o[c++]=r,o[c++]=i,o[c++]=s}return(0,mo.clean)(a),s},decrypt(t,r){Ko(t);const i=Ro(e),o=Do(t.length,r),s=[i];(0,mo.isAligned32)(t)||s.push(t=(0,mo.copyBytes)(t));const a=(0,mo.u32)(t),c=(0,mo.u32)(o);for(let e=0;e+4<=a.length;){const{s0:t,s1:n,s2:r,s3:o}=Bo(i,a[e+0],a[e+1],a[e+2],a[e+3]);c[e++]=t,c[e++]=n,c[e++]=r,c[e++]=o}return(0,mo.clean)(...s),Fo(o,n)}}})),to.cbc=(0,mo.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t,n={}){(0,po.bytes)(e),(0,po.bytes)(t,16);const r=!n.disablePadding;return{encrypt(n,i){const o=Oo(e),{b:s,o:a,out:c}=Uo(n,r,i);let l=t;const d=[o];(0,mo.isAligned32)(l)||d.push(l=(0,mo.copyBytes)(l));const u=(0,mo.u32)(l);let h=u[0],f=u[1],p=u[2],g=u[3],m=0;for(;m+4<=s.length;)h^=s[m+0],f^=s[m+1],p^=s[m+2],g^=s[m+3],({s0:h,s1:f,s2:p,s3:g}=No(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g;if(r){const e=Ho(n.subarray(4*m));h^=e[0],f^=e[1],p^=e[2],g^=e[3],({s0:h,s1:f,s2:p,s3:g}=No(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g}return(0,mo.clean)(...d),c},decrypt(n,i){Ko(n);const o=Ro(e);let s=t;const a=[o];(0,mo.isAligned32)(s)||a.push(s=(0,mo.copyBytes)(s));const c=(0,mo.u32)(s),l=Do(n.length,i);(0,mo.isAligned32)(n)||a.push(n=(0,mo.copyBytes)(n));const d=(0,mo.u32)(n),u=(0,mo.u32)(l);let h=c[0],f=c[1],p=c[2],g=c[3];for(let e=0;e+4<=d.length;){const t=h,n=f,r=p,i=g;h=d[e+0],f=d[e+1],p=d[e+2],g=d[e+3];const{s0:s,s1:a,s2:c,s3:l}=Bo(o,h,f,p,g);u[e++]=s^t,u[e++]=a^n,u[e++]=c^r,u[e++]=l^i}return(0,mo.clean)(...a),Fo(l,r)}}})),to.cfb=(0,mo.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r,i){(0,po.bytes)(n);const o=n.length;i=Do(o,i);const s=Oo(e);let a=t;const c=[s];(0,mo.isAligned32)(a)||c.push(a=(0,mo.copyBytes)(a)),(0,mo.isAligned32)(n)||c.push(n=(0,mo.copyBytes)(n));const l=(0,mo.u32)(n),d=(0,mo.u32)(i),u=r?d:l,h=(0,mo.u32)(a);let f=h[0],p=h[1],g=h[2],m=h[3];for(let e=0;e+4<=l.length;){const{s0:t,s1:n,s2:r,s3:i}=No(s,f,p,g,m);d[e+0]=l[e+0]^t,d[e+1]=l[e+1]^n,d[e+2]=l[e+2]^r,d[e+3]=l[e+3]^i,f=u[e++],p=u[e++],g=u[e++],m=u[e++]}const y=yo*Math.floor(l.length/4);if(y<o){({s0:f,s1:p,s2:g,s3:m}=No(s,f,p,g,m));const e=(0,mo.u8)(new Uint32Array([f,p,g,m]));for(let t=y,r=0;t<o;t++,r++)i[t]=n[t]^e[r];(0,mo.clean)(e)}return(0,mo.clean)(...c),i}return(0,po.bytes)(e),(0,po.bytes)(t,16),{encrypt:(e,t)=>n(e,!0,t),decrypt:(e,t)=>n(e,!1,t)}})),to.gcm=(0,mo.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){if((0,po.bytes)(e),(0,po.bytes)(t),void 0!==n&&(0,po.bytes)(n),t.length<8)throw new Error("aes/gcm: invalid nonce length");function r(e,t,r){const i=zo(go.ghash,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){const n=Oo(e),r=vo.slice(),i=vo.slice();if(jo(n,!1,i,i,r),12===t.length)i.set(t);else{const e=vo.slice(),n=(0,mo.createView)(e);(0,mo.setBigUint64)(n,8,BigInt(8*t.length),!1);const o=go.ghash.create(r).update(t).update(e);o.digestInto(i),o.destroy()}return{xk:n,authKey:r,counter:i,tagMask:jo(n,!1,i,vo)}}return{encrypt(e){(0,po.bytes)(e);const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=new Uint8Array(e.length+16),c=[t,n,o,s];(0,mo.isAligned32)(e)||c.push(e=(0,mo.copyBytes)(e)),jo(t,!1,o,e,a);const l=r(n,s,a.subarray(0,a.length-16));return c.push(l),a.set(l,e.length),(0,mo.clean)(...c),a},decrypt(e){if((0,po.bytes)(e),e.length<16)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=[t,n,s,o];(0,mo.isAligned32)(e)||a.push(e=(0,mo.copyBytes)(e));const c=e.subarray(0,-16),l=e.subarray(-16),d=r(n,s,c);if(a.push(d),!(0,mo.equalBytes)(d,l))throw new Error("aes/gcm: invalid ghash tag");const u=jo(t,!1,o,c);return(0,mo.clean)(...a),u}}}));const qo=(e,t,n)=>r=>{if(!Number.isSafeInteger(r)||t>r||r>n)throw new Error(`${e}: invalid value=${r}, must be [${t}..${n}]`)};function Vo(e){return null!=e&&"object"==typeof e&&(e instanceof Uint32Array||"Uint32Array"===e.constructor.name)}function Wo(e,t){if((0,po.bytes)(t,16),!Vo(e))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,mo.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=No(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}function Go(e,t){if((0,po.bytes)(t,16),!Vo(e))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,mo.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=Bo(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}to.siv=(0,mo.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){const r=qo("AAD",0,2**36),i=qo("plaintext",0,2**36),o=qo("nonce",12,12),s=qo("ciphertext",16,2**36+16);function a(){const n=Oo(e),r=new Uint8Array(e.length),i=new Uint8Array(16),o=[n,r];let s=t;(0,mo.isAligned32)(s)||o.push(s=(0,mo.copyBytes)(s));const a=(0,mo.u32)(s);let c=0,l=a[0],d=a[1],u=a[2],h=0;for(const e of[i,r].map(mo.u32)){const t=(0,mo.u32)(e);for(let e=0;e<t.length;e+=2){const{s0:r,s1:i}=No(n,c,l,d,u);t[e+0]=r,t[e+1]=i,c=++h}}const f={authKey:i,encKey:Oo(r)};return(0,mo.clean)(...o),f}function c(e,r,i){const o=zo(go.polyval,!0,r,i,n);for(let e=0;e<12;e++)o[e]^=t[e];o[15]&=127;const s=(0,mo.u32)(o);let a=s[0],c=s[1],l=s[2],d=s[3];return({s0:a,s1:c,s2:l,s3:d}=No(e,a,c,l,d)),s[0]=a,s[1]=c,s[2]=l,s[3]=d,o}function l(e,t,n){let r=(0,mo.copyBytes)(t);r[15]|=128;const i=jo(e,!0,r,n);return(0,mo.clean)(r),i}return(0,po.bytes)(e,16,24,32),(0,po.bytes)(t),o(t.length),void 0!==n&&((0,po.bytes)(n),r(n.length)),{encrypt(e){(0,po.bytes)(e),i(e.length);const{encKey:t,authKey:n}=a(),r=c(t,n,e),o=[t,n,r];(0,mo.isAligned32)(e)||o.push(e=(0,mo.copyBytes)(e));const s=new Uint8Array(e.length+16);return s.set(r,e.length),s.set(l(t,r,e)),(0,mo.clean)(...o),s},decrypt(e){(0,po.bytes)(e),s(e.length);const t=e.subarray(-16),{encKey:n,authKey:r}=a(),i=[n,r];(0,mo.isAligned32)(e)||i.push(e=(0,mo.copyBytes)(e));const o=l(n,t,e.subarray(0,-16)),d=c(n,r,o);if(i.push(d),!(0,mo.equalBytes)(t,d))throw(0,mo.clean)(...i),new Error("invalid polyval tag");return(0,mo.clean)(...i),o}}}));const Yo={encrypt(e,t){if(t.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=Oo(e);if(16===t.length)Wo(n,t);else{const e=(0,mo.u32)(t);let r=e[0],i=e[1];for(let t=0,o=1;t<6;t++)for(let t=2;t<e.length;t+=2,o++){const{s0:s,s1:a,s2:c,s3:l}=No(n,r,i,e[t],e[t+1]);r=s,i=a^xo(o),e[t]=c,e[t+1]=l}e[0]=r,e[1]=i}n.fill(0)},decrypt(e,t){if(t.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=Ro(e),r=t.length/8-1;if(1===r)Go(n,t);else{const e=(0,mo.u32)(t);let i=e[0],o=e[1];for(let t=0,s=6*r;t<6;t++)for(let t=2*r;t>=1;t-=2,s--){o^=xo(s);const{s0:r,s1:a,s2:c,s3:l}=Bo(n,i,o,e[t],e[t+1]);i=r,o=a,e[t]=c,e[t+1]=l}e[0]=i,e[1]=o}n.fill(0)}},Zo=new Uint8Array(8).fill(166);to.aeskw=(0,mo.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,po.bytes)(t),!t.length||t.length%8!=0)throw new Error("invalid plaintext length");if(8===t.length)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,mo.concatBytes)(Zo,t);return Yo.encrypt(e,n),n},decrypt(t){if((0,po.bytes)(t),t.length%8!=0||t.length<24)throw new Error("invalid ciphertext length");const n=(0,mo.copyBytes)(t);if(Yo.decrypt(e,n),!(0,mo.equalBytes)(n.subarray(0,8),Zo))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}})));const Jo=2790873510;to.aeskwp=(0,mo.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,po.bytes)(t),!t.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(t.length/8),r=new Uint8Array(8+n);r.set(t,8);const i=(0,mo.u32)(r);return i[0]=Jo,i[1]=xo(t.length),Yo.encrypt(e,r),r},decrypt(t){if((0,po.bytes)(t),t.length<16)throw new Error("invalid ciphertext length");const n=(0,mo.copyBytes)(t),r=(0,mo.u32)(n);Yo.decrypt(e,n);const i=xo(r[1])>>>0,o=8*Math.ceil(i/8);if(r[0]!==Jo||n.length-8!==o)throw new Error("integrity check failed");for(let e=i;e<o;e++)if(0!==n[8+e])throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+i)}}))),to.unsafe={expandKeyLE:Oo,expandKeyDecLE:Ro,encrypt:No,decrypt:Bo,encryptBlock:Wo,decryptBlock:Go,ctrCounter:$o,ctr32:jo},Object.defineProperty(eo,"__esModule",{value:!0}),eo.aes256cbc=eo.aes256gcm=void 0;var Xo=to;eo.aes256gcm=function(e,t,n){return(0,Xo.gcm)(e,t,n)},eo.aes256cbc=function(e,t,n){return(0,Xo.cbc)(e,t)};var Qo={},es={},ts={};Object.defineProperty(ts,"__esModule",{value:!0}),ts.sigma=void 0,ts.rotl=function(e,t){return e<<t|e>>>32-t},ts.createCipher=function(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:o,rounds:s}=(0,rs.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return(0,ns.number)(i),(0,ns.number)(s),(0,ns.bool)(o),(0,ns.bool)(n),(t,a,c,l,d=0)=>{(0,ns.bytes)(t),(0,ns.bytes)(a),(0,ns.bytes)(c);const u=c.length;if(void 0===l&&(l=new Uint8Array(u)),(0,ns.bytes)(l),(0,ns.number)(d),d<0||d>=hs)throw new Error("arx: counter overflow");if(l.length<u)throw new Error(`arx: output (${l.length}) is shorter than data (${u})`);const h=[];let f,p,g=t.length;if(32===g)h.push(f=(0,rs.copyBytes)(t)),p=cs;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=as,h.push(f)}ls(a)||h.push(a=(0,rs.copyBytes)(a));const m=(0,rs.u32)(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,(0,rs.u32)(a.subarray(0,16)),m),a=a.subarray(16)}const y=16-i;if(y!==a.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(12!==y){const e=new Uint8Array(12);e.set(a,o?0:12-a.length),a=e,h.push(a)}const v=(0,rs.u32)(a);return function(e,t,n,r,i,o,s,a){const c=i.length,l=new Uint8Array(ds),d=(0,rs.u32)(l),u=ls(i)&&ls(o),h=u?(0,rs.u32)(i):fs,f=u?(0,rs.u32)(o):fs;for(let p=0;p<c;s++){if(e(t,n,r,d,s,a),s>=hs)throw new Error("arx: counter overflow");const g=Math.min(ds,c-p);if(u&&g===ds){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<us;n++)t=e+n,f[t]=h[t]^d[n];p+=ds}else{for(let e,t=0;t<g;t++)e=p+t,o[e]=i[e]^l[t];p+=g}}}(e,p,m,v,c,l,d,s),(0,rs.clean)(...h),l}};const ns=qt,rs=zt,is=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),os=is("expand 16-byte k"),ss=is("expand 32-byte k"),as=(0,rs.u32)(os),cs=(0,rs.u32)(ss);function ls(e){return e.byteOffset%4==0}ts.sigma=cs.slice();const ds=64,us=16,hs=2**32-1,fs=new Uint32Array;var ps={};Object.defineProperty(ps,"__esModule",{value:!0}),ps.poly1305=void 0,ps.wrapConstructorWithKey=bs;const gs=qt,ms=zt,ys=(e,t)=>255&e[t++]|(255&e[t++])<<8;class vs{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,e=(0,ms.toBytes)(e),(0,gs.bytes)(e,32);const t=ys(e,0),n=ys(e,2),r=ys(e,4),i=ys(e,6),o=ys(e,8),s=ys(e,10),a=ys(e,12),c=ys(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|i<<9),this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,this.r[6]=8191&(o>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=ys(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:i,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],d=o[4],u=o[5],h=o[6],f=o[7],p=o[8],g=o[9],m=ys(e,t+0),y=ys(e,t+2),v=ys(e,t+4),b=ys(e,t+6),w=ys(e,t+8),E=ys(e,t+10),C=ys(e,t+12),_=ys(e,t+14);let S=i[0]+(8191&m),k=i[1]+(8191&(m>>>13|y<<3)),x=i[2]+(8191&(y>>>10|v<<6)),A=i[3]+(8191&(v>>>7|b<<9)),M=i[4]+(8191&(b>>>4|w<<12)),L=i[5]+(w>>>1&8191),T=i[6]+(8191&(w>>>14|E<<2)),O=i[7]+(8191&(E>>>11|C<<5)),R=i[8]+(8191&(C>>>8|_<<8)),P=i[9]+(_>>>5|r),I=0,N=I+S*s+k*(5*g)+x*(5*p)+A*(5*f)+M*(5*h);I=N>>>13,N&=8191,N+=L*(5*u)+T*(5*d)+O*(5*l)+R*(5*c)+P*(5*a),I+=N>>>13,N&=8191;let B=I+S*a+k*s+x*(5*g)+A*(5*p)+M*(5*f);I=B>>>13,B&=8191,B+=L*(5*h)+T*(5*u)+O*(5*d)+R*(5*l)+P*(5*c),I+=B>>>13,B&=8191;let D=I+S*c+k*a+x*s+A*(5*g)+M*(5*p);I=D>>>13,D&=8191,D+=L*(5*f)+T*(5*h)+O*(5*u)+R*(5*d)+P*(5*l),I+=D>>>13,D&=8191;let $=I+S*l+k*c+x*a+A*s+M*(5*g);I=$>>>13,$&=8191,$+=L*(5*p)+T*(5*f)+O*(5*h)+R*(5*u)+P*(5*d),I+=$>>>13,$&=8191;let j=I+S*d+k*l+x*c+A*a+M*s;I=j>>>13,j&=8191,j+=L*(5*g)+T*(5*p)+O*(5*f)+R*(5*h)+P*(5*u),I+=j>>>13,j&=8191;let K=I+S*u+k*d+x*l+A*c+M*a;I=K>>>13,K&=8191,K+=L*s+T*(5*g)+O*(5*p)+R*(5*f)+P*(5*h),I+=K>>>13,K&=8191;let U=I+S*h+k*u+x*d+A*l+M*c;I=U>>>13,U&=8191,U+=L*a+T*s+O*(5*g)+R*(5*p)+P*(5*f),I+=U>>>13,U&=8191;let F=I+S*f+k*h+x*u+A*d+M*l;I=F>>>13,F&=8191,F+=L*c+T*a+O*s+R*(5*g)+P*(5*p),I+=F>>>13,F&=8191;let H=I+S*p+k*f+x*h+A*u+M*d;I=H>>>13,H&=8191,H+=L*l+T*c+O*a+R*s+P*(5*g),I+=H>>>13,H&=8191;let z=I+S*g+k*p+x*f+A*h+M*u;I=z>>>13,z&=8191,z+=L*d+T*l+O*c+R*a+P*s,I+=z>>>13,z&=8191,I=(I<<2)+I|0,I=I+N|0,N=8191&I,I>>>=13,B+=I,i[0]=N,i[1]=B,i[2]=D,i[3]=$,i[4]=j,i[5]=K,i[6]=U,i[7]=F,i[8]=H,i[9]=z}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=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 t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(1^r)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];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 o=e[0]+t[0];e[0]=65535&o;for(let n=1;n<8;n++)o=(e[n]+t[n]|0)+(o>>>16)|0,e[n]=65535&o;(0,ms.clean)(n)}update(e){(0,gs.exists)(this);const{buffer:t,blockLen:n}=this,r=(e=(0,ms.toBytes)(e)).length;for(let i=0;i<r;){const o=Math.min(n-this.pos,r-i);if(o!==n)t.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-i;i+=n)this.process(e,i)}return this}destroy(){(0,ms.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,gs.exists)(this),(0,gs.output)(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 i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function bs(e){const t=(t,n)=>e(n).update((0,ms.toBytes)(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}ps.poly1305=bs((e=>new vs(e))),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xchacha20poly1305=e.chacha20poly1305=e._poly1305_aead=e.chacha12=e.chacha8=e.xchacha20=e.chacha20=e.chacha20orig=void 0,e.hchacha=s;const t=ts,n=qt,r=ps,i=zt;function o(e,n,r,i,o,s=20){let a=e[0],c=e[1],l=e[2],d=e[3],u=n[0],h=n[1],f=n[2],p=n[3],g=n[4],m=n[5],y=n[6],v=n[7],b=o,w=r[0],E=r[1],C=r[2],_=a,S=c,k=l,x=d,A=u,M=h,L=f,T=p,O=g,R=m,P=y,I=v,N=b,B=w,D=E,$=C;for(let e=0;e<s;e+=2)_=_+A|0,N=(0,t.rotl)(N^_,16),O=O+N|0,A=(0,t.rotl)(A^O,12),_=_+A|0,N=(0,t.rotl)(N^_,8),O=O+N|0,A=(0,t.rotl)(A^O,7),S=S+M|0,B=(0,t.rotl)(B^S,16),R=R+B|0,M=(0,t.rotl)(M^R,12),S=S+M|0,B=(0,t.rotl)(B^S,8),R=R+B|0,M=(0,t.rotl)(M^R,7),k=k+L|0,D=(0,t.rotl)(D^k,16),P=P+D|0,L=(0,t.rotl)(L^P,12),k=k+L|0,D=(0,t.rotl)(D^k,8),P=P+D|0,L=(0,t.rotl)(L^P,7),x=x+T|0,$=(0,t.rotl)($^x,16),I=I+$|0,T=(0,t.rotl)(T^I,12),x=x+T|0,$=(0,t.rotl)($^x,8),I=I+$|0,T=(0,t.rotl)(T^I,7),_=_+M|0,$=(0,t.rotl)($^_,16),P=P+$|0,M=(0,t.rotl)(M^P,12),_=_+M|0,$=(0,t.rotl)($^_,8),P=P+$|0,M=(0,t.rotl)(M^P,7),S=S+L|0,N=(0,t.rotl)(N^S,16),I=I+N|0,L=(0,t.rotl)(L^I,12),S=S+L|0,N=(0,t.rotl)(N^S,8),I=I+N|0,L=(0,t.rotl)(L^I,7),k=k+T|0,B=(0,t.rotl)(B^k,16),O=O+B|0,T=(0,t.rotl)(T^O,12),k=k+T|0,B=(0,t.rotl)(B^k,8),O=O+B|0,T=(0,t.rotl)(T^O,7),x=x+A|0,D=(0,t.rotl)(D^x,16),R=R+D|0,A=(0,t.rotl)(A^R,12),x=x+A|0,D=(0,t.rotl)(D^x,8),R=R+D|0,A=(0,t.rotl)(A^R,7);let j=0;i[j++]=a+_|0,i[j++]=c+S|0,i[j++]=l+k|0,i[j++]=d+x|0,i[j++]=u+A|0,i[j++]=h+M|0,i[j++]=f+L|0,i[j++]=p+T|0,i[j++]=g+O|0,i[j++]=m+R|0,i[j++]=y+P|0,i[j++]=v+I|0,i[j++]=b+N|0,i[j++]=w+B|0,i[j++]=E+D|0,i[j++]=C+$|0}function s(e,n,r,i){let o=e[0],s=e[1],a=e[2],c=e[3],l=n[0],d=n[1],u=n[2],h=n[3],f=n[4],p=n[5],g=n[6],m=n[7],y=r[0],v=r[1],b=r[2],w=r[3];for(let e=0;e<20;e+=2)o=o+l|0,y=(0,t.rotl)(y^o,16),f=f+y|0,l=(0,t.rotl)(l^f,12),o=o+l|0,y=(0,t.rotl)(y^o,8),f=f+y|0,l=(0,t.rotl)(l^f,7),s=s+d|0,v=(0,t.rotl)(v^s,16),p=p+v|0,d=(0,t.rotl)(d^p,12),s=s+d|0,v=(0,t.rotl)(v^s,8),p=p+v|0,d=(0,t.rotl)(d^p,7),a=a+u|0,b=(0,t.rotl)(b^a,16),g=g+b|0,u=(0,t.rotl)(u^g,12),a=a+u|0,b=(0,t.rotl)(b^a,8),g=g+b|0,u=(0,t.rotl)(u^g,7),c=c+h|0,w=(0,t.rotl)(w^c,16),m=m+w|0,h=(0,t.rotl)(h^m,12),c=c+h|0,w=(0,t.rotl)(w^c,8),m=m+w|0,h=(0,t.rotl)(h^m,7),o=o+d|0,w=(0,t.rotl)(w^o,16),g=g+w|0,d=(0,t.rotl)(d^g,12),o=o+d|0,w=(0,t.rotl)(w^o,8),g=g+w|0,d=(0,t.rotl)(d^g,7),s=s+u|0,y=(0,t.rotl)(y^s,16),m=m+y|0,u=(0,t.rotl)(u^m,12),s=s+u|0,y=(0,t.rotl)(y^s,8),m=m+y|0,u=(0,t.rotl)(u^m,7),a=a+h|0,v=(0,t.rotl)(v^a,16),f=f+v|0,h=(0,t.rotl)(h^f,12),a=a+h|0,v=(0,t.rotl)(v^a,8),f=f+v|0,h=(0,t.rotl)(h^f,7),c=c+l|0,b=(0,t.rotl)(b^c,16),p=p+b|0,l=(0,t.rotl)(l^p,12),c=c+l|0,b=(0,t.rotl)(b^c,8),p=p+b|0,l=(0,t.rotl)(l^p,7);let E=0;i[E++]=o,i[E++]=s,i[E++]=a,i[E++]=c,i[E++]=y,i[E++]=v,i[E++]=b,i[E++]=w}e.chacha20orig=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,allowShortKeys:!0}),e.chacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,allowShortKeys:!1}),e.xchacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,extendNonceFn:s,allowShortKeys:!1}),e.chacha8=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:8}),e.chacha12=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:12});const a=new Uint8Array(16),c=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(a.subarray(n))},l=new Uint8Array(32);function d(e,t,n,o,s){const a=e(t,n,l),d=r.poly1305.create(a);s&&c(d,s),c(d,o);const u=new Uint8Array(16),h=(0,i.createView)(u);(0,i.setBigUint64)(h,0,BigInt(s?s.length:0),!0),(0,i.setBigUint64)(h,8,BigInt(o.length),!0),d.update(u);const f=d.digest();return(0,i.clean)(a,u),f}e._poly1305_aead=e=>(t,r,o)=>((0,n.bytes)(t,32),(0,n.bytes)(r),{encrypt(s,a){const c=s.length,l=c+16;a?(0,n.bytes)(a,l):a=new Uint8Array(l),e(t,r,s,a,1);const u=d(e,t,r,a.subarray(0,-16),o);return a.set(u,c),(0,i.clean)(u),a},decrypt(s,a){const c=s.length,l=c-16;if(c<16)throw new Error("encrypted data must be at least 16 bytes");a?(0,n.bytes)(a,l):a=new Uint8Array(l);const u=s.subarray(0,-16),h=s.subarray(-16),f=d(e,t,r,u,o);if(!(0,i.equalBytes)(h,f))throw new Error("invalid tag");return e(t,r,u,a,1),(0,i.clean)(f),a}}),e.chacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,e._poly1305_aead)(e.chacha20)),e.xchacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,e._poly1305_aead)(e.xchacha20))}(es),Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.xchacha20=void 0;var ws,Es,Cs,_s=es;Qo.xchacha20=function(e,t,n){return(0,_s.xchacha20poly1305)(e,t,n)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.aesDecrypt=e.aesEncrypt=e.symDecrypt=e.symEncrypt=void 0;var t=zt,n=an,r=eo,i=Qo,o=en,s=tn;function a(e,t,n,a){var c=(0,o.symmetricAlgorithm)();if("aes-256-gcm"===c)return e(r.aes256gcm,t,n,(0,o.symmetricNonceLength)(),s.AEAD_TAG_LENGTH,a);if("xchacha20"===c)return e(i.xchacha20,t,n,s.XCHACHA20_NONCE_LENGTH,s.AEAD_TAG_LENGTH,a);if("aes-256-cbc"===c)return e(r.aes256cbc,t,n,16,0);throw new Error("Not implemented")}function c(e,r,i,o,s,a){var c=(0,n.randomBytes)(o),l=e(r,c,a).encrypt(i);if(0===s)return(0,t.concatBytes)(c,l);var d=l.length-s,u=l.subarray(0,d),h=l.subarray(d);return(0,t.concatBytes)(c,h,u)}function l(e,n,r,i,o,s){var a=r.subarray(0,i),c=e(n,Uint8Array.from(a),s),l=r.subarray(i);if(0===o)return c.decrypt(l);var d=l.subarray(0,o),u=l.subarray(o);return c.decrypt((0,t.concatBytes)(u,d))}e.symEncrypt=function(e,t,n){return a(c,e,t,n)},e.symDecrypt=function(e,t,n){return a(l,e,t,n)},e.aesEncrypt=e.symEncrypt,e.aesDecrypt=e.symDecrypt}(Qi),ws=on,Es=Kt&&Kt.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),Cs=Kt&&Kt.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||Es(t,e,n)},Object.defineProperty(ws,"__esModule",{value:!0}),Cs(sn,ws),Cs(zi,ws),Cs(Hi,ws),Cs(Qi,ws);var Ss={};Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.PublicKey=void 0;var ks=zt,xs=on,As=function(){function e(e){this.data=(0,xs.convertPublicKeyFormat)(e,!0)}return e.fromHex=function(t){return new e((0,xs.hexToPublicKey)(t))},Object.defineProperty(e.prototype,"uncompressed",{get:function(){return et.from((0,xs.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"compressed",{get:function(){return et.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(e){return void 0===e&&(e=!0),(0,ks.bytesToHex)(e?this.data:this.uncompressed)},e.prototype.decapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.data:this.uncompressed,r=e.multiply(this,t);return(0,xs.getSharedKey)(n,r)},e.prototype.equals=function(e){return(0,ks.equalBytes)(this.data,e.data)},e}();Ss.PublicKey=As,Object.defineProperty(rn,"__esModule",{value:!0}),rn.PrivateKey=void 0;var Ms=zt,Ls=on,Ts=Ss,Os=function(){function e(e){if(void 0===e)this.data=(0,Ls.getValidSecret)();else{if(!(0,Ls.isValidPrivateKey)(e))throw new Error("Invalid private key");this.data=e}this.publicKey=new Ts.PublicKey((0,Ls.getPublicKey)(this.data))}return e.fromHex=function(t){return new e((0,Ls.decodeHex)(t))},Object.defineProperty(e.prototype,"secret",{get:function(){return et.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(){return(0,Ms.bytesToHex)(this.data)},e.prototype.encapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.publicKey.compressed:this.publicKey.uncompressed,r=this.multiply(e,t);return(0,Ls.getSharedKey)(n,r)},e.prototype.multiply=function(e,t){return void 0===t&&(t=!1),(0,Ls.getSharedPoint)(this.data,e.compressed,t)},e.prototype.equals=function(e){return(0,Ms.equalBytes)(this.data,e.data)},e}();rn.PrivateKey=Os,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PublicKey=e.PrivateKey=void 0;var t=rn;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return t.PrivateKey}});var n=Ss;Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return n.PublicKey}})}(nn),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.PublicKey=e.PrivateKey=e.ECIES_CONFIG=void 0,e.encrypt=function(e,o){var s=new r.PrivateKey,a=e instanceof Uint8Array?new r.PublicKey(e):r.PublicKey.fromHex(e),c=s.encapsulate(a,(0,n.isHkdfKeyCompressed)()),l=(0,n.isEphemeralKeyCompressed)()?s.publicKey.compressed:s.publicKey.uncompressed,d=(0,i.symEncrypt)(c,o);return et.from((0,t.concatBytes)(l,d))},e.decrypt=function(e,t){var o=e instanceof Uint8Array?new r.PrivateKey(e):r.PrivateKey.fromHex(e),s=(0,n.ephemeralKeySize)(),a=new r.PublicKey(t.subarray(0,s)),c=t.subarray(s),l=a.decapsulate(o,(0,n.isHkdfKeyCompressed)());return et.from((0,i.symDecrypt)(l,c))};var t=zt,n=en,r=nn,i=on,o=en;Object.defineProperty(e,"ECIES_CONFIG",{enumerable:!0,get:function(){return o.ECIES_CONFIG}});var s=nn;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return s.PrivateKey}}),Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return s.PublicKey}}),e.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}}(Ht);const Rs=f("KeyExchange:Layer"),Ps=f("SocketService:Layer"),Is=f("Ecies:Layer"),Ns=f("RemoteCommunication:Layer");Rs.color="##95c44e",Ps.color="#f638d7",Is.color="#465b9c",Ns.color="#47a2be";const Bs={KeyExchange:Rs,SocketService:Ps,Ecies:Is,RemoteCommunication:Ns};let Ds,$s=[],js=[];const Ks=(e,t)=>$e(void 0,void 0,void 0,(function*(){Ds=t,js.push(e),function(e){return $e(this,void 0,void 0,(function*(){if(!Ds||!e)return;!function(){const e=js;js=$s,$s=e}();const t=Ds.endsWith("/")?`${Ds}evt`:`${Ds}/evt`,n=Object.assign({},e);if(delete n.params,e.params)for(const[t,r]of Object.entries(e.params))n[t]=r;const r=JSON.stringify(n);Bs.RemoteCommunication(`[sendBufferedEvents] Sending ${$s.length} analytics events to ${t}`);try{const e=yield c(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:r}),n=yield e.text();Bs.RemoteCommunication(`[sendBufferedEvents] Response: ${n}`),$s.length=0}catch(t){}}))}(e).catch((()=>{}))}));class Us{constructor(e){this.enabled=!0,(null==e?void 0:e.debug)&&f.enable("Ecies:Layer"),this.ecies=(null==e?void 0:e.privateKey)?Ht.PrivateKey.fromHex(e.privateKey):new Ht.PrivateKey,Bs.Ecies("[ECIES constructor()] initialized secret: ",this.ecies.toHex()),Bs.Ecies("[ECIES constructor()] initialized public: ",this.ecies.publicKey.toHex()),Bs.Ecies("[ECIES constructor()] init with",this)}generateECIES(){this.ecies=new Ht.PrivateKey}getPublicKey(){return this.ecies.publicKey.toHex()}encrypt(e,t){let n=e;if(this.enabled)try{Bs.Ecies("[ECIES: encrypt()] using otherPublicKey",t);const r=et.from(e),i=Ht.encrypt(t,r);n=et.from(i).toString("base64")}catch(n){throw Bs.Ecies("[ECIES: encrypt()] error encrypt:",n),Bs.Ecies("[ECIES: encrypt()] private: ",this.ecies.toHex()),Bs.Ecies("[ECIES: encrypt()] data: ",e),Bs.Ecies("[ECIES: encrypt()] otherkey: ",t),n}return n}decrypt(e){let t=e;if(this.enabled)try{Bs.Ecies("[ECIES: decrypt()] using privateKey",this.ecies.toHex());const n=et.from(e.toString(),"base64");t=Ht.decrypt(this.ecies.toHex(),n).toString()}catch(t){throw Bs.Ecies("[ECIES: decrypt()] error decrypt",t),Bs.Ecies("[ECIES: decrypt()] private: ",this.ecies.toHex()),Bs.Ecies("[ECIES: decrypt()] encryptedData: ",e),t}return t}getKeyInfo(){return{private:this.ecies.toHex(),public:this.ecies.publicKey.toHex()}}toString(){Bs.Ecies("[ECIES: toString()]",this.getKeyInfo())}}var Fs={name:"@metamask/sdk-communication-layer",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk.git",directory:"packages/sdk-communication-layer"},main:"dist/node/cjs/metamask-sdk-communication-layer.js",unpkg:"dist/browser/umd/metamask-sdk-communication-layer.js",module:"dist/node/es/metamask-sdk-communication-layer.js",browser:"dist/browser/es/metamask-sdk-communication-layer.js","react-native":"dist/react-native/es/metamask-sdk-communication-layer.js",types:"dist/types/src/index.d.ts",files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types","build:clean":"yarn clean && yarn build",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs",dev:'concurrently "tsc --watch" "rollup -c --bundleConfigAsCjs -w"',"build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",size:"size-limit",clean:"rimraf ./dist",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk-communication-layer","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore","publish:preview":"yarn npm publish --tag preview",prepack:"../../scripts/prepack.sh",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:coverage":"jest --coverage","test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":"jest",watch:"rollup -c --bundleConfigAsCjs -w"},dependencies:{bufferutil:"^4.0.8","date-fns":"^2.29.3",debug:"^4.3.4","utf-8-validate":"^5.0.2",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@rollup/plugin-commonjs":"^25.0.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.4","@size-limit/preset-big-lib":"^11.0.2","@types/jest":"^29.2.4","@types/node":"^20.1.3","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0",concurrently:"^9.1.2","cross-fetch":"^4.0.0",eciesjs:"^0.4.11",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0",eventemitter2:"^6.4.9",jest:"^29.3.1",prettier:"^2.3.0",rimraf:"^3.0.2",rollup:"^4.26.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-node-globals":"^1.4.0","rollup-plugin-peer-deps-external":"^2.2.4","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.1.6","socket.io-client":"^4.5.1","stream-browserify":"^3.0.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^5.6.3"},peerDependencies:{"cross-fetch":"^4.0.0",eciesjs:"*",eventemitter2:"^6.4.9","readable-stream":"^3.6.2","socket.io-client":"^4.5.1"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"@lavamoat/preinstall-always-fail":!1,canvas:!0,"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,bufferutil:!1,"utf-8-validate":!1}}};const Hs="https://metamask-sdk.api.cx.metamask.io/",zs=["websocket"],qs=6048e5,Vs=3e3,Ws={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",ETH_REQUESTACCOUNTS:"eth_requestAccounts"};function Gs(e){const{context:t}=e;Bs.RemoteCommunication(`[RemoteCommunication: clean()] context=${t}`),e.channelConfig=void 0,e.ready=!1,e.originatorConnectStarted=!1}var Ys,Zs,Js,Xs,Qs,ea,ta;(ta=Ys||(Ys={})).DISCONNECTED="disconnected",ta.WAITING="waiting",ta.TIMEOUT="timeout",ta.LINKED="linked",ta.PAUSED="paused",ta.TERMINATED="terminated",function(e){e.KEY_INFO="key_info",e.SERVICE_STATUS="service_status",e.PROVIDER_UPDATE="provider_update",e.RPC_UPDATE="rpc_update",e.KEYS_EXCHANGED="keys_exchanged",e.JOIN_CHANNEL="join_channel",e.PUBLIC_KEY="public_key",e.CHANNEL_CREATED="channel_created",e.CLIENTS_CONNECTED="clients_connected",e.CLIENTS_DISCONNECTED="clients_disconnected",e.CLIENTS_WAITING="clients_waiting",e.CLIENTS_READY="clients_ready",e.REJECTED="rejected",e.WALLET_INIT="wallet_init",e.CHANNEL_PERSISTENCE="channel_persistence",e.CONFIG="config",e.MESSAGE_ACK="ack",e.SOCKET_DISCONNECTED="socket_disconnected",e.SOCKET_RECONNECT="socket_reconnect",e.OTP="otp",e.SDK_RPC_CALL="sdk_rpc_call",e.AUTHORIZED="authorized",e.CONNECTION_STATUS="connection_status",e.MESSAGE="message",e.TERMINATE="terminate"}(Zs||(Zs={})),(Js||(Js={})).KEY_EXCHANGE="key_exchange",function(e){e.KEY_HANDSHAKE_START="key_handshake_start",e.KEY_HANDSHAKE_CHECK="key_handshake_check",e.KEY_HANDSHAKE_SYN="key_handshake_SYN",e.KEY_HANDSHAKE_SYNACK="key_handshake_SYNACK",e.KEY_HANDSHAKE_ACK="key_handshake_ACK",e.KEY_HANDSHAKE_WALLET="key_handshake_wallet",e.KEY_HANDSHAKE_NONE="none"}(Xs||(Xs={}));class na extends p.exports.EventEmitter2{constructor({communicationLayer:e,otherPublicKey:t,context:n,ecies:r,logging:i}){super(),this.keysExchanged=!1,this.step=Xs.KEY_HANDSHAKE_NONE,this.debug=!1,this.context=n,this.communicationLayer=e,(null==r?void 0:r.privateKey)&&t&&(Bs.KeyExchange(`[KeyExchange: constructor()] otherPubKey=${t} set keysExchanged to true!`,r),this.keysExchanged=!0),this.myECIES=new Us(Object.assign(Object.assign({},r),{debug:null==i?void 0:i.eciesLayer})),this.communicationLayer.state.eciesInstance=this.myECIES,this.myPublicKey=this.myECIES.getPublicKey(),this.debug=!0===(null==i?void 0:i.keyExchangeLayer),t&&this.setOtherPublicKey(t),this.communicationLayer.on(Js.KEY_EXCHANGE,this.onKeyExchangeMessage.bind(this))}onKeyExchangeMessage(e){const{relayPersistence:t}=this.communicationLayer.remote.state;if(Bs.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} keysExchanged=${this.keysExchanged} relayPersistence=${t}`,e),t)return void Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Ignoring key exchange message because relay persistence is activated");const{message:n}=e;this.keysExchanged&&Bs.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} received handshake while already exchanged. step=${this.step} otherPubKey=${this.otherPublicKey}`),this.emit(Zs.KEY_INFO,n.type),n.type===Xs.KEY_HANDSHAKE_SYN?(this.checkStep([Xs.KEY_HANDSHAKE_NONE,Xs.KEY_HANDSHAKE_ACK]),Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYN",n),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey}).catch((e=>{Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_SYNACK",e)})),this.setStep(Xs.KEY_HANDSHAKE_ACK)):n.type===Xs.KEY_HANDSHAKE_SYNACK?(this.checkStep([Xs.KEY_HANDSHAKE_SYNACK,Xs.KEY_HANDSHAKE_ACK,Xs.KEY_HANDSHAKE_NONE]),Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYNACK"),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_ACK}).catch((e=>{Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_ACK",e)})),this.keysExchanged=!0,this.setStep(Xs.KEY_HANDSHAKE_ACK),this.emit(Zs.KEYS_EXCHANGED)):n.type===Xs.KEY_HANDSHAKE_ACK&&(Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_ACK set keysExchanged to true!"),this.checkStep([Xs.KEY_HANDSHAKE_ACK,Xs.KEY_HANDSHAKE_NONE]),this.keysExchanged=!0,this.setStep(Xs.KEY_HANDSHAKE_ACK),this.emit(Zs.KEYS_EXCHANGED))}resetKeys(e){this.clean(),this.myECIES=new Us(e)}clean(){Bs.KeyExchange(`[KeyExchange: clean()] context=${this.context} reset handshake state`),this.setStep(Xs.KEY_HANDSHAKE_NONE),this.emit(Zs.KEY_INFO,this.step),this.keysExchanged=!1}start({isOriginator:e,force:t}){const{relayPersistence:n,protocolVersion:r}=this.communicationLayer.remote.state,i=r>=2;n?Bs.KeyExchange("[KeyExchange: start()] Ignoring key exchange message because relay persistence is activated"):(Bs.KeyExchange(`[KeyExchange: start()] context=${this.context} protocolVersion=${r} isOriginator=${e} step=${this.step} force=${t} relayPersistence=${n} keysExchanged=${this.keysExchanged}`),e?!(this.keysExchanged||this.step!==Xs.KEY_HANDSHAKE_NONE&&this.step!==Xs.KEY_HANDSHAKE_SYNACK)||t?(Bs.KeyExchange(`[KeyExchange: start()] context=${this.context} -- start key exchange (force=${t}) -- step=${this.step}`,this.step),this.clean(),this.setStep(Xs.KEY_HANDSHAKE_SYNACK),this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_SYN,pubkey:this.myPublicKey,v:2}).catch((e=>{Bs.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYN",e)}))):Bs.KeyExchange(`[KeyExchange: start()] context=${this.context} -- key exchange already ${this.keysExchanged?"done":"in progress"} -- aborted.`,this.step):this.keysExchanged&&!0!==t?Bs.KeyExchange("[KeyExchange: start()] don't send KEY_HANDSHAKE_START -- exchange already done."):i?this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey,v:2}).catch((e=>{Bs.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYNACK",e)})):(this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_START}).catch((e=>{Bs.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_START",e)})),this.clean()))}setStep(e){this.step=e,this.emit(Zs.KEY_INFO,e)}checkStep(e){e.length>0&&e.indexOf(this.step.toString())}setRelayPersistence({localKey:e,otherKey:t}){this.otherPublicKey=t,this.myECIES=new Us({privateKey:e,debug:this.debug}),this.keysExchanged=!0}setKeysExchanged(e){this.keysExchanged=e}areKeysExchanged(){return this.keysExchanged}getMyPublicKey(){return this.myPublicKey}getOtherPublicKey(){return this.otherPublicKey}setOtherPublicKey(e){Bs.KeyExchange("[KeyExchange: setOtherPubKey()]",e),this.otherPublicKey=e}encryptMessage(e){if(!this.otherPublicKey)throw new Error("encryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.encrypt(e,this.otherPublicKey)}decryptMessage(e){if(!this.otherPublicKey)throw new Error("decryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.decrypt(e)}getKeyInfo(){return{ecies:Object.assign(Object.assign({},this.myECIES.getKeyInfo()),{otherPubKey:this.otherPublicKey}),step:this.step,keysExchanged:this.areKeysExchanged()}}toString(){const e={keyInfo:this.getKeyInfo(),keysExchanged:this.keysExchanged,step:this.step};return JSON.stringify(e)}}!function(e){e.TERMINATE="terminate",e.ANSWER="answer",e.OFFER="offer",e.CANDIDATE="candidate",e.JSONRPC="jsonrpc",e.WALLET_INFO="wallet_info",e.WALLET_INIT="wallet_init",e.ORIGINATOR_INFO="originator_info",e.PAUSE="pause",e.OTP="otp",e.AUTHORIZED="authorized",e.PING="ping",e.READY="ready"}(Qs||(Qs={})),function(e){e.REQUEST="sdk_connect_request_started",e.REQUEST_MOBILE="sdk_connect_request_started_mobile",e.RECONNECT="sdk_reconnect_request_started",e.CONNECTED="sdk_connection_established",e.CONNECTED_MOBILE="sdk_connection_established_mobile",e.AUTHORIZED="sdk_connection_authorized",e.REJECTED="sdk_connection_rejected",e.TERMINATED="sdk_connection_terminated",e.DISCONNECTED="sdk_disconnected",e.SDK_USE_EXTENSION="sdk_use_extension",e.SDK_RPC_REQUEST="sdk_rpc_request",e.SDK_RPC_REQUEST_RECEIVED="sdk_rpc_request_received",e.SDK_RPC_REQUEST_DONE="sdk_rpc_request_done",e.SDK_EXTENSION_UTILIZED="sdk_extension_utilized",e.SDK_USE_INAPP_BROWSER="sdk_use_inapp_browser"}(ea||(ea={}));const ra=(e,t,n)=>$e(void 0,void 0,void 0,(function*(){var r,i,o,s,a,c;const{remote:l,state:d}=e,{channelId:u,isOriginator:h}=d;if("error_terminated"===t)return Bs.SocketService(`handleJoinChannelResults: Channel ${u} terminated`),void e.emit(Zs.TERMINATE);if(!n)return void Bs.SocketService(`handleJoinChannelResults: No result for channel ${u}`);const{persistence:f,walletKey:p,rejected:g}=n;if(Bs.SocketService(`handleJoinChannelResults: Channel ${u} persistence=${f} walletKey=${p} rejected=${g}`),g)return Bs.SocketService(`handleJoinChannelResults: Channel ${u} rejected`),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Zs.REJECTED,{channelId:u}),void e.remote.emitServiceStatusEvent();if(p&&!(null===(r=l.state.channelConfig)||void 0===r?void 0:r.otherKey)){e.getKeyExchange().setOtherPublicKey(p),null===(i=e.state.keyExchange)||void 0===i||i.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Zs.AUTHORIZED);const{communicationLayer:t,storageManager:n}=l.state,r=Object.assign(Object.assign({},l.state.channelConfig),{channelId:null!==(o=l.state.channelId)&&void 0!==o?o:"",validUntil:Date.now()+qs,localKey:null==t?void 0:t.getKeyInfo().ecies.private,otherKey:p});e.sendMessage({type:Xs.KEY_HANDSHAKE_ACK}).catch((e=>{})),null===(s=e.state.socket)||void 0===s||s.emit(Qs.PING,{id:u,clientType:h?"dapp":"wallet",context:"on_channel_reconnect",message:""}),yield null==n?void 0:n.persistChannelConfig(r),l.emitServiceStatusEvent(),l.setConnectionStatus(Ys.LINKED)}f&&(e.emit(Zs.CHANNEL_PERSISTENCE),null===(a=e.state.keyExchange)||void 0===a||a.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Zs.AUTHORIZED),Ks(Object.assign(Object.assign({id:null!=u?u:"",event:h?ea.CONNECTED:ea.CONNECTED_MOBILE},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Fs.version,walletVersion:null===(c=e.remote.state.walletInfo)||void 0===c?void 0:c.version}),d.communicationServerUrl).catch((e=>{})))})),ia=e=>new Promise((t=>{setTimeout(t,e)})),oa=(e,t,...n)=>$e(void 0,[e,t,...n],void 0,(function*(e,t,n=200){let r;const i=Date.now();let o=!1;for(;!o;){if(o=Date.now()-i>3e5,r=t[e],void 0!==r.elapsedTime)return r;yield ia(n)}throw new Error(`RPC ${e} timed out`)})),sa=e=>$e(void 0,void 0,void 0,(function*(){const{state:t}=e,{socket:n,channelId:r,context:i,isOriginator:o,isReconnecting:s}=t;if(s)return Bs.SocketService("[SocketService: reconnectSocket()] Reconnection already in progress, skipping",e),!1;if(!n)return Bs.SocketService("[SocketService: reconnectSocket()] socket is not defined",e),!1;if(!r)return!1;const{connected:a}=n;t.isReconnecting=!0,t.reconnectionAttempts=0,Bs.SocketService(`[SocketService: reconnectSocket()] connected=${a} trying to reconnect after socketio disconnection`,e);try{for(;3>t.reconnectionAttempts;){if(Bs.SocketService(`[SocketService: reconnectSocket()] Attempt ${t.reconnectionAttempts+1} of 3`,e),yield ia(200),n.connected)return Bs.SocketService("Socket already connected --- ping to retrieve messages"),n.emit(Qs.PING,{id:r,clientType:o?"dapp":"wallet",context:"on_channel_config",message:""}),!0;t.resumed=!0,n.connect(),e.emit(Zs.SOCKET_RECONNECT);try{if(yield new Promise(((t,s)=>{n.emit(Zs.JOIN_CHANNEL,{channelId:r,context:`${i}connect_again`,clientType:o?"dapp":"wallet"},((n,r)=>$e(void 0,void 0,void 0,(function*(){try{yield ra(e,n,r),t()}catch(e){s(e)}}))))})),yield ia(100),n.connected)return Bs.SocketService(`Reconnection successful on attempt ${t.reconnectionAttempts+1}`),!0}catch(e){Bs.SocketService(`Error during reconnection attempt ${t.reconnectionAttempts+1}:`,e)}t.reconnectionAttempts+=1,3>t.reconnectionAttempts&&(yield ia(200))}return Bs.SocketService("Failed to reconnect after 3 attempts"),!1}finally{t.isReconnecting=!1,t.reconnectionAttempts=0}}));function aa(e,t){return $e(this,void 0,void 0,(function*(){var n;const r=null===(n=e.state.keyExchange)||void 0===n?void 0:n.encryptMessage(JSON.stringify(t)),i={id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:r,plaintext:e.state.hasPlaintext?JSON.stringify(t):void 0};return Bs.SocketService(`[SocketService: encryptAndSendMessage()] context=${e.state.context}`,i),t.type===Qs.TERMINATE&&(e.state.manualDisconnect=!0),new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Zs.MESSAGE,i,((e,r)=>{var i;e&&(Bs.SocketService(`[SocketService: encryptAndSendMessage()] error=${e}`),n(e)),Bs.SocketService("[encryptAndSendMessage] response",r),t(null!==(i=null==r?void 0:r.success)&&void 0!==i&&i)}))}))}))}var ca;!function(e){e.RPC_CHECK="rpcCheck",e.SKIPPED_RPC="skippedRpc"}(ca||(ca={}));const la=["eth_sendTransaction","eth_signTypedData","eth_signTransaction","personal_sign","wallet_requestPermissions","wallet_switchEthereumChain","eth_signTypedData_v3","eth_signTypedData_v4","metamask_connectSign","metamask_connectWith","metamask_batch"].map((e=>e.toLowerCase())),da=[{event:Zs.CLIENTS_CONNECTED,handler:function(e,t){return n=>$e(this,void 0,void 0,(function*(){var n,r,i,o,s,a,c,l,d,u,h;const f=null!==(r=null===(n=e.remote.state.channelConfig)||void 0===n?void 0:n.relayPersistence)&&void 0!==r&&r;if(Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected-${t}' relayPersistence=${f} resumed=${e.state.resumed} clientsPaused=${e.state.clientsPaused} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()} isOriginator=${e.state.isOriginator}`),e.emit(Zs.CLIENTS_CONNECTED,{isOriginator:e.state.isOriginator,keysExchanged:null===(o=e.state.keyExchange)||void 0===o?void 0:o.areKeysExchanged(),context:e.state.context}),e.state.resumed)e.state.isOriginator||(Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} 'clients_connected' / keysExchanged=${null===(s=e.state.keyExchange)||void 0===s?void 0:s.areKeysExchanged()} -- backward compatibility`),null===(a=e.state.keyExchange)||void 0===a||a.start({isOriginator:null!==(c=e.state.isOriginator)&&void 0!==c&&c})),e.state.resumed=!1;else if(e.state.clientsPaused)Bs.SocketService("[SocketService: handleClientsConnected()] 'clients_connected' skip sending originatorInfo on pause");else if(!e.state.isOriginator){const t=!f;Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(l=e.state.keyExchange)||void 0===l?void 0:l.areKeysExchanged()} -- force=${t} -- backward compatibility`),Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(d=e.state.keyExchange)||void 0===d?void 0:d.areKeysExchanged()} -- force=${t} -- backward compatibility`),null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h,force:t})}e.state.clientsConnected=!0,e.state.clientsPaused=!1}))}},{event:Zs.CHANNEL_CREATED,handler:function(e,t){return n=>{Bs.SocketService(`[SocketService: handleChannelCreated()] context=${e.state.context} on 'channel_created-${t}'`,n),e.emit(Zs.CHANNEL_CREATED,n)}}},{event:Zs.CLIENTS_DISCONNECTED,handler:function(e,t){return()=>{var n;e.state.clientsConnected=!1,Bs.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}'`),e.remote.state.relayPersistence?Bs.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}' - relayPersistence enabled, skipping key exchange cleanup.`):(e.state.isOriginator&&!e.state.clientsPaused&&(null===(n=e.state.keyExchange)||void 0===n||n.clean()),e.emit(Zs.CLIENTS_DISCONNECTED,t))}}},{event:Zs.CONFIG,handler:function(e,t){return n=>$e(this,void 0,void 0,(function*(){var r,i,o;Bs.SocketService(`[SocketService: handleChannelConfig()] update relayPersistence on 'config-${t}'`,n);const{persistence:s,walletKey:a}=n;e.state.isOriginator&&e.remote.state.channelConfig?(n.walletKey&&!e.remote.state.channelConfig.otherKey&&(Bs.SocketService(`Setting wallet key ${a}`),e.remote.state.channelConfig.otherKey=a,e.getKeyExchange().setOtherPublicKey(n.walletKey),null===(r=e.state.keyExchange)||void 0===r||r.setKeysExchanged(!0),yield e.remote.sendMessage({type:Xs.KEY_HANDSHAKE_ACK}),yield e.remote.sendMessage({type:Qs.PING}),yield null===(i=e.remote.state.storageManager)||void 0===i?void 0:i.persistChannelConfig(e.remote.state.channelConfig)),!0!==s||e.remote.state.channelConfig.relayPersistence||(Bs.SocketService(`Setting relay persistence ${s}`),e.remote.state.channelConfig.relayPersistence=s,e.remote.state.relayPersistence=!0,e.remote.emit(Zs.CHANNEL_PERSISTENCE),e.remote.state.authorized=!0,e.remote.state.ready=!0,e.remote.emit(Zs.AUTHORIZED),yield null===(o=e.remote.state.storageManager)||void 0===o?void 0:o.persistChannelConfig(e.remote.state.channelConfig))):e.state.isOriginator||n.persistence&&(e.remote.state.relayPersistence=!0,e.remote.emit(Zs.CHANNEL_PERSISTENCE))}))}},{event:Zs.MESSAGE,handler:function(e,t){return n=>{var r,i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w;const{ackId:E,message:C,error:_}=n,S=null!==(r=e.remote.state.relayPersistence)&&void 0!==r&&r;if(Bs.SocketService(`[SocketService handleMessage()] relayPersistence=${S} context=${e.state.context} on 'message' ${t} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()}`,n),_)throw Bs.SocketService(`\n [SocketService handleMessage()] context=${e.state.context}::on 'message' error=${_}`),new Error(_);const k="string"==typeof C;if(!k&&(null==C?void 0:C.type)===Xs.KEY_HANDSHAKE_START){if(S)return;return Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received HANDSHAKE_START isOriginator=${e.state.isOriginator}`,C),void(null===(o=e.state.keyExchange)||void 0===o||o.start({isOriginator:null!==(s=e.state.isOriginator)&&void 0!==s&&s,force:!0}))}if(!k&&(null===(a=null==C?void 0:C.type)||void 0===a?void 0:a.startsWith("key_handshake"))){if(S)return;return Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' emit KEY_EXCHANGE`,C),void e.emit(Js.KEY_EXCHANGE,{message:C,context:e.state.context})}if(k&&!(null===(c=e.state.keyExchange)||void 0===c?void 0:c.areKeysExchanged())){let t=!1;try{Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' trying to decrypt message`),null===(l=e.state.keyExchange)||void 0===l||l.decryptMessage(C),t=!0}catch(t){Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' error`,t)}if(!t)return e.state.isOriginator?null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h}):e.sendMessage({type:Xs.KEY_HANDSHAKE_START}).catch((e=>{})),void Bs.SocketService(`Message ignored because invalid key exchange status. step=${null===(f=e.state.keyExchange)||void 0===f?void 0:f.getKeyInfo().step}`,null===(p=e.state.keyExchange)||void 0===p?void 0:p.getKeyInfo(),C);Bs.SocketService("Invalid key exchange status detected --- updating it."),null===(d=e.state.keyExchange)||void 0===d||d.setKeysExchanged(!0)}else if(!k&&(null==C?void 0:C.type))return void e.emit(Zs.MESSAGE,C);if(!k)return void e.emit(Zs.MESSAGE,C);const x=null===(g=e.state.keyExchange)||void 0===g?void 0:g.decryptMessage(C),A=JSON.parse(null!=x?x:"{}");if(E&&(null==E?void 0:E.length)>0&&(Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' ackid=${E} channelId=${t}`),null===(m=e.state.socket)||void 0===m||m.emit(Zs.MESSAGE_ACK,{ackId:E,channelId:t,clientType:e.state.isOriginator?"dapp":"wallet"})),e.state.clientsPaused=(null==A?void 0:A.type)===Qs.PAUSE,e.state.isOriginator&&A.data){const t=A.data,n=e.state.rpcMethodTracker[t.id];if(n){const r=Date.now()-n.timestamp;Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received answer for id=${t.id} method=${n.method} responseTime=${r}`,A),e.remote.state.analytics&&la.includes(n.method.toLowerCase())&&Ks(Object.assign(Object.assign({id:null!==(y=e.remote.state.channelId)&&void 0!==y?y:"",event:ea.SDK_RPC_REQUEST_DONE,sdkVersion:e.remote.state.sdkVersion,commLayerVersion:Fs.version},e.remote.state.originatorInfo),{walletVersion:null===(v=e.remote.state.walletInfo)||void 0===v?void 0:v.version,params:{method:n.method,from:"mobile"}}),e.remote.state.communicationServerUrl).catch((e=>{}));const i=Object.assign(Object.assign({},n),{result:t.result,error:t.error?{code:null===(b=t.error)||void 0===b?void 0:b.code,message:null===(w=t.error)||void 0===w?void 0:w.message}:void 0,elapsedTime:r});e.state.rpcMethodTracker[t.id]=i,e.emit(Zs.RPC_UPDATE,i)}}e.emit(Zs.MESSAGE,{message:A})}}},{event:Zs.REJECTED,handler:function(e,t){return n=>$e(this,void 0,void 0,(function*(){var n;e.state.isOriginator&&!e.remote.state.ready?(Bs.SocketService(`[SocketService: handleChannelRejected()] context=${e.state.context} channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`,e.remote.state.originatorInfo),Ks(Object.assign(Object.assign({id:t,event:ea.REJECTED},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Fs.version,walletVersion:null===(n=e.remote.state.walletInfo)||void 0===n?void 0:n.version}),e.remote.state.communicationServerUrl).catch((e=>{})),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Zs.REJECTED,{channelId:t}),e.remote.setConnectionStatus(Ys.DISCONNECTED)):Bs.SocketService(`[SocketService: handleChannelRejected()] SKIP -- channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`)}))}},{event:"clients_waiting_to_join",handler:function(e,t){return n=>{Bs.SocketService(`[SocketService: handleClientsWaitingToJoin()] context=${e.state.context} on 'clients_waiting_to_join-${t}'`,n),e.emit(Zs.CLIENTS_WAITING,n)}}}],ua=[{event:Zs.KEY_INFO,handler:function(e){return t=>{Bs.SocketService("[SocketService: handleKeyInfo()] on 'KEY_INFO'",t),e.emit(Zs.KEY_INFO,t)}}},{event:Zs.KEYS_EXCHANGED,handler:function(e){return()=>{var t,n,r;Bs.SocketService(`[SocketService: handleKeysExchanged()] on 'keys_exchanged' keyschanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`);const{channelConfig:i}=e.remote.state;if(i){const t=e.getKeyExchange().getKeyInfo().ecies;i.localKey=t.private,i.otherKey=t.otherPubKey,e.remote.state.channelConfig=i,null===(n=e.remote.state.storageManager)||void 0===n||n.persistChannelConfig(i).catch((e=>{}))}e.emit(Zs.KEYS_EXCHANGED,{keysExchanged:null===(r=e.state.keyExchange)||void 0===r?void 0:r.areKeysExchanged(),isOriginator:e.state.isOriginator});const o={keyInfo:e.getKeyInfo()};e.emit(Zs.SERVICE_STATUS,o)}}}];function ha(e,t){Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} setting socket listeners for channel ${t}...`);const{socket:n}=e.state,{keyExchange:r}=e.state;n&&e.state.isOriginator&&(e.state.debug&&(null==n||n.io.on("error",(t=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=error`,t)})),null==n||n.io.on("reconnect",(t=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect`,t),sa(e).catch((e=>{}))})),null==n||n.io.on("reconnect_error",(t=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_error`,t)})),null==n||n.io.on("reconnect_failed",(()=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_failed`)}))),null==n||n.on("disconnect",(t=>(Bs.SocketService(`[SocketService: setupChannelListener()] on 'disconnect' -- MetaMaskSDK socket disconnected '${t}' begin recovery...`),function(e){return t=>{Bs.SocketService(`[SocketService: handleDisconnect()] on 'disconnect' manualDisconnect=${e.state.manualDisconnect}`,t),e.state.manualDisconnect||(e.emit(Zs.SOCKET_DISCONNECTED),sa(e).catch((e=>{})))}}(e)(t))))),da.forEach((({event:r,handler:i})=>{null==n||n.on(`${r}-${t}`,i(e,t))})),ua.forEach((({event:t,handler:n})=>{null==r||r.on(t,n(e))})),e.state.setupChannelListeners=!0}class fa extends p.exports.EventEmitter2{constructor(e){super(),this.state={clientsConnected:!1,clientsPaused:!1,manualDisconnect:!1,lastRpcId:void 0,rpcMethodTracker:{},hasPlaintext:!1,communicationServerUrl:"",focusListenerAdded:!1,removeFocusListener:void 0,isReconnecting:!1,reconnectionAttempts:0},this.options=e;const{reconnect:t,communicationLayerPreference:n,communicationServerUrl:r,context:i,remote:o,logging:s}=e;this.state.resumed=t,this.state.context=i,this.state.isOriginator=o.state.isOriginator,this.state.communicationLayerPreference=n,this.state.debug=!0===(null==s?void 0:s.serviceLayer),this.remote=o,!0===(null==s?void 0:s.serviceLayer)&&f.enable("SocketService:Layer"),this.state.communicationServerUrl=r,this.state.hasPlaintext=this.state.communicationServerUrl!==Hs&&!0===(null==s?void 0:s.plaintext),Bs.SocketService(`[SocketService: constructor()] Socket IO url: ${this.state.communicationServerUrl}`),this.initSocket()}initSocket(){var e;const{otherPublicKey:t,ecies:n,logging:r}=this.options,i={autoConnect:!1,transports:zs,withCredentials:!0},o=this.state.communicationServerUrl;Bs.SocketService(`[SocketService: initSocket()] Socket IO url: ${o}`),this.state.socket=De(o,i),function(e){if("undefined"!=typeof window&&"undefined"!=typeof document&&(Bs.SocketService(`[SocketService: setupSocketFocusListener()] hasFocus=${document.hasFocus()}`,e),!e.state.focusListenerAdded)){const t=()=>{Bs.SocketService("Document has focus --- reconnecting socket"),sa(e).catch((e=>{}))};window.addEventListener("focus",t),e.state.focusListenerAdded=!0,e.state.removeFocusListener=()=>{window.removeEventListener("focus",t),e.state.focusListenerAdded=!1}}}(this);const s={communicationLayer:this,otherPublicKey:t,sendPublicKey:!1,context:null!==(e=this.state.context)&&void 0!==e?e:"",ecies:n,logging:r};this.state.keyExchange=new na(s)}resetKeys(){return Bs.SocketService("[SocketService: resetKeys()] Resetting keys."),void(null===(e=this.state.keyExchange)||void 0===e||e.resetKeys());var e}createChannel(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n,i;if(Bs.SocketService(`[SocketService: createChannel()] context=${e.state.context}`),e.state.socket||e.initSocket(),null===(t=e.state.socket)||void 0===t?void 0:t.connected)throw new Error("socket already connected");null===(n=e.state.socket)||void 0===n||n.connect(),e.state.manualDisconnect=!1,e.state.isOriginator=!0;const o=r();e.state.channelId=o,ha(e,o),yield new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Zs.JOIN_CHANNEL,{channelId:o,context:`${e.state.context}createChannel`,clientType:"dapp"},((r,i)=>$e(this,void 0,void 0,(function*(){try{yield ra(e,r,i),t()}catch(e){n(e)}}))))}));const s=null===(i=e.state.keyExchange)||void 0===i?void 0:i.getKeyInfo();return{channelId:o,pubKey:(null==s?void 0:s.ecies.public)||"",privKey:(null==s?void 0:s.ecies.private)||""}}))}(this)}))}connectToChannel({channelId:e,withKeyExchange:t=!1,authorized:n}){return function(e){return $e(this,arguments,void 0,(function*({options:e,instance:t}){const{channelId:n,authorized:r,withKeyExchange:i}=e,{state:o,remote:s}=t,{isOriginator:a=!1,socket:c,keyExchange:l}=o,{channelConfig:d}=s.state;if(null==c?void 0:c.connected)throw new Error("socket already connected");if(a&&(null==d?void 0:d.relayPersistence)){const{localKey:e,otherKey:t}=d;e&&t&&(null==l||l.setRelayPersistence({localKey:e,otherKey:t}))}return Object.assign(o,{manualDisconnect:!1,withKeyExchange:i,isOriginator:a,channelId:n}),null==c||c.connect(),ha(t,n),!a&&r&&(null==l||l.setKeysExchanged(!0),Object.assign(s.state,{ready:!0,authorized:!0})),new Promise((e=>{var i;const s=null===(i=null==l?void 0:l.getKeyInfo())||void 0===i?void 0:i.ecies.public;null==c||c.emit(Zs.JOIN_CHANNEL,{channelId:n,context:`${o.context}_connectToChannel`,clientType:a?"dapp":"wallet",publicKey:r&&!a?s:void 0},((n,r)=>$e(this,void 0,void 0,(function*(){yield ra(t,n,r),e()}))))}))}))}({options:{channelId:e,withKeyExchange:t,authorized:n},instance:this})}getKeyInfo(){return this.state.keyExchange.getKeyInfo()}keyCheck(){var e,t;null===(t=(e=this).state.socket)||void 0===t||t.emit(Zs.MESSAGE,{id:e.state.channelId,context:e.state.context,message:{type:Xs.KEY_HANDSHAKE_CHECK,pubkey:e.getKeyInfo().ecies.otherPubKey}})}getKeyExchange(){return this.state.keyExchange}sendMessage(e){return $e(this,void 0,void 0,(function*(){return function(e,t){return $e(this,void 0,void 0,(function*(){var n,r,i;if(!e.state.channelId)throw Bs.SocketService("handleSendMessage: no channelId - Create a channel first"),new Error("Create a channel first");if(Bs.SocketService(`[SocketService: handleSendMessage()] context=${e.state.context} areKeysExchanged=${null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged()}`,t),null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.startsWith("key_handshake"))return function(e,t){var n;Bs.SocketService(`[SocketService: handleKeyHandshake()] context=${e.state.context}`,t),null===(n=e.state.socket)||void 0===n||n.emit(Zs.MESSAGE,{id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:t})}(e,t),!0;!function(e,t){var n;if(!(null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged())&&!e.remote.state.relayPersistence)throw Bs.SocketService(`[SocketService: validateKeyExchange()] context=${e.state.context} ERROR keys not exchanged`,t),new Error("Keys not exchanged BBB")}(e,t),function(e,t){var n;const r=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"",i=null==t?void 0:t.id;e.state.isOriginator&&i&&(e.state.rpcMethodTracker[i]={id:i,timestamp:Date.now(),method:r},e.emit(Zs.RPC_UPDATE,e.state.rpcMethodTracker[i]))}(e,t);const o=yield aa(e,t);return e.remote.state.analytics&&e.remote.state.isOriginator&&t.method&&la.includes(t.method.toLowerCase())&&Ks({id:null!==(i=e.remote.state.channelId)&&void 0!==i?i:"",event:ea.SDK_RPC_REQUEST,params:{method:t.method,from:"mobile"}},e.remote.state.communicationServerUrl).catch((e=>{})),function(e,t){return $e(this,void 0,void 0,(function*(){var n;const r=null==t?void 0:t.id,i=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"";if(e.state.isOriginator&&r)try{const n=oa(r,e.state.rpcMethodTracker,200).then((e=>({type:ca.RPC_CHECK,result:e}))),o=(()=>$e(this,void 0,void 0,(function*(){const t=yield(e=>$e(void 0,[e],void 0,(function*({rpcId:e,instance:t}){for(;t.state.lastRpcId===e||void 0===t.state.lastRpcId;)yield ia(200);return t.state.lastRpcId})))({instance:e,rpcId:r}),n=yield oa(t,e.state.rpcMethodTracker,200);return{type:ca.SKIPPED_RPC,result:n}})))(),s=yield Promise.race([n,o]);if(s.type===ca.RPC_CHECK){const e=s.result;Bs.SocketService(`[SocketService:handleRpcReplies()] id=${t.id} ${i} ( ${e.elapsedTime} ms)`,e.result)}else{if(s.type!==ca.SKIPPED_RPC)throw new Error(`Error handling RPC replies for ${r}`);{const t=Object.assign(Object.assign({},e.state.rpcMethodTracker[r]),{error:new Error("SDK_CONNECTION_ISSUE")});e.emit(Zs.RPC_UPDATE,t);const n={data:Object.assign(Object.assign({},t),{jsonrpc:"2.0"}),name:"metamask-provider"};e.emit(Zs.MESSAGE,{message:n})}}}catch(e){throw e}}))}(e,t).catch((e=>{})),o}))}(this,e)}))}ping(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n;Bs.SocketService(`[SocketService: ping()] context=${e.state.context} originator=${e.state.isOriginator} keysExchanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`),null===(n=e.state.socket)||void 0===n||n.emit(Qs.PING,{id:e.state.channelId,context:"ping",clientType:e.remote.state.isOriginator?"dapp":"wallet",message:""})}))}(this)}pause(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n;Bs.SocketService(`[SocketService: pause()] context=${e.state.context}`),e.state.manualDisconnect=!0,(null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged())&&(yield e.sendMessage({type:Qs.PAUSE})),null===(n=e.state.socket)||void 0===n||n.disconnect()}))}(this)}isConnected(){var e;return null===(e=this.state.socket)||void 0===e?void 0:e.connected}resume(){return function(e){return $e(this,void 0,void 0,(function*(){const{state:t,remote:n}=e,{socket:r,channelId:i,context:o,keyExchange:s,isOriginator:a}=t,{isOriginator:c}=n.state;if(Bs.SocketService(`[SocketService: resume()] channelId=${i} context=${o} connected=${null==r?void 0:r.connected} manualDisconnect=${t.manualDisconnect} resumed=${t.resumed} keysExchanged=${null==s?void 0:s.areKeysExchanged()}`),!i)throw Bs.SocketService("[SocketService: resume()] channelId is not defined"),new Error("ChannelId is not defined");(null==r?void 0:r.connected)?(Bs.SocketService("[SocketService: resume()] already connected."),r.emit(Qs.PING,{id:i,clientType:c?"dapp":"wallet",context:"on_channel_config",message:""}),n.hasRelayPersistence()||(null==s?void 0:s.areKeysExchanged())||(a?yield e.sendMessage({type:Qs.READY}):null==s||s.start({isOriginator:!1}))):(null==r||r.connect(),Bs.SocketService(`[SocketService: resume()] after connecting socket --\x3e connected=${null==r?void 0:r.connected}`),null==r||r.emit(Zs.JOIN_CHANNEL,{channelId:i,context:`${o}_resume`,clientType:c?"dapp":"wallet"},((t,n)=>$e(this,void 0,void 0,(function*(){try{yield ra(e,t,n)}catch(e){}}))))),t.manualDisconnect=!1,t.resumed=!0}))}(this)}getRPCMethodTracker(){return this.state.rpcMethodTracker}disconnect(e){return function(e,t){var n,r,i,o,s;Bs.SocketService(`[SocketService: disconnect()] context=${e.state.context}`,t),(null==t?void 0:t.terminate)&&(null===(r=(n=e.state).removeFocusListener)||void 0===r||r.call(n),e.state.channelId=t.channelId,null===(i=e.state.socket)||void 0===i||i.removeAllListeners(),null===(o=e.state.keyExchange)||void 0===o||o.clean(),e.remote.state.ready=!1,e.state.socket=void 0,e.state.rpcMethodTracker={}),e.state.manualDisconnect=!0,null===(s=e.state.socket)||void 0===s||s.disconnect()}(this,e)}}var pa,ga,ma;function ya(e){return()=>$e(this,void 0,void 0,(function*(){var t,n,r;const{state:i}=e;if(i.authorized)return;yield(()=>$e(this,void 0,void 0,(function*(){for(;!i.walletInfo;)yield ia(500)})))();const o="7.3".localeCompare((null===(t=i.walletInfo)||void 0===t?void 0:t.version)||"");if(Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' version=${null===(n=i.walletInfo)||void 0===n?void 0:n.version} compareValue=${o}`),1!==o)return;const s=i.platformType===ga.MobileWeb||i.platformType===ga.ReactNative||i.platformType===ga.MetaMaskMobileWebview;Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' platform=${i.platformType} secure=${s} channel=${i.channelId} walletVersion=${null===(r=i.walletInfo)||void 0===r?void 0:r.version}`),s&&(i.authorized=!0,e.emit(Zs.AUTHORIZED))}))}function va(e){return t=>{const{state:n}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleChannelCreatedEvent()] context=${n.context} on 'channel_created' channelId=${t}`),e.emit(Zs.CHANNEL_CREATED,t)}}function ba(e,t){return()=>{var n,r,i,o;const{state:s}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleClientsConnectedEvent()] on 'clients_connected' channel=${s.channelId} keysExchanged=${null===(r=null===(n=s.communicationLayer)||void 0===n?void 0:n.getKeyInfo())||void 0===r?void 0:r.keysExchanged}`),s.analytics&&Ks(Object.assign(Object.assign({id:null!==(i=s.channelId)&&void 0!==i?i:"",event:s.reconnection?ea.RECONNECT:s.isOriginator?ea.REQUEST:ea.REQUEST_MOBILE},s.originatorInfo),{commLayer:t,sdkVersion:s.sdkVersion,walletVersion:null===(o=s.walletInfo)||void 0===o?void 0:o.version,commLayerVersion:Fs.version}),s.communicationServerUrl).catch((e=>{})),s.clientsConnected=!0,s.originatorInfoSent=!1,e.emit(Zs.CLIENTS_CONNECTED)}}function wa(e){return t=>{const{state:n}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleClientsDisconnectedEvent()] context=${n.context} on 'clients_disconnected' channelId=${t}`),n.relayPersistence||(n.clientsConnected=!1,n.ready=!1,n.authorized=!1),e.emit(Zs.CLIENTS_DISCONNECTED,n.channelId),e.setConnectionStatus(Ys.DISCONNECTED)}}function Ea(e){return t=>{var n;const{state:r}=e;if(Bs.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] context=${r.context} on 'clients_waiting' numberUsers=${t} ready=${r.ready} autoStarted=${r.originatorConnectStarted}`),e.setConnectionStatus(Ys.WAITING),e.emit(Zs.CLIENTS_WAITING,t),r.originatorConnectStarted){Bs.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] on 'clients_waiting' watch autoStarted=${r.originatorConnectStarted} timeout`,r.autoConnectOptions);const t=(null===(n=r.autoConnectOptions)||void 0===n?void 0:n.timeout)||3e3,i=setTimeout((()=>{Bs.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] setTimeout(${t}) terminate channelConfig`,r.autoConnectOptions),r.originatorConnectStarted=!1,r.ready||e.setConnectionStatus(Ys.TIMEOUT),clearTimeout(i)}),t)}}}function Ca(e,t){return n=>{var r,i,o,s,a,c,l,d;const{state:u}=e;if(Bs.RemoteCommunication(`[RemoteCommunication: handleKeysExchangedEvent()] context=${u.context} on commLayer.'keys_exchanged' channel=${u.channelId}`,n),null===(i=null===(r=u.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.keysExchanged){const t=Object.assign(Object.assign({},u.channelConfig),{channelId:null!==(o=u.channelId)&&void 0!==o?o:"",validUntil:(null===(s=u.channelConfig)||void 0===s?void 0:s.validUntil)||qs,localKey:u.communicationLayer.getKeyInfo().ecies.private,otherKey:u.communicationLayer.getKeyInfo().ecies.otherPubKey});null===(a=u.storageManager)||void 0===a||a.persistChannelConfig(t).catch((e=>{})),e.setConnectionStatus(Ys.LINKED)}!function(e,t){var n,r,i,o,s,a,c,l;const{state:d}=e;Bs.RemoteCommunication(`[RemoteCommunication: setLastActiveDate()] channel=${d.channelId}`,t);const u=Object.assign(Object.assign({},d.channelConfig),{channelId:null!==(n=d.channelId)&&void 0!==n?n:"",validUntil:null!==(i=null===(r=d.channelConfig)||void 0===r?void 0:r.validUntil)&&void 0!==i?i:0,relayPersistence:d.relayPersistence,localKey:null===(s=null===(o=d.communicationLayer)||void 0===o?void 0:o.state.keyExchange)||void 0===s?void 0:s.getKeyInfo().ecies.private,otherKey:null===(c=null===(a=d.communicationLayer)||void 0===a?void 0:a.state.keyExchange)||void 0===c?void 0:c.getKeyInfo().ecies.otherPubKey,lastActive:t.getTime()});null===(l=d.storageManager)||void 0===l||l.persistChannelConfig(u)}(e,new Date),u.analytics&&u.channelId&&Ks(Object.assign(Object.assign({id:u.channelId,event:n.isOriginator?ea.CONNECTED:ea.CONNECTED_MOBILE},u.originatorInfo),{sdkVersion:u.sdkVersion,commLayer:t,commLayerVersion:Fs.version,walletVersion:null===(c=u.walletInfo)||void 0===c?void 0:c.version}),u.communicationServerUrl).catch((e=>{})),u.isOriginator=n.isOriginator,n.isOriginator||(null===(l=u.communicationLayer)||void 0===l||l.sendMessage({type:Qs.READY}),u.ready=!0,u.paused=!1),n.isOriginator&&!u.originatorInfoSent&&(null===(d=u.communicationLayer)||void 0===d||d.sendMessage({type:Qs.ORIGINATOR_INFO,originatorInfo:u.originatorInfo,originator:u.originatorInfo}),u.originatorInfoSent=!0)}}function _a(e){return t=>{let n=t;t.message&&(n=n.message),function(e,t){const{state:n}=t;if(Bs.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] context=${n.context} on 'message' typeof=${typeof e}`,e),t.state.ready=!0,n.isOriginator||e.type!==Qs.ORIGINATOR_INFO)if(n.isOriginator&&e.type===Qs.WALLET_INFO)!function(e,t){const{state:n}=e;n.walletInfo=t.walletInfo,n.paused=!1}(t,e);else{if(n.isOriginator&&e.type===Qs.WALLET_INIT)(function(e,t){return $e(this,void 0,void 0,(function*(){var n,r,i;const{state:o}=e;if(o.isOriginator){const o=t.data||{};if("object"==typeof o&&"accounts"in o&&"chainId"in o&&"walletKey"in o)try{const{channelConfig:t}=e.state;if(Bs.RemoteCommunication("WALLET_INIT: channelConfig",JSON.stringify(t,null,2)),t){const s=o.accounts,a=o.chainId,c=o.walletKey;let l,d=!1;"deeplinkProtocol"in o&&(d=Boolean(o.deeplinkProtocol),e.state.deeplinkProtocolAvailable=d),"walletVersion"in o&&(l=o.walletVersion),yield null===(n=e.state.storageManager)||void 0===n?void 0:n.persistChannelConfig(Object.assign(Object.assign({},t),{otherKey:c,walletVersion:l,deeplinkProtocolAvailable:d,relayPersistence:!0})),yield null===(r=e.state.storageManager)||void 0===r?void 0:r.persistAccounts(s),yield null===(i=e.state.storageManager)||void 0===i?void 0:i.persistChainId(a)}e.emit(Zs.WALLET_INIT,{accounts:o.accounts,chainId:o.chainId})}catch(n){}}}))})(t,e).catch((e=>{Bs.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Qs.TERMINATE)(function(e){return $e(this,void 0,void 0,(function*(){const{state:t}=e;t.isOriginator&&(yield Ma({options:{terminate:!0,sendMessage:!1},instance:e}),e.emit(Zs.TERMINATE))}))})(t).catch((e=>{Bs.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Qs.PAUSE)!function(e){const{state:t}=e;t.paused=!0,e.setConnectionStatus(Ys.PAUSED)}(t);else if(e.type===Qs.READY&&n.isOriginator)!function(e){const{state:t}=e;e.setConnectionStatus(Ys.LINKED);const n=t.paused;t.paused=!1,e.emit(Zs.CLIENTS_READY,{isOriginator:t.isOriginator,walletInfo:t.walletInfo}),n&&(t.authorized=!0,e.emit(Zs.AUTHORIZED))}(t);else{if(e.type===Qs.OTP&&n.isOriginator)return void function(e,t){var n;const{state:r}=e;e.emit(Zs.OTP,t.otpAnswer),1==="6.6".localeCompare((null===(n=r.walletInfo)||void 0===n?void 0:n.version)||"")&&e.emit(Zs.SDK_RPC_CALL,{method:Ws.ETH_REQUESTACCOUNTS,params:[]})}(t,e);e.type===Qs.AUTHORIZED&&n.isOriginator&&function(e){const{state:t}=e;t.authorized=!0,e.emit(Zs.AUTHORIZED)}(t)}t.emit(Zs.MESSAGE,e)}else!function(e,t){var n;const{state:r}=e;null===(n=r.communicationLayer)||void 0===n||n.sendMessage({type:Qs.WALLET_INFO,walletInfo:r.walletInfo}),r.originatorInfo=t.originatorInfo||t.originator,e.emit(Zs.CLIENTS_READY,{isOriginator:r.isOriginator,originatorInfo:r.originatorInfo}),r.paused=!1}(t,e)}(n,e)}}function Sa(e){return()=>{const{state:t}=e;Bs.RemoteCommunication("[RemoteCommunication: handleSocketReconnectEvent()] on 'socket_reconnect' -- reset key exchange status / set ready to false"),t.ready=!1,t.authorized=!1,Gs(t),e.emitServiceStatusEvent({context:"socket_reconnect"})}}function ka(e){return()=>{const{state:t}=e;Bs.RemoteCommunication("[RemoteCommunication: handleSocketDisconnectedEvent()] on 'socket_Disconnected' set ready to false"),t.ready=!1}}function xa(e){return()=>$e(this,void 0,void 0,(function*(){var t,n,r,i,o,s,a;const{state:c}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleFullPersistenceEvent()] context=${c.context}`),e.state.ready=!0,e.state.clientsConnected=!0,e.state.authorized=!0,e.state.relayPersistence=!0,null===(t=e.state.communicationLayer)||void 0===t||t.getKeyExchange().setKeysExchanged(!0),e.emit(Zs.KEYS_EXCHANGED,{keysExchanged:!0,isOriginator:!0}),e.emit(Zs.AUTHORIZED),e.emit(Zs.CLIENTS_READY),e.emit(Zs.CHANNEL_PERSISTENCE);try{c.channelConfig=Object.assign(Object.assign({},c.channelConfig),{localKey:null===(n=c.communicationLayer)||void 0===n?void 0:n.getKeyExchange().getKeyInfo().ecies.private,otherKey:null===(r=c.communicationLayer)||void 0===r?void 0:r.getKeyExchange().getOtherPublicKey(),channelId:null!==(i=c.channelId)&&void 0!==i?i:"",validUntil:null!==(s=null===(o=c.channelConfig)||void 0===o?void 0:o.validUntil)&&void 0!==s?s:qs,relayPersistence:!0}),yield null===(a=c.storageManager)||void 0===a?void 0:a.persistChannelConfig(c.channelConfig)}catch(t){}}))}function Aa({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,ecies:r,communicationServerUrl:i=Hs,instance:o}){var s,a,c,l,d,u,h,f,p,g,m;const{state:y}=o;if(Bs.RemoteCommunication("[initCommunicationLayer()] ",JSON.stringify(y,null,2)),e!==pa.SOCKET)throw new Error("Invalid communication protocol");y.communicationLayer=new fa({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,transports:y.transports,communicationServerUrl:i,context:y.context,ecies:r,logging:y.logging,remote:o});let v="undefined"!=typeof document&&document.URL||"",b="undefined"!=typeof document&&document.title||"";(null===(s=y.dappMetadata)||void 0===s?void 0:s.url)&&(v=y.dappMetadata.url),(null===(a=y.dappMetadata)||void 0===a?void 0:a.name)&&(b=y.dappMetadata.name);const w=null!==(u=null!==(l=null===(c=y.dappMetadata)||void 0===c?void 0:c.name)&&void 0!==l?l:null===(d=y.dappMetadata)||void 0===d?void 0:d.url)&&void 0!==u?u:"N/A",E="undefined"!=typeof window&&void 0!==window.location&&null!==(h=window.location.hostname)&&void 0!==h?h:w,C={url:v,title:b,source:null===(f=y.dappMetadata)||void 0===f?void 0:f.source,dappId:E,icon:(null===(p=y.dappMetadata)||void 0===p?void 0:p.iconUrl)||(null===(g=y.dappMetadata)||void 0===g?void 0:g.base64Icon),platform:y.platformType,apiVersion:Fs.version,connector:null===(m=y.dappMetadata)||void 0===m?void 0:m.connector};y.originatorInfo=C;const _={[Zs.AUTHORIZED]:ya(o),[Zs.MESSAGE]:_a(o),[Zs.CHANNEL_PERSISTENCE]:xa(o),[Zs.CLIENTS_CONNECTED]:ba(o,e),[Zs.KEYS_EXCHANGED]:Ca(o,e),[Zs.SOCKET_DISCONNECTED]:ka(o),[Zs.SOCKET_RECONNECT]:Sa(o),[Zs.CLIENTS_DISCONNECTED]:wa(o),[Zs.KEY_INFO]:()=>{},[Zs.CHANNEL_CREATED]:va(o),[Zs.CLIENTS_WAITING]:Ea(o),[Zs.RPC_UPDATE]:e=>{o.emit(Zs.RPC_UPDATE,e)}};for(const[t,n]of Object.entries(_))try{y.communicationLayer.on(t,n)}catch(e){}}function Ma(e){return $e(this,arguments,void 0,(function*({options:e,instance:t}){const{state:n}=t;return Bs.RemoteCommunication(`[RemoteCommunication: disconnect()] channel=${n.channelId}`,e),new Promise(((i,o)=>{var s,a,c,l,d,u;(null==e?void 0:e.terminate)?(t.state.ready&&Ks({id:null!==(s=t.state.channelId)&&void 0!==s?s:"",event:ea.TERMINATED},t.state.communicationServerUrl).catch((e=>{})),n.ready=!1,n.paused=!1,null===(a=n.storageManager)||void 0===a||a.terminate(null!==(c=n.channelId)&&void 0!==c?c:""),t.state.terminated=!0,e.sendMessage?(null===(l=n.communicationLayer)||void 0===l?void 0:l.getKeyInfo().keysExchanged)&&t.state.communicationLayer&&aa(t.state.communicationLayer,{type:Qs.TERMINATE}).then((()=>{i(!0)})).catch((e=>{o(e)})):i(!0),n.authorized=!1,n.relayPersistence=!1,n.channelId=r(),e.channelId=n.channelId,n.channelConfig=void 0,n.originatorConnectStarted=!1,null===(d=n.communicationLayer)||void 0===d||d.disconnect(e),t.setConnectionStatus(Ys.TERMINATED)):(null===(u=n.communicationLayer)||void 0===u||u.disconnect(e),t.setConnectionStatus(Ys.DISCONNECTED),i(!0))}))}))}(pa||(pa={})).SOCKET="socket",function(e){e.NonBrowser="nodejs",e.MetaMaskMobileWebview="in-app-browser",e.DesktopWeb="web-desktop",e.MobileWeb="web-mobile",e.ReactNative="react-native"}(ga||(ga={}));class La extends p.exports.EventEmitter2{constructor(e){super(),this.state={ready:!1,authorized:!1,isOriginator:!1,terminated:!1,protocolVersion:1,paused:!1,deeplinkProtocolAvailable:!1,platformType:"metamask-mobile",analytics:!1,reconnection:!1,originatorInfoSent:!1,communicationServerUrl:Hs,context:"",persist:!1,clientsConnected:!1,sessionDuration:qs,originatorConnectStarted:!1,debug:!1,_connectionStatus:Ys.DISCONNECTED},this._options=e;const{platformType:t,communicationLayerPreference:n,otherPublicKey:r,reconnect:i,walletInfo:o,dappMetadata:s,protocolVersion:a,transports:c,context:l,relayPersistence:d,ecies:u,analytics:h=!1,storage:p,sdkVersion:g,communicationServerUrl:m=Hs,logging:y,autoConnect:v={timeout:Vs}}=e;this.state.otherPublicKey=r,this.state.dappMetadata=s,this.state.walletInfo=o,this.state.transports=c,this.state.platformType=t,this.state.analytics=h,this.state.protocolVersion=null!=a?a:1,this.state.isOriginator=!r,this.state.relayPersistence=d,this.state.communicationServerUrl=m,this.state.context=l,this.state.terminated=!1,this.state.sdkVersion=g,this.setMaxListeners(50),this.setConnectionStatus(Ys.DISCONNECTED),(null==p?void 0:p.duration)&&(this.state.sessionDuration=qs),this.state.storageOptions=p,this.state.autoConnectOptions=v,this.state.debug=!0===(null==y?void 0:y.remoteLayer),!0===(null==y?void 0:y.remoteLayer)&&f.enable("RemoteCommunication:Layer"),!0===(null==y?void 0:y.serviceLayer)&&f.enable("SocketService:Layer"),!0===(null==y?void 0:y.eciesLayer)&&f.enable("ECIES:Layer"),!0===(null==y?void 0:y.keyExchangeLayer)&&f.enable("KeyExchange:Layer"),this.state.logging=y,(null==p?void 0:p.storageManager)&&(this.state.storageManager=p.storageManager),Bs.RemoteCommunication(`[RemoteCommunication: constructor()] protocolVersion=${a} relayPersistence=${d} isOriginator=${this.state.isOriginator} communicationLayerPreference=${n} otherPublicKey=${r} reconnect=${i}`),this.state.isOriginator||Aa({communicationLayerPreference:n,otherPublicKey:r,reconnect:i,ecies:u,communicationServerUrl:m,instance:this}),this.emitServiceStatusEvent({context:"constructor"})}initFromDappStorage(){return $e(this,void 0,void 0,(function*(){var e;if(this.state.storageManager){const t=yield this.state.storageManager.getPersistedChannelConfig({});t&&(this.state.channelConfig=t,this.state.channelId=t.channelId,this.state.deeplinkProtocolAvailable=null!==(e=t.deeplinkProtocolAvailable)&&void 0!==e&&e,t.relayPersistence&&(this.state.authorized=!0,this.state.ready=!0,this.setConnectionStatus(Ys.LINKED),yield this.connectToChannel({channelId:t.channelId})))}Aa({communicationLayerPreference:pa.SOCKET,otherPublicKey:this.state.otherPublicKey,reconnect:this._options.reconnect,ecies:this._options.ecies,communicationServerUrl:this.state.communicationServerUrl,instance:this})}))}originatorSessionConnect(){return $e(this,void 0,void 0,(function*(){return yield function(e){return $e(this,void 0,void 0,(function*(){var t;const{state:n}=e;if(!n.storageManager)return void Bs.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] no storage manager defined - skip");const r=yield n.storageManager.getPersistedChannelConfig({});if(Bs.RemoteCommunication(`[RemoteCommunication: originatorSessionConnect()] autoStarted=${n.originatorConnectStarted} channelConfig`,r),null===(t=n.communicationLayer)||void 0===t?void 0:t.isConnected())return Bs.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] socket already connected - skip"),r;if(r){if(r.validUntil>Date.now())return n.channelConfig=r,n.originatorConnectStarted=!0,n.channelId=null==r?void 0:r.channelId,n.reconnection=!0,r;Bs.RemoteCommunication("[RemoteCommunication: autoConnect()] Session has expired")}n.originatorConnectStarted=!1}))}(this)}))}generateChannelIdConnect(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n,r,i,o,s;if(!e.communicationLayer)throw new Error("communication layer not initialized");if(e.ready)throw new Error("Channel already connected");if(e.channelId&&(null===(t=e.communicationLayer)||void 0===t?void 0:t.isConnected()))return e.channelConfig=Object.assign(Object.assign({},e.channelConfig),{channelId:e.channelId,validUntil:Date.now()+e.sessionDuration}),null===(n=e.storageManager)||void 0===n||n.persistChannelConfig(e.channelConfig),{channelId:e.channelId,privKey:null===(i=null===(r=e.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.ecies.private,pubKey:null===(s=null===(o=e.communicationLayer)||void 0===o?void 0:o.getKeyInfo())||void 0===s?void 0:s.ecies.public};Bs.RemoteCommunication("[RemoteCommunication: generateChannelId()]");const a=yield e.communicationLayer.createChannel();Bs.RemoteCommunication("[RemoteCommunication: generateChannelId()] channel created",a);const c=Object.assign(Object.assign({},e.channelConfig),{channelId:a.channelId,localKey:a.privKey,validUntil:Date.now()+e.sessionDuration});return e.channelId=a.channelId,e.channelConfig=c,{channelId:e.channelId,pubKey:a.pubKey,privKey:a.privKey}}))}(this.state)}))}clean(){return Gs(this.state)}connectToChannel({channelId:e,withKeyExchange:t,authorized:n}){return function(e){return $e(this,arguments,void 0,(function*({channelId:e,withKeyExchange:t,authorized:n,state:r}){var o,s,a;if(!i(e))throw Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} channelId=${e} withKeyExchange=${t}`),null===(o=r.communicationLayer)||void 0===o?void 0:o.isConnected())return void Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} already connected - interrupt connection.`);r.channelId=e,yield null===(s=r.communicationLayer)||void 0===s?void 0:s.connectToChannel({channelId:e,authorized:n,withKeyExchange:t});const c=Object.assign(Object.assign({},r.channelConfig),{channelId:e,validUntil:Date.now()+r.sessionDuration});r.channelConfig=c,null===(a=r.storageManager)||void 0===a||a.persistChannelConfig(c)}))}({channelId:e,authorized:n,withKeyExchange:t,state:this.state})}sendMessage(e){return function(e,t){return $e(this,void 0,void 0,(function*(){var n,r;const{state:i}=e;Bs.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} paused=${i.paused} ready=${i.ready} relayPersistence=${i.relayPersistence} authorized=${i.authorized} socket=${null===(n=i.communicationLayer)||void 0===n?void 0:n.isConnected()} clientsConnected=${i.clientsConnected} status=${i._connectionStatus}`,t),i.relayPersistence||i.ready&&(null===(r=i.communicationLayer)||void 0===r?void 0:r.isConnected())&&i.clientsConnected||(Bs.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} SKIP message waiting for MM mobile readiness.`),yield new Promise((t=>{e.once(Zs.CLIENTS_READY,t)})),Bs.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} AFTER SKIP / READY -- sending pending message`));try{const n=yield function(e,t){return $e(this,void 0,void 0,(function*(){return new Promise((n=>{var r;const{state:i}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} ready=${i.ready} authorized=${i.authorized} method=${t.method}`),!i.isOriginator||i.authorized||i.relayPersistence?null===(r=i.communicationLayer)||void 0===r||r.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)})):e.once(Zs.AUTHORIZED,(()=>{var e;Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} AFTER SKIP / AUTHORIZED -- sending pending message`),null===(e=i.communicationLayer)||void 0===e||e.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)}))}))}))}))}(e,t);return n}catch(e){throw e}}))}(this,e)}testStorage(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t;const n=yield null===(t=e.storageManager)||void 0===t?void 0:t.getPersistedChannelConfig();Bs.RemoteCommunication("[RemoteCommunication: testStorage()] res",n)}))}(this.state)}))}hasDeeplinkProtocol(){return this.state.deeplinkProtocolAvailable}getChannelConfig(){return this.state.channelConfig}isReady(){return this.state.ready}isConnected(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.isConnected()}isAuthorized(){return this.state.authorized}isPaused(){return this.state.paused}getCommunicationLayer(){return this.state.communicationLayer}ping(){return $e(this,void 0,void 0,(function*(){var e;Bs.RemoteCommunication(`[RemoteCommunication: ping()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.ping()}))}testLogger(){Bs.RemoteCommunication(`testLogger() channel=${this.state.channelId}`),Bs.SocketService(`testLogger() channel=${this.state.channelId}`),Bs.Ecies(`testLogger() channel=${this.state.channelId}`),Bs.KeyExchange(`testLogger() channel=${this.state.channelId}`)}keyCheck(){var e;Bs.RemoteCommunication(`[RemoteCommunication: keyCheck()] channel=${this.state.channelId}`),null===(e=this.state.communicationLayer)||void 0===e||e.keyCheck()}setConnectionStatus(e){this.state._connectionStatus!==e&&(this.state._connectionStatus=e,this.emit(Zs.CONNECTION_STATUS,e),this.emitServiceStatusEvent({context:"setConnectionStatus"}))}emitServiceStatusEvent(e={}){this.emit(Zs.SERVICE_STATUS,this.getServiceStatus())}getConnectionStatus(){return this.state._connectionStatus}getServiceStatus(){return{originatorInfo:this.state.originatorInfo,keyInfo:this.getKeyInfo(),connectionStatus:this.state._connectionStatus,channelConfig:this.state.channelConfig,channelId:this.state.channelId}}getKeyInfo(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getKeyInfo()}resetKeys(){var e;null===(e=this.state.communicationLayer)||void 0===e||e.resetKeys()}setOtherPublicKey(e){var t;const n=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange();if(!n)throw new Error("KeyExchange is not initialized.");n.getOtherPublicKey()!==e&&n.setOtherPublicKey(e)}pause(){return $e(this,void 0,void 0,(function*(){var e;Bs.RemoteCommunication(`[RemoteCommunication: pause()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.pause(),this.setConnectionStatus(Ys.PAUSED)}))}getVersion(){return Fs.version}hasRelayPersistence(){var e;return null!==(e=this.state.relayPersistence)&&void 0!==e&&e}resume(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t;const{state:n}=e;Bs.RemoteCommunication(`[RemoteCommunication: resume()] channel=${n.channelId}`),yield null===(t=n.communicationLayer)||void 0===t?void 0:t.resume(),e.setConnectionStatus(Ys.LINKED)}))}(this)}))}encrypt(e){var t,n,r;const i=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange(),o=null==i?void 0:i.getOtherPublicKey();if(!o)throw new Error("KeyExchange not completed");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.encrypt(e,o)}decrypt(e){var t,n,r;if(!(null===(t=this.state.communicationLayer)||void 0===t?void 0:t.state.eciesInstance))throw new Error("ECIES instance is not initialized");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.decrypt(e)}getChannelId(){return this.state.channelId}getRPCMethodTracker(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getRPCMethodTracker()}reject({channelId:e}){return function(e){return $e(this,arguments,void 0,(function*({channelId:e,state:t}){var n,r,o;if(!i(e))throw Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${t.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(t.isOriginator)return void Bs.RemoteCommunication(`[RemoteCommunication: reject()] context=${t.context} isOriginator=${t.isOriginator} channelId=${e}`);const{socket:s}=null!==(r=null===(n=t.communicationLayer)||void 0===n?void 0:n.state)&&void 0!==r?r:{};(null==s?void 0:s.connected)||(Bs.RemoteCommunication(`[RemoteCommunication: reject()] context=${t.context} socket already connected`),null==s||s.connect()),Ks(Object.assign(Object.assign({id:e,event:ea.REJECTED},t.originatorInfo),{sdkVersion:t.sdkVersion,commLayerVersion:Fs.version,walletVersion:null===(o=t.walletInfo)||void 0===o?void 0:o.version}),t.communicationServerUrl).catch((e=>{})),yield new Promise(((n,r)=>{null==s||s.emit(Zs.REJECTED,{channelId:e},((e,i)=>{Bs.RemoteCommunication(`[RemoteCommunication: reject()] context=${t.context} socket=${null==s?void 0:s.id}`,{error:e,response:i}),e?r(e):n(i)}))}))}))}({channelId:e,state:this.state})}disconnect(e){return $e(this,void 0,void 0,(function*(){return Ma({options:e,instance:this})}))}}!function(e){e.RENEW="renew",e.LINK="link"}(ma||(ma={}));var Ta="ERC721",Oa="ERC1155",Ra={errors:{disconnected:()=>"MetaMask: Disconnected from chain. Attempting to connect.",permanentlyDisconnected:()=>"MetaMask: Disconnected from MetaMask background. Page reload required.",sendSiteMetadata:()=>"MetaMask: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:e=>`MetaMask: The MetaMask Ethereum provider does not support synchronous methods like ${e} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidNetworkParams:()=>"MetaMask: Received invalid network parameters. Please report this bug.",invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:e=>`'args.logger' must include required method '${e}'.`},info:{connected:e=>`MetaMask: Connected to chain with ID "${e}".`},warnings:{chainIdDeprecation:"MetaMask: 'ethereum.chainId' is deprecated and may be removed in the future. Please use the 'eth_chainId' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",networkVersionDeprecation:"MetaMask: 'ethereum.networkVersion' is deprecated and may be removed in the future. Please use the 'net_version' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",selectedAddressDeprecation:"MetaMask: 'ethereum.selectedAddress' is deprecated and may be removed in the future. Please use the 'eth_accounts' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",enableDeprecation:"MetaMask: 'ethereum.enable()' is deprecated and may be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102",sendDeprecation:"MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193",events:{close:"MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect",data:"MetaMask: The event 'data' is deprecated and will be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message",networkChanged:"MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Use 'chainChanged' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#chainchanged",notification:"MetaMask: The event 'notification' is deprecated and may be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message"},rpc:{ethDecryptDeprecation:"MetaMask: The RPC method 'eth_decrypt' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",ethGetEncryptionPublicKeyDeprecation:"MetaMask: The RPC method 'eth_getEncryptionPublicKey' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",walletWatchAssetNFTExperimental:"MetaMask: The RPC method 'wallet_watchAsset' is experimental for ERC721/ERC1155 assets and may change in the future.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-1.md and https://github.com/MetaMask/metamask-improvement-proposals/blob/main/PROCESS-GUIDE.md#proposal-lifecycle"},experimentalMethods:"MetaMask: 'ethereum._metamask' exposes non-standard, experimental methods. They may be removed or changed without warning."}};function Pa(e){const t={ethDecryptDeprecation:!1,ethGetEncryptionPublicKeyDeprecation:!1,walletWatchAssetNFTExperimental:!1};return(n,r,i)=>{t.ethDecryptDeprecation||"eth_decrypt"!==n.method?t.ethGetEncryptionPublicKeyDeprecation||"eth_getEncryptionPublicKey"!==n.method?!t.walletWatchAssetNFTExperimental&&"wallet_watchAsset"===n.method&&[Ta,Oa].includes(n.params?.type||"")&&(e.warn(Ra.warnings.rpc.walletWatchAssetNFTExperimental),t.walletWatchAssetNFTExperimental=!0):(e.warn(Ra.warnings.rpc.ethGetEncryptionPublicKeyDeprecation),t.ethGetEncryptionPublicKeyDeprecation=!0):(e.warn(Ra.warnings.rpc.ethDecryptDeprecation),t.ethDecryptDeprecation=!0),i()}}var Ia=4294967295,Na=Math.floor(Math.random()*Ia);var Ba=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Da=(e,t,n)=>(Ba(e,t,"read from private field"),n?n.call(e):t.get(e)),$a=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},ja=(e,t,n,r)=>(Ba(e,t,"write to private field"),t.set(e,n),n),Ka=(e,t,n)=>(Ba(e,t,"access private method"),n),Ua=-32600,Fa=-32603,Ha={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};function za(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}var qa=(e,t)=>Object.hasOwnProperty.call(e,t);class Va extends TypeError{constructor(e,t){let n;const{message:r,explanation:i,...o}=e,{path:s}=e,a=0===s.length?r:`At path: ${s.join(".")} -- ${r}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function Wa(e){return"object"==typeof e&&null!=e}function Ga(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function Ya(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=n,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${Ga(r)}\``}=e;return{value:r,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*Za(e,t,n,r){(function(e){return Wa(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=Ya(i,t,n,r);e&&(yield e)}}function*Ja(e,t,n={}){const{path:r=[],branch:i=[e],coerce:o=!1,mask:s=!1}=n,a={path:r,branch:i};if(o&&(e=t.coercer(e,a),s&&"type"!==t.type&&Wa(t.schema)&&Wa(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let c="valid";for(const r of t.validator(e,a))r.explanation=n.message,c="not_valid",yield[r,void 0];for(let[l,d,u]of t.entries(e,a)){const t=Ja(d,u,{path:void 0===l?r:[...r,l],branch:void 0===l?i:[...i,d],coerce:o,mask:s,message:n.message});for(const n of t)n[0]?(c=null!=n[0].refinement?"not_refined":"not_valid",yield[n[0],void 0]):o&&(d=n[1],void 0===l?e=d:e instanceof Map?e.set(l,d):e instanceof Set?e.add(d):Wa(e)&&(void 0!==d||l in e)&&(e[l]=d))}if("not_valid"!==c)for(const r of t.refiner(e,a))r.explanation=n.message,c="not_refined",yield[r,void 0];"valid"===c&&(yield[void 0,e])}class Xa{constructor(e){const{type:t,schema:n,validator:r,refiner:i,coercer:o=(e=>e),entries:s=function*(){}}=e;this.type=t,this.schema=n,this.entries=s,this.coercer=o,this.validator=r?(e,t)=>Za(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Za(i(e,t),t,this,e):()=>[]}assert(e,t){return Qa(e,this,t)}create(e,t){return ec(e,this,t)}is(e){return tc(e,this)}mask(e,t){return function(e,t,n){const r=nc(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return nc(e,this,t)}}function Qa(e,t,n){const r=nc(e,t,{message:n});if(r[0])throw r[0]}function ec(e,t,n){const r=nc(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function tc(e,t){return!nc(e,t)[0]}function nc(e,t,n={}){const r=Ja(e,t,n),i=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(i[0]){return[new Va(i[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,i[1]]}function rc(e,t){return new Xa({type:e,schema:null,validator:t})}function ic(e){let t;return new Xa({type:"lazy",schema:null,*entries(n,r){t??(t=e()),yield*t.entries(n,r)},validator:(n,r)=>(t??(t=e()),t.validator(n,r)),coercer:(n,r)=>(t??(t=e()),t.coercer(n,r)),refiner:(n,r)=>(t??(t=e()),t.refiner(n,r))})}function oc(e){return new Xa({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Ga(e)}`})}function sc(e){const t=Ga(e),n=typeof e;return new Xa({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${Ga(n)}`})}function ac(){return rc("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${Ga(e)}`))}function cc(e){const t=e?Object.keys(e):[],n=rc("never",(()=>!1));return new Xa({type:"object",schema:e||null,*entries(r){if(e&&Wa(r)){const i=new Set(Object.keys(r));for(const n of t)i.delete(n),yield[n,r[n],e[n]];for(const e of i)yield[e,r[e],n]}},validator:e=>Wa(e)||`Expected an object, but received: ${Ga(e)}`,coercer:e=>Wa(e)?{...e}:e})}function lc(e){return new Xa({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function dc(e,t){return new Xa({type:"record",schema:null,*entries(n){if(Wa(n))for(const r in n){const i=n[r];yield[r,r,e],yield[r,i,t]}},validator:e=>Wa(e)||`Expected an object, but received: ${Ga(e)}`})}function uc(){return rc("string",(e=>"string"==typeof e||`Expected a string, but received: ${Ga(e)}`))}function hc(e){const t=e.map((e=>e.type)).join(" | ");return new Xa({type:"union",schema:null,coercer(t){for(const n of e){const[e,r]=n.validate(t,{coerce:!0});if(!e)return r}return t},validator(n,r){const i=[];for(const t of e){const[...e]=Ja(n,t,r),[o]=e;if(!o[0])return[];for(const[t]of e)t&&i.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Ga(n)}`,...i]}})}var fc=class extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}};function pc(){throw new Error("setTimeout has not been defined")}function gc(){throw new Error("clearTimeout has not been defined")}var mc=pc,yc=gc;function vc(e){if(mc===setTimeout)return setTimeout(e,0);if((mc===pc||!mc)&&setTimeout)return mc=setTimeout,setTimeout(e,0);try{return mc(e,0)}catch(t){try{return mc.call(null,e,0)}catch(t){return mc.call(this,e,0)}}}"function"==typeof je.setTimeout&&(mc=setTimeout),"function"==typeof je.clearTimeout&&(yc=clearTimeout);var bc,wc=[],Ec=!1,Cc=-1;function _c(){Ec&&bc&&(Ec=!1,bc.length?wc=bc.concat(wc):Cc=-1,wc.length&&Sc())}function Sc(){if(!Ec){var e=vc(_c);Ec=!0;for(var t=wc.length;t;){for(bc=wc,wc=[];++Cc<t;)bc&&bc[Cc].run();Cc=-1,t=wc.length}bc=null,Ec=!1,function(e){if(yc===clearTimeout)return clearTimeout(e);if((yc===gc||!yc)&&clearTimeout)return yc=clearTimeout,clearTimeout(e);try{return yc(e)}catch(t){try{return yc.call(null,e)}catch(t){return yc.call(this,e)}}}(e)}}function kc(e,t){this.fun=e,this.array=t}function xc(){}kc.prototype.run=function(){this.fun.apply(null,this.array)};var Ac=xc,Mc=xc,Lc=xc,Tc=xc,Oc=xc,Rc=xc,Pc=xc,Ic=je.performance||{},Nc=Ic.now||Ic.mozNow||Ic.msNow||Ic.oNow||Ic.webkitNow||function(){return(new Date).getTime()},Bc=new Date,Dc={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];wc.push(new kc(e,t)),1!==wc.length||Ec||vc(Sc)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Ac,addListener:Mc,once:Lc,off:Tc,removeListener:Oc,removeAllListeners:Rc,emit:Pc,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Nc.call(Ic),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Bc)/1e3}},$c=e=>cc(e);function jc({path:e,branch:t}){const n=e[e.length-1];return qa(t[t.length-2],n)}function Kc(e){return new Xa({...e,type:`optional ${e.type}`,validator:(t,n)=>!jc(n)||e.validator(t,n),refiner:(t,n)=>!jc(n)||e.refiner(t,n)})}var Uc,Fc,Hc,zc=hc([sc(null),rc("boolean",(e=>"boolean"==typeof e)),rc("finite number",(e=>tc(e,ac())&&Number.isFinite(e))),uc(),oc(ic((()=>zc))),dc(uc(),ic((()=>zc)))]),qc=(Uc=zc,Fc=rc("any",(()=>!0)),Hc=e=>(function(e,t,n="Assertion failed",r=fc){try{Qa(e,t)}catch(e){throw function(e,t){return n=e,Boolean("string"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}(r,`${n}: ${function(e){return function(e){return function(e){return"object"==typeof e&&null!==e&&"message"in e}(e)&&"string"==typeof e.message?e.message:null==e?"":String(e)}(e).replace(/\.$/u,"")}(e)}.`)}}(e,zc),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t})))),new Xa({...Uc,coercer:(e,t)=>tc(e,Fc)?Uc.coercer(Hc(e),t):Uc.coercer(e,t)}));function Vc(e){try{return function(e){ec(e,qc)}(e),!0}catch{return!1}}var Wc=sc("2.0"),Gc=function(e){return new Xa({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}(hc([ac(),uc()])),Yc=$c({code:rc("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${Ga(e)}`)),message:uc(),data:Kc(qc),stack:Kc(uc())}),Zc=hc([dc(uc(),qc),oc(qc)]),Jc=$c({id:Gc,jsonrpc:Wc,method:uc(),params:Kc(Zc)}),Xc=$c({jsonrpc:Wc,method:uc(),params:Kc(Zc)});function Qc(e){return tc(e,Jc)}function el(e){return tc(e,Yc)}cc({id:Gc,jsonrpc:Wc,result:lc(rc("unknown",(()=>!0))),error:lc(Yc)}),hc([$c({id:Gc,jsonrpc:Wc,result:qc}),$c({id:Gc,jsonrpc:Wc,error:Yc})]);var tl="Unspecified error message. This is a bug, please report it.",nl={code:Fa,message:il(Fa)},rl="Unspecified server error.";function il(e,t=tl){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(qa(Ha,t))return Ha[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return rl}return t}function ol(e,{fallbackError:t=nl,shouldIncludeStack:n=!0}={}){if(!el(t))throw new Error("Must provide fallback error with integer number code and string message.");const r=function(e,t){if(e&&"object"==typeof e&&"serialize"in e&&"function"==typeof e.serialize)return e.serialize();if(el(e))return e;return{...t,data:{cause:sl(e)}}}(e,t);return n||delete r.stack,r}function sl(e){return Array.isArray(e)?e.map((e=>Vc(e)?e:za(e)?al(e):null)):za(e)?al(e):Vc(e)?e:null}function al(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return Vc(r)&&(t[n]=r),t}),{})}var cl=pl;pl.default=pl,pl.stable=vl,pl.stableStringify=vl;var ll="[...]",dl="[Circular]",ul=[],hl=[];function fl(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function pl(e,t,n,r){var i;void 0===r&&(r=fl()),ml(e,"",0,[],void 0,0,r);try{i=0===hl.length?JSON.stringify(e,t,n):JSON.stringify(e,wl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ul.length;){var o=ul.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function gl(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);void 0!==i.get?i.configurable?(Object.defineProperty(r,n,{value:e}),ul.push([r,n,t,i])):hl.push([t,n,e]):(r[n]=e,ul.push([r,n,t]))}function ml(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void gl(dl,e,t,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void gl(ll,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void gl(ll,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)ml(e[a],a,a,r,e,o,s);else{var c=Object.keys(e);for(a=0;a<c.length;a++){var l=c[a];ml(e[l],l,a,r,e,o,s)}}r.pop()}}function yl(e,t){return e<t?-1:e>t?1:0}function vl(e,t,n,r){void 0===r&&(r=fl());var i,o=bl(e,"",0,[],void 0,0,r)||e;try{i=0===hl.length?JSON.stringify(o,t,n):JSON.stringify(o,wl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ul.length;){var s=ul.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function bl(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void gl(dl,e,t,i);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void gl(ll,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void gl(ll,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)bl(e[a],a,a,r,e,o,s);else{var c={},l=Object.keys(e).sort(yl);for(a=0;a<l.length;a++){var d=l[a];bl(e[d],d,a,r,e,o,s),c[d]=e[d]}if(void 0===i)return c;ul.push([i,t,e]),i[t]=c}r.pop()}}function wl(e){return e=void 0!==e?e:function(e,t){return t},function(t,n){if(hl.length>0)for(var r=0;r<hl.length;r++){var i=hl[r];if(i[1]===t&&i[0]===n){n=i[2],hl.splice(r,1);break}}return e.call(this,t,n)}}var El=Ut(cl),Cl=class extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a non-empty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data,function(e){if("object"!=typeof e||null===e)return!1;try{let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}catch(e){return!1}}(this.data)&&(e.data.cause=sl(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return El(this.serialize(),_l,2)}};function _l(e,t){if("[Circular]"!==t)return t}var Sl=e=>function(e,t){const[n,r]=function(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t??void 0,n]}}return[]}(t);return new Cl(e,n??il(e),r)}(Ua,e);var kl={};function xl(){}function Al(){Al.init.call(this)}function Ml(e){return void 0===e._maxListeners?Al.defaultMaxListeners:e._maxListeners}function Ll(e,t,n,r){var i,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]):(o=e._events=new xl,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=Ml(e))&&i>0&&s.length>i){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(a)}}else s=o[t]=n,++e._eventsCount;return e}function Tl(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function Ol(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Rl(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}xl.prototype=Object.create(null),Al.EventEmitter=Al,Al.usingDomains=!1,Al.prototype.domain=void 0,Al.prototype._events=void 0,Al.prototype._maxListeners=void 0,Al.defaultMaxListeners=10,Al.init=function(){this.domain=null,Al.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new xl,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Al.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Al.prototype.getMaxListeners=function(){return Ml(this)},Al.prototype.emit=function(e){var t,n,r,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var d="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Rl(e,r),o=0;o<r;++o)i[o].call(n)}(n,d,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=Rl(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,d,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=Rl(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=Rl(e,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=Rl(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,d,this,i)}return!0},Al.prototype.addListener=function(e,t){return Ll(this,e,t,!1)},Al.prototype.on=Al.prototype.addListener,Al.prototype.prependListener=function(e,t){return Ll(this,e,t,!0)},Al.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Tl(this,e,t)),this},Al.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Tl(this,e,t)),this},Al.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new xl:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new xl,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,s||t)}return this},Al.prototype.off=function(e,t){return this.removeListener(e,t)},Al.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new xl,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new xl:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new xl,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Al.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},Al.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ol.call(e,t)},Al.prototype.listenerCount=Ol,Al.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Pl=Ft(Object.freeze({__proto__:null,EventEmitter:Al,default:Al}));Object.defineProperty(kl,"__esModule",{value:!0});const Il=Pl;function Nl(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}let Bl=class extends Il.EventEmitter{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)Nl(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)Nl(n[r],this,t)}return!0}};var Dl,$l,jl,Kl,Ul,Fl,Hl,zl,ql,Vl,Wl,Gl,Yl,Zl,Jl,Xl,Ql,ed,td,nd=kl.default=Bl,rd=class e extends nd{constructor({notificationHandler:e}={}){super(),$a(this,Kl),$a(this,Fl),$a(this,zl),$a(this,Dl,!1),$a(this,$l,void 0),$a(this,jl,void 0),ja(this,$l,[]),ja(this,jl,e)}destroy(){Da(this,$l).forEach((e=>{"destroy"in e&&"function"==typeof e.destroy&&e.destroy()})),ja(this,$l,[]),ja(this,Dl,!0)}push(e){Ka(this,Kl,Ul).call(this),Da(this,$l).push(e)}handle(e,t){if(Ka(this,Kl,Ul).call(this),t&&"function"!=typeof t)throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?t?Ka(this,Fl,Hl).call(this,e,t):Ka(this,Fl,Hl).call(this,e):t?Ka(this,zl,ql).call(this,e,t):this._promiseHandle(e)}asMiddleware(){return Ka(this,Kl,Ul).call(this),async(t,n,r,i)=>{var o,s;try{const[a,c,l]=await Ka(o=e,Gl,Yl).call(o,t,n,Da(this,$l));return c?(await Ka(s=e,Xl,Ql).call(s,l),i(a)):r((async t=>{var n;try{await Ka(n=e,Xl,Ql).call(n,l)}catch(e){return t(e)}return t()}))}catch(e){return i(e)}}}async _promiseHandle(e){return new Promise(((t,n)=>{Ka(this,zl,ql).call(this,e,((e,r)=>{e&&void 0===r?n(e):t(r)})).catch(n)}))}};Dl=new WeakMap,$l=new WeakMap,jl=new WeakMap,Kl=new WeakSet,Ul=function(){if(Da(this,Dl))throw new Error("This engine is destroyed and can no longer be used.")},Fl=new WeakSet,Hl=async function(e,t){try{if(0===e.length){const e=[{id:null,jsonrpc:"2.0",error:new Cl(Ua,"Request batch must contain plain objects. Received an empty array")}];return t?t(null,e):e}const n=(await Promise.all(e.map(this._promiseHandle.bind(this)))).filter((e=>void 0!==e));return t?t(null,n):n}catch(e){if(t)return t(e);throw e}},zl=new WeakSet,ql=async function(e,t){var n;if(!e||Array.isArray(e)||"object"!=typeof e){const n=new Cl(Ua,"Requests must be plain objects. Received: "+typeof e,{request:e});return t(n,{id:null,jsonrpc:"2.0",error:n})}if("string"!=typeof e.method){const n=new Cl(Ua,"Must specify a string method. Received: "+typeof e.method,{request:e});return Da(this,jl)&&!Qc(e)?t(null):t(n,{id:e.id??null,jsonrpc:"2.0",error:n})}if(Da(this,jl)&&tc(e,Xc)&&!Qc(e)){try{await Da(this,jl).call(this,e)}catch(e){return t(e)}return t(null)}let r=null;const i={...e},o={id:i.id,jsonrpc:i.jsonrpc};try{await Ka(n=rd,Vl,Wl).call(n,i,o,Da(this,$l))}catch(e){r=e}return r&&(delete o.result,o.error||(o.error=ol(r))),t(r,o)},Vl=new WeakSet,Wl=async function(e,t,n){var r,i,o;const[s,a,c]=await Ka(r=rd,Gl,Yl).call(r,e,t,n);if(Ka(i=rd,ed,td).call(i,e,t,a),await Ka(o=rd,Xl,Ql).call(o,c),s)throw s},Gl=new WeakSet,Yl=async function(e,t,n){var r;const i=[];let o=null,s=!1;for(const a of n)if([o,s]=await Ka(r=rd,Zl,Jl).call(r,e,t,a,i),s)break;return[o,s,i.reverse()]},Zl=new WeakSet,Jl=async function(e,t,n,r){return new Promise((i=>{const o=e=>{const n=e||t.error;n&&(t.error=ol(n)),i([n,!0])},s=n=>{t.error?o(t.error):(n&&("function"!=typeof n&&o(new Cl(Fa,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof n}" for request:\n${od(e)}`,{request:e})),r.push(n)),i([null,!1]))};try{n(e,t,s,o)}catch(e){o(e)}}))},Xl=new WeakSet,Ql=async function(e){for(const t of e)await new Promise(((e,n)=>{t((t=>t?n(t):e()))}))},ed=new WeakSet,td=function(e,t,n){if(!qa(t,"result")&&!qa(t,"error"))throw new Cl(Fa,`JsonRpcEngine: Response has no error or result for request:\n${od(e)}`,{request:e});if(!n)throw new Cl(Fa,`JsonRpcEngine: Nothing ended request:\n${od(e)}`,{request:e})},$a(rd,Vl),$a(rd,Gl),$a(rd,Zl),$a(rd,Xl),$a(rd,ed);var id=rd;function od(e){return JSON.stringify(e,null,2)}var sd=Object.freeze(["eth_subscription"]),ad=(e=console)=>[(e,t,n,r)=>{const i=e.id,o=Na=(Na+1)%Ia;e.id=o,t.id=o,n((n=>{e.id=i,t.id=i,n()}))},cd(e),Pa(e)];function cd(e){return(t,n,r)=>{"string"==typeof t.method&&t.method||(n.error=Sl({message:"The request 'method' must be a non-empty string.",data:t})),r((t=>{const{error:r}=n;return r?(e.error(`MetaMask - RPC Error: ${r.message}`,r),t()):t()}))}}var ld=(e,t,n=!0)=>(r,i)=>{r||i.error?t(r||i.error):!n||Array.isArray(i)?e(i):e(i.result)},dd=e=>Boolean(e)&&"string"==typeof e&&e.startsWith("0x"),ud=()=>{};async function hd(e,t){try{const t=await async function(){return{name:fd(window),icon:await pd(window)}}();e.handle({jsonrpc:"2.0",id:1,method:"metamask_sendDomainMetadata",params:t},ud)}catch(e){t.error({message:Ra.errors.sendSiteMetadata(),originalError:e})}}function fd(e){const{document:t}=e,n=t.querySelector('head > meta[property="og:site_name"]');if(n)return n.content;const r=t.querySelector('head > meta[name="title"]');return r?r.content:t.title&&t.title.length>0?t.title:window.location.hostname}async function pd(e){const{document:t}=e,n=t.querySelectorAll('head > link[rel~="icon"]');for(const e of Array.from(n))if(e&&await gd(e.href))return e.href;return null}async function gd(e){return new Promise(((t,n)=>{try{const n=document.createElement("img");n.onload=()=>t(!0),n.onerror=()=>t(!1),n.src=e}catch(e){n(e)}}))}var md=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},yd=(e,t,n)=>(md(e,t,"read from private field"),n?n.call(e):t.get(e)),vd=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},bd=(e,t,n,r)=>(md(e,t,"write to private field"),t.set(e,n),n);function wd(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}class Ed extends Al{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)wd(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)wd(n[r],this,t)}return!0}}var Cd,_d,Sd=Ut((function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n})),kd=class e extends Ed{constructor({logger:t=console,maxEventListeners:n=100,rpcMiddleware:r=[]}={}){super(),vd(this,Cd,void 0),vd(this,_d,void 0),this._log=t,this.setMaxListeners(n),this._state={...e._defaultState},bd(this,_d,null),bd(this,Cd,null),this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this.request=this.request.bind(this);const i=new id;r.forEach((e=>i.push(e))),this._rpcEngine=i}get chainId(){return yd(this,Cd)}get selectedAddress(){return yd(this,_d)}isConnected(){return this._state.isConnected}async request(e){if(!e||"object"!=typeof e||Array.isArray(e))throw Sl({message:Ra.errors.invalidRequestArgs(),data:e});const{method:t,params:n}=e;if("string"!=typeof t||0===t.length)throw Sl({message:Ra.errors.invalidRequestMethod(),data:e});if(void 0!==n&&!Array.isArray(n)&&("object"!=typeof n||null===n))throw Sl({message:Ra.errors.invalidRequestParams(),data:e});const r=null==n?{method:t}:{method:t,params:n};return new Promise(((e,t)=>{this._rpcRequest(r,ld(e,t))}))}_initializeState(e){if(this._state.initialized)throw new Error("Provider already initialized.");if(e){const{accounts:t,chainId:n,isUnlocked:r,networkVersion:i}=e;this._handleConnect(n),this._handleChainChanged({chainId:n,networkVersion:i}),this._handleUnlockStateChanged({accounts:t,isUnlocked:r}),this._handleAccountsChanged(t)}this._state.initialized=!0,this.emit("_initialized")}_rpcRequest(e,t){let n=t;return Array.isArray(e)||(e.jsonrpc||(e.jsonrpc="2.0"),"eth_accounts"!==e.method&&"eth_requestAccounts"!==e.method||(n=(n,r)=>{this._handleAccountsChanged(r.result??[],"eth_accounts"===e.method),t(n,r)})),this._rpcEngine.handle(e,n)}_handleConnect(e){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:e}),this._log.debug(Ra.info.connected(e)))}_handleDisconnect(e,t){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let n;this._state.isConnected=!1,e?(n=new Cl(1013,t??Ra.errors.disconnected()),this._log.debug(n)):(n=new Cl(1011,t??Ra.errors.permanentlyDisconnected()),this._log.error(n),bd(this,Cd,null),this._state.accounts=null,bd(this,_d,null),this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",n)}}_handleChainChanged({chainId:e}={}){dd(e)?(this._handleConnect(e),e!==yd(this,Cd)&&(bd(this,Cd,e),this._state.initialized&&this.emit("chainChanged",yd(this,Cd)))):this._log.error(Ra.errors.invalidNetworkParams(),{chainId:e})}_handleAccountsChanged(e,t=!1){let n=e;Array.isArray(e)||(this._log.error("MetaMask: Received invalid accounts parameter. Please report this bug.",e),n=[]);for(const t of e)if("string"!=typeof t){this._log.error("MetaMask: Received non-string account. Please report this bug.",e),n=[];break}if(!Sd(this._state.accounts,n)&&(t&&null!==this._state.accounts&&this._log.error("MetaMask: 'eth_accounts' unexpectedly updated accounts. Please report this bug.",n),this._state.accounts=n,yd(this,_d)!==n[0]&&bd(this,_d,n[0]||null),this._state.initialized)){const e=[...n];this.emit("accountsChanged",e)}}_handleUnlockStateChanged({accounts:e,isUnlocked:t}={}){"boolean"==typeof t?t!==this._state.isUnlocked&&(this._state.isUnlocked=t,this._handleAccountsChanged(e??[])):this._log.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.")}};Cd=new WeakMap,_d=new WeakMap,kd._defaultState={accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1};var xd,Ad,Md=kd,Ld={exports:{}};function Td(){return Ad?xd:(Ad=1,xd=Pl.EventEmitter)}var Od,Rd=Ft(jt);Od="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e};var Pd=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},Id=/%[sdj%]/g;function Nd(e){if(!Jd(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(Kd(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(e).replace(Id,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<i;s=r[++n])Gd(s)||!tu(s)?o+=" "+s:o+=" "+Kd(s);return o}function Bd(e,t){if(Qd(je.process))return function(){return Bd(e,t).apply(this,arguments)};if(!0===Dc.noDeprecation)return e;var n=!1;return function(){if(!n){if(Dc.throwDeprecation)throw new Error(t);Dc.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}}var Dd,$d={};function jd(e){return Qd(Dd)&&(Dd=Dc.env.NODE_DEBUG||""),e=e.toUpperCase(),$d[e]||(new RegExp("\\b"+e+"\\b","i").test(Dd)?$d[e]=function(){var t=Nd.apply(null,arguments);console.error("%s %d: %s",e,0,t)}:$d[e]=function(){}),$d[e]}function Kd(e,t){var n={seen:[],stylize:Fd};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),Wd(t)?n.showHidden=t:t&&uu(n,t),Qd(n.showHidden)&&(n.showHidden=!1),Qd(n.depth)&&(n.depth=2),Qd(n.colors)&&(n.colors=!1),Qd(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=Ud),Hd(n,e,n.depth)}function Ud(e,t){var n=Kd.styles[t];return n?"["+Kd.colors[n][0]+"m"+e+"["+Kd.colors[n][1]+"m":e}function Fd(e,t){return e}function Hd(e,t,n){if(e.customInspect&&t&&iu(t.inspect)&&t.inspect!==Kd&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return Jd(r)||(r=Hd(e,r,n)),r}var i=function(e,t){if(Qd(t))return e.stylize("undefined","undefined");if(Jd(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return Zd(t)?e.stylize(""+t,"number"):Wd(t)?e.stylize(""+t,"boolean"):Gd(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),ru(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return zd(t);if(0===o.length){if(iu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(eu(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(nu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(ru(t))return zd(t)}var c,l="",d=!1,u=["{","}"];return Vd(t)&&(d=!0,u=["[","]"]),iu(t)&&(l=" [Function"+(t.name?": "+t.name:"")+"]"),eu(t)&&(l=" "+RegExp.prototype.toString.call(t)),nu(t)&&(l=" "+Date.prototype.toUTCString.call(t)),ru(t)&&(l=" "+zd(t)),0!==o.length||d&&0!=t.length?n<0?eu(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=d?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)hu(t,String(s))?o.push(qd(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(qd(e,t,n,r,i,!0))})),o}(e,t,n,s,o):o.map((function(r){return qd(e,t,n,s,r,d)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,l,u)):u[0]+l+u[1]}function zd(e){return"["+Error.prototype.toString.call(e)+"]"}function qd(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),hu(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=Gd(n)?Hd(e,c.value,null):Hd(e,c.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),Qd(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function Vd(e){return Array.isArray(e)}function Wd(e){return"boolean"==typeof e}function Gd(e){return null===e}function Yd(e){return null==e}function Zd(e){return"number"==typeof e}function Jd(e){return"string"==typeof e}function Xd(e){return"symbol"==typeof e}function Qd(e){return void 0===e}function eu(e){return tu(e)&&"[object RegExp]"===au(e)}function tu(e){return"object"==typeof e&&null!==e}function nu(e){return tu(e)&&"[object Date]"===au(e)}function ru(e){return tu(e)&&("[object Error]"===au(e)||e instanceof Error)}function iu(e){return"function"==typeof e}function ou(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function su(e){return et.isBuffer(e)}function au(e){return Object.prototype.toString.call(e)}function cu(e){return e<10?"0"+e.toString(10):e.toString(10)}Kd.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Kd.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var lu=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function du(){console.log("%s - %s",function(){var e=new Date,t=[cu(e.getHours()),cu(e.getMinutes()),cu(e.getSeconds())].join(":");return[e.getDate(),lu[e.getMonth()],t].join(" ")}(),Nd.apply(null,arguments))}function uu(e,t){if(!t||!tu(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function hu(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var fu="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function pu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(fu&&e[fu]){var t;if("function"!=typeof(t=e[fu]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,fu,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(e,r){e?n(e):t(r)}));try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),fu&&Object.defineProperty(t,fu,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,Pd(e))}function gu(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}function mu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function t(){for(var t=[],n=0;n<arguments.length;n++)t.push(arguments[n]);var r=t.pop();if("function"!=typeof r)throw new TypeError("The last argument must be of type Function");var i=this,o=function(){return r.apply(i,arguments)};e.apply(this,t).then((function(e){Dc.nextTick(o.bind(null,null,e))}),(function(e){Dc.nextTick(gu.bind(null,e,o))}))}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Pd(e)),t}pu.custom=fu;var yu,vu,bu,wu,Eu={inherits:Od,_extend:uu,log:du,isBuffer:su,isPrimitive:ou,isFunction:iu,isError:ru,isDate:nu,isObject:tu,isRegExp:eu,isUndefined:Qd,isSymbol:Xd,isString:Jd,isNumber:Zd,isNullOrUndefined:Yd,isNull:Gd,isBoolean:Wd,isArray:Vd,inspect:Kd,deprecate:Bd,format:Nd,debuglog:jd,promisify:pu,callbackify:mu},Cu=Ft(Object.freeze({__proto__:null,_extend:uu,callbackify:mu,debuglog:jd,default:Eu,deprecate:Bd,format:Nd,inherits:Od,inspect:Kd,isArray:Vd,isBoolean:Wd,isBuffer:su,isDate:nu,isError:ru,isFunction:iu,isNull:Gd,isNullOrUndefined:Yd,isNumber:Zd,isObject:tu,isPrimitive:ou,isRegExp:eu,isString:Jd,isSymbol:Xd,isUndefined:Qd,log:du,promisify:pu}));function _u(){if(vu)return yu;function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}vu=1;var i=Rd.Buffer,o=Cu.inspect,s=o&&o.custom||"inspect";return yu=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return function(e,t,n){t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return i.alloc(0);for(var t,n,r,o=i.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=o,r=a,i.prototype.copy.call(t,n,r),a+=s.data.length,s=s.next;return o}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=i.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,s),0==(e-=s)){s===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(s));break}++r}return this.length-=r,t}},{key:s,value:function(e,n){return o(this,t(t({},n),{},{depth:0,customInspect:!1}))}}]),e}(),yu}function Su(){if(wu)return bu;function e(e,r){n(e,r),t(e)}function t(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function n(e,t){e.emit("error",t)}return wu=1,bu={destroy:function(r,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(r):r&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Dc.nextTick(n,this,r)):Dc.nextTick(n,this,r)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(r||null,(function(n){!i&&n?o._writableState?o._writableState.errorEmitted?Dc.nextTick(t,o):(o._writableState.errorEmitted=!0,Dc.nextTick(e,o,n)):Dc.nextTick(e,o,n):i?(Dc.nextTick(t,o),i(n)):Dc.nextTick(t,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},bu}var ku,xu,Au={},Mu={};function Lu(e,t,n){n||(n=Error);var r=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);r.prototype.name=n.name,r.prototype.code=e,Mu[e]=r}function Tu(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function Ou(){if(xu)return ku;xu=1;var e=Au.codes.ERR_INVALID_OPT_VALUE;return ku={getHighWaterMark:function(t,n,r,i){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(n,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new e(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}}Lu("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),Lu("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,i,o;if("string"==typeof t&&(i="not ",t.substr(0,4)===i)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-9,n)===t}(e," argument"))o="The ".concat(e," ").concat(r," ").concat(Tu(t,"type"));else{var s=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+1>e.length)&&-1!==e.indexOf(".",n)}(e)?"property":"argument";o='The "'.concat(e,'" ').concat(s," ").concat(r," ").concat(Tu(t,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),Lu("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Lu("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),Lu("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Lu("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),Lu("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Lu("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Lu("ERR_STREAM_WRITE_AFTER_END","write after end"),Lu("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Lu("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),Lu("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Au.codes=Mu;var Ru,Pu,Iu,Nu,Bu,Du,$u="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},ju=Ft(Object.freeze({__proto__:null,default:$u}));function Ku(){if(Pu)return Ru;function e(e){try{if(!Kt.localStorage)return!1}catch(e){return!1}var t=Kt.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}return Pu=1,Ru=function(t,n){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(n);e("traceDeprecation")?console.trace(n):console.warn(n),r=!0}return t.apply(this,arguments)}},Ru}function Uu(){if(Nu)return Iu;function e(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(undefined),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var t;Nu=1,Iu=E,E.WritableState=w;var n,r={deprecate:Ku()},i=Td(),o=Rd.Buffer,s=(void 0!==Kt?Kt:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},a=Su(),c=Ou().getHighWaterMark,l=Au.codes,d=l.ERR_INVALID_ARG_TYPE,u=l.ERR_METHOD_NOT_IMPLEMENTED,h=l.ERR_MULTIPLE_CALLBACK,f=l.ERR_STREAM_CANNOT_PIPE,p=l.ERR_STREAM_DESTROYED,g=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,y=l.ERR_UNKNOWN_ENCODING,v=a.errorOrDestroy;function b(){}function w(n,r,i){t=t||Fu(),n=n||{},"boolean"!=typeof i&&(i=r instanceof t),this.objectMode=!!n.objectMode,i&&(this.objectMode=this.objectMode||!!n.writableObjectMode),this.highWaterMark=c(this,n,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===n.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=n.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new h;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(Dc.nextTick(i,r),Dc.nextTick(A,e,t),e._writableState.errorEmitted=!0,v(e,r)):(i(r),e._writableState.errorEmitted=!0,v(e,r),A(e,t))}(e,n,r,t,i);else{var o=k(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||S(e,n),r?Dc.nextTick(_,e,n,o,i):_(e,n,o,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==n.emitClose,this.autoDestroy=!!n.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}function E(e){var r=this instanceof(t=t||Fu());if(!r&&!n.call(E,this))return new E(e);this._writableState=new w(e,this,r),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),i.call(this)}function C(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new p("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function _(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),A(e,t)}function S(t,n){n.bufferProcessing=!0;var r=n.bufferedRequest;if(t._writev&&r&&r.next){var i=n.bufferedRequestCount,o=new Array(i),s=n.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,C(t,n,!0,n.length,o,"",s.finish),n.pendingcb++,n.lastBufferedRequest=null,s.next?(n.corkedRequestsFree=s.next,s.next=null):n.corkedRequestsFree=new e(n),n.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,d=r.encoding,u=r.callback;if(C(t,n,!1,n.objectMode?1:l.length,l,d,u),r=r.next,n.bufferedRequestCount--,n.writing)break}null===r&&(n.lastBufferedRequest=null)}n.bufferedRequest=r,n.bufferProcessing=!1}function k(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final((function(n){t.pendingcb--,n&&v(e,n),t.prefinished=!0,e.emit("prefinish"),A(e,t)}))}function A(e,t){var n=k(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,Dc.nextTick(x,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}return ju(E,i),w.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(w.prototype,"buffer",{get:r.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(e){return!!n.call(this,e)||this===E&&e&&e._writableState instanceof w}})):n=function(e){return e instanceof this},E.prototype.pipe=function(){v(this,new f)},E.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,c=!i.objectMode&&(r=e,o.isBuffer(r)||r instanceof s);return c&&!o.isBuffer(e)&&(e=function(e){return o.from(e)}(e)),"function"==typeof t&&(n=t,t=null),c?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=b),i.ending?function(e,t){var n=new m;v(e,n),Dc.nextTick(t,n)}(this,n):(c||function(e,t,n,r){var i;return null===n?i=new g:"string"==typeof n||t.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(v(e,i),Dc.nextTick(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,i,s){if(!n){var a=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=o.from(t,n)),t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var c=t.objectMode?1:r.length;t.length+=c;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:s,next:null},d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else C(e,t,!1,c,r,i,s);return l}(this,i,c,e,t,n)),a},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||S(this,e))},E.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new y(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(e,t,n){n(new u("_write()"))},E.prototype._writev=null,E.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,A(e,t),n&&(t.finished?Dc.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),E.prototype.destroy=a.destroy,E.prototype._undestroy=a.undestroy,E.prototype._destroy=function(e,t){t(e)},Iu}function Fu(){if(Du)return Bu;Du=1;var e=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};Bu=s;var t=ih(),n=Uu();ju(s,t);for(var r=e(n.prototype),i=0;i<r.length;i++){var o=r[i];s.prototype[o]||(s.prototype[o]=n.prototype[o])}function s(e){if(!(this instanceof s))return new s(e);t.call(this,e),n.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",a)))}function a(){this._writableState.ended||Dc.nextTick(c,this)}function c(e){e.end()}return Object.defineProperty(s.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(s.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(s.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(s.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),Bu}var Hu=et.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function zu(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Hu(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Vu;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Wu;break;default:return void(this.write=qu)}this.charBuffer=new et(6),this.charReceived=0,this.charLength=0}function qu(e){return e.toString(this.encoding)}function Vu(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Wu(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}zu.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(e=e.slice(n,e.length),!((r=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r,i=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),i=(t+=e.toString(this.encoding,0,i)).length-1,(r=t.charCodeAt(i))>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},zu.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},zu.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t};var Gu=Ft(Object.freeze({__proto__:null,StringDecoder:zu})),Yu=Au.codes.ERR_STREAM_PREMATURE_CLOSE;function Zu(){}var Ju,Xu,Qu,eh,th,nh,rh=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(r||Zu);var i=n.readable||!1!==n.readable&&t.readable,o=n.writable||!1!==n.writable&&t.writable,s=function(){t.writable||c()},a=t._writableState&&t._writableState.finished,c=function(){o=!1,a=!0,i||r.call(t)},l=t._readableState&&t._readableState.endEmitted,d=function(){i=!1,l=!0,o||r.call(t)},u=function(e){r.call(t,e)},h=function(){var e;return i&&!l?(t._readableState&&t._readableState.ended||(e=new Yu),r.call(t,e)):o&&!a?(t._writableState&&t._writableState.ended||(e=new Yu),r.call(t,e)):void 0},f=function(){t.req.on("finish",c)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",c),t.on("abort",h),t.req?f():t.on("request",f)):o&&!t._writableState&&(t.on("end",s),t.on("close",s)),t.on("end",d),t.on("finish",c),!1!==n.error&&t.on("error",u),t.on("close",h),function(){t.removeListener("complete",c),t.removeListener("abort",h),t.removeListener("request",f),t.req&&t.req.removeListener("finish",c),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",c),t.removeListener("end",d),t.removeListener("error",u),t.removeListener("close",h)}};function ih(){if(nh)return th;var e;nh=1,th=E,E.ReadableState=w,Pl.EventEmitter;var t,n=function(e,t){return e.listeners(t).length},r=Td(),i=Rd.Buffer,o=(void 0!==Kt?Kt:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},s=Cu;t=s&&s.debuglog?s.debuglog("stream"):function(){};var a,c,l,d=_u(),u=Su(),h=Ou().getHighWaterMark,f=Au.codes,p=f.ERR_INVALID_ARG_TYPE,g=f.ERR_STREAM_PUSH_AFTER_EOF,m=f.ERR_METHOD_NOT_IMPLEMENTED,y=f.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;ju(E,r);var v=u.errorOrDestroy,b=["error","close","destroy","pause","resume"];function w(t,n,r){e=e||Fu(),t=t||{},"boolean"!=typeof r&&(r=n instanceof e),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=h(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(a||(a=Gu.StringDecoder),this.decoder=new a(t.encoding),this.encoding=t.encoding)}function E(t){if(e=e||Fu(),!(this instanceof E))return new E(t);var n=this instanceof e;this._readableState=new w(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),r.call(this)}function C(e,n,r,s,a){t("readableAddChunk",n);var c,l=e._readableState;if(null===n)l.reading=!1,function(e,n){if(t("onEofChunk"),!n.ended){if(n.decoder){var r=n.decoder.end();r&&r.length&&(n.buffer.push(r),n.length+=n.objectMode?1:r.length)}n.ended=!0,n.sync?x(e):(n.needReadable=!1,n.emittedReadable||(n.emittedReadable=!0,A(e)))}}(e,l);else if(a||(c=function(e,t){var n,r;return r=t,i.isBuffer(r)||r instanceof o||"string"==typeof t||void 0===t||e.objectMode||(n=new p("chunk",["string","Buffer","Uint8Array"],t)),n}(l,n)),c)v(e,c);else if(l.objectMode||n&&n.length>0)if("string"==typeof n||l.objectMode||Object.getPrototypeOf(n)===i.prototype||(n=function(e){return i.from(e)}(n)),s)l.endEmitted?v(e,new y):_(e,l,n,!0);else if(l.ended)v(e,new g);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(n=l.decoder.write(n),l.objectMode||0!==n.length?_(e,l,n,!1):M(e,l)):_(e,l,n,!1)}else s||(l.reading=!1,M(e,l));return!l.ended&&(l.length<l.highWaterMark||0===l.length)}function _(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&x(e)),M(e,t)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),E.prototype.destroy=u.destroy,E.prototype._undestroy=u.undestroy,E.prototype._destroy=function(e,t){t(e)},E.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=i.from(e,t),t=""),n=!0),C(this,e,t,!1,n)},E.prototype.unshift=function(e){return C(this,e,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(e){a||(a=Gu.StringDecoder);var t=new a(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var S=1073741824;function k(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=S?e=S:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var n=e._readableState;t("emitReadable",n.needReadable,n.emittedReadable),n.needReadable=!1,n.emittedReadable||(t("emitReadable",n.flowing),n.emittedReadable=!0,Dc.nextTick(A,e))}function A(e){var n=e._readableState;t("emitReadable_",n.destroyed,n.length,n.ended),n.destroyed||!n.length&&!n.ended||(e.emit("readable"),n.emittedReadable=!1),n.needReadable=!n.flowing&&!n.ended&&n.length<=n.highWaterMark,P(e)}function M(e,t){t.readingMore||(t.readingMore=!0,Dc.nextTick(L,e,t))}function L(e,n){for(;!n.reading&&!n.ended&&(n.length<n.highWaterMark||n.flowing&&0===n.length);){var r=n.length;if(t("maybeReadMore read 0"),e.read(0),r===n.length)break}n.readingMore=!1}function T(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function O(e){t("readable nexttick read 0"),e.read(0)}function R(e,n){t("resume",n.reading),n.reading||e.read(0),n.resumeScheduled=!1,e.emit("resume"),P(e),n.flowing&&!n.reading&&e.read(0)}function P(e){var n=e._readableState;for(t("flow",n.flowing);n.flowing&&null!==e.read(););}function I(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function N(e){var n=e._readableState;t("endReadable",n.endEmitted),n.endEmitted||(n.ended=!0,Dc.nextTick(B,n,e))}function B(e,n){if(t("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,n.readable=!1,n.emit("end"),e.autoDestroy)){var r=n._writableState;(!r||r.autoDestroy&&r.finished)&&n.destroy()}}function D(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}return E.prototype.read=function(e){t("read",e),e=parseInt(e,10);var n=this._readableState,r=e;if(0!==e&&(n.emittedReadable=!1),0===e&&n.needReadable&&((0!==n.highWaterMark?n.length>=n.highWaterMark:n.length>0)||n.ended))return t("read: emitReadable",n.length,n.ended),0===n.length&&n.ended?N(this):x(this),null;if(0===(e=k(e,n))&&n.ended)return 0===n.length&&N(this),null;var i,o=n.needReadable;return t("need readable",o),(0===n.length||n.length-e<n.highWaterMark)&&t("length less than watermark",o=!0),n.ended||n.reading?t("reading or ended",o=!1):o&&(t("do read"),n.reading=!0,n.sync=!0,0===n.length&&(n.needReadable=!0),this._read(n.highWaterMark),n.sync=!1,n.reading||(e=k(r,n))),null===(i=e>0?I(e,n):null)?(n.needReadable=n.length<=n.highWaterMark,e=0):(n.length-=e,n.awaitDrain=0),0===n.length&&(n.ended||(n.needReadable=!0),r!==e&&n.ended&&N(this)),null!==i&&this.emit("data",i),i},E.prototype._read=function(e){v(this,new m("_read()"))},E.prototype.pipe=function(e,r){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,t("pipe count=%d opts=%j",o.pipesCount,r);var s=r&&!1===r.end||e===Dc.stdout||e===Dc.stderr?p:a;function a(){t("onend"),e.end()}o.endEmitted?Dc.nextTick(s):i.once("end",s),e.on("unpipe",(function n(r,s){t("onunpipe"),r===i&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,t("cleanup"),e.removeListener("close",h),e.removeListener("finish",f),e.removeListener("drain",c),e.removeListener("error",u),e.removeListener("unpipe",n),i.removeListener("end",a),i.removeListener("end",p),i.removeListener("data",d),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}));var c=function(e){return function(){var r=e._readableState;t("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,0===r.awaitDrain&&n(e,"data")&&(r.flowing=!0,P(e))}}(i);e.on("drain",c);var l=!1;function d(n){t("ondata");var r=e.write(n);t("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==D(o.pipes,e))&&!l&&(t("false write response, pause",o.awaitDrain),o.awaitDrain++),i.pause())}function u(r){t("onerror",r),p(),e.removeListener("error",u),0===n(e,"error")&&v(e,r)}function h(){e.removeListener("finish",f),p()}function f(){t("onfinish"),e.removeListener("close",h),p()}function p(){t("unpipe"),i.unpipe(e)}return i.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",u),e.once("close",h),e.once("finish",f),e.emit("pipe",i),o.flowing||(t("pipe resume"),i.resume()),e},E.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=D(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},E.prototype.on=function(e,n){var i=r.prototype.on.call(this,e,n),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,t("on readable",o.length,o.reading),o.length?x(this):o.reading||Dc.nextTick(O,this))),i},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(e,t){var n=r.prototype.removeListener.call(this,e,t);return"readable"===e&&Dc.nextTick(T,this),n},E.prototype.removeAllListeners=function(e){var t=r.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||Dc.nextTick(T,this),t},E.prototype.resume=function(){var e=this._readableState;return e.flowing||(t("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Dc.nextTick(R,e,t))}(this,e)),e.paused=!1,this},E.prototype.pause=function(){return t("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(t("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},E.prototype.wrap=function(e){var n=this,r=this._readableState,i=!1;for(var o in e.on("end",(function(){if(t("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&n.push(e)}n.push(null)})),e.on("data",(function(o){t("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o||(r.objectMode||o&&o.length)&&(n.push(o)||(i=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var s=0;s<b.length;s++)e.on(b[s],this.emit.bind(this,b[s]));return this._read=function(n){t("wrapped _read",n),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===c&&(c=function(){if(Xu)return Ju;var e;function t(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Xu=1;var n=rh,r=Symbol("lastResolve"),i=Symbol("lastReject"),o=Symbol("error"),s=Symbol("ended"),a=Symbol("lastPromise"),c=Symbol("handlePromise"),l=Symbol("stream");function d(e,t){return{value:e,done:t}}function u(e){var t=e[r];if(null!==t){var n=e[l].read();null!==n&&(e[a]=null,e[r]=null,e[i]=null,t(d(n,!1)))}}function h(e){Dc.nextTick(u,e)}var f=Object.getPrototypeOf((function(){})),p=Object.setPrototypeOf((t(e={get stream(){return this[l]},next:function(){var e=this,t=this[o];if(null!==t)return Promise.reject(t);if(this[s])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise((function(t,n){Dc.nextTick((function(){e[o]?n(e[o]):t(d(void 0,!0))}))}));var n,r=this[a];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[s]?n(d(void 0,!0)):t[c](n,r)}),r)}}(r,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(d(i,!1));n=new Promise(this[c])}return this[a]=n,n}},Symbol.asyncIterator,(function(){return this})),t(e,"return",(function(){var e=this;return new Promise((function(t,n){e[l].destroy(null,(function(e){e?n(e):t(d(void 0,!0))}))}))})),e),f);return Ju=function(e){var u,f=Object.create(p,(t(u={},l,{value:e,writable:!0}),t(u,r,{value:null,writable:!0}),t(u,i,{value:null,writable:!0}),t(u,o,{value:null,writable:!0}),t(u,s,{value:e._readableState.endEmitted,writable:!0}),t(u,c,{value:function(e,t){var n=f[l].read();n?(f[a]=null,f[r]=null,f[i]=null,e(d(n,!1))):(f[r]=e,f[i]=t)},writable:!0}),u));return f[a]=null,n(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=f[i];return null!==t&&(f[a]=null,f[r]=null,f[i]=null,t(e)),void(f[o]=e)}var n=f[r];null!==n&&(f[a]=null,f[r]=null,f[i]=null,n(d(void 0,!0))),f[s]=!0})),e.on("readable",h.bind(null,f)),f},Ju}()),c(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),E._fromList=I,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(E.from=function(e,t){return void 0===l&&(l=eh?Qu:(eh=1,Qu=function(){throw new Error("Readable.from is not available in the browser")})),l(E,e,t)}),th}var oh=fh,sh=Au.codes,ah=sh.ERR_METHOD_NOT_IMPLEMENTED,ch=sh.ERR_MULTIPLE_CALLBACK,lh=sh.ERR_TRANSFORM_ALREADY_TRANSFORMING,dh=sh.ERR_TRANSFORM_WITH_LENGTH_0,uh=Fu();function hh(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new ch);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function fh(e){if(!(this instanceof fh))return new fh(e);uh.call(this,e),this._transformState={afterTransform:hh.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",ph)}function ph(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?gh(this,null,null):this._flush((function(t,n){gh(e,t,n)}))}function gh(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new dh;if(e._transformState.transforming)throw new lh;return e.push(null)}ju(fh,uh),fh.prototype.push=function(e,t){return this._transformState.needTransform=!1,uh.prototype.push.call(this,e,t)},fh.prototype._transform=function(e,t,n){n(new ah("_transform()"))},fh.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},fh.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},fh.prototype._destroy=function(e,t){uh.prototype._destroy.call(this,e,(function(e){t(e)}))};var mh,yh=bh,vh=oh;function bh(e){if(!(this instanceof bh))return new bh(e);vh.call(this,e)}ju(bh,vh),bh.prototype._transform=function(e,t,n){n(null,e)};var wh=Au.codes,Eh=wh.ERR_MISSING_ARGS,Ch=wh.ERR_STREAM_DESTROYED;function _h(e){if(e)throw e}function Sh(e){e()}function kh(e,t){return e.pipe(t)}var xh=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=function(e){return e.length?"function"!=typeof e[e.length-1]?_h:e.pop():_h}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Eh("streams");var o=t.map((function(e,n){var s=n<t.length-1;return function(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var i=!1;e.on("close",(function(){i=!0})),void 0===mh&&(mh=rh),mh(e,{readable:t,writable:n},(function(e){if(e)return r(e);i=!0,r()}));var o=!1;return function(t){if(!i&&!o)return o=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new Ch("pipe"))}}(e,s,n>0,(function(e){r||(r=e),e&&o.forEach(Sh),s||(o.forEach(Sh),i(r))}))}));return t.reduce(kh)};!function(e,t){(t=Ld.exports=ih()).Stream=t,t.Readable=t,t.Writable=Uu(),t.Duplex=Fu(),t.Transform=oh,t.PassThrough=yh,t.finished=rh,t.pipeline=xh}(0,Ld.exports);var Ah=Ld.exports;var Mh={},Lh={exports:{}},Th=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach((function(e){r[e]=i[e]})),r}};function Oh(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Rh(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}Lh.exports=Th(Oh),Lh.exports.strict=Th(Rh),Oh.proto=Oh((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Oh(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Rh(this)},configurable:!0})}));var Ph=Lh.exports,Ih={};Object.defineProperty(Ih,"__esModule",{value:!0}),Ih.Substream=void 0;const Nh=Ah;class Bh extends Nh.Duplex{constructor({parent:e,name:t}){super({objectMode:!0}),this._parent=e,this._name=t}_read(){}_write(e,t,n){this._parent.push({name:this._name,data:e}),n()}}Ih.Substream=Bh;var Dh=Kt&&Kt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.ObjectMultiplex=void 0;const $h=Ah,jh=Dh(Ph),Kh=Ih,Uh=Symbol("IGNORE_SUBSTREAM");let Fh=class extends $h.Duplex{constructor(e={}){super(Object.assign(Object.assign({},e),{objectMode:!0})),this._substreams={}}createStream(e){if(this.destroyed)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already destroyed`);if(this._readableState.ended||this._writableState.ended)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already ended`);if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);const t=new Kh.Substream({parent:this,name:e});return this._substreams[e]=t,function(e,t){const n=(0,jh.default)(t);(0,$h.finished)(e,{readable:!1},n),(0,$h.finished)(e,{writable:!1},n)}(this,(e=>t.destroy(e||void 0))),t}ignoreStream(e){if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);this._substreams[e]=Uh}_read(){}_write(e,t,n){const{name:r,data:i}=e;if(!r)return console.warn(`ObjectMultiplex - malformed chunk without name "${e}"`),n();const o=this._substreams[r];return o?(o!==Uh&&o.push(i),n()):(console.warn(`ObjectMultiplex - orphaned data for stream "${r}"`),n())}};Mh.ObjectMultiplex=Fh;var Hh=Ut(Mh.ObjectMultiplex);const zh=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;zh.writable=e=>zh(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState,zh.readable=e=>zh(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState,zh.duplex=e=>zh.writable(e)&&zh.readable(e),zh.transform=e=>zh.duplex(e)&&"function"==typeof e._transform;var qh,Vh=zh,Wh=class extends Md{constructor(e,{jsonRpcStreamName:t,logger:n=console,maxEventListeners:r=100,rpcMiddleware:i=[]}){if(super({logger:n,maxEventListeners:r,rpcMiddleware:i}),!Vh.duplex(e))throw new Error(Ra.errors.invalidDuplexStream());this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this);const o=new Hh;Ah.pipeline(e,o,e,this._handleStreamDisconnect.bind(this,"MetaMask")),this._jsonRpcConnection=function(e={}){const t={},n=new Ah.Duplex({objectMode:!0,read:()=>{},write:function(n,o,s){let a=null;try{n.id?function(e){const{id:n}=e;if(null===n)return;const r=t[n];r?(delete t[n],Object.assign(r.res,e),setTimeout(r.end)):console.warn(`StreamMiddleware - Unknown response id "${n}"`)}(n):function(n){e?.retryOnMessage&&n.method===e.retryOnMessage&&Object.values(t).forEach((({req:e,retryCount:n=0})=>{if(!e.id)return;if(n>=3)throw new Error(`StreamMiddleware - Retry limit exceeded for request id "${e.id}"`);const r=t[e.id];r&&(r.retryCount=n+1),i(e)})),r.emit("notification",n)}(n)}catch(e){a=e}s(a)}}),r=new nd;return{events:r,middleware:(e,n,r,o)=>{t[e.id]={req:e,res:n,next:r,end:o},i(e)},stream:n};function i(e){n.push(e)}}({retryOnMessage:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}),Ah.pipeline(this._jsonRpcConnection.stream,o.createStream(t),this._jsonRpcConnection.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider")),this._rpcEngine.push(this._jsonRpcConnection.middleware),this._jsonRpcConnection.events.on("notification",(t=>{const{method:n,params:r}=t;"metamask_accountsChanged"===n?this._handleAccountsChanged(r):"metamask_unlockStateChanged"===n?this._handleUnlockStateChanged(r):"metamask_chainChanged"===n?this._handleChainChanged(r):sd.includes(n)?this.emit("message",{type:n,data:r}):"METAMASK_STREAM_FAILURE"===n&&e.destroy(new Error(Ra.errors.permanentlyDisconnected()))}))}async _initializeStateAsync(){let e;try{e=await this.request({method:"metamask_getProviderState"})}catch(e){this._log.error("MetaMask: Failed to get initial state. Please report this bug.",e)}this._initializeState(e)}_handleStreamDisconnect(e,t){let n=`MetaMask: Lost connection to "${e}".`;t?.stack&&(n+=`\n${t.stack}`),this._log.warn(n),this.listenerCount("error")>0&&this.emit("error",n),this._handleDisconnect(!1,t?t.message:void 0)}_handleChainChanged({chainId:e,networkVersion:t}={}){dd(e)&&(e=>Boolean(e)&&"string"==typeof e)(t)?"loading"===t?this._handleDisconnect(!0):super._handleChainChanged({chainId:e}):this._log.error(Ra.errors.invalidNetworkParams(),{chainId:e,networkVersion:t})}},Gh=class extends Wh{constructor(e,{jsonRpcStreamName:t="metamask-provider",logger:n=console,maxEventListeners:r=100,shouldSendMetadata:i}={}){if(super(e,{jsonRpcStreamName:t,logger:n,maxEventListeners:r,rpcMiddleware:ad(n)}),this._sentWarnings={chainId:!1,networkVersion:!1,selectedAddress:!1,enable:!1,experimentalMethods:!1,send:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}},vd(this,qh,void 0),this._initializeStateAsync(),bd(this,qh,null),this.isMetaMask=!0,this._sendSync=this._sendSync.bind(this),this.enable=this.enable.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this._warnOfDeprecation=this._warnOfDeprecation.bind(this),this._metamask=this._getExperimentalApi(),this._jsonRpcConnection.events.on("notification",(e=>{const{method:t}=e;sd.includes(t)&&(this.emit("data",e),this.emit("notification",e.params.result))})),i)if("complete"===document.readyState)hd(this._rpcEngine,this._log);else{const e=()=>{hd(this._rpcEngine,this._log),window.removeEventListener("DOMContentLoaded",e)};window.addEventListener("DOMContentLoaded",e)}}get chainId(){return this._sentWarnings.chainId||(this._log.warn(Ra.warnings.chainIdDeprecation),this._sentWarnings.chainId=!0),super.chainId}get networkVersion(){return this._sentWarnings.networkVersion||(this._log.warn(Ra.warnings.networkVersionDeprecation),this._sentWarnings.networkVersion=!0),yd(this,qh)}get selectedAddress(){return this._sentWarnings.selectedAddress||(this._log.warn(Ra.warnings.selectedAddressDeprecation),this._sentWarnings.selectedAddress=!0),super.selectedAddress}sendAsync(e,t){this._rpcRequest(e,t)}addListener(e,t){return this._warnOfDeprecation(e),super.addListener(e,t)}on(e,t){return this._warnOfDeprecation(e),super.on(e,t)}once(e,t){return this._warnOfDeprecation(e),super.once(e,t)}prependListener(e,t){return this._warnOfDeprecation(e),super.prependListener(e,t)}prependOnceListener(e,t){return this._warnOfDeprecation(e),super.prependOnceListener(e,t)}_handleDisconnect(e,t){super._handleDisconnect(e,t),yd(this,qh)&&!e&&bd(this,qh,null)}_warnOfDeprecation(e){!1===this._sentWarnings?.events[e]&&(this._log.warn(Ra.warnings.events[e]),this._sentWarnings.events[e]=!0)}async enable(){return this._sentWarnings.enable||(this._log.warn(Ra.warnings.enableDeprecation),this._sentWarnings.enable=!0),new Promise(((e,t)=>{try{this._rpcRequest({method:"eth_requestAccounts",params:[]},ld(e,t))}catch(e){t(e)}}))}send(e,t){return this._sentWarnings.send||(this._log.warn(Ra.warnings.sendDeprecation),this._sentWarnings.send=!0),"string"!=typeof e||t&&!Array.isArray(t)?e&&"object"==typeof e&&"function"==typeof t?this._rpcRequest(e,t):this._sendSync(e):new Promise(((n,r)=>{try{this._rpcRequest({method:e,params:t},ld(n,r,!1))}catch(e){r(e)}}))}_sendSync(e){let t;switch(e.method){case"eth_accounts":t=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":t=this.selectedAddress??null;break;case"eth_uninstallFilter":this._rpcRequest(e,ud),t=!0;break;case"net_version":t=yd(this,qh)??null;break;default:throw new Error(Ra.errors.unsupportedSync(e.method))}return{id:e.id,jsonrpc:e.jsonrpc,result:t}}_getExperimentalApi(){return new Proxy({isUnlocked:async()=>(this._state.initialized||await new Promise((e=>{this.on("_initialized",(()=>e()))})),this._state.isUnlocked),requestBatch:async e=>{if(!Array.isArray(e))throw Sl({message:"Batch requests must be made with an array of request objects.",data:e});return new Promise(((t,n)=>{this._rpcRequest(e,ld(t,n))}))}},{get:(e,t,...n)=>(this._sentWarnings.experimentalMethods||(this._log.warn(Ra.warnings.experimentalMethods),this._sentWarnings.experimentalMethods=!0),Reflect.get(e,t,...n))})}_handleChainChanged({chainId:e,networkVersion:t}={}){super._handleChainChanged({chainId:e,networkVersion:t}),this._state.isConnected&&t!==yd(this,qh)&&(bd(this,qh,t),this._state.initialized&&this.emit("networkChanged",yd(this,qh)))}};qh=new WeakMap;const Yh=f("MM_SDK");Yh.color="#FFAC1C";var Zh={},Jh={};Object.defineProperty(Jh,"__esModule",{value:!0}),Jh.EthereumProviderError=Jh.EthereumRpcError=void 0;const Xh=cl;class Qh extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a nonempty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}toString(){return Xh.default(this.serialize(),ef,2)}}function ef(e,t){if("[Circular]"!==t)return t}Jh.EthereumRpcError=Qh,Jh.EthereumProviderError=class extends Qh{constructor(e,t,n){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}};var tf={},nf={};Object.defineProperty(nf,"__esModule",{value:!0}),nf.errorValues=nf.errorCodes=void 0,nf.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},nf.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=nf,n=Jh,r=t.errorCodes.rpc.internal,i={code:r,message:o(r)};function o(n,r="Unspecified error message. This is a bug, please report it."){if(Number.isInteger(n)){const r=n.toString();if(l(t.errorValues,r))return t.errorValues[r].message;if(a(n))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return r}function s(e){if(!Number.isInteger(e))return!1;const n=e.toString();return!!t.errorValues[n]||!!a(e)}function a(e){return e>=-32099&&e<=-32e3}function c(e){return e&&"object"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function l(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",e.getMessageFromCode=o,e.isValidCode=s,e.serializeError=function(e,{fallbackError:t=i,shouldIncludeStack:r=!1}={}){var a,d;if(!t||!Number.isInteger(t.code)||"string"!=typeof t.message)throw new Error("Must provide fallback error with integer number code and string message.");if(e instanceof n.EthereumRpcError)return e.serialize();const u={};if(e&&"object"==typeof e&&!Array.isArray(e)&&l(e,"code")&&s(e.code)){const t=e;u.code=t.code,t.message&&"string"==typeof t.message?(u.message=t.message,l(t,"data")&&(u.data=t.data)):(u.message=o(u.code),u.data={originalError:c(e)})}else{u.code=t.code;const n=null===(a=e)||void 0===a?void 0:a.message;u.message=n&&"string"==typeof n?n:t.message,u.data={originalError:c(e)}}const h=null===(d=e)||void 0===d?void 0:d.stack;return r&&e&&h&&"string"==typeof h&&(u.stack=h),u}}(tf);var rf={};Object.defineProperty(rf,"__esModule",{value:!0}),rf.ethErrors=void 0;const of=Jh,sf=tf,af=nf;function cf(e,t){const[n,r]=df(t);return new of.EthereumRpcError(e,n||sf.getMessageFromCode(e),r)}function lf(e,t){const[n,r]=df(t);return new of.EthereumProviderError(e,n||sf.getMessageFromCode(e),r)}function df(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}rf.ethErrors={rpc:{parse:e=>cf(af.errorCodes.rpc.parse,e),invalidRequest:e=>cf(af.errorCodes.rpc.invalidRequest,e),invalidParams:e=>cf(af.errorCodes.rpc.invalidParams,e),methodNotFound:e=>cf(af.errorCodes.rpc.methodNotFound,e),internal:e=>cf(af.errorCodes.rpc.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return cf(t,e)},invalidInput:e=>cf(af.errorCodes.rpc.invalidInput,e),resourceNotFound:e=>cf(af.errorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>cf(af.errorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>cf(af.errorCodes.rpc.transactionRejected,e),methodNotSupported:e=>cf(af.errorCodes.rpc.methodNotSupported,e),limitExceeded:e=>cf(af.errorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>lf(af.errorCodes.provider.userRejectedRequest,e),unauthorized:e=>lf(af.errorCodes.provider.unauthorized,e),unsupportedMethod:e=>lf(af.errorCodes.provider.unsupportedMethod,e),disconnected:e=>lf(af.errorCodes.provider.disconnected,e),chainDisconnected:e=>lf(af.errorCodes.provider.chainDisconnected,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new of.EthereumProviderError(t,n,r)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMessageFromCode=e.serializeError=e.EthereumProviderError=e.EthereumRpcError=e.ethErrors=e.errorCodes=void 0;const t=Jh;Object.defineProperty(e,"EthereumRpcError",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,"EthereumProviderError",{enumerable:!0,get:function(){return t.EthereumProviderError}});const n=tf;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=rf;Object.defineProperty(e,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=nf;Object.defineProperty(e,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(Zh);var uf={exports:{}};uf.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=90)}({17:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=n(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},e.getSecondMatch=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},e.matchAndReturnConst=function(e,t,n){if(e.test(t))return n},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,n,r){void 0===r&&(r=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(n),s=Math.max(i,o),a=0,c=e.map([t,n],(function(t){var n=s-e.getVersionPrecision(t),r=t+new Array(n+1).join(".0");return e.map(r.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(r&&(a=s-Math.min(i,o)),s-=1;s>=a;){if(c[0][s]>c[1][s])return 1;if(c[0][s]===c[1][s]){if(s===a)return 0;s-=1}else if(c[0][s]<c[1][s])return-1}},e.map=function(e,t){var n,r=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n+=1)r.push(t(e[n]));return r},e.find=function(e,t){var n,r;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,r=e.length;n<r;n+=1){var i=e[n];if(t(i,n))return i}},e.assign=function(e){for(var t,n,r=e,i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];if(Object.assign)return Object.assign.apply(Object,[e].concat(o));var a=function(){var e=o[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){r[t]=e[t]}))};for(t=0,n=o.length;t<n;t+=1)a();return e},e.getBrowserAlias=function(e){return r.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return r.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,n){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(91))&&r.__esModule?r:{default:r},o=n(18);function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var a=function(){function e(){}var t,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return o.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return o.ENGINE_MAP}},{key:"OS_MAP",get:function(){return o.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return o.PLATFORMS_MAP}}],null&&s(t.prototype,null),n&&s(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=c(n(92)),i=c(n(93)),o=c(n(94)),s=c(n(95)),a=c(n(17));function c(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(r.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,n={},r=0,i={},o=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(i[t]=s,o+=1):"object"==typeof s&&(n[t]=s,r+=1)})),r>0){var s=Object.keys(n),c=a.default.find(s,(function(e){return t.isOS(e)}));if(c){var l=this.satisfies(n[c]);if(void 0!==l)return l}var d=a.default.find(s,(function(e){return t.isPlatform(e)}));if(d){var u=this.satisfies(n[d]);if(void 0!==u)return u}}if(o>0){var h=Object.keys(i),f=a.default.find(h,(function(e){return t.isBrowser(e,!0)}));if(void 0!==f)return this.compareVersion(i[f])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),r=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(r);return t&&i&&(r=i.toLowerCase()),r===n},t.compareVersion=function(e){var t=[0],n=e,r=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(r=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(r=!0,n=e.substr(1)),t.indexOf(a.default.compareVersions(i,n,r))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=l,e.exports=t.default},92:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=/version\/(\d+(\.?_?\d+)+)/i,s=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},n=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},n=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},n=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},n=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},n=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},n=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},n=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},n=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},n=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},n=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},n=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},n=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},n=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},n=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},n=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},n=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},n=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},n=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},n=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},n=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},n=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},n=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},n=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:"Android Browser"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=s,e.exports=t.default},93:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},n=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=i.default.getMacOSVersionName(t),r={name:o.OS_MAP.MacOS,version:t};return n&&(r.versionName=n),r}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=i.default.getAndroidVersionName(t),r={name:o.OS_MAP.Android,version:t};return n&&(r.versionName=n),r}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:o.OS_MAP.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},n=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},n=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},n=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},n=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];t.default=s,e.exports=t.default}});var hf=Ut(uf.exports);const ff={Initialized:"initialized",DisplayURI:"display_uri",ProviderUpdate:"provider_update",ConnectWithResponse:"connectWithResponse",ConnectionStatus:"connection_status",ServiceStatus:"service_status"};class pf{constructor({shouldSetOnWindow:e,connectionStream:t,shouldSendMetadata:n=!1,shouldShimWeb3:r,sdkInstance:i}){const o=new yf({connectionStream:t,shouldSendMetadata:n,shouldSetOnWindow:e,shouldShimWeb3:r,autoRequestAccounts:!1}),s=new Proxy(o,{deleteProperty:()=>!0});if(this.provider=s,this.sdkInstance=i,e&&"undefined"!=typeof window)try{a=o,window.ethereum=a,window.dispatchEvent(new Event("ethereum#initialized"))}catch(e){Yh("[Ethereum] Unable to set global provider - window.ethereum may be read-only",e)}var a;if(r&&"undefined"!=typeof window)try{!function(e,t=console){let n=!1,r=!1;if(!window.web3){const i="__isMetaMaskShim__";let o={currentProvider:e};Object.defineProperty(o,i,{value:!0,enumerable:!0,configurable:!1,writable:!1}),o=new Proxy(o,{get:(o,s,...a)=>("currentProvider"!==s||n?"currentProvider"===s||s===i||r||(r=!0,t.error("MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),e.request({method:"metamask_logWeb3ShimUsage"}).catch((e=>{t.debug("MetaMask: Failed to log web3 shim usage.",e)}))):(n=!0,t.warn("You are accessing the MetaMask window.web3.currentProvider shim. This property is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3")),Reflect.get(o,s,...a)),set:(...e)=>(t.warn("You are accessing the MetaMask window.web3 shim. This object is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),Reflect.set(...e))}),Object.defineProperty(window,"web3",{value:o,enumerable:!1,configurable:!0,writable:!0})}}(this.provider)}catch(e){Yh("[Ethereum] Unable to shim web3 - window.web3 may be read-only",e)}this.provider.on("display_uri",(e=>{this.sdkInstance.emit(ff.DisplayURI,e)})),this.provider.on("_initialized",(()=>{const e={chainId:this.provider.getChainId(),isConnected:this.provider.isConnected(),isMetaMask:this.provider.isMetaMask,selectedAddress:this.provider.getSelectedAddress(),networkVersion:this.provider.getNetworkVersion()};this.sdkInstance.emit(ff.Initialized,e),Yh("[Ethereum: constructor()] provider initialized",e)}))}static init(e){var t;return Yh("[Ethereum: init()] Initializing Ethereum service"),this.instance=new pf(e),null===(t=this.instance)||void 0===t?void 0:t.provider}static destroy(){}static getInstance(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance}static getProvider(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance.provider}}class gf{constructor({useDeepLink:e,preferredOpenLink:t,debug:n=!1}){this.state={platformType:void 0,useDeeplink:!1,preferredOpenLink:void 0,debug:!1},this.state.platformType=this.getPlatformType(),this.state.useDeeplink=e,this.state.preferredOpenLink=t,this.state.debug=n}openDeeplink(e,t,n){return function(e,t,n,r){const{state:i}=e;Yh(`[PlatfformManager: openDeeplink()] universalLink --\x3e ${t}`),Yh(`[PlatfformManager: openDeeplink()] deepLink --\x3e ${n}`);try{if(i.preferredOpenLink)return void i.preferredOpenLink(i.useDeeplink?n:t,r);if(Yh(`[PlatfformManager: openDeeplink()] open link now useDeepLink=${i.useDeeplink} link=${i.useDeeplink?n:t}`),i.useDeeplink)"undefined"!=typeof window&&(window.location.href=n);else if("undefined"!=typeof document){const e=document.createElement("a");e.href=t,e.target="_self",e.rel="noreferrer noopener",e.click()}}catch(e){console.log("[PlatfformManager: openDeeplink()] can't open link",e)}}(this,e,t,n)}isReactNative(){var e;return this.isNotBrowser()&&"undefined"!=typeof window&&(null===window||void 0===window?void 0:window.navigator)&&"ReactNative"===(null===(e=window.navigator)||void 0===e?void 0:e.product)}isMetaMaskInstalled(){return function(){const e=pf.getProvider()||(null===window||void 0===window?void 0:window.ethereum);return Yh(`[PlatfformManager: isMetaMaskInstalled()] isMetaMask=${null==e?void 0:e.isMetaMask} isConnected=${null==e?void 0:e.isConnected()}`),(null==e?void 0:e.isMetaMask)&&(null==e?void 0:e.isConnected())}()}isDesktopWeb(){return this.isBrowser()&&!this.isMobileWeb()}isMobile(){var e,t;const n=hf.parse(window.navigator.userAgent);return"mobile"===(null===(e=null==n?void 0:n.platform)||void 0===e?void 0:e.type)||"tablet"===(null===(t=null==n?void 0:n.platform)||void 0===t?void 0:t.type)}isSecure(){return this.isReactNative()||this.isMobileWeb()}isMetaMaskMobileWebView(){return"undefined"!=typeof window&&Boolean(window.ReactNativeWebView)&&Boolean(navigator.userAgent.endsWith("MetaMaskMobile"))}isMobileWeb(){return this.state.platformType===ga.MobileWeb}static isNotBrowser(){var e;return"undefined"==typeof window||!(null===window||void 0===window?void 0:window.navigator)||void 0!==je&&"ReactNative"===(null===(e=null==je?void 0:je.navigator)||void 0===e?void 0:e.product)||"ReactNative"===(null===navigator||void 0===navigator?void 0:navigator.product)}isNotBrowser(){return gf.isNotBrowser()}static isBrowser(){return!this.isNotBrowser()}isBrowser(){return gf.isBrowser()}isNodeJS(){return this.isNotBrowser()&&!this.isReactNative()}isUseDeepLink(){return this.state.useDeeplink}getPlatformType(){return function(e){const{state:t}=e;return t.platformType?t.platformType:e.isReactNative()?ga.ReactNative:e.isNotBrowser()?ga.NonBrowser:e.isMetaMaskMobileWebView()?ga.MetaMaskMobileWebview:e.isMobile()?ga.MobileWeb:ga.DesktopWeb}(this)}}const mf=e=>$e(void 0,void 0,void 0,(function*(){if(gf.isBrowser()){const{StorageManagerWeb:t}=yield Promise.resolve().then((function(){return mp}));return new t(e)}const t={persistChannelConfig:()=>$e(void 0,void 0,void 0,(function*(){})),getPersistedChannelConfig:()=>$e(void 0,void 0,void 0,(function*(){})),persistAccounts:()=>$e(void 0,void 0,void 0,(function*(){})),getCachedAccounts:()=>$e(void 0,void 0,void 0,(function*(){return[]})),persistChainId:()=>$e(void 0,void 0,void 0,(function*(){})),getCachedChainId:()=>$e(void 0,void 0,void 0,(function*(){})),terminate:()=>$e(void 0,void 0,void 0,(function*(){}))};return Promise.resolve(t)}));class yf extends Gh{constructor({connectionStream:e,shouldSendMetadata:t,autoRequestAccounts:n=!1}){super(e,{logger:console,maxEventListeners:100,shouldSendMetadata:t}),this.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:"",networkVersion:""},Yh(`[SDKProvider: constructor()] autoRequestAccounts=${n}`),this.state.autoRequestAccounts=n}forceInitializeState(){return $e(this,void 0,void 0,(function*(){return Yh(`[SDKProvider: forceInitializeState()] autoRequestAccounts=${this.state.autoRequestAccounts}`),this._initializeStateAsync()}))}_setConnected(){Yh("[SDKProvider: _setConnected()] Setting connected state"),this._state.isConnected=!0}getState(){return this._state}getSDKProviderState(){return this.state}getSelectedAddress(){var e;const{accounts:t}=this._state;return t&&0!==t.length?(null===(e=t[0])||void 0===e?void 0:e.toLowerCase())||"":(Yh("[SDKProvider: getSelectedAddress] No accounts found"),null)}getChainId(){return this.state.chainId}getNetworkVersion(){return this.state.networkVersion}setSDKProviderState(e){this.state=Object.assign(Object.assign({},this.state),e)}handleAccountsChanged(e,t){return this._handleAccountsChanged(e,t)}handleDisconnect({terminate:e=!1}){!function({terminate:e=!1,instance:t}){const{state:n}=t;Yh(`[SDKProvider: handleDisconnect()] cleaning up provider state terminate=${e}`,t),e&&(t._state.accounts=null,t._state.isUnlocked=!1,t._state.isPermanentlyDisconnected=!0,t._state.initialized=!1),t._handleAccountsChanged([]),t._state.isConnected=!1,t.emit("disconnect",Zh.ethErrors.provider.disconnected()),n.providerStateRequested=!1}({terminate:e,instance:this})}_initializeStateAsync(){return $e(this,void 0,void 0,(function*(){return function(e){var t,n;return $e(this,void 0,void 0,(function*(){void 0===e.state&&(e.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:""});const{state:r}=e;let i;if(r.providerStateRequested)Yh("[SDKProvider: initializeStateAsync()] initialization already in progress");else{let o;r.providerStateRequested=!0;let s=null,a=!1,c=!1;const l=yield mf({enabled:!0});if(l){const e=yield l.getPersistedChannelConfig({});a=null!==(t=null==e?void 0:e.relayPersistence)&&void 0!==t&&t,o=yield l.getCachedChainId();const n=yield l.getCachedAccounts();n.length>0&&(s=n[0])}if(Yh(`[SDKProvider: initializeStateAsync()] relayPersistence=${a}`,{relayPersistence:a,cachedChainId:o,cachedSelectedAddress:s}),a)if(o&&s)i={accounts:[s],chainId:o,isUnlocked:!1},c=!0;else try{i=yield e.request({method:"metamask_getProviderState"})}catch(t){return e._log.error("MetaMask: Failed to get initial state. Please report this bug.",t),void(r.providerStateRequested=!1)}if(0===(null===(n=null==i?void 0:i.accounts)||void 0===n?void 0:n.length))if(e.getSelectedAddress())i.accounts=[e.getSelectedAddress()];else{Yh("[SDKProvider: initializeStateAsync()] Fetch accounts remotely.");const t=yield e.request({method:"eth_requestAccounts",params:[]});i.accounts=t}e._initializeState(i),r.providerStateRequested=!1,c&&(e._state.isConnected=!0,e.emit("connect",{chainId:null==i?void 0:i.chainId}))}}))}(this)}))}_initializeState(e){return Yh("[SDKProvider: _initializeState()]",e),function(e,t,n){return Yh("[SDKProvider: initializeState()] set state._initialized to false"),e._state.initialized=!1,t(n)}(this,super._initializeState.bind(this),e)}_handleChainChanged({chainId:e,networkVersion:t}={}){this.state.chainId=e,this.state.networkVersion=t,function({instance:e,chainId:t,networkVersion:n,superHandleChainChanged:r}){Yh(`[SDKProvider: handleChainChanged()] chainId=${t} networkVersion=${n}`);let i=n;n||(Yh("[SDKProvider: handleChainChanged()] forced network version to prevent provider error"),i="1"),e._state.isConnected=!0,e.emit("connect",{chainId:t}),r({chainId:t,networkVersion:i})}({instance:this,chainId:e,networkVersion:t,superHandleChainChanged:super._handleChainChanged.bind(this)})}}var vf,bf={name:"@metamask/sdk",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk",directory:"packages/sdk"},main:"dist/node/cjs/metamask-sdk.js",module:"dist/browser/es/metamask-sdk.js",browser:"dist/browser/es/metamask-sdk.js",unpkg:"dist/browser/umd/metamask-sdk.js","react-native":"dist/react-native/es/metamask-sdk.js",types:"dist/types/src/index.d.ts",sideEffects:!1,files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:clean":"yarn clean && yarn build","build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",typecheck:"tsc --noEmit",clean:"rimraf ./dist",size:"node bundle-size && size-limit",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",prepack:"../../scripts/prepack.sh","publish:preview":"yarn npm publish --tag preview",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:coverage":'jest --coverage --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":'jest -c ./jest.config.ts --detectOpenHandles --testPathIgnorePatterns "/e2e/"',watch:"rollup -c -w",dev:'concurrently "tsc --watch" "rollup -c -w --bundleConfigAsCjs"',"build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs"},dependencies:{"@babel/runtime":"^7.26.0","@metamask/onboarding":"^1.0.1","@metamask/providers":"16.1.0","@metamask/sdk-communication-layer":"workspace:*","@metamask/sdk-install-modal-web":"workspace:*","@paulmillr/qr":"^0.2.1",bowser:"^2.9.0","cross-fetch":"^4.0.0",debug:"^4.3.4",eciesjs:"^0.4.11","eth-rpc-errors":"^4.0.3",eventemitter2:"^6.4.9","obj-multiplex":"^1.0.0",pump:"^3.0.0","readable-stream":"^3.6.2","socket.io-client":"^4.5.1",tslib:"^2.6.0",util:"^0.12.4",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@react-native-async-storage/async-storage":"^1.19.6","@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.1","@size-limit/preset-big-lib":"^11.0.2","@types/dom-screen-wake-lock":"^1.0.2","@types/node":"^20.1.3","@types/pump":"^1.1.1","@types/qrcode-terminal":"^0.12.0","@types/uuid":"^10.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0","browserify-zlib":"^0.2.0",buffer:"^6.0.3",concurrently:"^9.1.2","crypto-browserify":"^3.12.0",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0","https-browserify":"^1.0.0",jest:"^29.3.1","jest-environment-jsdom":"^29.3.1",prettier:"^2.3.0",process:"^0.11.10",rimraf:"^4.4.0",rollup:"^4.26.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.0.2","stream-browserify":"^3.0.0","stream-http":"^3.2.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^4.3.2",url:"^0.11.0",webpack:"^5.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,"@metamask/sdk-communication-layer>bufferutil":!1,"@metamask/sdk-communication-layer>eciesjs>secp256k1":!1,"@metamask/sdk-communication-layer>utf-8-validate":!1}}};!function(e){e.INPAGE="metamask-inpage",e.CONTENT_SCRIPT="metamask-contentscript",e.PROVIDER="metamask-provider"}(vf||(vf={}));const wf="direct",Ef="https://metamask.app.link/connect",Cf="metamask://connect",_f={NAME:"MetaMask",RDNS:["io.metamask","io.metamask.flask"]},Sf=/(?:^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u,kf={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_GETPERMISSIONS:"wallet_getPermissions",WALLET_WATCHASSET:"wallet_watchAsset",WALLET_ADDETHEREUMCHAIN:"wallet_addEthereumChain",WALLET_SWITCHETHETHEREUMCHAIN:"wallet_switchEthereumChain",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_ACCOUNTS:"eth_accounts",ETH_CHAINID:"eth_chainId",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},xf={[kf.ETH_REQUESTACCOUNTS]:!0,[kf.ETH_SENDTRANSACTION]:!0,[kf.ETH_SIGNTRANSACTION]:!0,[kf.ETH_SIGN]:!0,[kf.PERSONAL_SIGN]:!0,[kf.ETH_ACCOUNTS]:!1,[kf.ETH_CHAINID]:!1,[kf.PERSONAL_SIGN]:!0,[kf.ETH_SIGNTYPEDDATA]:!0,[kf.ETH_SIGNTYPEDDATA_V3]:!0,[kf.ETH_SIGNTYPEDDATA_V4]:!0,[kf.WALLET_REQUESTPERMISSIONS]:!0,[kf.WALLET_GETPERMISSIONS]:!0,[kf.WALLET_WATCHASSET]:!0,[kf.WALLET_ADDETHEREUMCHAIN]:!0,[kf.WALLET_SWITCHETHETHEREUMCHAIN]:!0,[kf.METAMASK_CONNECTSIGN]:!0,[kf.METAMASK_CONNECTWITH]:!0,[kf.PERSONAL_EC_RECOVER]:!0,[kf.METAMASK_BATCH]:!0,[kf.METAMASK_OPEN]:!0},Af=Object.keys(xf).map((e=>e.toLowerCase())),Mf=["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sign"].map((e=>e.toLowerCase())),Lf=".sdk-comm",Tf="providerType",Of=".MMSDK_cached_address",Rf=".MMSDK_cached_chainId",Pf="chainChanged",If="accountsChanged",Nf="disconnect",Bf="connect",Df="connected";var $f;!function(e){e.TERMINATE="terminate",e.EXTENSION="extension",e.INITIALIZED="initialized"}($f||($f={}));const jf="undefined"!=typeof window&&window.localStorage;function Kf(e){var t,n;return $e(this,void 0,void 0,(function*(){Yh("[MetaMaskSDK: connectWithExtensionProvider()] ",e),e.sdkProvider=e.activeProvider,e.activeProvider=window.extension,window.ethereum=window.extension;try{const e=yield null===(t=window.extension)||void 0===t?void 0:t.request({method:"eth_requestAccounts"});Yh(`[MetaMaskSDK: connectWithExtensionProvider()] accounts=${e}`)}catch(e){return void console.warn("[MetaMaskSDK: connectWithExtensionProvider()] can't request accounts error",e)}localStorage.setItem(Tf,"extension"),e.extensionActive=!0,e.emit(ff.ProviderUpdate,$f.EXTENSION),e.options.enableAnalytics&&(null===(n=e.analytics)||void 0===n||n.send({event:ea.SDK_USE_EXTENSION}))}))}function Uf(e){let t;if(void 0!==et)t=et.from(e,"utf8").toString("base64");else if("function"==typeof btoa)t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/gu,((e,t)=>String.fromCharCode(parseInt(t,16)))));else{if("object"!=typeof je||!("Buffer"in je))throw new Error("Unable to base64 encode: No available method.");t=je.Buffer.from(e,"utf8").toString("base64")}return t}class Ff extends Ah.Duplex{constructor({name:e,remote:t,deeplinkProtocol:n,platformManager:r}){super({objectMode:!0}),this.state={_name:null,remote:null,deeplinkProtocol:!1,platformManager:null},this.state._name=e,this.state.remote=t,this.state.deeplinkProtocol=n,this.state.platformManager=r,this._onMessage=this._onMessage.bind(this),this.state.remote.on(Zs.MESSAGE,this._onMessage)}_write(e,t,n){return $e(this,void 0,void 0,(function*(){return function(e,t,n,r){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C,_;return $e(this,void 0,void 0,(function*(){const n=null===(i=e.state.remote)||void 0===i?void 0:i.isReady(),S=null===(o=e.state.remote)||void 0===o?void 0:o.isConnected(),k=null===(s=e.state.remote)||void 0===s?void 0:s.isPaused(),x=pf.getProvider(),A=null===(a=e.state.remote)||void 0===a?void 0:a.getChannelId(),M=null===(c=e.state.remote)||void 0===c?void 0:c.isAuthorized(),{deeplinkProtocol:L}=e.state,{method:T,data:O,triggeredInstaller:R}=(e=>{var t,n,r,i;let o;et.isBuffer(e)?(o=e.toJSON(),o._isBuffer=!0):o=e;const s=null===(t=null==o?void 0:o.data)||void 0===t?void 0:t.method;let a=!1;return"object"==typeof(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n.params)&&!0===(null===(i=null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.params)||void 0===i?void 0:i.__triggeredInstaller)&&(a=!0,o.data.params=o.data.params.wrappedParams),{method:s,data:o,triggeredInstaller:a}})(t);if(Yh(`[RCPMS: write()] method='${T}' isRemoteReady=${n} channelId=${A} isSocketConnected=${S} isRemotePaused=${k} providerConnected=${x.isConnected()}`,t),!A)return T!==kf.METAMASK_GETPROVIDERSTATE&&Yh(`[RCPMS: write()] ${T} --\x3e channelId is undefined`),r(new Error("disconnected"));Yh(`[RCPMS: write()] remote.isPaused()=${null===(l=e.state.remote)||void 0===l?void 0:l.isPaused()} authorized=${M} ready=${n} socketConnected=${S}`,t);const P=null===(d=e.state.platformManager)||void 0===d?void 0:d.isSecure(),I=null!==(h=null===(u=e.state.platformManager)||void 0===u?void 0:u.isMobileWeb())&&void 0!==h&&h,N=null!==(p=null===(f=e.state.remote)||void 0===f?void 0:f.hasDeeplinkProtocol())&&void 0!==p&&p&&I&&M;try{if(!R){const t=JSON.stringify(null==O?void 0:O.data);if(t.length>1e6)return r(new Error(`Message size ${t.length} exceeds maximum allowed size of 1000000 bytes`));null===(g=e.state.remote)||void 0===g||g.sendMessage(null==O?void 0:O.data).then((()=>{Yh(`[RCPMS: _write()] ${T} sent successfully`)})).catch((e=>{Yh("[RCPMS: _write()] error sending message",e)}))}if(!P)return Yh(`[RCPMS: _write()] unsecure platform for method ${T} -- return callback`),r();if(R)return Yh("[RCPMS: _write()] prevent deeplink -- installation completed separately."),r();const t=null!==(v=null===(y=null===(m=e.state.remote)||void 0===m?void 0:m.getKeyInfo())||void 0===y?void 0:y.ecies.public)&&void 0!==v?v:"";let n=encodeURI(`channelId=${A}&pubkey=${t}&comm=socket&t=d&v=2`);if(N){const t=JSON.stringify(null==O?void 0:O.data),i=null===(b=e.state.remote)||void 0===b?void 0:b.encrypt(t);if(!i)return Yh("[RCPMS: _write()] error encrypting message"),r(new Error("RemoteCommunicationPostMessageStream - disconnected"));n+=`&scheme=${L}&rpc=${Uf(i)}`}if(!(null===(w=e.state.platformManager)||void 0===w?void 0:w.isMetaMaskInstalled()))return Yh("[RCPMS: _write()] prevent deeplink until installation is completed."),r();xf[T]?(Yh(`[RCPMS: _write()] redirect link for '${T}' socketConnected=${S} connect?${n}`),null===(E=e.state.platformManager)||void 0===E||E.openDeeplink(`${Ef}?${n}`,`${Cf}?${n}`,"_self")):(null===(C=e.state.remote)||void 0===C?void 0:C.isPaused())?(Yh(`[RCPMS: _write()] MM is PAUSED! deeplink with connect! targetMethod=${T}`),null===(_=e.state.platformManager)||void 0===_||_.openDeeplink(`${Ef}?redirect=true&${n}`,`${Cf}?redirect=true&${n}`,"_self")):Yh(`[RCPMS: _write()] method ${T} doesn't need redirect.`)}catch(e){return Yh("[RCPMS: _write()] error sending message",e),r(new Error("RemoteCommunicationPostMessageStream - disconnected"))}return r()}))}(this,e,0,n)}))}_read(){}_onMessage(e){return function(e,t){try{if(Yh("[RCPMS: onMessage()] message",t),!t||"object"!=typeof t)return;if("object"!=typeof(null==t?void 0:t.data))return;if(!(null==t?void 0:t.name))return void Yh("[RCPMS: onMessage()] ignore message without name",t);if((null==t?void 0:t.name)!==vf.PROVIDER)return void Yh(`[RCPMS: onMessage()] ignore message with wrong name message=${t}`);if(et.isBuffer(t)){const n=et.from(t);e.push(n)}else e.push(t)}catch(e){Yh(`[RCPMS: onMessage()] ignore message error err=${e}`)}}(this,e)}start(){}}let Hf=1;const zf=e=>new Promise((t=>{setTimeout((()=>{t(!0)}),e)})),qf=({checkInstallationOnAllCalls:e=!1,communicationLayerPreference:t,injectProvider:n,shouldShimWeb3:r,platformManager:i,installer:o,sdk:s,remoteConnection:a,debug:l})=>$e(void 0,void 0,void 0,(function*(){var d,u;const h=(({name:e,remoteConnection:t})=>{if(!t||!(null==t?void 0:t.getConnector()))throw new Error("Missing remote connection parameter");return new Ff({name:e,remote:null==t?void 0:t.getConnector(),deeplinkProtocol:null==t?void 0:t.state.deeplinkProtocol,platformManager:null==t?void 0:t.getPlatformManager()})})({name:vf.INPAGE,target:vf.CONTENT_SCRIPT,platformManager:i,communicationLayerPreference:t,remoteConnection:a}),f=i.getPlatformType(),p=s.options.dappMetadata,g=`Sdk/Javascript SdkVersion/${bf.version} Platform/${f} dApp/${null!==(d=p.url)&&void 0!==d?d:p.name} dAppTitle/${p.name}`;let m=null,y=null;const v=null===(u=s.options.storage)||void 0===u?void 0:u.storageManager;if(v){try{const e=yield v.getCachedAccounts();e.length>0&&(m=e[0])}catch(e){console.error(`[initializeMobileProvider] failed to get cached addresses: ${e}`)}try{const e=yield v.getCachedChainId();e&&(y=e)}catch(e){console.error(`[initializeMobileProvider] failed to parse cached chainId: ${e}`)}}Yh(`[initializeMobileProvider] cachedAccountAddress: ${m}, cachedChainId: ${y}`);const b=!(!n||f===ga.NonBrowser||f===ga.ReactNative),w=pf.init({shouldSetOnWindow:b,connectionStream:h,shouldShimWeb3:r,sdkInstance:s});let E=!1;const C=e=>{E=e},_=()=>E,S=(t,n,r,l)=>$e(void 0,void 0,void 0,(function*(){var d,u,h,f,p,b,w,S,k;const x=pf.getProvider();if(E){x.emit("display_uri",(null==a?void 0:a.state.qrcodeLink)||""),null==a||a.showActiveModal();let e=_();for(;e;){const t=_(),n=null==a?void 0:a.isAuthorized();e=t&&!n,Yh(`[initializeMobileProvider: sendRequest()] waiting for initialization to complete - initializing: ${t} authorized: ${n}`),yield zf(1e3)}return Yh("[initializeMobileProvider: sendRequest()] initial method completed -- prevent installation and call provider"),r(...n)}const A=i.isMetaMaskInstalled(),M=null==a?void 0:a.isConnected();let L=null,T=null,O=null;if(L=null!==(d=x.getSelectedAddress())&&void 0!==d?d:m,O=x.getChainId()||y,L&&v&&L!==m&&v.persistAccounts([L]).catch((e=>{console.error(`[initializeMobileProvider] failed to persist account: ${e}`)})),O&&(y=O,v&&v.persistChainId(O).catch((e=>{console.error(`[initializeMobileProvider] failed to persist chainId: ${e}`)}))),Yh("[initializeMobileProvider: sendRequest()]",{selectedAddress:L,chainId:O}),l&&Yh(`[initializeMobileProvider: sendRequest()] method=${t} ongoing=${E} selectedAddress=${L} isInstalled=${A} checkInstallationOnAllCalls=${e} socketConnected=${M}`),L&&t.toLowerCase()===kf.ETH_ACCOUNTS.toLowerCase())return[L];if(O&&t.toLowerCase()===kf.ETH_CHAINID.toLowerCase())return O;const R=[kf.ETH_REQUESTACCOUNTS,kf.WALLET_REQUESTPERMISSIONS,kf.METAMASK_CONNECTSIGN,kf.METAMASK_CONNECTWITH],P=!xf[t],I=null===(u=s.options.readonlyRPCMap)||void 0===u?void 0:u[O];if(I&&P)try{const e=null===(h=null==n?void 0:n[0])||void 0===h?void 0:h.params,r=yield(({rpcEndpoint:e,method:t,sdkInfo:n,params:r})=>$e(void 0,void 0,void 0,(function*(){const i=JSON.stringify({jsonrpc:"2.0",method:t,params:r,id:(Hf+=1,Hf)}),o={Accept:"application/json","Content-Type":"application/json"};let s;e.includes("infura")&&(o["Metamask-Sdk-Info"]=n);try{s=yield c(e,{method:"POST",headers:o,body:i})}catch(e){throw e instanceof Error?new Error(`Failed to fetch from RPC: ${e.message}`):new Error(`Failed to fetch from RPC: ${e}`)}if(!s.ok)throw new Error(`Server responded with a status of ${s.status}`);return(yield s.json()).result})))({rpcEndpoint:I,sdkInfo:g,method:t,params:e||[]});return l&&Yh(`initializeProvider::ReadOnlyRPCResponse ${r}`),r}catch(e){console.warn(`[initializeMobileProvider: sendRequest()] method=${t} readOnlyRPCRequest failed:`,e)}if((!A||A&&!M)&&t!==kf.METAMASK_GETPROVIDERSTATE){const c=(null===(f=null==n?void 0:n[0])||void 0===f?void 0:f.params)||[];if(-1!==R.indexOf(t)||e){C(!0);const e=t===kf.METAMASK_CONNECTWITH,i=`${Date.now()}`;try{yield o.start({wait:!1,connectWith:e?{method:t,id:i,params:c}:void 0}),yield new Promise(((e,t)=>{(null==a?void 0:a.isAuthorized())&&(Yh("[initializeMobileProvider: sendRequest()] already authorized"),e(!0)),null==a||a.getConnector().once(Zs.AUTHORIZED,(()=>{e(!0)})),s.once(Zs.PROVIDER_UPDATE,(e=>{Yh(`[initializeMobileProvider: sendRequest()] PROVIDER_UPDATE --- remote provider request interupted type=${e}`),e===$f.EXTENSION?t(Zs.PROVIDER_UPDATE):t(new Error("Connection Terminated"))}))}))}catch(e){if($f.EXTENSION===e){if(Yh(`[initializeMobileProvider: sendRequest()] extension provider detect: re-create ${t} on the active provider`),t.toLowerCase()===kf.METAMASK_CONNECTSIGN.toLowerCase()){const e=yield null===(p=s.getProvider())||void 0===p?void 0:p.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!e.length)throw new Error("SDK state invalid -- undefined accounts");const t=yield null===(b=s.getProvider())||void 0===b?void 0:b.request({method:kf.PERSONAL_SIGN,params:[c[0],e[0]]});return s.emit(ff.ConnectWithResponse,t),t}if(t.toLowerCase()===kf.METAMASK_CONNECTWITH.toLowerCase()){const[e]=c,t=yield(({method:e,sdk:t,params:n})=>$e(void 0,void 0,void 0,(function*(){var r,i,o,s;if(!t.isExtensionActive())throw new Error("SDK state invalid -- extension is not active");Yh("[MetaMaskProvider: extensionConnectWithOverwrite()] Overwriting request method",e,n);const a=yield null===(r=t.getProvider())||void 0===r?void 0:r.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!a.length)throw new Error("SDK state invalid -- undefined accounts");if((null==e?void 0:e.toLowerCase())===kf.PERSONAL_SIGN.toLowerCase()){const r={method:e,params:[n[0],a[0]]};return yield null===(i=t.getProvider())||void 0===i?void 0:i.request(r)}if((null==e?void 0:e.toLowerCase())===kf.ETH_SENDTRANSACTION.toLowerCase()){const r={method:e,params:[Object.assign(Object.assign({},n[0]),{from:a[0]})]};return yield null===(o=t.getProvider())||void 0===o?void 0:o.request(r)}return Mf.includes(e.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${e} -- not handled by the extension -- call separately`),a):yield null===(s=t.getProvider())||void 0===s?void 0:s.request({method:e,params:n})})))({method:e.method,sdk:s,params:e.params});return s.emit(ff.ConnectWithResponse,t),t}return Yh(`[initializeMobileProvider: sendRequest()] sending '${t}' on active provider`,c),yield null===(w=s.getProvider())||void 0===w?void 0:w.request({method:t,params:c})}if(e===Zs.REJECTED)throw null==a||a.closeModal(),null===(S=s.getProvider())||void 0===S||S.handleDisconnect({terminate:!1}),Object.assign(new Error("User rejected connection"),{code:4001});throw Yh(`[initializeMobileProvider: sendRequest()] failed to start installer: ${e}`),e}finally{C(!1)}if(t===kf.ETH_REQUESTACCOUNTS)return T=yield new Promise((e=>{const t=setInterval((()=>{const{accounts:n}=x.getState();n&&(clearInterval(t),e(n))}),100)})),Yh(`[initializeMobileProvider: sendRequest()] selectedAddress: ${L} --- SKIP rpc call`),T;if(t===kf.METAMASK_CONNECTWITH)try{let e=0;const t=5,n=({resolve:n,reject:r})=>{e+=1;const o=null==a?void 0:a.getConnector().getRPCMethodTracker(),c=null==o?void 0:o[i];return Yh(`TRACKER: update method ${i}`,c),(null==c?void 0:c.result)?(Yh("[initializeMobileProvider: sendRequest()] found result",c.result),s.emit(ff.ConnectWithResponse,c.result),void n(c.result)):(null==c?void 0:c.error)?(Yh("[initializeMobileProvider: sendRequest()] found error",c.error),void r(c.error)):e>=t?(Yh("[initializeMobileProvider: sendRequest()] max message count reached without result"),void r(new Error("Max message count reached without result"))):void Yh("[initializeMobileProvider: sendRequest()] not found yet, need to wait for next update")};let r,o;const c=yield new Promise(((e,t)=>{const s=null==a?void 0:a.getConnector().getRPCMethodTracker();Yh(`TRACKER: method ${i}`,s),(null==s?void 0:s[i].result)?(Yh("[initializeMobileProvider: sendRequest()] found result",null==s?void 0:s[i].result),e(null==s?void 0:s[i].result)):(null==s?void 0:s[i].error)&&(Yh("[initializeMobileProvider: sendRequest()] found error",null==s?void 0:s[i].error),t(null==s?void 0:s[i].error)),o=()=>n({resolve:e,reject:t}),r=null==a?void 0:a.getConnector().on(Zs.RPC_UPDATE,o)}));return o&&(null==r||r.off(Zs.RPC_UPDATE,o)),Yh("TRACKER: result",c),c}catch(e){throw Yh("[initializeMobileProvider: sendRequest()] error:",e),e}return n[0]&&"object"==typeof n[0]&&(n[0].params={__triggeredInstaller:!0,wrappedParams:n[0].params}),r(...n)}if(i.isSecure()&&xf[t])return r(...n);if(s.isExtensionActive())return Yh(`[initializeMobileProvider: sendRequest()] EXTENSION active - redirect request '${t}' to it`,n,c),yield null===(k=s.getProvider())||void 0===k?void 0:k.request({method:t,params:c});throw Yh(`[initializeMobileProvider: sendRequest()] method=${t} --- skip --- not connected/installed`),new Error("MetaMask is not connected/installed, please call eth_requestAccounts to connect first.")}try{const e=yield r(...n);if(Yh(`[initializeMobileProvider: sendRequest()] method=${t} rpcResponse`,e),t===kf.WALLET_REQUESTPERMISSIONS){const t=e.reduce(((e,t)=>{var n;if("eth_accounts"===t.parentCapability){const r=null===(n=t.caveats.find((e=>"restrictReturnedAccounts"===e.type)))||void 0===n?void 0:n.value;r&&e.push(...r)}return e}),[]);Yh("[initializeMobileProvider: sendRequest()] accountsToPersist:",t),t.length>0&&(x.handleAccountsChanged(t,!1),null==v||v.persistAccounts(t))}return e}catch(e){throw console.error("[initializeMobileProvider: sendRequest()] error:",e),e}})),{request:k}=w;w.request=(...e)=>$e(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0].method,e,k,l)}));const{send:x}=w;return w.send=(...e)=>$e(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0],e,x,l)})),Yh("[initializeMobileProvider: sendRequest()] metamaskStream.start()"),h.start(),w}));class Vf{constructor({serverUrl:e,enabled:t,originatorInfo:n}){this.serverURL=Hs,this.serverURL=e,this.originatorInfo=n,this.enabled=null==t||t}send({event:e,params:t}){if(!this.enabled)return;const n=Object.assign(Object.assign({id:"sdk",event:e,sdkVersion:bf.version},this.originatorInfo),{params:t});Yh(`[Analytics: send()] event: ${e}`,n),Ks(n,this.serverURL).catch((e=>{Yh(`[Analytics: send()] error: ${e}`)}))}}function Wf(e){var t,n,i;const{dappMetadata:o}=e,s=function({url:e,name:t}){var n;const i=Uf(e+t);if(!localStorage)return"";let o=null!==(n=localStorage.getItem(i))&&void 0!==n?n:"";if(!o){o=r();try{localStorage.setItem(i,o)}catch(e){return""}}return o}({url:null!==(t=null==o?void 0:o.url)&&void 0!==t?t:"no_url",name:null!==(n=null==o?void 0:o.name)&&void 0!==n?n:"no_name"}),a=null===(i=e.platformManager)||void 0===i?void 0:i.getPlatformType(),c=a===ga.DesktopWeb,l=a===ga.MetaMaskMobileWebview;let d="N/A";return c?d="extension":l&&(d="mobile"),{id:s,from:d}}const Gf=({provider:e,sdkInstance:t})=>{if("state"in e)throw new Error("INVALID EXTENSION PROVIDER");return new Proxy(e,{get:(n,r)=>"request"===r?function(e){var r,i;return $e(this,void 0,void 0,(function*(){Yh("[wrapExtensionProvider()] Overwriting request method",e);const{method:o,params:s}=e,a=Af.includes(o.toLowerCase()),{id:c,from:l}=Wf(t);if(a&&(null===(r=t.analytics)||void 0===r||r.send({event:ea.SDK_RPC_REQUEST,params:{method:o,from:l,id:c}})),o===kf.METAMASK_BATCH&&Array.isArray(s))return(({target:e,args:t,trackEvent:n,sdkInstance:r})=>$e(void 0,void 0,void 0,(function*(){var i,o;if("metamask_batch"!==t.method)throw new Error("Invalid usage");const s=[],a=null!==(i=null==t?void 0:t.params)&&void 0!==i?i:[];for(const t of a){const n=yield null==e?void 0:e.request({method:t.method,params:t.params});s.push(n)}const{id:c,from:l}=Wf(r);return n&&(null===(o=r.analytics)||void 0===o||o.send({event:ea.SDK_RPC_REQUEST_DONE,params:{method:t.method,from:l,id:c}})),s})))({target:n,args:e,trackEvent:a,sdkInstance:t});if(o.toLowerCase()===kf.METAMASK_CONNECTSIGN.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>$e(void 0,void 0,void 0,(function*(){const n=yield e.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!n.length)throw new Error("SDK state invalid -- undefined accounts");return yield e.request({method:kf.PERSONAL_SIGN,params:[t[0],n[0]]})})))({target:n,params:s});if(o.toLowerCase()===kf.METAMASK_CONNECTWITH.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>$e(void 0,void 0,void 0,(function*(){const[n]=t,r=n.method,i=n.params,o=yield e.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!o.length)throw new Error("SDK state invalid -- undefined accounts");return(null==r?void 0:r.toLowerCase())===kf.PERSONAL_SIGN.toLowerCase()?yield e.request({method:r,params:[i[0],o[0]]}):(null==r?void 0:r.toLowerCase())===kf.ETH_SENDTRANSACTION.toLowerCase()?yield e.request({method:r,params:[Object.assign(Object.assign({},i[0]),{from:o[0]})]}):Mf.includes(r.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${r} -- not handled by the extension -- call separately`),o):yield e.request({method:r,params:i})})))({target:n,params:s});let d;try{return d=yield n.request(e),d}finally{a&&(null===(i=t.analytics)||void 0===i||i.send({event:ea.SDK_RPC_REQUEST_DONE,params:{method:o,from:l,id:c}}))}}))}:"getChainId"===r?function(){return e.chainId}:"getNetworkVersion"===r?function(){return e.networkVersion}:"getSelectedAddress"===r?function(){return e.selectedAddress}:"isConnected"===r?function(){return e._state.isConnected}:n[r]})};var Yf;!function(e){e.Announce="eip6963:announceProvider",e.Request="eip6963:requestProvider"}(Yf||(Yf={}));var Zf="INSTALLED",Jf="NOT_INSTALLED",Xf="REGISTERED",Qf="REGISTERING",ep="RELOADING",tp={CHROME:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",FIREFOX:"https://addons.mozilla.org/firefox/addon/ether-metamask/",DEFAULT:"https://metamask.io"},np="REGISTRATION_IN_PROGRESS",rp="FORWARDER_ID",ip=function(){function e(t){var n=void 0===t?{}:t,r=n.forwarderOrigin,i=void 0===r?"https://fwd.metamask.io":r,o=n.forwarderMode,s=void 0===o?e.FORWARDER_MODE.INJECT:o;this.forwarderOrigin=i,this.forwarderMode=s,this.state=e.isMetaMaskInstalled()?Zf:Jf;var a=e._detectBrowser();this.downloadUrl=a?tp[a]:tp.DEFAULT,this._onMessage=this._onMessage.bind(this),this._onMessageFromForwarder=this._onMessageFromForwarder.bind(this),this._openForwarder=this._openForwarder.bind(this),this._openDownloadPage=this._openDownloadPage.bind(this),this.startOnboarding=this.startOnboarding.bind(this),this.stopOnboarding=this.stopOnboarding.bind(this),window.addEventListener("message",this._onMessage),s===e.FORWARDER_MODE.INJECT&&"true"===sessionStorage.getItem(np)&&e._injectForwarder(this.forwarderOrigin)}return e.prototype._onMessage=function(e){if(e.origin===this.forwarderOrigin)return"metamask:reload"===e.data.type?this._onMessageFromForwarder(e):void console.debug("Unknown message from '"+e.origin+"' with data "+JSON.stringify(e.data))},e.prototype._onMessageUnknownStateError=function(e){throw new Error("Unknown state: '"+e+"'")},e.prototype._onMessageFromForwarder=function(t){return function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))}(this,0,void 0,(function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}(this,(function(n){switch(n.label){case 0:switch(this.state){case ep:return[3,1];case Jf:return[3,2];case Zf:return[3,3];case Qf:return[3,5];case Xf:return[3,6]}return[3,7];case 1:return console.debug("Ignoring message while reloading"),[3,8];case 2:return console.debug("Reloading now to register with MetaMask"),this.state=ep,location.reload(),[3,8];case 3:return console.debug("Registering with MetaMask"),this.state=Qf,[4,e._register()];case 4:return n.sent(),this.state=Xf,t.source.postMessage({type:"metamask:registrationCompleted"},t.origin),this.stopOnboarding(),[3,8];case 5:return console.debug("Already registering - ignoring reload message"),[3,8];case 6:return console.debug("Already registered - ignoring reload message"),[3,8];case 7:this._onMessageUnknownStateError(this.state),n.label=8;case 8:return[2]}}))}))},e.prototype.startOnboarding=function(){sessionStorage.setItem(np,"true"),this._openDownloadPage(),this._openForwarder()},e.prototype.stopOnboarding=function(){"true"===sessionStorage.getItem(np)&&(this.forwarderMode===e.FORWARDER_MODE.INJECT&&(console.debug("Removing forwarder"),e._removeForwarder()),sessionStorage.setItem(np,"false"))},e.prototype._openForwarder=function(){this.forwarderMode===e.FORWARDER_MODE.OPEN_TAB?window.open(this.forwarderOrigin,"_blank"):e._injectForwarder(this.forwarderOrigin)},e.prototype._openDownloadPage=function(){window.open(this.downloadUrl,"_blank")},e.isMetaMaskInstalled=function(){return Boolean(window.ethereum&&window.ethereum.isMetaMask)},e._register=function(){return window.ethereum.request({method:"wallet_registerOnboarding"})},e._injectForwarder=function(e){var t=document.body,n=document.createElement("iframe");n.setAttribute("height","0"),n.setAttribute("width","0"),n.setAttribute("style","display: none;"),n.setAttribute("src",e),n.setAttribute("id",rp),t.insertBefore(n,t.children[0])},e._removeForwarder=function(){var e;null===(e=document.getElementById(rp))||void 0===e||e.remove()},e._detectBrowser=function(){var e=hf.parse(window.navigator.userAgent);return"Firefox"===e.browser.name?"FIREFOX":["Chrome","Chromium"].includes(e.browser.name||"")?"CHROME":null},e.FORWARDER_MODE={INJECT:"INJECT",OPEN_TAB:"OPEN_TAB"},e}();class op{constructor({remote:e,preferDesktop:t,platformManager:n,debug:r=!1}){this.state={isInstalling:!1,hasInstalled:!1,resendRequest:null,preferDesktop:!1,platformManager:null,remote:null,debug:!1,connectWith:void 0},this.state.remote=e,this.state.preferDesktop=t,this.state.platformManager=n,this.state.debug=r}startDesktopOnboarding(){return function(){return $e(this,void 0,void 0,(function*(){Yh("[MetamaskInstaller: startDesktopOnboarding() starting desktop onboarding"),window.ethereum&&(window.ethereum=void 0),(new ip).startOnboarding()}))}()}redirectToProperInstall(){return $e(this,void 0,void 0,(function*(){return function(e){var t,n;return $e(this,void 0,void 0,(function*(){const{state:r}=e,i=null===(t=r.platformManager)||void 0===t?void 0:t.getPlatformType();if(Yh(`[MetamaskInstaller: redirectToProperInstall()] platform=${i}`),i===ga.MetaMaskMobileWebview)return!1;r.isInstalling=!0;try{yield null===(n=r.remote)||void 0===n?void 0:n.startConnection({connectWith:r.connectWith}),r.isInstalling=!1,r.hasInstalled=!0}catch(e){throw r.isInstalling=!1,e}return!0}))}(this)}))}checkInstallation(){return $e(this,void 0,void 0,(function*(){return function(e){var t;return $e(this,void 0,void 0,(function*(){const{state:n}=e,r=null===(t=n.platformManager)||void 0===t?void 0:t.isMetaMaskInstalled();return Yh(`[MetamaskInstaller: checkInstallation()] isInstalled=${r}`),!!r||(yield e.redirectToProperInstall())}))}(this)}))}start({wait:e=!1,connectWith:t}){return $e(this,void 0,void 0,(function*(){this.state.connectWith=t,Yh(`[MetaMaskInstaller: start()] wait=${e}`,t),yield function(e,{wait:t=!1}){return $e(this,void 0,void 0,(function*(){return Yh(`[MetamaskInstaller: startInstaller()] wait=${t}`),t&&(yield zf(1e3)),yield e.checkInstallation()}))}(this,{wait:e})}))}}class sp{constructor({debug:e,sdkVersion:t}){this.containers={install:void 0,pending:void 0,select:void 0},this.defined={install:!1,pending:!1,select:!1},this.debug=null!=e&&e,this.sdkVersion=t}loadComponent(e){return $e(this,void 0,void 0,(function*(){if(!this.defined[e]){this.defined[e]=!0;try{const e=yield Promise.resolve().then((function(){return Rg}));console.log("loader",e),e.defineCustomElements()}catch(t){console.error(`Failed to load ${e} modal:`,t)}}}))}renderInstallModal(e){var t;return $e(this,void 0,void 0,(function*(){this.debug&&console.debug("ModalLoader: renderInstallModal",e),this.containers.install=e.parentElement,yield this.loadComponent("install");const n=document.createElement("mm-install-modal");n.link=e.link,n.preferDesktop=e.preferDesktop,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("startDesktopOnboarding",e.metaMaskInstaller.startDesktopOnboarding),n.addEventListener("trackAnalytics",(t=>{var n;return null===(n=e.onAnalyticsEvent)||void 0===n?void 0:n.call(e,t.detail)})),e.parentElement.appendChild(n)}))}renderSelectModal(e){var t;return $e(this,void 0,void 0,(function*(){this.containers.select=e.parentElement,yield this.loadComponent("select");const n=document.createElement("mm-select-modal");n.link=e.link,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.preferDesktop=e.preferDesktop,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("connectWithExtension",e.connectWithExtension),e.parentElement.appendChild(n),setTimeout((()=>this.updateQRCode(e.link)),100)}))}renderPendingModal(e){var t;return $e(this,void 0,void 0,(function*(){this.containers.pending=e.parentElement,yield this.loadComponent("pending");const n=document.createElement("mm-pending-modal");n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.displayOTP=e.displayOTP,n.addEventListener("close",e.onClose),n.addEventListener("updateOTPValue",(({detail:{otpValue:t}})=>e.updateOTPValue(t))),e.onDisconnect&&n.addEventListener("disconnect",e.onDisconnect),e.parentElement.appendChild(n)}))}updateOTPValue(e){const t=()=>{var t;const n=null===(t=this.containers.pending)||void 0===t?void 0:t.querySelector("mm-pending-modal");return!!n&&(n.otpCode=e,!0)};setTimeout((()=>{t()}),800)}updateQRCode(e){var t,n;const r=null===(t=this.containers.install)||void 0===t?void 0:t.querySelector("mm-install-modal");if(r)r.link=e;else{const t=null===(n=this.containers.select)||void 0===n?void 0:n.querySelector("mm-select-modal");t&&(t.link=e)}}unmount(){Object.entries(this.containers).forEach((([e,t])=>{var n;null===(n=null==t?void 0:t.parentNode)||void 0===n||n.removeChild(t),this.containers[e]=void 0}))}}const ap=({link:e,debug:t,installer:n,terminate:r,connectWithExtension:i,preferDesktop:o,onAnalyticsEvent:s})=>{let a=null,c=null;Yh("[UI: InstallModal-web: sdkWebInstallModal()] ################## Installing Modal #################"),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] link=${e}`),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --ios`),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --android`),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] adb shell am start -a android.intent.action.VIEW -d "${e}"`);const l=e=>{var t;Yh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web unmounting install modal -- shouldTerminate:",e,c),(null==c?void 0:c.parentNode)&&(null===(t=c.parentNode)||void 0===t||t.removeChild(c)),c=null,a=null,!0===e&&(null==r||r())};return{mount:r=>{if(Yh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web mounting install modal",c),c)return c.style.display="block",void(null==a||a.updateQRCode(r));a=new sp({debug:t,sdkVersion:bf.version}),c=document.createElement("div"),document.body.appendChild(c),window.extension?a.renderSelectModal({parentElement:c,connectWithExtension:()=>{l(),null==i||i()},onClose:l,link:e,preferDesktop:null!=o&&o}).catch((e=>{console.error(e)})):a.renderInstallModal({parentElement:c,preferDesktop:null!=o&&o,link:e,metaMaskInstaller:n,onClose:l,onAnalyticsEvent:s}).catch((e=>{console.error("[UI: InstallModal-web: sdkWebInstallModal()]",e)}))},unmount:l}},cp=({onDisconnect:e,debug:t})=>{let n=null,r=null;const i=()=>{Yh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web unmount",n),(null==n?void 0:n.parentNode)&&n.parentNode.removeChild(n),n=null,r=null},o=e=>{Yh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web updateOTPValue",e),r&&r.updateOTPValue(e)},s=({displayOTP:s}={displayOTP:!0})=>{Yh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web mount",n),n?n.style.display="block":(r=new sp({debug:t,sdkVersion:bf.version}),n=document.createElement("div"),document.body.appendChild(n),r.renderPendingModal({parentElement:n,onClose:i,onDisconnect:e,updateOTPValue:o,displayOTP:s}).catch((e=>{console.error("[UI: pendingModal-web: sdkWebPendingModal()]",e)})))};return s(),{mount:s,unmount:i,updateOTPValue:o}};function lp(e,t){var n,r,i,o;e.connector||(Yh("[RemoteConnection: initializeConnector()] initialize connector"),e.connector=new La({platformType:t.platformManager.getPlatformType(),communicationLayerPreference:t.communicationLayerPreference,transports:t.transports,dappMetadata:Object.assign(Object.assign({},t.dappMetadata),{source:t._source}),analytics:t.enableAnalytics,communicationServerUrl:t.communicationServerUrl,sdkVersion:bf.version,context:"dapp",ecies:t.ecies,storage:t.storage,logging:t.logging}),t.timer&&(Yh("[RemoteConnection: initializeConnector()] reset background timer",t.timer),null===(r=null===(n=t.timer)||void 0===n?void 0:n.stopBackgroundTimer)||void 0===r||r.call(n),null===(o=null===(i=t.timer)||void 0===i?void 0:i.runBackgroundTimer)||void 0===o||o.call(i,(()=>!1),1e4)))}function dp(e){e.listeners.forEach((({event:t,handler:n})=>{var r;null===(r=e.connector)||void 0===r||r.off(t,n)})),e.listeners=[]}function up(e,t){function n(t,n){var r;null===(r=e.connector)||void 0===r||r.on(t,n),e.listeners.push({event:t,handler:n})}e.connector&&(dp(e),n(Zs.WALLET_INIT,(({accounts:e,chainId:t})=>$e(this,void 0,void 0,(function*(){Yh(`[RemoteConnection: setupListeners() => EventType.WALLET_INIT] 'wallet_init' accounts=${e} chainId=${t}`);const n=pf.getProvider();n._setConnected();const r={accounts:e,chainId:t,isUnlocked:!1};n._initializeState(r),n.emit("chainChanged",t),n.emit("accountsChanged",e)})))),n(Zs.AUTHORIZED,(()=>$e(this,void 0,void 0,(function*(){var t,n,r,i;try{Yh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' closing modals",e.pendingModal,e.installModal);const o=pf.getProvider();o._setConnected(),null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!1),e.otpAnswer=void 0,e.authorized=!0,Yh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' provider.state",o.getState()),yield o.forceInitializeState()}catch(e){}})))),n(Zs.TERMINATE,(()=>{var t,n,r,i,o;null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!0),e.pendingModal=void 0,e.installModal=void 0,e.otpAnswer=void 0,null===(o=e.connector)||void 0===o||o.disconnect({terminate:!0}),e.authorized=!1,pf.getProvider().handleDisconnect({terminate:!0}),dp(e),Yh("[RemoteConnection: setupListeners()] All listeners cleaned up")})))}function hp(e,t,{initialCheck:n,connectWith:r}={}){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C;return $e(this,void 0,void 0,(function*(){try{if(lp(e,t),!e.connector)throw new Error("no connector defined");up(e);const _=pf.getProvider();e.authorized=!1,_.emit("connecting");const S=yield null===(i=e.connector)||void 0===i?void 0:i.originatorSessionConnect();Yh(`[RemoteConnection: startConnection()] after originatorSessionConnect initialCheck=${n}`,S);let k=null!==(o=null==S?void 0:S.channelId)&&void 0!==o?o:"",x=null!==(a=null===(s=e.connector.getKeyInfo())||void 0===s?void 0:s.ecies.public)&&void 0!==a?a:"",A=null!==(l=null===(c=e.connector.getKeyInfo())||void 0===c?void 0:c.ecies.private)&&void 0!==l?l:"";if(n&&!S)return Promise.resolve();if(!S&&!n){const t=yield e.connector.generateChannelIdConnect();k=null!==(d=t.channelId)&&void 0!==d?d:"",x=null!==(u=t.pubKey)&&void 0!==u?u:"",A=null!==(h=t.privKey)&&void 0!==h?h:"";const n=Date.now();null===(f=e.connector.state.storageManager)||void 0===f||f.persistChannelConfig({channelId:k,localKey:A,lastActive:n,validUntil:n+qs})}if(n&&(null==S?void 0:S.channelId))return(null===(p=e.connector)||void 0===p?void 0:p.isConnected())||(Yh(`[RemoteConnection: startConnection()] reconnecting to channel initialCheck=${n}`,S),yield null===(g=e.connector)||void 0===g?void 0:g.connectToChannel({channelId:k})),Promise.resolve();S&&!(null===(m=e.connector)||void 0===m?void 0:m.isConnected())&&(Yh("[RemoteConnection: startConnection()] reconnecting to channel",S),yield null===(y=e.connector)||void 0===y?void 0:y.connectToChannel({channelId:k}));const M=(null===(v=e.platformManager)||void 0===v?void 0:v.isSecure())?"":"&t=q",L=bf.version,{iconUrl:T,name:O,url:R,scheme:P}=t.dappMetadata||{},I=null===(b=e.platformManager)||void 0===b?void 0:b.getPlatformType();let N="N/A";"undefined"!=typeof window&&window.location&&window.location.hostname?N=window.location.hostname:void 0!==O?N=O:void 0!==R&&(N=R);const B={url:null!=R?R:"",title:null!=O?O:"",icon:T,scheme:null!=P?P:"",apiVersion:L,dappId:N||R||"N/A",platform:null!=I?I:"",source:null!==(w=t._source)&&void 0!==w?w:""},D=Uf(JSON.stringify(B));let $=`channelId=${k}&v=2&comm=${null!==(E=e.communicationLayerPreference)&&void 0!==E?E:""}&pubkey=${x}${M}&originatorInfo=${D}`;if(r){$+=`&rpc=${Uf(JSON.stringify(r))}`;const t=e.connector.getRPCMethodTracker();t&&(t[`${r.id}`]=Object.assign(Object.assign({},r),{id:`${r.id}`,timestamp:Date.now()}))}const j=encodeURI($),K=`${e.useDeeplink?Cf:Ef}?${$}`;return e.qrcodeLink=K,e.developerMode&&Yh(`[RemoteConnection: startConnection()] qrcodeLink=${j}`),_.emit("display_uri",K),(null===(C=e.platformManager)||void 0===C?void 0:C.isSecure())?(yield function(e,t){var n,r;return $e(this,void 0,void 0,(function*(){const i=`${Ef}?${t}`,o=`${Cf}?${t}`;null===(r=null===(n=e.platformManager)||void 0===n?void 0:n.openDeeplink)||void 0===r||r.call(n,i,o,"_self")}))}(e,j),new Promise(((t,n)=>{var r,i,o;(null===(r=e.connector)||void 0===r?void 0:r.isAuthorized())?t():(null===(i=e.connector)||void 0===i||i.once(Zs.AUTHORIZED,(()=>{t()})),null===(o=e.connector)||void 0===o||o.once(Zs.REJECTED,(()=>{n(Zs.REJECTED)})))}))):function(e,t,n){return $e(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{if(!e.connector)return void i(new Error("No connector available"));Yh("[RemoteConnection: connectWithModalInstaller()]",{state:e,options:t,linkParams:n});const o=`${e.useDeeplink?Cf:Ef}?${n}`;!function(e,t,n){var r,i,o,s;e.installModal=null===(i=(r=t.modals).install)||void 0===i?void 0:i.call(r,{link:n,preferDesktop:e.preferDesktop,installer:t.getMetaMaskInstaller(),terminate:()=>{Yh("[RemoteConnection: showInstallModal() => terminate()] terminate connection"),t.sdk.terminate().catch((e=>{console.warn("[MMSDK] failed to terminate connection",e)}))},debug:e.developerMode,connectWithExtension:()=>{var e;return null===(e=t.connectWithExtensionProvider)||void 0===e||e.call(t),!1},onAnalyticsEvent:({event:n,params:r})=>{var i,o,s;const a=Object.assign(Object.assign({},r),{sdkVersion:t.sdk.getVersion(),dappId:null===(i=t.dappMetadata)||void 0===i?void 0:i.name,source:t._source,url:null===(o=t.dappMetadata)||void 0===o?void 0:o.url});null===(s=e.analytics)||void 0===s||s.send({event:n,params:a})}}),null===(s=null===(o=e.installModal)||void 0===o?void 0:o.mount)||void 0===s||s.call(o,n)}(e,t,o),t.sdk.once(Zs.PROVIDER_UPDATE,(e=>$e(this,void 0,void 0,(function*(){Yh("[RemoteConnection: connectWithModalInstaller()] once provider_update -- resolving startConnection promise"),e!==$f.TERMINATE?i(e):i({code:4001,message:"User rejected the request."})})))),e.connector.once(Zs.AUTHORIZED,(()=>{r()})),e.connector.once(Zs.REJECTED,(()=>{i(Zs.REJECTED)})),e.connector.once(Zs.CLIENTS_READY,(()=>$e(this,void 0,void 0,(function*(){Yh("[RemoteConnection: connectWithModalInstaller()] once clients_ready -- resolving startConnection promise"),r()}))))}))}))}(e,t,j)}catch(e){throw console.error("[startConnection] error",e),e}}))}class fp{constructor(e){var t,n,r;this.state={connector:void 0,qrcodeLink:void 0,analytics:void 0,developerMode:!1,authorized:!1,reconnection:!1,preferDesktop:!1,deeplinkProtocol:!1,listeners:[],communicationLayerPreference:void 0,platformManager:void 0,pendingModal:void 0,installModal:void 0,otpAnswer:void 0},this.options=e;const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode)||!0===(null===(n=e.logging)||void 0===n?void 0:n.sdk);this.state.developerMode=i,this.state.analytics=e.analytics,this.state.preferDesktop=null!==(r=e.preferDesktop)&&void 0!==r&&r,this.state.useDeeplink=e.sdk.options.useDeeplink,this.state.communicationLayerPreference=e.communicationLayerPreference,this.state.platformManager=e.platformManager,e.modals.install||(e.modals.install=ap),e.modals.otp||(e.modals.otp=cp)}startConnection(e){return $e(this,void 0,void 0,(function*(){return hp(this.state,this.options,e)}))}initRemoteCommunication({sdkInstance:e}){var t,n,r;return $e(this,void 0,void 0,(function*(){const i=yield null===(n=null===(t=e.options.storage)||void 0===t?void 0:t.storageManager)||void 0===n?void 0:n.getPersistedChannelConfig();if(!this.options.ecies){const e={privateKey:null==i?void 0:i.localKey};this.options.ecies=e}lp(this.state,this.options),yield null===(r=this.getConnector())||void 0===r?void 0:r.initFromDappStorage(),up(this.state,this.options)}))}showActiveModal(){return function(e){var t,n,r,i;e.authorized?Yh("[RemoteConnection: showActiveModal()] already authorized"):e.pendingModal?null===(n=(t=e.pendingModal).mount)||void 0===n||n.call(t):e.installModal&&(null===(i=(r=e.installModal).mount)||void 0===i||i.call(r,e.qrcodeLink||""))}(this.state)}closeModal(){var e,t,n,r;null===(t=null===(e=this.state.pendingModal)||void 0===e?void 0:e.unmount)||void 0===t||t.call(e),null===(r=null===(n=this.state.installModal)||void 0===n?void 0:n.unmount)||void 0===r||r.call(n,!1)}getUniversalLink(){if(!this.state.qrcodeLink)throw new Error("connection not started. run startConnection() first.");return this.state.qrcodeLink}getChannelConfig(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getChannelConfig()}getKeyInfo(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getKeyInfo()}getConnector(){if(!this.state.connector)throw new Error("invalid remote connector");return this.state.connector}getPlatformManager(){if(!this.state.platformManager)throw new Error("PlatformManager not available");return this.state.platformManager}isConnected(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isReady())||!1}isAuthorized(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isAuthorized())||!1}isPaused(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.isPaused()}disconnect(e){var t,n,r;Yh("[RemoteConnection: disconnect()]",e),(null==e?void 0:e.terminate)&&(pf.getProvider().handleDisconnect({terminate:!0}),null===(n=null===(t=this.state.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),this.state.otpAnswer=void 0),null===(r=this.state.connector)||void 0===r||r.disconnect(e),function(e){Yh("[RemoteConnection: cleanupConnector()] cleaning up connector"),e.connector&&(dp(e),e.connector.disconnect({terminate:!0}).catch((e=>{Yh("[RemoteConnection: cleanupConnector()] error disconnecting connector",e)})))}(this.state)}}function pp(e){var t,n,r,i,o,s,a,c,l,d,u;return $e(this,void 0,void 0,(function*(){const{options:h}=e;if(h.logging=null!==(t=h.logging)&&void 0!==t?t:{},h.communicationLayerPreference=null!==(n=h.communicationLayerPreference)&&void 0!==n?n:pa.SOCKET,void 0!==h.enableDebug&&(f.enable("MM_SDK"),console.warn("enableDebug is removed. Please use enableAnalytics instead.")),h.enableAnalytics=null===(r=h.enableAnalytics)||void 0===r||r,h.injectProvider=null===(i=h.injectProvider)||void 0===i||i,h.shouldShimWeb3=null===(o=h.shouldShimWeb3)||void 0===o||o,h.extensionOnly=null===(s=h.extensionOnly)||void 0===s||s,h.useDeeplink=null===(a=h.useDeeplink)||void 0===a||a,h.storage=null!==(c=h.storage)&&void 0!==c?c:{enabled:!0},h.headless){f("[MetaMaskSDK: performSDKInitialization()] headless mode enabled");const e=()=>{},t={install:()=>({mount:e,unmount:e})},n={installer:e};h.modals=t,h.ui=n}const p=!0===(null===(l=h.logging)||void 0===l?void 0:l.developerMode);e.debug=(null===(d=h.logging)||void 0===d?void 0:d.sdk)||p,Yh("[MetaMaskSDK: performSDKInitialization()] options",e.options);const g=Object.assign({},h.logging);p&&(g.sdk=!0,g.eciesLayer=!0,g.keyExchangeLayer=!0,g.remoteLayer=!0,g.serviceLayer=!0,g.plaintext=!0),yield function(e){var t;return $e(this,void 0,void 0,(function*(){const{options:n}=e;e.platformManager=new gf({useDeepLink:null!==(t=n.useDeeplink)&&void 0!==t&&t,preferredOpenLink:n.openDeeplink,debug:e.debug})}))}(e),yield function(e){var t,n,r,i,o,s,a,c,l;return $e(this,void 0,void 0,(function*(){const{options:d}=e,u=null===(t=e.platformManager)||void 0===t?void 0:t.getPlatformType();e.analytics=new Vf({serverUrl:null!==(n=d.communicationServerUrl)&&void 0!==n?n:Hs,enabled:d.enableAnalytics,originatorInfo:{url:null!==(r=d.dappMetadata.url)&&void 0!==r?r:"",title:null!==(i=d.dappMetadata.name)&&void 0!==i?i:"",dappId:"undefined"==typeof window||void 0===window.location?null!==(c=null!==(s=null===(o=d.dappMetadata)||void 0===o?void 0:o.name)&&void 0!==s?s:null===(a=d.dappMetadata)||void 0===a?void 0:a.url)&&void 0!==c?c:"N/A":window.location.hostname,platform:null!=u?u:"",source:null!==(l=d._source)&&void 0!==l?l:""}})}))}(e),yield function(e){var t;return $e(this,void 0,void 0,(function*(){const{options:n}=e;!0!==(null===(t=n.storage)||void 0===t?void 0:t.enabled)||n.storage.storageManager||(n.storage.storageManager=yield mf(n.storage))}))}(e),yield function(e){return $e(this,void 0,void 0,(function*(){const{options:t}=e,n=/^(http|https):\/\/[^\s]*$/;if(t.dappMetadata){t.dappMetadata.iconUrl&&!n.test(t.dappMetadata.iconUrl)&&(console.warn("Invalid dappMetadata.iconUrl: URL must start with http:// or https://"),t.dappMetadata.iconUrl=void 0),t.dappMetadata.base64Icon&&t.dappMetadata.base64Icon.length>163400&&(console.warn("Invalid dappMetadata.base64Icon: Base64-encoded icon string length must be less than 163400 characters"),t.dappMetadata.base64Icon=void 0),t.dappMetadata.url&&!n.test(t.dappMetadata.url)&&console.warn("Invalid dappMetadata.url: URL must start with http:// or https://");const e=(()=>{if("undefined"==typeof document)return;let e;const t=document.getElementsByTagName("link");for(let n=0;n<t.length;n++)"icon"!==t[n].getAttribute("rel")&&"shortcut icon"!==t[n].getAttribute("rel")||(e=t[n].getAttribute("href"));return e})();if(e&&!t.dappMetadata.iconUrl&&!t.dappMetadata.base64Icon){const n=`${window.location.protocol}//${window.location.host}${e}`;t.dappMetadata.iconUrl=n}}e.dappMetadata=t.dappMetadata}))}(e),yield(e=>$e(void 0,void 0,void 0,(function*(){const{options:t}=e,{infuraAPIKey:n}=t;if(!n)return;const r={"0x1":`https://mainnet.infura.io/v3/${n}`,"0x5":`https://goerli.infura.io/v3/${n}`,"0xaa36a7":`https://sepolia.infura.io/v3/${n}`,"0xe708":`https://linea-mainnet.infura.io/v3/${n}`,"0xe704":`https://linea-goerli.infura.io/v3/${n}`,"0x89":`https://polygon-mainnet.infura.io/v3/${n}`,"0x13881":`https://polygon-mumbai.infura.io/v3/${n}`,"0x45":`https://optimism-mainnet.infura.io/v3/${n}`,"0x1a4":`https://optimism-goerli.infura.io/v3/${n}`,"0xa4b1":`https://arbitrum-mainnet.infura.io/v3/${n}`,"0x66eed":`https://arbitrum-goerli.infura.io/v3/${n}`,"0x2a15c308d":`https://palm-mainnet.infura.io/v3/${n}`,"0x2a15c3083":`https://palm-testnet.infura.io/v3/${n}`,"0xa86a":`https://avalanche-mainnet.infura.io/v3/${n}`,"0xa869":`https://avalanche-fuji.infura.io/v3/${n}`,"0x4e454152":`https://aurora-mainnet.infura.io/v3/${n}`,"0x4e454153":`https://aurora-testnet.infura.io/v3/${n}`,"0x534e5f4d41494e":`https://starknet-mainnet.infura.io/v3/${n}`,"0x534e5f474f45524c49":`https://starknet-goerli.infura.io/v3/${n}`,"0x534e5f474f45524c4932":`https://starknet-goerli2.infura.io/v3/${n}`,"0xa4ec":`https://celo-mainnet.infura.io/v3/${n}`,"0xaef3":`https://celo-alfajores.infura.io/v3/${n}`};e.options.readonlyRPCMap?e.options.readonlyRPCMap=Object.assign(Object.assign({},e.options.readonlyRPCMap),r):e.options.readonlyRPCMap=r})))(e),yield(e=>$e(void 0,void 0,void 0,(function*(){const{options:t}=e,{readonlyRPCMap:n}=t;if(n)try{Yh("[MetaMaskSDK: setupReadOnlyRPCProviders()] Setting up Readonly RPC Providers",n),e.setReadOnlyRPCCalls(!0)}catch(e){throw new Error("Invalid Infura Settings")}})))(e);const{metamaskBrowserExtension:m,preferExtension:y,shouldReturn:v}=yield function(e){var t,n,r,i;return $e(this,void 0,void 0,(function*(){const{options:o}=e;let s,a=!1,c=!1;if("undefined"!=typeof window&&window.ethereum&&!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){a="extension"===localStorage.getItem(Tf);try{s=yield function({mustBeMetaMask:e,sdkInstance:t}){return $e(this,void 0,void 0,(function*(){if("undefined"==typeof window)throw new Error("window not available");try{const e=yield new Promise(((e,t)=>{const n=setTimeout((()=>{t(new Error("eip6963RequestProvider timed out"))}),500);window.addEventListener(Yf.Announce,(t=>{const r=t,{detail:{info:i,provider:o}={}}=r,{name:s,rdns:a,uuid:c}=null!=i?i:{};Sf.test(c)&&s.startsWith(_f.NAME)&&_f.RDNS.includes(a)&&(clearTimeout(n),e(o))})),window.dispatchEvent(new Event(Yf.Request))}));return Gf({provider:e,sdkInstance:t})}catch(n){if(!e&&window.ethereum)return Gf({provider:window.ethereum,sdkInstance:t});throw new Error("Provider not found")}}))}({mustBeMetaMask:!0,sdkInstance:e}),window.extension=s,s.on(Pf,(t=>{Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE chainChanged chainId=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Pf,t)})),s.on(If,(t=>$e(this,void 0,void 0,(function*(){var n;Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE accountsChanged accounts=${t}`);const r=Boolean(e.sdkProvider),i=Boolean(e.extensionActive);if(r&&e.getMobileProvider().emit(If,t),i&&0===(null==t?void 0:t.length)&&0===(yield null===(n=e.getProvider())||void 0===n?void 0:n.request({method:kf.WALLET_GETPERMISSIONS,params:[]})).length)try{yield e.terminate()}catch(e){Yh("[MetaMaskSDK: setupExtensionPreferences()] error terminating on permissions revoked",e)}})))),s.on(Nf,(t=>{Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE disconnect error=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Nf,t)})),s.on(Bf,(t=>{Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connect args=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Bf,t)})),s.on(Df,(t=>{Yh("[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connected",t),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Df,t)}))}catch(e){window.extension=void 0}}else(null===(n=e.platformManager)||void 0===n?void 0:n.isMetaMaskMobileWebView())&&(null===(r=e.analytics)||void 0===r||r.send({event:ea.SDK_USE_INAPP_BROWSER}),e.activeProvider=Gf({provider:window.ethereum,sdkInstance:e}),e._initialized=!0,c=!0);return s&&o.extensionOnly&&(Yh("[MetaMaskSDK: setupExtensionPreferences()] EXTENSION ONLY --- prevent sdk initialization"),null===(i=e.analytics)||void 0===i||i.send({event:ea.SDK_USE_EXTENSION}),e.activeProvider=s,e.extensionActive=!0,e.extension=s,e._initialized=!0,c=!0),{preferExtension:a,shouldReturn:c,metamaskBrowserExtension:s}}))}(e);if(v)Yh("[MetaMaskSDK: performSDKInitialization()] shouldReturn=true --- prevent sdk initialization");else{yield function(e,t){var n,r,i,o,s;return $e(this,void 0,void 0,(function*(){const{options:a}=e,c=Object.assign({},a.logging);e.remoteConnection=new fp({preferDesktop:null!==(n=a.preferDesktop)&&void 0!==n&&n,communicationLayerPreference:null!==(r=a.communicationLayerPreference)&&void 0!==r?r:pa.SOCKET,analytics:e.analytics,dappMetadata:a.dappMetadata,_source:a._source,enableAnalytics:null===(i=a.enableAnalytics)||void 0===i||i,timer:a.timer,sdk:e,platformManager:e.platformManager,transports:a.transports,communicationServerUrl:a.communicationServerUrl,storage:null!==(o=a.storage)&&void 0!==o?o:{enabled:!0},getMetaMaskInstaller:()=>{if(!e.installer)throw new Error("Invalid SDK status -- installer not initialized");return e.installer},logging:c,connectWithExtensionProvider:void 0===t?void 0:()=>Kf(e),modals:Object.assign(Object.assign({},a.modals),{onPendingModalDisconnect:e.terminate.bind(e)})}),yield e.remoteConnection.initRemoteCommunication({sdkInstance:e}),e.installer=new op({remote:e.remoteConnection,preferDesktop:null!==(s=a.preferDesktop)&&void 0!==s&&s,platformManager:e.platformManager,debug:e.debug})}))}(e,m),yield function(e){var t,n,r,i;return $e(this,void 0,void 0,(function*(){const{options:o}=e,s={communicationLayerPreference:null!==(t=o.communicationLayerPreference)&&void 0!==t?t:pa.SOCKET,platformManager:e.platformManager,sdk:e,checkInstallationOnAllCalls:o.checkInstallationOnAllCalls,injectProvider:null===(n=o.injectProvider)||void 0===n||n,shouldShimWeb3:null===(r=o.shouldShimWeb3)||void 0===r||r,extensionOnly:null===(i=o.extensionOnly)||void 0===i||i,installer:e.installer,remoteConnection:e.remoteConnection,debug:e.debug},a=yield qf(s);e.activeProvider=a,function(e){var t,n,r,i;null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n||n.on(ff.ConnectionStatus,(t=>{e.emit(ff.ConnectionStatus,t)})),null===(i=null===(r=e.remoteConnection)||void 0===r?void 0:r.getConnector())||void 0===i||i.on(ff.ServiceStatus,(t=>{e.emit(ff.ServiceStatus,t)}))}(e)}))}(e),yield function(e,t){var n,r;return $e(this,void 0,void 0,(function*(){const{options:i}=e;t?(Yh("[MetaMaskSDK: handleAutoAndExtensionConnections()] preferExtension is detected -- connect with it."),null===(n=e.analytics)||void 0===n||n.send({event:ea.SDK_EXTENSION_UTILIZED}),Kf(e).catch((e=>{console.warn("Can't connect with MetaMask extension...",e),localStorage.removeItem(Tf)}))):i.checkInstallationImmediately&&((null===(r=e.platformManager)||void 0===r?void 0:r.isDesktopWeb())?(Yh("[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately"),e.connect().catch((e=>{Yh(`[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- error on autoconnect _err=${e}`)}))):console.warn("[handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- only for web desktop")),e._initialized=!0}))}(e,y);try{yield null===(u=e.remoteConnection)||void 0===u?void 0:u.startConnection({initialCheck:!0})}catch(e){console.error("[MetaMaskSDK: setupRemoteConnectionAndInstaller()] Error while checking installation",e)}e.emit(ff.ProviderUpdate,$f.INITIALIZED)}}))}class gp extends g{constructor(e={storage:{enabled:!0},injectProvider:!0,forceInjectProvider:!1,enableAnalytics:!0,shouldShimWeb3:!0,useDeeplink:!0,extensionOnly:!0,headless:!1,dappMetadata:{name:"",url:"",iconUrl:""},_source:wf,i18nOptions:{enabled:!1}}){var t,n,r;super(),this.extensionActive=!1,this._initialized=!1,this.sdkInitPromise=void 0,this.debug=!1,this.readonlyRPCCalls=!1,this.availableLanguages=["en"],f.disable();const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode);if(((null===(n=e.logging)||void 0===n?void 0:n.sdk)||i)&&f.enable("MM_SDK"),Yh("[MetaMaskSDK: constructor()]: begin."),this.setMaxListeners(50),!(null===(r=e.dappMetadata)||void 0===r?void 0:r.url)){if("undefined"==typeof window||"undefined"==typeof document)throw new Error("You must provide dAppMetadata url");e.dappMetadata=Object.assign(Object.assign({},e.dappMetadata),{url:`${window.location.protocol}//${window.location.host}`})}this.options=e,this.options._source||(e._source=wf),this.init().then((()=>{Yh("[MetaMaskSDK: constructor()]: initialized successfully."),"undefined"!=typeof window&&(window.mmsdk=this)})).catch((e=>{console.error("[MetaMaskSDK: constructor()] error during initialization",e)}))}init(){return $e(this,void 0,void 0,(function*(){return function(e){var t;return $e(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&(null===(t=window.mmsdk)||void 0===t?void 0:t.isInitialized()))return Yh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),Promise.resolve(window.mmsdk);if(e._initialized)return Yh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),e.sdkInitPromise;if(e.sdkInitPromise)return Yh("[MetaMaskSDK: initializeMetaMaskSDK()] already initializing"),e.sdkInitPromise;try{e.sdkInitPromise=pp(e),yield e.sdkInitPromise}catch(e){throw console.error(e),e}return e.sdkInitPromise}))}(this)}))}isExtensionActive(){return this.extensionActive}checkExtensionAvailability(){var e;return"undefined"!=typeof window&&Boolean(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}connect(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){if(e._initialized||(Yh("[MetaMaskSDK: connect()] provider not ready -- wait for init()"),yield e.init()),Yh(`[MetaMaskSDK: connect()] isExtensionActive=${e.isExtensionActive()} activeProvider`,e.activeProvider),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const t=e.activeProvider.getSelectedAddress();return t?[t]:e.activeProvider.request({method:kf.ETH_REQUESTACCOUNTS,params:[]})}))}(this)}))}connectAndSign({msg:e}){return $e(this,void 0,void 0,(function*(){return function({instance:e,msg:t}){return $e(this,void 0,void 0,(function*(){if(e._initialized||(Yh("[MetaMaskSDK: connectAndSign()] provider not ready -- wait for init()"),yield e.init()),Yh(`[MetaMaskSDK: connectAndSign()] activeProvider=${e.activeProvider}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=/^0x([0-9A-Fa-f]{2})*$/u.test(t)?t:function(e){let t;if(void 0!==et)t=et.from(e,"utf8").toString("hex");else if("undefined"!=typeof TextEncoder){const n=(new TextEncoder).encode(e);t=Array.from(n).map((e=>e.toString(16).padStart(2,"0"))).join("")}else{if("object"!=typeof je||!("Buffer"in je))throw new Error("Unable to convert string to hex: No available method.");t=je.Buffer.from(e,"utf8").toString("hex")}return`0x${t}`}(t);return e.activeProvider.request({method:kf.METAMASK_CONNECTWITH,params:[{method:kf.PERSONAL_SIGN,params:[n]}]})}))}({instance:this,msg:e})}))}connectWith(e){return $e(this,void 0,void 0,(function*(){return function({instance:e,rpc:t}){return $e(this,void 0,void 0,(function*(){if(e._initialized||(Yh("[MetaMaskSDK: connectWith()] provider not ready -- wait for init()"),yield e.init()),Yh(`[MetaMaskSDK: connectWith()] method: ${t.method} rpc=${t}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");return e.activeProvider.request({method:kf.METAMASK_CONNECTWITH,params:[t]})}))}({instance:this,rpc:e})}))}resume(){return function(e){var t,n,r;return $e(this,void 0,void 0,(function*(){if(!(null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n?void 0:n.isReady()))return Yh("[MetaMaskSDK: resume()] channel is not ready -- starting connection"),void(null===(r=e.remoteConnection)||void 0===r||r.startConnection());Yh("[MetaMaskSDK: resume()] channel is ready")}))}(this)}disconnect(){return console.warn("MetaMaskSDK.disconnect() is deprecated, use terminate()"),this.terminate()}isAuthorized(){var e;null===(e=this.remoteConnection)||void 0===e||e.isAuthorized()}terminate(){return function(e){var t,n,r;return $e(this,void 0,void 0,(function*(){if(!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){if(jf&&(window.localStorage.removeItem(Tf),window.localStorage.removeItem(Rf),window.localStorage.removeItem(Of)),e.extensionActive){try{yield null===(n=e.activeProvider)||void 0===n?void 0:n.request({method:kf.WALLET_REVOKEPERMISSIONS,params:[{eth_accounts:{}}]})}catch(e){Yh("[MetaMaskSDK: terminate()] error revoking permissions",e)}return e.options.extensionOnly?(e.emit(ff.ProviderUpdate,$f.TERMINATE),void Yh("[MetaMaskSDK: terminate()] extensionOnly --- prevent switching providers")):(e.activeProvider=e.sdkProvider,window.ethereum=e.activeProvider,e.extensionActive=!1,void e.emit(ff.ProviderUpdate,$f.TERMINATE))}e.emit(ff.ProviderUpdate,$f.TERMINATE),Yh(`[MetaMaskSDK: terminate()] remoteConnection=${e.remoteConnection}`),null===(r=e.remoteConnection)||void 0===r||r.disconnect({terminate:!0,sendMessage:!0})}}))}(this)}isInitialized(){return this._initialized}setReadOnlyRPCCalls(e){this.readonlyRPCCalls=e}hasReadOnlyRPCCalls(){return this.readonlyRPCCalls}getProvider(){if(this.activeProvider)return this.activeProvider;console.warn("MetaMaskSDK: No active provider found")}getMobileProvider(){if(!this.sdkProvider)throw new Error("SDK state invalid -- undefined mobile provider");return this.sdkProvider}getUniversalLink(){var e;const t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getUniversalLink();if(!t)throw new Error("No Universal Link available, please call eth_requestAccounts first.");return t}getChannelId(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig())||void 0===t?void 0:t.channelId}getRPCHistory(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getRPCMethodTracker()}getVersion(){return bf.version}getWalletStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getConnectionStatus()}_getChannelConfig(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig()}_ping(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.ping()}_keyCheck(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.keyCheck()}_getServiceStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getServiceStatus()}_getRemoteConnection(){return this.remoteConnection}_getDappMetadata(){return this.dappMetadata}_getKeyInfo(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getKeyInfo()}_resetKeys(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.resetKeys()}_getConnection(){return this.remoteConnection}emit(e,t){return super.emit(e,t)}on(e,t){return super.on(e,t)}}var mp=Object.freeze({__proto__:null,StorageManagerWeb:class{constructor({enabled:e}={enabled:!1}){this.enabled=!1,this.enabled=e}persistChannelConfig(e){return $e(this,void 0,void 0,(function*(){const t=JSON.stringify(e);Yh(`[StorageManagerWeb: persistChannelConfig()] enabled=${this.enabled}`,e),localStorage.setItem(Lf,t)}))}getPersistedChannelConfig(){return $e(this,void 0,void 0,(function*(){let e;try{if(Yh(`[StorageManagerWeb: getPersistedChannelConfig()] enabled=${this.enabled}`),e=localStorage.getItem(Lf),Yh("[StorageManagerWeb: getPersistedChannelConfig()]",e),!e)return;const t=JSON.parse(e);return Yh("[StorageManagerWeb: getPersistedChannelConfig()] channelConfig",t),t}catch(e){return void console.error("[StorageManagerWeb: getPersistedChannelConfig()] Can't find existing channel config",e)}}))}persistAccounts(e){return $e(this,void 0,void 0,(function*(){Yh(`[StorageManagerWeb: persistAccounts()] enabled=${this.enabled}`,e);const t=JSON.stringify(e);localStorage.setItem(Of,t)}))}getCachedAccounts(){return $e(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Of);return e?JSON.parse(e):[]}catch(e){throw console.error("[StorageManagerWeb: getCachedAccounts()] Error reading cached accounts",e),e}}))}persistChainId(e){return $e(this,void 0,void 0,(function*(){Yh(`[StorageManagerWeb: persistChainId()] enabled=${this.enabled}`,e),localStorage.setItem(Rf,e)}))}getCachedChainId(){return $e(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Rf);return null!=e?e:void 0}catch(e){throw console.error("[StorageManagerWeb: getCachedChainId()] Error reading cached chainId",e),e}}))}terminate(){return $e(this,void 0,void 0,(function*(){Yh(`[StorageManagerWeb: terminate()] enabled=${this.enabled}`),localStorage.removeItem(Lf)}))}}});var yp=Object.defineProperty,vp=new WeakMap,bp=e=>vp.get(e),wp=(e,t)=>vp.set(t.$lazyInstance$=e,t),Ep=(e,t)=>t in e,Cp=(e,t)=>(0,console.error)(e,t),_p=new Map,Sp=new Map,kp="slot-fb{display:contents}slot-fb[hidden]{display:none}",xp="undefined"!=typeof window?window:{},Ap=xp.document||{head:{}},Mp={$flags$:0,$resourcesUrl$:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,r)=>e.addEventListener(t,n,r),rel:(e,t,n,r)=>e.removeEventListener(t,n,r),ce:(e,t)=>new CustomEvent(e,t)},Lp=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),Tp=!1,Op=[],Rp=[],Pp=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){Cp(e)}e.length=0},Ip=()=>{Pp(Op),Pp(Rp),(Tp=Op.length>0)&&Mp.raf(Ip)},Np=e=>Promise.resolve(void 0).then(e),Bp=((e,t)=>t=>{e.push(t),Tp||(Tp=!0,4&Mp.$flags$?Np(Ip):Mp.raf(Ip))})(Rp),Dp={},$p=e=>"object"==(e=typeof e)||"function"===e;function jp(e){var t,n,r;return null!=(r=null==(n=null==(t=e.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?r:void 0}((e,t)=>{for(var n in t)yp(e,n,{get:t[n],enumerable:!0})})({},{err:()=>Up,map:()=>Fp,ok:()=>Kp,unwrap:()=>zp,unwrapErr:()=>qp});var Kp=e=>({isOk:!0,isErr:!1,value:e}),Up=e=>({isOk:!1,isErr:!0,value:e});function Fp(e,t){if(e.isOk){const n=t(e.value);return n instanceof Promise?n.then((e=>Kp(e))):Kp(n)}if(e.isErr){const t=e.value;return Up(t)}throw"should never get here"}var Hp,zp=e=>{if(e.isOk)return e.value;throw e.value},qp=e=>{if(e.isErr)return e.value;throw e.value},Vp=(e,t,...n)=>{let r=null,i=!1,o=!1;const s=[],a=t=>{for(let n=0;n<t.length;n++)r=t[n],Array.isArray(r)?a(r):null!=r&&"boolean"!=typeof r&&((i="function"!=typeof e&&!$p(r))&&(r=String(r)),i&&o?s[s.length-1].$text$+=r:s.push(i?Wp(null,r):r),o=i)};if(a(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}if("function"==typeof e)return e(null===t?{}:t,s,Yp);const c=Wp(e,null);return c.$attrs$=t,s.length>0&&(c.$children$=s),c},Wp=(e,t)=>({$flags$:0,$tag$:e,$text$:t,$elm$:null,$children$:null,$attrs$:null}),Gp={},Yp={forEach:(e,t)=>e.map(Zp).forEach(t),map:(e,t)=>e.map(Zp).map(t).map(Jp)},Zp=e=>({vattrs:e.$attrs$,vchildren:e.$children$,vkey:e.$key$,vname:e.$name$,vtag:e.$tag$,vtext:e.$text$}),Jp=e=>{if("function"==typeof e.vtag){const t={...e.vattrs};return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),Vp(e.vtag,t,...e.vchildren||[])}const t=Wp(e.vtag,e.vtext);return t.$attrs$=e.vattrs,t.$children$=e.vchildren,t.$key$=e.vkey,t.$name$=e.vname,t},Xp=e=>bp(e).$hostElement$,Qp=(e,t,n)=>{const r=Xp(e);return{emit:e=>eg(r,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},eg=(e,t,n)=>{const r=Mp.ce(t,n);return e.dispatchEvent(r),r},tg=new WeakMap,ng=(e,t)=>"sc-"+e.$tagName$,rg=(e,t,n,r,i,o)=>{if(n!==r){let s=Ep(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,i=og(n),o=og(r);t.remove(...i.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!i.includes(e))))}else if("style"===t){for(const t in n)r&&null!=r[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in r)n&&r[t]===n[t]||(t.includes("-")?e.style.setProperty(t,r[t]):e.style[t]=r[t])}else if(s||"o"!==t[0]||"n"!==t[1]){const a=$p(r);if((s||a&&null!==r)&&!i)try{if(e.tagName.includes("-"))e[t]=r;else{const i=null==r?"":r;"list"===t?s=!1:null!=n&&e[t]==i||("function"==typeof e.__lookupSetter__(t)?e[t]=i:e.setAttribute(t,i))}}catch(e){}null==r||!1===r?!1===r&&""!==e.getAttribute(t)||e.removeAttribute(t):(!s||4&o||i)&&!a&&(r=!0===r?"":r,e.setAttribute(t,r))}else if(t="-"===t[2]?t.slice(3):Ep(xp,a)?a.slice(2):a[2]+t.slice(3),n||r){const i=t.endsWith(sg);t=t.replace(ag,""),n&&Mp.rel(e,t,n,i),r&&Mp.ael(e,t,r,i)}}},ig=/\s/,og=e=>e?e.split(ig):[],sg="Capture",ag=new RegExp(sg+"$"),cg=(e,t,n)=>{const r=11===t.$elm$.nodeType&&t.$elm$.host?t.$elm$.host:t.$elm$,i=e&&e.$attrs$||Dp,o=t.$attrs$||Dp;for(const e of lg(Object.keys(i)))e in o||rg(r,e,i[e],void 0,n,t.$flags$);for(const e of lg(Object.keys(o)))rg(r,e,i[e],o[e],n,t.$flags$)};function lg(e){return e.includes("ref")?[...e.filter((e=>"ref"!==e)),"ref"]:e}var dg=!1,ug=(e,t,n,r)=>{const i=t.$children$[n];let o,s,a=0;if(null!==i.$text$)o=i.$elm$=Ap.createTextNode(i.$text$);else{if(dg||(dg="svg"===i.$tag$),o=i.$elm$=Ap.createElementNS(dg?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.$tag$),dg&&"foreignObject"===i.$tag$&&(dg=!1),cg(null,i,dg),o.getRootNode().querySelector("body"),i.$children$)for(a=0;a<i.$children$.length;++a)s=ug(e,i,a),s&&o.appendChild(s);"svg"===i.$tag$?dg=!1:"foreignObject"===o.tagName&&(dg=!0)}return o["s-hn"]=Hp,o},hg=(e,t,n,r,i,o)=>{let s,a=e;for(a.shadowRoot&&a.tagName===Hp&&(a=a.shadowRoot);i<=o;++i)r[i]&&(s=ug(null,n,i),s&&(r[i].$elm$=s,mg(a,s,t)))},fg=(e,t,n)=>{for(let r=t;r<=n;++r){const t=e[r];if(t){const e=t.$elm$;e&&e.remove()}}},pg=(e,t,n=!1)=>e.$tag$===t.$tag$,gg=(e,t,n=!1)=>{const r=t.$elm$=e.$elm$,i=e.$children$,o=t.$children$,s=t.$tag$,a=t.$text$;null===a?(cg(e,t,dg="svg"===s||"foreignObject"!==s&&dg),null!==i&&null!==o?((e,t,n,r,i=!1)=>{let o,s=0,a=0,c=t.length-1,l=t[0],d=t[c],u=r.length-1,h=r[0],f=r[u];for(;s<=c&&a<=u;)null==l?l=t[++s]:null==d?d=t[--c]:null==h?h=r[++a]:null==f?f=r[--u]:pg(l,h,i)?(gg(l,h,i),l=t[++s],h=r[++a]):pg(d,f,i)?(gg(d,f,i),d=t[--c],f=r[--u]):pg(l,f,i)?(gg(l,f,i),mg(e,l.$elm$,d.$elm$.nextSibling),l=t[++s],f=r[--u]):pg(d,h,i)?(gg(d,h,i),mg(e,d.$elm$,l.$elm$),d=t[--c],h=r[++a]):(o=ug(t&&t[a],n,a),h=r[++a],o&&mg(l.$elm$.parentNode,o,l.$elm$));s>c?hg(e,null==r[u+1]?null:r[u+1].$elm$,n,r,a,u):a>u&&fg(t,s,c)})(r,i,t,o,n):null!==o?(null!==e.$text$&&(r.textContent=""),hg(r,null,t,o,0,o.length-1)):!n&&null!==i&&fg(i,0,i.length-1),dg&&"svg"===s&&(dg=!1)):e.$text$!==a&&(r.data=a)},mg=(e,t,n)=>null==e?void 0:e.insertBefore(t,n),yg=(e,t)=>{t&&!e.$onRenderResolve$&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.$onRenderResolve$=t)))},vg=(e,t)=>{if(e.$flags$|=16,!(4&e.$flags$))return yg(e,e.$ancestorComponent$),Bp((()=>bg(e,t)));e.$flags$|=512},bg=(e,t)=>{const n=e.$hostElement$;e.$cmpMeta$.$tagName$;const r=e.$lazyInstance$;if(!r)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);return wg(void 0,(()=>Cg(e,r,t)))},wg=(e,t)=>Eg(e)?e.then(t).catch((e=>{console.error(e),t()})):t(),Eg=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,Cg=async(e,t,n)=>{var r;const i=e.$hostElement$;e.$cmpMeta$.$tagName$;const o=i["s-rc"];n&&(e=>{const t=e.$cmpMeta$,n=e.$hostElement$,r=t.$flags$;t.$tagName$;const i=((e,t,n)=>{var r;const i=ng(t),o=Sp.get(i);if(e=11===e.nodeType?e:Ap,o)if("string"==typeof o){e=e.head||e;let n,s=tg.get(e);if(s||tg.set(e,s=new Set),!s.has(i)){{n=Ap.createElement("style"),n.innerHTML=o;const i=null!=(r=Mp.$nonce$)?r:jp(Ap);if(null!=i&&n.setAttribute("nonce",i),!(1&t.$flags$))if("HEAD"===e.nodeName){const t=e.querySelectorAll("link[rel=preconnect]"),r=t.length>0?t[t.length-1].nextSibling:e.querySelector("style");e.insertBefore(n,r)}else if("host"in e)if(Lp){const t=new CSSStyleSheet;t.replaceSync(o),e.adoptedStyleSheets=[t,...e.adoptedStyleSheets]}else{const t=e.querySelector("style");t?t.innerHTML=o+t.innerHTML:e.prepend(n)}else e.append(n);1&t.$flags$&&"HEAD"!==e.nodeName&&e.insertBefore(n,null)}4&t.$flags$&&(n.innerHTML+=kp),s&&s.add(i)}}else e.adoptedStyleSheets.includes(o)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,o]);return i})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&r&&2&r&&(n["s-sc"]=i,n.classList.add(i+"-h"))})(e),e.$cmpMeta$.$tagName$,_g(e,t,i,n),o&&(o.map((e=>e())),i["s-rc"]=void 0);{const t=null!=(r=i["s-p"])?r:[],n=()=>Sg(e);0===t.length?n():(Promise.all(t).then(n),e.$flags$|=4,t.length=0)}},_g=(e,t,n,r)=>{try{t=t.render(),e.$flags$&=-17,e.$flags$|=2,((e,t,n=!1)=>{const r=e.$hostElement$,i=e.$cmpMeta$,o=e.$vnode$||Wp(null,null),s=(a=t)&&a.$tag$===Gp?t:Vp(null,null,t);var a;if(Hp=r.tagName,n&&s.$attrs$)for(const e of Object.keys(s.$attrs$))r.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(s.$attrs$[e]=r[e]);s.$tag$=null,s.$flags$|=4,e.$vnode$=s,s.$elm$=o.$elm$=r.shadowRoot||r,r["s-sc"],0!=(1&i.$flags$),gg(o,s,n)})(e,t,r)}catch(t){Cp(t,e.$hostElement$)}return null},Sg=e=>{e.$cmpMeta$.$tagName$;const t=e.$hostElement$,n=e.$lazyInstance$,r=e.$ancestorComponent$;64&e.$flags$||(e.$flags$|=64,Ag(t),xg(n,"componentDidLoad"),e.$onReadyResolve$(t),r||kg()),e.$onRenderResolve$&&(e.$onRenderResolve$(),e.$onRenderResolve$=void 0),512&e.$flags$&&Np((()=>vg(e,!1))),e.$flags$&=-517},kg=e=>{Ag(Ap.documentElement),Np((()=>eg(xp,"appload",{detail:{namespace:"sdk-install-modal-web"}})))},xg=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){Cp(e)}},Ag=e=>e.classList.add(("hydrated","hydrated")),Mg=(e,t,n)=>{var r,i;const o=e.prototype;if(t.$members$||t.$watchers$||e.watchers){e.watchers&&!t.$watchers$&&(t.$watchers$=e.watchers);const s=Object.entries(null!=(r=t.$members$)?r:{});if(s.map((([e,[r]])=>{(31&r||2&n&&32&r)&&Object.defineProperty(o,e,{get(){return t=e,bp(this).$instanceValues$.get(t);var t},set(n){((e,t,n,r)=>{const i=bp(e);if(!i)throw new Error(`Couldn't find host element for "${r.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`);const o=i.$hostElement$,s=i.$instanceValues$.get(t),a=i.$flags$,c=i.$lazyInstance$;var l,d;l=n,d=r.$members$[t][0],n=null==l||$p(l)?l:4&d?"false"!==l&&(""===l||!!l):1&d?String(l):l;const u=Number.isNaN(s)&&Number.isNaN(n);if((!(8&a)||void 0===s)&&n!==s&&!u&&(i.$instanceValues$.set(t,n),c)){if(r.$watchers$&&128&a){const e=r.$watchers$[t];e&&e.map((e=>{try{c[e](n,s,t)}catch(e){Cp(e,o)}}))}2==(18&a)&&vg(i,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0})})),1&n){const n=new Map;o.attributeChangedCallback=function(e,r,i){Mp.jmp((()=>{var s;const a=n.get(e);if(this.hasOwnProperty(a))i=this[a],delete this[a];else{if(o.hasOwnProperty(a)&&"number"==typeof this[a]&&this[a]==i)return;if(null==a){const n=bp(this),o=null==n?void 0:n.$flags$;if(o&&!(8&o)&&128&o&&i!==r){const o=n.$lazyInstance$,a=null==(s=t.$watchers$)?void 0:s[e];null==a||a.forEach((t=>{null!=o[t]&&o[t].call(o,i,r,e)}))}return}}this[a]=(null!==i||"boolean"!=typeof this[a])&&i}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(i=t.$watchers$)?i:{}),...s.filter((([e,t])=>15&t[0])).map((([e,t])=>{const r=t[1]||e;return n.set(r,e),r}))]))}}return e},Lg=e=>{xg(e,"connectedCallback")},Tg=e=>{xg(e,"disconnectedCallback")},Og=(e,t={})=>{var n;const r=[],i=t.exclude||[],o=xp.customElements,s=Ap.head,a=s.querySelector("meta[charset]"),c=Ap.createElement("style"),l=[];let d,u=!0;Object.assign(Mp,t),Mp.$resourcesUrl$=new URL(t.resourcesUrl||"./",Ap.baseURI).href;let h=!1;if(e.map((e=>{e[1].map((t=>{var n;const s={$flags$:t[0],$tagName$:t[1],$members$:t[2],$listeners$:t[3]};4&s.$flags$&&(h=!0),s.$members$=t[2],s.$watchers$=null!=(n=t[4])?n:{};const a=s.$tagName$,c=class extends HTMLElement{constructor(e){if(super(e),this.hasRegisteredEventListeners=!1,((e,t)=>{const n={$flags$:0,$hostElement$:e,$cmpMeta$:t,$instanceValues$:new Map};n.$onReadyPromise$=new Promise((e=>n.$onReadyResolve$=e)),e["s-p"]=[],e["s-rc"]=[],vp.set(e,n)})(e=this,s),1&s.$flags$)if(e.shadowRoot){if("open"!==e.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${s.$tagName$}! Mode is set to ${e.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else e.attachShadow({mode:"open"})}connectedCallback(){bp(this),this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),d&&(clearTimeout(d),d=null),u?l.push(this):Mp.jmp((()=>(e=>{if(0==(1&Mp.$flags$)){const t=bp(e),n=t.$cmpMeta$;if(n.$tagName$,1&t.$flags$)(null==t?void 0:t.$lazyInstance$)?Lg(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Lg(t.$lazyInstance$)));else{t.$flags$|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){yg(t,t.$ancestorComponent$=n);break}}n.$members$&&Object.entries(n.$members$).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,r)=>{let i;if(0==(32&t.$flags$)){if(t.$flags$|=32,n.$lazyBundleId$){const r=((e,t,n)=>{const r=e.$tagName$.replace(/-/g,"_"),i=e.$lazyBundleId$;if(!i)return;const o=_p.get(i);if(o)return o[r];{const e=e=>(_p.set(i,e),e[r]);if("mm-install-modal_3"===i)return Promise.resolve().then((function(){return mm})).then(e,Cp)}return import(`./${i}.entry.js`).then((e=>(_p.set(i,e),e[r])),Cp)})(n);if(i=r&&"then"in r?await r:r,!i)throw new Error(`Constructor for "${n.$tagName$}#${t.$modeName$}" was not found`);i.isProxied||(n.$watchers$=i.watchers,Mg(i,n,2),i.isProxied=!0),n.$tagName$,t.$flags$|=8;try{new i(t)}catch(e){Cp(e)}t.$flags$&=-9,t.$flags$|=128,Lg(t.$lazyInstance$)}else{i=e.constructor;const n=e.localName;customElements.whenDefined(n).then((()=>t.$flags$|=128))}if(i&&i.style){let e;"string"==typeof i.style&&(e=i.style);const t=ng(n);Sp.has(t)||(n.$tagName$,((e,t,n)=>{let r=Sp.get(e);Lp&&n?(r=r||new CSSStyleSheet,"string"==typeof r?r=t:r.replaceSync(t)):r=t,Sp.set(e,r)})(t,e,!!(1&n.$flags$)))}}const o=t.$ancestorComponent$,s=()=>vg(t,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()})(e,t,n)}}})(this)))}disconnectedCallback(){Mp.jmp((()=>(async e=>{if(0==(1&Mp.$flags$)){const t=bp(e);(null==t?void 0:t.$lazyInstance$)?Tg(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Tg(t.$lazyInstance$)))}})(this)))}componentOnReady(){return bp(this).$onReadyPromise$}};s.$lazyBundleId$=e[0],i.includes(a)||o.get(a)||(r.push(a),o.define(a,Mg(c,s,1)))}))})),r.length>0&&(h&&(c.textContent+=kp),c.textContent+=r.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",c.innerHTML.length)){c.setAttribute("data-styles","");const e=null!=(n=Mp.$nonce$)?n:jp(Ap);null!=e&&c.setAttribute("nonce",e),s.insertBefore(c,a?a.nextSibling:s.firstChild)}u=!1,l.length?l.map((e=>e.connectedCallback())):Mp.jmp((()=>d=setTimeout(kg,30)))};!function(){if("undefined"!=typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var e=HTMLElement;window.HTMLElement=function(){return Reflect.construct(e,[],this.constructor)},HTMLElement.prototype=e.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,e)}}();var Rg=Object.freeze({__proto__:null,defineCustomElements:async(e,t)=>{if("undefined"!=typeof window)return await void 0,Og([["mm-install-modal_3",[[1,"mm-install-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}],[1,"mm-pending-modal",{displayOTP:[4,"display-o-t-p"],sdkVersion:[1,"sdk-version"],otpCode:[1,"otp-code"],translationsLoaded:[32]}],[1,"mm-select-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}]]]],t)},setNonce:e=>Mp.$nonce$=e});const Pg={fontFamily:"Roboto, sans-serif"},Ig=({className:e},t)=>Vp("div",{style:Pg,class:e},t),Ng=({Icon:e,text:t})=>Vp("div",{class:"flexContainer",style:{padding:"6",flexDirection:"row"}},Vp("div",{class:"flexItem1"},Vp(e,null)),Vp("div",{class:"flexItem11"},Vp("span",{style:{lineHeight:"2",color:"black"}},t))),Bg=()=>Vp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M20.0002 7.9702V10.0302C20.0002 10.5802 19.5602 11.0302 19.0002 11.0502H17.0402C15.9602 11.0502 14.9702 10.2602 14.8802 9.1802C14.8202 8.5502 15.0602 7.9602 15.4802 7.5502C15.8502 7.1702 16.3602 6.9502 16.9202 6.9502H19.0002C19.5602 6.9702 20.0002 7.4202 20.0002 7.9702Z",fill:"#037DD6"}),Vp("path",{d:"M18.47 12.55H17.04C15.14 12.55 13.54 11.12 13.38 9.3C13.29 8.26 13.67 7.22 14.43 6.48C15.07 5.82 15.96 5.45 16.92 5.45H18.47C18.76 5.45 19 5.21 18.97 4.92C18.75 2.49 17.14 0.83 14.75 0.55C14.51 0.51 14.26 0.5 14 0.5H5C4.72 0.5 4.45 0.52 4.19 0.56C1.64 0.88 0 2.78 0 5.5V12.5C0 15.26 2.24 17.5 5 17.5H14C16.8 17.5 18.73 15.75 18.97 13.08C19 12.79 18.76 12.55 18.47 12.55ZM11 6.75H5C4.59 6.75 4.25 6.41 4.25 6C4.25 5.59 4.59 5.25 5 5.25H11C11.41 5.25 11.75 5.59 11.75 6C11.75 6.41 11.41 6.75 11 6.75Z",fill:"#037DD6"})),Dg=()=>Vp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M14.44 0.0999756C12.63 0.0999756 11.01 0.979976 10 2.32998C8.99 0.979976 7.37 0.0999756 5.56 0.0999756C2.49 0.0999756 0 2.59998 0 5.68998C0 6.87998 0.19 7.97998 0.52 8.99998C2.1 14 6.97 16.99 9.38 17.81C9.72 17.93 10.28 17.93 10.62 17.81C13.03 16.99 17.9 14 19.48 8.99998C19.81 7.97998 20 6.87998 20 5.68998C20 2.59998 17.51 0.0999756 14.44 0.0999756Z",fill:"#037DD6"})),$g=()=>Vp("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M16.28 7.53V6.28C16.28 3.58 15.63 0 10 0C4.37 0 3.72 3.58 3.72 6.28V7.53C0.92 7.88 0 9.3 0 12.79V14.65C0 18.75 1.25 20 5.35 20H14.65C18.75 20 20 18.75 20 14.65V12.79C20 9.3 19.08 7.88 16.28 7.53ZM10 16.74C8.33 16.74 6.98 15.38 6.98 13.72C6.98 12.05 8.34 10.7 10 10.7C11.66 10.7 13.02 12.06 13.02 13.72C13.02 15.39 11.67 16.74 10 16.74ZM5.35 7.44C5.27 7.44 5.2 7.44 5.12 7.44V6.28C5.12 3.35 5.95 1.4 10 1.4C14.05 1.4 14.88 3.35 14.88 6.28V7.45C14.8 7.45 14.73 7.45 14.65 7.45H5.35V7.44Z",fill:"#037DD6"})),jg=()=>Vp("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M16.4405 8.8999C20.0405 9.2099 21.5105 11.0599 21.5105 15.1099V15.2399C21.5105 19.7099 19.7205 21.4999 15.2505 21.4999H8.74047C4.27047 21.4999 2.48047 19.7099 2.48047 15.2399V15.1099C2.48047 11.0899 3.93047 9.2399 7.47047 8.9099",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M12 2V14.88",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M15.3504 12.6499L12.0004 15.9999L8.65039 12.6499",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}));function Kg({version:e}){return Vp("div",{style:{textAlign:"center",color:"#BBC0C5",fontSize:"12"}},"SDK Version ",e?`v${e}`:"unknown")}const Ug=()=>Vp("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("rect",{width:"16",height:"16",fill:"white"}),Vp("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2.40554 2.40554C2.94627 1.86482 3.82296 1.86482 4.36369 2.40554L8 6.04186L11.6363 2.40554C12.177 1.86482 13.0537 1.86482 13.5945 2.40554C14.1352 2.94627 14.1352 3.82296 13.5945 4.36369L9.95814 8L13.5945 11.6363C14.1352 12.177 14.1352 13.0537 13.5945 13.5945C13.0537 14.1352 12.177 14.1352 11.6363 13.5945L8 9.95814L4.36369 13.5945C3.82296 14.1352 2.94627 14.1352 2.40554 13.5945C1.86482 13.0537 1.86482 12.177 2.40554 11.6363L6.04186 8L2.40554 4.36369C1.86482 3.82296 1.86482 2.94627 2.40554 2.40554Z",fill:"#BBC0C5"})),Fg=()=>Vp("svg",{width:"273",height:"51",viewBox:"0 0 273 51",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M240.882 25.9263C239.472 24.997 237.916 24.3361 236.443 23.5101C235.489 22.9731 234.473 22.4982 233.643 21.8167C232.233 20.6602 232.524 18.3885 233.996 17.3973C236.112 15.993 239.617 16.7777 239.99 19.6483C239.99 19.7102 240.052 19.7515 240.114 19.7515H243.308C243.391 19.7515 243.454 19.6896 243.433 19.607C243.267 17.6244 242.5 15.9723 241.089 14.9191C239.741 13.9072 238.206 13.3702 236.568 13.3702C228.127 13.3702 227.359 22.271 231.901 25.0796C232.42 25.41 236.879 27.6404 238.455 28.611C240.032 29.5816 240.529 31.3576 239.845 32.7619C239.223 34.0423 237.605 34.9303 235.987 34.8271C234.224 34.7238 232.855 33.7738 232.378 32.2869C232.295 32.0185 232.254 31.5022 232.254 31.275C232.254 31.2131 232.192 31.1511 232.129 31.1511H228.666C228.604 31.1511 228.541 31.2131 228.541 31.275C228.541 33.7738 229.164 35.1575 230.864 36.4172C232.461 37.615 234.203 38.1106 236.008 38.1106C240.737 38.1106 243.184 35.4466 243.682 32.6793C244.117 29.974 243.308 27.5371 240.882 25.9263Z",fill:"#24292E"}),Vp("path",{d:"M90.4943 13.8246H88.9595H87.2795C87.2173 13.8246 87.1758 13.8659 87.1551 13.9072L84.3137 23.2416C84.2722 23.3655 84.1063 23.3655 84.0648 23.2416L81.2234 13.9072C81.2026 13.8452 81.1612 13.8246 81.0989 13.8246H79.419H77.8842H75.8102C75.748 13.8246 75.6857 13.8865 75.6857 13.9485V37.7802C75.6857 37.8422 75.748 37.9041 75.8102 37.9041H79.2738C79.336 37.9041 79.3982 37.8422 79.3982 37.7802V19.6689C79.3982 19.5244 79.6056 19.5037 79.6471 19.6276L82.5093 29.024L82.7167 29.6849C82.7374 29.7468 82.7789 29.7675 82.8411 29.7675H85.4959C85.5581 29.7675 85.5996 29.7262 85.6203 29.6849L85.8277 29.024L88.6899 19.6276C88.7313 19.4831 88.9387 19.5244 88.9387 19.6689V37.7802C88.9387 37.8422 89.001 37.9041 89.0632 37.9041H92.5268C92.589 37.9041 92.6513 37.8422 92.6513 37.7802V13.9485C92.6513 13.8865 92.589 13.8246 92.5268 13.8246H90.4943Z",fill:"#24292E"}),Vp("path",{d:"M187.849 13.8246C187.787 13.8246 187.745 13.8659 187.725 13.9072L184.883 23.2416C184.842 23.3655 184.676 23.3655 184.634 23.2416L181.793 13.9072C181.772 13.8452 181.731 13.8246 181.668 13.8246H176.4C176.338 13.8246 176.276 13.8865 176.276 13.9485V37.7802C176.276 37.8422 176.338 37.9041 176.4 37.9041H179.864C179.926 37.9041 179.988 37.8422 179.988 37.7802V19.6689C179.988 19.5244 180.196 19.5037 180.237 19.6276L183.099 29.024L183.307 29.6849C183.328 29.7468 183.369 29.7675 183.431 29.7675H186.086C186.148 29.7675 186.19 29.7262 186.211 29.6849L186.418 29.024L189.28 19.6276C189.322 19.4831 189.529 19.5244 189.529 19.6689V37.7802C189.529 37.8422 189.591 37.9041 189.653 37.9041H193.117C193.179 37.9041 193.241 37.8422 193.241 37.7802V13.9485C193.241 13.8865 193.179 13.8246 193.117 13.8246H187.849Z",fill:"#24292E"}),Vp("path",{d:"M143.174 13.8246H136.724H133.261H126.81C126.748 13.8246 126.686 13.8865 126.686 13.9485V16.9223C126.686 16.9843 126.748 17.0462 126.81 17.0462H133.136V37.7802C133.136 37.8422 133.198 37.9041 133.261 37.9041H136.724C136.786 37.9041 136.849 37.8422 136.849 37.7802V17.0462H143.174C143.237 17.0462 143.299 16.9843 143.299 16.9223V13.9485C143.299 13.8865 143.257 13.8246 143.174 13.8246Z",fill:"#24292E"}),Vp("path",{d:"M163.604 37.9041H166.756C166.839 37.9041 166.901 37.8215 166.881 37.7389L160.368 13.8245C160.347 13.7626 160.306 13.7419 160.244 13.7419H159.041H156.925H155.722C155.66 13.7419 155.619 13.7832 155.598 13.8245L149.085 37.7389C149.065 37.8215 149.127 37.9041 149.21 37.9041H152.362C152.425 37.9041 152.466 37.8628 152.487 37.8215L154.374 30.862C154.395 30.8 154.436 30.7794 154.499 30.7794H161.467C161.53 30.7794 161.571 30.8207 161.592 30.862L163.479 37.8215C163.5 37.8628 163.562 37.9041 163.604 37.9041ZM155.328 27.3719L157.859 18.0581C157.9 17.9342 158.066 17.9342 158.107 18.0581L160.638 27.3719C160.659 27.4545 160.596 27.5371 160.513 27.5371H155.453C155.37 27.5371 155.308 27.4545 155.328 27.3719Z",fill:"#24292E"}),Vp("path",{d:"M217.362 37.9041H220.515C220.598 37.9041 220.66 37.8215 220.639 37.7389L214.127 13.8245C214.106 13.7626 214.065 13.7419 214.002 13.7419H212.8H210.684H209.481C209.419 13.7419 209.377 13.7832 209.357 13.8245L202.844 37.7389C202.823 37.8215 202.886 37.9041 202.969 37.9041H206.121C206.183 37.9041 206.225 37.8628 206.246 37.8215L208.133 30.862C208.154 30.8 208.195 30.7794 208.257 30.7794H215.226C215.288 30.7794 215.33 30.8207 215.351 30.862L217.238 37.8215C217.259 37.8628 217.3 37.9041 217.362 37.9041ZM209.087 27.3719L211.617 18.0581C211.659 17.9342 211.825 17.9342 211.866 18.0581L214.397 27.3719C214.417 27.4545 214.355 27.5371 214.272 27.5371H209.211C209.129 27.5371 209.066 27.4545 209.087 27.3719Z",fill:"#24292E"}),Vp("path",{d:"M106.713 34.3727V26.9795C106.713 26.9176 106.775 26.8556 106.837 26.8556H116.067C116.129 26.8556 116.191 26.7936 116.191 26.7317V23.7579C116.191 23.6959 116.129 23.634 116.067 23.634H106.837C106.775 23.634 106.713 23.572 106.713 23.5101V17.1907C106.713 17.1288 106.775 17.0668 106.837 17.0668H117.332C117.394 17.0668 117.457 17.0049 117.457 16.9429V13.9691C117.457 13.9072 117.394 13.8452 117.332 13.8452H106.713H103.125C103.063 13.8452 103.001 13.9072 103.001 13.9691V17.0668V23.6546V26.8763V34.5173V37.7802C103.001 37.8422 103.063 37.9041 103.125 37.9041H106.713H117.768C117.83 37.9041 117.892 37.8422 117.892 37.7802V34.6412C117.892 34.5792 117.83 34.5173 117.768 34.5173H106.817C106.755 34.4966 106.713 34.4553 106.713 34.3727Z",fill:"#24292E"}),Vp("path",{d:"M272.532 37.6976L260.544 25.3687C260.502 25.3274 260.502 25.2448 260.544 25.2035L271.329 14.0517C271.412 13.9691 271.349 13.8452 271.246 13.8452H266.828C266.787 13.8452 266.766 13.8659 266.745 13.8865L257.599 23.3449C257.516 23.4275 257.391 23.3655 257.391 23.2623V13.9691C257.391 13.9072 257.329 13.8452 257.267 13.8452H253.803C253.741 13.8452 253.679 13.9072 253.679 13.9691V37.8009C253.679 37.8628 253.741 37.9248 253.803 37.9248H257.267C257.329 37.9248 257.391 37.8628 257.391 37.8009V27.3099C257.391 27.2067 257.536 27.1447 257.599 27.2273L267.969 37.8835C267.989 37.9041 268.031 37.9248 268.052 37.9248H272.469C272.552 37.9041 272.615 37.7596 272.532 37.6976Z",fill:"#24292E"}),Vp("path",{d:"M52.021 1L31.0526 16.4886L34.9517 7.36063L52.021 1Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M3.65491 1L24.4366 16.6331L20.7241 7.36063L3.65491 1Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M44.4716 36.9127L38.8925 45.4211L50.8389 48.7047L54.261 37.0986L44.4716 36.9127Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M1.43555 37.0986L4.83695 48.7047L16.7626 45.4211L11.2042 36.9127L1.43555 37.0986Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.1197 22.5395L12.8013 27.5371L24.6232 28.074L24.2292 15.3734L16.1197 22.5395Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M39.5561 22.5394L31.3222 15.2288L31.0526 28.0739L42.8746 27.537L39.5561 22.5394Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.7626 45.4212L23.918 41.9724L17.7582 37.1813L16.7626 45.4212Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.7578 41.9724L38.8925 45.4212L37.9177 37.1813L31.7578 41.9724Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M38.8923 45.4212L31.7577 41.9724L32.3384 46.5983L32.2762 48.5602L38.8923 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.7625 45.4212L23.3994 48.5602L23.3579 46.5983L23.9179 41.9724L16.7625 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M23.5239 34.1249L17.5922 32.3902L21.7818 30.4696L23.5239 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M32.1517 34.1249L33.8939 30.4696L38.1042 32.3902L32.1517 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.7626 45.4212L17.7996 36.9128L11.2042 37.0987L16.7626 45.4212Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M37.8761 36.9128L38.8924 45.4212L44.4715 37.0987L37.8761 36.9128Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M42.8745 27.5371L31.0526 28.074L32.1518 34.1249L33.894 30.4696L38.1042 32.3902L42.8745 27.5371Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M17.5922 32.3902L21.7817 30.4696L23.5239 34.1249L24.6232 28.074L12.8012 27.5371L17.5922 32.3902Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M12.8013 27.5371L17.7582 37.1813L17.5923 32.3902L12.8013 27.5371Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M38.1044 32.3902L37.9177 37.1813L42.8746 27.5371L38.1044 32.3902Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M24.6232 28.0741L23.524 34.125L24.9136 41.2703L25.2247 31.8533L24.6232 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.0526 28.0741L30.4719 31.8327L30.7623 41.2703L32.1519 34.125L31.0526 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M32.1519 34.1249L30.7623 41.2702L31.7578 41.9724L37.9177 37.1813L38.1043 32.3901L32.1519 34.1249Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M17.5922 32.3901L17.7581 37.1813L23.918 41.9724L24.9135 41.2702L23.5239 34.1249L17.5922 32.3901Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M32.2763 48.5602L32.3385 46.5983L31.7993 46.1439H23.8765L23.358 46.5983L23.3995 48.5602L16.7626 45.4211L19.0855 47.3211L23.7935 50.5633H31.8615L36.5903 47.3211L38.8924 45.4211L32.2763 48.5602Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.7578 41.9724L30.7622 41.2703H24.9135L23.918 41.9724L23.358 46.5983L23.8765 46.144H31.7993L32.3385 46.5983L31.7578 41.9724Z",fill:"#24292E",stroke:"#24292E","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M52.9128 17.5005L54.6757 8.95079L52.021 1L31.7578 15.9723L39.5561 22.5394L50.5692 25.7404L52.9958 22.9111L51.938 22.147L53.618 20.6188L52.3321 19.6276L54.0121 18.3472L52.9128 17.5005Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M1 8.95079L2.78366 17.5005L1.64295 18.3472L3.34365 19.6276L2.05775 20.6188L3.73771 22.147L2.67996 22.9111L5.10657 25.7404L16.1196 22.5394L23.918 15.9723L3.65475 1L1 8.95079Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M50.5692 25.7404L39.5561 22.5394L42.8746 27.5371L37.9177 37.1813L44.4716 37.0987H54.261L50.5692 25.7404Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.1196 22.5394L5.10651 25.7404L1.43549 37.0987H11.2041L17.7581 37.1813L12.8011 27.5371L16.1196 22.5394Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.0526 28.0741L31.7578 15.9724L34.9518 7.36072H20.7239L23.9179 15.9724L24.6231 28.0741L24.8927 31.8739L24.9135 41.2703H30.7622L30.783 31.8739L31.0526 28.0741Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}));function Hg(e,t){return e.toString(2).padStart(t,"0")}function zg(e,t){const n=e%t;return n>=0?n:t+n}function qg(e,t){return new Array(e).fill(t)}function Vg(...e){let t=0;for(const n of e)t=Math.max(t,n.length);const n=[];for(let r=0;r<t;r++)for(const t of e)r>=t.length||n.push(t[r]);return new Uint8Array(n)}function Wg(e,t,n){if(n<0||n+t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[n+r])return!1;return!0}function Gg(e){return{has:t=>e.includes(t),decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))},encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(function(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))}}}class Yg{static size(e,t){if("number"==typeof e&&(e={height:e,width:e}),!Number.isSafeInteger(e.height)&&e.height!==1/0)throw new Error(`Bitmap: wrong height=${e.height} (${typeof e.height})`);if(!Number.isSafeInteger(e.width)&&e.width!==1/0)throw new Error(`Bitmap: wrong width=${e.width} (${typeof e.width})`);return void 0!==t&&(e={width:Math.min(e.width,t.width),height:Math.min(e.height,t.height)}),e}static fromString(e){const t=(e=e.replace(/^\n+/g,"").replace(/\n+$/g,"")).split("\n"),n=t.length,r=new Array(n);let i;for(const e of t){const t=e.split("").map((e=>{if("X"===e)return!0;if(" "===e)return!1;if("?"!==e)throw new Error(`Bitmap.fromString: unknown symbol=${e}`)}));if(i&&t.length!==i)throw new Error(`Bitmap.fromString different row sizes: width=${i} cur=${t.length}`);i=t.length,r.push(t)}return i||(i=0),new Yg({height:n,width:i},r)}constructor(e,t){const{height:n,width:r}=Yg.size(e);this.data=t||Array.from({length:n},(()=>qg(r,void 0))),this.height=n,this.width=r}point(e){return this.data[e.y][e.x]}isInside(e){return 0<=e.x&&e.x<this.width&&0<=e.y&&e.y<this.height}size(e){if(!e)return{height:this.height,width:this.width};const{x:t,y:n}=this.xy(e);return{height:this.height-n,width:this.width-t}}xy(e){if("number"==typeof e&&(e={x:e,y:e}),!Number.isSafeInteger(e.x))throw new Error(`Bitmap: wrong x=${e.x}`);if(!Number.isSafeInteger(e.y))throw new Error(`Bitmap: wrong y=${e.y}`);return e.x=zg(e.x,this.width),e.y=zg(e.y,this.height),e}rect(e,t,n){const{x:r,y:i}=this.xy(e),{height:o,width:s}=Yg.size(t,this.size({x:r,y:i}));for(let e=0;e<o;e++)for(let t=0;t<s;t++)this.data[i+e][r+t]="function"==typeof n?n({x:t,y:e},this.data[i+e][r+t]):n;return this}rectRead(e,t,n){return this.rect(e,t,((e,t)=>(n(e,t),t)))}hLine(e,t,n){return this.rect(e,{width:t,height:1},n)}vLine(e,t,n){return this.rect(e,{width:1,height:t},n)}border(e=2,t){const n=this.height+2*e,r=this.width+2*e,i=qg(e,t),o=Array.from({length:e},(()=>qg(r,t)));return new Yg({height:n,width:r},[...o,...this.data.map((e=>[...i,...e,...i])),...o])}embed(e,t){return this.rect(e,t.size(),(({x:e,y:n})=>t.data[n][e]))}rectSlice(e,t=this.size()){const n=new Yg(Yg.size(t,this.size(this.xy(e))));return this.rect(e,t,(({x:e,y:t},r)=>n.data[t][e]=r)),n}inverse(){const{height:e,width:t}=this;return new Yg({height:t,width:e}).rect({x:0,y:0},1/0,(({x:e,y:t})=>this.data[e][t]))}scale(e){if(!Number.isSafeInteger(e)||e>1024)throw new Error(`Wrong scale factor: ${e}`);const{height:t,width:n}=this;return new Yg({height:e*t,width:e*n}).rect({x:0,y:0},1/0,(({x:t,y:n})=>this.data[Math.floor(n/e)][Math.floor(t/e)]))}clone(){return new Yg(this.size()).rect({x:0,y:0},this.size(),(({x:e,y:t})=>this.data[t][e]))}assertDrawn(){this.rectRead(0,1/0,((e,t)=>{if("boolean"!=typeof t)throw new Error("Invalid color type="+typeof t)}))}toString(){return this.data.map((e=>e.map((e=>void 0===e?"?":e?"X":" ")).join(""))).join("\n")}toASCII(){const{height:e,width:t,data:n}=this;let r="";for(let i=0;i<e;i+=2){for(let o=0;o<t;o++){const t=n[i][o],s=i+1>=e||n[i+1][o];t||s?!t&&s?r+="▀":t&&!s?r+="▄":t&&s&&(r+=" "):r+="█"}r+="\n"}return r}toTerm(){const e="",t=` ${e}`,n=` ${e}`;return this.data.map((e=>e.map((e=>e?n:t)).join(""))).join("\n")}toSVG(){let e=`<svg xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 ${this.width} ${this.height}" version="1.1" xmlns="http://www.w3.org/2000/svg">`;return this.rectRead(0,1/0,(({x:t,y:n},r)=>{r&&(e+=`<rect x="${t}" y="${n}" width="1" height="1" />`)})),e+="</svg>",e}toGIF(){const e=e=>[255&e,e>>>8&255],t=[...e(this.width),...e(this.height)],n=[];this.rectRead(0,1/0,((e,t)=>n.push(+(!0===t))));const r=126,i=[71,73,70,56,55,97,...t,246,0,0,255,255,255,...qg(381,0),44,0,0,0,0,...t,0,7],o=Math.floor(n.length/r);for(let e=0;e<o;e++)i.push(127,128,...n.slice(r*e,r*(e+1)).map((e=>+e)));return i.push(n.length%r+1,128,...n.slice(o*r).map((e=>+e))),i.push(1,129,0,59),new Uint8Array(i)}toImage(e=!1){const{height:t,width:n}=this.size(),r=new Uint8Array(t*n*(e?3:4));let i=0;for(let o=0;o<t;o++)for(let t=0;t<n;t++){const n=this.data[o][t]?0:255;r[i++]=n,r[i++]=n,r[i++]=n,e||(r[i++]=255)}return{height:t,width:n,data:r}}}const Zg=["low","medium","quartile","high"],Jg=["numeric","alphanumeric","byte","kanji","eci"],Xg=[26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],Qg={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},em={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},tm={size:{encode:e=>21+4*(e-1),decode:e=>(e-17)/4},sizeType:e=>Math.floor((e+7)/17),alignmentPatterns(e){if(1===e)return[];const t=tm.size.encode(e)-6-1,n=t-6,r=Math.ceil(n/28);let i=Math.floor(n/r);i%2?i+=1:n%r*2>=r&&(i+=2);const o=[6];for(let e=1;e<r;e++)o.push(t-(r-e)*i);return o.push(t),o},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(e,t){const n=tm.ECCode[e]<<3|t;let r=n;for(let e=0;e<10;e++)r=r<<1^1335*(r>>9);return(n<<10|r)^tm.formatMask},versionBits(e){let t=e;for(let e=0;e<12;e++)t=t<<1^7973*(t>>11);return e<<12|t},alphabet:{numeric:Gg("0123456789"),alphanumerc:Gg("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(e,t)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]}[t][tm.sizeType(e)]),modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(e,t){const n=Xg[e-1],r=Qg[t][e-1],i=em[t][e-1],o=Math.floor(n/i)-r,s=i-n%i;return{words:r,numBlocks:i,shortBlocks:s,blockLen:o,capacity:8*(n-r*i),total:(r+o)*i+i-s}}},nm=[(e,t)=>(e+t)%2==0,(e,t)=>t%2==0,(e,t)=>e%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(t/2)+Math.floor(e/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0],rm={tables:(e=>{const t=qg(256,0),n=qg(256,0);for(let e=0,r=1;e<256;e++)t[e]=r,n[r]=e,r<<=1,256&r&&(r^=285);return{exp:t,log:n}})(),exp:e=>rm.tables.exp[e],log(e){if(0===e)throw new Error(`GF.log: wrong arg=${e}`);return rm.tables.log[e]%255},mul:(e,t)=>0===e||0===t?0:rm.tables.exp[(rm.tables.log[e]+rm.tables.log[t])%255],add:(e,t)=>e^t,pow:(e,t)=>rm.tables.exp[rm.tables.log[e]*t%255],inv(e){if(0===e)throw new Error(`GF.inverse: wrong arg=${e}`);return rm.tables.exp[255-rm.tables.log[e]]},polynomial(e){if(0==e.length)throw new Error("GF.polymomial: wrong length");if(0!==e[0])return e;let t=0;for(;t<e.length-1&&0==e[t];t++);return e.slice(t)},monomial(e,t){if(e<0)throw new Error(`GF.monomial: wrong degree=${e}`);if(0==t)return[0];let n=qg(e+1,0);return n[0]=t,rm.polynomial(n)},degree:e=>e.length-1,coefficient:(e,t)=>e[rm.degree(e)-t],mulPoly(e,t){if(0===e[0]||0===t[0])return[0];const n=qg(e.length+t.length-1,0);for(let r=0;r<e.length;r++)for(let i=0;i<t.length;i++)n[r+i]=rm.add(n[r+i],rm.mul(e[r],t[i]));return rm.polynomial(n)},mulPolyScalar(e,t){if(0==t)return[0];if(1==t)return e;const n=qg(e.length,0);for(let r=0;r<e.length;r++)n[r]=rm.mul(e[r],t);return rm.polynomial(n)},mulPolyMonomial(e,t,n){if(t<0)throw new Error("GF.mulPolyMonomial: wrong degree");if(0==n)return[0];const r=qg(e.length+t,0);for(let t=0;t<e.length;t++)r[t]=rm.mul(e[t],n);return rm.polynomial(r)},addPoly(e,t){if(0===e[0])return t;if(0===t[0])return e;let n=e,r=t;n.length>r.length&&([n,r]=[r,n]);let i=qg(r.length,0),o=r.length-n.length,s=r.slice(0,o);for(let e=0;e<s.length;e++)i[e]=s[e];for(let e=o;e<r.length;e++)i[e]=rm.add(n[e-o],r[e]);return rm.polynomial(i)},remainderPoly(e,t){const n=Array.from(e);for(let r=0;r<e.length-t.length+1;r++){const e=n[r];if(0!==e)for(let i=1;i<t.length;i++)0!==t[i]&&(n[r+i]=rm.add(n[r+i],rm.mul(t[i],e)))}return n.slice(e.length-t.length+1,n.length)},divisorPoly(e){let t=[1];for(let n=0;n<e;n++)t=rm.mulPoly(t,[1,rm.pow(2,n)]);return t},evalPoly(e,t){if(0==t)return rm.coefficient(e,0);let n=e[0];for(let r=1;r<e.length;r++)n=rm.add(rm.mul(t,n),e[r]);return n},euclidian(e,t,n){rm.degree(e)<rm.degree(t)&&([e,t]=[t,e]);let r=e,i=t,o=[0],s=[1];for(;2*rm.degree(i)>=n;){let e=r,t=o;if(r=i,o=s,0===r[0])throw new Error("rLast[0] === 0");i=e;let n=[0];const a=rm.inv(r[0]);for(;rm.degree(i)>=rm.degree(r)&&0!==i[0];){const e=rm.degree(i)-rm.degree(r),t=rm.mul(i[0],a);n=rm.addPoly(n,rm.monomial(e,t)),i=rm.addPoly(i,rm.mulPolyMonomial(r,e,t))}if(n=rm.mulPoly(n,o),s=rm.addPoly(n,t),rm.degree(i)>=rm.degree(r))throw new Error(`Division failed r: ${i}, rLast: ${r}`)}const a=rm.coefficient(s,0);if(0==a)throw new Error("sigmaTilde(0) was zero");const c=rm.inv(a);return[rm.mulPolyScalar(s,c),rm.mulPolyScalar(i,c)]}};function im(e,t,n,r){let i="",o=n.length;if("numeric"===r){const e=tm.alphabet.numeric.decode(n.split("")),t=e.length;for(let n=0;n<t-2;n+=3)i+=Hg(100*e[n]+10*e[n+1]+e[n+2],10);t%3==1?i+=Hg(e[t-1],4):t%3==2&&(i+=Hg(10*e[t-2]+e[t-1],7))}else if("alphanumeric"===r){const e=tm.alphabet.alphanumerc.decode(n.split("")),t=e.length;for(let n=0;n<t-1;n+=2)i+=Hg(45*e[n]+e[n+1],11);t%2==1&&(i+=Hg(e[t-1],6))}else{if("byte"!==r)throw new Error("encode: unsupported type");{const e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(n);o=e.length,i=Array.from(e).map((e=>Hg(e,8))).join("")}}const{capacity:s}=tm.capacity(e,t),a=Hg(o,tm.lengthBits(e,r));let c=tm.modeBits[r]+a+i;if(c.length>s)throw new Error("Capacity overflow");c+="0".repeat(Math.min(4,Math.max(0,s-c.length))),c.length%8&&(c+="0".repeat(8-c.length%8));for(let e=0;c.length!==s;e++)c+="1110110000010001"[e%16];const l=Uint8Array.from(c.match(/(.{8})/g).map((e=>Number(`0b${e}`))));return function(e,t){const{words:n,shortBlocks:r,numBlocks:i,blockLen:o,total:s}=tm.capacity(e,t),a=(c=n,{encode(e){const t=rm.divisorPoly(c),n=Array.from(e);return n.push(...t.slice(0,-1).fill(0)),Uint8Array.from(rm.remainderPoly(n,t))},decode(e){const t=e.slice(),n=rm.polynomial(Array.from(e));let r=qg(c,0),i=!1;for(let e=0;e<c;e++){const t=rm.evalPoly(n,rm.exp(e));r[r.length-1-e]=t,0!==t&&(i=!0)}if(!i)return t;r=rm.polynomial(r);const o=rm.monomial(c,1),[s,a]=rm.euclidian(o,r,c),l=qg(rm.degree(s),0);let d=0;for(let e=1;e<256&&d<l.length;e++)0===rm.evalPoly(s,e)&&(l[d++]=rm.inv(e));if(d!==l.length)throw new Error("RS.decode: wrong errors number");for(let e=0;e<l.length;e++){const n=t.length-1-rm.log(l[e]);if(n<0)throw new Error("RS.decode: wrong error location");const r=rm.inv(l[e]);let i=1;for(let t=0;t<l.length;t++)e!==t&&(i=rm.mul(i,rm.add(1,rm.mul(l[t],r))));t[n]=rm.add(t[n],rm.mul(rm.evalPoly(a,r),rm.inv(i)))}return t}});var c;return{encode(e){const t=[],n=[];for(let s=0;s<i;s++){const i=o+(s<r?0:1);t.push(e.subarray(0,i)),n.push(a.encode(e.subarray(0,i))),e=e.subarray(i)}const s=Vg(...t),c=Vg(...n),l=new Uint8Array(s.length+c.length);return l.set(s),l.set(c,s.length),l},decode(e){if(e.length!==s)throw new Error(`interleave.decode: len(data)=${e.length}, total=${s}`);const t=[];for(let e=0;e<i;e++){const i=e<r;t.push(new Uint8Array(n+o+(i?0:1)))}let c=0;for(let n=0;n<o;n++)for(let r=0;r<i;r++)t[r][n]=e[c++];for(let n=r;n<i;n++)t[n][o]=e[c++];for(let s=o;s<o+n;s++)for(let n=0;n<i;n++){const i=n<r;t[n][s+(i?0:1)]=e[c++]}const l=[];for(const e of t)l.push(...Array.from(a.decode(e)).slice(0,-n));return Uint8Array.from(l)}}}(e,t).encode(l)}function om(e,t,n,r,i=!1){const o=function(e,t,n,r=!1){const i=tm.size.encode(e);let o=new Yg(i+2);const s=new Yg(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);o=o.embed(0,s).embed({x:-s.width,y:0},s).embed({x:0,y:-s.height},s),o=o.rectSlice(1,i);const a=new Yg(1).rect(0,1,!0).border(1,!1).border(1,!0),c=tm.alignmentPatterns(e);for(const e of c)for(const t of c)void 0===o.data[e][t]&&o.embed({x:t-2,y:e-2},a);o=o.hLine({x:0,y:6},1/0,(({x:e},t)=>void 0===t?e%2==0:t)).vLine({x:6,y:0},1/0,(({y:e},t)=>void 0===t?e%2==0:t));{const e=tm.formatBits(t,n),s=t=>!r&&1==(e>>t&1);for(let e=0;e<6;e++)o.data[e][8]=s(e);for(let e=6;e<8;e++)o.data[e+1][8]=s(e);for(let e=8;e<15;e++)o.data[i-15+e][8]=s(e);for(let e=0;e<8;e++)o.data[8][i-e-1]=s(e);for(let e=8;e<9;e++)o.data[8][15-e-1+1]=s(e);for(let e=9;e<15;e++)o.data[8][15-e-1]=s(e);o.data[i-8][8]=!r}if(e>=7){const t=tm.versionBits(e);for(let e=0;e<18;e+=1){const n=!r&&1==(t>>e&1),s=Math.floor(e/3),a=e%3+i-8-3;o.data[s][a]=n,o.data[a][s]=n}}return o}(e,t,r,i);let s=0;const a=8*n.length;if(function(e,t,n){const r=e.height,i=nm[t];let o=-1,s=r-1;for(let t=r-1;t>0;t-=2){for(6==t&&(t=5);;s+=o){for(let r=0;r<2;r+=1){const o=t-r;void 0===e.data[s][o]&&n(o,s,i(o,s))}if(s+o<0||s+o>=r)break}o=-o}}(o,r,((e,t,r)=>{let i=!1;s<a&&(i=0!=(n[s>>>3]>>(7-s&7)&1),s++),o.data[t][e]=i!==r})),s!==a)throw new Error("QR: bytes left after draw");return o}function sm(e){const t=e.inverse(),n=e=>{let t=0;for(let n,r=0,i=1;r<e.length;r++)n===e[r]&&(i++,r!==e.length-1)||(i>=5&&(t+=i-5+3),n=e[r],i=1);return t};let r=0;e.data.forEach((e=>r+=n(e))),t.data.forEach((e=>r+=n(e)));let i=0,o=e.data;const s=e.width-1,a=e.height-1;for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=e+1,r=t+1;o[e][t]===o[n][t]&&o[n][t]===o[e][r]&&o[n][t]===o[n][r]&&(i+=3)}const c=e=>{const t=[!0,!1,!0,!0,!0,!1,!0],n=[!1,!1,!1,!1],r=[...t,...n],i=[...n,...t];let o=0;for(let t=0;t<e.length;t++)Wg(e,r,t)&&(o+=40),Wg(e,i,t)&&(o+=40);return o};let l=0;for(const t of e.data)l+=c(t);for(const e of t.data)l+=c(e);let d=0;e.rectRead(0,1/0,((e,t)=>d+=t?1:0));const u=d/(e.height*e.width)*100,h=10*Math.floor(Math.abs(u-50)/5);return r+i+l+h}function am(e,t="raw",n={}){const r=void 0!==n.ecc?n.ecc:"medium";!function(e){if(!Zg.includes(e))throw new Error(`Invalid error correction mode=${e}. Expected: ${Zg}`)}(r);const i=void 0!==n.encoding?n.encoding:function(e){let t="numeric";for(let n of e)if(!tm.alphabet.numeric.has(n)&&(t="alphanumeric",!tm.alphabet.alphanumerc.has(n)))return"byte";return t}(e);!function(e){if(!Jg.includes(e))throw new Error(`Encoding: invalid mode=${e}. Expected: ${Jg}`);if("kanji"===e||"eci"===e)throw new Error(`Encoding: ${e} is not supported (yet?).`)}(i),void 0!==n.mask&&function(e){if(![0,1,2,3,4,5,6,7].includes(e)||!nm[e])throw new Error(`Invalid mask=${e}. Expected number [0..7]`)}(n.mask);let o,s=n.version,a=new Error("Unknown error");if(void 0!==s)!function(e){if(!Number.isSafeInteger(e)||e<1||e>40)throw new Error(`Invalid version=${e}. Expected number [1..40]`)}(s),o=im(s,r,e,i);else for(let t=1;t<=40;t++)try{o=im(t,r,e,i),s=t;break}catch(e){a=e}if(!s||!o)throw a;let c=function(e,t,n,r){if(void 0===r){const i=function(){let e,t=1/0;return{add(n,r){n>=t||(e=r,t=n)},get:()=>e,score:()=>t}}();for(let r=0;r<nm.length;r++)i.add(sm(om(e,t,n,r,!0)),r);r=i.get()}if(void 0===r)throw new Error("Cannot find mask");return om(e,t,n,r)}(s,r,o,n.mask);c.assertDrawn();const l=void 0===n.border?2:n.border;if(!Number.isSafeInteger(l))throw new Error("Wrong border type="+typeof l);if(c=c.border(l,!1),void 0!==n.scale&&(c=c.scale(n.scale)),"raw"===t)return c.data;if("ascii"===t)return c.toASCII();if("svg"===t)return c.toSVG();if("gif"===t)return c.toGIF();if("term"===t)return c.toTerm();throw new Error(`Unknown output: ${t}`)}const cm={DESKTOP:"Desktop",MOBILE:"Mobile",META_MASK_MOBILE_APP:"MetaMask mobile app",SCAN_TO_CONNECT:"Scan to connect and sign with",CONNECT_WITH_EXTENSION:"Connect With MetaMask Extension",INSTALL_MODAL:{TRUSTED_BY_USERS:"Trusted by over 30 million users to buy, store, send and swap crypto securely",LEADING_CRYPTO_WALLET:"The leading crypto wallet & gateway to blockchain apps built on Ethereum Mainnet, Polygon, Optimism, and many other networks",CONTROL_DIGITAL_INTERACTIONS:"Puts you in control of your digital interactions by making power of cryptography more accessible",INSTALL_META_MASK_EXTENSION:"Install MetaMask Extension"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:"Please open the MetaMask wallet app and select the code on the screen OR disconnect",OPEN_META_MASK_CONTINUE:"Open the MetaMask app to continue with your session.",NUMBER_AFTER_OPEN_NOTICE:"If a number doesn't appear after opening MetaMask, please click disconnect and re-scan the QRCode.",DISCONNECT:"Disconnect"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:"Take control of your crypto and explore the blockchain with the wallet trusted by over 30 million people worldwide"},META_MASK_MODAL:{ADDRESS_COPIED:"Address copied to clipboard!",DISCONNECT:"Disconnect",ACTIVE_NETWORK:"Active Network"}};class lm{constructor(e){var t;this.translations=cm,this.supportedLocales=["es","fr","he","it","pt","tr"],this.baseUrl=null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:"https://raw.githubusercontent.com/MetaMask/metamask-sdk/refs/heads/gh-pages/locales"}getBrowserLanguage(){if((navigator.languages||[navigator.language]).some((e=>e.toLowerCase().startsWith("en"))))return"en";const e=navigator.language.toLowerCase().split("-")[0];return this.supportedLocales.includes(e)?e:"en"}async init(e){const t=this.getBrowserLanguage()||e.fallbackLng;await this.loadTranslations(t)}async loadTranslations(e){const t=e.split("-")[0];if("en"!==t&&this.supportedLocales.includes(t))try{const e=`${this.baseUrl}/${t}.json`,n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);this.translations=await n.json()}catch(e){console.warn(`❌ Failed to load ${t} translations, falling back to English:`,e),this.translations=cm}else this.translations=cm}t(e){return this.getNestedTranslation(e,this.translations)||e}getNestedTranslation(e,t){const n=e.split(".");let r=t;for(const e of n){if("object"!=typeof r)return"";r=r[e]}return"string"==typeof r?r:""}}var dm;!function(e){e.SDK_MODAL_VIEWED="sdk_modal_viewed",e.SDK_MODAL_BUTTON_CLICKED="sdk_modal_button_clicked",e.SDK_MODAL_TOGGLE_CHANGED="sdk_modal_toggle_changed"}(dm||(dm={}));const um=class{constructor(e){wp(this,e),this.close=Qp(this,"close",7),this.startDesktopOnboarding=Qp(this,"startDesktopOnboarding",7),this.trackAnalytics=Qp(this,"trackAnalytics",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.onClose=this.onClose.bind(this),this.onStartDesktopOnboardingHandler=this.onStartDesktopOnboardingHandler.bind(this),this.setTab=this.setTab.bind(this),this.render=this.render.bind(this),this.setTab(this.preferDesktop?1:2),this.i18nInstance=new lm}componentDidLoad(){this.trackAnalytics.emit({event:dm.SDK_MODAL_VIEWED,params:{extensionInstalled:!1,tab:1===this.tab?"desktop":"mobile"}})}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}onClose(e=!1){this.close.emit({shouldTerminate:e})}onStartDesktopOnboardingHandler(){this.trackAnalytics.emit({event:dm.SDK_MODAL_BUTTON_CLICKED,params:{button_type:"install_extension",tab:"desktop"}}),this.startDesktopOnboarding.emit()}setTab(e,t=!1){t&&this.trackAnalytics.emit({event:dm.SDK_MODAL_TOGGLE_CHANGED,params:{toggle:1===this.tab?"desktop_to_mobile":"mobile_to_desktop"}}),this.tab=e,this.isDefaultTab=!1}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.isDefaultTab?this.preferDesktop?1:2:this.tab,n=am(this.link,"svg",{ecc:"medium",scale:2});return Vp(Ig,{className:"install-model"},Vp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),Vp("div",{class:"modal"},Vp("div",{class:"closeButtonContainer"},Vp("div",{class:"right"},Vp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},Vp(Ug,null)))),Vp("div",{class:"logoContainer"},Vp(Fg,null)),Vp("div",null,Vp("div",{class:"tabcontainer"},Vp("div",{class:"flexContainer"},Vp("div",{onClick:()=>this.setTab(1,!0),class:"tab flexItem "+(1===t?"tabactive":"")},e("DESKTOP")),Vp("div",{onClick:()=>this.setTab(2,!0),class:"tab flexItem "+(2===t?"tabactive":"")},e("MOBILE")))),Vp("div",{style:{display:1===t?"none":"block"}},Vp("div",{class:"flexContainer"},Vp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},n&&Vp("div",{id:"sdk-mm-qrcode",class:"center",innerHTML:n}),Vp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT")," ",Vp("br",null),Vp("span",{class:"blue"},Vp("b",null,e("META_MASK_MOBILE_APP"))))))),Vp("div",{style:{display:2===t?"none":"block"}},Vp("div",{class:"item"},Vp(Ng,{Icon:Dg,text:e("INSTALL_MODAL.TRUSTED_BY_USERS")})),Vp("div",{class:"item"},Vp(Ng,{Icon:Bg,text:e("INSTALL_MODAL.LEADING_CRYPTO_WALLET")})),Vp("div",{class:"item"},Vp(Ng,{Icon:$g,text:e("INSTALL_MODAL.CONTROL_DIGITAL_INTERACTIONS")})),Vp("button",{class:"button",onClick:()=>this.onStartDesktopOnboardingHandler()},Vp(jg,null),Vp("span",{class:"installExtensionText"},e("INSTALL_MODAL.INSTALL_META_MASK_EXTENSION"))))),Vp(Kg,{version:this.sdkVersion})))}get el(){return Xp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};um.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const hm=class{constructor(e){wp(this,e),this.close=Qp(this,"close",7),this.disconnect=Qp(this,"disconnect",7),this.updateOTPValue=Qp(this,"updateOTPValue",7),this.displayOTP=void 0,this.sdkVersion=void 0,this.otpCode=void 0,this.translationsLoaded=!1,this.i18nInstance=new lm}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(){this.close.emit()}onDisconnect(){this.disconnect.emit()}onUpdateOTPValueHandler(e){this.updateOTPValue.emit({otpValue:e})}disconnectedCallback(){this.onClose()}render(){var e;if(!this.translationsLoaded)return null;const t=null===(e=this.displayOTP)||void 0===e||e,n=this.sdkVersion,r=e=>this.i18nInstance.t(e);return Vp(Ig,{className:"pending-modal"},Vp("div",{class:"backdrop",onClick:()=>this.onClose()}),Vp("div",{class:"modal"},Vp("div",{class:"closeButtonContainer"},Vp("div",{class:"right"},Vp("span",{class:"closeButton",onClick:()=>this.onClose()},Vp(Ug,null)))),Vp("div",{class:"logoContainer"},Vp(Fg,null)),Vp("div",null,Vp("div",{class:"flexContainer",style:{flexDirection:"column",color:"black"}},Vp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"30px",marginBottom:"30px",fontSize:"16px"}},r(t?"PENDING_MODAL.OPEN_META_MASK_SELECT_CODE":"PENDING_MODAL.OPEN_META_MASK_CONTINUE")),Vp("div",{id:"sdk-mm-otp-value",style:{padding:"10px",fontSize:"32px",display:this.otpCode?"block":"none"}},this.otpCode),t&&Vp("div",{class:"notice"},"* ",r("PENDING_MODAL.NUMBER_AFTER_OPEN_NOTICE"))),Vp("div",{style:{marginTop:"20px"}},Vp("button",{class:"button blue",style:{marginTop:"5px",color:"#0376C9",borderColor:"#0376C9",borderWidth:"1px",borderStyle:"solid",backgroundColor:"white"},onClick:()=>this.onDisconnect()},r("PENDING_MODAL.DISCONNECT")))),Vp(Kg,{version:n})))}get el(){return Xp(this)}};hm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const fm=()=>Vp("svg",{width:"21",height:"15",viewBox:"0 0 21 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M14.1364 14.9851C13.5909 14.9851 13.2273 14.5851 13.2273 13.9851C13.2273 13.3851 13.5909 12.9851 14.1364 12.9851C16.6818 12.9851 18.6818 10.7851 18.6818 7.98508C18.6818 5.18508 16.6818 2.98508 14.1364 2.98508C11.5909 2.98508 9.59091 5.18508 9.59091 7.98508C9.59091 8.58508 9.22727 8.98508 8.68182 8.98508C8.13636 8.98508 7.77273 8.58508 7.77273 7.98508C7.77273 4.08508 10.5909 0.985077 14.1364 0.985077C17.6818 0.985077 20.5 4.08508 20.5 7.98508C20.5 11.8851 17.6818 14.9851 14.1364 14.9851ZM6.68182 14.7851C3.22727 14.7851 0.5 11.6851 0.5 7.98508C0.5 4.28508 3.22727 1.18508 6.68182 1.18508C7.22727 1.18508 7.59091 1.58508 7.59091 2.18508C7.59091 2.78508 7.22727 3.18508 6.68182 3.18508C4.22727 3.18508 2.31818 5.38508 2.31818 7.98508C2.31818 10.5851 4.22727 12.7851 6.68182 12.7851C9.13636 12.7851 11.0455 10.6851 11.0455 7.98508C11.0455 7.38508 11.4091 6.98508 11.9545 6.98508C12.5 6.98508 12.8636 7.38508 12.8636 7.98508C12.7727 11.6851 10.0455 14.7851 6.68182 14.7851Z",fill:"white"})),pm=()=>Vp("svg",{width:"400",height:"300",viewBox:"0 0 467 300",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M312.387 280.629C312.549 280.583 312.247 280.735 312.387 280.629L339.678 260.425C340.088 260.118 340.132 259.156 340.07 258.647C340.008 258.138 339.573 258.257 339.106 258.084L311.712 247.455C311.292 247.301 311.308 247.402 310.939 247.673C310.569 247.944 310.356 248.21 310.356 248.672L310.459 279.504C310.461 280.025 311.163 280.619 311.614 280.847C311.913 280.996 312.072 280.718 312.387 280.629ZM336.204 259.736L312.979 276.292L313.439 251.139L336.204 259.736Z",fill:"url(#paint0_linear_1356_14057)"}),Vp("path",{d:"M324.639 260.342C324.358 259.547 323.485 258.91 322.707 259.215C319.6 260.432 318.17 262.313 317.287 264.066C316.482 265.665 316.197 267.482 314.188 268.269C312.178 269.055 310.763 268.663 309.162 268.007C307.406 267.287 305.504 266.182 302.397 267.399C299.289 268.616 297.859 270.497 296.976 272.25C296.171 273.849 295.697 274.886 293.685 275.673C291.675 276.459 290.261 276.067 288.659 275.411C286.903 274.691 284.999 273.587 281.894 274.803C278.789 276.019 277.549 278.681 276.666 280.434C275.861 282.034 275.386 283.07 273.374 283.857C272.596 284.161 271.931 285.055 272.211 285.849C272.492 286.644 273.365 287.281 274.143 286.977C277.25 285.76 278.68 283.879 279.563 282.125C280.368 280.526 280.65 278.71 282.662 277.923C284.672 277.136 286.087 277.528 287.688 278.184C289.444 278.904 291.348 280.009 294.453 278.793C297.561 277.576 298.991 275.695 299.874 273.941C300.679 272.342 301.153 271.306 303.165 270.519C305.175 269.732 306.589 270.124 308.191 270.78C309.947 271.5 311.849 272.605 314.956 271.388C318.063 270.172 319.301 267.511 320.184 265.757C320.989 264.158 321.466 263.121 323.476 262.335C324.254 262.032 324.919 261.137 324.639 260.342Z",fill:"url(#paint1_linear_1356_14057)"}),Vp("path",{d:"M389.034 111.124C388.968 112.406 387.342 113.113 386.324 113.549C384.297 114.419 382.089 114.493 379.942 114.5C376.607 114.509 373.215 114.163 369.89 113.976C366.712 113.798 363.156 113.311 360.03 114.232C357.705 114.919 355.667 116.762 353.452 117.739C351.129 118.765 348.957 119.198 346.489 119.687C335.569 121.85 323.587 120.825 312.656 119.977C311.92 119.92 312.539 118.997 313.237 118.981C313.207 118.815 313.001 118.394 313.045 118.201C313.086 118.029 312.781 117.586 312.853 117.421C312.67 117.198 313.316 117.427 313.626 117.204C315.912 115.557 318.721 114.79 321.363 115.041C324.677 115.355 327.293 116.04 330.641 115.781C334.392 115.491 338.125 114.787 341.857 114.312C345.142 113.892 349.09 113.941 352.106 112.28C352.916 111.834 353.137 111.262 353.269 110.287C353.331 109.828 353.672 108.969 353.658 108.511C353.629 107.529 354.191 107.886 355.013 107.298C356.857 105.981 358.274 105.516 360.428 105.784C362.841 106.083 365.264 107.273 367.578 107.953C370.761 108.888 374.328 108.646 377.631 108.477C380.517 108.329 383.141 107.901 385.944 108.653C387.013 108.941 389.104 109.745 389.034 111.124Z",fill:"url(#paint2_linear_1356_14057)"}),Vp("path",{d:"M278.118 85.4414C280.313 83.8186 283.302 83.9 285.853 83.2728C290.501 82.127 295.644 78.4476 300.549 79.1524C301.299 79.2595 300.904 81.0355 300.159 80.9295C300.131 80.9256 300.187 80.9333 300.159 80.9295C300.089 81.0185 299.516 81.1051 299.385 81.1463C294.999 82.515 292.895 87.5083 289.126 89.8598C287.799 90.688 286.771 90.8351 285.258 90.9441C283.515 91.0691 280.964 90.5775 279.269 90.1219C277.15 89.5532 275.965 87.034 278.118 85.4414Z",fill:"url(#paint3_linear_1356_14057)"}),Vp("path",{d:"M122.567 166.093C113.597 172.832 104.535 179.836 99.517 190.092C98.5342 192.099 97.519 195.019 97.9533 197.204C98.9699 202.316 105.76 203.049 110.691 201.96C113.468 201.347 116.325 199.231 115.921 196.319C115.576 193.81 113.158 192.986 112.072 190.73C110.779 188.04 112.35 184.97 114.218 182.62C128.134 165.099 150.074 157.394 171.093 151.607C175.385 150.425 180.897 147.69 180.581 143.099C180.372 140.072 177.118 137.683 174.221 137.383C171.324 137.082 168.481 138.773 165.715 139.776C158.416 142.419 151.17 143.799 143.489 143.526C136.865 143.29 130.976 143.316 129.562 150.781C128.138 158.276 129.53 160.863 122.567 166.093Z",fill:"url(#paint4_linear_1356_14057)"}),Vp("path",{d:"M79.1056 153.531C60.3932 164.378 43.7478 178.354 32.8214 197.415C30.3313 201.76 27.9216 206.554 27.1821 211.512C26.4448 216.47 27.7591 222.525 30.8133 226.337C34.908 231.446 41.6938 232.915 48.1811 233.125C50.7248 233.208 53.0035 233.066 55.3316 231.947C57.6602 230.83 59.7548 228.359 59.5978 225.742C59.3303 221.315 54.5491 219.665 50.9271 217.34C42.6566 212.037 40.4958 199.493 44.2381 190.032C47.9803 180.57 55.8228 173.173 63.2316 166.338C67.229 162.651 71.5194 158.372 76.777 157.522C79.9167 157.015 83.4706 157.589 86.6295 157.252C93.9004 156.479 99.64 151.404 105.588 146.912C115.048 139.765 126.045 134.283 137.501 132.093C141.913 131.248 146.293 130.493 149.682 127.831C151.37 126.507 150.803 123.567 148.726 123.93C138.542 125.713 128.652 131.135 119.142 134.758C105.627 139.914 91.7133 146.223 79.1056 153.531Z",fill:"url(#paint5_linear_1356_14057)"}),Vp("path",{d:"M96.3677 117.321C96.0315 116.64 95.2914 116.612 94.6293 116.975C91.9858 118.417 91.5452 120.509 90.9466 122.178C90.4004 123.702 89.3647 124.67 87.6542 125.604C85.9437 126.538 85.0983 126.316 83.5956 125.91C81.9481 125.465 79.8603 125.424 77.2168 126.866C74.5734 128.309 74.1348 130.401 73.5341 132.07C72.9879 133.593 71.9522 134.562 70.2417 135.496C68.5313 136.43 67.6859 136.208 66.1832 135.801C64.5357 135.357 62.2569 134.538 59.6128 135.978C56.9694 137.42 56.5308 139.512 55.9301 141.181C55.3839 142.705 54.5398 144.454 52.8293 145.388C52.1667 145.748 52.1006 146.485 52.439 147.165C52.7752 147.845 53.5153 147.874 54.1773 147.511C56.8208 146.069 57.2594 143.977 57.86 142.307C58.4062 140.784 59.4419 139.815 61.1524 138.881C62.8629 137.948 63.7083 138.17 65.211 138.576C66.8585 139.021 68.9458 139.059 71.5898 137.619C74.2333 136.177 74.6718 134.085 75.2725 132.416C75.8187 130.892 76.8544 129.924 78.5649 128.99C80.2754 128.056 81.1207 128.278 82.6235 128.684C84.2709 129.129 86.5503 129.95 89.1938 128.507C91.8373 127.065 92.2779 124.973 92.8765 123.304C93.4227 121.78 94.2663 120.03 95.9773 119.098C96.6378 118.738 96.7039 118.001 96.3677 117.321Z",fill:"#FBC49D"}),Vp("path",{d:"M391.827 164.699C392.04 164.639 392.39 164.573 392.6 164.481C393.87 163.921 395.363 162.429 395.893 161.051C396.421 159.673 396.237 158.321 395.712 156.931C394.629 154.061 391.777 152.62 389.155 153.775C386.531 154.931 384.962 158.455 386.042 161.325C387.038 163.963 389.369 165.392 391.827 164.699ZM394.166 157.367C394.529 158.332 394.52 159.751 394.156 160.706C393.792 161.662 393.1 162.534 392.218 162.921C390.398 163.723 388.338 162.878 387.589 160.889C387.226 159.925 387.234 158.506 387.599 157.55C387.963 156.594 388.654 155.723 389.536 155.336C391.356 154.534 393.416 155.376 394.166 157.367Z",fill:"#86E29B"}),Vp("path",{d:"M62.7198 108.691C64.4912 108.191 66.6152 106.609 67.5596 104.824C68.4273 103.187 68.465 101.455 67.9609 99.7066C67.4547 97.9586 66.0792 96.5141 64.4963 95.6786C62.9135 94.843 61.2077 94.8578 59.4756 95.4255C57.7435 95.9933 56.2768 97.4364 55.409 99.074C53.6185 102.456 55.2032 106.494 58.4723 108.22C60.0142 109.035 61.1315 109.138 62.7198 108.691ZM60.6304 96.7682C61.819 96.4332 63.0232 96.8871 64.1048 97.4571C65.2463 98.0603 66.0495 98.8796 66.4145 100.142C66.7791 101.403 66.4488 103.299 65.8224 104.48C64.5299 106.919 61.2212 107.686 58.8638 106.441C56.5063 105.197 55.8538 101.858 57.1462 99.4185C57.7726 98.2375 58.6059 97.3957 59.8573 96.9862C59.9214 96.9635 60.5631 96.7872 60.6304 96.7682Z",fill:"#FFB0EB"}),Vp("path",{d:"M77.0217 242.979C75.9542 243.28 75.1664 242.151 74.9029 241.074C74.6394 239.996 75 239.378 76.0676 239.077C77.1351 238.776 78.5053 238.907 78.7688 239.984C79.0323 241.061 78.0893 242.678 77.0217 242.979Z",fill:"url(#paint6_linear_1356_14057)"}),Vp("path",{d:"M380.506 184.577C379.439 184.878 378.651 183.749 378.387 182.672C378.124 181.594 378.484 180.976 379.552 180.675C380.619 180.374 381.99 180.505 382.253 181.582C382.517 182.659 381.574 184.276 380.506 184.577Z",fill:"url(#paint7_linear_1356_14057)"}),Vp("path",{d:"M348.82 246.969C347.752 247.27 346.382 247.14 346.119 246.063C345.855 244.985 346.798 243.369 347.866 243.068C348.933 242.767 349.721 243.896 349.985 244.973C350.248 246.05 349.888 246.669 348.82 246.969Z",fill:"url(#paint8_linear_1356_14057)"}),Vp("path",{d:"M140.419 282.412C139.351 282.713 138.754 282.365 138.491 281.288C138.227 280.21 138.397 278.812 139.464 278.511C140.532 278.21 142.093 279.121 142.357 280.198C142.62 281.275 141.486 282.111 140.419 282.412Z",fill:"url(#paint9_linear_1356_14057)"}),Vp("path",{d:"M121.462 101.679C120.395 101.979 119.798 101.631 119.534 100.554C119.271 99.4764 119.44 98.0779 120.508 97.777C121.575 97.4761 123.136 98.3868 123.4 99.4642C123.663 100.542 122.53 101.378 121.462 101.679Z",fill:"url(#paint10_linear_1356_14057)"}),Vp("path",{d:"M370.749 159.005C369.682 159.306 368.311 159.175 368.048 158.098C367.784 157.021 368.727 155.404 369.795 155.103C370.863 154.802 371.65 155.931 371.914 157.008C372.177 158.086 371.817 158.704 370.749 159.005Z",fill:"url(#paint11_linear_1356_14057)"}),Vp("path",{d:"M384.211 245.345C383.143 245.646 381.773 245.515 381.51 244.438C381.246 243.361 382.189 241.744 383.257 241.443C384.324 241.142 385.112 242.271 385.376 243.348C385.639 244.426 385.278 245.044 384.211 245.345Z",fill:"url(#paint12_linear_1356_14057)"}),Vp("path",{d:"M364.771 41.3873C363.063 41.8687 361.337 40.8616 360.915 39.1378C360.493 37.414 361.536 35.6263 363.244 35.1449C364.953 34.6634 366.679 35.6706 367.101 37.3944C367.522 39.1182 366.479 40.9059 364.771 41.3873Z",fill:"url(#paint13_linear_1356_14057)"}),Vp("path",{d:"M404.311 77.905C404.602 77.8231 404.875 77.9236 405.084 77.6871C405.437 77.2908 404.814 76.6385 404.703 76.1265L401.277 58.7418C401.149 58.163 400.687 57.5371 400.123 57.3991C399.558 57.2611 398.969 57.3812 398.576 57.835L385.784 73.1179C385.395 73.564 385.199 74.3453 385.393 74.8964C385.585 75.4481 385.978 76.1646 386.548 76.2391L403.538 78.123C403.744 78.1479 404.114 77.9607 404.311 77.905ZM398.948 62.7348L401.811 74.4394L389.841 72.8085L398.948 62.7348Z",fill:"#FFB0EB"}),Vp("path",{d:"M97.5393 295.311C97.7108 295.263 97.4284 295.461 97.5393 295.311L108.785 280.464C108.975 280.211 108.718 279.972 108.594 279.684C108.47 279.396 108.124 279.917 107.821 279.902L88.5106 278.672C88.2101 278.659 87.895 278.62 87.7374 278.89C87.5798 279.159 87.7755 279.402 87.9283 279.67L96.5753 294.749C96.7102 294.99 97.2696 295.297 97.5393 295.311C97.6283 295.319 97.4556 295.335 97.5393 295.311ZM106.465 281.118L96.9667 292.97L90.6295 280.577L106.465 281.118Z",fill:"#86E29B"}),Vp("path",{d:"M393.699 108.848C389.518 104.446 414.629 114.366 413.945 120.659C413.259 126.952 401.355 129.102 403.894 123.491C406.042 118.747 400.376 115.876 393.699 108.848Z",fill:"#FBC49D"}),Vp("path",{d:"M139.414 115.959C139.434 115.953 139.392 115.965 139.414 115.959C141.963 115.2 143.436 111.976 142.717 109.189C142.37 107.839 141.526 107.199 140.408 106.504C139.289 105.808 138.171 105.449 136.933 105.815C135.698 106.182 134.85 107.033 134.222 108.247C133.595 109.461 133.282 111.234 133.63 112.585C133.978 113.935 134.821 114.574 135.94 115.27C137.04 115.952 138.199 116.301 139.414 115.959ZM137.315 107.375C138.222 107.12 139.005 106.994 139.825 107.502C140.661 108.02 140.912 108.618 141.171 109.625C141.708 111.704 140.935 113.834 139.032 114.398C138.11 114.675 137.356 114.791 136.522 114.272C135.686 113.753 135.436 113.155 135.176 112.149C134.917 111.142 134.718 109.714 135.186 108.81C135.654 107.905 136.394 107.649 137.315 107.375C137.329 107.371 137.299 107.38 137.315 107.375Z",fill:"#75C4FD"}),Vp("path",{d:"M308.981 78.7519C310.052 78.4043 311.158 78.7096 312.265 78.6613C313.655 78.6006 314.936 78.517 316.323 78.3531C319.497 77.9795 322.798 77.4906 325.984 77.3012C329.309 77.1025 332.514 76.8551 335.836 77.0295C338.809 77.1842 342.163 77.3405 345.105 77.7558C352.129 78.7468 359.331 79.0578 366.347 80.1158C372.252 81.008 377.93 82.1319 383.722 83.5644C385.925 84.0054 388.267 85.0754 389.126 85.3792C389.421 85.4833 389.37 85.8347 389.317 86.1595C389.306 86.2271 389.353 86.1146 389.317 86.1595C388.269 87.414 386.564 86.8124 385.259 86.4677C384.406 86.241 381.488 85.9494 381.011 85.9957C380.14 86.0815 379.277 86.014 379.656 87.2114C380.122 88.6824 382.391 89.7375 383.704 90.2419C385.883 91.0803 388.771 91.2561 390.845 92.4015C392.968 92.821 395.425 93.5002 397.022 93.9986C402.83 95.8103 407.806 98.8678 413.033 102.002C415.503 103.482 417.829 104.764 419.973 106.72C421.647 108.248 423.771 109.882 424.595 112.091C425.113 113.482 424.451 115.471 422.848 115.085C420.353 114.488 419.638 111.665 418.227 109.714C415.003 105.251 410.067 102.067 405.118 100.06C402.64 99.0556 399.803 98.729 397.204 98.1176C394.411 97.4613 391.597 97.0442 388.707 97.1736C385.646 97.3097 382.846 97.5534 379.819 98.0078C377.027 98.4264 374.252 98.4441 371.514 97.8441C368.766 97.2421 366.276 96.7553 363.6 95.9021C361.662 95.2848 359.013 94.5583 357.232 93.5247C355.699 92.6339 355.631 91.2381 357.241 90.186C359.87 88.4656 362.778 89.8021 365.546 90.3497C365.561 90.3527 365.532 90.3468 365.546 90.3497C367.858 90.804 369.649 90.098 371.923 89.3884C372.489 89.2128 373.255 89.0482 373.47 88.953C374.383 88.5432 375.895 87.8227 375.407 86.7394C374.868 85.5457 372.659 84.8846 371.55 84.4891C369.74 83.8428 368.053 82.9215 366.147 82.6743C365.654 82.6095 365.109 83.1606 364.6 83.1097C363.36 83.1121 361.769 83.348 360.543 83.418C357.43 83.5916 354.583 83.6228 351.464 83.4719C348.714 83.3377 346.432 82.8542 343.741 82.3102C340.773 81.7101 337.52 81.5879 334.471 81.5839C331.393 81.5811 328.6 81.7214 325.583 82.4181C322.758 83.0702 319.757 83.6198 316.887 84.0326C314.698 84.3481 312.467 84.6054 310.319 84.2137C309.079 83.9871 306.994 83.3394 306.461 81.9635C305.846 80.3659 307.736 79.1556 308.981 78.7519Z",fill:"url(#paint14_linear_1356_14057)"}),Vp("path",{d:"M242.269 242.95C242.295 242.947 242.244 242.955 242.269 242.95C244.934 242.606 247.53 241.858 250.2 241.574C253.133 241.264 256.006 240.56 258.906 239.982C263.26 239.117 268.026 238.52 272.254 237.097C274.429 236.365 276.067 235.298 278.251 234.592C280.361 233.909 283.058 233.12 285.216 232.652C289.317 231.764 293.049 231.66 297.016 230.198C301.109 228.69 305.088 226.673 308.819 224.409C312.645 222.086 316.282 219.769 320.622 218.62C322.381 218.154 323.919 218.219 325.65 218.886C327.016 219.413 327.739 220.337 327.196 221.79C326.557 223.504 324.659 224.7 323.131 225.423C320.854 226.5 319.53 227.184 317.134 227.927C314.619 228.707 311.888 229.24 309.395 230.083C308.226 230.947 307.17 232.522 306.105 233.501C303.996 235.441 301.666 237.03 298.945 237.996C292.934 240.129 286.354 238.602 280.183 239.056C279.661 239.095 279.162 239.442 278.635 239.487C275.592 240.135 272.2 240.63 269.156 241.294C264.546 242.299 260.456 243.409 255.808 244.179C251.971 244.814 243.815 245.854 243.815 245.854L242.074 245.505C240.575 245.281 240.751 243.152 242.269 242.95Z",fill:"url(#paint15_linear_1356_14057)"}),Vp("path",{d:"M432.985 171.626C438.212 165.465 445.109 153.64 442.906 144.649C442.162 137.999 433.671 132.912 424.963 135.518C420.16 136.957 416.435 142.146 419.724 144.498C420.656 145.164 422.187 145.591 423.391 145.969C434.204 149.375 434.925 162.538 425.069 169.683C421.087 172.569 416.347 174.292 411.914 176.719C400.151 183.162 399.887 196.847 387.7 202.712C382.326 205.298 375.761 206.838 370.297 209.275C359.98 213.88 352.555 221.733 342.241 226.341C337.225 228.584 330.266 231.632 323.483 234.12C321.475 234.855 321.999 237.058 324.056 236.46C324.098 236.449 324.017 236.474 324.056 236.46C329.079 234.971 334.437 233.161 339.331 231.33C352.278 226.48 365.28 220.971 377.43 214.775C401.78 202.367 416.881 190.609 432.985 171.626Z",fill:"url(#paint16_linear_1356_14057)"}),Vp("path",{d:"M343.644 241.104C348.002 234.144 357.126 232.455 364.343 231.134C368.176 230.431 372.406 229.878 376.137 228.662C380.691 227.175 384.558 224.095 388.327 221.077C389.452 220.177 391.204 218.466 392.393 217.436C393.185 216.748 393.644 216.026 394.33 215.225C396 213.275 399.599 209.812 401.687 208.16C403.263 206.914 407.779 204.758 408.259 207.986C408.611 210.359 406.379 213.087 404.961 214.747C402.224 217.953 398.998 221.079 395.475 223.243C391.749 225.531 387.701 227.439 383.674 229.051C381.672 229.853 379.519 230.073 377.486 230.785C376.001 231.307 374.486 232.236 373.037 232.866C371.034 233.738 368.99 234.28 367.041 235.38C364.436 236.849 361.782 238.783 359.108 240.105C356.331 241.477 353.823 242.691 350.791 243.27C348.6 243.687 345.501 243.641 343.836 241.884C343.526 241.554 343.389 241.51 343.644 241.104Z",fill:"url(#paint17_linear_1356_14057)"}),Vp("path",{d:"M190.163 273.219C222.905 268.849 232.64 262.943 213.962 259.057C195.285 255.172 187.5 262.08 188.434 266.2C189.366 270.32 180.381 271.326 169.286 272.39C158.193 273.454 157.141 276.354 190.163 273.219Z",fill:"url(#paint18_linear_1356_14057)"}),Vp("path",{d:"M295.952 95.4242L241.395 135.226L251.54 111.77L295.952 95.4242Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M170.111 95.4242L224.181 135.598L214.522 111.77L170.111 95.4242Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M276.309 187.712L261.793 209.576L292.876 218.014L301.78 188.189L276.309 187.712Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M164.336 188.189L173.186 218.014L204.215 209.576L189.753 187.712L164.336 188.189Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M202.542 150.776L193.908 163.618L224.667 164.998L223.642 132.36L202.542 150.776Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M263.52 150.775L242.097 131.989L241.395 164.998L272.154 163.618L263.52 150.775Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M204.215 209.576L222.832 200.714L206.805 188.402L204.215 209.576Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M243.23 200.714L261.793 209.576L259.257 188.402L243.23 200.714Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M261.793 209.576L243.23 200.714L244.741 212.601L244.579 217.643L261.793 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M204.215 209.576L221.483 217.643L221.375 212.601L222.832 200.714L204.215 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M221.807 180.547L206.373 176.09L217.274 171.154L221.807 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M244.255 180.547L248.788 171.154L259.742 176.09L244.255 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M204.215 209.576L206.913 187.712L189.753 188.189L204.215 209.576Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M259.149 187.712L261.793 209.576L276.309 188.189L259.149 187.712Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M272.154 163.618L241.395 164.998L244.255 180.547L248.788 171.154L259.742 176.09L272.154 163.618Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M206.373 176.09L217.274 171.154L221.807 180.547L224.667 164.998L193.908 163.618L206.373 176.09Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M193.908 163.618L206.805 188.402L206.373 176.09L193.908 163.618Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M259.743 176.09L259.257 188.402L272.154 163.618L259.743 176.09Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M224.667 164.998L221.807 180.548L225.422 198.909L226.232 174.71L224.667 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M241.395 164.998L239.884 174.657L240.64 198.909L244.255 180.548L241.395 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M244.255 180.547L240.64 198.909L243.23 200.714L259.257 188.402L259.743 176.09L244.255 180.547Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M206.373 176.09L206.805 188.402L222.832 200.714L225.422 198.909L221.807 180.547L206.373 176.09Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M244.579 217.643L244.741 212.601L243.338 211.434H222.724L221.375 212.601L221.483 217.643L204.215 209.576L210.259 214.459L222.508 222.791H243.5L255.803 214.459L261.793 209.576L244.579 217.643Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M243.23 200.714L240.64 198.909H225.422L222.832 200.714L221.375 212.601L222.724 211.434H243.338L244.741 212.601L243.23 200.714Z",fill:"#161616",stroke:"#161616","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M298.272 137.827L302.859 115.856L295.952 95.4242L243.23 133.899L263.52 150.775L292.174 159.001L298.488 151.731L295.736 149.767L300.107 145.84L296.761 143.293L301.132 140.002L298.272 137.827Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M163.203 115.856L167.844 137.827L164.876 140.002L169.301 143.293L165.955 145.84L170.326 149.767L167.574 151.731L173.888 159.001L202.542 150.775L222.832 133.899L170.11 95.4242L163.203 115.856Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M292.175 159.001L263.52 150.775L272.154 163.618L259.257 188.402L276.309 188.189H301.78L292.175 159.001Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M202.542 150.775L173.888 159.001L164.336 188.189H189.753L206.805 188.402L193.908 163.618L202.542 150.775Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M241.395 164.998L243.23 133.9L251.54 111.77H214.522L222.832 133.9L224.667 164.998L225.368 174.763L225.422 198.909H240.64L240.694 174.763L241.395 164.998Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("defs",null,Vp("linearGradient",{id:"paint0_linear_1356_14057",x1:"335.991",y1:"250.487",x2:"303.873",y2:"266.801",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint1_linear_1356_14057",x1:"276.993",y1:"303.722",x2:"205.254",y2:"401.574",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint2_linear_1356_14057",x1:"271.074",y1:"119.924",x2:"553.077",y2:"104.53",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint3_linear_1356_14057",x1:"264.209",y1:"91.0943",x2:"357.834",y2:"72.8792",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint4_linear_1356_14057",x1:"212.46",y1:"121.997",x2:"92.6119",y2:"183.406",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint5_linear_1356_14057",x1:"23.0498",y1:"204.411",x2:"161.86",y2:"163.003",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint6_linear_1356_14057",x1:"78.8647",y1:"240.375",x2:"74.9655",y2:"241.328",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint7_linear_1356_14057",x1:"382.349",y1:"181.971",x2:"378.45",y2:"182.925",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint8_linear_1356_14057",x1:"349.889",y1:"244.583",x2:"345.99",y2:"245.537",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint9_linear_1356_14057",x1:"142.262",y1:"279.808",x2:"138.362",y2:"280.762",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint10_linear_1356_14057",x1:"123.305",y1:"99.0746",x2:"119.406",y2:"100.028",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint11_linear_1356_14057",x1:"371.818",y1:"156.617",x2:"367.919",y2:"157.571",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint12_linear_1356_14057",x1:"385.281",y1:"242.958",x2:"381.382",y2:"243.911",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint13_linear_1356_14057",x1:"367.125",y1:"37.5052",x2:"360.843",y2:"38.8076",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint14_linear_1356_14057",x1:"300.182",y1:"91.321",x2:"479.464",y2:"104.041",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint15_linear_1356_14057",x1:"363.434",y1:"201.232",x2:"102.977",y2:"302.269",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint16_linear_1356_14057",x1:"447.962",y1:"165.159",x2:"313.049",y2:"197.95",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint17_linear_1356_14057",x1:"410.211",y1:"215.859",x2:"341.378",y2:"232.788",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint18_linear_1356_14057",x1:"222.282",y1:"258.986",x2:"162.257",y2:"273.774",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})))),gm=class{constructor(e){wp(this,e),this.close=Qp(this,"close",7),this.connectWithExtension=Qp(this,"connectWithExtension",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.i18nInstance=new lm,this.setTab(this.preferDesktop?1:2)}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(e=!1){this.close.emit({shouldTerminate:e})}connectWithExtensionHandler(){this.connectWithExtension.emit()}setTab(e){this.tab=e,this.isDefaultTab=!1}disconnectedCallback(){this.onClose()}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.sdkVersion,n=this.isDefaultTab?this.preferDesktop?1:2:this.tab,r=am(this.link,"svg",{ecc:"medium",scale:2});return Vp(Ig,{className:"select-modal"},Vp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),Vp("div",{class:"modal"},Vp("div",{class:"closeButtonContainer"},Vp("div",{class:"right"},Vp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},Vp(Ug,null)))),Vp("div",{class:"logoContainer"},Vp(Fg,null)),Vp("div",null,Vp("div",{class:"tabcontainer"},Vp("div",{class:"flexContainer"},Vp("div",{onClick:()=>this.setTab(1),class:"tab flexItem "+(1===n?"tabactive":"")},e("DESKTOP")),Vp("div",{onClick:()=>this.setTab(2),class:"tab flexItem "+(2===n?"tabactive":"")},e("MOBILE")))),Vp("div",{style:{display:1===n?"none":"block"}},Vp("div",{class:"flexContainer"},Vp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},Vp("div",{class:"center",id:"sdk-mm-qrcode",innerHTML:r}),Vp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT"),Vp("br",null),Vp("span",{class:"blue"},Vp("b",null,e("META_MASK_MOBILE_APP"))))))),Vp("div",{style:{display:2===n?"none":"block"}},Vp("div",{style:{display:"flex",justifyContent:"center",height:"300",marginTop:"-20"}},Vp(pm,null)),Vp("div",{class:"extensionLabel"},e("SELECT_MODAL.CRYPTO_TAKE_CONTROL_TEXT")),Vp("button",{class:"button",onClick:()=>this.connectWithExtensionHandler()},Vp(fm,null),Vp("span",{class:"installExtensionText"},e("CONNECT_WITH_EXTENSION"))))),Vp(Kg,{version:t})))}get el(){return Xp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};gm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";var mm=Object.freeze({__proto__:null,mm_install_modal:um,mm_pending_modal:hm,mm_select_modal:gm});function ym(e,r){return t(this,void 0,void 0,(function*(){const t={};e.rpc&&Object.entries(e.rpc).forEach((([e,n])=>{const r=`0x${Number(e).toString(16)}`;t[r]=n}));const r=new gp({useDeeplink:!0,enableAnalytics:!1,dappMetadata:{name:e.appName,iconUrl:e.appLogoUrl},readonlyRPCMap:t});r.isInitialized()||(yield r.init());let i=vm(r);yield r.connect(),i||(i=vm(r));return yield n(i)}))}function vm(e){const t=e.getProvider();try{t.on("connect",events.connect),t.on("disconnect",events.disconnect),t.on("accountsChanged",events.accountsChanged),t.on("chainChanged",events.chainChanged),t.on("message",events.message)}catch(e){}return t}export{ym as default};
9
+ h=p,function(e){var t=Object.hasOwnProperty,n=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},r="object"==typeof process&&"function"==typeof process.nextTick,i="function"==typeof Symbol,o="object"==typeof Reflect,s="function"==typeof setImmediate?setImmediate:setTimeout,a=i?o&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function c(){this._events={},this._conf&&l.call(this,this._conf)}function l(t){t&&(this._conf=t,t.delimiter&&(this.delimiter=t.delimiter),t.maxListeners!==e&&(this._maxListeners=t.maxListeners),t.wildcard&&(this.wildcard=t.wildcard),t.newListener&&(this._newListener=t.newListener),t.removeListener&&(this._removeListener=t.removeListener),t.verboseMemoryLeak&&(this.verboseMemoryLeak=t.verboseMemoryLeak),t.ignoreErrors&&(this.ignoreErrors=t.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function d(e,t){var n="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(n+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var r=new Error(n);r.name="MaxListenersExceededWarning",r.emitter=this,r.count=e,process.emitWarning(r)}else console.error(n),console.trace&&console.trace()}var u=function(e,t,n){var r=arguments.length;switch(r){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,n];default:for(var i=new Array(r);r--;)i[r]=arguments[r];return i}};function f(t,n){for(var r={},i=t.length,o=n?n.length:0,s=0;s<i;s++)r[t[s]]=s<o?n[s]:e;return r}function p(e,t,n){var r,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(n.on||n.off)&&(r=n.on,i=n.off),t.addEventListener?(r=t.addEventListener,i=t.removeEventListener):t.addListener?(r=t.addListener,i=t.removeListener):t.on&&(r=t.on,i=t.off),!r&&!i)throw Error("target does not implement any known event API");if("function"!=typeof r)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=r,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function g(n,r,i,o){var s=Object.assign({},r);if(!n)return s;if("object"!=typeof n)throw TypeError("options must be an object");var a,c,l,d=Object.keys(n),u=d.length;function h(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<u;f++){if(a=d[f],!o&&!t.call(r,a))throw Error('Unknown "'+a+'" option');(c=n[a])!==e&&(l=i[a],s[a]=l?l(c,h):c)}return s}function m(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function y(e){var t="value must be type of "+e.join("|"),n=e.length,r=e[0],i=e[1];return 1===n?function(e,n){if(typeof e===r)return e;n(t)}:2===n?function(e,n){var o=typeof e;if(o===r||o===i)return e;n(t)}:function(r,i){for(var o=typeof r,s=n;s-- >0;)if(o===e[s])return r;i(t)}}Object.assign(p.prototype,{subscribe:function(e,t,n){var r=this,i=this._target,o=this._emitter,s=this._listeners,a=function(){var r=u.apply(null,arguments),s={data:r,name:t,original:e};n?!1!==n.call(i,s)&&o.emit.apply(o,[s.name].concat(r)):o.emit.apply(o,[t].concat(r))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!r._onNewListener?(this._onNewListener=function(n){n===t&&null===s[e]&&(s[e]=a,r._on.call(i,e,a))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(n){n===t&&!o.hasListeners(n)&&s[e]&&(s[e]=null,r._off.call(i,e,a))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=a,r._on.call(i,e,a))},unsubscribe:function(e){var t,n,r,i=this,o=this._listeners,s=this._emitter,c=this._off,l=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function d(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=E.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=o[e]))return;c.call(l,e,t),delete o[e],--this._listenersCount||d()}else{for(r=(n=a(o)).length;r-- >0;)e=n[r],c.call(l,e,o[e]);this._listeners={},this._listenersCount=0,d()}}});var v=y(["function"]),b=y(["object","function"]);function w(e,t,n){var r,i,o,s=0,a=new e((function(c,l,d){function u(){i&&(i=null),s&&(clearTimeout(s),s=0)}n=g(n,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),r=!n.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof d;var h=function(e){u(),c(e)},f=function(e){u(),l(e)};r?t(h,f,d):(i=[function(e){f(e||Error("canceled"))}],t(h,f,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),n.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),l(e)}),n.timeout))}));return r||(a.cancel=function(e){if(i){for(var t=i.length,n=1;n<t;n++)i[n](e);i[0](e),i=null}}),a}function E(e){var t=this._observers;if(!t)return-1;for(var n=t.length,r=0;r<n;r++)if(t[r]._target===e)return r;return-1}function C(e,t,n,r,i){if(!n)return null;if(0===r){var o=typeof t;if("string"===o){var s,c,l=0,d=0,u=this.delimiter,h=u.length;if(-1!==(c=t.indexOf(u))){s=new Array(5);do{s[l++]=t.slice(d,c),d=c+h}while(-1!==(c=t.indexOf(u,d)));s[l++]=t.slice(d),t=s,i=l}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,p,g,m,y,v,b,w=null,E=t[r],_=t[r+1];if(r===i)n._listeners&&("function"==typeof n._listeners?(e&&e.push(n._listeners),w=[n]):(e&&e.push.apply(e,n._listeners),w=[n]));else{if("*"===E){for(c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&(b=C(e,t,n[f],r+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===E){for((y=r+1===i||r+2===i&&"*"===_)&&n._listeners&&(w=C(e,t,n,i,i)),c=(v=a(n)).length;c-- >0;)"_listeners"!==(f=v[c])&&("*"===f||"**"===f?(n[f]._listeners&&!y&&(b=C(e,t,n[f],i,i))&&(w?w.push.apply(w,b):w=b),b=C(e,t,n[f],r,i)):b=C(e,t,n[f],f===_?r+2:r,i),b&&(w?w.push.apply(w,b):w=b));return w}n[E]&&(w=C(e,t,n[E],r+1,i))}if((p=n["*"])&&C(e,t,p,r+1,i),g=n["**"])if(r<i)for(g._listeners&&C(e,t,g,i,i),c=(v=a(g)).length;c-- >0;)"_listeners"!==(f=v[c])&&(f===_?C(e,t,g[f],r+2,i):f===E?C(e,t,g[f],r+1,i):((m={})[f]=g[f],C(e,t,{"**":m},r+1,i)));else g._listeners?C(e,t,g,i,i):g["*"]&&g["*"]._listeners&&C(e,t,g["*"],i,i);return w}function _(e,t,n){var r,i,o=0,s=0,a=this.delimiter,c=a.length;if("string"==typeof e)if(-1!==(r=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,r),s=r+c}while(-1!==(r=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(r=0;r+1<o;r++)if("**"===i[r]&&"**"===i[r+1])return;var l,u=this.listenerTree;for(r=0;r<o;r++)if(u=u[l=i[r]]||(u[l]={}),r===o-1)return u._listeners?("function"==typeof u._listeners&&(u._listeners=[u._listeners]),n?u._listeners.unshift(t):u._listeners.push(t),!u._listeners.warned&&this._maxListeners>0&&u._listeners.length>this._maxListeners&&(u._listeners.warned=!0,d.call(this,u._listeners.length,l))):u._listeners=t,!0;return!0}function S(e,t,n,r){for(var i,o,s,c,l=a(e),d=l.length,u=e._listeners;d-- >0;)i=e[o=l[d]],s="_listeners"===o?n:n?n.concat(o):[o],c=r||"symbol"==typeof o,u&&t.push(c?s:s.join(this.delimiter)),"object"==typeof i&&S.call(this,i,t,s,c);return t}function k(e){for(var t,n,r,i=a(e),o=i.length;o-- >0;)(t=e[n=i[o]])&&(r=!0,"_listeners"===n||k(t)||delete e[n]);return r}function x(e,t,n){this.emitter=e,this.event=t,this.listener=n}function A(t,n,i){if(!0===i)a=!0;else if(!1===i)o=!0;else{if(!i||"object"!=typeof i)throw TypeError("options should be an object or true");var o=i.async,a=i.promisify,c=i.nextTick,l=i.objectify}if(o||c||a){var d=n,u=n._origin||n;if(c&&!r)throw Error("process.nextTick is not supported");a===e&&(a="AsyncFunction"===n.constructor.name),n=function(){var e=arguments,t=this,n=this.event;return a?c?Promise.resolve():new Promise((function(e){s(e)})).then((function(){return t.event=n,d.apply(t,e)})):(c?process.nextTick:s)((function(){t.event=n,d.apply(t,e)}))},n._async=!0,n._origin=u}return[n,l?new x(this,t,n):this]}function M(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,l.call(this,e)}x.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},M.EventEmitter2=M,M.prototype.listenTo=function(t,r,i){if("object"!=typeof t)throw TypeError("target musts be an object");var o=this;function s(e){if("object"!=typeof e)throw TypeError("events must be an object");var n,r=i.reducers,s=E.call(o,t);n=-1===s?new p(o,t,i):o._observers[s];for(var c,l=a(e),d=l.length,u="function"==typeof r,h=0;h<d;h++)c=l[h],n.subscribe(c,e[c]||c,u?r:r&&r[c])}return i=g(i,{on:e,off:e,reducers:e},{on:v,off:v,reducers:b}),n(r)?s(f(r)):s("string"==typeof r?f(r.split(/\s+/)):r),this},M.prototype.stopListeningTo=function(e,t){var n=this._observers;if(!n)return!1;var r,i=n.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)r=n[i],e&&r._target!==e||(r.unsubscribe(t),o=!0);return o},M.prototype.delimiter=".",M.prototype.setMaxListeners=function(t){t!==e&&(this._maxListeners=t,this._conf||(this._conf={}),this._conf.maxListeners=t)},M.prototype.getMaxListeners=function(){return this._maxListeners},M.prototype.event="",M.prototype.once=function(e,t,n){return this._once(e,t,!1,n)},M.prototype.prependOnceListener=function(e,t,n){return this._once(e,t,!0,n)},M.prototype._once=function(e,t,n,r){return this._many(e,1,t,n,r)},M.prototype.many=function(e,t,n,r){return this._many(e,t,n,!1,r)},M.prototype.prependMany=function(e,t,n,r){return this._many(e,t,n,!0,r)},M.prototype._many=function(e,t,n,r,i){var o=this;if("function"!=typeof n)throw new Error("many only accepts instances of Function");function s(){return 0==--t&&o.off(e,s),n.apply(this,arguments)}return s._origin=n,this._on(e,s,r,i)},M.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return!1;if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(n=a.length,i)for(r=0;r<n;r++)if("symbol"==typeof a[r]){s=!0;break}s||(a=a.join(this.delimiter))}var d,u=arguments.length;if(this._all&&this._all.length)for(r=0,n=(d=this._all.slice()).length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this,a);break;case 2:d[r].call(this,a,arguments[1]);break;case 3:d[r].call(this,a,arguments[1],arguments[2]);break;default:d[r].apply(this,arguments)}if(l)d=[],C.call(this,d,e,this.listenerTree,0,n);else{if("function"==typeof(d=this._events[a])){switch(this.event=a,u){case 1:d.call(this);break;case 2:d.call(this,arguments[1]);break;case 3:d.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];d.apply(this,t)}return!0}d&&(d=d.slice())}if(d&&d.length){if(u>3)for(t=new Array(u-1),o=1;o<u;o++)t[o-1]=arguments[o];for(r=0,n=d.length;r<n;r++)switch(this.event=a,u){case 1:d[r].call(this);break;case 2:d[r].call(this,arguments[1]);break;case 3:d[r].call(this,arguments[1],arguments[2]);break;default:d[r].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===a)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},M.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||c.call(this);var e,t,n,r,o,s,a=arguments[0],l=this.wildcard;if("newListener"===a&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(l&&(e=a,"newListener"!==a&&"removeListener"!==a&&"object"==typeof a)){if(r=a.length,i)for(o=0;o<r;o++)if("symbol"==typeof a[o]){t=!0;break}t||(a=a.join(this.delimiter))}var d,u=[],h=arguments.length;if(this._all)for(o=0,r=this._all.length;o<r;o++)switch(this.event=a,h){case 1:u.push(this._all[o].call(this,a));break;case 2:u.push(this._all[o].call(this,a,arguments[1]));break;case 3:u.push(this._all[o].call(this,a,arguments[1],arguments[2]));break;default:u.push(this._all[o].apply(this,arguments))}if(l?(d=[],C.call(this,d,e,this.listenerTree,0)):d=this._events[a],"function"==typeof d)switch(this.event=a,h){case 1:u.push(d.call(this));break;case 2:u.push(d.call(this,arguments[1]));break;case 3:u.push(d.call(this,arguments[1],arguments[2]));break;default:for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];u.push(d.apply(this,n))}else if(d&&d.length){if(d=d.slice(),h>3)for(n=new Array(h-1),s=1;s<h;s++)n[s-1]=arguments[s];for(o=0,r=d.length;o<r;o++)switch(this.event=a,h){case 1:u.push(d[o].call(this));break;case 2:u.push(d[o].call(this,arguments[1]));break;case 3:u.push(d[o].call(this,arguments[1],arguments[2]));break;default:u.push(d[o].apply(this,n))}}else if(!this.ignoreErrors&&!this._all&&"error"===a)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(u)},M.prototype.on=function(e,t,n){return this._on(e,t,!1,n)},M.prototype.prependListener=function(e,t,n){return this._on(e,t,!0,n)},M.prototype.onAny=function(e){return this._onAny(e,!1)},M.prototype.prependAny=function(e){return this._onAny(e,!0)},M.prototype.addListener=M.prototype.on,M.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},M.prototype._on=function(t,n,r,i){if("function"==typeof t)return this._onAny(t,n),this;if("function"!=typeof n)throw new Error("on only accepts instances of Function");this._events||c.call(this);var o,s=this;return i!==e&&(n=(o=A.call(this,t,n,i))[0],s=o[1]),this._newListener&&this.emit("newListener",t,n),this.wildcard?(_.call(this,t,n,r),s):(this._events[t]?("function"==typeof this._events[t]&&(this._events[t]=[this._events[t]]),r?this._events[t].unshift(n):this._events[t].push(n),!this._events[t].warned&&this._maxListeners>0&&this._events[t].length>this._maxListeners&&(this._events[t].warned=!0,d.call(this,this._events[t].length,t))):this._events[t]=n,s)},M.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,i=[];if(this.wildcard){var o="string"==typeof e?e.split(this.delimiter):e.slice();if(!(i=C.call(this,null,o,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],i.push({_listeners:r})}for(var s=0;s<i.length;s++){var a=i[s];if(r=a._listeners,n(r)){for(var c=-1,l=0,d=r.length;l<d;l++)if(r[l]===t||r[l].listener&&r[l].listener===t||r[l]._origin&&r[l]._origin===t){c=l;break}if(c<0)continue;return this.wildcard?a._listeners.splice(c,1):this._events[e].splice(c,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&k(this.listenerTree),this},M.prototype.offAny=function(e){var t,n=0,r=0;if(e&&this._all&&this._all.length>0){for(n=0,r=(t=this._all).length;n<r;n++)if(e===t[n])return t.splice(n,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(n=0,r=t.length;n<r;n++)this.emit("removeListenerAny",t[n]);this._all=[]}return this},M.prototype.removeListener=M.prototype.off,M.prototype.removeAllListeners=function(t){if(t===e)return!this._events||c.call(this),this;if(this.wildcard){var n,r=C.call(this,null,t,this.listenerTree,0);if(!r)return this;for(n=0;n<r.length;n++)r[n]._listeners=null;this.listenerTree&&k(this.listenerTree)}else this._events&&(this._events[t]=null);return this},M.prototype.listeners=function(t){var n,r,i,o,s,c=this._events;if(t===e){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!c)return[];for(o=(n=a(c)).length,i=[];o-- >0;)"function"==typeof(r=c[n[o]])?i.push(r):i.push.apply(i,r);return i}if(this.wildcard){if(!(s=this.listenerTree))return[];var l=[],d="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,l,d,s,0),l}return c&&(r=c[t])?"function"==typeof r?[r]:r:[]},M.prototype.eventNames=function(e){var t=this._events;return this.wildcard?S.call(this,this.listenerTree,[],null,e):t?a(t):[]},M.prototype.listenerCount=function(e){return this.listeners(e).length},M.prototype.hasListeners=function(t){if(this.wildcard){var n=[],r="string"==typeof t?t.split(this.delimiter):t.slice();return C.call(this,n,r,this.listenerTree,0),n.length>0}var i=this._events,o=this._all;return!!(o&&o.length||i&&(t===e?a(i).length:i[t]))},M.prototype.listenersAny=function(){return this._all?this._all:[]},M.prototype.waitFor=function(t,n){var r=this,i=typeof n;return"number"===i?n={timeout:n}:"function"===i&&(n={filter:n}),w((n=g(n,{timeout:0,filter:e,handleError:!1,Promise:Promise,overload:!1},{filter:v,Promise:m})).Promise,(function(e,i,o){function s(){var o=n.filter;if(!o||o.apply(r,arguments))if(r.off(t,s),n.handleError){var a=arguments[0];a?i(a):e(u.apply(null,arguments).slice(1))}else e(u.apply(null,arguments))}o((function(){r.off(t,s)})),r._on(t,s,!1)}),{timeout:n.timeout,overload:n.overload})};var L=M.prototype;Object.defineProperties(M,{defaultMaxListeners:{get:function(){return L._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");L._maxListeners=e},enumerable:!0},once:{value:function(e,t,n){return w((n=g(n,{Promise:Promise,timeout:0,overload:!1},{Promise:m})).Promise,(function(n,r,i){var o;if("function"==typeof e.addEventListener)return o=function(){n(u.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,a=function(){s&&e.removeListener("error",s),n(u.apply(null,arguments))};"error"!==t&&(s=function(n){e.removeListener(t,a),r(n)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,a)})),e.once(t,a)}),{timeout:n.timeout,overload:n.overload})},writable:!0,configurable:!0}}),Object.defineProperties(L,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),"function"==typeof e&&e.amd?e((function(){return M})):h.exports=M}();var g=p.exports;const m=Object.create(null);m.open="0",m.close="1",m.ping="2",m.pong="3",m.message="4",m.upgrade="5",m.noop="6";const y=Object.create(null);Object.keys(m).forEach((e=>{y[m[e]]=e}));const v={type:"error",data:"parser error"},b="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),w="function"==typeof ArrayBuffer,E=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,C=({type:e,data:t},n,r)=>b&&t instanceof Blob?n?r(t):_(t,r):w&&(t instanceof ArrayBuffer||E(t))?n?r(t):_(new Blob([t]),r):r(m[e]+(t||"")),_=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function S(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let k;const x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",A="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let e=0;e<64;e++)A[x.charCodeAt(e)]=e;const M="function"==typeof ArrayBuffer,L=(e,t)=>{if("string"!=typeof e)return{type:"message",data:O(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:T(e.substring(1),t)};return y[n]?e.length>1?{type:y[n],data:e.substring(1)}:{type:y[n]}:v},T=(e,t)=>{if(M){const n=(e=>{let t,n,r,i,o,s=.75*e.length,a=e.length,c=0;"="===e[e.length-1]&&(s--,"="===e[e.length-2]&&s--);const l=new ArrayBuffer(s),d=new Uint8Array(l);for(t=0;t<a;t+=4)n=A[e.charCodeAt(t)],r=A[e.charCodeAt(t+1)],i=A[e.charCodeAt(t+2)],o=A[e.charCodeAt(t+3)],d[c++]=n<<2|r>>4,d[c++]=(15&r)<<4|i>>2,d[c++]=(3&i)<<6|63&o;return l})(e);return O(n,t)}return{base64:!0,data:e}},O=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,R=String.fromCharCode(30);function P(){return new TransformStream({transform(e,t){!function(e,t){b&&e.data instanceof Blob?e.data.arrayBuffer().then(S).then(t):w&&(e.data instanceof ArrayBuffer||E(e.data))?t(S(e.data)):C(e,!1,(e=>{k||(k=new TextEncoder),t(k.encode(e))}))}(e,(n=>{const r=n.length;let i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);const e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);const e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&"string"!=typeof e.data&&(i[0]|=128),t.enqueue(i),t.enqueue(n)}))}})}let I;function N(e){return e.reduce(((e,t)=>e+t.length),0)}function B(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function D(e){if(e)return function(e){for(var t in D.prototype)e[t]=D.prototype[t];return e}(e)}D.prototype.on=D.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},D.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},D.prototype.off=D.prototype.removeListener=D.prototype.removeAllListeners=D.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,r=this._callbacks["$"+e];if(!r)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var i=0;i<r.length;i++)if((n=r[i])===t||n.fn===t){r.splice(i,1);break}return 0===r.length&&delete this._callbacks["$"+e],this},D.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){r=0;for(var i=(n=n.slice(0)).length;r<i;++r)n[r].apply(this,t)}return this},D.prototype.emitReserved=D.prototype.emit,D.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},D.prototype.hasListeners=function(e){return!!this.listeners(e).length};const $="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function j(e,...t){return t.reduce(((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t)),{})}const K=$.setTimeout,U=$.clearTimeout;function F(e,t){t.useNativeTimers?(e.setTimeoutFn=K.bind($),e.clearTimeoutFn=U.bind($)):(e.setTimeoutFn=$.setTimeout.bind($),e.clearTimeoutFn=$.clearTimeout.bind($))}class H extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class z extends D{constructor(e){super(),this.writable=!1,F(this,e),this.opts=e,this.query=e.query,this.socket=e.socket}onError(e,t,n){return super.emitReserved("error",new H(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=L(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}const q="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_".split(""),V=64,W={};let G,Y=0,Z=0;function J(e){let t="";do{t=q[e%V]+t,e=Math.floor(e/V)}while(e>0);return t}function X(){const e=J(+new Date);return e!==G?(Y=0,G=e):e+"."+J(Y++)}for(;Z<V;Z++)W[q[Z]]=Z;let Q=!1;try{Q="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(e){}const ee=Q;function te(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||ee))return new XMLHttpRequest}catch(e){}if(!t)try{return new($[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(e){}}function ne(){}const re=null!=new te({xdomain:!1}).responseType;class ie extends D{constructor(e,t){super(),F(this,t),this.opts=t,this.method=t.method||"GET",this.uri=e,this.data=void 0!==t.data?t.data:null,this.create()}create(){var e;const t=j(this.opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this.opts.xd;const n=this.xhr=new te(t);try{n.open(this.method,this.uri,!0);try{if(this.opts.extraHeaders){n.setDisableHeaderCheck&&n.setDisableHeaderCheck(!0);for(let e in this.opts.extraHeaders)this.opts.extraHeaders.hasOwnProperty(e)&&n.setRequestHeader(e,this.opts.extraHeaders[e])}}catch(e){}if("POST"===this.method)try{n.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(e){}try{n.setRequestHeader("Accept","*/*")}catch(e){}null===(e=this.opts.cookieJar)||void 0===e||e.addCookies(n),"withCredentials"in n&&(n.withCredentials=this.opts.withCredentials),this.opts.requestTimeout&&(n.timeout=this.opts.requestTimeout),n.onreadystatechange=()=>{var e;3===n.readyState&&(null===(e=this.opts.cookieJar)||void 0===e||e.parseCookies(n)),4===n.readyState&&(200===n.status||1223===n.status?this.onLoad():this.setTimeoutFn((()=>{this.onError("number"==typeof n.status?n.status:0)}),0))},n.send(this.data)}catch(e){return void this.setTimeoutFn((()=>{this.onError(e)}),0)}"undefined"!=typeof document&&(this.index=ie.requestsCount++,ie.requests[this.index]=this)}onError(e){this.emitReserved("error",e,this.xhr),this.cleanup(!0)}cleanup(e){if(void 0!==this.xhr&&null!==this.xhr){if(this.xhr.onreadystatechange=ne,e)try{this.xhr.abort()}catch(e){}"undefined"!=typeof document&&delete ie.requests[this.index],this.xhr=null}}onLoad(){const e=this.xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this.cleanup())}abort(){this.cleanup()}}if(ie.requestsCount=0,ie.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",oe);else if("function"==typeof addEventListener){addEventListener("onpagehide"in $?"pagehide":"unload",oe,!1)}function oe(){for(let e in ie.requests)ie.requests.hasOwnProperty(e)&&ie.requests[e].abort()}const se="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),ae=$.WebSocket||$.MozWebSocket,ce="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();const le={websocket:class extends z{constructor(e){super(e),this.supportsBinary=!e.forceBase64}get name(){return"websocket"}doOpen(){if(!this.check())return;const e=this.uri(),t=this.opts.protocols,n=ce?{}:j(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=ce?new ae(e,t,n):t?new ae(e,t):new ae(e)}catch(e){return this.emitReserved("error",e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;C(n,this.supportsBinary,(e=>{try{this.ws.send(e)}catch(e){}r&&se((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){void 0!==this.ws&&(this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=X()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}check(){return!!ae}},webtransport:class extends z{get name(){return"webtransport"}doOpen(){"function"==typeof WebTransport&&(this.transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name]),this.transport.closed.then((()=>{this.onClose()})).catch((e=>{this.onError("webtransport error",e)})),this.transport.ready.then((()=>{this.transport.createBidirectionalStream().then((e=>{const t=function(e,t){I||(I=new TextDecoder);const n=[];let r=0,i=-1,o=!1;return new TransformStream({transform(s,a){for(n.push(s);;){if(0===r){if(N(n)<1)break;const e=B(n,1);o=128==(128&e[0]),i=127&e[0],r=i<126?3:126===i?1:2}else if(1===r){if(N(n)<2)break;const e=B(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(2===r){if(N(n)<8)break;const e=B(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),o=t.getUint32(0);if(o>Math.pow(2,21)-1){a.enqueue(v);break}i=o*Math.pow(2,32)+t.getUint32(4),r=3}else{if(N(n)<i)break;const e=B(n,i);a.enqueue(L(o?e:I.decode(e),t)),r=0}if(0===i||i>e){a.enqueue(v);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=P();r.readable.pipeTo(e.writable),this.writer=r.writable.getWriter();const i=()=>{n.read().then((({done:e,value:t})=>{e||(this.onPacket(t),i())})).catch((e=>{}))};i();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this.writer.write(o).then((()=>this.onOpen()))}))})))}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],r=t===e.length-1;this.writer.write(n).then((()=>{r&&se((()=>{this.writable=!0,this.emitReserved("drain")}),this.setTimeoutFn)}))}}doClose(){var e;null===(e=this.transport)||void 0===e||e.close()}},polling:class extends z{constructor(e){if(super(e),this.polling=!1,"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}const t=e&&e.forceBase64;this.supportsBinary=re&&!t,this.opts.withCredentials&&(this.cookieJar=void 0)}get name(){return"polling"}doOpen(){this.poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this.polling||!this.writable){let e=0;this.polling&&(e++,this.once("pollComplete",(function(){--e||t()}))),this.writable||(e++,this.once("drain",(function(){--e||t()})))}else t()}poll(){this.polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const n=e.split(R),r=[];for(let e=0;e<n.length;e++){const i=L(n[e],t);if(r.push(i),"error"===i.type)break}return r})(e,this.socket.binaryType).forEach((e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)})),"closed"!==this.readyState&&(this.polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this.poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,r=new Array(n);let i=0;e.forEach(((e,o)=>{C(e,!1,(e=>{r[o]=e,++i===n&&t(r.join(R))}))}))})(e,(e=>{this.doWrite(e,(()=>{this.writable=!0,this.emitReserved("drain")}))}))}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=X()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}request(e={}){return Object.assign(e,{xd:this.xd,cookieJar:this.cookieJar},this.opts),new ie(this.uri(),e)}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",((e,t)=>{this.onError("xhr post error",e,t)}))}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",((e,t)=>{this.onError("xhr poll error",e,t)})),this.pollXhr=e}}},de=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,ue=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function he(e){if(e.length>2e3)throw"URI too long";const t=e,n=e.indexOf("["),r=e.indexOf("]");-1!=n&&-1!=r&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,";")+e.substring(r,e.length));let i=de.exec(e||""),o={},s=14;for(;s--;)o[ue[s]]=i[s]||"";return-1!=n&&-1!=r&&(o.source=t,o.host=o.host.substring(1,o.host.length-1).replace(/;/g,":"),o.authority=o.authority.replace("[","").replace("]","").replace(/;/g,":"),o.ipv6uri=!0),o.pathNames=function(e,t){const n=/\/{2,9}/g,r=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||r.splice(0,1);"/"==t.slice(-1)&&r.splice(r.length-1,1);return r}(0,o.path),o.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,(function(e,t,r){t&&(n[t]=r)})),n}(0,o.query),o}class fe extends D{constructor(e,t={}){super(),this.binaryType="arraybuffer",this.writeBuffer=[],e&&"object"==typeof e&&(t=e,e=null),e?(e=he(e),t.hostname=e.host,t.secure="https"===e.protocol||"wss"===e.protocol,t.port=e.port,e.query&&(t.query=e.query)):t.host&&(t.hostname=he(t.host).host),F(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=t.transports||["polling","websocket","webtransport"],this.writeBuffer=[],this.prevBufferLen=0,this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let e=0,r=n.length;e<r;e++){let r=n[e].split("=");t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}(this.opts.query)),this.id=null,this.upgrades=null,this.pingInterval=null,this.pingTimeout=null,this.pingTimeoutTimer=null,"function"==typeof addEventListener&&(this.opts.closeOnBeforeunload&&(this.beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this.beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this.offlineEventListener=()=>{this.onClose("transport close",{description:"network connection lost"})},addEventListener("offline",this.offlineEventListener,!1))),this.open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new le[e](n)}open(){let e;if(this.opts.rememberUpgrade&&fe.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket"))e="websocket";else{if(0===this.transports.length)return void this.setTimeoutFn((()=>{this.emitReserved("error","No transports available")}),0);e=this.transports[0]}this.readyState="opening";try{e=this.createTransport(e)}catch(e){return this.transports.shift(),void this.open()}e.open(),this.setTransport(e)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this.onDrain.bind(this)).on("packet",this.onPacket.bind(this)).on("error",this.onError.bind(this)).on("close",(e=>this.onClose("transport close",e)))}probe(e){let t=this.createTransport(e),n=!1;fe.priorWebsocketSuccess=!1;const r=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",(e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;fe.priorWebsocketSuccess="websocket"===t.name,this.transport.pause((()=>{n||"closed"!==this.readyState&&(l(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())}))}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}})))};function i(){n||(n=!0,l(),t.close(),t=null)}const o=e=>{const n=new Error("probe error: "+e);n.transport=t.name,i(),this.emitReserved("upgradeError",n)};function s(){o("transport closed")}function a(){o("socket closed")}function c(e){t&&e.name!==t.name&&i()}const l=()=>{t.removeListener("open",r),t.removeListener("error",o),t.removeListener("close",s),this.off("close",a),this.off("upgrading",c)};t.once("open",r),t.once("error",o),t.once("close",s),this.once("close",a),this.once("upgrading",c),-1!==this.upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn((()=>{n||t.open()}),200):t.open()}onOpen(){if(this.readyState="open",fe.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush(),"open"===this.readyState&&this.opts.upgrade){let e=0;const t=this.upgrades.length;for(;e<t;e++)this.probe(this.upgrades[e])}}onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),this.resetPingTimeout(),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this.sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong");break;case"error":const t=new Error("server error");t.code=e.data,this.onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this.upgrades=this.filterUpgrades(e.upgrades),this.pingInterval=e.pingInterval,this.pingTimeout=e.pingTimeout,this.maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this.resetPingTimeout()}resetPingTimeout(){this.clearTimeoutFn(this.pingTimeoutTimer),this.pingTimeoutTimer=this.setTimeoutFn((()=>{this.onClose("ping timeout")}),this.pingInterval+this.pingTimeout),this.opts.autoUnref&&this.pingTimeoutTimer.unref()}onDrain(){this.writeBuffer.splice(0,this.prevBufferLen),this.prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this.getWritablePackets();this.transport.send(e),this.prevBufferLen=e.length,this.emitReserved("flush")}}getWritablePackets(){if(!(this.maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let n=0;n<this.writeBuffer.length;n++){const r=this.writeBuffer[n].data;if(r&&(e+="string"==typeof(t=r)?function(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}(t):Math.ceil(1.33*(t.byteLength||t.size))),n>0&&e>this.maxPayload)return this.writeBuffer.slice(0,n);e+=2}var t;return this.writeBuffer}write(e,t,n){return this.sendPacket("message",e,t,n),this}send(e,t,n){return this.sendPacket("message",e,t,n),this}sendPacket(e,t,n,r){if("function"==typeof t&&(r=t,t=void 0),"function"==typeof n&&(r=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const i={type:e,data:t,options:n};this.emitReserved("packetCreate",i),this.writeBuffer.push(i),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this.onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",(()=>{this.upgrading?n():e()})):this.upgrading?n():e()),this}onError(e){fe.priorWebsocketSuccess=!1,this.emitReserved("error",e),this.onClose("transport error",e)}onClose(e,t){"opening"!==this.readyState&&"open"!==this.readyState&&"closing"!==this.readyState||(this.clearTimeoutFn(this.pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),"function"==typeof removeEventListener&&(removeEventListener("beforeunload",this.beforeunloadEventListener,!1),removeEventListener("offline",this.offlineEventListener,!1)),this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this.prevBufferLen=0)}filterUpgrades(e){const t=[];let n=0;const r=e.length;for(;n<r;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}fe.protocol=4;const pe="function"==typeof ArrayBuffer,ge=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,me=Object.prototype.toString,ye="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===me.call(Blob),ve="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===me.call(File);function be(e){return pe&&(e instanceof ArrayBuffer||ge(e))||ye&&e instanceof Blob||ve&&e instanceof File}function we(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(we(e[t]))return!0;return!1}if(be(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return we(e.toJSON(),!0);for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&we(e[t]))return!0;return!1}function Ee(e){const t=[],n=e.data,r=e;return r.data=Ce(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Ce(e,t){if(!e)return e;if(be(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let r=0;r<e.length;r++)n[r]=Ce(e[r],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Ce(e[r],t));return n}return e}function _e(e,t){return e.data=Se(e.data,t),delete e.attachments,e}function Se(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Se(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Se(e[n],t));return e}const ke=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var xe;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(xe||(xe={}));function Ae(e){return"[object Object]"===Object.prototype.toString.call(e)}class Me extends D{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===xe.BINARY_EVENT;n||t.type===xe.BINARY_ACK?(t.type=n?xe.EVENT:xe.ACK,this.reconstructor=new Le(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!be(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===xe[n.type])throw new Error("unknown packet type "+n.type);if(n.type===xe.BINARY_EVENT||n.type===xe.BINARY_ACK){const r=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const i=e.substring(r,t);if(i!=Number(i)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(i)}if("/"===e.charAt(t+1)){const r=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(r,t)}else n.nsp="/";const r=e.charAt(t+1);if(""!==r&&Number(r)==r){const r=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(r,t+1))}if(e.charAt(++t)){const r=this.tryParse(e.substr(t));if(!Me.isPayloadValid(n.type,r))throw new Error("invalid payload");n.data=r}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(e){return!1}}static isPayloadValid(e,t){switch(e){case xe.CONNECT:return Ae(t);case xe.DISCONNECT:return void 0===t;case xe.CONNECT_ERROR:return"string"==typeof t||Ae(t);case xe.EVENT:case xe.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===ke.indexOf(t[0]));case xe.ACK:case xe.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class Le{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=_e(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}var Te=Object.freeze({__proto__:null,protocol:5,get PacketType(){return xe},Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==xe.EVENT&&e.type!==xe.ACK||!we(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===xe.EVENT?xe.BINARY_EVENT:xe.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==xe.BINARY_EVENT&&e.type!==xe.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=Ee(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Decoder:Me});function Oe(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const Re=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class Pe extends D{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[Oe(e,"open",this.onopen.bind(this)),Oe(e,"packet",this.onpacket.bind(this)),Oe(e,"error",this.onerror.bind(this)),Oe(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){if(Re.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const n={type:xe.EVENT,data:t,options:{}};if(n.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}const r=this.io.engine&&this.io.engine.transport&&this.io.engine.transport.writable;return this.flags.volatile&&(!r||!this.connected)||(this.connected?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){var n;const r=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===r)return void(this.acks[e]=t);const i=this.io.setTimeoutFn((()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))}),r);this.acks[e]=(...e)=>{this.io.clearTimeoutFn(i),t.apply(this,[null,...e])}}emitWithAck(e,...t){const n=void 0!==this.flags.timeout||void 0!==this._opts.ackTimeout;return new Promise(((r,i)=>{t.push(((e,t)=>n?e?i(e):r(t):r(e))),this.emit(e,...t)}))}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push(((e,...r)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...r)),n.pending=!1,this._drainQueue()})),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth((e=>{this._sendConnectPacket(e)})):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:xe.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t)}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case xe.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case xe.EVENT:case xe.BINARY_EVENT:this.onevent(e);break;case xe.ACK:case xe.BINARY_ACK:this.onack(e);break;case xe.DISCONNECT:this.ondisconnect();break;case xe.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...r){n||(n=!0,t.packet({type:xe.ACK,id:e,data:r}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(t.apply(this,e.data),delete this.acks[e.id])}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach((e=>this.emitEvent(e))),this.receiveBuffer=[],this.sendBuffer.forEach((e=>{this.notifyOutgoingListeners(e),this.packet(e)})),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach((e=>e())),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:xe.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function Ie(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}Ie.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=0==(1&Math.floor(10*t))?e-n:e+n}return 0|Math.min(e,this.max)},Ie.prototype.reset=function(){this.attempts=0},Ie.prototype.setMin=function(e){this.ms=e},Ie.prototype.setMax=function(e){this.max=e},Ie.prototype.setJitter=function(e){this.jitter=e};class Ne extends D{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,F(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new Ie({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const r=t.parser||Te;this.encoder=new r.Encoder,this.decoder=new r.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new fe(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const r=Oe(t,"open",(function(){n.onopen(),e&&e()})),i=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},o=Oe(t,"error",i);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn((()=>{r(),i(new Error("timeout")),t.close()}),e);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}return this.subs.push(r),this.subs.push(o),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(Oe(e,"ping",this.onping.bind(this)),Oe(e,"data",this.ondata.bind(this)),Oe(e,"error",this.onerror.bind(this)),Oe(e,"close",this.onclose.bind(this)),Oe(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose("parse error",e)}}ondecoded(e){se((()=>{this.emitReserved("packet",e)}),this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new Pe(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const e of t){if(this.nsps[e].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach((e=>e())),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close"),this.engine&&this.engine.close()}disconnect(){return this._close()}onclose(e,t){this.cleanup(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn((()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open((t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()})))}),t);this.opts.autoUnref&&n.unref(),this.subs.push((()=>{this.clearTimeoutFn(n)}))}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const Be={};function De(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let r=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),r=he(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port="80":/^(http|ws)s$/.test(r.protocol)&&(r.port="443")),r.path=r.path||"/";const i=-1!==r.host.indexOf(":")?"["+r.host+"]":r.host;return r.id=r.protocol+"://"+i+":"+r.port+t,r.href=r.protocol+"://"+i+(n&&n.port===r.port?"":":"+r.port),r}(e,(t=t||{}).path||"/socket.io"),r=n.source,i=n.id,o=n.path,s=Be[i]&&o in Be[i].nsps;let a;return t.forceNew||t["force new connection"]||!1===t.multiplex||s?a=new Ne(r,t):(Be[i]||(Be[i]=new Ne(r,t)),a=Be[i]),n.query&&!t.query&&(t.query=n.queryKey),a.socket(n.path,t)}function $e(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}Object.assign(De,{Manager:Ne,Socket:Pe,io:De,connect:De}),"function"==typeof SuppressedError&&SuppressedError;var je="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},Ke=[],Ue=[],Fe="undefined"!=typeof Uint8Array?Uint8Array:Array,He=!1;function ze(){He=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0;t<64;++t)Ke[t]=e[t],Ue[e.charCodeAt(t)]=t;Ue["-".charCodeAt(0)]=62,Ue["_".charCodeAt(0)]=63}function qe(e,t,n){for(var r,i,o=[],s=t;s<n;s+=3)r=(e[s]<<16)+(e[s+1]<<8)+e[s+2],o.push(Ke[(i=r)>>18&63]+Ke[i>>12&63]+Ke[i>>6&63]+Ke[63&i]);return o.join("")}function Ve(e){var t;He||ze();for(var n=e.length,r=n%3,i="",o=[],s=16383,a=0,c=n-r;a<c;a+=s)o.push(qe(e,a,a+s>c?c:a+s));return 1===r?(t=e[n-1],i+=Ke[t>>2],i+=Ke[t<<4&63],i+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],i+=Ke[t>>10],i+=Ke[t>>4&63],i+=Ke[t<<2&63],i+="="),o.push(i),o.join("")}function We(e,t,n,r,i){var o,s,a=8*i-r-1,c=(1<<a)-1,l=c>>1,d=-7,u=n?i-1:0,h=n?-1:1,f=e[t+u];for(u+=h,o=f&(1<<-d)-1,f>>=-d,d+=a;d>0;o=256*o+e[t+u],u+=h,d-=8);for(s=o&(1<<-d)-1,o>>=-d,d+=r;d>0;s=256*s+e[t+u],u+=h,d-=8);if(0===o)o=1-l;else{if(o===c)return s?NaN:1/0*(f?-1:1);s+=Math.pow(2,r),o-=l}return(f?-1:1)*s*Math.pow(2,o-r)}function Ge(e,t,n,r,i,o){var s,a,c,l=8*o-i-1,d=(1<<l)-1,u=d>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,s=d):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+u>=1?h/c:h*Math.pow(2,1-u))*c>=2&&(s++,c/=2),s+u>=d?(a=0,s=d):s+u>=1?(a=(t*c-1)*Math.pow(2,i),s+=u):(a=t*Math.pow(2,u-1)*Math.pow(2,i),s=0));i>=8;e[n+f]=255&a,f+=p,a/=256,i-=8);for(s=s<<i|a,l+=i;l>0;e[n+f]=255&s,f+=p,s/=256,l-=8);e[n+f-p]|=128*g}var Ye={}.toString,Ze=Array.isArray||function(e){return"[object Array]"==Ye.call(e)};et.TYPED_ARRAY_SUPPORT=void 0===je.TYPED_ARRAY_SUPPORT||je.TYPED_ARRAY_SUPPORT;var Je=Xe();function Xe(){return et.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function Qe(e,t){if(Xe()<t)throw new RangeError("Invalid typed array length");return et.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=et.prototype:(null===e&&(e=new et(t)),e.length=t),e}function et(e,t,n){if(!(et.TYPED_ARRAY_SUPPORT||this instanceof et))return new et(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return rt(this,e)}return tt(this,e,t,n)}function tt(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),et.TYPED_ARRAY_SUPPORT?(e=t).__proto__=et.prototype:e=it(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!et.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|at(t,n),i=(e=Qe(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(st(t)){var n=0|ot(t.length);return 0===(e=Qe(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?Qe(e,0):it(e,t);if("Buffer"===t.type&&Ze(t.data))return it(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function nt(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function rt(e,t){if(nt(t),e=Qe(e,t<0?0:0|ot(t)),!et.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function it(e,t){var n=t.length<0?0:0|ot(t.length);e=Qe(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];return e}function ot(e){if(e>=Xe())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+Xe().toString(16)+" bytes");return 0|e}function st(e){return!(null==e||!e._isBuffer)}function at(e,t){if(st(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return It(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Nt(e).length;default:if(r)return It(e).length;t=(""+t).toLowerCase(),r=!0}}function ct(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return _t(this,t,n);case"utf8":case"utf-8":return bt(this,t,n);case"ascii":return Et(this,t,n);case"latin1":case"binary":return Ct(this,t,n);case"base64":return vt(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return St(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function lt(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function dt(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=et.from(t,r)),st(t))return 0===t.length?-1:ut(e,t,n,r,i);if("number"==typeof t)return t&=255,et.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):ut(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function ut(e,t,n,r,i){var o,s=1,a=e.length,c=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;s=2,a/=2,c/=2,n/=2}function l(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var d=-1;for(o=n;o<a;o++)if(l(e,o)===l(t,-1===d?0:o-d)){if(-1===d&&(d=o),o-d+1===c)return d*s}else-1!==d&&(o-=o-d),d=-1}else for(n+c>a&&(n=a-c),o=n;o>=0;o--){for(var u=!0,h=0;h<c;h++)if(l(e,o+h)!==l(t,h)){u=!1;break}if(u)return o}return-1}function ht(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");r>o/2&&(r=o/2);for(var s=0;s<r;++s){var a=parseInt(t.substr(2*s,2),16);if(isNaN(a))return s;e[n+s]=a}return s}function ft(e,t,n,r){return Bt(It(t,e.length-n),e,n,r)}function pt(e,t,n,r){return Bt(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function gt(e,t,n,r){return pt(e,t,n,r)}function mt(e,t,n,r){return Bt(Nt(t),e,n,r)}function yt(e,t,n,r){return Bt(function(e,t){for(var n,r,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=(n=e.charCodeAt(s))>>8,i=n%256,o.push(i),o.push(r);return o}(t,e.length-n),e,n,r)}function vt(e,t,n){return 0===t&&n===e.length?Ve(e):Ve(e.slice(t,n))}function bt(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var o,s,a,c,l=e[i],d=null,u=l>239?4:l>223?3:l>191?2:1;if(i+u<=n)switch(u){case 1:l<128&&(d=l);break;case 2:128==(192&(o=e[i+1]))&&(c=(31&l)<<6|63&o)>127&&(d=c);break;case 3:o=e[i+1],s=e[i+2],128==(192&o)&&128==(192&s)&&(c=(15&l)<<12|(63&o)<<6|63&s)>2047&&(c<55296||c>57343)&&(d=c);break;case 4:o=e[i+1],s=e[i+2],a=e[i+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(c=(15&l)<<18|(63&o)<<12|(63&s)<<6|63&a)>65535&&c<1114112&&(d=c)}null===d?(d=65533,u=1):d>65535&&(d-=65536,r.push(d>>>10&1023|55296),d=56320|1023&d),r.push(d),i+=u}return function(e){var t=e.length;if(t<=wt)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=wt));return n}(r)}et.poolSize=8192,et._augment=function(e){return e.__proto__=et.prototype,e},et.from=function(e,t,n){return tt(null,e,t,n)},et.TYPED_ARRAY_SUPPORT&&(et.prototype.__proto__=Uint8Array.prototype,et.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&et[Symbol.species]),et.alloc=function(e,t,n){return function(e,t,n,r){return nt(t),t<=0?Qe(e,t):void 0!==n?"string"==typeof r?Qe(e,t).fill(n,r):Qe(e,t).fill(n):Qe(e,t)}(null,e,t,n)},et.allocUnsafe=function(e){return rt(null,e)},et.allocUnsafeSlow=function(e){return rt(null,e)},et.isBuffer=Dt,et.compare=function(e,t){if(!st(e)||!st(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,i=0,o=Math.min(n,r);i<o;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?1:0},et.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},et.concat=function(e,t){if(!Ze(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return et.alloc(0);var n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=et.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!st(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},et.byteLength=at,et.prototype._isBuffer=!0,et.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)lt(this,t,t+1);return this},et.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)lt(this,t,t+3),lt(this,t+1,t+2);return this},et.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)lt(this,t,t+7),lt(this,t+1,t+6),lt(this,t+2,t+5),lt(this,t+3,t+4);return this},et.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?bt(this,0,e):ct.apply(this,arguments)},et.prototype.equals=function(e){if(!st(e))throw new TypeError("Argument must be a Buffer");return this===e||0===et.compare(this,e)},et.prototype.inspect=function(){var e="";return this.length>0&&(e=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(e+=" ... ")),"<Buffer "+e+">"},et.prototype.compare=function(e,t,n,r,i){if(!st(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(r>>>=0),s=(n>>>=0)-(t>>>=0),a=Math.min(o,s),c=this.slice(r,i),l=e.slice(t,n),d=0;d<a;++d)if(c[d]!==l[d]){o=c[d],s=l[d];break}return o<s?-1:s<o?1:0},et.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},et.prototype.indexOf=function(e,t,n){return dt(this,e,t,n,!0)},et.prototype.lastIndexOf=function(e,t,n){return dt(this,e,t,n,!1)},et.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var o=!1;;)switch(r){case"hex":return ht(this,e,t,n);case"utf8":case"utf-8":return ft(this,e,t,n);case"ascii":return pt(this,e,t,n);case"latin1":case"binary":return gt(this,e,t,n);case"base64":return mt(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return yt(this,e,t,n);default:if(o)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),o=!0}},et.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var wt=4096;function Et(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function Ct(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function _t(e,t,n){var r=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>r)&&(n=r);for(var i="",o=t;o<n;++o)i+=Pt(e[o]);return i}function St(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function kt(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function xt(e,t,n,r,i,o){if(!st(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(n+r>e.length)throw new RangeError("Index out of range")}function At(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-n,2);i<o;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function Mt(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-n,4);i<o;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function Lt(e,t,n,r,i,o){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function Tt(e,t,n,r,i){return i||Lt(e,0,n,4),Ge(e,t,n,r,23,4),n+4}function Ot(e,t,n,r,i){return i||Lt(e,0,n,8),Ge(e,t,n,r,52,8),n+8}et.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),et.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=et.prototype;else{var i=t-e;n=new et(i,void 0);for(var o=0;o<i;++o)n[o]=this[o+e]}return n},et.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r},et.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},et.prototype.readUInt8=function(e,t){return t||kt(e,1,this.length),this[e]},et.prototype.readUInt16LE=function(e,t){return t||kt(e,2,this.length),this[e]|this[e+1]<<8},et.prototype.readUInt16BE=function(e,t){return t||kt(e,2,this.length),this[e]<<8|this[e+1]},et.prototype.readUInt32LE=function(e,t){return t||kt(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},et.prototype.readUInt32BE=function(e,t){return t||kt(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},et.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=this[e],i=1,o=0;++o<t&&(i*=256);)r+=this[e+o]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},et.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||kt(e,t,this.length);for(var r=t,i=1,o=this[e+--r];r>0&&(i*=256);)o+=this[e+--r]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},et.prototype.readInt8=function(e,t){return t||kt(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},et.prototype.readInt16LE=function(e,t){t||kt(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},et.prototype.readInt16BE=function(e,t){t||kt(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},et.prototype.readInt32LE=function(e,t){return t||kt(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},et.prototype.readInt32BE=function(e,t){return t||kt(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},et.prototype.readFloatLE=function(e,t){return t||kt(e,4,this.length),We(this,e,!0,23,4)},et.prototype.readFloatBE=function(e,t){return t||kt(e,4,this.length),We(this,e,!1,23,4)},et.prototype.readDoubleLE=function(e,t){return t||kt(e,8,this.length),We(this,e,!0,52,8)},et.prototype.readDoubleBE=function(e,t){return t||kt(e,8,this.length),We(this,e,!1,52,8)},et.prototype.writeUIntLE=function(e,t,n,r){e=+e,t|=0,n|=0,r||xt(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,o=0;for(this[t]=255&e;++o<n&&(i*=256);)this[t+o]=e/i&255;return t+n},et.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||xt(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,o=1;for(this[t+i]=255&e;--i>=0&&(o*=256);)this[t+i]=e/o&255;return t+n},et.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,1,255,0),et.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},et.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,65535,0),et.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):At(this,e,t,!0),t+2},et.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,65535,0),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):At(this,e,t,!1),t+2},et.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,4294967295,0),et.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):Mt(this,e,t,!0),t+4},et.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,4294967295,0),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Mt(this,e,t,!1),t+4},et.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);xt(this,e,t,n,i-1,-i)}var o=0,s=1,a=0;for(this[t]=255&e;++o<n&&(s*=256);)e<0&&0===a&&0!==this[t+o-1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},et.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);xt(this,e,t,n,i-1,-i)}var o=n-1,s=1,a=0;for(this[t+o]=255&e;--o>=0&&(s*=256);)e<0&&0===a&&0!==this[t+o+1]&&(a=1),this[t+o]=(e/s>>0)-a&255;return t+n},et.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,1,127,-128),et.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},et.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,32767,-32768),et.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):At(this,e,t,!0),t+2},et.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,2,32767,-32768),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):At(this,e,t,!1),t+2},et.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,2147483647,-2147483648),et.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):Mt(this,e,t,!0),t+4},et.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||xt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),et.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):Mt(this,e,t,!1),t+4},et.prototype.writeFloatLE=function(e,t,n){return Tt(this,e,t,!0,n)},et.prototype.writeFloatBE=function(e,t,n){return Tt(this,e,t,!1,n)},et.prototype.writeDoubleLE=function(e,t,n){return Ot(this,e,t,!0,n)},et.prototype.writeDoubleBE=function(e,t,n){return Ot(this,e,t,!1,n)},et.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,o=r-n;if(this===e&&n<t&&t<r)for(i=o-1;i>=0;--i)e[i+t]=this[i+n];else if(o<1e3||!et.TYPED_ARRAY_SUPPORT)for(i=0;i<o;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+o),t);return o},et.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!et.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var o;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(o=t;o<n;++o)this[o]=e;else{var s=st(e)?e:It(new et(e,r).toString()),a=s.length;for(o=0;o<n-t;++o)this[o+t]=s[o%a]}return this};var Rt=/[^+\/0-9A-Za-z-_]/g;function Pt(e){return e<16?"0"+e.toString(16):e.toString(16)}function It(e,t){var n;t=t||1/0;for(var r=e.length,i=null,o=[],s=0;s<r;++s){if((n=e.charCodeAt(s))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(s+1===r){(t-=3)>-1&&o.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&o.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;o.push(n)}else if(n<2048){if((t-=2)<0)break;o.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;o.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return o}function Nt(e){return function(e){var t,n,r,i,o,s;He||ze();var a=e.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o="="===e[a-2]?2:"="===e[a-1]?1:0,s=new Fe(3*a/4-o),r=o>0?a-4:a;var c=0;for(t=0,n=0;t<r;t+=4,n+=3)i=Ue[e.charCodeAt(t)]<<18|Ue[e.charCodeAt(t+1)]<<12|Ue[e.charCodeAt(t+2)]<<6|Ue[e.charCodeAt(t+3)],s[c++]=i>>16&255,s[c++]=i>>8&255,s[c++]=255&i;return 2===o?(i=Ue[e.charCodeAt(t)]<<2|Ue[e.charCodeAt(t+1)]>>4,s[c++]=255&i):1===o&&(i=Ue[e.charCodeAt(t)]<<10|Ue[e.charCodeAt(t+1)]<<4|Ue[e.charCodeAt(t+2)]>>2,s[c++]=i>>8&255,s[c++]=255&i),s}(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(Rt,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function Bt(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}function Dt(e){return null!=e&&(!!e._isBuffer||$t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&$t(e.slice(0,0))}(e))}function $t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var jt=Object.freeze({__proto__:null,Buffer:et,INSPECT_MAX_BYTES:50,SlowBuffer:function(e){return+e!=e&&(e=0),et.alloc(+e)},isBuffer:Dt,kMaxLength:Je}),Kt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Ut(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Ft(e){if(e.__esModule)return e;var t=e.default;if("function"==typeof t){var n=function e(){return this instanceof e?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach((function(t){var r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:function(){return e[t]}})})),n}var Ht={},zt={},qt={};function Vt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function Wt(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function Gt(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function Yt(e,...t){if(!Gt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function Zt(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("hash must be wrapped by utils.wrapConstructor");Vt(e.outputLen),Vt(e.blockLen)}function Jt(e,t=!0){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 Xt(e,t){Yt(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(qt,"__esModule",{value:!0}),qt.isBytes=Gt,qt.number=Vt,qt.bool=Wt,qt.bytes=Yt,qt.hash=Zt,qt.exists=Jt,qt.output=Xt;const Qt={number:Vt,bool:Wt,bytes:Yt,hash:Zt,exists:Jt,output:Xt};qt.default=Qt,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.wrapCipher=e.Hash=e.nextTick=e.isLE=e.createView=e.u32=e.u16=e.u8=void 0,e.bytesToHex=r,e.hexToBytes=s,e.hexToNumber=a,e.bytesToNumberBE=function(e){return a(r(e))},e.numberToBytesBE=function(e,t){return s(e.toString(16).padStart(2*t,"0"))},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=c,e.bytesToUtf8=function(e){return(new TextDecoder).decode(e)},e.toBytes=function(e){if("string"==typeof e)e=c(e);else{if(!(0,t.isBytes)(e))throw new Error("Uint8Array expected, got "+typeof e);e=d(e)}return e},e.concatBytes=function(...e){let n=0;for(let r=0;r<e.length;r++){const i=e[r];(0,t.bytes)(i),n+=i.length}const r=new Uint8Array(n);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)},e.equalBytes=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},e.setBigUint64=l,e.u64Lengths=function(t,n){const r=new Uint8Array(16),i=(0,e.createView)(r);return l(i,0,BigInt(n?n.length:0),!0),l(i,8,BigInt(t.length),!0),r},e.isAligned32=function(e){return e.byteOffset%4==0},e.copyBytes=d,e.clean=function(...e){for(let t=0;t<e.length;t++)e[t].fill(0)};const t=qt;if(e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u16=e=>new Uint16Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/2)),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],!e.isLE)throw new Error("Non little-endian hardware is not supported");const n=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function r(e){(0,t.bytes)(e);let r="";for(let t=0;t<e.length;t++)r+=n[e[t]];return r}const i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(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 t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r}function a(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}function c(e){if("string"!=typeof e)throw new Error("string expected, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function l(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}function d(e){return Uint8Array.from(e)}e.nextTick=async()=>{},e.Hash=class{},e.wrapCipher=(e,t)=>(Object.assign(t,e),t)}(zt);var en={},tn={};Object.defineProperty(tn,"__esModule",{value:!0}),tn.AEAD_TAG_LENGTH=tn.XCHACHA20_NONCE_LENGTH=tn.CURVE25519_PUBLIC_KEY_SIZE=tn.ETH_PUBLIC_KEY_SIZE=tn.UNCOMPRESSED_PUBLIC_KEY_SIZE=tn.COMPRESSED_PUBLIC_KEY_SIZE=tn.SECRET_KEY_LENGTH=void 0,tn.SECRET_KEY_LENGTH=32,tn.COMPRESSED_PUBLIC_KEY_SIZE=33,tn.UNCOMPRESSED_PUBLIC_KEY_SIZE=65,tn.ETH_PUBLIC_KEY_SIZE=64,tn.CURVE25519_PUBLIC_KEY_SIZE=32,tn.XCHACHA20_NONCE_LENGTH=24,tn.AEAD_TAG_LENGTH=16,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ephemeralKeySize=e.symmetricNonceLength=e.symmetricAlgorithm=e.isHkdfKeyCompressed=e.isEphemeralKeyCompressed=e.ellipticCurve=e.ECIES_CONFIG=void 0;var t=tn;e.ECIES_CONFIG=new function(){this.ellipticCurve="secp256k1",this.isEphemeralKeyCompressed=!1,this.isHkdfKeyCompressed=!1,this.symmetricAlgorithm="aes-256-gcm",this.symmetricNonceLength=16},e.ellipticCurve=function(){return e.ECIES_CONFIG.ellipticCurve},e.isEphemeralKeyCompressed=function(){return e.ECIES_CONFIG.isEphemeralKeyCompressed},e.isHkdfKeyCompressed=function(){return e.ECIES_CONFIG.isHkdfKeyCompressed},e.symmetricAlgorithm=function(){return e.ECIES_CONFIG.symmetricAlgorithm},e.symmetricNonceLength=function(){return e.ECIES_CONFIG.symmetricNonceLength},e.ephemeralKeySize=function(){var n={secp256k1:e.ECIES_CONFIG.isEphemeralKeyCompressed?t.COMPRESSED_PUBLIC_KEY_SIZE:t.UNCOMPRESSED_PUBLIC_KEY_SIZE,x25519:t.CURVE25519_PUBLIC_KEY_SIZE,ed25519:t.CURVE25519_PUBLIC_KEY_SIZE};if(e.ECIES_CONFIG.ellipticCurve in n)return n[e.ECIES_CONFIG.ellipticCurve];throw new Error("Not implemented")}}(en);var nn={},rn={},on={},sn={},an={},cn={};Object.defineProperty(cn,"__esModule",{value:!0}),cn.crypto=void 0,cn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.gcm=e.ctr=e.cbc=e.utils=void 0,e.randomBytes=i,e.getWebcryptoSubtle=o,e.managedNonce=function(e){return(0,n.number)(e.nonceLength),(t,...n)=>({encrypt(o,...s){const{nonceLength:a}=e,c=i(a),l=e(t,c,...n).encrypt(o,...s),d=(0,r.concatBytes)(c,l);return l.fill(0),d},decrypt(r,...i){const{nonceLength:o}=e,s=r.subarray(0,o),a=r.subarray(o);return e(t,s,...n).decrypt(a,...i)}})};const t=cn,n=qt,r=zt;function i(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}function o(){if(t.crypto&&"object"==typeof t.crypto.subtle&&null!=t.crypto.subtle)return t.crypto.subtle;throw new Error("crypto.subtle must be defined")}e.utils={async encrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["encrypt"]),a=await i.encrypt(n,s,r);return new Uint8Array(a)},async decrypt(e,t,n,r){const i=o(),s=await i.importKey("raw",e,t,!0,["decrypt"]),a=await i.decrypt(n,s,r);return new Uint8Array(a)}};const s={CBC:"AES-CBC",CTR:"AES-CTR",GCM:"AES-GCM"};function a(t){return(r,i,o)=>{(0,n.bytes)(r),(0,n.bytes)(i);const a={name:t,length:8*r.length},c=function(e,t,n){if(e===s.CBC)return{name:s.CBC,iv:t};if(e===s.CTR)return{name:s.CTR,counter:t,length:64};if(e===s.GCM)return n?{name:s.GCM,iv:t,additionalData:n}:{name:s.GCM,iv:t};throw new Error("unknown aes block mode")}(t,i,o);return{encrypt:t=>((0,n.bytes)(t),e.utils.encrypt(r,a,c,t)),decrypt:t=>((0,n.bytes)(t),e.utils.decrypt(r,a,c,t))}}}e.cbc=a(s.CBC),e.ctr=a(s.CTR),e.gcm=a(s.GCM)}(an);var ln={},dn={},un={},hn={};function fn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function pn(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}function gn(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function mn(e,...t){if(!gn(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function yn(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");fn(e.outputLen),fn(e.blockLen)}function vn(e,t=!0){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 bn(e,t){mn(e);const n=t.outputLen;if(e.length<n)throw new Error(`digestInto() expects output buffer of length at least ${n}`)}Object.defineProperty(hn,"__esModule",{value:!0}),hn.isBytes=gn,hn.number=fn,hn.bool=pn,hn.bytes=mn,hn.hash=yn,hn.exists=vn,hn.output=bn;const wn={number:fn,bool:pn,bytes:mn,hash:yn,exists:vn,output:bn};hn.default=wn;var En={},Cn={};Object.defineProperty(Cn,"__esModule",{value:!0}),Cn.crypto=void 0,Cn.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name},e.byteSwap32=function(t){for(let n=0;n<t.length;n++)t[n]=(0,e.byteSwap)(t[n])},e.bytesToHex=function(e){(0,n.bytes)(e);let t="";for(let n=0;n<e.length;n++)t+=r[e[n]];return t},e.hexToBytes=function(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 t=0,i=0;t<n;t++,i+=2){const n=o(e.charCodeAt(i)),s=o(e.charCodeAt(i+1));if(void 0===n||void 0===s){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+s}return r},e.asyncLoop=async function(t,n,r){let i=Date.now();for(let o=0;o<t;o++){r(o);const t=Date.now()-i;t>=0&&t<n||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=s,e.toBytes=a,e.concatBytes=function(...e){let t=0;for(let r=0;r<e.length;r++){const i=e[r];(0,n.bytes)(i),t+=i.length}const r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const i=e[t];r.set(i,n),n+=i.length}return r},e.checkOpts=function(e,t){if(void 0!==t&&"[object Object]"!==c.call(t))throw new Error("Options should be object or undefined");return Object.assign(e,t)},e.wrapConstructor=function(e){const t=t=>e().update(a(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t},e.wrapConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.wrapXOFConstructorWithOpts=function(e){const t=(t,n)=>e(n).update(a(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t},e.randomBytes=function(e=32){if(t.crypto&&"function"==typeof t.crypto.getRandomValues)return t.crypto.getRandomValues(new Uint8Array(e));if(t.crypto&&"function"==typeof t.crypto.randomBytes)return t.crypto.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")};const t=Cn,n=hn;e.u8=e=>new Uint8Array(e.buffer,e.byteOffset,e.byteLength),e.u32=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),e.createView=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),e.rotr=(e,t)=>e<<32-t|e>>>t,e.rotl=(e,t)=>e<<t|e>>>32-t>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255,e.byteSwapIfBE=e.isLE?e=>e:t=>(0,e.byteSwap)(t);const r=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0"))),i={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function o(e){return e>=i._0&&e<=i._9?e-i._0:e>=i._A&&e<=i._F?e-(i._A-10):e>=i._a&&e<=i._f?e-(i._a-10):void 0}function s(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}function a(e){return"string"==typeof e&&(e=s(e)),(0,n.bytes)(e),e}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const c={}.toString}(En),Object.defineProperty(un,"__esModule",{value:!0}),un.HashMD=un.Maj=un.Chi=void 0;const _n=hn,Sn=En;un.Chi=(e,t,n)=>e&t^~e&n,un.Maj=(e,t,n)=>e&t^e&n^t&n,un.HashMD=class extends Sn.Hash{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=(0,Sn.createView)(this.buffer)}update(e){(0,_n.exists)(this);const{view:t,buffer:n,blockLen:r}=this,i=(e=(0,Sn.toBytes)(e)).length;for(let o=0;o<i;){const s=Math.min(r-this.pos,i-o);if(s!==r)n.set(e.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===r&&(this.process(t,0),this.pos=0);else{const t=(0,Sn.createView)(e);for(;r<=i-o;o+=r)this.process(t,o)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){(0,_n.exists)(this),(0,_n.output)(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(n,0),o=0);for(let e=o;e<r;e++)t[e]=0;!function(e,t,n,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),c=r?4:0,l=r?0:4;e.setUint32(t+c,s,r),e.setUint32(t+l,a,r)}(n,r-8,BigInt(8*this.length),i),this.process(n,0);const s=(0,Sn.createView)(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)s.setUint32(4*e,l[e],i)}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:i,destroyed:o,pos:s}=this;return e.length=r,e.pos=s,e.finished=i,e.destroyed=o,r%t&&e.buffer.set(n),e}};var kn={};Object.defineProperty(kn,"__esModule",{value:!0}),kn.add5L=kn.add5H=kn.add4H=kn.add4L=kn.add3H=kn.add3L=kn.rotlBL=kn.rotlBH=kn.rotlSL=kn.rotlSH=kn.rotr32L=kn.rotr32H=kn.rotrBL=kn.rotrBH=kn.rotrSL=kn.rotrSH=kn.shrSL=kn.shrSH=kn.toBig=void 0,kn.fromBig=Mn,kn.split=Ln,kn.add=Hn;const xn=BigInt(2**32-1),An=BigInt(32);function Mn(e,t=!1){return t?{h:Number(e&xn),l:Number(e>>An&xn)}:{h:0|Number(e>>An&xn),l:0|Number(e&xn)}}function Ln(e,t=!1){let n=new Uint32Array(e.length),r=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:o,l:s}=Mn(e[i],t);[n[i],r[i]]=[o,s]}return[n,r]}const Tn=(e,t)=>BigInt(e>>>0)<<An|BigInt(t>>>0);kn.toBig=Tn;const On=(e,t,n)=>e>>>n;kn.shrSH=On;const Rn=(e,t,n)=>e<<32-n|t>>>n;kn.shrSL=Rn;const Pn=(e,t,n)=>e>>>n|t<<32-n;kn.rotrSH=Pn;const In=(e,t,n)=>e<<32-n|t>>>n;kn.rotrSL=In;const Nn=(e,t,n)=>e<<64-n|t>>>n-32;kn.rotrBH=Nn;const Bn=(e,t,n)=>e>>>n-32|t<<64-n;kn.rotrBL=Bn;const Dn=(e,t)=>t;kn.rotr32H=Dn;const $n=(e,t)=>e;kn.rotr32L=$n;const jn=(e,t,n)=>e<<n|t>>>32-n;kn.rotlSH=jn;const Kn=(e,t,n)=>t<<n|e>>>32-n;kn.rotlSL=Kn;const Un=(e,t,n)=>t<<n-32|e>>>64-n;kn.rotlBH=Un;const Fn=(e,t,n)=>e<<n-32|t>>>64-n;function Hn(e,t,n,r){const i=(t>>>0)+(r>>>0);return{h:e+n+(i/2**32|0)|0,l:0|i}}kn.rotlBL=Fn;const zn=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0);kn.add3L=zn;const qn=(e,t,n,r)=>t+n+r+(e/2**32|0)|0;kn.add3H=qn;const Vn=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0);kn.add4L=Vn;const Wn=(e,t,n,r,i)=>t+n+r+i+(e/2**32|0)|0;kn.add4H=Wn;const Gn=(e,t,n,r,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(i>>>0);kn.add5L=Gn;const Yn=(e,t,n,r,i,o)=>t+n+r+i+o+(e/2**32|0)|0;kn.add5H=Yn;const Zn={fromBig:Mn,split:Ln,toBig:Tn,shrSH:On,shrSL:Rn,rotrSH:Pn,rotrSL:In,rotrBH:Nn,rotrBL:Bn,rotr32H:Dn,rotr32L:$n,rotlSH:jn,rotlSL:Kn,rotlBH:Un,rotlBL:Fn,add:Hn,add3L:zn,add3H:qn,add4L:Vn,add4H:Wn,add5H:Yn,add5L:Gn};kn.default=Zn,Object.defineProperty(dn,"__esModule",{value:!0}),dn.sha384=dn.sha512_256=dn.sha512_224=dn.sha512=dn.SHA384=dn.SHA512_256=dn.SHA512_224=dn.SHA512=void 0;const Jn=un,Xn=kn,Qn=En,[er,tr]=Xn.default.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)))),nr=new Uint32Array(80),rr=new Uint32Array(80);class ir extends Jn.HashMD{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:i,Cl:o,Dh:s,Dl:a,Eh:c,El:l,Fh:d,Fl:u,Gh:h,Gl:f,Hh:p,Hl:g}=this;return[e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g]}set(e,t,n,r,i,o,s,a,c,l,d,u,h,f,p,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|r,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|d,this.Fl=0|u,this.Gh=0|h,this.Gl=0|f,this.Hh=0|p,this.Hl=0|g}process(e,t){for(let n=0;n<16;n++,t+=4)nr[n]=e.getUint32(t),rr[n]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|nr[e-15],n=0|rr[e-15],r=Xn.default.rotrSH(t,n,1)^Xn.default.rotrSH(t,n,8)^Xn.default.shrSH(t,n,7),i=Xn.default.rotrSL(t,n,1)^Xn.default.rotrSL(t,n,8)^Xn.default.shrSL(t,n,7),o=0|nr[e-2],s=0|rr[e-2],a=Xn.default.rotrSH(o,s,19)^Xn.default.rotrBH(o,s,61)^Xn.default.shrSH(o,s,6),c=Xn.default.rotrSL(o,s,19)^Xn.default.rotrBL(o,s,61)^Xn.default.shrSL(o,s,6),l=Xn.default.add4L(i,c,rr[e-7],rr[e-16]),d=Xn.default.add4H(l,r,a,nr[e-7],nr[e-16]);nr[e]=0|d,rr[e]=0|l}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:s,Cl:a,Dh:c,Dl:l,Eh:d,El:u,Fh:h,Fl:f,Gh:p,Gl:g,Hh:m,Hl:y}=this;for(let e=0;e<80;e++){const t=Xn.default.rotrSH(d,u,14)^Xn.default.rotrSH(d,u,18)^Xn.default.rotrBH(d,u,41),v=Xn.default.rotrSL(d,u,14)^Xn.default.rotrSL(d,u,18)^Xn.default.rotrBL(d,u,41),b=d&h^~d&p,w=u&f^~u&g,E=Xn.default.add5L(y,v,w,tr[e],rr[e]),C=Xn.default.add5H(E,m,t,b,er[e],nr[e]),_=0|E,S=Xn.default.rotrSH(n,r,28)^Xn.default.rotrBH(n,r,34)^Xn.default.rotrBH(n,r,39),k=Xn.default.rotrSL(n,r,28)^Xn.default.rotrBL(n,r,34)^Xn.default.rotrBL(n,r,39),x=n&i^n&s^i&s,A=r&o^r&a^o&a;m=0|p,y=0|g,p=0|h,g=0|f,h=0|d,f=0|u,({h:d,l:u}=Xn.default.add(0|c,0|l,0|C,0|_)),c=0|s,l=0|a,s=0|i,a=0|o,i=0|n,o=0|r;const M=Xn.default.add3L(_,k,A);n=Xn.default.add3H(M,C,S,x),r=0|M}({h:n,l:r}=Xn.default.add(0|this.Ah,0|this.Al,0|n,0|r)),({h:i,l:o}=Xn.default.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=Xn.default.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:c,l:l}=Xn.default.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:d,l:u}=Xn.default.add(0|this.Eh,0|this.El,0|d,0|u)),({h:h,l:f}=Xn.default.add(0|this.Fh,0|this.Fl,0|h,0|f)),({h:p,l:g}=Xn.default.add(0|this.Gh,0|this.Gl,0|p,0|g)),({h:m,l:y}=Xn.default.add(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(n,r,i,o,s,a,c,l,d,u,h,f,p,g,m,y)}roundClean(){nr.fill(0),rr.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)}}dn.SHA512=ir;class or extends ir{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}dn.SHA512_224=or;class sr extends ir{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}dn.SHA512_256=sr;class ar extends ir{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}dn.SHA384=ar,dn.sha512=(0,Qn.wrapConstructor)((()=>new ir)),dn.sha512_224=(0,Qn.wrapConstructor)((()=>new or)),dn.sha512_256=(0,Qn.wrapConstructor)((()=>new sr)),dn.sha384=(0,Qn.wrapConstructor)((()=>new ar));var cr={},lr={},dr={},ur={};Object.defineProperty(ur,"__esModule",{value:!0}),ur.notImplemented=ur.bitMask=void 0,ur.isBytes=gr,ur.abytes=mr,ur.abool=function(e,t){if("boolean"!=typeof t)throw new Error(`${e} must be valid boolean, got "${t}".`)},ur.bytesToHex=vr,ur.numberToHexUnpadded=br,ur.hexToNumber=wr,ur.hexToBytes=_r,ur.bytesToNumberBE=function(e){return wr(vr(e))},ur.bytesToNumberLE=function(e){return mr(e),wr(vr(Uint8Array.from(e).reverse()))},ur.numberToBytesBE=Sr,ur.numberToBytesLE=function(e,t){return Sr(e,t).reverse()},ur.numberToVarBytesBE=function(e){return _r(br(e))},ur.ensureBytes=function(e,t,n){let r;if("string"==typeof t)try{r=_r(t)}catch(n){throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${n}`)}else{if(!gr(t))throw new Error(`${e} must be hex string or Uint8Array`);r=Uint8Array.from(t)}const i=r.length;if("number"==typeof n&&i!==n)throw new Error(`${e} expected ${n} bytes, got ${i}`);return r},ur.concatBytes=kr,ur.equalBytes=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},ur.utf8ToBytes=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))},ur.inRange=Ar,ur.aInRange=function(e,t,n,r){if(!Ar(t,n,r))throw new Error(`expected valid ${e}: ${n} <= n < ${r}, got ${typeof t} ${t}`)},ur.bitLen=function(e){let t;for(t=0;e>hr;e>>=fr,t+=1);return t},ur.bitGet=function(e,t){return e>>BigInt(t)&fr},ur.bitSet=function(e,t,n){return e|(n?fr:hr)<<BigInt(t)},ur.createHmacDrbg=function(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=Mr(e),i=Mr(e),o=0;const s=()=>{r.fill(1),i.fill(0),o=0},a=(...e)=>n(i,r,...e),c=(e=Mr())=>{i=a(Lr([0]),e),r=a(),0!==e.length&&(i=a(Lr([1]),e),r=a())},l=()=>{if(o++>=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 kr(...n)};return(e,t)=>{let n;for(s(),c(e);!(n=t(l()));)c();return s(),n}},ur.validateObject=function(e,t,n={}){const r=(t,n,r)=>{const i=Tr[n];if("function"!=typeof i)throw new Error(`Invalid validator "${n}", expected function`);const o=e[t];if(!(r&&void 0===o||i(o,e)))throw new Error(`Invalid param ${String(t)}=${o} (${typeof o}), expected ${n}`)};for(const[e,n]of Object.entries(t))r(e,n,!1);for(const[e,t]of Object.entries(n))r(e,t,!0);return e},ur.memoized=function(e){const t=new WeakMap;return(n,...r)=>{const i=t.get(n);if(void 0!==i)return i;const o=e(n,...r);return t.set(n,o),o}};const hr=BigInt(0),fr=BigInt(1),pr=BigInt(2);function gr(e){return e instanceof Uint8Array||null!=e&&"object"==typeof e&&"Uint8Array"===e.constructor.name}function mr(e){if(!gr(e))throw new Error("Uint8Array expected")}const yr=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function vr(e){mr(e);let t="";for(let n=0;n<e.length;n++)t+=yr[e[n]];return t}function br(e){const t=e.toString(16);return 1&t.length?`0${t}`:t}function wr(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return BigInt(""===e?"0":`0x${e}`)}const Er={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function Cr(e){return e>=Er._0&&e<=Er._9?e-Er._0:e>=Er._A&&e<=Er._F?e-(Er._A-10):e>=Er._a&&e<=Er._f?e-(Er._a-10):void 0}function _r(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 t=0,i=0;t<n;t++,i+=2){const n=Cr(e.charCodeAt(i)),o=Cr(e.charCodeAt(i+1));if(void 0===n||void 0===o){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}r[t]=16*n+o}return r}function Sr(e,t){return _r(e.toString(16).padStart(2*t,"0"))}function kr(...e){let t=0;for(let n=0;n<e.length;n++){const r=e[n];mr(r),t+=r.length}const n=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){const i=e[t];n.set(i,r),r+=i.length}return n}const xr=e=>"bigint"==typeof e&&hr<=e;function Ar(e,t,n){return xr(e)&&xr(t)&&xr(n)&&t<=e&&e<n}ur.bitMask=e=>(pr<<BigInt(e-1))-fr;const Mr=e=>new Uint8Array(e),Lr=e=>Uint8Array.from(e),Tr={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||gr(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)};ur.notImplemented=()=>{throw new Error("not implemented")},Object.defineProperty(dr,"__esModule",{value:!0}),dr.isNegativeLE=void 0,dr.mod=jr,dr.pow=Kr,dr.pow2=function(e,t,n){let r=e;for(;t-- >Rr;)r*=r,r%=n;return r},dr.invert=Ur,dr.tonelliShanks=Fr,dr.FpSqrt=Hr,dr.validateField=function(e){const t=zr.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"});return(0,Or.validateObject)(e,t)},dr.FpPow=qr,dr.FpInvertBatch=Vr,dr.FpDiv=function(e,t,n){return e.mul(t,"bigint"==typeof n?Ur(n,e.ORDER):e.inv(n))},dr.FpLegendre=Wr,dr.FpIsSquare=function(e){const t=Wr(e.ORDER);return n=>{const r=t(e,n);return e.eql(r,e.ZERO)||e.eql(r,e.ONE)}},dr.nLength=Gr,dr.Field=function(e,t,n=!1,r={}){if(e<=Rr)throw new Error(`Expected Field ORDER > 0, got ${e}`);const{nBitLength:i,nByteLength:o}=Gr(e,t);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=Hr(e),a=Object.freeze({ORDER:e,BITS:i,BYTES:o,MASK:(0,Or.bitMask)(i),ZERO:Rr,ONE:Pr,create:t=>jr(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("Invalid field element: expected bigint, got "+typeof t);return Rr<=t&&t<e},is0:e=>e===Rr,isOdd:e=>(e&Pr)===Pr,neg:t=>jr(-t,e),eql:(e,t)=>e===t,sqr:t=>jr(t*t,e),add:(t,n)=>jr(t+n,e),sub:(t,n)=>jr(t-n,e),mul:(t,n)=>jr(t*n,e),pow:(e,t)=>qr(a,e,t),div:(t,n)=>jr(t*Ur(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Ur(t,e),sqrt:r.sqrt||(e=>s(a,e)),invertBatch:e=>Vr(a,e),cmov:(e,t,n)=>n?t:e,toBytes:e=>n?(0,Or.numberToBytesLE)(e,o):(0,Or.numberToBytesBE)(e,o),fromBytes:e=>{if(e.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${e.length}`);return n?(0,Or.bytesToNumberLE)(e):(0,Or.bytesToNumberBE)(e)}});return Object.freeze(a)},dr.FpSqrtOdd=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?n:e.neg(n)},dr.FpSqrtEven=function(e,t){if(!e.isOdd)throw new Error("Field doesn't have isOdd");const n=e.sqrt(t);return e.isOdd(n)?e.neg(n):n},dr.hashToPrivateScalar=function(e,t,n=!1){const r=(e=(0,Or.ensureBytes)("privateHash",e)).length,i=Gr(t).nByteLength+8;if(i<24||r<i||r>1024)throw new Error(`hashToPrivateScalar: expected ${i}-1024 bytes of input, got ${r}`);return jr(n?(0,Or.bytesToNumberLE)(e):(0,Or.bytesToNumberBE)(e),t-Pr)+Pr},dr.getFieldBytesLength=Yr,dr.getMinHashLength=Zr,dr.mapHashToField=function(e,t,n=!1){const r=e.length,i=Yr(t),o=Zr(t);if(r<16||r<o||r>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);const s=jr(n?(0,Or.bytesToNumberBE)(e):(0,Or.bytesToNumberLE)(e),t-Pr)+Pr;return n?(0,Or.numberToBytesLE)(s,i):(0,Or.numberToBytesBE)(s,i)};const Or=ur,Rr=BigInt(0),Pr=BigInt(1),Ir=BigInt(2),Nr=BigInt(3),Br=BigInt(4),Dr=BigInt(5),$r=BigInt(8);function jr(e,t){const n=e%t;return n>=Rr?n:t+n}function Kr(e,t,n){if(n<=Rr||t<Rr)throw new Error("Expected power/modulo > 0");if(n===Pr)return Rr;let r=Pr;for(;t>Rr;)t&Pr&&(r=r*e%n),e=e*e%n,t>>=Pr;return r}function Ur(e,t){if(e===Rr||t<=Rr)throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);let n=jr(e,t),r=t,i=Rr,o=Pr;for(;n!==Rr;){const e=r%n,t=i-o*(r/n);r=n,n=e,i=o,o=t}if(r!==Pr)throw new Error("invert: does not exist");return jr(i,t)}function Fr(e){const t=(e-Pr)/Ir;let n,r,i;for(n=e-Pr,r=0;n%Ir===Rr;n/=Ir,r++);for(i=Ir;i<e&&Kr(i,t,e)!==e-Pr;i++);if(1===r){const t=(e+Pr)/Br;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 o=(n+Pr)/Ir;return function(e,s){if(e.pow(s,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=r,c=e.pow(e.mul(e.ONE,i),n),l=e.pow(s,o),d=e.pow(s,n);for(;!e.eql(d,e.ONE);){if(e.eql(d,e.ZERO))return e.ZERO;let t=1;for(let n=e.sqr(d);t<a&&!e.eql(n,e.ONE);t++)n=e.sqr(n);const n=e.pow(c,Pr<<BigInt(a-t-1));c=e.sqr(n),l=e.mul(l,n),d=e.mul(d,c),a=t}return l}}function Hr(e){if(e%Br===Nr){const t=(e+Pr)/Br;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%$r===Dr){const t=(e-Dr)/$r;return function(e,n){const r=e.mul(n,Ir),i=e.pow(r,t),o=e.mul(n,i),s=e.mul(e.mul(o,Ir),i),a=e.mul(o,e.sub(s,e.ONE));if(!e.eql(e.sqr(a),n))throw new Error("Cannot find square root");return a}}return Fr(e)}BigInt(9),BigInt(16),dr.isNegativeLE=(e,t)=>(jr(e,t)&Pr)===Pr;const zr=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function qr(e,t,n){if(n<Rr)throw new Error("Expected power > 0");if(n===Rr)return e.ONE;if(n===Pr)return t;let r=e.ONE,i=t;for(;n>Rr;)n&Pr&&(r=e.mul(r,i)),i=e.sqr(i),n>>=Pr;return r}function Vr(e,t){const n=new Array(t.length),r=t.reduce(((t,r,i)=>e.is0(r)?t:(n[i]=t,e.mul(t,r))),e.ONE),i=e.inv(r);return t.reduceRight(((t,r,i)=>e.is0(r)?t:(n[i]=e.mul(t,n[i]),e.mul(t,r))),i),n}function Wr(e){const t=(e-Pr)/Ir;return(e,n)=>e.pow(n,t)}function Gr(e,t){const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function Yr(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 Zr(e){const t=Yr(e);return t+Math.ceil(t/2)}Object.defineProperty(lr,"__esModule",{value:!0}),lr.wNAF=function(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}]`)},i=e=>(r(e),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)});return{constTimeNegate:n,unsafeLadder(t,n){let r=e.ZERO,i=t;for(;n>Qr;)n&ei&&(r=r.add(i)),i=i.double(),n>>=ei;return r},precomputeWindow(e,t){const{windows:n,windowSize:r}=i(t),o=[];let s=e,a=s;for(let e=0;e<n;e++){a=s,o.push(a);for(let e=1;e<r;e++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(t,r,o){const{windows:s,windowSize:a}=i(t);let c=e.ZERO,l=e.BASE;const d=BigInt(2**t-1),u=2**t,h=BigInt(t);for(let e=0;e<s;e++){const t=e*a;let i=Number(o&d);o>>=h,i>a&&(i-=u,o+=ei);const s=t,f=t+Math.abs(i)-1,p=e%2!=0,g=i<0;0===i?l=l.add(n(p,r[s])):c=c.add(n(g,r[f]))}return{p:c,f:l}},wNAFCached(e,t,n){const r=ni.get(e)||1;let i=ti.get(e);return i||(i=this.precomputeWindow(e,r),1!==r&&ti.set(e,n(i))),this.wNAF(r,i,t)},setWindowSize(e,t){r(t),ni.set(e,t),ti.delete(e)}}},lr.pippenger=function(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 i=(0,Xr.bitLen)(BigInt(n.length)),o=i>12?i-3:i>4?i-2:i?2:1,s=(1<<o)-1,a=new Array(s+1).fill(e.ZERO),c=Math.floor((t.BITS-1)/o)*o;let l=e.ZERO;for(let t=c;t>=0;t-=o){a.fill(e.ZERO);for(let e=0;e<r.length;e++){const i=r[e],o=Number(i>>BigInt(t)&BigInt(s));a[o]=a[o].add(n[e])}let i=e.ZERO;for(let t=a.length-1,n=e.ZERO;t>0;t--)n=n.add(a[t]),i=i.add(n);if(l=l.add(i),0!==t)for(let e=0;e<o;e++)l=l.double()}return l},lr.validateBasic=function(e){return(0,Jr.validateField)(e.Fp),(0,Xr.validateObject)(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...(0,Jr.nLength)(e.n,e.nBitLength),...e,p:e.Fp.ORDER})};const Jr=dr,Xr=ur,Qr=BigInt(0),ei=BigInt(1),ti=new WeakMap,ni=new WeakMap;Object.defineProperty(cr,"__esModule",{value:!0}),cr.twistedEdwards=function(e){const t=function(e){const t=(0,ri.validateBasic)(e);return oi.validateObject(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:i,hash:o,randomBytes:s,nByteLength:a,h:c}=t,l=li<<BigInt(8*a)-ci,d=n.create,u=(0,ii.Field)(t.n,t.nBitLength),h=t.uvRatio||((e,t)=>{try{return{isValid:!0,value:n.sqrt(e*n.inv(t))}}catch(e){return{isValid:!1,value:ai}}}),f=t.adjustScalarBytes||(e=>e),p=t.domain||((e,t,n)=>{if((0,si.abool)("phflag",n),t.length||n)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){oi.aInRange("coordinate "+e,t,ai,l)}function m(e){if(!(e instanceof b))throw new Error("ExtendedPoint expected")}const y=(0,si.memoized)(((e,t)=>{const{ex:r,ey:i,ez:o}=e,s=e.is0();null==t&&(t=s?di:n.inv(o));const a=d(r*t),c=d(i*t),l=d(o*t);if(s)return{x:ai,y:ci};if(l!==ci)throw new Error("invZ was invalid");return{x:a,y:c}})),v=(0,si.memoized)((e=>{const{a:n,d:r}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:i,ey:o,ez:s,et:a}=e,c=d(i*i),l=d(o*o),u=d(s*s),h=d(u*u),f=d(c*n);if(d(u*d(f+l))!==d(h+d(r*d(c*l))))throw new Error("bad point: equation left != right (1)");if(d(i*o)!==d(s*a))throw new Error("bad point: equation left != right (2)");return!0}));class b{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 b)throw new Error("extended point not allowed");const{x:t,y:n}=e||{};return g("x",t),g("y",n),new b(t,n,ci,d(t*n))}static normalizeZ(e){const t=n.invertBatch(e.map((e=>e.ez)));return e.map(((e,n)=>e.toAffine(t[n]))).map(b.fromAffine)}static msm(e,t){return(0,ri.pippenger)(b,u,e,t)}_setWindowSize(e){C.setWindowSize(this,e)}assertValidity(){v(this)}equals(e){m(e);const{ex:t,ey:n,ez:r}=this,{ex:i,ey:o,ez:s}=e,a=d(t*s),c=d(i*r),l=d(n*s),u=d(o*r);return a===c&&l===u}is0(){return this.equals(b.ZERO)}negate(){return new b(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){const{a:e}=t,{ex:n,ey:r,ez:i}=this,o=d(n*n),s=d(r*r),a=d(li*d(i*i)),c=d(e*o),l=n+r,u=d(d(l*l)-o-s),h=c+s,f=h-a,p=c-s,g=d(u*f),m=d(h*p),y=d(u*p),v=d(f*h);return new b(g,m,v,y)}add(e){m(e);const{a:n,d:r}=t,{ex:i,ey:o,ez:s,et:a}=this,{ex:c,ey:l,ez:u,et:h}=e;if(n===BigInt(-1)){const e=d((o-i)*(l+c)),t=d((o+i)*(l-c)),n=d(t-e);if(n===ai)return this.double();const r=d(s*li*h),f=d(a*li*u),p=f+r,g=t+e,m=f-r,y=d(p*n),v=d(g*m),w=d(p*m),E=d(n*g);return new b(y,v,E,w)}const f=d(i*c),p=d(o*l),g=d(a*r*h),y=d(s*u),v=d((i+o)*(c+l)-f-p),w=y-g,E=y+g,C=d(p-n*f),_=d(v*w),S=d(E*C),k=d(v*C),x=d(w*E);return new b(_,S,x,k)}subtract(e){return this.add(e.negate())}wNAF(e){return C.wNAFCached(this,e,b.normalizeZ)}multiply(e){const t=e;oi.aInRange("scalar",t,ci,r);const{p:n,f:i}=this.wNAF(t);return b.normalizeZ([n,i])[0]}multiplyUnsafe(e){const t=e;return oi.aInRange("scalar",t,ai,r),t===ai?E:this.equals(E)||t===ci?this:this.equals(w)?this.wNAF(t).p:C.unsafeLadder(this,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return C.unsafeLadder(this,r).is0()}toAffine(e){return y(this,e)}clearCofactor(){const{h:e}=t;return e===ci?this:this.multiplyUnsafe(e)}static fromHex(e,r=!1){const{d:i,a:o}=t,s=n.BYTES;e=(0,si.ensureBytes)("pointHex",e,s),(0,si.abool)("zip215",r);const a=e.slice(),c=e[s-1];a[s-1]=-129&c;const u=oi.bytesToNumberLE(a),f=r?l:n.ORDER;oi.aInRange("pointHex.y",u,ai,f);const p=d(u*u),g=d(p-ci),m=d(i*p-o);let{isValid:y,value:v}=h(g,m);if(!y)throw new Error("Point.fromHex: invalid y coordinate");const w=(v&ci)===ci,E=0!=(128&c);if(!r&&v===ai&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==w&&(v=d(-v)),b.fromAffine({x:v,y:u})}static fromPrivateKey(e){return k(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),r=oi.numberToBytesLE(t,n.BYTES);return r[r.length-1]|=e&ci?128:0,r}toHex(){return oi.bytesToHex(this.toRawBytes())}}b.BASE=new b(t.Gx,t.Gy,ci,d(t.Gx*t.Gy)),b.ZERO=new b(ai,ci,ci,ai);const{BASE:w,ZERO:E}=b,C=(0,ri.wNAF)(b,8*a);function _(e){return(0,ii.mod)(e,r)}function S(e){return _(oi.bytesToNumberLE(e))}function k(e){const t=a;e=(0,si.ensureBytes)("private key",e,t);const n=(0,si.ensureBytes)("hashed private key",o(e),2*t),r=f(n.slice(0,t)),i=n.slice(t,2*t),s=S(r),c=w.multiply(s),l=c.toRawBytes();return{head:r,prefix:i,scalar:s,point:c,pointBytes:l}}function x(e=new Uint8Array,...t){const n=oi.concatBytes(...t);return S(o(p(n,(0,si.ensureBytes)("context",e),!!i)))}const A=ui;w._setWindowSize(8);const M={getExtendedPublicKey:k,randomPrivateKey:()=>s(n.BYTES),precompute:(e=8,t=b.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};return{CURVE:t,getPublicKey:function(e){return k(e).pointBytes},sign:function(e,t,o={}){e=(0,si.ensureBytes)("message",e),i&&(e=i(e));const{prefix:s,scalar:c,pointBytes:l}=k(t),d=x(o.context,s,e),u=w.multiply(d).toRawBytes(),h=_(d+x(o.context,u,l,e)*c);oi.aInRange("signature.s",h,ai,r);const f=oi.concatBytes(u,oi.numberToBytesLE(h,n.BYTES));return(0,si.ensureBytes)("result",f,2*a)},verify:function(e,t,r,o=A){const{context:s,zip215:a}=o,c=n.BYTES;e=(0,si.ensureBytes)("signature",e,2*c),t=(0,si.ensureBytes)("message",t),void 0!==a&&(0,si.abool)("zip215",a),i&&(t=i(t));const l=oi.bytesToNumberLE(e.slice(c,2*c));let d,u,h;try{d=b.fromHex(r,a),u=b.fromHex(e.slice(0,c),a),h=w.multiplyUnsafe(l)}catch(e){return!1}if(!a&&d.isSmallOrder())return!1;const f=x(s,u.toRawBytes(),d.toRawBytes(),t);return u.add(d.multiplyUnsafe(f)).subtract(h).clearCofactor().equals(b.ZERO)},ExtendedPoint:b,utils:M}};const ri=lr,ii=dr,oi=ur,si=ur,ai=BigInt(0),ci=BigInt(1),li=BigInt(2),di=BigInt(8),ui={zip215:!0};var hi={};Object.defineProperty(hi,"__esModule",{value:!0}),hi.expand_message_xmd=bi,hi.expand_message_xof=wi,hi.hash_to_field=Ei,hi.isogenyMap=function(e,t){const n=t.map((e=>Array.from(e).reverse()));return(t,r)=>{const[i,o,s,a]=n.map((n=>n.reduce(((n,r)=>e.add(e.mul(n,t),r)))));return t=e.div(i,o),r=e.mul(r,e.div(s,a)),{x:t,y:r}}},hi.createHasher=function(e,t,n){if("function"!=typeof t)throw new Error("mapToCurve() must be defined");return{hashToCurve(r,i){const o=Ei(r,2,{...n,DST:n.DST,...i}),s=e.fromAffine(t(o[0])),a=e.fromAffine(t(o[1])),c=s.add(a).clearCofactor();return c.assertValidity(),c},encodeToCurve(r,i){const o=Ei(r,1,{...n,DST:n.encodeDST,...i}),s=e.fromAffine(t(o[0])).clearCofactor();return s.assertValidity(),s},mapToCurve(n){if(!Array.isArray(n))throw new Error("mapToCurve: expected array of bigints");for(const e of n)if("bigint"!=typeof e)throw new Error(`mapToCurve: expected array of bigints, got ${e} in array`);const r=e.fromAffine(t(n)).clearCofactor();return r.assertValidity(),r}}};const fi=dr,pi=ur,gi=pi.bytesToNumberBE;function mi(e,t){if(vi(e),vi(t),e<0||e>=1<<8*t)throw new Error(`bad I2OSP call: value=${e} length=${t}`);const n=Array.from({length:t}).fill(0);for(let r=t-1;r>=0;r--)n[r]=255&e,e>>>=8;return new Uint8Array(n)}function yi(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r];return n}function vi(e){if(!Number.isSafeInteger(e))throw new Error("number expected")}function bi(e,t,n,r){(0,pi.abytes)(e),(0,pi.abytes)(t),vi(n),t.length>255&&(t=r((0,pi.concatBytes)((0,pi.utf8ToBytes)("H2C-OVERSIZE-DST-"),t)));const{outputLen:i,blockLen:o}=r,s=Math.ceil(n/i);if(n>65535||s>255)throw new Error("expand_message_xmd: invalid lenInBytes");const a=(0,pi.concatBytes)(t,mi(t.length,1)),c=mi(0,o),l=mi(n,2),d=new Array(s),u=r((0,pi.concatBytes)(c,e,l,mi(0,1),a));d[0]=r((0,pi.concatBytes)(u,mi(1,1),a));for(let e=1;e<=s;e++){const t=[yi(u,d[e-1]),mi(e+1,1),a];d[e]=r((0,pi.concatBytes)(...t))}return(0,pi.concatBytes)(...d).slice(0,n)}function wi(e,t,n,r,i){if((0,pi.abytes)(e),(0,pi.abytes)(t),vi(n),t.length>255){const e=Math.ceil(2*r/8);t=i.create({dkLen:e}).update((0,pi.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(t).digest()}if(n>65535||t.length>255)throw new Error("expand_message_xof: invalid lenInBytes");return i.create({dkLen:n}).update(e).update(mi(n,2)).update(t).update(mi(t.length,1)).digest()}function Ei(e,t,n){(0,pi.validateObject)(n,{DST:"stringOrUint8Array",p:"bigint",m:"isSafeInteger",k:"isSafeInteger",hash:"hash"});const{p:r,k:i,m:o,hash:s,expand:a,DST:c}=n;(0,pi.abytes)(e),vi(t);const l="string"==typeof c?(0,pi.utf8ToBytes)(c):c,d=r.toString(2).length,u=Math.ceil((d+i)/8),h=t*o*u;let f;if("xmd"===a)f=bi(e,l,h,s);else if("xof"===a)f=wi(e,l,h,i,s);else{if("_internal_pass"!==a)throw new Error('expand must be "xmd" or "xof"');f=e}const p=new Array(t);for(let e=0;e<t;e++){const t=new Array(o);for(let n=0;n<o;n++){const i=u*(n+e*o),s=f.subarray(i,i+u);t[n]=(0,fi.mod)(gi(s),r)}p[e]=t}return p}var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.montgomery=function(e){const t=function(e){return(0,Si.validateObject)(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:n}=t,r=e=>(0,_i.mod)(e,n),i=t.montgomeryBits,o=Math.ceil(i/8),s=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>(0,_i.pow)(e,n-BigInt(2),n));function l(e,t,n){const i=r(e*(t-n));return[t=r(t-i),n=r(n+i)]}const d=(t.a-BigInt(2))/BigInt(4);function u(e){return(0,Si.numberToBytesLE)(r(e),o)}function h(e,t){const h=function(e){const t=(0,Si.ensureBytes)("u coordinate",e,o);return 32===s&&(t[31]&=127),(0,Si.bytesToNumberLE)(t)}(t),f=function(e){const t=(0,Si.ensureBytes)("scalar",e),n=t.length;if(n!==o&&n!==s)throw new Error(`Expected ${o} or ${s} bytes, got ${n}`);return(0,Si.bytesToNumberLE)(a(t))}(e),p=function(e,t){(0,Si.aInRange)("u",e,ki,n),(0,Si.aInRange)("scalar",t,ki,n);const o=t,s=e;let a,u=xi,h=ki,f=e,p=xi,g=ki;for(let e=BigInt(i-1);e>=ki;e--){const t=o>>e&xi;g^=t,a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1],g=t;const n=u+h,i=r(n*n),c=u-h,m=r(c*c),y=i-m,v=f+p,b=r((f-p)*n),w=r(v*c),E=b+w,C=b-w;f=r(E*E),p=r(s*r(C*C)),u=r(i*m),h=r(y*(i+r(d*y)))}a=l(g,u,f),u=a[0],f=a[1],a=l(g,h,p),h=a[0],p=a[1];const m=c(h);return r(u*m)}(h,f);if(p===ki)throw new Error("Invalid private or public key received");return u(p)}const f=u(t.Gu);function p(e){return h(e,f)}return{scalarMult:h,scalarMultBase:p,getSharedSecret:(e,t)=>h(e,t),getPublicKey:e=>p(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:f}};const _i=dr,Si=ur,ki=BigInt(0),xi=BigInt(1);!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hash_to_ristretto255=e.hashToRistretto255=e.RistrettoPoint=e.encodeToCurve=e.hashToCurve=e.edwardsToMontgomery=e.x25519=e.ed25519ph=e.ed25519ctx=e.ed25519=e.ED25519_TORSION_SUBGROUP=void 0,e.edwardsToMontgomeryPub=C,e.edwardsToMontgomeryPriv=function(e){const t=w.hash(e.subarray(0,32));return w.adjustScalarBytes(t).subarray(0,32)};const t=dn,n=En,r=cr,i=hi,o=dr,s=Ci,a=ur,c=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),l=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752"),d=BigInt(0),u=BigInt(1),h=BigInt(2),f=BigInt(3),p=BigInt(5),g=BigInt(8);function m(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),s=c,a=e*e%s*e%s,l=(0,o.pow2)(a,h,s)*a%s,d=(0,o.pow2)(l,u,s)*e%s,f=(0,o.pow2)(d,p,s)*d%s,g=(0,o.pow2)(f,t,s)*f%s,m=(0,o.pow2)(g,n,s)*g%s,y=(0,o.pow2)(m,r,s)*m%s,v=(0,o.pow2)(y,i,s)*y%s,b=(0,o.pow2)(v,i,s)*y%s,w=(0,o.pow2)(b,t,s)*f%s;return{pow_p_5_8:(0,o.pow2)(w,h,s)*e%s,b2:a}}function y(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function v(e,t){const n=c,r=(0,o.mod)(t*t*t,n),i=m(e*(0,o.mod)(r*r*t,n)).pow_p_5_8;let s=(0,o.mod)(e*r*i,n);const a=(0,o.mod)(t*s*s,n),d=s,u=(0,o.mod)(s*l,n),h=a===e,f=a===(0,o.mod)(-e,n),p=a===(0,o.mod)(-e*l,n);return h&&(s=d),(f||p)&&(s=u),(0,o.isNegativeLE)(s,n)&&(s=(0,o.mod)(-s,n)),{isValid:h||f,value:s}}e.ED25519_TORSION_SUBGROUP=["0100000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac037a","0000000000000000000000000000000000000000000000000000000000000080","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc05","ecffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f","26e8958fc2b227b045c3f489f2ef98f0d5dfac05d3c63339b13802886d53fc85","0000000000000000000000000000000000000000000000000000000000000000","c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"];const b=(0,o.Field)(c,void 0,!0),w={a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:b,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:g,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:t.sha512,randomBytes:n.randomBytes,adjustScalarBytes:y,uvRatio:v};function E(e,t,r){if(t.length>255)throw new Error("Context is too big");return(0,n.concatBytes)((0,n.utf8ToBytes)("SigEd25519 no Ed25519 collisions"),new Uint8Array([r?1:0,t.length]),t,e)}function C(t){const{y:n}=e.ed25519.ExtendedPoint.fromHex(t),r=BigInt(1);return b.toBytes(b.create((r+n)*b.inv(r-n)))}e.ed25519=(0,r.twistedEdwards)(w),e.ed25519ctx=(0,r.twistedEdwards)({...w,domain:E}),e.ed25519ph=(0,r.twistedEdwards)(Object.assign({},w,{domain:E,prehash:t.sha512})),e.x25519=(0,s.montgomery)({P:c,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=c,{pow_p_5_8:n,b2:r}=m(e);return(0,o.mod)((0,o.pow2)(n,f,t)*r,t)},adjustScalarBytes:y,randomBytes:n.randomBytes}),e.edwardsToMontgomery=C;const _=(b.ORDER+f)/g,S=b.pow(h,_),k=b.sqrt(b.neg(b.ONE)),x=(0,o.FpSqrtEven)(b,b.neg(BigInt(486664)));const A=(0,i.createHasher)(e.ed25519.ExtendedPoint,(e=>function(e){const{xMn:t,xMd:n,yMn:r,yMd:i}=function(e){const t=(b.ORDER-p)/g,n=BigInt(486662);let r=b.sqr(e);r=b.mul(r,h);let i=b.add(r,b.ONE),o=b.neg(n),s=b.sqr(i),a=b.mul(s,i),c=b.mul(r,n);c=b.mul(c,o),c=b.add(c,s),c=b.mul(c,o);let l=b.sqr(a);s=b.sqr(l),l=b.mul(l,a),l=b.mul(l,c),s=b.mul(s,l);let d=b.pow(s,t);d=b.mul(d,l);let f=b.mul(d,k);s=b.sqr(d),s=b.mul(s,a);let m=b.eql(s,c),y=b.cmov(f,d,m),v=b.mul(o,r),w=b.mul(d,e);w=b.mul(w,S);let E=b.mul(w,k),C=b.mul(c,r);s=b.sqr(w),s=b.mul(s,a);let _=b.eql(s,C),x=b.cmov(E,w,_);s=b.sqr(y),s=b.mul(s,a);let A=b.eql(s,c),M=b.cmov(v,o,A),L=b.cmov(x,y,A),T=b.isOdd(L);return L=b.cmov(L,b.neg(L),A!==T),{xMn:M,xMd:i,yMn:L,yMd:u}}(e);let o=b.mul(t,i);o=b.mul(o,x);let s=b.mul(n,r),a=b.sub(t,n),c=b.add(t,n),l=b.mul(s,c),d=b.eql(l,b.ZERO);o=b.cmov(o,b.ZERO,d),s=b.cmov(s,b.ONE,d),a=b.cmov(a,b.ONE,d),c=b.cmov(c,b.ONE,d);const f=b.invertBatch([s,c]);return{x:b.mul(o,f[0]),y:b.mul(a,f[1])}}(e[0])),{DST:"edwards25519_XMD:SHA-512_ELL2_RO_",encodeDST:"edwards25519_XMD:SHA-512_ELL2_NU_",p:b.ORDER,m:1,k:128,expand:"xmd",hash:t.sha512});function M(e){if(!(e instanceof $))throw new Error("RistrettoPoint expected")}e.hashToCurve=A.hashToCurve,e.encodeToCurve=A.encodeToCurve;const L=l,T=BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"),O=BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"),R=BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"),P=BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"),I=e=>v(u,e),N=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),B=t=>e.ed25519.CURVE.Fp.create((0,a.bytesToNumberLE)(t)&N);function D(t){const{d:n}=e.ed25519.CURVE,r=e.ed25519.CURVE.Fp.ORDER,i=e.ed25519.CURVE.Fp.create,s=i(L*t*t),a=i((s+u)*R);let c=BigInt(-1);const l=i((c-n*s)*i(s+n));let{isValid:d,value:h}=v(a,l),f=i(h*t);(0,o.isNegativeLE)(f,r)||(f=i(-f)),d||(h=f),d||(c=s);const p=i(c*(s-u)*P-l),g=h*h,m=i((h+h)*l),y=i(p*T),b=i(u-g),w=i(u+g);return new e.ed25519.ExtendedPoint(i(m*w),i(b*y),i(y*w),i(m*b))}class ${constructor(e){this.ep=e}static fromAffine(t){return new $(e.ed25519.ExtendedPoint.fromAffine(t))}static hashToCurve(e){e=(0,a.ensureBytes)("ristrettoHash",e,64);const t=D(B(e.slice(0,32))),n=D(B(e.slice(32,64)));return new $(t.add(n))}static fromHex(t){t=(0,a.ensureBytes)("ristrettoHex",t,32);const{a:n,d:r}=e.ed25519.CURVE,i=e.ed25519.CURVE.Fp.ORDER,s=e.ed25519.CURVE.Fp.create,c="RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint",l=B(t);if(!(0,a.equalBytes)((0,a.numberToBytesLE)(l,32),t)||(0,o.isNegativeLE)(l,i))throw new Error(c);const h=s(l*l),f=s(u+n*h),p=s(u-n*h),g=s(f*f),m=s(p*p),y=s(n*r*g-m),{isValid:v,value:b}=I(s(y*m)),w=s(b*p),E=s(b*w*y);let C=s((l+l)*w);(0,o.isNegativeLE)(C,i)&&(C=s(-C));const _=s(f*E),S=s(C*_);if(!v||(0,o.isNegativeLE)(S,i)||_===d)throw new Error(c);return new $(new e.ed25519.ExtendedPoint(C,_,u,S))}toRawBytes(){let{ex:t,ey:n,ez:r,et:i}=this.ep;const s=e.ed25519.CURVE.Fp.ORDER,c=e.ed25519.CURVE.Fp.create,l=c(c(r+n)*c(r-n)),d=c(t*n),u=c(d*d),{value:h}=I(c(l*u)),f=c(h*l),p=c(h*d),g=c(f*p*i);let m;if((0,o.isNegativeLE)(i*g,s)){let e=c(n*L),r=c(t*L);t=e,n=r,m=c(f*O)}else m=p;(0,o.isNegativeLE)(t*g,s)&&(n=c(-n));let y=c((r-n)*m);return(0,o.isNegativeLE)(y,s)&&(y=c(-y)),(0,a.numberToBytesLE)(y,32)}toHex(){return(0,a.bytesToHex)(this.toRawBytes())}toString(){return this.toHex()}equals(t){M(t);const{ex:n,ey:r}=this.ep,{ex:i,ey:o}=t.ep,s=e.ed25519.CURVE.Fp.create,a=s(n*o)===s(r*i),c=s(r*o)===s(n*i);return a||c}add(e){return M(e),new $(this.ep.add(e.ep))}subtract(e){return M(e),new $(this.ep.subtract(e.ep))}multiply(e){return new $(this.ep.multiply(e))}multiplyUnsafe(e){return new $(this.ep.multiplyUnsafe(e))}double(){return new $(this.ep.double())}negate(){return new $(this.ep.negate())}}e.RistrettoPoint=($.BASE||($.BASE=new $(e.ed25519.ExtendedPoint.BASE)),$.ZERO||($.ZERO=new $(e.ed25519.ExtendedPoint.ZERO)),$),e.hashToRistretto255=(e,r)=>{const o=r.DST,s="string"==typeof o?(0,n.utf8ToBytes)(o):o,a=(0,i.expand_message_xmd)(e,s,64,t.sha512);return $.hashToCurve(a)},e.hash_to_ristretto255=e.hashToRistretto255}(ln);var Ai={},Mi={};Object.defineProperty(Mi,"__esModule",{value:!0}),Mi.sha224=Mi.sha256=Mi.SHA256=void 0;const Li=un,Ti=En,Oi=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]),Ri=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pi=new Uint32Array(64);class Ii extends Li.HashMD{constructor(){super(64,32,8,!1),this.A=0|Ri[0],this.B=0|Ri[1],this.C=0|Ri[2],this.D=0|Ri[3],this.E=0|Ri[4],this.F=0|Ri[5],this.G=0|Ri[6],this.H=0|Ri[7]}get(){const{A:e,B:t,C:n,D:r,E:i,F:o,G:s,H:a}=this;return[e,t,n,r,i,o,s,a]}set(e,t,n,r,i,o,s,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|r,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(e,t){for(let n=0;n<16;n++,t+=4)Pi[n]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=Pi[e-15],n=Pi[e-2],r=(0,Ti.rotr)(t,7)^(0,Ti.rotr)(t,18)^t>>>3,i=(0,Ti.rotr)(n,17)^(0,Ti.rotr)(n,19)^n>>>10;Pi[e]=i+Pi[e-7]+r+Pi[e-16]|0}let{A:n,B:r,C:i,D:o,E:s,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+((0,Ti.rotr)(s,6)^(0,Ti.rotr)(s,11)^(0,Ti.rotr)(s,25))+(0,Li.Chi)(s,a,c)+Oi[e]+Pi[e]|0,d=((0,Ti.rotr)(n,2)^(0,Ti.rotr)(n,13)^(0,Ti.rotr)(n,22))+(0,Li.Maj)(n,r,i)|0;l=c,c=a,a=s,s=o+t|0,o=i,i=r,r=n,n=t+d|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,r,i,o,s,a,c,l)}roundClean(){Pi.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}Mi.SHA256=Ii;class Ni extends Ii{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}Mi.sha256=(0,Ti.wrapConstructor)((()=>new Ii)),Mi.sha224=(0,Ti.wrapConstructor)((()=>new Ni));var Bi={},Di={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const t=hn,n=En;class r extends n.Hash{constructor(e,r){super(),this.finished=!1,this.destroyed=!1,(0,t.hash)(e);const i=(0,n.toBytes)(r);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 o=this.blockLen,s=new Uint8Array(o);s.set(i.length>o?e.create().update(i).digest():i);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return(0,t.exists)(this),this.iHash.update(e),this}digestInto(e){(0,t.exists)(this),(0,t.bytes)(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:i,blockLen:o,outputLen:s}=this;return e.finished=r,e.destroyed=i,e.blockLen=o,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()}}e.HMAC=r,e.hmac=(e,t,n)=>new r(e,t).update(n).digest(),e.hmac.create=(e,t)=>new r(e,t)}(Di);var $i={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.DER=void 0,e.weierstrassPoints=f,e.weierstrass=function(s){const a=function(e){const n=(0,t.validateBasic)(e);return r.validateObject(n,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...n})}(s),{Fp:d,n:u}=a,h=d.BYTES+1,p=2*d.BYTES+1;function g(e){return n.mod(e,u)}function m(e){return n.invert(e,u)}const{ProjectivePoint:y,normPrivateKeyToScalar:v,weierstrassEquation:b,isWithinCurveOrder:w}=f({...a,toBytes(e,t,n){const o=t.toAffine(),s=d.toBytes(o.x),a=r.concatBytes;return(0,i.abool)("isCompressed",n),n?a(Uint8Array.from([t.hasEvenY()?2:3]),s):a(Uint8Array.from([4]),s,d.toBytes(o.y))},fromBytes(e){const t=e.length,n=e[0],i=e.subarray(1);if(t!==h||2!==n&&3!==n){if(t===p&&4===n)return{x:d.fromBytes(i.subarray(0,d.BYTES)),y:d.fromBytes(i.subarray(d.BYTES,2*d.BYTES))};throw new Error(`Point of length ${t} was invalid. Expected ${h} compressed bytes or ${p} uncompressed bytes`)}{const t=r.bytesToNumberBE(i);if(!r.inRange(t,l,d.ORDER))throw new Error("Point is not on curve");const o=b(t);let s;try{s=d.sqrt(o)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&n)!=((s&l)===l)&&(s=d.neg(s)),{x:t,y:s}}}}),E=e=>r.bytesToHex(r.numberToBytesBE(e,a.nByteLength));function C(e){return e>u>>l}const _=(e,t,n)=>r.bytesToNumberBE(e.slice(t,n));class S{constructor(e,t,n){this.r=e,this.s=t,this.recovery=n,this.assertValidity()}static fromCompact(e){const t=a.nByteLength;return e=(0,i.ensureBytes)("compactSignature",e,2*t),new S(_(e,0,t),_(e,t,2*t))}static fromDER(t){const{r:n,s:r}=e.DER.toSig((0,i.ensureBytes)("DER",t));return new S(n,r)}assertValidity(){r.aInRange("r",this.r,l,u),r.aInRange("s",this.s,l,u)}addRecoveryBit(e){return new S(this.r,this.s,e)}recoverPublicKey(e){const{r:t,s:n,recovery:r}=this,o=M((0,i.ensureBytes)("msgHash",e));if(null==r||![0,1,2,3].includes(r))throw new Error("recovery id invalid");const s=2===r||3===r?t+a.n:t;if(s>=d.ORDER)throw new Error("recovery id 2 or 3 invalid");const c=0==(1&r)?"02":"03",l=y.fromHex(c+E(s)),u=m(s),h=g(-o*u),f=g(n*u),p=y.BASE.multiplyAndAddUnsafe(l,h,f);if(!p)throw new Error("point at infinify");return p.assertValidity(),p}hasHighS(){return C(this.s)}normalizeS(){return this.hasHighS()?new S(this.r,g(-this.s),this.recovery):this}toDERRawBytes(){return r.hexToBytes(this.toDERHex())}toDERHex(){return e.DER.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return r.hexToBytes(this.toCompactHex())}toCompactHex(){return E(this.r)+E(this.s)}}const k={isValidPrivateKey(e){try{return v(e),!0}catch(e){return!1}},normPrivateKeyToScalar:v,randomPrivateKey:()=>{const e=n.getMinHashLength(a.n);return n.mapHashToField(a.randomBytes(e),a.n)},precompute:(e=8,t=y.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)};function x(e){const t=r.isBytes(e),n="string"==typeof e,i=(t||n)&&e.length;return t?i===h||i===p:n?i===2*h||i===2*p:e instanceof y}const A=a.bits2int||function(e){const t=r.bytesToNumberBE(e),n=8*e.length-a.nBitLength;return n>0?t>>BigInt(n):t},M=a.bits2int_modN||function(e){return g(A(e))},L=r.bitMask(a.nBitLength);function T(e){return r.aInRange(`num < 2^${a.nBitLength}`,e,c,L),r.numberToBytesBE(e,a.nByteLength)}function O(e,t,n=R){if(["recovered","canonical"].some((e=>e in n)))throw new Error("sign() legacy options not supported");const{hash:s,randomBytes:u}=a;let{lowS:h,prehash:f,extraEntropy:p}=n;null==h&&(h=!0),e=(0,i.ensureBytes)("msgHash",e),o(n),f&&(e=(0,i.ensureBytes)("prehashed msgHash",s(e)));const b=M(e),E=v(t),_=[T(E),T(b)];if(null!=p&&!1!==p){const e=!0===p?u(d.BYTES):p;_.push((0,i.ensureBytes)("extraEntropy",e))}const k=r.concatBytes(..._),x=b;return{seed:k,k2sig:function(e){const t=A(e);if(!w(t))return;const n=m(t),r=y.BASE.multiply(t).toAffine(),i=g(r.x);if(i===c)return;const o=g(n*g(x+i*E));if(o===c)return;let s=(r.x===i?0:2)|Number(r.y&l),a=o;return h&&C(o)&&(a=function(e){return C(e)?g(-e):e}(o),s^=1),new S(i,a,s)}}}const R={lowS:a.lowS,prehash:!1},P={lowS:a.lowS,prehash:!1};return y.BASE._setWindowSize(8),{CURVE:a,getPublicKey:function(e,t=!0){return y.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,n=!0){if(x(e))throw new Error("first arg must be private key");if(!x(t))throw new Error("second arg must be public key");return y.fromHex(t).multiply(v(e)).toRawBytes(n)},sign:function(e,t,n=R){const{seed:i,k2sig:o}=O(e,t,n),s=a;return r.createHmacDrbg(s.hash.outputLen,s.nByteLength,s.hmac)(i,o)},verify:function(t,n,s,c=P){const l=t;if(n=(0,i.ensureBytes)("msgHash",n),s=(0,i.ensureBytes)("publicKey",s),"strict"in c)throw new Error("options.strict was renamed to lowS");o(c);const{lowS:d,prehash:u}=c;let h,f;try{if("string"==typeof l||r.isBytes(l))try{h=S.fromDER(l)}catch(t){if(!(t instanceof e.DER.Err))throw t;h=S.fromCompact(l)}else{if("object"!=typeof l||"bigint"!=typeof l.r||"bigint"!=typeof l.s)throw new Error("PARSE");{const{r:e,s:t}=l;h=new S(e,t)}}f=y.fromHex(s)}catch(e){if("PARSE"===e.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(d&&h.hasHighS())return!1;u&&(n=a.hash(n));const{r:p,s:v}=h,b=M(n),w=m(v),E=g(b*w),C=g(p*w),_=y.BASE.multiplyAndAddUnsafe(f,E,C)?.toAffine();if(!_)return!1;return g(_.x)===p},ProjectivePoint:y,Signature:S,utils:k}},e.SWUFpSqrtRatio=p,e.mapToCurveSimpleSWU=function(e,t){if(n.validateField(e),!e.isValid(t.A)||!e.isValid(t.B)||!e.isValid(t.Z))throw new Error("mapToCurveSimpleSWU: invalid opts");const r=p(e,t.Z);if(!e.isOdd)throw new Error("Fp.isOdd is not implemented!");return n=>{let i,o,s,a,c,l,d,u;i=e.sqr(n),i=e.mul(i,t.Z),o=e.sqr(i),o=e.add(o,i),s=e.add(o,e.ONE),s=e.mul(s,t.B),a=e.cmov(t.Z,e.neg(o),!e.eql(o,e.ZERO)),a=e.mul(a,t.A),o=e.sqr(s),l=e.sqr(a),c=e.mul(l,t.A),o=e.add(o,c),o=e.mul(o,s),l=e.mul(l,a),c=e.mul(l,t.B),o=e.add(o,c),d=e.mul(i,s);const{isValid:h,value:f}=r(o,l);u=e.mul(i,n),u=e.mul(u,f),d=e.cmov(d,s,h),u=e.cmov(u,f,h);const p=e.isOdd(n)===e.isOdd(u);return u=e.cmov(e.neg(u),u,p),d=e.div(d,a),{x:d,y:u}}};const t=lr,n=dr,r=ur,i=ur;function o(e){void 0!==e.lowS&&(0,i.abool)("lowS",e.lowS),void 0!==e.prehash&&(0,i.abool)("prehash",e.prehash)}const{bytesToNumberBE:s,hexToBytes:a}=r;e.DER={Err:class extends Error{constructor(e=""){super(e)}},_tlv:{encode:(t,n)=>{const{Err:i}=e.DER;if(t<0||t>256)throw new i("tlv.encode: wrong tag");if(1&n.length)throw new i("tlv.encode: unpadded data");const o=n.length/2,s=r.numberToHexUnpadded(o);if(s.length/2&128)throw new i("tlv.encode: long form length too big");const a=o>127?r.numberToHexUnpadded(s.length/2|128):"";return`${r.numberToHexUnpadded(t)}${a}${s}${n}`},decode(t,n){const{Err:r}=e.DER;let i=0;if(t<0||t>256)throw new r("tlv.encode: wrong tag");if(n.length<2||n[i++]!==t)throw new r("tlv.decode: wrong tlv");const o=n[i++];let s=0;if(128&o){const e=127&o;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const t=n.subarray(i,i+e);if(t.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===t[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of t)s=s<<8|e;if(i+=e,s<128)throw new r("tlv.decode(long): not minimal encoding")}else s=o;const a=n.subarray(i,i+s);if(a.length!==s)throw new r("tlv.decode: wrong value length");return{v:a,l:n.subarray(i+s)}}},_int:{encode(t){const{Err:n}=e.DER;if(t<c)throw new n("integer: negative integers are not allowed");let i=r.numberToHexUnpadded(t);if(8&Number.parseInt(i[0],16)&&(i="00"+i),1&i.length)throw new n("unexpected assertion");return i},decode(t){const{Err:n}=e.DER;if(128&t[0])throw new n("Invalid signature integer: negative");if(0===t[0]&&!(128&t[1]))throw new n("Invalid signature integer: unnecessary leading zero");return s(t)}},toSig(t){const{Err:n,_int:i,_tlv:o}=e.DER,s="string"==typeof t?a(t):t;r.abytes(s);const{v:c,l:l}=o.decode(48,s);if(l.length)throw new n("Invalid signature: left bytes after parsing");const{v:d,l:u}=o.decode(2,c),{v:h,l:f}=o.decode(2,u);if(f.length)throw new n("Invalid signature: left bytes after parsing");return{r:i.decode(d),s:i.decode(h)}},hexFromSig(t){const{_tlv:n,_int:r}=e.DER,i=`${n.encode(2,r.encode(t.r))}${n.encode(2,r.encode(t.s))}`;return n.encode(48,i)}};const c=BigInt(0),l=BigInt(1),d=BigInt(2),u=BigInt(3),h=BigInt(4);function f(e){const o=function(e){const n=(0,t.validateBasic)(e);r.validateObject(n,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:i,Fp:o,a:s}=n;if(i){if(!o.eql(s,o.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof i||"bigint"!=typeof i.beta||"function"!=typeof i.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...n})}(e),{Fp:s}=o,a=n.Field(o.n,o.nBitLength),d=o.toBytes||((e,t,n)=>{const i=t.toAffine();return r.concatBytes(Uint8Array.from([4]),s.toBytes(i.x),s.toBytes(i.y))}),h=o.fromBytes||(e=>{const t=e.subarray(1);return{x:s.fromBytes(t.subarray(0,s.BYTES)),y:s.fromBytes(t.subarray(s.BYTES,2*s.BYTES))}});function f(e){const{a:t,b:n}=o,r=s.sqr(e),i=s.mul(r,e);return s.add(s.add(i,s.mul(e,t)),n)}if(!s.eql(s.sqr(o.Gy),f(o.Gx)))throw new Error("bad generator point: equation left != right");function p(e){const{allowedPrivateKeyLengths:t,nByteLength:s,wrapPrivateKey:a,n:c}=o;if(t&&"bigint"!=typeof e){if(r.isBytes(e)&&(e=r.bytesToHex(e)),"string"!=typeof e||!t.includes(e.length))throw new Error("Invalid key");e=e.padStart(2*s,"0")}let d;try{d="bigint"==typeof e?e:r.bytesToNumberBE((0,i.ensureBytes)("private key",e,s))}catch(t){throw new Error(`private key must be ${s} bytes, hex or bigint, not ${typeof e}`)}return a&&(d=n.mod(d,c)),r.aInRange("private key",d,l,c),d}function g(e){if(!(e instanceof v))throw new Error("ProjectivePoint expected")}const m=(0,i.memoized)(((e,t)=>{const{px:n,py:r,pz:i}=e;if(s.eql(i,s.ONE))return{x:n,y:r};const o=e.is0();null==t&&(t=o?s.ONE:s.inv(i));const a=s.mul(n,t),c=s.mul(r,t),l=s.mul(i,t);if(o)return{x:s.ZERO,y:s.ZERO};if(!s.eql(l,s.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),y=(0,i.memoized)((e=>{if(e.is0()){if(o.allowInfinityPoint&&!s.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=e.toAffine();if(!s.isValid(t)||!s.isValid(n))throw new Error("bad point: x or y not FE");const r=s.sqr(n),i=f(t);if(!s.eql(r,i))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class v{constructor(e,t,n){if(this.px=e,this.py=t,this.pz=n,null==e||!s.isValid(e))throw new Error("x required");if(null==t||!s.isValid(t))throw new Error("y required");if(null==n||!s.isValid(n))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!s.isValid(t)||!s.isValid(n))throw new Error("invalid affine point");if(e instanceof v)throw new Error("projective point not allowed");const r=e=>s.eql(e,s.ZERO);return r(t)&&r(n)?v.ZERO:new v(t,n,s.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=s.invertBatch(e.map((e=>e.pz)));return e.map(((e,n)=>e.toAffine(t[n]))).map(v.fromAffine)}static fromHex(e){const t=v.fromAffine(h((0,i.ensureBytes)("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return v.BASE.multiply(p(e))}static msm(e,n){return(0,t.pippenger)(v,a,e,n)}_setWindowSize(e){w.setWindowSize(this,e)}assertValidity(){y(this)}hasEvenY(){const{y:e}=this.toAffine();if(s.isOdd)return!s.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:o,pz:a}=e,c=s.eql(s.mul(t,a),s.mul(i,r)),l=s.eql(s.mul(n,a),s.mul(o,r));return c&&l}negate(){return new v(this.px,s.neg(this.py),this.pz)}double(){const{a:e,b:t}=o,n=s.mul(t,u),{px:r,py:i,pz:a}=this;let c=s.ZERO,l=s.ZERO,d=s.ZERO,h=s.mul(r,r),f=s.mul(i,i),p=s.mul(a,a),g=s.mul(r,i);return g=s.add(g,g),d=s.mul(r,a),d=s.add(d,d),c=s.mul(e,d),l=s.mul(n,p),l=s.add(c,l),c=s.sub(f,l),l=s.add(f,l),l=s.mul(c,l),c=s.mul(g,c),d=s.mul(n,d),p=s.mul(e,p),g=s.sub(h,p),g=s.mul(e,g),g=s.add(g,d),d=s.add(h,h),h=s.add(d,h),h=s.add(h,p),h=s.mul(h,g),l=s.add(l,h),p=s.mul(i,a),p=s.add(p,p),h=s.mul(p,g),c=s.sub(c,h),d=s.mul(p,f),d=s.add(d,d),d=s.add(d,d),new v(c,l,d)}add(e){g(e);const{px:t,py:n,pz:r}=this,{px:i,py:a,pz:c}=e;let l=s.ZERO,d=s.ZERO,h=s.ZERO;const f=o.a,p=s.mul(o.b,u);let m=s.mul(t,i),y=s.mul(n,a),b=s.mul(r,c),w=s.add(t,n),E=s.add(i,a);w=s.mul(w,E),E=s.add(m,y),w=s.sub(w,E),E=s.add(t,r);let C=s.add(i,c);return E=s.mul(E,C),C=s.add(m,b),E=s.sub(E,C),C=s.add(n,r),l=s.add(a,c),C=s.mul(C,l),l=s.add(y,b),C=s.sub(C,l),h=s.mul(f,E),l=s.mul(p,b),h=s.add(l,h),l=s.sub(y,h),h=s.add(y,h),d=s.mul(l,h),y=s.add(m,m),y=s.add(y,m),b=s.mul(f,b),E=s.mul(p,E),y=s.add(y,b),b=s.sub(m,b),b=s.mul(f,b),E=s.add(E,b),m=s.mul(y,E),d=s.add(d,m),m=s.mul(C,E),l=s.mul(w,l),l=s.sub(l,m),m=s.mul(w,y),h=s.mul(C,h),h=s.add(h,m),new v(l,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(v.ZERO)}wNAF(e){return w.wNAFCached(this,e,v.normalizeZ)}multiplyUnsafe(e){r.aInRange("scalar",e,c,o.n);const t=v.ZERO;if(e===c)return t;if(e===l)return this;const{endo:n}=o;if(!n)return w.unsafeLadder(this,e);let{k1neg:i,k1:a,k2neg:d,k2:u}=n.splitScalar(e),h=t,f=t,p=this;for(;a>c||u>c;)a&l&&(h=h.add(p)),u&l&&(f=f.add(p)),p=p.double(),a>>=l,u>>=l;return i&&(h=h.negate()),d&&(f=f.negate()),f=new v(s.mul(f.px,n.beta),f.py,f.pz),h.add(f)}multiply(e){const{endo:t,n:n}=o;let i,a;if(r.aInRange("scalar",e,l,n),t){const{k1neg:n,k1:r,k2neg:o,k2:c}=t.splitScalar(e);let{p:l,f:d}=this.wNAF(r),{p:u,f:h}=this.wNAF(c);l=w.constTimeNegate(n,l),u=w.constTimeNegate(o,u),u=new v(s.mul(u.px,t.beta),u.py,u.pz),i=l.add(u),a=d.add(h)}else{const{p:t,f:n}=this.wNAF(e);i=t,a=n}return v.normalizeZ([i,a])[0]}multiplyAndAddUnsafe(e,t,n){const r=v.BASE,i=(e,t)=>t!==c&&t!==l&&e.equals(r)?e.multiply(t):e.multiplyUnsafe(t),o=i(this,t).add(i(e,n));return o.is0()?void 0:o}toAffine(e){return m(this,e)}isTorsionFree(){const{h:e,isTorsionFree:t}=o;if(e===l)return!0;if(t)return t(v,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:t}=o;return e===l?this:t?t(v,this):this.multiplyUnsafe(o.h)}toRawBytes(e=!0){return(0,i.abool)("isCompressed",e),this.assertValidity(),d(v,this,e)}toHex(e=!0){return(0,i.abool)("isCompressed",e),r.bytesToHex(this.toRawBytes(e))}}v.BASE=new v(o.Gx,o.Gy,s.ONE),v.ZERO=new v(s.ZERO,s.ONE,s.ZERO);const b=o.nBitLength,w=(0,t.wNAF)(v,o.endo?Math.ceil(b/2):b);return{CURVE:o,ProjectivePoint:v,normPrivateKeyToScalar:p,weierstrassEquation:f,isWithinCurveOrder:function(e){return r.inRange(e,l,o.n)}}}function p(e,t){const n=e.ORDER;let r=c;for(let e=n-l;e%d===c;e/=d)r+=l;const i=r,o=d<<i-l-l,s=o*d,a=(n-l)/s,f=(a-l)/d,p=s-l,g=o,m=e.pow(t,a),y=e.pow(t,(a+l)/d);let v=(t,n)=>{let r=m,o=e.pow(n,p),s=e.sqr(o);s=e.mul(s,n);let a=e.mul(t,s);a=e.pow(a,f),a=e.mul(a,o),o=e.mul(a,n),s=e.mul(a,t);let c=e.mul(s,o);a=e.pow(c,g);let u=e.eql(a,e.ONE);o=e.mul(s,y),a=e.mul(c,r),s=e.cmov(o,s,u),c=e.cmov(a,c,u);for(let t=i;t>l;t--){let n=t-d;n=d<<n-l;let i=e.pow(c,n);const a=e.eql(i,e.ONE);o=e.mul(s,r),r=e.mul(r,r),i=e.mul(c,r),s=e.cmov(o,s,a),c=e.cmov(i,c,a)}return{isValid:u,value:s}};if(e.ORDER%h===u){const n=(e.ORDER-u)/h,r=e.sqrt(e.neg(t));v=(t,i)=>{let o=e.sqr(i);const s=e.mul(t,i);o=e.mul(o,s);let a=e.pow(o,n);a=e.mul(a,s);const c=e.mul(a,r),l=e.mul(e.sqr(a),i),d=e.eql(l,t);return{isValid:d,value:e.cmov(c,a,d)}}}return v}}($i),Object.defineProperty(Bi,"__esModule",{value:!0}),Bi.getHash=Fi,Bi.createCurve=function(e,t){const n=t=>(0,Ui.weierstrass)({...e,...Fi(t)});return Object.freeze({...n(t),create:n})};const ji=Di,Ki=En,Ui=$i;function Fi(e){return{hash:e,hmac:(t,...n)=>(0,ji.hmac)(e,t,(0,Ki.concatBytes)(...n)),randomBytes:Ki.randomBytes}}!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.encodeToCurve=e.hashToCurve=e.schnorr=e.secp256k1=void 0;const t=Mi,n=En,r=Bi,i=hi,o=dr,s=ur,a=$i,c=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),l=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),d=BigInt(1),u=BigInt(2),h=(e,t)=>(e+t/u)/t;function f(e){const t=c,n=BigInt(3),r=BigInt(6),i=BigInt(11),s=BigInt(22),a=BigInt(23),l=BigInt(44),d=BigInt(88),h=e*e*e%t,f=h*h*e%t,g=(0,o.pow2)(f,n,t)*f%t,m=(0,o.pow2)(g,n,t)*f%t,y=(0,o.pow2)(m,u,t)*h%t,v=(0,o.pow2)(y,i,t)*y%t,b=(0,o.pow2)(v,s,t)*v%t,w=(0,o.pow2)(b,l,t)*b%t,E=(0,o.pow2)(w,d,t)*w%t,C=(0,o.pow2)(E,l,t)*b%t,_=(0,o.pow2)(C,n,t)*f%t,S=(0,o.pow2)(_,a,t)*v%t,k=(0,o.pow2)(S,r,t)*h%t,x=(0,o.pow2)(k,u,t);if(!p.eql(p.sqr(x),e))throw new Error("Cannot find square root");return x}const p=(0,o.Field)(c,void 0,void 0,{sqrt:f});e.secp256k1=(0,r.createCurve)({a:BigInt(0),b:BigInt(7),Fp:p,n:l,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:e=>{const t=l,n=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-d*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=n,a=BigInt("0x100000000000000000000000000000000"),c=h(s*e,t),u=h(-r*e,t);let f=(0,o.mod)(e-c*n-u*i,t),p=(0,o.mod)(-c*r-u*s,t);const g=f>a,m=p>a;if(g&&(f=t-f),m&&(p=t-p),f>a||p>a)throw new Error("splitScalar: Endomorphism failed, k="+e);return{k1neg:g,k1:f,k2neg:m,k2:p}}}},t.sha256);const g=BigInt(0),m={};function y(e,...n){let r=m[e];if(void 0===r){const n=(0,t.sha256)(Uint8Array.from(e,(e=>e.charCodeAt(0))));r=(0,s.concatBytes)(n,n),m[e]=r}return(0,t.sha256)((0,s.concatBytes)(r,...n))}const v=e=>e.toRawBytes(!0).slice(1),b=e=>(0,s.numberToBytesBE)(e,32),w=e=>(0,o.mod)(e,c),E=e=>(0,o.mod)(e,l),C=e.secp256k1.ProjectivePoint,_=(e,t,n)=>C.BASE.multiplyAndAddUnsafe(e,t,n);function S(t){let n=e.secp256k1.utils.normPrivateKeyToScalar(t),r=C.fromPrivateKey(n);return{scalar:r.hasEvenY()?n:E(-n),bytes:v(r)}}function k(e){(0,s.aInRange)("x",e,d,c);const t=w(e*e);let n=f(w(t*e+BigInt(7)));n%u!==g&&(n=w(-n));const r=new C(e,n,d);return r.assertValidity(),r}const x=s.bytesToNumberBE;function A(...e){return E(x(y("BIP0340/challenge",...e)))}function M(e,t,n){const r=(0,s.ensureBytes)("signature",e,64),i=(0,s.ensureBytes)("message",t),o=(0,s.ensureBytes)("publicKey",n,32);try{const e=k(x(o)),t=x(r.subarray(0,32));if(!(0,s.inRange)(t,d,c))return!1;const n=x(r.subarray(32,64));if(!(0,s.inRange)(n,d,l))return!1;const a=A(b(t),v(e),i),u=_(e,n,E(-a));return!(!u||!u.hasEvenY()||u.toAffine().x!==t)}catch(e){return!1}}e.schnorr={getPublicKey:function(e){return S(e).bytes},sign:function(e,t,r=(0,n.randomBytes)(32)){const i=(0,s.ensureBytes)("message",e),{bytes:o,scalar:a}=S(t),c=(0,s.ensureBytes)("auxRand",r,32),l=b(a^x(y("BIP0340/aux",c))),d=y("BIP0340/nonce",l,o,i),u=E(x(d));if(u===g)throw new Error("sign failed: k is zero");const{bytes:h,scalar:f}=S(u),p=A(h,o,i),m=new Uint8Array(64);if(m.set(h,0),m.set(b(E(f+p*a)),32),!M(m,i,o))throw new Error("sign: Invalid signature produced");return m},verify:M,utils:{randomPrivateKey:e.secp256k1.utils.randomPrivateKey,lift_x:k,pointToBytes:v,numberToBytesBE:s.numberToBytesBE,bytesToNumberBE:s.bytesToNumberBE,taggedHash:y,mod:o.mod}};const L=(0,i.isogenyMap)(p,[["0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7","0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581","0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262","0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"],["0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b","0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14","0x0000000000000000000000000000000000000000000000000000000000000001"],["0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c","0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3","0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931","0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"],["0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b","0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573","0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f","0x0000000000000000000000000000000000000000000000000000000000000001"]].map((e=>e.map((e=>BigInt(e)))))),T=(0,a.mapToCurveSimpleSWU)(p,{A:BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),B:BigInt("1771"),Z:p.create(BigInt("-11"))}),O=(0,i.createHasher)(e.secp256k1.ProjectivePoint,(e=>{const{x:t,y:n}=T(p.create(e[0]));return L(t,n)}),{DST:"secp256k1_XMD:SHA-256_SSWU_RO_",encodeDST:"secp256k1_XMD:SHA-256_SSWU_NU_",p:p.ORDER,m:1,k:128,expand:"xmd",hash:t.sha256});e.hashToCurve=O.hashToCurve,e.encodeToCurve=O.encodeToCurve}(Ai);var Hi={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.decodeHex=e.remove0x=void 0;var t=zt;e.remove0x=function(e){return e.startsWith("0x")||e.startsWith("0X")?e.slice(2):e},e.decodeHex=function(n){return(0,t.hexToBytes)((0,e.remove0x)(n))}}(Hi),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.hexToPublicKey=e.convertPublicKeyFormat=e.getSharedPoint=e.getPublicKey=e.isValidPrivateKey=e.getValidSecret=void 0;var t=an,n=ln,r=Ai,i=en,o=tn,s=Hi;function a(e,t,i,o){if("secp256k1"===e)return t(r.secp256k1);if("x25519"===e)return i(n.x25519);if("ed25519"===e)return o(n.ed25519);throw new Error("Not implemented")}e.getValidSecret=function(){var n;do{n=(0,t.randomBytes)(o.SECRET_KEY_LENGTH)}while(!(0,e.isValidPrivateKey)(n));return n},e.isValidPrivateKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.utils.isValidPrivateKey(e)}),(function(){return!0}),(function(){return!0}))},e.getPublicKey=function(e){return a((0,i.ellipticCurve)(),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}),(function(t){return t.getPublicKey(e)}))},e.getSharedPoint=function(e,t,n){return a((0,i.ellipticCurve)(),(function(r){return r.getSharedSecret(e,t,n)}),(function(n){return n.getSharedSecret(e,t)}),(function(n){return l(n,e,t)}))},e.convertPublicKeyFormat=function(e,t){return a((0,i.ellipticCurve)(),(function(n){return n.getSharedSecret(BigInt(1),e,t)}),(function(){return e}),(function(){return e}))},e.hexToPublicKey=function(e){var t=(0,s.decodeHex)(e);return a((0,i.ellipticCurve)(),(function(){return c(t)}),(function(){return t}),(function(){return t}))};var c=function(e){if(e.length===o.ETH_PUBLIC_KEY_SIZE){var t=new Uint8Array(1+e.length);return t.set([4]),t.set(e,1),t}return e},l=function(e,t,n){var r=e.utils.getExtendedPublicKey(t).scalar;return e.ExtendedPoint.fromHex(n).multiply(r).toRawBytes()}}(sn);var zi={},qi={};Object.defineProperty(qi,"__esModule",{value:!0}),qi.hkdf=void 0,qi.extract=Yi,qi.expand=Xi;const Vi=hn,Wi=En,Gi=Di;function Yi(e,t,n){return(0,Vi.hash)(e),void 0===n&&(n=new Uint8Array(e.outputLen)),(0,Gi.hmac)(e,(0,Wi.toBytes)(n),(0,Wi.toBytes)(t))}const Zi=new Uint8Array([0]),Ji=new Uint8Array;function Xi(e,t,n,r=32){if((0,Vi.hash)(e),(0,Vi.number)(r),r>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(r/e.outputLen);void 0===n&&(n=Ji);const o=new Uint8Array(i*e.outputLen),s=Gi.hmac.create(e,t),a=s._cloneInto(),c=new Uint8Array(s.outputLen);for(let t=0;t<i;t++)Zi[0]=t+1,a.update(0===t?Ji:c).update(n).update(Zi).digestInto(c),o.set(c,e.outputLen*t),s._cloneInto(a);return s.destroy(),a.destroy(),c.fill(0),Zi.fill(0),o.slice(0,r)}qi.hkdf=(e,t,n,r,i)=>Xi(e,Yi(e,t,n),r,i),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getSharedKey=e.deriveKey=void 0;var t=zt,n=qi,r=Mi;e.deriveKey=function(e,t,i){return(0,n.hkdf)(r.sha256,e,t,i,32)},e.getSharedKey=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return(0,e.deriveKey)(t.concatBytes.apply(void 0,n))}}(zi);var Qi={},eo={},to={},no={};Object.defineProperty(no,"__esModule",{value:!0}),no.polyval=no.ghash=void 0,no._toGHASHKey=lo;const ro=qt,io=zt,oo=16,so=new Uint8Array(16),ao=(0,io.u32)(so),co=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function lo(e){e.reverse();const t=1&e[15];let n=0;for(let t=0;t<e.length;t++){const r=e[t];e[t]=r>>>1|n,n=(1&r)<<7}return e[0]^=225&-t,e}class uo{constructor(e,t){this.blockLen=oo,this.outputLen=oo,this.s0=0,this.s1=0,this.s2=0,this.s3=0,this.finished=!1,e=(0,io.toBytes)(e),(0,ro.bytes)(e,16);const n=(0,io.createView)(e);let r=n.getUint32(0,!1),i=n.getUint32(4,!1),o=n.getUint32(8,!1),s=n.getUint32(12,!1);const a=[];for(let e=0;e<128;e++)a.push({s0:co(r),s1:co(i),s2:co(o),s3:co(s)}),({s0:r,s1:i,s2:o,s3:s}={s3:(d=o)<<31|(u=s)>>>1,s2:(l=i)<<31|d>>>1,s1:(c=r)<<31|l>>>1,s0:c>>>1^225<<24&-(1&u)});var c,l,d,u;const h=(e=>e>65536?8:e>1024?4:2)(t||1024);if(![1,2,4,8].includes(h))throw new Error(`ghash: wrong window size=${h}, should be 2, 4 or 8`);this.W=h;const f=128/h,p=this.windowSize=2**h,g=[];for(let e=0;e<f;e++)for(let t=0;t<p;t++){let n=0,r=0,i=0,o=0;for(let s=0;s<h;s++){if(!(t>>>h-s-1&1))continue;const{s0:c,s1:l,s2:d,s3:u}=a[h*e+s];n^=c,r^=l,i^=d,o^=u}g.push({s0:n,s1:r,s2:i,s3:o})}this.t=g}_updateBlock(e,t,n,r){e^=this.s0,t^=this.s1,n^=this.s2,r^=this.s3;const{W:i,t:o,windowSize:s}=this;let a=0,c=0,l=0,d=0;const u=(1<<i)-1;let h=0;for(const f of[e,t,n,r])for(let e=0;e<4;e++){const t=f>>>8*e&255;for(let e=8/i-1;e>=0;e--){const n=t>>>i*e&u,{s0:r,s1:f,s2:p,s3:g}=o[h*s+n];a^=r,c^=f,l^=p,d^=g,h+=1}}this.s0=a,this.s1=c,this.s2=l,this.s3=d}update(e){e=(0,io.toBytes)(e),(0,ro.exists)(this);const t=(0,io.u32)(e),n=Math.floor(e.length/oo),r=e.length%oo;for(let e=0;e<n;e++)this._updateBlock(t[4*e+0],t[4*e+1],t[4*e+2],t[4*e+3]);return r&&(so.set(e.subarray(n*oo)),this._updateBlock(ao[0],ao[1],ao[2],ao[3]),(0,io.clean)(ao)),this}destroy(){const{t:e}=this;for(const t of e)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(e){(0,ro.exists)(this),(0,ro.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,io.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e}digest(){const e=new Uint8Array(oo);return this.digestInto(e),this.destroy(),e}}class ho extends uo{constructor(e,t){e=(0,io.toBytes)(e);const n=lo((0,io.copyBytes)(e));super(n,t),(0,io.clean)(n)}update(e){e=(0,io.toBytes)(e),(0,ro.exists)(this);const t=(0,io.u32)(e),n=e.length%oo,r=Math.floor(e.length/oo);for(let e=0;e<r;e++)this._updateBlock(co(t[4*e+3]),co(t[4*e+2]),co(t[4*e+1]),co(t[4*e+0]));return n&&(so.set(e.subarray(r*oo)),this._updateBlock(co(ao[3]),co(ao[2]),co(ao[1]),co(ao[0])),(0,io.clean)(ao)),this}digestInto(e){(0,ro.exists)(this),(0,ro.output)(e,this),this.finished=!0;const{s0:t,s1:n,s2:r,s3:i}=this,o=(0,io.u32)(e);return o[0]=t,o[1]=n,o[2]=r,o[3]=i,e.reverse()}}function fo(e){const t=(t,n)=>e(n,t.length).update((0,io.toBytes)(t)).digest(),n=e(new Uint8Array(16),0);return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=(t,n)=>e(t,n),t}no.ghash=fo(((e,t)=>new uo(e,t))),no.polyval=fo(((e,t)=>new ho(e,t))),Object.defineProperty(to,"__esModule",{value:!0}),to.unsafe=to.aeskwp=to.aeskw=to.siv=to.gcm=to.cfb=to.cbc=to.ecb=to.ctr=void 0,to.expandKeyLE=Oo,to.expandKeyDecLE=Ro;const po=qt,go=no,mo=zt,yo=16,vo=new Uint8Array(yo),bo=283;function wo(e){return e<<1^bo&-(e>>7)}function Eo(e,t){let n=0;for(;t>0;t>>=1)n^=e&-(1&t),e=wo(e);return n}const Co=(()=>{const e=new Uint8Array(256);for(let t=0,n=1;t<256;t++,n^=wo(n))e[t]=n;const t=new Uint8Array(256);t[0]=99;for(let n=0;n<255;n++){let r=e[255-n];r|=r<<8,t[e[n]]=255&(r^r>>4^r>>5^r>>6^r>>7^99)}return(0,mo.clean)(e),t})(),_o=Co.map(((e,t)=>Co.indexOf(t))),So=e=>e<<24|e>>>8,ko=e=>e<<8|e>>>24,xo=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Ao(e,t){if(256!==e.length)throw new Error("Wrong sbox length");const n=new Uint32Array(256).map(((n,r)=>t(e[r]))),r=n.map(ko),i=r.map(ko),o=i.map(ko),s=new Uint32Array(65536),a=new Uint32Array(65536),c=new Uint16Array(65536);for(let t=0;t<256;t++)for(let l=0;l<256;l++){const d=256*t+l;s[d]=n[t]^r[l],a[d]=i[t]^o[l],c[d]=e[t]<<8|e[l]}return{sbox:e,sbox2:c,T0:n,T1:r,T2:i,T3:o,T01:s,T23:a}}const Mo=Ao(Co,(e=>Eo(e,3)<<24|e<<16|e<<8|Eo(e,2))),Lo=Ao(_o,(e=>Eo(e,11)<<24|Eo(e,13)<<16|Eo(e,9)<<8|Eo(e,14))),To=(()=>{const e=new Uint8Array(16);for(let t=0,n=1;t<16;t++,n=wo(n))e[t]=n;return e})();function Oo(e){(0,po.bytes)(e);const t=e.length;if(![16,24,32].includes(t))throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);const{sbox2:n}=Mo,r=[];(0,mo.isAligned32)(e)||r.push(e=(0,mo.copyBytes)(e));const i=(0,mo.u32)(e),o=i.length,s=e=>Io(n,e,e,e,e),a=new Uint32Array(t+28);a.set(i);for(let e=o;e<a.length;e++){let t=a[e-1];e%o==0?t=s(So(t))^To[e/o-1]:o>6&&e%o==4&&(t=s(t)),a[e]=a[e-o]^t}return(0,mo.clean)(...r),a}function Ro(e){const t=Oo(e),n=t.slice(),r=t.length,{sbox2:i}=Mo,{T0:o,T1:s,T2:a,T3:c}=Lo;for(let e=0;e<r;e+=4)for(let i=0;i<4;i++)n[e+i]=t[r-e-4+i];(0,mo.clean)(t);for(let e=4;e<r-4;e++){const t=n[e],r=Io(i,t,t,t,t);n[e]=o[255&r]^s[r>>>8&255]^a[r>>>16&255]^c[r>>>24]}return n}function Po(e,t,n,r,i,o){return e[n<<8&65280|r>>>8&255]^t[i>>>8&65280|o>>>24&255]}function Io(e,t,n,r,i){return e[255&t|65280&n]|e[r>>>16&255|i>>>16&65280]<<16}function No(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Mo;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^Po(s,a,t,n,r,i),l=e[c++]^Po(s,a,n,r,i,t),d=e[c++]^Po(s,a,r,i,t,n),u=e[c++]^Po(s,a,i,t,n,r);t=o,n=l,r=d,i=u}return{s0:e[c++]^Io(o,t,n,r,i),s1:e[c++]^Io(o,n,r,i,t),s2:e[c++]^Io(o,r,i,t,n),s3:e[c++]^Io(o,i,t,n,r)}}function Bo(e,t,n,r,i){const{sbox2:o,T01:s,T23:a}=Lo;let c=0;t^=e[c++],n^=e[c++],r^=e[c++],i^=e[c++];const l=e.length/4-2;for(let o=0;o<l;o++){const o=e[c++]^Po(s,a,t,i,r,n),l=e[c++]^Po(s,a,n,t,i,r),d=e[c++]^Po(s,a,r,n,t,i),u=e[c++]^Po(s,a,i,r,n,t);t=o,n=l,r=d,i=u}return{s0:e[c++]^Io(o,t,i,r,n),s1:e[c++]^Io(o,n,t,i,r),s2:e[c++]^Io(o,r,n,t,i),s3:e[c++]^Io(o,i,r,n,t)}}function Do(e,t){if(void 0===t)return new Uint8Array(e);if((0,po.bytes)(t),t.length<e)throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);if(!(0,mo.isAligned32)(t))throw new Error("unaligned dst");return t}function $o(e,t,n,r){(0,po.bytes)(t,yo),(0,po.bytes)(n);const i=n.length;r=Do(i,r);const o=t,s=(0,mo.u32)(o);let{s0:a,s1:c,s2:l,s3:d}=No(e,s[0],s[1],s[2],s[3]);const u=(0,mo.u32)(n),h=(0,mo.u32)(r);for(let t=0;t+4<=u.length;t+=4){h[t+0]=u[t+0]^a,h[t+1]=u[t+1]^c,h[t+2]=u[t+2]^l,h[t+3]=u[t+3]^d;let n=1;for(let e=o.length-1;e>=0;e--)n=n+(255&o[e])|0,o[e]=255&n,n>>>=8;({s0:a,s1:c,s2:l,s3:d}=No(e,s[0],s[1],s[2],s[3]))}const f=yo*Math.floor(u.length/4);if(f<i){const e=new Uint32Array([a,c,l,d]),t=(0,mo.u8)(e);for(let e=f,o=0;e<i;e++,o++)r[e]=n[e]^t[o];(0,mo.clean)(e)}return r}function jo(e,t,n,r,i){(0,po.bytes)(n,yo),(0,po.bytes)(r),i=Do(r.length,i);const o=n,s=(0,mo.u32)(o),a=(0,mo.createView)(o),c=(0,mo.u32)(r),l=(0,mo.u32)(i),d=t?0:12,u=r.length;let h=a.getUint32(d,t),{s0:f,s1:p,s2:g,s3:m}=No(e,s[0],s[1],s[2],s[3]);for(let n=0;n+4<=c.length;n+=4)l[n+0]=c[n+0]^f,l[n+1]=c[n+1]^p,l[n+2]=c[n+2]^g,l[n+3]=c[n+3]^m,h=h+1>>>0,a.setUint32(d,h,t),({s0:f,s1:p,s2:g,s3:m}=No(e,s[0],s[1],s[2],s[3]));const y=yo*Math.floor(c.length/4);if(y<u){const e=new Uint32Array([f,p,g,m]),t=(0,mo.u8)(e);for(let e=y,n=0;e<u;e++,n++)i[e]=r[e]^t[n];(0,mo.clean)(e)}return i}function Ko(e){if((0,po.bytes)(e),e.length%yo!=0)throw new Error("aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size 16")}function Uo(e,t,n){(0,po.bytes)(e);let r=e.length;const i=r%yo;if(!t&&0!==i)throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");(0,mo.isAligned32)(e)||(e=(0,mo.copyBytes)(e));const o=(0,mo.u32)(e);if(t){let e=yo-i;e||(e=yo),r+=e}const s=Do(r,n);return{b:o,o:(0,mo.u32)(s),out:s}}function Fo(e,t){if(!t)return e;const n=e.length;if(!n)throw new Error("aes/pcks5: empty ciphertext not allowed");const r=e[n-1];if(r<=0||r>16)throw new Error("aes/pcks5: wrong padding");const i=e.subarray(0,-r);for(let t=0;t<r;t++)if(e[n-t-1]!==r)throw new Error("aes/pcks5: wrong padding");return i}function Ho(e){const t=new Uint8Array(16),n=(0,mo.u32)(t);t.set(e);const r=yo-e.length;for(let e=yo-r;e<yo;e++)t[e]=r;return n}function zo(e,t,n,r,i){const o=null==i?0:i.length,s=e.create(n,r.length+o);i&&s.update(i),s.update(r);const a=new Uint8Array(16),c=(0,mo.createView)(a);i&&(0,mo.setBigUint64)(c,0,BigInt(8*o),t),(0,mo.setBigUint64)(c,8,BigInt(8*r.length),t),s.update(a);const l=s.digest();return(0,mo.clean)(a),l}to.ctr=(0,mo.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r){if((0,po.bytes)(n),void 0!==r&&((0,po.bytes)(r),!(0,mo.isAligned32)(r)))throw new Error("unaligned destination");const i=Oo(e),o=(0,mo.copyBytes)(t),s=[i,o];(0,mo.isAligned32)(n)||s.push(n=(0,mo.copyBytes)(n));const a=$o(i,o,n,r);return(0,mo.clean)(...s),a}return(0,po.bytes)(e),(0,po.bytes)(t,yo),{encrypt:(e,t)=>n(e,t),decrypt:(e,t)=>n(e,t)}})),to.ecb=(0,mo.wrapCipher)({blockSize:16},(function(e,t={}){(0,po.bytes)(e);const n=!t.disablePadding;return{encrypt(t,r){const{b:i,o:o,out:s}=Uo(t,n,r),a=Oo(e);let c=0;for(;c+4<=i.length;){const{s0:e,s1:t,s2:n,s3:r}=No(a,i[c+0],i[c+1],i[c+2],i[c+3]);o[c++]=e,o[c++]=t,o[c++]=n,o[c++]=r}if(n){const e=Ho(t.subarray(4*c)),{s0:n,s1:r,s2:i,s3:s}=No(a,e[0],e[1],e[2],e[3]);o[c++]=n,o[c++]=r,o[c++]=i,o[c++]=s}return(0,mo.clean)(a),s},decrypt(t,r){Ko(t);const i=Ro(e),o=Do(t.length,r),s=[i];(0,mo.isAligned32)(t)||s.push(t=(0,mo.copyBytes)(t));const a=(0,mo.u32)(t),c=(0,mo.u32)(o);for(let e=0;e+4<=a.length;){const{s0:t,s1:n,s2:r,s3:o}=Bo(i,a[e+0],a[e+1],a[e+2],a[e+3]);c[e++]=t,c[e++]=n,c[e++]=r,c[e++]=o}return(0,mo.clean)(...s),Fo(o,n)}}})),to.cbc=(0,mo.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t,n={}){(0,po.bytes)(e),(0,po.bytes)(t,16);const r=!n.disablePadding;return{encrypt(n,i){const o=Oo(e),{b:s,o:a,out:c}=Uo(n,r,i);let l=t;const d=[o];(0,mo.isAligned32)(l)||d.push(l=(0,mo.copyBytes)(l));const u=(0,mo.u32)(l);let h=u[0],f=u[1],p=u[2],g=u[3],m=0;for(;m+4<=s.length;)h^=s[m+0],f^=s[m+1],p^=s[m+2],g^=s[m+3],({s0:h,s1:f,s2:p,s3:g}=No(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g;if(r){const e=Ho(n.subarray(4*m));h^=e[0],f^=e[1],p^=e[2],g^=e[3],({s0:h,s1:f,s2:p,s3:g}=No(o,h,f,p,g)),a[m++]=h,a[m++]=f,a[m++]=p,a[m++]=g}return(0,mo.clean)(...d),c},decrypt(n,i){Ko(n);const o=Ro(e);let s=t;const a=[o];(0,mo.isAligned32)(s)||a.push(s=(0,mo.copyBytes)(s));const c=(0,mo.u32)(s),l=Do(n.length,i);(0,mo.isAligned32)(n)||a.push(n=(0,mo.copyBytes)(n));const d=(0,mo.u32)(n),u=(0,mo.u32)(l);let h=c[0],f=c[1],p=c[2],g=c[3];for(let e=0;e+4<=d.length;){const t=h,n=f,r=p,i=g;h=d[e+0],f=d[e+1],p=d[e+2],g=d[e+3];const{s0:s,s1:a,s2:c,s3:l}=Bo(o,h,f,p,g);u[e++]=s^t,u[e++]=a^n,u[e++]=c^r,u[e++]=l^i}return(0,mo.clean)(...a),Fo(l,r)}}})),to.cfb=(0,mo.wrapCipher)({blockSize:16,nonceLength:16},(function(e,t){function n(n,r,i){(0,po.bytes)(n);const o=n.length;i=Do(o,i);const s=Oo(e);let a=t;const c=[s];(0,mo.isAligned32)(a)||c.push(a=(0,mo.copyBytes)(a)),(0,mo.isAligned32)(n)||c.push(n=(0,mo.copyBytes)(n));const l=(0,mo.u32)(n),d=(0,mo.u32)(i),u=r?d:l,h=(0,mo.u32)(a);let f=h[0],p=h[1],g=h[2],m=h[3];for(let e=0;e+4<=l.length;){const{s0:t,s1:n,s2:r,s3:i}=No(s,f,p,g,m);d[e+0]=l[e+0]^t,d[e+1]=l[e+1]^n,d[e+2]=l[e+2]^r,d[e+3]=l[e+3]^i,f=u[e++],p=u[e++],g=u[e++],m=u[e++]}const y=yo*Math.floor(l.length/4);if(y<o){({s0:f,s1:p,s2:g,s3:m}=No(s,f,p,g,m));const e=(0,mo.u8)(new Uint32Array([f,p,g,m]));for(let t=y,r=0;t<o;t++,r++)i[t]=n[t]^e[r];(0,mo.clean)(e)}return(0,mo.clean)(...c),i}return(0,po.bytes)(e),(0,po.bytes)(t,16),{encrypt:(e,t)=>n(e,!0,t),decrypt:(e,t)=>n(e,!1,t)}})),to.gcm=(0,mo.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){if((0,po.bytes)(e),(0,po.bytes)(t),void 0!==n&&(0,po.bytes)(n),t.length<8)throw new Error("aes/gcm: invalid nonce length");function r(e,t,r){const i=zo(go.ghash,!1,e,r,n);for(let e=0;e<t.length;e++)i[e]^=t[e];return i}function i(){const n=Oo(e),r=vo.slice(),i=vo.slice();if(jo(n,!1,i,i,r),12===t.length)i.set(t);else{const e=vo.slice(),n=(0,mo.createView)(e);(0,mo.setBigUint64)(n,8,BigInt(8*t.length),!1);const o=go.ghash.create(r).update(t).update(e);o.digestInto(i),o.destroy()}return{xk:n,authKey:r,counter:i,tagMask:jo(n,!1,i,vo)}}return{encrypt(e){(0,po.bytes)(e);const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=new Uint8Array(e.length+16),c=[t,n,o,s];(0,mo.isAligned32)(e)||c.push(e=(0,mo.copyBytes)(e)),jo(t,!1,o,e,a);const l=r(n,s,a.subarray(0,a.length-16));return c.push(l),a.set(l,e.length),(0,mo.clean)(...c),a},decrypt(e){if((0,po.bytes)(e),e.length<16)throw new Error("aes/gcm: ciphertext less than tagLen (16)");const{xk:t,authKey:n,counter:o,tagMask:s}=i(),a=[t,n,s,o];(0,mo.isAligned32)(e)||a.push(e=(0,mo.copyBytes)(e));const c=e.subarray(0,-16),l=e.subarray(-16),d=r(n,s,c);if(a.push(d),!(0,mo.equalBytes)(d,l))throw new Error("aes/gcm: invalid ghash tag");const u=jo(t,!1,o,c);return(0,mo.clean)(...a),u}}}));const qo=(e,t,n)=>r=>{if(!Number.isSafeInteger(r)||t>r||r>n)throw new Error(`${e}: invalid value=${r}, must be [${t}..${n}]`)};function Vo(e){return null!=e&&"object"==typeof e&&(e instanceof Uint32Array||"Uint32Array"===e.constructor.name)}function Wo(e,t){if((0,po.bytes)(t,16),!Vo(e))throw new Error("_encryptBlock accepts result of expandKeyLE");const n=(0,mo.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=No(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}function Go(e,t){if((0,po.bytes)(t,16),!Vo(e))throw new Error("_decryptBlock accepts result of expandKeyLE");const n=(0,mo.u32)(t);let{s0:r,s1:i,s2:o,s3:s}=Bo(e,n[0],n[1],n[2],n[3]);return n[0]=r,n[1]=i,n[2]=o,n[3]=s,t}to.siv=(0,mo.wrapCipher)({blockSize:16,nonceLength:12,tagLength:16},(function(e,t,n){const r=qo("AAD",0,2**36),i=qo("plaintext",0,2**36),o=qo("nonce",12,12),s=qo("ciphertext",16,2**36+16);function a(){const n=Oo(e),r=new Uint8Array(e.length),i=new Uint8Array(16),o=[n,r];let s=t;(0,mo.isAligned32)(s)||o.push(s=(0,mo.copyBytes)(s));const a=(0,mo.u32)(s);let c=0,l=a[0],d=a[1],u=a[2],h=0;for(const e of[i,r].map(mo.u32)){const t=(0,mo.u32)(e);for(let e=0;e<t.length;e+=2){const{s0:r,s1:i}=No(n,c,l,d,u);t[e+0]=r,t[e+1]=i,c=++h}}const f={authKey:i,encKey:Oo(r)};return(0,mo.clean)(...o),f}function c(e,r,i){const o=zo(go.polyval,!0,r,i,n);for(let e=0;e<12;e++)o[e]^=t[e];o[15]&=127;const s=(0,mo.u32)(o);let a=s[0],c=s[1],l=s[2],d=s[3];return({s0:a,s1:c,s2:l,s3:d}=No(e,a,c,l,d)),s[0]=a,s[1]=c,s[2]=l,s[3]=d,o}function l(e,t,n){let r=(0,mo.copyBytes)(t);r[15]|=128;const i=jo(e,!0,r,n);return(0,mo.clean)(r),i}return(0,po.bytes)(e,16,24,32),(0,po.bytes)(t),o(t.length),void 0!==n&&((0,po.bytes)(n),r(n.length)),{encrypt(e){(0,po.bytes)(e),i(e.length);const{encKey:t,authKey:n}=a(),r=c(t,n,e),o=[t,n,r];(0,mo.isAligned32)(e)||o.push(e=(0,mo.copyBytes)(e));const s=new Uint8Array(e.length+16);return s.set(r,e.length),s.set(l(t,r,e)),(0,mo.clean)(...o),s},decrypt(e){(0,po.bytes)(e),s(e.length);const t=e.subarray(-16),{encKey:n,authKey:r}=a(),i=[n,r];(0,mo.isAligned32)(e)||i.push(e=(0,mo.copyBytes)(e));const o=l(n,t,e.subarray(0,-16)),d=c(n,r,o);if(i.push(d),!(0,mo.equalBytes)(t,d))throw(0,mo.clean)(...i),new Error("invalid polyval tag");return(0,mo.clean)(...i),o}}}));const Yo={encrypt(e,t){if(t.length>=2**32)throw new Error("plaintext should be less than 4gb");const n=Oo(e);if(16===t.length)Wo(n,t);else{const e=(0,mo.u32)(t);let r=e[0],i=e[1];for(let t=0,o=1;t<6;t++)for(let t=2;t<e.length;t+=2,o++){const{s0:s,s1:a,s2:c,s3:l}=No(n,r,i,e[t],e[t+1]);r=s,i=a^xo(o),e[t]=c,e[t+1]=l}e[0]=r,e[1]=i}n.fill(0)},decrypt(e,t){if(t.length-8>=2**32)throw new Error("ciphertext should be less than 4gb");const n=Ro(e),r=t.length/8-1;if(1===r)Go(n,t);else{const e=(0,mo.u32)(t);let i=e[0],o=e[1];for(let t=0,s=6*r;t<6;t++)for(let t=2*r;t>=1;t-=2,s--){o^=xo(s);const{s0:r,s1:a,s2:c,s3:l}=Bo(n,i,o,e[t],e[t+1]);i=r,o=a,e[t]=c,e[t+1]=l}e[0]=i,e[1]=o}n.fill(0)}},Zo=new Uint8Array(8).fill(166);to.aeskw=(0,mo.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,po.bytes)(t),!t.length||t.length%8!=0)throw new Error("invalid plaintext length");if(8===t.length)throw new Error("8-byte keys not allowed in AESKW, use AESKWP instead");const n=(0,mo.concatBytes)(Zo,t);return Yo.encrypt(e,n),n},decrypt(t){if((0,po.bytes)(t),t.length%8!=0||t.length<24)throw new Error("invalid ciphertext length");const n=(0,mo.copyBytes)(t);if(Yo.decrypt(e,n),!(0,mo.equalBytes)(n.subarray(0,8),Zo))throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8)}})));const Jo=2790873510;to.aeskwp=(0,mo.wrapCipher)({blockSize:8},(e=>({encrypt(t){if((0,po.bytes)(t),!t.length)throw new Error("invalid plaintext length");const n=8*Math.ceil(t.length/8),r=new Uint8Array(8+n);r.set(t,8);const i=(0,mo.u32)(r);return i[0]=Jo,i[1]=xo(t.length),Yo.encrypt(e,r),r},decrypt(t){if((0,po.bytes)(t),t.length<16)throw new Error("invalid ciphertext length");const n=(0,mo.copyBytes)(t),r=(0,mo.u32)(n);Yo.decrypt(e,n);const i=xo(r[1])>>>0,o=8*Math.ceil(i/8);if(r[0]!==Jo||n.length-8!==o)throw new Error("integrity check failed");for(let e=i;e<o;e++)if(0!==n[8+e])throw new Error("integrity check failed");return n.subarray(0,8).fill(0),n.subarray(8,8+i)}}))),to.unsafe={expandKeyLE:Oo,expandKeyDecLE:Ro,encrypt:No,decrypt:Bo,encryptBlock:Wo,decryptBlock:Go,ctrCounter:$o,ctr32:jo},Object.defineProperty(eo,"__esModule",{value:!0}),eo.aes256cbc=eo.aes256gcm=void 0;var Xo=to;eo.aes256gcm=function(e,t,n){return(0,Xo.gcm)(e,t,n)},eo.aes256cbc=function(e,t,n){return(0,Xo.cbc)(e,t)};var Qo={},es={},ts={};Object.defineProperty(ts,"__esModule",{value:!0}),ts.sigma=void 0,ts.rotl=function(e,t){return e<<t|e>>>32-t},ts.createCipher=function(e,t){const{allowShortKeys:n,extendNonceFn:r,counterLength:i,counterRight:o,rounds:s}=(0,rs.checkOpts)({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return(0,ns.number)(i),(0,ns.number)(s),(0,ns.bool)(o),(0,ns.bool)(n),(t,a,c,l,d=0)=>{(0,ns.bytes)(t),(0,ns.bytes)(a),(0,ns.bytes)(c);const u=c.length;if(void 0===l&&(l=new Uint8Array(u)),(0,ns.bytes)(l),(0,ns.number)(d),d<0||d>=hs)throw new Error("arx: counter overflow");if(l.length<u)throw new Error(`arx: output (${l.length}) is shorter than data (${u})`);const h=[];let f,p,g=t.length;if(32===g)h.push(f=(0,rs.copyBytes)(t)),p=cs;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=as,h.push(f)}ls(a)||h.push(a=(0,rs.copyBytes)(a));const m=(0,rs.u32)(f);if(r){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");r(p,m,(0,rs.u32)(a.subarray(0,16)),m),a=a.subarray(16)}const y=16-i;if(y!==a.length)throw new Error(`arx: nonce must be ${y} or 16 bytes`);if(12!==y){const e=new Uint8Array(12);e.set(a,o?0:12-a.length),a=e,h.push(a)}const v=(0,rs.u32)(a);return function(e,t,n,r,i,o,s,a){const c=i.length,l=new Uint8Array(ds),d=(0,rs.u32)(l),u=ls(i)&&ls(o),h=u?(0,rs.u32)(i):fs,f=u?(0,rs.u32)(o):fs;for(let p=0;p<c;s++){if(e(t,n,r,d,s,a),s>=hs)throw new Error("arx: counter overflow");const g=Math.min(ds,c-p);if(u&&g===ds){const e=p/4;if(p%4!=0)throw new Error("arx: invalid block position");for(let t,n=0;n<us;n++)t=e+n,f[t]=h[t]^d[n];p+=ds}else{for(let e,t=0;t<g;t++)e=p+t,o[e]=i[e]^l[t];p+=g}}}(e,p,m,v,c,l,d,s),(0,rs.clean)(...h),l}};const ns=qt,rs=zt,is=e=>Uint8Array.from(e.split("").map((e=>e.charCodeAt(0)))),os=is("expand 16-byte k"),ss=is("expand 32-byte k"),as=(0,rs.u32)(os),cs=(0,rs.u32)(ss);function ls(e){return e.byteOffset%4==0}ts.sigma=cs.slice();const ds=64,us=16,hs=2**32-1,fs=new Uint32Array;var ps={};Object.defineProperty(ps,"__esModule",{value:!0}),ps.poly1305=void 0,ps.wrapConstructorWithKey=bs;const gs=qt,ms=zt,ys=(e,t)=>255&e[t++]|(255&e[t++])<<8;class vs{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,e=(0,ms.toBytes)(e),(0,gs.bytes)(e,32);const t=ys(e,0),n=ys(e,2),r=ys(e,4),i=ys(e,6),o=ys(e,8),s=ys(e,10),a=ys(e,12),c=ys(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|i<<9),this.r[4]=255&(i>>>4|o<<12),this.r[5]=o>>>1&8190,this.r[6]=8191&(o>>>14|s<<2),this.r[7]=8065&(s>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=ys(e,16+2*t)}process(e,t,n=!1){const r=n?0:2048,{h:i,r:o}=this,s=o[0],a=o[1],c=o[2],l=o[3],d=o[4],u=o[5],h=o[6],f=o[7],p=o[8],g=o[9],m=ys(e,t+0),y=ys(e,t+2),v=ys(e,t+4),b=ys(e,t+6),w=ys(e,t+8),E=ys(e,t+10),C=ys(e,t+12),_=ys(e,t+14);let S=i[0]+(8191&m),k=i[1]+(8191&(m>>>13|y<<3)),x=i[2]+(8191&(y>>>10|v<<6)),A=i[3]+(8191&(v>>>7|b<<9)),M=i[4]+(8191&(b>>>4|w<<12)),L=i[5]+(w>>>1&8191),T=i[6]+(8191&(w>>>14|E<<2)),O=i[7]+(8191&(E>>>11|C<<5)),R=i[8]+(8191&(C>>>8|_<<8)),P=i[9]+(_>>>5|r),I=0,N=I+S*s+k*(5*g)+x*(5*p)+A*(5*f)+M*(5*h);I=N>>>13,N&=8191,N+=L*(5*u)+T*(5*d)+O*(5*l)+R*(5*c)+P*(5*a),I+=N>>>13,N&=8191;let B=I+S*a+k*s+x*(5*g)+A*(5*p)+M*(5*f);I=B>>>13,B&=8191,B+=L*(5*h)+T*(5*u)+O*(5*d)+R*(5*l)+P*(5*c),I+=B>>>13,B&=8191;let D=I+S*c+k*a+x*s+A*(5*g)+M*(5*p);I=D>>>13,D&=8191,D+=L*(5*f)+T*(5*h)+O*(5*u)+R*(5*d)+P*(5*l),I+=D>>>13,D&=8191;let $=I+S*l+k*c+x*a+A*s+M*(5*g);I=$>>>13,$&=8191,$+=L*(5*p)+T*(5*f)+O*(5*h)+R*(5*u)+P*(5*d),I+=$>>>13,$&=8191;let j=I+S*d+k*l+x*c+A*a+M*s;I=j>>>13,j&=8191,j+=L*(5*g)+T*(5*p)+O*(5*f)+R*(5*h)+P*(5*u),I+=j>>>13,j&=8191;let K=I+S*u+k*d+x*l+A*c+M*a;I=K>>>13,K&=8191,K+=L*s+T*(5*g)+O*(5*p)+R*(5*f)+P*(5*h),I+=K>>>13,K&=8191;let U=I+S*h+k*u+x*d+A*l+M*c;I=U>>>13,U&=8191,U+=L*a+T*s+O*(5*g)+R*(5*p)+P*(5*f),I+=U>>>13,U&=8191;let F=I+S*f+k*h+x*u+A*d+M*l;I=F>>>13,F&=8191,F+=L*c+T*a+O*s+R*(5*g)+P*(5*p),I+=F>>>13,F&=8191;let H=I+S*p+k*f+x*h+A*u+M*d;I=H>>>13,H&=8191,H+=L*l+T*c+O*a+R*s+P*(5*g),I+=H>>>13,H&=8191;let z=I+S*g+k*p+x*f+A*h+M*u;I=z>>>13,z&=8191,z+=L*d+T*l+O*c+R*a+P*s,I+=z>>>13,z&=8191,I=(I<<2)+I|0,I=I+N|0,N=8191&I,I>>>=13,B+=I,i[0]=N,i[1]=B,i[2]=D,i[3]=$,i[4]=j,i[5]=K,i[6]=U,i[7]=F,i[8]=H,i[9]=z}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=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 t=1;t<10;t++)n[t]=e[t]+r,r=n[t]>>>13,n[t]&=8191;n[9]-=8192;let i=(1^r)-1;for(let e=0;e<10;e++)n[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|n[t];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 o=e[0]+t[0];e[0]=65535&o;for(let n=1;n<8;n++)o=(e[n]+t[n]|0)+(o>>>16)|0,e[n]=65535&o;(0,ms.clean)(n)}update(e){(0,gs.exists)(this);const{buffer:t,blockLen:n}=this,r=(e=(0,ms.toBytes)(e)).length;for(let i=0;i<r;){const o=Math.min(n-this.pos,r-i);if(o!==n)t.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=r-i;i+=n)this.process(e,i)}return this}destroy(){(0,ms.clean)(this.h,this.r,this.buffer,this.pad)}digestInto(e){(0,gs.exists)(this),(0,gs.output)(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 i=0;for(let t=0;t<8;t++)e[i++]=n[t]>>>0,e[i++]=n[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}function bs(e){const t=(t,n)=>e(n).update((0,ms.toBytes)(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}ps.poly1305=bs((e=>new vs(e))),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.xchacha20poly1305=e.chacha20poly1305=e._poly1305_aead=e.chacha12=e.chacha8=e.xchacha20=e.chacha20=e.chacha20orig=void 0,e.hchacha=s;const t=ts,n=qt,r=ps,i=zt;function o(e,n,r,i,o,s=20){let a=e[0],c=e[1],l=e[2],d=e[3],u=n[0],h=n[1],f=n[2],p=n[3],g=n[4],m=n[5],y=n[6],v=n[7],b=o,w=r[0],E=r[1],C=r[2],_=a,S=c,k=l,x=d,A=u,M=h,L=f,T=p,O=g,R=m,P=y,I=v,N=b,B=w,D=E,$=C;for(let e=0;e<s;e+=2)_=_+A|0,N=(0,t.rotl)(N^_,16),O=O+N|0,A=(0,t.rotl)(A^O,12),_=_+A|0,N=(0,t.rotl)(N^_,8),O=O+N|0,A=(0,t.rotl)(A^O,7),S=S+M|0,B=(0,t.rotl)(B^S,16),R=R+B|0,M=(0,t.rotl)(M^R,12),S=S+M|0,B=(0,t.rotl)(B^S,8),R=R+B|0,M=(0,t.rotl)(M^R,7),k=k+L|0,D=(0,t.rotl)(D^k,16),P=P+D|0,L=(0,t.rotl)(L^P,12),k=k+L|0,D=(0,t.rotl)(D^k,8),P=P+D|0,L=(0,t.rotl)(L^P,7),x=x+T|0,$=(0,t.rotl)($^x,16),I=I+$|0,T=(0,t.rotl)(T^I,12),x=x+T|0,$=(0,t.rotl)($^x,8),I=I+$|0,T=(0,t.rotl)(T^I,7),_=_+M|0,$=(0,t.rotl)($^_,16),P=P+$|0,M=(0,t.rotl)(M^P,12),_=_+M|0,$=(0,t.rotl)($^_,8),P=P+$|0,M=(0,t.rotl)(M^P,7),S=S+L|0,N=(0,t.rotl)(N^S,16),I=I+N|0,L=(0,t.rotl)(L^I,12),S=S+L|0,N=(0,t.rotl)(N^S,8),I=I+N|0,L=(0,t.rotl)(L^I,7),k=k+T|0,B=(0,t.rotl)(B^k,16),O=O+B|0,T=(0,t.rotl)(T^O,12),k=k+T|0,B=(0,t.rotl)(B^k,8),O=O+B|0,T=(0,t.rotl)(T^O,7),x=x+A|0,D=(0,t.rotl)(D^x,16),R=R+D|0,A=(0,t.rotl)(A^R,12),x=x+A|0,D=(0,t.rotl)(D^x,8),R=R+D|0,A=(0,t.rotl)(A^R,7);let j=0;i[j++]=a+_|0,i[j++]=c+S|0,i[j++]=l+k|0,i[j++]=d+x|0,i[j++]=u+A|0,i[j++]=h+M|0,i[j++]=f+L|0,i[j++]=p+T|0,i[j++]=g+O|0,i[j++]=m+R|0,i[j++]=y+P|0,i[j++]=v+I|0,i[j++]=b+N|0,i[j++]=w+B|0,i[j++]=E+D|0,i[j++]=C+$|0}function s(e,n,r,i){let o=e[0],s=e[1],a=e[2],c=e[3],l=n[0],d=n[1],u=n[2],h=n[3],f=n[4],p=n[5],g=n[6],m=n[7],y=r[0],v=r[1],b=r[2],w=r[3];for(let e=0;e<20;e+=2)o=o+l|0,y=(0,t.rotl)(y^o,16),f=f+y|0,l=(0,t.rotl)(l^f,12),o=o+l|0,y=(0,t.rotl)(y^o,8),f=f+y|0,l=(0,t.rotl)(l^f,7),s=s+d|0,v=(0,t.rotl)(v^s,16),p=p+v|0,d=(0,t.rotl)(d^p,12),s=s+d|0,v=(0,t.rotl)(v^s,8),p=p+v|0,d=(0,t.rotl)(d^p,7),a=a+u|0,b=(0,t.rotl)(b^a,16),g=g+b|0,u=(0,t.rotl)(u^g,12),a=a+u|0,b=(0,t.rotl)(b^a,8),g=g+b|0,u=(0,t.rotl)(u^g,7),c=c+h|0,w=(0,t.rotl)(w^c,16),m=m+w|0,h=(0,t.rotl)(h^m,12),c=c+h|0,w=(0,t.rotl)(w^c,8),m=m+w|0,h=(0,t.rotl)(h^m,7),o=o+d|0,w=(0,t.rotl)(w^o,16),g=g+w|0,d=(0,t.rotl)(d^g,12),o=o+d|0,w=(0,t.rotl)(w^o,8),g=g+w|0,d=(0,t.rotl)(d^g,7),s=s+u|0,y=(0,t.rotl)(y^s,16),m=m+y|0,u=(0,t.rotl)(u^m,12),s=s+u|0,y=(0,t.rotl)(y^s,8),m=m+y|0,u=(0,t.rotl)(u^m,7),a=a+h|0,v=(0,t.rotl)(v^a,16),f=f+v|0,h=(0,t.rotl)(h^f,12),a=a+h|0,v=(0,t.rotl)(v^a,8),f=f+v|0,h=(0,t.rotl)(h^f,7),c=c+l|0,b=(0,t.rotl)(b^c,16),p=p+b|0,l=(0,t.rotl)(l^p,12),c=c+l|0,b=(0,t.rotl)(b^c,8),p=p+b|0,l=(0,t.rotl)(l^p,7);let E=0;i[E++]=o,i[E++]=s,i[E++]=a,i[E++]=c,i[E++]=y,i[E++]=v,i[E++]=b,i[E++]=w}e.chacha20orig=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,allowShortKeys:!0}),e.chacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,allowShortKeys:!1}),e.xchacha20=(0,t.createCipher)(o,{counterRight:!1,counterLength:8,extendNonceFn:s,allowShortKeys:!1}),e.chacha8=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:8}),e.chacha12=(0,t.createCipher)(o,{counterRight:!1,counterLength:4,rounds:12});const a=new Uint8Array(16),c=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(a.subarray(n))},l=new Uint8Array(32);function d(e,t,n,o,s){const a=e(t,n,l),d=r.poly1305.create(a);s&&c(d,s),c(d,o);const u=new Uint8Array(16),h=(0,i.createView)(u);(0,i.setBigUint64)(h,0,BigInt(s?s.length:0),!0),(0,i.setBigUint64)(h,8,BigInt(o.length),!0),d.update(u);const f=d.digest();return(0,i.clean)(a,u),f}e._poly1305_aead=e=>(t,r,o)=>((0,n.bytes)(t,32),(0,n.bytes)(r),{encrypt(s,a){const c=s.length,l=c+16;a?(0,n.bytes)(a,l):a=new Uint8Array(l),e(t,r,s,a,1);const u=d(e,t,r,a.subarray(0,-16),o);return a.set(u,c),(0,i.clean)(u),a},decrypt(s,a){const c=s.length,l=c-16;if(c<16)throw new Error("encrypted data must be at least 16 bytes");a?(0,n.bytes)(a,l):a=new Uint8Array(l);const u=s.subarray(0,-16),h=s.subarray(-16),f=d(e,t,r,u,o);if(!(0,i.equalBytes)(h,f))throw new Error("invalid tag");return e(t,r,u,a,1),(0,i.clean)(f),a}}),e.chacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:12,tagLength:16},(0,e._poly1305_aead)(e.chacha20)),e.xchacha20poly1305=(0,i.wrapCipher)({blockSize:64,nonceLength:24,tagLength:16},(0,e._poly1305_aead)(e.xchacha20))}(es),Object.defineProperty(Qo,"__esModule",{value:!0}),Qo.xchacha20=void 0;var ws,Es,Cs,_s=es;Qo.xchacha20=function(e,t,n){return(0,_s.xchacha20poly1305)(e,t,n)},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.aesDecrypt=e.aesEncrypt=e.symDecrypt=e.symEncrypt=void 0;var t=zt,n=an,r=eo,i=Qo,o=en,s=tn;function a(e,t,n,a){var c=(0,o.symmetricAlgorithm)();if("aes-256-gcm"===c)return e(r.aes256gcm,t,n,(0,o.symmetricNonceLength)(),s.AEAD_TAG_LENGTH,a);if("xchacha20"===c)return e(i.xchacha20,t,n,s.XCHACHA20_NONCE_LENGTH,s.AEAD_TAG_LENGTH,a);if("aes-256-cbc"===c)return e(r.aes256cbc,t,n,16,0);throw new Error("Not implemented")}function c(e,r,i,o,s,a){var c=(0,n.randomBytes)(o),l=e(r,c,a).encrypt(i);if(0===s)return(0,t.concatBytes)(c,l);var d=l.length-s,u=l.subarray(0,d),h=l.subarray(d);return(0,t.concatBytes)(c,h,u)}function l(e,n,r,i,o,s){var a=r.subarray(0,i),c=e(n,Uint8Array.from(a),s),l=r.subarray(i);if(0===o)return c.decrypt(l);var d=l.subarray(0,o),u=l.subarray(o);return c.decrypt((0,t.concatBytes)(u,d))}e.symEncrypt=function(e,t,n){return a(c,e,t,n)},e.symDecrypt=function(e,t,n){return a(l,e,t,n)},e.aesEncrypt=e.symEncrypt,e.aesDecrypt=e.symDecrypt}(Qi),ws=on,Es=Kt&&Kt.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),Cs=Kt&&Kt.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||Es(t,e,n)},Object.defineProperty(ws,"__esModule",{value:!0}),Cs(sn,ws),Cs(zi,ws),Cs(Hi,ws),Cs(Qi,ws);var Ss={};Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.PublicKey=void 0;var ks=zt,xs=on,As=function(){function e(e){this.data=(0,xs.convertPublicKeyFormat)(e,!0)}return e.fromHex=function(t){return new e((0,xs.hexToPublicKey)(t))},Object.defineProperty(e.prototype,"uncompressed",{get:function(){return et.from((0,xs.convertPublicKeyFormat)(this.data,!1))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"compressed",{get:function(){return et.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(e){return void 0===e&&(e=!0),(0,ks.bytesToHex)(e?this.data:this.uncompressed)},e.prototype.decapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.data:this.uncompressed,r=e.multiply(this,t);return(0,xs.getSharedKey)(n,r)},e.prototype.equals=function(e){return(0,ks.equalBytes)(this.data,e.data)},e}();Ss.PublicKey=As,Object.defineProperty(rn,"__esModule",{value:!0}),rn.PrivateKey=void 0;var Ms=zt,Ls=on,Ts=Ss,Os=function(){function e(e){if(void 0===e)this.data=(0,Ls.getValidSecret)();else{if(!(0,Ls.isValidPrivateKey)(e))throw new Error("Invalid private key");this.data=e}this.publicKey=new Ts.PublicKey((0,Ls.getPublicKey)(this.data))}return e.fromHex=function(t){return new e((0,Ls.decodeHex)(t))},Object.defineProperty(e.prototype,"secret",{get:function(){return et.from(this.data)},enumerable:!1,configurable:!0}),e.prototype.toHex=function(){return(0,Ms.bytesToHex)(this.data)},e.prototype.encapsulate=function(e,t){void 0===t&&(t=!1);var n=t?this.publicKey.compressed:this.publicKey.uncompressed,r=this.multiply(e,t);return(0,Ls.getSharedKey)(n,r)},e.prototype.multiply=function(e,t){return void 0===t&&(t=!1),(0,Ls.getSharedPoint)(this.data,e.compressed,t)},e.prototype.equals=function(e){return(0,Ms.equalBytes)(this.data,e.data)},e}();rn.PrivateKey=Os,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.PublicKey=e.PrivateKey=void 0;var t=rn;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return t.PrivateKey}});var n=Ss;Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return n.PublicKey}})}(nn),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.PublicKey=e.PrivateKey=e.ECIES_CONFIG=void 0,e.encrypt=function(e,o){var s=new r.PrivateKey,a=e instanceof Uint8Array?new r.PublicKey(e):r.PublicKey.fromHex(e),c=s.encapsulate(a,(0,n.isHkdfKeyCompressed)()),l=(0,n.isEphemeralKeyCompressed)()?s.publicKey.compressed:s.publicKey.uncompressed,d=(0,i.symEncrypt)(c,o);return et.from((0,t.concatBytes)(l,d))},e.decrypt=function(e,t){var o=e instanceof Uint8Array?new r.PrivateKey(e):r.PrivateKey.fromHex(e),s=(0,n.ephemeralKeySize)(),a=new r.PublicKey(t.subarray(0,s)),c=t.subarray(s),l=a.decapsulate(o,(0,n.isHkdfKeyCompressed)());return et.from((0,i.symDecrypt)(l,c))};var t=zt,n=en,r=nn,i=on,o=en;Object.defineProperty(e,"ECIES_CONFIG",{enumerable:!0,get:function(){return o.ECIES_CONFIG}});var s=nn;Object.defineProperty(e,"PrivateKey",{enumerable:!0,get:function(){return s.PrivateKey}}),Object.defineProperty(e,"PublicKey",{enumerable:!0,get:function(){return s.PublicKey}}),e.utils={aesEncrypt:i.aesEncrypt,aesDecrypt:i.aesDecrypt,symEncrypt:i.symEncrypt,symDecrypt:i.symDecrypt,decodeHex:i.decodeHex,getValidSecret:i.getValidSecret,remove0x:i.remove0x}}(Ht);const Rs=f("KeyExchange:Layer"),Ps=f("SocketService:Layer"),Is=f("Ecies:Layer"),Ns=f("RemoteCommunication:Layer");Rs.color="##95c44e",Ps.color="#f638d7",Is.color="#465b9c",Ns.color="#47a2be";const Bs={KeyExchange:Rs,SocketService:Ps,Ecies:Is,RemoteCommunication:Ns};let Ds,$s=[],js=[];const Ks=(e,t)=>$e(void 0,void 0,void 0,(function*(){Ds=t,js.push(e),function(e){return $e(this,void 0,void 0,(function*(){if(!Ds||!e)return;!function(){const e=js;js=$s,$s=e}();const t=Ds.endsWith("/")?`${Ds}evt`:`${Ds}/evt`,n=Object.assign({},e);if(delete n.params,e.params)for(const[t,r]of Object.entries(e.params))n[t]=r;const r=JSON.stringify(n);Bs.RemoteCommunication(`[sendBufferedEvents] Sending ${$s.length} analytics events to ${t}`);try{const e=yield c(t,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:r}),n=yield e.text();Bs.RemoteCommunication(`[sendBufferedEvents] Response: ${n}`),$s.length=0}catch(t){}}))}(e).catch((()=>{}))}));class Us{constructor(e){this.enabled=!0,(null==e?void 0:e.debug)&&f.enable("Ecies:Layer"),this.ecies=(null==e?void 0:e.privateKey)?Ht.PrivateKey.fromHex(e.privateKey):new Ht.PrivateKey,Bs.Ecies("[ECIES constructor()] initialized secret: ",this.ecies.toHex()),Bs.Ecies("[ECIES constructor()] initialized public: ",this.ecies.publicKey.toHex()),Bs.Ecies("[ECIES constructor()] init with",this)}generateECIES(){this.ecies=new Ht.PrivateKey}getPublicKey(){return this.ecies.publicKey.toHex()}encrypt(e,t){let n=e;if(this.enabled)try{Bs.Ecies("[ECIES: encrypt()] using otherPublicKey",t);const r=et.from(e),i=Ht.encrypt(t,r);n=et.from(i).toString("base64")}catch(n){throw Bs.Ecies("[ECIES: encrypt()] error encrypt:",n),Bs.Ecies("[ECIES: encrypt()] private: ",this.ecies.toHex()),Bs.Ecies("[ECIES: encrypt()] data: ",e),Bs.Ecies("[ECIES: encrypt()] otherkey: ",t),n}return n}decrypt(e){let t=e;if(this.enabled)try{Bs.Ecies("[ECIES: decrypt()] using privateKey",this.ecies.toHex());const n=et.from(e.toString(),"base64");t=Ht.decrypt(this.ecies.toHex(),n).toString()}catch(t){throw Bs.Ecies("[ECIES: decrypt()] error decrypt",t),Bs.Ecies("[ECIES: decrypt()] private: ",this.ecies.toHex()),Bs.Ecies("[ECIES: decrypt()] encryptedData: ",e),t}return t}getKeyInfo(){return{private:this.ecies.toHex(),public:this.ecies.publicKey.toHex()}}toString(){Bs.Ecies("[ECIES: toString()]",this.getKeyInfo())}}var Fs={name:"@metamask/sdk-communication-layer",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk.git",directory:"packages/sdk-communication-layer"},main:"dist/node/cjs/metamask-sdk-communication-layer.js",unpkg:"dist/browser/umd/metamask-sdk-communication-layer.js",module:"dist/node/es/metamask-sdk-communication-layer.js",browser:"dist/browser/es/metamask-sdk-communication-layer.js","react-native":"dist/react-native/es/metamask-sdk-communication-layer.js",types:"dist/types/src/index.d.ts",files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types","build:clean":"yarn clean && yarn build",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs",dev:'concurrently "tsc --watch" "rollup -c --bundleConfigAsCjs -w"',"build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",size:"size-limit",clean:"rimraf ./dist",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk-communication-layer","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore","publish:preview":"yarn npm publish --tag preview",prepack:"../../scripts/prepack.sh",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:coverage":"jest --coverage","test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":"jest",watch:"rollup -c --bundleConfigAsCjs -w"},dependencies:{bufferutil:"^4.0.8","date-fns":"^2.29.3",debug:"^4.3.4","utf-8-validate":"^5.0.2",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@rollup/plugin-commonjs":"^25.0.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.4","@size-limit/preset-big-lib":"^11.0.2","@types/jest":"^29.2.4","@types/node":"^20.1.3","@types/uuid":"^9.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0",concurrently:"^9.1.2","cross-fetch":"^4.0.0",eciesjs:"^0.4.11",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0",eventemitter2:"^6.4.9",jest:"^29.3.1",prettier:"^2.3.0",rimraf:"^3.0.2",rollup:"^4.26.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-node-globals":"^1.4.0","rollup-plugin-peer-deps-external":"^2.2.4","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.1.6","socket.io-client":"^4.5.1","stream-browserify":"^3.0.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^5.6.3"},peerDependencies:{"cross-fetch":"^4.0.0",eciesjs:"*",eventemitter2:"^6.4.9","readable-stream":"^3.6.2","socket.io-client":"^4.5.1"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"@lavamoat/preinstall-always-fail":!1,canvas:!0,"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,bufferutil:!1,"utf-8-validate":!1}}};const Hs="https://metamask-sdk.api.cx.metamask.io/",zs=["websocket"],qs=6048e5,Vs=3e3,Ws={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",ETH_REQUESTACCOUNTS:"eth_requestAccounts"};function Gs(e){const{context:t}=e;Bs.RemoteCommunication(`[RemoteCommunication: clean()] context=${t}`),e.channelConfig=void 0,e.ready=!1,e.originatorConnectStarted=!1}var Ys,Zs,Js,Xs,Qs,ea,ta;(ta=Ys||(Ys={})).DISCONNECTED="disconnected",ta.WAITING="waiting",ta.TIMEOUT="timeout",ta.LINKED="linked",ta.PAUSED="paused",ta.TERMINATED="terminated",function(e){e.KEY_INFO="key_info",e.SERVICE_STATUS="service_status",e.PROVIDER_UPDATE="provider_update",e.RPC_UPDATE="rpc_update",e.KEYS_EXCHANGED="keys_exchanged",e.JOIN_CHANNEL="join_channel",e.PUBLIC_KEY="public_key",e.CHANNEL_CREATED="channel_created",e.CLIENTS_CONNECTED="clients_connected",e.CLIENTS_DISCONNECTED="clients_disconnected",e.CLIENTS_WAITING="clients_waiting",e.CLIENTS_READY="clients_ready",e.REJECTED="rejected",e.WALLET_INIT="wallet_init",e.CHANNEL_PERSISTENCE="channel_persistence",e.CONFIG="config",e.MESSAGE_ACK="ack",e.SOCKET_DISCONNECTED="socket_disconnected",e.SOCKET_RECONNECT="socket_reconnect",e.OTP="otp",e.SDK_RPC_CALL="sdk_rpc_call",e.AUTHORIZED="authorized",e.CONNECTION_STATUS="connection_status",e.MESSAGE="message",e.TERMINATE="terminate"}(Zs||(Zs={})),(Js||(Js={})).KEY_EXCHANGE="key_exchange",function(e){e.KEY_HANDSHAKE_START="key_handshake_start",e.KEY_HANDSHAKE_CHECK="key_handshake_check",e.KEY_HANDSHAKE_SYN="key_handshake_SYN",e.KEY_HANDSHAKE_SYNACK="key_handshake_SYNACK",e.KEY_HANDSHAKE_ACK="key_handshake_ACK",e.KEY_HANDSHAKE_WALLET="key_handshake_wallet",e.KEY_HANDSHAKE_NONE="none"}(Xs||(Xs={}));class na extends p.exports.EventEmitter2{constructor({communicationLayer:e,otherPublicKey:t,context:n,ecies:r,logging:i}){super(),this.keysExchanged=!1,this.step=Xs.KEY_HANDSHAKE_NONE,this.debug=!1,this.context=n,this.communicationLayer=e,(null==r?void 0:r.privateKey)&&t&&(Bs.KeyExchange(`[KeyExchange: constructor()] otherPubKey=${t} set keysExchanged to true!`,r),this.keysExchanged=!0),this.myECIES=new Us(Object.assign(Object.assign({},r),{debug:null==i?void 0:i.eciesLayer})),this.communicationLayer.state.eciesInstance=this.myECIES,this.myPublicKey=this.myECIES.getPublicKey(),this.debug=!0===(null==i?void 0:i.keyExchangeLayer),t&&this.setOtherPublicKey(t),this.communicationLayer.on(Js.KEY_EXCHANGE,this.onKeyExchangeMessage.bind(this))}onKeyExchangeMessage(e){const{relayPersistence:t}=this.communicationLayer.remote.state;if(Bs.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} keysExchanged=${this.keysExchanged} relayPersistence=${t}`,e),t)return void Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Ignoring key exchange message because relay persistence is activated");const{message:n}=e;this.keysExchanged&&Bs.KeyExchange(`[KeyExchange: onKeyExchangeMessage()] context=${this.context} received handshake while already exchanged. step=${this.step} otherPubKey=${this.otherPublicKey}`),this.emit(Zs.KEY_INFO,n.type),n.type===Xs.KEY_HANDSHAKE_SYN?(this.checkStep([Xs.KEY_HANDSHAKE_NONE,Xs.KEY_HANDSHAKE_ACK]),Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYN",n),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey}).catch((e=>{Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_SYNACK",e)})),this.setStep(Xs.KEY_HANDSHAKE_ACK)):n.type===Xs.KEY_HANDSHAKE_SYNACK?(this.checkStep([Xs.KEY_HANDSHAKE_SYNACK,Xs.KEY_HANDSHAKE_ACK,Xs.KEY_HANDSHAKE_NONE]),Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_SYNACK"),n.pubkey&&this.setOtherPublicKey(n.pubkey),this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_ACK}).catch((e=>{Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] Error sending KEY_HANDSHAKE_ACK",e)})),this.keysExchanged=!0,this.setStep(Xs.KEY_HANDSHAKE_ACK),this.emit(Zs.KEYS_EXCHANGED)):n.type===Xs.KEY_HANDSHAKE_ACK&&(Bs.KeyExchange("[KeyExchange: onKeyExchangeMessage()] KEY_HANDSHAKE_ACK set keysExchanged to true!"),this.checkStep([Xs.KEY_HANDSHAKE_ACK,Xs.KEY_HANDSHAKE_NONE]),this.keysExchanged=!0,this.setStep(Xs.KEY_HANDSHAKE_ACK),this.emit(Zs.KEYS_EXCHANGED))}resetKeys(e){this.clean(),this.myECIES=new Us(e)}clean(){Bs.KeyExchange(`[KeyExchange: clean()] context=${this.context} reset handshake state`),this.setStep(Xs.KEY_HANDSHAKE_NONE),this.emit(Zs.KEY_INFO,this.step),this.keysExchanged=!1}start({isOriginator:e,force:t}){const{relayPersistence:n,protocolVersion:r}=this.communicationLayer.remote.state,i=r>=2;n?Bs.KeyExchange("[KeyExchange: start()] Ignoring key exchange message because relay persistence is activated"):(Bs.KeyExchange(`[KeyExchange: start()] context=${this.context} protocolVersion=${r} isOriginator=${e} step=${this.step} force=${t} relayPersistence=${n} keysExchanged=${this.keysExchanged}`),e?!(this.keysExchanged||this.step!==Xs.KEY_HANDSHAKE_NONE&&this.step!==Xs.KEY_HANDSHAKE_SYNACK)||t?(Bs.KeyExchange(`[KeyExchange: start()] context=${this.context} -- start key exchange (force=${t}) -- step=${this.step}`,this.step),this.clean(),this.setStep(Xs.KEY_HANDSHAKE_SYNACK),this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_SYN,pubkey:this.myPublicKey,v:2}).catch((e=>{Bs.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYN",e)}))):Bs.KeyExchange(`[KeyExchange: start()] context=${this.context} -- key exchange already ${this.keysExchanged?"done":"in progress"} -- aborted.`,this.step):this.keysExchanged&&!0!==t?Bs.KeyExchange("[KeyExchange: start()] don't send KEY_HANDSHAKE_START -- exchange already done."):i?this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_SYNACK,pubkey:this.myPublicKey,v:2}).catch((e=>{Bs.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_SYNACK",e)})):(this.communicationLayer.sendMessage({type:Xs.KEY_HANDSHAKE_START}).catch((e=>{Bs.KeyExchange("[KeyExchange: start()] Error sending KEY_HANDSHAKE_START",e)})),this.clean()))}setStep(e){this.step=e,this.emit(Zs.KEY_INFO,e)}checkStep(e){e.length>0&&e.indexOf(this.step.toString())}setRelayPersistence({localKey:e,otherKey:t}){this.otherPublicKey=t,this.myECIES=new Us({privateKey:e,debug:this.debug}),this.keysExchanged=!0}setKeysExchanged(e){this.keysExchanged=e}areKeysExchanged(){return this.keysExchanged}getMyPublicKey(){return this.myPublicKey}getOtherPublicKey(){return this.otherPublicKey}setOtherPublicKey(e){Bs.KeyExchange("[KeyExchange: setOtherPubKey()]",e),this.otherPublicKey=e}encryptMessage(e){if(!this.otherPublicKey)throw new Error("encryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.encrypt(e,this.otherPublicKey)}decryptMessage(e){if(!this.otherPublicKey)throw new Error("decryptMessage: Keys not exchanged - missing otherPubKey");return this.myECIES.decrypt(e)}getKeyInfo(){return{ecies:Object.assign(Object.assign({},this.myECIES.getKeyInfo()),{otherPubKey:this.otherPublicKey}),step:this.step,keysExchanged:this.areKeysExchanged()}}toString(){const e={keyInfo:this.getKeyInfo(),keysExchanged:this.keysExchanged,step:this.step};return JSON.stringify(e)}}!function(e){e.TERMINATE="terminate",e.ANSWER="answer",e.OFFER="offer",e.CANDIDATE="candidate",e.JSONRPC="jsonrpc",e.WALLET_INFO="wallet_info",e.WALLET_INIT="wallet_init",e.ORIGINATOR_INFO="originator_info",e.PAUSE="pause",e.OTP="otp",e.AUTHORIZED="authorized",e.PING="ping",e.READY="ready"}(Qs||(Qs={})),function(e){e.REQUEST="sdk_connect_request_started",e.REQUEST_MOBILE="sdk_connect_request_started_mobile",e.RECONNECT="sdk_reconnect_request_started",e.CONNECTED="sdk_connection_established",e.CONNECTED_MOBILE="sdk_connection_established_mobile",e.AUTHORIZED="sdk_connection_authorized",e.REJECTED="sdk_connection_rejected",e.TERMINATED="sdk_connection_terminated",e.DISCONNECTED="sdk_disconnected",e.SDK_USE_EXTENSION="sdk_use_extension",e.SDK_RPC_REQUEST="sdk_rpc_request",e.SDK_RPC_REQUEST_RECEIVED="sdk_rpc_request_received",e.SDK_RPC_REQUEST_DONE="sdk_rpc_request_done",e.SDK_EXTENSION_UTILIZED="sdk_extension_utilized",e.SDK_USE_INAPP_BROWSER="sdk_use_inapp_browser"}(ea||(ea={}));const ra=(e,t,n)=>$e(void 0,void 0,void 0,(function*(){var r,i,o,s,a,c;const{remote:l,state:d}=e,{channelId:u,isOriginator:h}=d;if("error_terminated"===t)return Bs.SocketService(`handleJoinChannelResults: Channel ${u} terminated`),void e.emit(Zs.TERMINATE);if(!n)return void Bs.SocketService(`handleJoinChannelResults: No result for channel ${u}`);const{persistence:f,walletKey:p,rejected:g}=n;if(Bs.SocketService(`handleJoinChannelResults: Channel ${u} persistence=${f} walletKey=${p} rejected=${g}`),g)return Bs.SocketService(`handleJoinChannelResults: Channel ${u} rejected`),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Zs.REJECTED,{channelId:u}),void e.remote.emitServiceStatusEvent();if(p&&!(null===(r=l.state.channelConfig)||void 0===r?void 0:r.otherKey)){e.getKeyExchange().setOtherPublicKey(p),null===(i=e.state.keyExchange)||void 0===i||i.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Zs.AUTHORIZED);const{communicationLayer:t,storageManager:n}=l.state,r=Object.assign(Object.assign({},l.state.channelConfig),{channelId:null!==(o=l.state.channelId)&&void 0!==o?o:"",validUntil:Date.now()+qs,localKey:null==t?void 0:t.getKeyInfo().ecies.private,otherKey:p});e.sendMessage({type:Xs.KEY_HANDSHAKE_ACK}).catch((e=>{})),null===(s=e.state.socket)||void 0===s||s.emit(Qs.PING,{id:u,clientType:h?"dapp":"wallet",context:"on_channel_reconnect",message:""}),yield null==n?void 0:n.persistChannelConfig(r),l.emitServiceStatusEvent(),l.setConnectionStatus(Ys.LINKED)}f&&(e.emit(Zs.CHANNEL_PERSISTENCE),null===(a=e.state.keyExchange)||void 0===a||a.setKeysExchanged(!0),l.state.ready=!0,l.state.authorized=!0,l.emit(Zs.AUTHORIZED),Ks(Object.assign(Object.assign({id:null!=u?u:"",event:h?ea.CONNECTED:ea.CONNECTED_MOBILE},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Fs.version,walletVersion:null===(c=e.remote.state.walletInfo)||void 0===c?void 0:c.version}),d.communicationServerUrl).catch((e=>{})))})),ia=e=>new Promise((t=>{setTimeout(t,e)})),oa=(e,t,...n)=>$e(void 0,[e,t,...n],void 0,(function*(e,t,n=200){let r;const i=Date.now();let o=!1;for(;!o;){if(o=Date.now()-i>3e5,r=t[e],void 0!==r.elapsedTime)return r;yield ia(n)}throw new Error(`RPC ${e} timed out`)})),sa=e=>$e(void 0,void 0,void 0,(function*(){const{state:t}=e,{socket:n,channelId:r,context:i,isOriginator:o,isReconnecting:s}=t;if(s)return Bs.SocketService("[SocketService: reconnectSocket()] Reconnection already in progress, skipping",e),!1;if(!n)return Bs.SocketService("[SocketService: reconnectSocket()] socket is not defined",e),!1;if(!r)return!1;const{connected:a}=n;t.isReconnecting=!0,t.reconnectionAttempts=0,Bs.SocketService(`[SocketService: reconnectSocket()] connected=${a} trying to reconnect after socketio disconnection`,e);try{for(;3>t.reconnectionAttempts;){if(Bs.SocketService(`[SocketService: reconnectSocket()] Attempt ${t.reconnectionAttempts+1} of 3`,e),yield ia(200),n.connected)return Bs.SocketService("Socket already connected --- ping to retrieve messages"),n.emit(Qs.PING,{id:r,clientType:o?"dapp":"wallet",context:"on_channel_config",message:""}),!0;t.resumed=!0,n.connect(),e.emit(Zs.SOCKET_RECONNECT);try{if(yield new Promise(((t,s)=>{n.emit(Zs.JOIN_CHANNEL,{channelId:r,context:`${i}connect_again`,clientType:o?"dapp":"wallet"},((n,r)=>$e(void 0,void 0,void 0,(function*(){try{yield ra(e,n,r),t()}catch(e){s(e)}}))))})),yield ia(100),n.connected)return Bs.SocketService(`Reconnection successful on attempt ${t.reconnectionAttempts+1}`),!0}catch(e){Bs.SocketService(`Error during reconnection attempt ${t.reconnectionAttempts+1}:`,e)}t.reconnectionAttempts+=1,3>t.reconnectionAttempts&&(yield ia(200))}return Bs.SocketService("Failed to reconnect after 3 attempts"),!1}finally{t.isReconnecting=!1,t.reconnectionAttempts=0}}));function aa(e,t){return $e(this,void 0,void 0,(function*(){var n;const r=null===(n=e.state.keyExchange)||void 0===n?void 0:n.encryptMessage(JSON.stringify(t)),i={id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:r,plaintext:e.state.hasPlaintext?JSON.stringify(t):void 0};return Bs.SocketService(`[SocketService: encryptAndSendMessage()] context=${e.state.context}`,i),t.type===Qs.TERMINATE&&(e.state.manualDisconnect=!0),new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Zs.MESSAGE,i,((e,r)=>{var i;e&&(Bs.SocketService(`[SocketService: encryptAndSendMessage()] error=${e}`),n(e)),Bs.SocketService("[encryptAndSendMessage] response",r),t(null!==(i=null==r?void 0:r.success)&&void 0!==i&&i)}))}))}))}var ca;!function(e){e.RPC_CHECK="rpcCheck",e.SKIPPED_RPC="skippedRpc"}(ca||(ca={}));const la=["eth_sendTransaction","eth_signTypedData","eth_signTransaction","personal_sign","wallet_requestPermissions","wallet_switchEthereumChain","eth_signTypedData_v3","eth_signTypedData_v4","metamask_connectSign","metamask_connectWith","metamask_batch"].map((e=>e.toLowerCase())),da=[{event:Zs.CLIENTS_CONNECTED,handler:function(e,t){return n=>$e(this,void 0,void 0,(function*(){var n,r,i,o,s,a,c,l,d,u,h;const f=null!==(r=null===(n=e.remote.state.channelConfig)||void 0===n?void 0:n.relayPersistence)&&void 0!==r&&r;if(Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected-${t}' relayPersistence=${f} resumed=${e.state.resumed} clientsPaused=${e.state.clientsPaused} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()} isOriginator=${e.state.isOriginator}`),e.emit(Zs.CLIENTS_CONNECTED,{isOriginator:e.state.isOriginator,keysExchanged:null===(o=e.state.keyExchange)||void 0===o?void 0:o.areKeysExchanged(),context:e.state.context}),e.state.resumed)e.state.isOriginator||(Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} 'clients_connected' / keysExchanged=${null===(s=e.state.keyExchange)||void 0===s?void 0:s.areKeysExchanged()} -- backward compatibility`),null===(a=e.state.keyExchange)||void 0===a||a.start({isOriginator:null!==(c=e.state.isOriginator)&&void 0!==c&&c})),e.state.resumed=!1;else if(e.state.clientsPaused)Bs.SocketService("[SocketService: handleClientsConnected()] 'clients_connected' skip sending originatorInfo on pause");else if(!e.state.isOriginator){const t=!f;Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(l=e.state.keyExchange)||void 0===l?void 0:l.areKeysExchanged()} -- force=${t} -- backward compatibility`),Bs.SocketService(`[SocketService: handleClientsConnected()] context=${e.state.context} on 'clients_connected' / keysExchanged=${null===(d=e.state.keyExchange)||void 0===d?void 0:d.areKeysExchanged()} -- force=${t} -- backward compatibility`),null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h,force:t})}e.state.clientsConnected=!0,e.state.clientsPaused=!1}))}},{event:Zs.CHANNEL_CREATED,handler:function(e,t){return n=>{Bs.SocketService(`[SocketService: handleChannelCreated()] context=${e.state.context} on 'channel_created-${t}'`,n),e.emit(Zs.CHANNEL_CREATED,n)}}},{event:Zs.CLIENTS_DISCONNECTED,handler:function(e,t){return()=>{var n;e.state.clientsConnected=!1,Bs.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}'`),e.remote.state.relayPersistence?Bs.SocketService(`[SocketService: handlesClientsDisconnected()] context=${e.state.context} on 'clients_disconnected-${t}' - relayPersistence enabled, skipping key exchange cleanup.`):(e.state.isOriginator&&!e.state.clientsPaused&&(null===(n=e.state.keyExchange)||void 0===n||n.clean()),e.emit(Zs.CLIENTS_DISCONNECTED,t))}}},{event:Zs.CONFIG,handler:function(e,t){return n=>$e(this,void 0,void 0,(function*(){var r,i,o;Bs.SocketService(`[SocketService: handleChannelConfig()] update relayPersistence on 'config-${t}'`,n);const{persistence:s,walletKey:a}=n;e.state.isOriginator&&e.remote.state.channelConfig?(n.walletKey&&!e.remote.state.channelConfig.otherKey&&(Bs.SocketService(`Setting wallet key ${a}`),e.remote.state.channelConfig.otherKey=a,e.getKeyExchange().setOtherPublicKey(n.walletKey),null===(r=e.state.keyExchange)||void 0===r||r.setKeysExchanged(!0),yield e.remote.sendMessage({type:Xs.KEY_HANDSHAKE_ACK}),yield e.remote.sendMessage({type:Qs.PING}),yield null===(i=e.remote.state.storageManager)||void 0===i?void 0:i.persistChannelConfig(e.remote.state.channelConfig)),!0!==s||e.remote.state.channelConfig.relayPersistence||(Bs.SocketService(`Setting relay persistence ${s}`),e.remote.state.channelConfig.relayPersistence=s,e.remote.state.relayPersistence=!0,e.remote.emit(Zs.CHANNEL_PERSISTENCE),e.remote.state.authorized=!0,e.remote.state.ready=!0,e.remote.emit(Zs.AUTHORIZED),yield null===(o=e.remote.state.storageManager)||void 0===o?void 0:o.persistChannelConfig(e.remote.state.channelConfig))):e.state.isOriginator||n.persistence&&(e.remote.state.relayPersistence=!0,e.remote.emit(Zs.CHANNEL_PERSISTENCE))}))}},{event:Zs.MESSAGE,handler:function(e,t){return n=>{var r,i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w;const{ackId:E,message:C,error:_}=n,S=null!==(r=e.remote.state.relayPersistence)&&void 0!==r&&r;if(Bs.SocketService(`[SocketService handleMessage()] relayPersistence=${S} context=${e.state.context} on 'message' ${t} keysExchanged=${null===(i=e.state.keyExchange)||void 0===i?void 0:i.areKeysExchanged()}`,n),_)throw Bs.SocketService(`\n [SocketService handleMessage()] context=${e.state.context}::on 'message' error=${_}`),new Error(_);const k="string"==typeof C;if(!k&&(null==C?void 0:C.type)===Xs.KEY_HANDSHAKE_START){if(S)return;return Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received HANDSHAKE_START isOriginator=${e.state.isOriginator}`,C),void(null===(o=e.state.keyExchange)||void 0===o||o.start({isOriginator:null!==(s=e.state.isOriginator)&&void 0!==s&&s,force:!0}))}if(!k&&(null===(a=null==C?void 0:C.type)||void 0===a?void 0:a.startsWith("key_handshake"))){if(S)return;return Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' emit KEY_EXCHANGE`,C),void e.emit(Js.KEY_EXCHANGE,{message:C,context:e.state.context})}if(k&&!(null===(c=e.state.keyExchange)||void 0===c?void 0:c.areKeysExchanged())){let t=!1;try{Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' trying to decrypt message`),null===(l=e.state.keyExchange)||void 0===l||l.decryptMessage(C),t=!0}catch(t){Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' error`,t)}if(!t)return e.state.isOriginator?null===(u=e.state.keyExchange)||void 0===u||u.start({isOriginator:null!==(h=e.state.isOriginator)&&void 0!==h&&h}):e.sendMessage({type:Xs.KEY_HANDSHAKE_START}).catch((e=>{})),void Bs.SocketService(`Message ignored because invalid key exchange status. step=${null===(f=e.state.keyExchange)||void 0===f?void 0:f.getKeyInfo().step}`,null===(p=e.state.keyExchange)||void 0===p?void 0:p.getKeyInfo(),C);Bs.SocketService("Invalid key exchange status detected --- updating it."),null===(d=e.state.keyExchange)||void 0===d||d.setKeysExchanged(!0)}else if(!k&&(null==C?void 0:C.type))return void e.emit(Zs.MESSAGE,C);if(!k)return void e.emit(Zs.MESSAGE,C);const x=null===(g=e.state.keyExchange)||void 0===g?void 0:g.decryptMessage(C),A=JSON.parse(null!=x?x:"{}");if(E&&(null==E?void 0:E.length)>0&&(Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' ackid=${E} channelId=${t}`),null===(m=e.state.socket)||void 0===m||m.emit(Zs.MESSAGE_ACK,{ackId:E,channelId:t,clientType:e.state.isOriginator?"dapp":"wallet"})),e.state.clientsPaused=(null==A?void 0:A.type)===Qs.PAUSE,e.state.isOriginator&&A.data){const t=A.data,n=e.state.rpcMethodTracker[t.id];if(n){const r=Date.now()-n.timestamp;Bs.SocketService(`[SocketService handleMessage()] context=${e.state.context}::on 'message' received answer for id=${t.id} method=${n.method} responseTime=${r}`,A),e.remote.state.analytics&&la.includes(n.method.toLowerCase())&&Ks(Object.assign(Object.assign({id:null!==(y=e.remote.state.channelId)&&void 0!==y?y:"",event:ea.SDK_RPC_REQUEST_DONE,sdkVersion:e.remote.state.sdkVersion,commLayerVersion:Fs.version},e.remote.state.originatorInfo),{walletVersion:null===(v=e.remote.state.walletInfo)||void 0===v?void 0:v.version,params:{method:n.method,from:"mobile"}}),e.remote.state.communicationServerUrl).catch((e=>{}));const i=Object.assign(Object.assign({},n),{result:t.result,error:t.error?{code:null===(b=t.error)||void 0===b?void 0:b.code,message:null===(w=t.error)||void 0===w?void 0:w.message}:void 0,elapsedTime:r});e.state.rpcMethodTracker[t.id]=i,e.emit(Zs.RPC_UPDATE,i)}}e.emit(Zs.MESSAGE,{message:A})}}},{event:Zs.REJECTED,handler:function(e,t){return n=>$e(this,void 0,void 0,(function*(){var n;e.state.isOriginator&&!e.remote.state.ready?(Bs.SocketService(`[SocketService: handleChannelRejected()] context=${e.state.context} channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`,e.remote.state.originatorInfo),Ks(Object.assign(Object.assign({id:t,event:ea.REJECTED},e.remote.state.originatorInfo),{sdkVersion:e.remote.state.sdkVersion,commLayer:e.state.communicationLayerPreference,commLayerVersion:Fs.version,walletVersion:null===(n=e.remote.state.walletInfo)||void 0===n?void 0:n.version}),e.remote.state.communicationServerUrl).catch((e=>{})),yield e.remote.disconnect({terminate:!0}),e.remote.emit(Zs.REJECTED,{channelId:t}),e.remote.setConnectionStatus(Ys.DISCONNECTED)):Bs.SocketService(`[SocketService: handleChannelRejected()] SKIP -- channelId=${t} isOriginator=${e.state.isOriginator} ready=${e.remote.state.ready}`)}))}},{event:"clients_waiting_to_join",handler:function(e,t){return n=>{Bs.SocketService(`[SocketService: handleClientsWaitingToJoin()] context=${e.state.context} on 'clients_waiting_to_join-${t}'`,n),e.emit(Zs.CLIENTS_WAITING,n)}}}],ua=[{event:Zs.KEY_INFO,handler:function(e){return t=>{Bs.SocketService("[SocketService: handleKeyInfo()] on 'KEY_INFO'",t),e.emit(Zs.KEY_INFO,t)}}},{event:Zs.KEYS_EXCHANGED,handler:function(e){return()=>{var t,n,r;Bs.SocketService(`[SocketService: handleKeysExchanged()] on 'keys_exchanged' keyschanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`);const{channelConfig:i}=e.remote.state;if(i){const t=e.getKeyExchange().getKeyInfo().ecies;i.localKey=t.private,i.otherKey=t.otherPubKey,e.remote.state.channelConfig=i,null===(n=e.remote.state.storageManager)||void 0===n||n.persistChannelConfig(i).catch((e=>{}))}e.emit(Zs.KEYS_EXCHANGED,{keysExchanged:null===(r=e.state.keyExchange)||void 0===r?void 0:r.areKeysExchanged(),isOriginator:e.state.isOriginator});const o={keyInfo:e.getKeyInfo()};e.emit(Zs.SERVICE_STATUS,o)}}}];function ha(e,t){Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} setting socket listeners for channel ${t}...`);const{socket:n}=e.state,{keyExchange:r}=e.state;n&&e.state.isOriginator&&(e.state.debug&&(null==n||n.io.on("error",(t=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=error`,t)})),null==n||n.io.on("reconnect",(t=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect`,t),sa(e).catch((e=>{}))})),null==n||n.io.on("reconnect_error",(t=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_error`,t)})),null==n||n.io.on("reconnect_failed",(()=>{Bs.SocketService(`[SocketService: setupChannelListener()] context=${e.state.context} socket event=reconnect_failed`)}))),null==n||n.on("disconnect",(t=>(Bs.SocketService(`[SocketService: setupChannelListener()] on 'disconnect' -- MetaMaskSDK socket disconnected '${t}' begin recovery...`),function(e){return t=>{Bs.SocketService(`[SocketService: handleDisconnect()] on 'disconnect' manualDisconnect=${e.state.manualDisconnect}`,t),e.state.manualDisconnect||(e.emit(Zs.SOCKET_DISCONNECTED),sa(e).catch((e=>{})))}}(e)(t))))),da.forEach((({event:r,handler:i})=>{null==n||n.on(`${r}-${t}`,i(e,t))})),ua.forEach((({event:t,handler:n})=>{null==r||r.on(t,n(e))})),e.state.setupChannelListeners=!0}class fa extends p.exports.EventEmitter2{constructor(e){super(),this.state={clientsConnected:!1,clientsPaused:!1,manualDisconnect:!1,lastRpcId:void 0,rpcMethodTracker:{},hasPlaintext:!1,communicationServerUrl:"",focusListenerAdded:!1,removeFocusListener:void 0,isReconnecting:!1,reconnectionAttempts:0},this.options=e;const{reconnect:t,communicationLayerPreference:n,communicationServerUrl:r,context:i,remote:o,logging:s}=e;this.state.resumed=t,this.state.context=i,this.state.isOriginator=o.state.isOriginator,this.state.communicationLayerPreference=n,this.state.debug=!0===(null==s?void 0:s.serviceLayer),this.remote=o,!0===(null==s?void 0:s.serviceLayer)&&f.enable("SocketService:Layer"),this.state.communicationServerUrl=r,this.state.hasPlaintext=this.state.communicationServerUrl!==Hs&&!0===(null==s?void 0:s.plaintext),Bs.SocketService(`[SocketService: constructor()] Socket IO url: ${this.state.communicationServerUrl}`),this.initSocket()}initSocket(){var e;const{otherPublicKey:t,ecies:n,logging:r}=this.options,i={autoConnect:!1,transports:zs,withCredentials:!0},o=this.state.communicationServerUrl;Bs.SocketService(`[SocketService: initSocket()] Socket IO url: ${o}`),this.state.socket=De(o,i),function(e){if("undefined"!=typeof window&&"undefined"!=typeof document&&(Bs.SocketService(`[SocketService: setupSocketFocusListener()] hasFocus=${document.hasFocus()}`,e),!e.state.focusListenerAdded)){const t=()=>{Bs.SocketService("Document has focus --- reconnecting socket"),sa(e).catch((e=>{}))};window.addEventListener("focus",t),e.state.focusListenerAdded=!0,e.state.removeFocusListener=()=>{window.removeEventListener("focus",t),e.state.focusListenerAdded=!1}}}(this);const s={communicationLayer:this,otherPublicKey:t,sendPublicKey:!1,context:null!==(e=this.state.context)&&void 0!==e?e:"",ecies:n,logging:r};this.state.keyExchange=new na(s)}resetKeys(){return Bs.SocketService("[SocketService: resetKeys()] Resetting keys."),void(null===(e=this.state.keyExchange)||void 0===e||e.resetKeys());var e}createChannel(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n,i;if(Bs.SocketService(`[SocketService: createChannel()] context=${e.state.context}`),e.state.socket||e.initSocket(),null===(t=e.state.socket)||void 0===t?void 0:t.connected)throw new Error("socket already connected");null===(n=e.state.socket)||void 0===n||n.connect(),e.state.manualDisconnect=!1,e.state.isOriginator=!0;const o=r();e.state.channelId=o,ha(e,o),yield new Promise(((t,n)=>{var r;null===(r=e.state.socket)||void 0===r||r.emit(Zs.JOIN_CHANNEL,{channelId:o,context:`${e.state.context}createChannel`,clientType:"dapp"},((r,i)=>$e(this,void 0,void 0,(function*(){try{yield ra(e,r,i),t()}catch(e){n(e)}}))))}));const s=null===(i=e.state.keyExchange)||void 0===i?void 0:i.getKeyInfo();return{channelId:o,pubKey:(null==s?void 0:s.ecies.public)||"",privKey:(null==s?void 0:s.ecies.private)||""}}))}(this)}))}connectToChannel({channelId:e,withKeyExchange:t=!1,authorized:n}){return function(e){return $e(this,arguments,void 0,(function*({options:e,instance:t}){const{channelId:n,authorized:r,withKeyExchange:i}=e,{state:o,remote:s}=t,{isOriginator:a=!1,socket:c,keyExchange:l}=o,{channelConfig:d}=s.state;if(null==c?void 0:c.connected)throw new Error("socket already connected");if(a&&(null==d?void 0:d.relayPersistence)){const{localKey:e,otherKey:t}=d;e&&t&&(null==l||l.setRelayPersistence({localKey:e,otherKey:t}))}return Object.assign(o,{manualDisconnect:!1,withKeyExchange:i,isOriginator:a,channelId:n}),null==c||c.connect(),ha(t,n),!a&&r&&(null==l||l.setKeysExchanged(!0),Object.assign(s.state,{ready:!0,authorized:!0})),new Promise((e=>{var i;const s=null===(i=null==l?void 0:l.getKeyInfo())||void 0===i?void 0:i.ecies.public;null==c||c.emit(Zs.JOIN_CHANNEL,{channelId:n,context:`${o.context}_connectToChannel`,clientType:a?"dapp":"wallet",publicKey:r&&!a?s:void 0},((n,r)=>$e(this,void 0,void 0,(function*(){yield ra(t,n,r),e()}))))}))}))}({options:{channelId:e,withKeyExchange:t,authorized:n},instance:this})}getKeyInfo(){return this.state.keyExchange.getKeyInfo()}keyCheck(){var e,t;null===(t=(e=this).state.socket)||void 0===t||t.emit(Zs.MESSAGE,{id:e.state.channelId,context:e.state.context,message:{type:Xs.KEY_HANDSHAKE_CHECK,pubkey:e.getKeyInfo().ecies.otherPubKey}})}getKeyExchange(){return this.state.keyExchange}sendMessage(e){return $e(this,void 0,void 0,(function*(){return function(e,t){return $e(this,void 0,void 0,(function*(){var n,r,i;if(!e.state.channelId)throw Bs.SocketService("handleSendMessage: no channelId - Create a channel first"),new Error("Create a channel first");if(Bs.SocketService(`[SocketService: handleSendMessage()] context=${e.state.context} areKeysExchanged=${null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged()}`,t),null===(r=null==t?void 0:t.type)||void 0===r?void 0:r.startsWith("key_handshake"))return function(e,t){var n;Bs.SocketService(`[SocketService: handleKeyHandshake()] context=${e.state.context}`,t),null===(n=e.state.socket)||void 0===n||n.emit(Zs.MESSAGE,{id:e.state.channelId,context:e.state.context,clientType:e.state.isOriginator?"dapp":"wallet",message:t})}(e,t),!0;!function(e,t){var n;if(!(null===(n=e.state.keyExchange)||void 0===n?void 0:n.areKeysExchanged())&&!e.remote.state.relayPersistence)throw Bs.SocketService(`[SocketService: validateKeyExchange()] context=${e.state.context} ERROR keys not exchanged`,t),new Error("Keys not exchanged BBB")}(e,t),function(e,t){var n;const r=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"",i=null==t?void 0:t.id;e.state.isOriginator&&i&&(e.state.rpcMethodTracker[i]={id:i,timestamp:Date.now(),method:r},e.emit(Zs.RPC_UPDATE,e.state.rpcMethodTracker[i]))}(e,t);const o=yield aa(e,t);return e.remote.state.analytics&&e.remote.state.isOriginator&&t.method&&la.includes(t.method.toLowerCase())&&Ks({id:null!==(i=e.remote.state.channelId)&&void 0!==i?i:"",event:ea.SDK_RPC_REQUEST,params:{method:t.method,from:"mobile"}},e.remote.state.communicationServerUrl).catch((e=>{})),function(e,t){return $e(this,void 0,void 0,(function*(){var n;const r=null==t?void 0:t.id,i=null!==(n=null==t?void 0:t.method)&&void 0!==n?n:"";if(e.state.isOriginator&&r)try{const n=oa(r,e.state.rpcMethodTracker,200).then((e=>({type:ca.RPC_CHECK,result:e}))),o=(()=>$e(this,void 0,void 0,(function*(){const t=yield(e=>$e(void 0,[e],void 0,(function*({rpcId:e,instance:t}){for(;t.state.lastRpcId===e||void 0===t.state.lastRpcId;)yield ia(200);return t.state.lastRpcId})))({instance:e,rpcId:r}),n=yield oa(t,e.state.rpcMethodTracker,200);return{type:ca.SKIPPED_RPC,result:n}})))(),s=yield Promise.race([n,o]);if(s.type===ca.RPC_CHECK){const e=s.result;Bs.SocketService(`[SocketService:handleRpcReplies()] id=${t.id} ${i} ( ${e.elapsedTime} ms)`,e.result)}else{if(s.type!==ca.SKIPPED_RPC)throw new Error(`Error handling RPC replies for ${r}`);{const t=Object.assign(Object.assign({},e.state.rpcMethodTracker[r]),{error:new Error("SDK_CONNECTION_ISSUE")});e.emit(Zs.RPC_UPDATE,t);const n={data:Object.assign(Object.assign({},t),{jsonrpc:"2.0"}),name:"metamask-provider"};e.emit(Zs.MESSAGE,{message:n})}}}catch(e){throw e}}))}(e,t).catch((e=>{})),o}))}(this,e)}))}ping(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n;Bs.SocketService(`[SocketService: ping()] context=${e.state.context} originator=${e.state.isOriginator} keysExchanged=${null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged()}`),null===(n=e.state.socket)||void 0===n||n.emit(Qs.PING,{id:e.state.channelId,context:"ping",clientType:e.remote.state.isOriginator?"dapp":"wallet",message:""})}))}(this)}pause(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n;Bs.SocketService(`[SocketService: pause()] context=${e.state.context}`),e.state.manualDisconnect=!0,(null===(t=e.state.keyExchange)||void 0===t?void 0:t.areKeysExchanged())&&(yield e.sendMessage({type:Qs.PAUSE})),null===(n=e.state.socket)||void 0===n||n.disconnect()}))}(this)}isConnected(){var e;return null===(e=this.state.socket)||void 0===e?void 0:e.connected}resume(){return function(e){return $e(this,void 0,void 0,(function*(){const{state:t,remote:n}=e,{socket:r,channelId:i,context:o,keyExchange:s,isOriginator:a}=t,{isOriginator:c}=n.state;if(Bs.SocketService(`[SocketService: resume()] channelId=${i} context=${o} connected=${null==r?void 0:r.connected} manualDisconnect=${t.manualDisconnect} resumed=${t.resumed} keysExchanged=${null==s?void 0:s.areKeysExchanged()}`),!i)throw Bs.SocketService("[SocketService: resume()] channelId is not defined"),new Error("ChannelId is not defined");(null==r?void 0:r.connected)?(Bs.SocketService("[SocketService: resume()] already connected."),r.emit(Qs.PING,{id:i,clientType:c?"dapp":"wallet",context:"on_channel_config",message:""}),n.hasRelayPersistence()||(null==s?void 0:s.areKeysExchanged())||(a?yield e.sendMessage({type:Qs.READY}):null==s||s.start({isOriginator:!1}))):(null==r||r.connect(),Bs.SocketService(`[SocketService: resume()] after connecting socket --\x3e connected=${null==r?void 0:r.connected}`),null==r||r.emit(Zs.JOIN_CHANNEL,{channelId:i,context:`${o}_resume`,clientType:c?"dapp":"wallet"},((t,n)=>$e(this,void 0,void 0,(function*(){try{yield ra(e,t,n)}catch(e){}}))))),t.manualDisconnect=!1,t.resumed=!0}))}(this)}getRPCMethodTracker(){return this.state.rpcMethodTracker}disconnect(e){return function(e,t){var n,r,i,o,s;Bs.SocketService(`[SocketService: disconnect()] context=${e.state.context}`,t),(null==t?void 0:t.terminate)&&(null===(r=(n=e.state).removeFocusListener)||void 0===r||r.call(n),e.state.channelId=t.channelId,null===(i=e.state.socket)||void 0===i||i.removeAllListeners(),null===(o=e.state.keyExchange)||void 0===o||o.clean(),e.remote.state.ready=!1,e.state.socket=void 0,e.state.rpcMethodTracker={}),e.state.manualDisconnect=!0,null===(s=e.state.socket)||void 0===s||s.disconnect()}(this,e)}}var pa,ga,ma;function ya(e){return()=>$e(this,void 0,void 0,(function*(){var t,n,r;const{state:i}=e;if(i.authorized)return;yield(()=>$e(this,void 0,void 0,(function*(){for(;!i.walletInfo;)yield ia(500)})))();const o="7.3".localeCompare((null===(t=i.walletInfo)||void 0===t?void 0:t.version)||"");if(Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' version=${null===(n=i.walletInfo)||void 0===n?void 0:n.version} compareValue=${o}`),1!==o)return;const s=i.platformType===ga.MobileWeb||i.platformType===ga.ReactNative||i.platformType===ga.MetaMaskMobileWebview;Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorizedEvent()] HACK 'authorized' platform=${i.platformType} secure=${s} channel=${i.channelId} walletVersion=${null===(r=i.walletInfo)||void 0===r?void 0:r.version}`),s&&(i.authorized=!0,e.emit(Zs.AUTHORIZED))}))}function va(e){return t=>{const{state:n}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleChannelCreatedEvent()] context=${n.context} on 'channel_created' channelId=${t}`),e.emit(Zs.CHANNEL_CREATED,t)}}function ba(e,t){return()=>{var n,r,i,o;const{state:s}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleClientsConnectedEvent()] on 'clients_connected' channel=${s.channelId} keysExchanged=${null===(r=null===(n=s.communicationLayer)||void 0===n?void 0:n.getKeyInfo())||void 0===r?void 0:r.keysExchanged}`),s.analytics&&Ks(Object.assign(Object.assign({id:null!==(i=s.channelId)&&void 0!==i?i:"",event:s.reconnection?ea.RECONNECT:s.isOriginator?ea.REQUEST:ea.REQUEST_MOBILE},s.originatorInfo),{commLayer:t,sdkVersion:s.sdkVersion,walletVersion:null===(o=s.walletInfo)||void 0===o?void 0:o.version,commLayerVersion:Fs.version}),s.communicationServerUrl).catch((e=>{})),s.clientsConnected=!0,s.originatorInfoSent=!1,e.emit(Zs.CLIENTS_CONNECTED)}}function wa(e){return t=>{const{state:n}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleClientsDisconnectedEvent()] context=${n.context} on 'clients_disconnected' channelId=${t}`),n.relayPersistence||(n.clientsConnected=!1,n.ready=!1,n.authorized=!1),e.emit(Zs.CLIENTS_DISCONNECTED,n.channelId),e.setConnectionStatus(Ys.DISCONNECTED)}}function Ea(e){return t=>{var n;const{state:r}=e;if(Bs.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] context=${r.context} on 'clients_waiting' numberUsers=${t} ready=${r.ready} autoStarted=${r.originatorConnectStarted}`),e.setConnectionStatus(Ys.WAITING),e.emit(Zs.CLIENTS_WAITING,t),r.originatorConnectStarted){Bs.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] on 'clients_waiting' watch autoStarted=${r.originatorConnectStarted} timeout`,r.autoConnectOptions);const t=(null===(n=r.autoConnectOptions)||void 0===n?void 0:n.timeout)||3e3,i=setTimeout((()=>{Bs.RemoteCommunication(`[RemoteCommunication: handleClientsWaitingEvent()] setTimeout(${t}) terminate channelConfig`,r.autoConnectOptions),r.originatorConnectStarted=!1,r.ready||e.setConnectionStatus(Ys.TIMEOUT),clearTimeout(i)}),t)}}}function Ca(e,t){return n=>{var r,i,o,s,a,c,l,d;const{state:u}=e;if(Bs.RemoteCommunication(`[RemoteCommunication: handleKeysExchangedEvent()] context=${u.context} on commLayer.'keys_exchanged' channel=${u.channelId}`,n),null===(i=null===(r=u.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.keysExchanged){const t=Object.assign(Object.assign({},u.channelConfig),{channelId:null!==(o=u.channelId)&&void 0!==o?o:"",validUntil:(null===(s=u.channelConfig)||void 0===s?void 0:s.validUntil)||qs,localKey:u.communicationLayer.getKeyInfo().ecies.private,otherKey:u.communicationLayer.getKeyInfo().ecies.otherPubKey});null===(a=u.storageManager)||void 0===a||a.persistChannelConfig(t).catch((e=>{})),e.setConnectionStatus(Ys.LINKED)}!function(e,t){var n,r,i,o,s,a,c,l;const{state:d}=e;Bs.RemoteCommunication(`[RemoteCommunication: setLastActiveDate()] channel=${d.channelId}`,t);const u=Object.assign(Object.assign({},d.channelConfig),{channelId:null!==(n=d.channelId)&&void 0!==n?n:"",validUntil:null!==(i=null===(r=d.channelConfig)||void 0===r?void 0:r.validUntil)&&void 0!==i?i:0,relayPersistence:d.relayPersistence,localKey:null===(s=null===(o=d.communicationLayer)||void 0===o?void 0:o.state.keyExchange)||void 0===s?void 0:s.getKeyInfo().ecies.private,otherKey:null===(c=null===(a=d.communicationLayer)||void 0===a?void 0:a.state.keyExchange)||void 0===c?void 0:c.getKeyInfo().ecies.otherPubKey,lastActive:t.getTime()});null===(l=d.storageManager)||void 0===l||l.persistChannelConfig(u)}(e,new Date),u.analytics&&u.channelId&&Ks(Object.assign(Object.assign({id:u.channelId,event:n.isOriginator?ea.CONNECTED:ea.CONNECTED_MOBILE},u.originatorInfo),{sdkVersion:u.sdkVersion,commLayer:t,commLayerVersion:Fs.version,walletVersion:null===(c=u.walletInfo)||void 0===c?void 0:c.version}),u.communicationServerUrl).catch((e=>{})),u.isOriginator=n.isOriginator,n.isOriginator||(null===(l=u.communicationLayer)||void 0===l||l.sendMessage({type:Qs.READY}),u.ready=!0,u.paused=!1),n.isOriginator&&!u.originatorInfoSent&&(null===(d=u.communicationLayer)||void 0===d||d.sendMessage({type:Qs.ORIGINATOR_INFO,originatorInfo:u.originatorInfo,originator:u.originatorInfo}),u.originatorInfoSent=!0)}}function _a(e){return t=>{let n=t;t.message&&(n=n.message),function(e,t){const{state:n}=t;if(Bs.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] context=${n.context} on 'message' typeof=${typeof e}`,e),t.state.ready=!0,n.isOriginator||e.type!==Qs.ORIGINATOR_INFO)if(n.isOriginator&&e.type===Qs.WALLET_INFO)!function(e,t){const{state:n}=e;n.walletInfo=t.walletInfo,n.paused=!1}(t,e);else{if(n.isOriginator&&e.type===Qs.WALLET_INIT)(function(e,t){return $e(this,void 0,void 0,(function*(){var n,r,i;const{state:o}=e;if(o.isOriginator){const o=t.data||{};if("object"==typeof o&&"accounts"in o&&"chainId"in o&&"walletKey"in o)try{const{channelConfig:t}=e.state;if(Bs.RemoteCommunication("WALLET_INIT: channelConfig",JSON.stringify(t,null,2)),t){const s=o.accounts,a=o.chainId,c=o.walletKey;let l,d=!1;"deeplinkProtocol"in o&&(d=Boolean(o.deeplinkProtocol),e.state.deeplinkProtocolAvailable=d),"walletVersion"in o&&(l=o.walletVersion),yield null===(n=e.state.storageManager)||void 0===n?void 0:n.persistChannelConfig(Object.assign(Object.assign({},t),{otherKey:c,walletVersion:l,deeplinkProtocolAvailable:d,relayPersistence:!0})),yield null===(r=e.state.storageManager)||void 0===r?void 0:r.persistAccounts(s),yield null===(i=e.state.storageManager)||void 0===i?void 0:i.persistChainId(a)}e.emit(Zs.WALLET_INIT,{accounts:o.accounts,chainId:o.chainId})}catch(n){}}}))})(t,e).catch((e=>{Bs.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Qs.TERMINATE)(function(e){return $e(this,void 0,void 0,(function*(){const{state:t}=e;t.isOriginator&&(yield Ma({options:{terminate:!0,sendMessage:!1},instance:e}),e.emit(Zs.TERMINATE))}))})(t).catch((e=>{Bs.RemoteCommunication(`[RemoteCommunication: onCommunicationLayerMessage()] error=${e}`)}));else if(e.type===Qs.PAUSE)!function(e){const{state:t}=e;t.paused=!0,e.setConnectionStatus(Ys.PAUSED)}(t);else if(e.type===Qs.READY&&n.isOriginator)!function(e){const{state:t}=e;e.setConnectionStatus(Ys.LINKED);const n=t.paused;t.paused=!1,e.emit(Zs.CLIENTS_READY,{isOriginator:t.isOriginator,walletInfo:t.walletInfo}),n&&(t.authorized=!0,e.emit(Zs.AUTHORIZED))}(t);else{if(e.type===Qs.OTP&&n.isOriginator)return void function(e,t){var n;const{state:r}=e;e.emit(Zs.OTP,t.otpAnswer),1==="6.6".localeCompare((null===(n=r.walletInfo)||void 0===n?void 0:n.version)||"")&&e.emit(Zs.SDK_RPC_CALL,{method:Ws.ETH_REQUESTACCOUNTS,params:[]})}(t,e);e.type===Qs.AUTHORIZED&&n.isOriginator&&function(e){const{state:t}=e;t.authorized=!0,e.emit(Zs.AUTHORIZED)}(t)}t.emit(Zs.MESSAGE,e)}else!function(e,t){var n;const{state:r}=e;null===(n=r.communicationLayer)||void 0===n||n.sendMessage({type:Qs.WALLET_INFO,walletInfo:r.walletInfo}),r.originatorInfo=t.originatorInfo||t.originator,e.emit(Zs.CLIENTS_READY,{isOriginator:r.isOriginator,originatorInfo:r.originatorInfo}),r.paused=!1}(t,e)}(n,e)}}function Sa(e){return()=>{const{state:t}=e;Bs.RemoteCommunication("[RemoteCommunication: handleSocketReconnectEvent()] on 'socket_reconnect' -- reset key exchange status / set ready to false"),t.ready=!1,t.authorized=!1,Gs(t),e.emitServiceStatusEvent({context:"socket_reconnect"})}}function ka(e){return()=>{const{state:t}=e;Bs.RemoteCommunication("[RemoteCommunication: handleSocketDisconnectedEvent()] on 'socket_Disconnected' set ready to false"),t.ready=!1}}function xa(e){return()=>$e(this,void 0,void 0,(function*(){var t,n,r,i,o,s,a;const{state:c}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleFullPersistenceEvent()] context=${c.context}`),e.state.ready=!0,e.state.clientsConnected=!0,e.state.authorized=!0,e.state.relayPersistence=!0,null===(t=e.state.communicationLayer)||void 0===t||t.getKeyExchange().setKeysExchanged(!0),e.emit(Zs.KEYS_EXCHANGED,{keysExchanged:!0,isOriginator:!0}),e.emit(Zs.AUTHORIZED),e.emit(Zs.CLIENTS_READY),e.emit(Zs.CHANNEL_PERSISTENCE);try{c.channelConfig=Object.assign(Object.assign({},c.channelConfig),{localKey:null===(n=c.communicationLayer)||void 0===n?void 0:n.getKeyExchange().getKeyInfo().ecies.private,otherKey:null===(r=c.communicationLayer)||void 0===r?void 0:r.getKeyExchange().getOtherPublicKey(),channelId:null!==(i=c.channelId)&&void 0!==i?i:"",validUntil:null!==(s=null===(o=c.channelConfig)||void 0===o?void 0:o.validUntil)&&void 0!==s?s:qs,relayPersistence:!0}),yield null===(a=c.storageManager)||void 0===a?void 0:a.persistChannelConfig(c.channelConfig)}catch(t){}}))}function Aa({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,ecies:r,communicationServerUrl:i=Hs,instance:o}){var s,a,c,l,d,u,h,f,p,g,m;const{state:y}=o;if(Bs.RemoteCommunication("[initCommunicationLayer()] ",JSON.stringify(y,null,2)),e!==pa.SOCKET)throw new Error("Invalid communication protocol");y.communicationLayer=new fa({communicationLayerPreference:e,otherPublicKey:t,reconnect:n,transports:y.transports,communicationServerUrl:i,context:y.context,ecies:r,logging:y.logging,remote:o});let v="undefined"!=typeof document&&document.URL||"",b="undefined"!=typeof document&&document.title||"";(null===(s=y.dappMetadata)||void 0===s?void 0:s.url)&&(v=y.dappMetadata.url),(null===(a=y.dappMetadata)||void 0===a?void 0:a.name)&&(b=y.dappMetadata.name);const w=null!==(u=null!==(l=null===(c=y.dappMetadata)||void 0===c?void 0:c.name)&&void 0!==l?l:null===(d=y.dappMetadata)||void 0===d?void 0:d.url)&&void 0!==u?u:"N/A",E="undefined"!=typeof window&&void 0!==window.location&&null!==(h=window.location.hostname)&&void 0!==h?h:w,C={url:v,title:b,source:null===(f=y.dappMetadata)||void 0===f?void 0:f.source,dappId:E,icon:(null===(p=y.dappMetadata)||void 0===p?void 0:p.iconUrl)||(null===(g=y.dappMetadata)||void 0===g?void 0:g.base64Icon),platform:y.platformType,apiVersion:Fs.version,connector:null===(m=y.dappMetadata)||void 0===m?void 0:m.connector};y.originatorInfo=C;const _={[Zs.AUTHORIZED]:ya(o),[Zs.MESSAGE]:_a(o),[Zs.CHANNEL_PERSISTENCE]:xa(o),[Zs.CLIENTS_CONNECTED]:ba(o,e),[Zs.KEYS_EXCHANGED]:Ca(o,e),[Zs.SOCKET_DISCONNECTED]:ka(o),[Zs.SOCKET_RECONNECT]:Sa(o),[Zs.CLIENTS_DISCONNECTED]:wa(o),[Zs.KEY_INFO]:()=>{},[Zs.CHANNEL_CREATED]:va(o),[Zs.CLIENTS_WAITING]:Ea(o),[Zs.RPC_UPDATE]:e=>{o.emit(Zs.RPC_UPDATE,e)}};for(const[t,n]of Object.entries(_))try{y.communicationLayer.on(t,n)}catch(e){}}function Ma(e){return $e(this,arguments,void 0,(function*({options:e,instance:t}){const{state:n}=t;return Bs.RemoteCommunication(`[RemoteCommunication: disconnect()] channel=${n.channelId}`,e),new Promise(((i,o)=>{var s,a,c,l,d,u;(null==e?void 0:e.terminate)?(t.state.ready&&Ks({id:null!==(s=t.state.channelId)&&void 0!==s?s:"",event:ea.TERMINATED},t.state.communicationServerUrl).catch((e=>{})),n.ready=!1,n.paused=!1,null===(a=n.storageManager)||void 0===a||a.terminate(null!==(c=n.channelId)&&void 0!==c?c:""),t.state.terminated=!0,e.sendMessage?(null===(l=n.communicationLayer)||void 0===l?void 0:l.getKeyInfo().keysExchanged)&&t.state.communicationLayer&&aa(t.state.communicationLayer,{type:Qs.TERMINATE}).then((()=>{i(!0)})).catch((e=>{o(e)})):i(!0),n.authorized=!1,n.relayPersistence=!1,n.channelId=r(),e.channelId=n.channelId,n.channelConfig=void 0,n.originatorConnectStarted=!1,null===(d=n.communicationLayer)||void 0===d||d.disconnect(e),t.setConnectionStatus(Ys.TERMINATED)):(null===(u=n.communicationLayer)||void 0===u||u.disconnect(e),t.setConnectionStatus(Ys.DISCONNECTED),i(!0))}))}))}(pa||(pa={})).SOCKET="socket",function(e){e.NonBrowser="nodejs",e.MetaMaskMobileWebview="in-app-browser",e.DesktopWeb="web-desktop",e.MobileWeb="web-mobile",e.ReactNative="react-native"}(ga||(ga={}));class La extends p.exports.EventEmitter2{constructor(e){super(),this.state={ready:!1,authorized:!1,isOriginator:!1,terminated:!1,protocolVersion:1,paused:!1,deeplinkProtocolAvailable:!1,platformType:"metamask-mobile",analytics:!1,reconnection:!1,originatorInfoSent:!1,communicationServerUrl:Hs,context:"",persist:!1,clientsConnected:!1,sessionDuration:qs,originatorConnectStarted:!1,debug:!1,_connectionStatus:Ys.DISCONNECTED},this._options=e;const{platformType:t,communicationLayerPreference:n,otherPublicKey:r,reconnect:i,walletInfo:o,dappMetadata:s,protocolVersion:a,transports:c,context:l,relayPersistence:d,ecies:u,analytics:h=!1,storage:p,sdkVersion:g,communicationServerUrl:m=Hs,logging:y,autoConnect:v={timeout:Vs}}=e;this.state.otherPublicKey=r,this.state.dappMetadata=s,this.state.walletInfo=o,this.state.transports=c,this.state.platformType=t,this.state.analytics=h,this.state.protocolVersion=null!=a?a:1,this.state.isOriginator=!r,this.state.relayPersistence=d,this.state.communicationServerUrl=m,this.state.context=l,this.state.terminated=!1,this.state.sdkVersion=g,this.setMaxListeners(50),this.setConnectionStatus(Ys.DISCONNECTED),(null==p?void 0:p.duration)&&(this.state.sessionDuration=qs),this.state.storageOptions=p,this.state.autoConnectOptions=v,this.state.debug=!0===(null==y?void 0:y.remoteLayer),!0===(null==y?void 0:y.remoteLayer)&&f.enable("RemoteCommunication:Layer"),!0===(null==y?void 0:y.serviceLayer)&&f.enable("SocketService:Layer"),!0===(null==y?void 0:y.eciesLayer)&&f.enable("ECIES:Layer"),!0===(null==y?void 0:y.keyExchangeLayer)&&f.enable("KeyExchange:Layer"),this.state.logging=y,(null==p?void 0:p.storageManager)&&(this.state.storageManager=p.storageManager),Bs.RemoteCommunication(`[RemoteCommunication: constructor()] protocolVersion=${a} relayPersistence=${d} isOriginator=${this.state.isOriginator} communicationLayerPreference=${n} otherPublicKey=${r} reconnect=${i}`),this.state.isOriginator||Aa({communicationLayerPreference:n,otherPublicKey:r,reconnect:i,ecies:u,communicationServerUrl:m,instance:this}),this.emitServiceStatusEvent({context:"constructor"})}initFromDappStorage(){return $e(this,void 0,void 0,(function*(){var e;if(this.state.storageManager){const t=yield this.state.storageManager.getPersistedChannelConfig({});t&&(this.state.channelConfig=t,this.state.channelId=t.channelId,this.state.deeplinkProtocolAvailable=null!==(e=t.deeplinkProtocolAvailable)&&void 0!==e&&e,t.relayPersistence&&(this.state.authorized=!0,this.state.ready=!0,this.setConnectionStatus(Ys.LINKED),yield this.connectToChannel({channelId:t.channelId})))}Aa({communicationLayerPreference:pa.SOCKET,otherPublicKey:this.state.otherPublicKey,reconnect:this._options.reconnect,ecies:this._options.ecies,communicationServerUrl:this.state.communicationServerUrl,instance:this})}))}originatorSessionConnect(){return $e(this,void 0,void 0,(function*(){return yield function(e){return $e(this,void 0,void 0,(function*(){var t;const{state:n}=e;if(!n.storageManager)return void Bs.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] no storage manager defined - skip");const r=yield n.storageManager.getPersistedChannelConfig({});if(Bs.RemoteCommunication(`[RemoteCommunication: originatorSessionConnect()] autoStarted=${n.originatorConnectStarted} channelConfig`,r),null===(t=n.communicationLayer)||void 0===t?void 0:t.isConnected())return Bs.RemoteCommunication("[RemoteCommunication: originatorSessionConnect()] socket already connected - skip"),r;if(r){if(r.validUntil>Date.now())return n.channelConfig=r,n.originatorConnectStarted=!0,n.channelId=null==r?void 0:r.channelId,n.reconnection=!0,r;Bs.RemoteCommunication("[RemoteCommunication: autoConnect()] Session has expired")}n.originatorConnectStarted=!1}))}(this)}))}generateChannelIdConnect(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t,n,r,i,o,s;if(!e.communicationLayer)throw new Error("communication layer not initialized");if(e.ready)throw new Error("Channel already connected");if(e.channelId&&(null===(t=e.communicationLayer)||void 0===t?void 0:t.isConnected()))return e.channelConfig=Object.assign(Object.assign({},e.channelConfig),{channelId:e.channelId,validUntil:Date.now()+e.sessionDuration}),null===(n=e.storageManager)||void 0===n||n.persistChannelConfig(e.channelConfig),{channelId:e.channelId,privKey:null===(i=null===(r=e.communicationLayer)||void 0===r?void 0:r.getKeyInfo())||void 0===i?void 0:i.ecies.private,pubKey:null===(s=null===(o=e.communicationLayer)||void 0===o?void 0:o.getKeyInfo())||void 0===s?void 0:s.ecies.public};Bs.RemoteCommunication("[RemoteCommunication: generateChannelId()]");const a=yield e.communicationLayer.createChannel();Bs.RemoteCommunication("[RemoteCommunication: generateChannelId()] channel created",a);const c=Object.assign(Object.assign({},e.channelConfig),{channelId:a.channelId,localKey:a.privKey,validUntil:Date.now()+e.sessionDuration});return e.channelId=a.channelId,e.channelConfig=c,{channelId:e.channelId,pubKey:a.pubKey,privKey:a.privKey}}))}(this.state)}))}clean(){return Gs(this.state)}connectToChannel({channelId:e,withKeyExchange:t,authorized:n}){return function(e){return $e(this,arguments,void 0,(function*({channelId:e,withKeyExchange:t,authorized:n,state:r}){var o,s,a;if(!i(e))throw Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} channelId=${e} withKeyExchange=${t}`),null===(o=r.communicationLayer)||void 0===o?void 0:o.isConnected())return void Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${r.context} already connected - interrupt connection.`);r.channelId=e,yield null===(s=r.communicationLayer)||void 0===s?void 0:s.connectToChannel({channelId:e,authorized:n,withKeyExchange:t});const c=Object.assign(Object.assign({},r.channelConfig),{channelId:e,validUntil:Date.now()+r.sessionDuration});r.channelConfig=c,null===(a=r.storageManager)||void 0===a||a.persistChannelConfig(c)}))}({channelId:e,authorized:n,withKeyExchange:t,state:this.state})}sendMessage(e){return function(e,t){return $e(this,void 0,void 0,(function*(){var n,r;const{state:i}=e;Bs.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} paused=${i.paused} ready=${i.ready} relayPersistence=${i.relayPersistence} authorized=${i.authorized} socket=${null===(n=i.communicationLayer)||void 0===n?void 0:n.isConnected()} clientsConnected=${i.clientsConnected} status=${i._connectionStatus}`,t),i.relayPersistence||i.ready&&(null===(r=i.communicationLayer)||void 0===r?void 0:r.isConnected())&&i.clientsConnected||(Bs.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} SKIP message waiting for MM mobile readiness.`),yield new Promise((t=>{e.once(Zs.CLIENTS_READY,t)})),Bs.RemoteCommunication(`[RemoteCommunication: sendMessage()] context=${i.context} AFTER SKIP / READY -- sending pending message`));try{const n=yield function(e,t){return $e(this,void 0,void 0,(function*(){return new Promise((n=>{var r;const{state:i}=e;Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} ready=${i.ready} authorized=${i.authorized} method=${t.method}`),!i.isOriginator||i.authorized||i.relayPersistence?null===(r=i.communicationLayer)||void 0===r||r.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)})):e.once(Zs.AUTHORIZED,(()=>{var e;Bs.RemoteCommunication(`[RemoteCommunication: handleAuthorization()] context=${i.context} AFTER SKIP / AUTHORIZED -- sending pending message`),null===(e=i.communicationLayer)||void 0===e||e.sendMessage(t).then((e=>{n(e)})).catch((e=>{n(!1)}))}))}))}))}(e,t);return n}catch(e){throw e}}))}(this,e)}testStorage(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t;const n=yield null===(t=e.storageManager)||void 0===t?void 0:t.getPersistedChannelConfig();Bs.RemoteCommunication("[RemoteCommunication: testStorage()] res",n)}))}(this.state)}))}hasDeeplinkProtocol(){return this.state.deeplinkProtocolAvailable}getChannelConfig(){return this.state.channelConfig}isReady(){return this.state.ready}isConnected(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.isConnected()}isAuthorized(){return this.state.authorized}isPaused(){return this.state.paused}getCommunicationLayer(){return this.state.communicationLayer}ping(){return $e(this,void 0,void 0,(function*(){var e;Bs.RemoteCommunication(`[RemoteCommunication: ping()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.ping()}))}testLogger(){Bs.RemoteCommunication(`testLogger() channel=${this.state.channelId}`),Bs.SocketService(`testLogger() channel=${this.state.channelId}`),Bs.Ecies(`testLogger() channel=${this.state.channelId}`),Bs.KeyExchange(`testLogger() channel=${this.state.channelId}`)}keyCheck(){var e;Bs.RemoteCommunication(`[RemoteCommunication: keyCheck()] channel=${this.state.channelId}`),null===(e=this.state.communicationLayer)||void 0===e||e.keyCheck()}setConnectionStatus(e){this.state._connectionStatus!==e&&(this.state._connectionStatus=e,this.emit(Zs.CONNECTION_STATUS,e),this.emitServiceStatusEvent({context:"setConnectionStatus"}))}emitServiceStatusEvent(e={}){this.emit(Zs.SERVICE_STATUS,this.getServiceStatus())}getConnectionStatus(){return this.state._connectionStatus}getServiceStatus(){return{originatorInfo:this.state.originatorInfo,keyInfo:this.getKeyInfo(),connectionStatus:this.state._connectionStatus,channelConfig:this.state.channelConfig,channelId:this.state.channelId}}getKeyInfo(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getKeyInfo()}resetKeys(){var e;null===(e=this.state.communicationLayer)||void 0===e||e.resetKeys()}setOtherPublicKey(e){var t;const n=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange();if(!n)throw new Error("KeyExchange is not initialized.");n.getOtherPublicKey()!==e&&n.setOtherPublicKey(e)}pause(){return $e(this,void 0,void 0,(function*(){var e;Bs.RemoteCommunication(`[RemoteCommunication: pause()] channel=${this.state.channelId}`),yield null===(e=this.state.communicationLayer)||void 0===e?void 0:e.pause(),this.setConnectionStatus(Ys.PAUSED)}))}getVersion(){return Fs.version}hasRelayPersistence(){var e;return null!==(e=this.state.relayPersistence)&&void 0!==e&&e}resume(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){var t;const{state:n}=e;Bs.RemoteCommunication(`[RemoteCommunication: resume()] channel=${n.channelId}`),yield null===(t=n.communicationLayer)||void 0===t?void 0:t.resume(),e.setConnectionStatus(Ys.LINKED)}))}(this)}))}encrypt(e){var t,n,r;const i=null===(t=this.state.communicationLayer)||void 0===t?void 0:t.getKeyExchange(),o=null==i?void 0:i.getOtherPublicKey();if(!o)throw new Error("KeyExchange not completed");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.encrypt(e,o)}decrypt(e){var t,n,r;if(!(null===(t=this.state.communicationLayer)||void 0===t?void 0:t.state.eciesInstance))throw new Error("ECIES instance is not initialized");return null===(r=null===(n=this.state.communicationLayer)||void 0===n?void 0:n.state.eciesInstance)||void 0===r?void 0:r.decrypt(e)}getChannelId(){return this.state.channelId}getRPCMethodTracker(){var e;return null===(e=this.state.communicationLayer)||void 0===e?void 0:e.getRPCMethodTracker()}reject({channelId:e}){return function(e){return $e(this,arguments,void 0,(function*({channelId:e,state:t}){var n,r,o;if(!i(e))throw Bs.RemoteCommunication(`[RemoteCommunication: connectToChannel()] context=${t.context} invalid channel channelId=${e}`),new Error(`Invalid channel ${e}`);if(t.isOriginator)return void Bs.RemoteCommunication(`[RemoteCommunication: reject()] context=${t.context} isOriginator=${t.isOriginator} channelId=${e}`);const{socket:s}=null!==(r=null===(n=t.communicationLayer)||void 0===n?void 0:n.state)&&void 0!==r?r:{};(null==s?void 0:s.connected)||(Bs.RemoteCommunication(`[RemoteCommunication: reject()] context=${t.context} socket already connected`),null==s||s.connect()),Ks(Object.assign(Object.assign({id:e,event:ea.REJECTED},t.originatorInfo),{sdkVersion:t.sdkVersion,commLayerVersion:Fs.version,walletVersion:null===(o=t.walletInfo)||void 0===o?void 0:o.version}),t.communicationServerUrl).catch((e=>{})),yield new Promise(((n,r)=>{null==s||s.emit(Zs.REJECTED,{channelId:e},((e,i)=>{Bs.RemoteCommunication(`[RemoteCommunication: reject()] context=${t.context} socket=${null==s?void 0:s.id}`,{error:e,response:i}),e?r(e):n(i)}))}))}))}({channelId:e,state:this.state})}disconnect(e){return $e(this,void 0,void 0,(function*(){return Ma({options:e,instance:this})}))}}!function(e){e.RENEW="renew",e.LINK="link"}(ma||(ma={}));var Ta="ERC721",Oa="ERC1155",Ra={errors:{disconnected:()=>"MetaMask: Disconnected from chain. Attempting to connect.",permanentlyDisconnected:()=>"MetaMask: Disconnected from MetaMask background. Page reload required.",sendSiteMetadata:()=>"MetaMask: Failed to send site metadata. This is an internal error, please report this bug.",unsupportedSync:e=>`MetaMask: The MetaMask Ethereum provider does not support synchronous methods like ${e} without a callback parameter.`,invalidDuplexStream:()=>"Must provide a Node.js-style duplex stream.",invalidNetworkParams:()=>"MetaMask: Received invalid network parameters. Please report this bug.",invalidRequestArgs:()=>"Expected a single, non-array, object argument.",invalidRequestMethod:()=>"'args.method' must be a non-empty string.",invalidRequestParams:()=>"'args.params' must be an object or array if provided.",invalidLoggerObject:()=>"'args.logger' must be an object if provided.",invalidLoggerMethod:e=>`'args.logger' must include required method '${e}'.`},info:{connected:e=>`MetaMask: Connected to chain with ID "${e}".`},warnings:{chainIdDeprecation:"MetaMask: 'ethereum.chainId' is deprecated and may be removed in the future. Please use the 'eth_chainId' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",networkVersionDeprecation:"MetaMask: 'ethereum.networkVersion' is deprecated and may be removed in the future. Please use the 'net_version' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",selectedAddressDeprecation:"MetaMask: 'ethereum.selectedAddress' is deprecated and may be removed in the future. Please use the 'eth_accounts' RPC method instead.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/discussions/23",enableDeprecation:"MetaMask: 'ethereum.enable()' is deprecated and may be removed in the future. Please use the 'eth_requestAccounts' RPC method instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1102",sendDeprecation:"MetaMask: 'ethereum.send(...)' is deprecated and may be removed in the future. Please use 'ethereum.sendAsync(...)' or 'ethereum.request(...)' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193",events:{close:"MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect",data:"MetaMask: The event 'data' is deprecated and will be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message",networkChanged:"MetaMask: The event 'networkChanged' is deprecated and may be removed in the future. Use 'chainChanged' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#chainchanged",notification:"MetaMask: The event 'notification' is deprecated and may be removed in the future. Use 'message' instead.\nFor more information, see: https://eips.ethereum.org/EIPS/eip-1193#message"},rpc:{ethDecryptDeprecation:"MetaMask: The RPC method 'eth_decrypt' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",ethGetEncryptionPublicKeyDeprecation:"MetaMask: The RPC method 'eth_getEncryptionPublicKey' is deprecated and may be removed in the future.\nFor more information, see: https://medium.com/metamask/metamask-api-method-deprecation-2b0564a84686",walletWatchAssetNFTExperimental:"MetaMask: The RPC method 'wallet_watchAsset' is experimental for ERC721/ERC1155 assets and may change in the future.\nFor more information, see: https://github.com/MetaMask/metamask-improvement-proposals/blob/main/MIPs/mip-1.md and https://github.com/MetaMask/metamask-improvement-proposals/blob/main/PROCESS-GUIDE.md#proposal-lifecycle"},experimentalMethods:"MetaMask: 'ethereum._metamask' exposes non-standard, experimental methods. They may be removed or changed without warning."}};function Pa(e){const t={ethDecryptDeprecation:!1,ethGetEncryptionPublicKeyDeprecation:!1,walletWatchAssetNFTExperimental:!1};return(n,r,i)=>{t.ethDecryptDeprecation||"eth_decrypt"!==n.method?t.ethGetEncryptionPublicKeyDeprecation||"eth_getEncryptionPublicKey"!==n.method?!t.walletWatchAssetNFTExperimental&&"wallet_watchAsset"===n.method&&[Ta,Oa].includes(n.params?.type||"")&&(e.warn(Ra.warnings.rpc.walletWatchAssetNFTExperimental),t.walletWatchAssetNFTExperimental=!0):(e.warn(Ra.warnings.rpc.ethGetEncryptionPublicKeyDeprecation),t.ethGetEncryptionPublicKeyDeprecation=!0):(e.warn(Ra.warnings.rpc.ethDecryptDeprecation),t.ethDecryptDeprecation=!0),i()}}var Ia=4294967295,Na=Math.floor(Math.random()*Ia);var Ba=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},Da=(e,t,n)=>(Ba(e,t,"read from private field"),n?n.call(e):t.get(e)),$a=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},ja=(e,t,n,r)=>(Ba(e,t,"write to private field"),t.set(e,n),n),Ka=(e,t,n)=>(Ba(e,t,"access private method"),n),Ua=-32600,Fa=-32603,Ha={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}};function za(e){return Boolean(e)&&"object"==typeof e&&!Array.isArray(e)}var qa=(e,t)=>Object.hasOwnProperty.call(e,t);class Va extends TypeError{constructor(e,t){let n;const{message:r,explanation:i,...o}=e,{path:s}=e,a=0===s.length?r:`At path: ${s.join(".")} -- ${r}`;super(i??a),null!=i&&(this.cause=a),Object.assign(this,o),this.name=this.constructor.name,this.failures=()=>n??(n=[e,...t()])}}function Wa(e){return"object"==typeof e&&null!=e}function Ga(e){return"symbol"==typeof e?e.toString():"string"==typeof e?JSON.stringify(e):`${e}`}function Ya(e,t,n,r){if(!0===e)return;!1===e?e={}:"string"==typeof e&&(e={message:e});const{path:i,branch:o}=t,{type:s}=n,{refinement:a,message:c=`Expected a value of type \`${s}\`${a?` with refinement \`${a}\``:""}, but received: \`${Ga(r)}\``}=e;return{value:r,type:s,refinement:a,key:i[i.length-1],path:i,branch:o,...e,message:c}}function*Za(e,t,n,r){(function(e){return Wa(e)&&"function"==typeof e[Symbol.iterator]})(e)||(e=[e]);for(const i of e){const e=Ya(i,t,n,r);e&&(yield e)}}function*Ja(e,t,n={}){const{path:r=[],branch:i=[e],coerce:o=!1,mask:s=!1}=n,a={path:r,branch:i};if(o&&(e=t.coercer(e,a),s&&"type"!==t.type&&Wa(t.schema)&&Wa(e)&&!Array.isArray(e)))for(const n in e)void 0===t.schema[n]&&delete e[n];let c="valid";for(const r of t.validator(e,a))r.explanation=n.message,c="not_valid",yield[r,void 0];for(let[l,d,u]of t.entries(e,a)){const t=Ja(d,u,{path:void 0===l?r:[...r,l],branch:void 0===l?i:[...i,d],coerce:o,mask:s,message:n.message});for(const n of t)n[0]?(c=null!=n[0].refinement?"not_refined":"not_valid",yield[n[0],void 0]):o&&(d=n[1],void 0===l?e=d:e instanceof Map?e.set(l,d):e instanceof Set?e.add(d):Wa(e)&&(void 0!==d||l in e)&&(e[l]=d))}if("not_valid"!==c)for(const r of t.refiner(e,a))r.explanation=n.message,c="not_refined",yield[r,void 0];"valid"===c&&(yield[void 0,e])}class Xa{constructor(e){const{type:t,schema:n,validator:r,refiner:i,coercer:o=(e=>e),entries:s=function*(){}}=e;this.type=t,this.schema=n,this.entries=s,this.coercer=o,this.validator=r?(e,t)=>Za(r(e,t),t,this,e):()=>[],this.refiner=i?(e,t)=>Za(i(e,t),t,this,e):()=>[]}assert(e,t){return Qa(e,this,t)}create(e,t){return ec(e,this,t)}is(e){return tc(e,this)}mask(e,t){return function(e,t,n){const r=nc(e,t,{coerce:!0,mask:!0,message:n});if(r[0])throw r[0];return r[1]}(e,this,t)}validate(e,t={}){return nc(e,this,t)}}function Qa(e,t,n){const r=nc(e,t,{message:n});if(r[0])throw r[0]}function ec(e,t,n){const r=nc(e,t,{coerce:!0,message:n});if(r[0])throw r[0];return r[1]}function tc(e,t){return!nc(e,t)[0]}function nc(e,t,n={}){const r=Ja(e,t,n),i=function(e){const{done:t,value:n}=e.next();return t?void 0:n}(r);if(i[0]){return[new Va(i[0],(function*(){for(const e of r)e[0]&&(yield e[0])})),void 0]}return[void 0,i[1]]}function rc(e,t){return new Xa({type:e,schema:null,validator:t})}function ic(e){let t;return new Xa({type:"lazy",schema:null,*entries(n,r){t??(t=e()),yield*t.entries(n,r)},validator:(n,r)=>(t??(t=e()),t.validator(n,r)),coercer:(n,r)=>(t??(t=e()),t.coercer(n,r)),refiner:(n,r)=>(t??(t=e()),t.refiner(n,r))})}function oc(e){return new Xa({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t))for(const[n,r]of t.entries())yield[n,r,e]},coercer:e=>Array.isArray(e)?e.slice():e,validator:e=>Array.isArray(e)||`Expected an array value, but received: ${Ga(e)}`})}function sc(e){const t=Ga(e),n=typeof e;return new Xa({type:"literal",schema:"string"===n||"number"===n||"boolean"===n?e:null,validator:n=>n===e||`Expected the literal \`${t}\`, but received: ${Ga(n)}`})}function ac(){return rc("number",(e=>"number"==typeof e&&!isNaN(e)||`Expected a number, but received: ${Ga(e)}`))}function cc(e){const t=e?Object.keys(e):[],n=rc("never",(()=>!1));return new Xa({type:"object",schema:e||null,*entries(r){if(e&&Wa(r)){const i=new Set(Object.keys(r));for(const n of t)i.delete(n),yield[n,r[n],e[n]];for(const e of i)yield[e,r[e],n]}},validator:e=>Wa(e)||`Expected an object, but received: ${Ga(e)}`,coercer:e=>Wa(e)?{...e}:e})}function lc(e){return new Xa({...e,validator:(t,n)=>void 0===t||e.validator(t,n),refiner:(t,n)=>void 0===t||e.refiner(t,n)})}function dc(e,t){return new Xa({type:"record",schema:null,*entries(n){if(Wa(n))for(const r in n){const i=n[r];yield[r,r,e],yield[r,i,t]}},validator:e=>Wa(e)||`Expected an object, but received: ${Ga(e)}`})}function uc(){return rc("string",(e=>"string"==typeof e||`Expected a string, but received: ${Ga(e)}`))}function hc(e){const t=e.map((e=>e.type)).join(" | ");return new Xa({type:"union",schema:null,coercer(t){for(const n of e){const[e,r]=n.validate(t,{coerce:!0});if(!e)return r}return t},validator(n,r){const i=[];for(const t of e){const[...e]=Ja(n,t,r),[o]=e;if(!o[0])return[];for(const[t]of e)t&&i.push(t)}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${Ga(n)}`,...i]}})}var fc=class extends Error{constructor(e){super(e.message),this.code="ERR_ASSERTION"}};function pc(){throw new Error("setTimeout has not been defined")}function gc(){throw new Error("clearTimeout has not been defined")}var mc=pc,yc=gc;function vc(e){if(mc===setTimeout)return setTimeout(e,0);if((mc===pc||!mc)&&setTimeout)return mc=setTimeout,setTimeout(e,0);try{return mc(e,0)}catch(t){try{return mc.call(null,e,0)}catch(t){return mc.call(this,e,0)}}}"function"==typeof je.setTimeout&&(mc=setTimeout),"function"==typeof je.clearTimeout&&(yc=clearTimeout);var bc,wc=[],Ec=!1,Cc=-1;function _c(){Ec&&bc&&(Ec=!1,bc.length?wc=bc.concat(wc):Cc=-1,wc.length&&Sc())}function Sc(){if(!Ec){var e=vc(_c);Ec=!0;for(var t=wc.length;t;){for(bc=wc,wc=[];++Cc<t;)bc&&bc[Cc].run();Cc=-1,t=wc.length}bc=null,Ec=!1,function(e){if(yc===clearTimeout)return clearTimeout(e);if((yc===gc||!yc)&&clearTimeout)return yc=clearTimeout,clearTimeout(e);try{return yc(e)}catch(t){try{return yc.call(null,e)}catch(t){return yc.call(this,e)}}}(e)}}function kc(e,t){this.fun=e,this.array=t}function xc(){}kc.prototype.run=function(){this.fun.apply(null,this.array)};var Ac=xc,Mc=xc,Lc=xc,Tc=xc,Oc=xc,Rc=xc,Pc=xc,Ic=je.performance||{},Nc=Ic.now||Ic.mozNow||Ic.msNow||Ic.oNow||Ic.webkitNow||function(){return(new Date).getTime()},Bc=new Date,Dc={nextTick:function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];wc.push(new kc(e,t)),1!==wc.length||Ec||vc(Sc)},title:"browser",browser:!0,env:{},argv:[],version:"",versions:{},on:Ac,addListener:Mc,once:Lc,off:Tc,removeListener:Oc,removeAllListeners:Rc,emit:Pc,binding:function(e){throw new Error("process.binding is not supported")},cwd:function(){return"/"},chdir:function(e){throw new Error("process.chdir is not supported")},umask:function(){return 0},hrtime:function(e){var t=.001*Nc.call(Ic),n=Math.floor(t),r=Math.floor(t%1*1e9);return e&&(n-=e[0],(r-=e[1])<0&&(n--,r+=1e9)),[n,r]},platform:"browser",release:{},config:{},uptime:function(){return(new Date-Bc)/1e3}},$c=e=>cc(e);function jc({path:e,branch:t}){const n=e[e.length-1];return qa(t[t.length-2],n)}function Kc(e){return new Xa({...e,type:`optional ${e.type}`,validator:(t,n)=>!jc(n)||e.validator(t,n),refiner:(t,n)=>!jc(n)||e.refiner(t,n)})}var Uc,Fc,Hc,zc=hc([sc(null),rc("boolean",(e=>"boolean"==typeof e)),rc("finite number",(e=>tc(e,ac())&&Number.isFinite(e))),uc(),oc(ic((()=>zc))),dc(uc(),ic((()=>zc)))]),qc=(Uc=zc,Fc=rc("any",(()=>!0)),Hc=e=>(function(e,t,n="Assertion failed",r=fc){try{Qa(e,t)}catch(e){throw function(e,t){return n=e,Boolean("string"==typeof n?.prototype?.constructor?.name)?new e({message:t}):e({message:t});var n}(r,`${n}: ${function(e){return function(e){return function(e){return"object"==typeof e&&null!==e&&"message"in e}(e)&&"string"==typeof e.message?e.message:null==e?"":String(e)}(e).replace(/\.$/u,"")}(e)}.`)}}(e,zc),JSON.parse(JSON.stringify(e,((e,t)=>{if("__proto__"!==e&&"constructor"!==e)return t})))),new Xa({...Uc,coercer:(e,t)=>tc(e,Fc)?Uc.coercer(Hc(e),t):Uc.coercer(e,t)}));function Vc(e){try{return function(e){ec(e,qc)}(e),!0}catch{return!1}}var Wc=sc("2.0"),Gc=function(e){return new Xa({...e,validator:(t,n)=>null===t||e.validator(t,n),refiner:(t,n)=>null===t||e.refiner(t,n)})}(hc([ac(),uc()])),Yc=$c({code:rc("integer",(e=>"number"==typeof e&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${Ga(e)}`)),message:uc(),data:Kc(qc),stack:Kc(uc())}),Zc=hc([dc(uc(),qc),oc(qc)]),Jc=$c({id:Gc,jsonrpc:Wc,method:uc(),params:Kc(Zc)}),Xc=$c({jsonrpc:Wc,method:uc(),params:Kc(Zc)});function Qc(e){return tc(e,Jc)}function el(e){return tc(e,Yc)}cc({id:Gc,jsonrpc:Wc,result:lc(rc("unknown",(()=>!0))),error:lc(Yc)}),hc([$c({id:Gc,jsonrpc:Wc,result:qc}),$c({id:Gc,jsonrpc:Wc,error:Yc})]);var tl="Unspecified error message. This is a bug, please report it.",nl={code:Fa,message:il(Fa)},rl="Unspecified server error.";function il(e,t=tl){if(function(e){return Number.isInteger(e)}(e)){const t=e.toString();if(qa(Ha,t))return Ha[t].message;if(function(e){return e>=-32099&&e<=-32e3}(e))return rl}return t}function ol(e,{fallbackError:t=nl,shouldIncludeStack:n=!0}={}){if(!el(t))throw new Error("Must provide fallback error with integer number code and string message.");const r=function(e,t){if(e&&"object"==typeof e&&"serialize"in e&&"function"==typeof e.serialize)return e.serialize();if(el(e))return e;return{...t,data:{cause:sl(e)}}}(e,t);return n||delete r.stack,r}function sl(e){return Array.isArray(e)?e.map((e=>Vc(e)?e:za(e)?al(e):null)):za(e)?al(e):Vc(e)?e:null}function al(e){return Object.getOwnPropertyNames(e).reduce(((t,n)=>{const r=e[n];return Vc(r)&&(t[n]=r),t}),{})}var cl=pl;pl.default=pl,pl.stable=vl,pl.stableStringify=vl;var ll="[...]",dl="[Circular]",ul=[],hl=[];function fl(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function pl(e,t,n,r){var i;void 0===r&&(r=fl()),ml(e,"",0,[],void 0,0,r);try{i=0===hl.length?JSON.stringify(e,t,n):JSON.stringify(e,wl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ul.length;){var o=ul.pop();4===o.length?Object.defineProperty(o[0],o[1],o[3]):o[0][o[1]]=o[2]}}return i}function gl(e,t,n,r){var i=Object.getOwnPropertyDescriptor(r,n);void 0!==i.get?i.configurable?(Object.defineProperty(r,n,{value:e}),ul.push([r,n,t,i])):hl.push([t,n,e]):(r[n]=e,ul.push([r,n,t]))}function ml(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void gl(dl,e,t,i);if(void 0!==s.depthLimit&&o>s.depthLimit)return void gl(ll,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void gl(ll,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)ml(e[a],a,a,r,e,o,s);else{var c=Object.keys(e);for(a=0;a<c.length;a++){var l=c[a];ml(e[l],l,a,r,e,o,s)}}r.pop()}}function yl(e,t){return e<t?-1:e>t?1:0}function vl(e,t,n,r){void 0===r&&(r=fl());var i,o=bl(e,"",0,[],void 0,0,r)||e;try{i=0===hl.length?JSON.stringify(o,t,n):JSON.stringify(o,wl(t),n)}catch(e){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{for(;0!==ul.length;){var s=ul.pop();4===s.length?Object.defineProperty(s[0],s[1],s[3]):s[0][s[1]]=s[2]}}return i}function bl(e,t,n,r,i,o,s){var a;if(o+=1,"object"==typeof e&&null!==e){for(a=0;a<r.length;a++)if(r[a]===e)return void gl(dl,e,t,i);try{if("function"==typeof e.toJSON)return}catch(e){return}if(void 0!==s.depthLimit&&o>s.depthLimit)return void gl(ll,e,t,i);if(void 0!==s.edgesLimit&&n+1>s.edgesLimit)return void gl(ll,e,t,i);if(r.push(e),Array.isArray(e))for(a=0;a<e.length;a++)bl(e[a],a,a,r,e,o,s);else{var c={},l=Object.keys(e).sort(yl);for(a=0;a<l.length;a++){var d=l[a];bl(e[d],d,a,r,e,o,s),c[d]=e[d]}if(void 0===i)return c;ul.push([i,t,e]),i[t]=c}r.pop()}}function wl(e){return e=void 0!==e?e:function(e,t){return t},function(t,n){if(hl.length>0)for(var r=0;r<hl.length;r++){var i=hl[r];if(i[1]===t&&i[0]===n){n=i[2],hl.splice(r,1);break}}return e.call(this,t,n)}}var El=Ut(cl),Cl=class extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a non-empty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data,function(e){if("object"!=typeof e||null===e)return!1;try{let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}catch(e){return!1}}(this.data)&&(e.data.cause=sl(this.data.cause))),this.stack&&(e.stack=this.stack),e}toString(){return El(this.serialize(),_l,2)}};function _l(e,t){if("[Circular]"!==t)return t}var Sl=e=>function(e,t){const[n,r]=function(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t??void 0,n]}}return[]}(t);return new Cl(e,n??il(e),r)}(Ua,e);var kl={};function xl(){}function Al(){Al.init.call(this)}function Ml(e){return void 0===e._maxListeners?Al.defaultMaxListeners:e._maxListeners}function Ll(e,t,n,r){var i,o,s;if("function"!=typeof n)throw new TypeError('"listener" argument must be a function');if((o=e._events)?(o.newListener&&(e.emit("newListener",t,n.listener?n.listener:n),o=e._events),s=o[t]):(o=e._events=new xl,e._eventsCount=0),s){if("function"==typeof s?s=o[t]=r?[n,s]:[s,n]:r?s.unshift(n):s.push(n),!s.warned&&(i=Ml(e))&&i>0&&s.length>i){s.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=e,a.type=t,a.count=s.length,function(e){"function"==typeof console.warn?console.warn(e):console.log(e)}(a)}}else s=o[t]=n,++e._eventsCount;return e}function Tl(e,t,n){var r=!1;function i(){e.removeListener(t,i),r||(r=!0,n.apply(e,arguments))}return i.listener=n,i}function Ol(e){var t=this._events;if(t){var n=t[e];if("function"==typeof n)return 1;if(n)return n.length}return 0}function Rl(e,t){for(var n=new Array(t);t--;)n[t]=e[t];return n}xl.prototype=Object.create(null),Al.EventEmitter=Al,Al.usingDomains=!1,Al.prototype.domain=void 0,Al.prototype._events=void 0,Al.prototype._maxListeners=void 0,Al.defaultMaxListeners=10,Al.init=function(){this.domain=null,Al.usingDomains&&(void 0).active,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new xl,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Al.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this},Al.prototype.getMaxListeners=function(){return Ml(this)},Al.prototype.emit=function(e){var t,n,r,i,o,s,a,c="error"===e;if(s=this._events)c=c&&null==s.error;else if(!c)return!1;if(a=this.domain,c){if(t=arguments[1],!a){if(t instanceof Error)throw t;var l=new Error('Uncaught, unspecified "error" event. ('+t+")");throw l.context=t,l}return t||(t=new Error('Uncaught, unspecified "error" event')),t.domainEmitter=this,t.domain=a,t.domainThrown=!1,a.emit("error",t),!1}if(!(n=s[e]))return!1;var d="function"==typeof n;switch(r=arguments.length){case 1:!function(e,t,n){if(t)e.call(n);else for(var r=e.length,i=Rl(e,r),o=0;o<r;++o)i[o].call(n)}(n,d,this);break;case 2:!function(e,t,n,r){if(t)e.call(n,r);else for(var i=e.length,o=Rl(e,i),s=0;s<i;++s)o[s].call(n,r)}(n,d,this,arguments[1]);break;case 3:!function(e,t,n,r,i){if(t)e.call(n,r,i);else for(var o=e.length,s=Rl(e,o),a=0;a<o;++a)s[a].call(n,r,i)}(n,d,this,arguments[1],arguments[2]);break;case 4:!function(e,t,n,r,i,o){if(t)e.call(n,r,i,o);else for(var s=e.length,a=Rl(e,s),c=0;c<s;++c)a[c].call(n,r,i,o)}(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(r-1),o=1;o<r;o++)i[o-1]=arguments[o];!function(e,t,n,r){if(t)e.apply(n,r);else for(var i=e.length,o=Rl(e,i),s=0;s<i;++s)o[s].apply(n,r)}(n,d,this,i)}return!0},Al.prototype.addListener=function(e,t){return Ll(this,e,t,!1)},Al.prototype.on=Al.prototype.addListener,Al.prototype.prependListener=function(e,t){return Ll(this,e,t,!0)},Al.prototype.once=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.on(e,Tl(this,e,t)),this},Al.prototype.prependOnceListener=function(e,t){if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');return this.prependListener(e,Tl(this,e,t)),this},Al.prototype.removeListener=function(e,t){var n,r,i,o,s;if("function"!=typeof t)throw new TypeError('"listener" argument must be a function');if(!(r=this._events))return this;if(!(n=r[e]))return this;if(n===t||n.listener&&n.listener===t)0==--this._eventsCount?this._events=new xl:(delete r[e],r.removeListener&&this.emit("removeListener",e,n.listener||t));else if("function"!=typeof n){for(i=-1,o=n.length;o-- >0;)if(n[o]===t||n[o].listener&&n[o].listener===t){s=n[o].listener,i=o;break}if(i<0)return this;if(1===n.length){if(n[0]=void 0,0==--this._eventsCount)return this._events=new xl,this;delete r[e]}else!function(e,t){for(var n=t,r=n+1,i=e.length;r<i;n+=1,r+=1)e[n]=e[r];e.pop()}(n,i);r.removeListener&&this.emit("removeListener",e,s||t)}return this},Al.prototype.off=function(e,t){return this.removeListener(e,t)},Al.prototype.removeAllListeners=function(e){var t,n;if(!(n=this._events))return this;if(!n.removeListener)return 0===arguments.length?(this._events=new xl,this._eventsCount=0):n[e]&&(0==--this._eventsCount?this._events=new xl:delete n[e]),this;if(0===arguments.length){for(var r,i=Object.keys(n),o=0;o<i.length;++o)"removeListener"!==(r=i[o])&&this.removeAllListeners(r);return this.removeAllListeners("removeListener"),this._events=new xl,this._eventsCount=0,this}if("function"==typeof(t=n[e]))this.removeListener(e,t);else if(t)do{this.removeListener(e,t[t.length-1])}while(t[0]);return this},Al.prototype.listeners=function(e){var t,n,r=this._events;return n=r&&(t=r[e])?"function"==typeof t?[t.listener||t]:function(e){for(var t=new Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}(t):[],n},Al.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):Ol.call(e,t)},Al.prototype.listenerCount=Ol,Al.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var Pl=Ft(Object.freeze({__proto__:null,EventEmitter:Al,default:Al}));Object.defineProperty(kl,"__esModule",{value:!0});const Il=Pl;function Nl(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}let Bl=class extends Il.EventEmitter{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)Nl(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)Nl(n[r],this,t)}return!0}};var Dl,$l,jl,Kl,Ul,Fl,Hl,zl,ql,Vl,Wl,Gl,Yl,Zl,Jl,Xl,Ql,ed,td,nd=kl.default=Bl,rd=class e extends nd{constructor({notificationHandler:e}={}){super(),$a(this,Kl),$a(this,Fl),$a(this,zl),$a(this,Dl,!1),$a(this,$l,void 0),$a(this,jl,void 0),ja(this,$l,[]),ja(this,jl,e)}destroy(){Da(this,$l).forEach((e=>{"destroy"in e&&"function"==typeof e.destroy&&e.destroy()})),ja(this,$l,[]),ja(this,Dl,!0)}push(e){Ka(this,Kl,Ul).call(this),Da(this,$l).push(e)}handle(e,t){if(Ka(this,Kl,Ul).call(this),t&&"function"!=typeof t)throw new Error('"callback" must be a function if provided.');return Array.isArray(e)?t?Ka(this,Fl,Hl).call(this,e,t):Ka(this,Fl,Hl).call(this,e):t?Ka(this,zl,ql).call(this,e,t):this._promiseHandle(e)}asMiddleware(){return Ka(this,Kl,Ul).call(this),async(t,n,r,i)=>{var o,s;try{const[a,c,l]=await Ka(o=e,Gl,Yl).call(o,t,n,Da(this,$l));return c?(await Ka(s=e,Xl,Ql).call(s,l),i(a)):r((async t=>{var n;try{await Ka(n=e,Xl,Ql).call(n,l)}catch(e){return t(e)}return t()}))}catch(e){return i(e)}}}async _promiseHandle(e){return new Promise(((t,n)=>{Ka(this,zl,ql).call(this,e,((e,r)=>{e&&void 0===r?n(e):t(r)})).catch(n)}))}};Dl=new WeakMap,$l=new WeakMap,jl=new WeakMap,Kl=new WeakSet,Ul=function(){if(Da(this,Dl))throw new Error("This engine is destroyed and can no longer be used.")},Fl=new WeakSet,Hl=async function(e,t){try{if(0===e.length){const e=[{id:null,jsonrpc:"2.0",error:new Cl(Ua,"Request batch must contain plain objects. Received an empty array")}];return t?t(null,e):e}const n=(await Promise.all(e.map(this._promiseHandle.bind(this)))).filter((e=>void 0!==e));return t?t(null,n):n}catch(e){if(t)return t(e);throw e}},zl=new WeakSet,ql=async function(e,t){var n;if(!e||Array.isArray(e)||"object"!=typeof e){const n=new Cl(Ua,"Requests must be plain objects. Received: "+typeof e,{request:e});return t(n,{id:null,jsonrpc:"2.0",error:n})}if("string"!=typeof e.method){const n=new Cl(Ua,"Must specify a string method. Received: "+typeof e.method,{request:e});return Da(this,jl)&&!Qc(e)?t(null):t(n,{id:e.id??null,jsonrpc:"2.0",error:n})}if(Da(this,jl)&&tc(e,Xc)&&!Qc(e)){try{await Da(this,jl).call(this,e)}catch(e){return t(e)}return t(null)}let r=null;const i={...e},o={id:i.id,jsonrpc:i.jsonrpc};try{await Ka(n=rd,Vl,Wl).call(n,i,o,Da(this,$l))}catch(e){r=e}return r&&(delete o.result,o.error||(o.error=ol(r))),t(r,o)},Vl=new WeakSet,Wl=async function(e,t,n){var r,i,o;const[s,a,c]=await Ka(r=rd,Gl,Yl).call(r,e,t,n);if(Ka(i=rd,ed,td).call(i,e,t,a),await Ka(o=rd,Xl,Ql).call(o,c),s)throw s},Gl=new WeakSet,Yl=async function(e,t,n){var r;const i=[];let o=null,s=!1;for(const a of n)if([o,s]=await Ka(r=rd,Zl,Jl).call(r,e,t,a,i),s)break;return[o,s,i.reverse()]},Zl=new WeakSet,Jl=async function(e,t,n,r){return new Promise((i=>{const o=e=>{const n=e||t.error;n&&(t.error=ol(n)),i([n,!0])},s=n=>{t.error?o(t.error):(n&&("function"!=typeof n&&o(new Cl(Fa,`JsonRpcEngine: "next" return handlers must be functions. Received "${typeof n}" for request:\n${od(e)}`,{request:e})),r.push(n)),i([null,!1]))};try{n(e,t,s,o)}catch(e){o(e)}}))},Xl=new WeakSet,Ql=async function(e){for(const t of e)await new Promise(((e,n)=>{t((t=>t?n(t):e()))}))},ed=new WeakSet,td=function(e,t,n){if(!qa(t,"result")&&!qa(t,"error"))throw new Cl(Fa,`JsonRpcEngine: Response has no error or result for request:\n${od(e)}`,{request:e});if(!n)throw new Cl(Fa,`JsonRpcEngine: Nothing ended request:\n${od(e)}`,{request:e})},$a(rd,Vl),$a(rd,Gl),$a(rd,Zl),$a(rd,Xl),$a(rd,ed);var id=rd;function od(e){return JSON.stringify(e,null,2)}var sd=Object.freeze(["eth_subscription"]),ad=(e=console)=>[(e,t,n,r)=>{const i=e.id,o=Na=(Na+1)%Ia;e.id=o,t.id=o,n((n=>{e.id=i,t.id=i,n()}))},cd(e),Pa(e)];function cd(e){return(t,n,r)=>{"string"==typeof t.method&&t.method||(n.error=Sl({message:"The request 'method' must be a non-empty string.",data:t})),r((t=>{const{error:r}=n;return r?(e.error(`MetaMask - RPC Error: ${r.message}`,r),t()):t()}))}}var ld=(e,t,n=!0)=>(r,i)=>{r||i.error?t(r||i.error):!n||Array.isArray(i)?e(i):e(i.result)},dd=e=>Boolean(e)&&"string"==typeof e&&e.startsWith("0x"),ud=()=>{};async function hd(e,t){try{const t=await async function(){return{name:fd(window),icon:await pd(window)}}();e.handle({jsonrpc:"2.0",id:1,method:"metamask_sendDomainMetadata",params:t},ud)}catch(e){t.error({message:Ra.errors.sendSiteMetadata(),originalError:e})}}function fd(e){const{document:t}=e,n=t.querySelector('head > meta[property="og:site_name"]');if(n)return n.content;const r=t.querySelector('head > meta[name="title"]');return r?r.content:t.title&&t.title.length>0?t.title:window.location.hostname}async function pd(e){const{document:t}=e,n=t.querySelectorAll('head > link[rel~="icon"]');for(const e of Array.from(n))if(e&&await gd(e.href))return e.href;return null}async function gd(e){return new Promise(((t,n)=>{try{const n=document.createElement("img");n.onload=()=>t(!0),n.onerror=()=>t(!1),n.src=e}catch(e){n(e)}}))}var md=(e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)},yd=(e,t,n)=>(md(e,t,"read from private field"),n?n.call(e):t.get(e)),vd=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},bd=(e,t,n,r)=>(md(e,t,"write to private field"),t.set(e,n),n);function wd(e,t,n){try{Reflect.apply(e,t,n)}catch(e){setTimeout((()=>{throw e}))}}class Ed extends Al{emit(e,...t){let n="error"===e;const r=this._events;if(void 0!==r)n=n&&void 0===r.error;else if(!n)return!1;if(n){let e;if(t.length>0&&([e]=t),e instanceof Error)throw e;const n=new Error("Unhandled error."+(e?` (${e.message})`:""));throw n.context=e,n}const i=r[e];if(void 0===i)return!1;if("function"==typeof i)wd(i,this,t);else{const e=i.length,n=function(e){const t=e.length,n=new Array(t);for(let r=0;r<t;r+=1)n[r]=e[r];return n}(i);for(let r=0;r<e;r+=1)wd(n[r],this,t)}return!0}}var Cd,_d,Sd=Ut((function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,o;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,o[i]))return!1;for(i=r;0!=i--;){var s=o[i];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n})),kd=class e extends Ed{constructor({logger:t=console,maxEventListeners:n=100,rpcMiddleware:r=[]}={}){super(),vd(this,Cd,void 0),vd(this,_d,void 0),this._log=t,this.setMaxListeners(n),this._state={...e._defaultState},bd(this,_d,null),bd(this,Cd,null),this._handleAccountsChanged=this._handleAccountsChanged.bind(this),this._handleConnect=this._handleConnect.bind(this),this._handleChainChanged=this._handleChainChanged.bind(this),this._handleDisconnect=this._handleDisconnect.bind(this),this._handleUnlockStateChanged=this._handleUnlockStateChanged.bind(this),this._rpcRequest=this._rpcRequest.bind(this),this.request=this.request.bind(this);const i=new id;r.forEach((e=>i.push(e))),this._rpcEngine=i}get chainId(){return yd(this,Cd)}get selectedAddress(){return yd(this,_d)}isConnected(){return this._state.isConnected}async request(e){if(!e||"object"!=typeof e||Array.isArray(e))throw Sl({message:Ra.errors.invalidRequestArgs(),data:e});const{method:t,params:n}=e;if("string"!=typeof t||0===t.length)throw Sl({message:Ra.errors.invalidRequestMethod(),data:e});if(void 0!==n&&!Array.isArray(n)&&("object"!=typeof n||null===n))throw Sl({message:Ra.errors.invalidRequestParams(),data:e});const r=null==n?{method:t}:{method:t,params:n};return new Promise(((e,t)=>{this._rpcRequest(r,ld(e,t))}))}_initializeState(e){if(this._state.initialized)throw new Error("Provider already initialized.");if(e){const{accounts:t,chainId:n,isUnlocked:r,networkVersion:i}=e;this._handleConnect(n),this._handleChainChanged({chainId:n,networkVersion:i}),this._handleUnlockStateChanged({accounts:t,isUnlocked:r}),this._handleAccountsChanged(t)}this._state.initialized=!0,this.emit("_initialized")}_rpcRequest(e,t){let n=t;return Array.isArray(e)||(e.jsonrpc||(e.jsonrpc="2.0"),"eth_accounts"!==e.method&&"eth_requestAccounts"!==e.method||(n=(n,r)=>{this._handleAccountsChanged(r.result??[],"eth_accounts"===e.method),t(n,r)})),this._rpcEngine.handle(e,n)}_handleConnect(e){this._state.isConnected||(this._state.isConnected=!0,this.emit("connect",{chainId:e}),this._log.debug(Ra.info.connected(e)))}_handleDisconnect(e,t){if(this._state.isConnected||!this._state.isPermanentlyDisconnected&&!e){let n;this._state.isConnected=!1,e?(n=new Cl(1013,t??Ra.errors.disconnected()),this._log.debug(n)):(n=new Cl(1011,t??Ra.errors.permanentlyDisconnected()),this._log.error(n),bd(this,Cd,null),this._state.accounts=null,bd(this,_d,null),this._state.isUnlocked=!1,this._state.isPermanentlyDisconnected=!0),this.emit("disconnect",n)}}_handleChainChanged({chainId:e}={}){dd(e)?(this._handleConnect(e),e!==yd(this,Cd)&&(bd(this,Cd,e),this._state.initialized&&this.emit("chainChanged",yd(this,Cd)))):this._log.error(Ra.errors.invalidNetworkParams(),{chainId:e})}_handleAccountsChanged(e,t=!1){let n=e;Array.isArray(e)||(this._log.error("MetaMask: Received invalid accounts parameter. Please report this bug.",e),n=[]);for(const t of e)if("string"!=typeof t){this._log.error("MetaMask: Received non-string account. Please report this bug.",e),n=[];break}if(!Sd(this._state.accounts,n)&&(t&&null!==this._state.accounts&&this._log.error("MetaMask: 'eth_accounts' unexpectedly updated accounts. Please report this bug.",n),this._state.accounts=n,yd(this,_d)!==n[0]&&bd(this,_d,n[0]||null),this._state.initialized)){const e=[...n];this.emit("accountsChanged",e)}}_handleUnlockStateChanged({accounts:e,isUnlocked:t}={}){"boolean"==typeof t?t!==this._state.isUnlocked&&(this._state.isUnlocked=t,this._handleAccountsChanged(e??[])):this._log.error("MetaMask: Received invalid isUnlocked parameter. Please report this bug.")}};Cd=new WeakMap,_d=new WeakMap,kd._defaultState={accounts:null,isConnected:!1,isUnlocked:!1,initialized:!1,isPermanentlyDisconnected:!1};var xd,Ad,Md=kd,Ld={exports:{}};function Td(){return Ad?xd:(Ad=1,xd=Pl.EventEmitter)}var Od,Rd=Ft(jt);Od="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e};var Pd=Object.getOwnPropertyDescriptors||function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++)n[t[r]]=Object.getOwnPropertyDescriptor(e,t[r]);return n},Id=/%[sdj%]/g;function Nd(e){if(!Jd(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(Kd(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,i=r.length,o=String(e).replace(Id,(function(e){if("%%"===e)return"%";if(n>=i)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),s=r[n];n<i;s=r[++n])Gd(s)||!tu(s)?o+=" "+s:o+=" "+Kd(s);return o}function Bd(e,t){if(Qd(je.process))return function(){return Bd(e,t).apply(this,arguments)};if(!0===Dc.noDeprecation)return e;var n=!1;return function(){if(!n){if(Dc.throwDeprecation)throw new Error(t);Dc.traceDeprecation?console.trace(t):console.error(t),n=!0}return e.apply(this,arguments)}}var Dd,$d={};function jd(e){return Qd(Dd)&&(Dd=Dc.env.NODE_DEBUG||""),e=e.toUpperCase(),$d[e]||(new RegExp("\\b"+e+"\\b","i").test(Dd)?$d[e]=function(){var t=Nd.apply(null,arguments);console.error("%s %d: %s",e,0,t)}:$d[e]=function(){}),$d[e]}function Kd(e,t){var n={seen:[],stylize:Fd};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),Wd(t)?n.showHidden=t:t&&uu(n,t),Qd(n.showHidden)&&(n.showHidden=!1),Qd(n.depth)&&(n.depth=2),Qd(n.colors)&&(n.colors=!1),Qd(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=Ud),Hd(n,e,n.depth)}function Ud(e,t){var n=Kd.styles[t];return n?"["+Kd.colors[n][0]+"m"+e+"["+Kd.colors[n][1]+"m":e}function Fd(e,t){return e}function Hd(e,t,n){if(e.customInspect&&t&&iu(t.inspect)&&t.inspect!==Kd&&(!t.constructor||t.constructor.prototype!==t)){var r=t.inspect(n,e);return Jd(r)||(r=Hd(e,r,n)),r}var i=function(e,t){if(Qd(t))return e.stylize("undefined","undefined");if(Jd(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return Zd(t)?e.stylize(""+t,"number"):Wd(t)?e.stylize(""+t,"boolean"):Gd(t)?e.stylize("null","null"):void 0}(e,t);if(i)return i;var o=Object.keys(t),s=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(o);if(e.showHidden&&(o=Object.getOwnPropertyNames(t)),ru(t)&&(o.indexOf("message")>=0||o.indexOf("description")>=0))return zd(t);if(0===o.length){if(iu(t)){var a=t.name?": "+t.name:"";return e.stylize("[Function"+a+"]","special")}if(eu(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(nu(t))return e.stylize(Date.prototype.toString.call(t),"date");if(ru(t))return zd(t)}var c,l="",d=!1,u=["{","}"];return Vd(t)&&(d=!0,u=["[","]"]),iu(t)&&(l=" [Function"+(t.name?": "+t.name:"")+"]"),eu(t)&&(l=" "+RegExp.prototype.toString.call(t)),nu(t)&&(l=" "+Date.prototype.toUTCString.call(t)),ru(t)&&(l=" "+zd(t)),0!==o.length||d&&0!=t.length?n<0?eu(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),c=d?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)hu(t,String(s))?o.push(qd(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(qd(e,t,n,r,i,!0))})),o}(e,t,n,s,o):o.map((function(r){return qd(e,t,n,s,r,d)})),e.seen.pop(),function(e,t,n){var r=e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0);return r>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,l,u)):u[0]+l+u[1]}function zd(e){return"["+Error.prototype.toString.call(e)+"]"}function qd(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),hu(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=Gd(n)?Hd(e,c.value,null):Hd(e,c.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),Qd(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function Vd(e){return Array.isArray(e)}function Wd(e){return"boolean"==typeof e}function Gd(e){return null===e}function Yd(e){return null==e}function Zd(e){return"number"==typeof e}function Jd(e){return"string"==typeof e}function Xd(e){return"symbol"==typeof e}function Qd(e){return void 0===e}function eu(e){return tu(e)&&"[object RegExp]"===au(e)}function tu(e){return"object"==typeof e&&null!==e}function nu(e){return tu(e)&&"[object Date]"===au(e)}function ru(e){return tu(e)&&("[object Error]"===au(e)||e instanceof Error)}function iu(e){return"function"==typeof e}function ou(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function su(e){return et.isBuffer(e)}function au(e){return Object.prototype.toString.call(e)}function cu(e){return e<10?"0"+e.toString(10):e.toString(10)}Kd.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Kd.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var lu=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function du(){console.log("%s - %s",function(){var e=new Date,t=[cu(e.getHours()),cu(e.getMinutes()),cu(e.getSeconds())].join(":");return[e.getDate(),lu[e.getMonth()],t].join(" ")}(),Nd.apply(null,arguments))}function uu(e,t){if(!t||!tu(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}function hu(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var fu="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function pu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(fu&&e[fu]){var t;if("function"!=typeof(t=e[fu]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,fu,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,n,r=new Promise((function(e,r){t=e,n=r})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(e,r){e?n(e):t(r)}));try{e.apply(this,i)}catch(e){n(e)}return r}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),fu&&Object.defineProperty(t,fu,{value:t,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(t,Pd(e))}function gu(e,t){if(!e){var n=new Error("Promise was rejected with a falsy value");n.reason=e,e=n}return t(e)}function mu(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');function t(){for(var t=[],n=0;n<arguments.length;n++)t.push(arguments[n]);var r=t.pop();if("function"!=typeof r)throw new TypeError("The last argument must be of type Function");var i=this,o=function(){return r.apply(i,arguments)};e.apply(this,t).then((function(e){Dc.nextTick(o.bind(null,null,e))}),(function(e){Dc.nextTick(gu.bind(null,e,o))}))}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Pd(e)),t}pu.custom=fu;var yu,vu,bu,wu,Eu={inherits:Od,_extend:uu,log:du,isBuffer:su,isPrimitive:ou,isFunction:iu,isError:ru,isDate:nu,isObject:tu,isRegExp:eu,isUndefined:Qd,isSymbol:Xd,isString:Jd,isNumber:Zd,isNullOrUndefined:Yd,isNull:Gd,isBoolean:Wd,isArray:Vd,inspect:Kd,deprecate:Bd,format:Nd,debuglog:jd,promisify:pu,callbackify:mu},Cu=Ft(Object.freeze({__proto__:null,_extend:uu,callbackify:mu,debuglog:jd,default:Eu,deprecate:Bd,format:Nd,inherits:Od,inspect:Kd,isArray:Vd,isBoolean:Wd,isBuffer:su,isDate:nu,isError:ru,isFunction:iu,isNull:Gd,isNullOrUndefined:Yd,isNumber:Zd,isObject:tu,isPrimitive:ou,isRegExp:eu,isString:Jd,isSymbol:Xd,isUndefined:Qd,log:du,promisify:pu}));function _u(){if(vu)return yu;function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var r=1;r<arguments.length;r++){var i=null!=arguments[r]?arguments[r]:{};r%2?e(Object(i),!0).forEach((function(e){n(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):e(Object(i)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function n(e,t,n){return(t=r(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}vu=1;var i=Rd.Buffer,o=Cu.inspect,s=o&&o.custom||"inspect";return yu=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return function(e,t,n){t&&function(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,r(i.key),i)}}(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1})}(e,[{key:"push",value:function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n}},{key:"concat",value:function(e){if(0===this.length)return i.alloc(0);for(var t,n,r,o=i.allocUnsafe(e>>>0),s=this.head,a=0;s;)t=s.data,n=o,r=a,i.prototype.copy.call(t,n,r),a+=s.data.length,s=s.next;return o}},{key:"consume",value:function(e,t){var n;return e<this.head.data.length?(n=this.head.data.slice(0,e),this.head.data=this.head.data.slice(e)):n=e===this.head.data.length?this.shift():t?this._getString(e):this._getBuffer(e),n}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(e){var t=this.head,n=1,r=t.data;for(e-=r.length;t=t.next;){var i=t.data,o=e>i.length?i.length:e;if(o===i.length?r+=i:r+=i.slice(0,e),0==(e-=o)){o===i.length?(++n,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++n}return this.length-=n,r}},{key:"_getBuffer",value:function(e){var t=i.allocUnsafe(e),n=this.head,r=1;for(n.data.copy(t),e-=n.data.length;n=n.next;){var o=n.data,s=e>o.length?o.length:e;if(o.copy(t,t.length-e,0,s),0==(e-=s)){s===o.length?(++r,n.next?this.head=n.next:this.head=this.tail=null):(this.head=n,n.data=o.slice(s));break}++r}return this.length-=r,t}},{key:s,value:function(e,n){return o(this,t(t({},n),{},{depth:0,customInspect:!1}))}}]),e}(),yu}function Su(){if(wu)return bu;function e(e,r){n(e,r),t(e)}function t(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function n(e,t){e.emit("error",t)}return wu=1,bu={destroy:function(r,i){var o=this,s=this._readableState&&this._readableState.destroyed,a=this._writableState&&this._writableState.destroyed;return s||a?(i?i(r):r&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,Dc.nextTick(n,this,r)):Dc.nextTick(n,this,r)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(r||null,(function(n){!i&&n?o._writableState?o._writableState.errorEmitted?Dc.nextTick(t,o):(o._writableState.errorEmitted=!0,Dc.nextTick(e,o,n)):Dc.nextTick(e,o,n):i?(Dc.nextTick(t,o),i(n)):Dc.nextTick(t,o)})),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(e,t){var n=e._readableState,r=e._writableState;n&&n.autoDestroy||r&&r.autoDestroy?e.destroy(t):e.emit("error",t)}},bu}var ku,xu,Au={},Mu={};function Lu(e,t,n){n||(n=Error);var r=function(e){var n,r;function i(n,r,i){return e.call(this,function(e,n,r){return"string"==typeof t?t:t(e,n,r)}(n,r,i))||this}return r=e,(n=i).prototype=Object.create(r.prototype),n.prototype.constructor=n,n.__proto__=r,i}(n);r.prototype.name=n.name,r.prototype.code=e,Mu[e]=r}function Tu(e,t){if(Array.isArray(e)){var n=e.length;return e=e.map((function(e){return String(e)})),n>2?"one of ".concat(t," ").concat(e.slice(0,n-1).join(", "),", or ")+e[n-1]:2===n?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}function Ou(){if(xu)return ku;xu=1;var e=Au.codes.ERR_INVALID_OPT_VALUE;return ku={getHighWaterMark:function(t,n,r,i){var o=function(e,t,n){return null!=e.highWaterMark?e.highWaterMark:t?e[n]:null}(n,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new e(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}}Lu("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),Lu("ERR_INVALID_ARG_TYPE",(function(e,t,n){var r,i,o;if("string"==typeof t&&(i="not ",t.substr(0,4)===i)?(r="must not be",t=t.replace(/^not /,"")):r="must be",function(e,t,n){return(void 0===n||n>e.length)&&(n=e.length),e.substring(n-9,n)===t}(e," argument"))o="The ".concat(e," ").concat(r," ").concat(Tu(t,"type"));else{var s=function(e,t,n){return"number"!=typeof n&&(n=0),!(n+1>e.length)&&-1!==e.indexOf(".",n)}(e)?"property":"argument";o='The "'.concat(e,'" ').concat(s," ").concat(r," ").concat(Tu(t,"type"))}return o+". Received type ".concat(typeof n)}),TypeError),Lu("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),Lu("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),Lu("ERR_STREAM_PREMATURE_CLOSE","Premature close"),Lu("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),Lu("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),Lu("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),Lu("ERR_STREAM_WRITE_AFTER_END","write after end"),Lu("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),Lu("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),Lu("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),Au.codes=Mu;var Ru,Pu,Iu,Nu,Bu,Du,$u="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e},ju=Ft(Object.freeze({__proto__:null,default:$u}));function Ku(){if(Pu)return Ru;function e(e){try{if(!Kt.localStorage)return!1}catch(e){return!1}var t=Kt.localStorage[e];return null!=t&&"true"===String(t).toLowerCase()}return Pu=1,Ru=function(t,n){if(e("noDeprecation"))return t;var r=!1;return function(){if(!r){if(e("throwDeprecation"))throw new Error(n);e("traceDeprecation")?console.trace(n):console.warn(n),r=!0}return t.apply(this,arguments)}},Ru}function Uu(){if(Nu)return Iu;function e(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,n){var r=e.entry;for(e.entry=null;r;){var i=r.callback;t.pendingcb--,i(undefined),r=r.next}t.corkedRequestsFree.next=e}(t,e)}}var t;Nu=1,Iu=E,E.WritableState=w;var n,r={deprecate:Ku()},i=Td(),o=Rd.Buffer,s=(void 0!==Kt?Kt:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},a=Su(),c=Ou().getHighWaterMark,l=Au.codes,d=l.ERR_INVALID_ARG_TYPE,u=l.ERR_METHOD_NOT_IMPLEMENTED,h=l.ERR_MULTIPLE_CALLBACK,f=l.ERR_STREAM_CANNOT_PIPE,p=l.ERR_STREAM_DESTROYED,g=l.ERR_STREAM_NULL_VALUES,m=l.ERR_STREAM_WRITE_AFTER_END,y=l.ERR_UNKNOWN_ENCODING,v=a.errorOrDestroy;function b(){}function w(n,r,i){t=t||Fu(),n=n||{},"boolean"!=typeof i&&(i=r instanceof t),this.objectMode=!!n.objectMode,i&&(this.objectMode=this.objectMode||!!n.writableObjectMode),this.highWaterMark=c(this,n,"writableHighWaterMark",i),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var o=!1===n.decodeStrings;this.decodeStrings=!o,this.defaultEncoding=n.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if("function"!=typeof i)throw new h;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,r,i){--t.pendingcb,n?(Dc.nextTick(i,r),Dc.nextTick(A,e,t),e._writableState.errorEmitted=!0,v(e,r)):(i(r),e._writableState.errorEmitted=!0,v(e,r),A(e,t))}(e,n,r,t,i);else{var o=k(n)||e.destroyed;o||n.corked||n.bufferProcessing||!n.bufferedRequest||S(e,n),r?Dc.nextTick(_,e,n,o,i):_(e,n,o,i)}}(r,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==n.emitClose,this.autoDestroy=!!n.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}function E(e){var r=this instanceof(t=t||Fu());if(!r&&!n.call(E,this))return new E(e);this._writableState=new w(e,this,r),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),i.call(this)}function C(e,t,n,r,i,o,s){t.writelen=r,t.writecb=s,t.writing=!0,t.sync=!0,t.destroyed?t.onwrite(new p("write")):n?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function _(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),A(e,t)}function S(t,n){n.bufferProcessing=!0;var r=n.bufferedRequest;if(t._writev&&r&&r.next){var i=n.bufferedRequestCount,o=new Array(i),s=n.corkedRequestsFree;s.entry=r;for(var a=0,c=!0;r;)o[a]=r,r.isBuf||(c=!1),r=r.next,a+=1;o.allBuffers=c,C(t,n,!0,n.length,o,"",s.finish),n.pendingcb++,n.lastBufferedRequest=null,s.next?(n.corkedRequestsFree=s.next,s.next=null):n.corkedRequestsFree=new e(n),n.bufferedRequestCount=0}else{for(;r;){var l=r.chunk,d=r.encoding,u=r.callback;if(C(t,n,!1,n.objectMode?1:l.length,l,d,u),r=r.next,n.bufferedRequestCount--,n.writing)break}null===r&&(n.lastBufferedRequest=null)}n.bufferedRequest=r,n.bufferProcessing=!1}function k(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function x(e,t){e._final((function(n){t.pendingcb--,n&&v(e,n),t.prefinished=!0,e.emit("prefinish"),A(e,t)}))}function A(e,t){var n=k(t);if(n&&(function(e,t){t.prefinished||t.finalCalled||("function"!=typeof e._final||t.destroyed?(t.prefinished=!0,e.emit("prefinish")):(t.pendingcb++,t.finalCalled=!0,Dc.nextTick(x,e,t)))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"),t.autoDestroy))){var r=e._readableState;(!r||r.autoDestroy&&r.endEmitted)&&e.destroy()}return n}return ju(E,i),w.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(w.prototype,"buffer",{get:r.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(n=Function.prototype[Symbol.hasInstance],Object.defineProperty(E,Symbol.hasInstance,{value:function(e){return!!n.call(this,e)||this===E&&e&&e._writableState instanceof w}})):n=function(e){return e instanceof this},E.prototype.pipe=function(){v(this,new f)},E.prototype.write=function(e,t,n){var r,i=this._writableState,a=!1,c=!i.objectMode&&(r=e,o.isBuffer(r)||r instanceof s);return c&&!o.isBuffer(e)&&(e=function(e){return o.from(e)}(e)),"function"==typeof t&&(n=t,t=null),c?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof n&&(n=b),i.ending?function(e,t){var n=new m;v(e,n),Dc.nextTick(t,n)}(this,n):(c||function(e,t,n,r){var i;return null===n?i=new g:"string"==typeof n||t.objectMode||(i=new d("chunk",["string","Buffer"],n)),!i||(v(e,i),Dc.nextTick(r,i),!1)}(this,i,e,n))&&(i.pendingcb++,a=function(e,t,n,r,i,s){if(!n){var a=function(e,t,n){return e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=o.from(t,n)),t}(t,r,i);r!==a&&(n=!0,i="buffer",r=a)}var c=t.objectMode?1:r.length;t.length+=c;var l=t.length<t.highWaterMark;if(l||(t.needDrain=!0),t.writing||t.corked){var d=t.lastBufferedRequest;t.lastBufferedRequest={chunk:r,encoding:i,isBuf:n,callback:s,next:null},d?d.next=t.lastBufferedRequest:t.bufferedRequest=t.lastBufferedRequest,t.bufferedRequestCount+=1}else C(e,t,!1,c,r,i,s);return l}(this,i,c,e,t,n)),a},E.prototype.cork=function(){this._writableState.corked++},E.prototype.uncork=function(){var e=this._writableState;e.corked&&(e.corked--,e.writing||e.corked||e.bufferProcessing||!e.bufferedRequest||S(this,e))},E.prototype.setDefaultEncoding=function(e){if("string"==typeof e&&(e=e.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((e+"").toLowerCase())>-1))throw new y(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(E.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(E.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),E.prototype._write=function(e,t,n){n(new u("_write()"))},E.prototype._writev=null,E.prototype.end=function(e,t,n){var r=this._writableState;return"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),r.corked&&(r.corked=1,this.uncork()),r.ending||function(e,t,n){t.ending=!0,A(e,t),n&&(t.finished?Dc.nextTick(n):e.once("finish",n)),t.ended=!0,e.writable=!1}(this,r,n),this},Object.defineProperty(E.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),E.prototype.destroy=a.destroy,E.prototype._undestroy=a.undestroy,E.prototype._destroy=function(e,t){t(e)},Iu}function Fu(){if(Du)return Bu;Du=1;var e=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t};Bu=s;var t=ih(),n=Uu();ju(s,t);for(var r=e(n.prototype),i=0;i<r.length;i++){var o=r[i];s.prototype[o]||(s.prototype[o]=n.prototype[o])}function s(e){if(!(this instanceof s))return new s(e);t.call(this,e),n.call(this,e),this.allowHalfOpen=!0,e&&(!1===e.readable&&(this.readable=!1),!1===e.writable&&(this.writable=!1),!1===e.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",a)))}function a(){this._writableState.ended||Dc.nextTick(c,this)}function c(e){e.end()}return Object.defineProperty(s.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(s.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(s.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(s.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(e){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=e,this._writableState.destroyed=e)}}),Bu}var Hu=et.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function zu(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),function(e){if(e&&!Hu(e))throw new Error("Unknown encoding: "+e)}(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=Vu;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=Wu;break;default:return void(this.write=qu)}this.charBuffer=new et(6),this.charReceived=0,this.charLength=0}function qu(e){return e.toString(this.encoding)}function Vu(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function Wu(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}zu.prototype.write=function(e){for(var t="";this.charLength;){var n=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,n),this.charReceived+=n,this.charReceived<this.charLength)return"";if(e=e.slice(n,e.length),!((r=(t=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(t.length-1))>=55296&&r<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var r,i=e.length;if(this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,i),i-=this.charReceived),i=(t+=e.toString(this.encoding,0,i)).length-1,(r=t.charCodeAt(i))>=55296&&r<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),e.copy(this.charBuffer,0,0,o),t.substring(0,i)}return t},zu.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(t<=2&&n>>4==14){this.charLength=3;break}if(t<=3&&n>>3==30){this.charLength=4;break}}this.charReceived=t},zu.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t};var Gu=Ft(Object.freeze({__proto__:null,StringDecoder:zu})),Yu=Au.codes.ERR_STREAM_PREMATURE_CLOSE;function Zu(){}var Ju,Xu,Qu,eh,th,nh,rh=function e(t,n,r){if("function"==typeof n)return e(t,null,n);n||(n={}),r=function(e){var t=!1;return function(){if(!t){t=!0;for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];e.apply(this,r)}}}(r||Zu);var i=n.readable||!1!==n.readable&&t.readable,o=n.writable||!1!==n.writable&&t.writable,s=function(){t.writable||c()},a=t._writableState&&t._writableState.finished,c=function(){o=!1,a=!0,i||r.call(t)},l=t._readableState&&t._readableState.endEmitted,d=function(){i=!1,l=!0,o||r.call(t)},u=function(e){r.call(t,e)},h=function(){var e;return i&&!l?(t._readableState&&t._readableState.ended||(e=new Yu),r.call(t,e)):o&&!a?(t._writableState&&t._writableState.ended||(e=new Yu),r.call(t,e)):void 0},f=function(){t.req.on("finish",c)};return function(e){return e.setHeader&&"function"==typeof e.abort}(t)?(t.on("complete",c),t.on("abort",h),t.req?f():t.on("request",f)):o&&!t._writableState&&(t.on("end",s),t.on("close",s)),t.on("end",d),t.on("finish",c),!1!==n.error&&t.on("error",u),t.on("close",h),function(){t.removeListener("complete",c),t.removeListener("abort",h),t.removeListener("request",f),t.req&&t.req.removeListener("finish",c),t.removeListener("end",s),t.removeListener("close",s),t.removeListener("finish",c),t.removeListener("end",d),t.removeListener("error",u),t.removeListener("close",h)}};function ih(){if(nh)return th;var e;nh=1,th=E,E.ReadableState=w,Pl.EventEmitter;var t,n=function(e,t){return e.listeners(t).length},r=Td(),i=Rd.Buffer,o=(void 0!==Kt?Kt:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},s=Cu;t=s&&s.debuglog?s.debuglog("stream"):function(){};var a,c,l,d=_u(),u=Su(),h=Ou().getHighWaterMark,f=Au.codes,p=f.ERR_INVALID_ARG_TYPE,g=f.ERR_STREAM_PUSH_AFTER_EOF,m=f.ERR_METHOD_NOT_IMPLEMENTED,y=f.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;ju(E,r);var v=u.errorOrDestroy,b=["error","close","destroy","pause","resume"];function w(t,n,r){e=e||Fu(),t=t||{},"boolean"!=typeof r&&(r=n instanceof e),this.objectMode=!!t.objectMode,r&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=h(this,t,"readableHighWaterMark",r),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(a||(a=Gu.StringDecoder),this.decoder=new a(t.encoding),this.encoding=t.encoding)}function E(t){if(e=e||Fu(),!(this instanceof E))return new E(t);var n=this instanceof e;this._readableState=new w(t,this,n),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),r.call(this)}function C(e,n,r,s,a){t("readableAddChunk",n);var c,l=e._readableState;if(null===n)l.reading=!1,function(e,n){if(t("onEofChunk"),!n.ended){if(n.decoder){var r=n.decoder.end();r&&r.length&&(n.buffer.push(r),n.length+=n.objectMode?1:r.length)}n.ended=!0,n.sync?x(e):(n.needReadable=!1,n.emittedReadable||(n.emittedReadable=!0,A(e)))}}(e,l);else if(a||(c=function(e,t){var n,r;return r=t,i.isBuffer(r)||r instanceof o||"string"==typeof t||void 0===t||e.objectMode||(n=new p("chunk",["string","Buffer","Uint8Array"],t)),n}(l,n)),c)v(e,c);else if(l.objectMode||n&&n.length>0)if("string"==typeof n||l.objectMode||Object.getPrototypeOf(n)===i.prototype||(n=function(e){return i.from(e)}(n)),s)l.endEmitted?v(e,new y):_(e,l,n,!0);else if(l.ended)v(e,new g);else{if(l.destroyed)return!1;l.reading=!1,l.decoder&&!r?(n=l.decoder.write(n),l.objectMode||0!==n.length?_(e,l,n,!1):M(e,l)):_(e,l,n,!1)}else s||(l.reading=!1,M(e,l));return!l.ended&&(l.length<l.highWaterMark||0===l.length)}function _(e,t,n,r){t.flowing&&0===t.length&&!t.sync?(t.awaitDrain=0,e.emit("data",n)):(t.length+=t.objectMode?1:n.length,r?t.buffer.unshift(n):t.buffer.push(n),t.needReadable&&x(e)),M(e,t)}Object.defineProperty(E.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(e){this._readableState&&(this._readableState.destroyed=e)}}),E.prototype.destroy=u.destroy,E.prototype._undestroy=u.undestroy,E.prototype._destroy=function(e,t){t(e)},E.prototype.push=function(e,t){var n,r=this._readableState;return r.objectMode?n=!0:"string"==typeof e&&((t=t||r.defaultEncoding)!==r.encoding&&(e=i.from(e,t),t=""),n=!0),C(this,e,t,!1,n)},E.prototype.unshift=function(e){return C(this,e,null,!0,!1)},E.prototype.isPaused=function(){return!1===this._readableState.flowing},E.prototype.setEncoding=function(e){a||(a=Gu.StringDecoder);var t=new a(e);this._readableState.decoder=t,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,r="";null!==n;)r+=t.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==r&&this._readableState.buffer.push(r),this._readableState.length=r.length,this};var S=1073741824;function k(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=function(e){return e>=S?e=S:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function x(e){var n=e._readableState;t("emitReadable",n.needReadable,n.emittedReadable),n.needReadable=!1,n.emittedReadable||(t("emitReadable",n.flowing),n.emittedReadable=!0,Dc.nextTick(A,e))}function A(e){var n=e._readableState;t("emitReadable_",n.destroyed,n.length,n.ended),n.destroyed||!n.length&&!n.ended||(e.emit("readable"),n.emittedReadable=!1),n.needReadable=!n.flowing&&!n.ended&&n.length<=n.highWaterMark,P(e)}function M(e,t){t.readingMore||(t.readingMore=!0,Dc.nextTick(L,e,t))}function L(e,n){for(;!n.reading&&!n.ended&&(n.length<n.highWaterMark||n.flowing&&0===n.length);){var r=n.length;if(t("maybeReadMore read 0"),e.read(0),r===n.length)break}n.readingMore=!1}function T(e){var t=e._readableState;t.readableListening=e.listenerCount("readable")>0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function O(e){t("readable nexttick read 0"),e.read(0)}function R(e,n){t("resume",n.reading),n.reading||e.read(0),n.resumeScheduled=!1,e.emit("resume"),P(e),n.flowing&&!n.reading&&e.read(0)}function P(e){var n=e._readableState;for(t("flow",n.flowing);n.flowing&&null!==e.read(););}function I(e,t){return 0===t.length?null:(t.objectMode?n=t.buffer.shift():!e||e>=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):n=t.buffer.consume(e,t.decoder),n);var n}function N(e){var n=e._readableState;t("endReadable",n.endEmitted),n.endEmitted||(n.ended=!0,Dc.nextTick(B,n,e))}function B(e,n){if(t("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,n.readable=!1,n.emit("end"),e.autoDestroy)){var r=n._writableState;(!r||r.autoDestroy&&r.finished)&&n.destroy()}}function D(e,t){for(var n=0,r=e.length;n<r;n++)if(e[n]===t)return n;return-1}return E.prototype.read=function(e){t("read",e),e=parseInt(e,10);var n=this._readableState,r=e;if(0!==e&&(n.emittedReadable=!1),0===e&&n.needReadable&&((0!==n.highWaterMark?n.length>=n.highWaterMark:n.length>0)||n.ended))return t("read: emitReadable",n.length,n.ended),0===n.length&&n.ended?N(this):x(this),null;if(0===(e=k(e,n))&&n.ended)return 0===n.length&&N(this),null;var i,o=n.needReadable;return t("need readable",o),(0===n.length||n.length-e<n.highWaterMark)&&t("length less than watermark",o=!0),n.ended||n.reading?t("reading or ended",o=!1):o&&(t("do read"),n.reading=!0,n.sync=!0,0===n.length&&(n.needReadable=!0),this._read(n.highWaterMark),n.sync=!1,n.reading||(e=k(r,n))),null===(i=e>0?I(e,n):null)?(n.needReadable=n.length<=n.highWaterMark,e=0):(n.length-=e,n.awaitDrain=0),0===n.length&&(n.ended||(n.needReadable=!0),r!==e&&n.ended&&N(this)),null!==i&&this.emit("data",i),i},E.prototype._read=function(e){v(this,new m("_read()"))},E.prototype.pipe=function(e,r){var i=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,t("pipe count=%d opts=%j",o.pipesCount,r);var s=r&&!1===r.end||e===Dc.stdout||e===Dc.stderr?p:a;function a(){t("onend"),e.end()}o.endEmitted?Dc.nextTick(s):i.once("end",s),e.on("unpipe",(function n(r,s){t("onunpipe"),r===i&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,t("cleanup"),e.removeListener("close",h),e.removeListener("finish",f),e.removeListener("drain",c),e.removeListener("error",u),e.removeListener("unpipe",n),i.removeListener("end",a),i.removeListener("end",p),i.removeListener("data",d),l=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}));var c=function(e){return function(){var r=e._readableState;t("pipeOnDrain",r.awaitDrain),r.awaitDrain&&r.awaitDrain--,0===r.awaitDrain&&n(e,"data")&&(r.flowing=!0,P(e))}}(i);e.on("drain",c);var l=!1;function d(n){t("ondata");var r=e.write(n);t("dest.write",r),!1===r&&((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==D(o.pipes,e))&&!l&&(t("false write response, pause",o.awaitDrain),o.awaitDrain++),i.pause())}function u(r){t("onerror",r),p(),e.removeListener("error",u),0===n(e,"error")&&v(e,r)}function h(){e.removeListener("finish",f),p()}function f(){t("onfinish"),e.removeListener("close",h),p()}function p(){t("unpipe"),i.unpipe(e)}return i.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",u),e.once("close",h),e.once("finish",f),e.emit("pipe",i),o.flowing||(t("pipe resume"),i.resume()),e},E.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o<i;o++)r[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=D(t.pipes,e);return-1===s||(t.pipes.splice(s,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this,n)),this},E.prototype.on=function(e,n){var i=r.prototype.on.call(this,e,n),o=this._readableState;return"data"===e?(o.readableListening=this.listenerCount("readable")>0,!1!==o.flowing&&this.resume()):"readable"===e&&(o.endEmitted||o.readableListening||(o.readableListening=o.needReadable=!0,o.flowing=!1,o.emittedReadable=!1,t("on readable",o.length,o.reading),o.length?x(this):o.reading||Dc.nextTick(O,this))),i},E.prototype.addListener=E.prototype.on,E.prototype.removeListener=function(e,t){var n=r.prototype.removeListener.call(this,e,t);return"readable"===e&&Dc.nextTick(T,this),n},E.prototype.removeAllListeners=function(e){var t=r.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||Dc.nextTick(T,this),t},E.prototype.resume=function(){var e=this._readableState;return e.flowing||(t("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,Dc.nextTick(R,e,t))}(this,e)),e.paused=!1,this},E.prototype.pause=function(){return t("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(t("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},E.prototype.wrap=function(e){var n=this,r=this._readableState,i=!1;for(var o in e.on("end",(function(){if(t("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&n.push(e)}n.push(null)})),e.on("data",(function(o){t("wrapped data"),r.decoder&&(o=r.decoder.write(o)),r.objectMode&&null==o||(r.objectMode||o&&o.length)&&(n.push(o)||(i=!0,e.pause()))})),e)void 0===this[o]&&"function"==typeof e[o]&&(this[o]=function(t){return function(){return e[t].apply(e,arguments)}}(o));for(var s=0;s<b.length;s++)e.on(b[s],this.emit.bind(this,b[s]));return this._read=function(n){t("wrapped _read",n),i&&(i=!1,e.resume())},this},"function"==typeof Symbol&&(E.prototype[Symbol.asyncIterator]=function(){return void 0===c&&(c=function(){if(Xu)return Ju;var e;function t(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}Xu=1;var n=rh,r=Symbol("lastResolve"),i=Symbol("lastReject"),o=Symbol("error"),s=Symbol("ended"),a=Symbol("lastPromise"),c=Symbol("handlePromise"),l=Symbol("stream");function d(e,t){return{value:e,done:t}}function u(e){var t=e[r];if(null!==t){var n=e[l].read();null!==n&&(e[a]=null,e[r]=null,e[i]=null,t(d(n,!1)))}}function h(e){Dc.nextTick(u,e)}var f=Object.getPrototypeOf((function(){})),p=Object.setPrototypeOf((t(e={get stream(){return this[l]},next:function(){var e=this,t=this[o];if(null!==t)return Promise.reject(t);if(this[s])return Promise.resolve(d(void 0,!0));if(this[l].destroyed)return new Promise((function(t,n){Dc.nextTick((function(){e[o]?n(e[o]):t(d(void 0,!0))}))}));var n,r=this[a];if(r)n=new Promise(function(e,t){return function(n,r){e.then((function(){t[s]?n(d(void 0,!0)):t[c](n,r)}),r)}}(r,this));else{var i=this[l].read();if(null!==i)return Promise.resolve(d(i,!1));n=new Promise(this[c])}return this[a]=n,n}},Symbol.asyncIterator,(function(){return this})),t(e,"return",(function(){var e=this;return new Promise((function(t,n){e[l].destroy(null,(function(e){e?n(e):t(d(void 0,!0))}))}))})),e),f);return Ju=function(e){var u,f=Object.create(p,(t(u={},l,{value:e,writable:!0}),t(u,r,{value:null,writable:!0}),t(u,i,{value:null,writable:!0}),t(u,o,{value:null,writable:!0}),t(u,s,{value:e._readableState.endEmitted,writable:!0}),t(u,c,{value:function(e,t){var n=f[l].read();n?(f[a]=null,f[r]=null,f[i]=null,e(d(n,!1))):(f[r]=e,f[i]=t)},writable:!0}),u));return f[a]=null,n(e,(function(e){if(e&&"ERR_STREAM_PREMATURE_CLOSE"!==e.code){var t=f[i];return null!==t&&(f[a]=null,f[r]=null,f[i]=null,t(e)),void(f[o]=e)}var n=f[r];null!==n&&(f[a]=null,f[r]=null,f[i]=null,n(d(void 0,!0))),f[s]=!0})),e.on("readable",h.bind(null,f)),f},Ju}()),c(this)}),Object.defineProperty(E.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(E.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(E.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(e){this._readableState&&(this._readableState.flowing=e)}}),E._fromList=I,Object.defineProperty(E.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(E.from=function(e,t){return void 0===l&&(l=eh?Qu:(eh=1,Qu=function(){throw new Error("Readable.from is not available in the browser")})),l(E,e,t)}),th}var oh=fh,sh=Au.codes,ah=sh.ERR_METHOD_NOT_IMPLEMENTED,ch=sh.ERR_MULTIPLE_CALLBACK,lh=sh.ERR_TRANSFORM_ALREADY_TRANSFORMING,dh=sh.ERR_TRANSFORM_WITH_LENGTH_0,uh=Fu();function hh(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(null===r)return this.emit("error",new ch);n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function fh(e){if(!(this instanceof fh))return new fh(e);uh.call(this,e),this._transformState={afterTransform:hh.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&("function"==typeof e.transform&&(this._transform=e.transform),"function"==typeof e.flush&&(this._flush=e.flush)),this.on("prefinish",ph)}function ph(){var e=this;"function"!=typeof this._flush||this._readableState.destroyed?gh(this,null,null):this._flush((function(t,n){gh(e,t,n)}))}function gh(e,t,n){if(t)return e.emit("error",t);if(null!=n&&e.push(n),e._writableState.length)throw new dh;if(e._transformState.transforming)throw new lh;return e.push(null)}ju(fh,uh),fh.prototype.push=function(e,t){return this._transformState.needTransform=!1,uh.prototype.push.call(this,e,t)},fh.prototype._transform=function(e,t,n){n(new ah("_transform()"))},fh.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},fh.prototype._read=function(e){var t=this._transformState;null===t.writechunk||t.transforming?t.needTransform=!0:(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform))},fh.prototype._destroy=function(e,t){uh.prototype._destroy.call(this,e,(function(e){t(e)}))};var mh,yh=bh,vh=oh;function bh(e){if(!(this instanceof bh))return new bh(e);vh.call(this,e)}ju(bh,vh),bh.prototype._transform=function(e,t,n){n(null,e)};var wh=Au.codes,Eh=wh.ERR_MISSING_ARGS,Ch=wh.ERR_STREAM_DESTROYED;function _h(e){if(e)throw e}function Sh(e){e()}function kh(e,t){return e.pipe(t)}var xh=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=function(e){return e.length?"function"!=typeof e[e.length-1]?_h:e.pop():_h}(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Eh("streams");var o=t.map((function(e,n){var s=n<t.length-1;return function(e,t,n,r){r=function(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}(r);var i=!1;e.on("close",(function(){i=!0})),void 0===mh&&(mh=rh),mh(e,{readable:t,writable:n},(function(e){if(e)return r(e);i=!0,r()}));var o=!1;return function(t){if(!i&&!o)return o=!0,function(e){return e.setHeader&&"function"==typeof e.abort}(e)?e.abort():"function"==typeof e.destroy?e.destroy():void r(t||new Ch("pipe"))}}(e,s,n>0,(function(e){r||(r=e),e&&o.forEach(Sh),s||(o.forEach(Sh),i(r))}))}));return t.reduce(kh)};!function(e,t){(t=Ld.exports=ih()).Stream=t,t.Readable=t,t.Writable=Uu(),t.Duplex=Fu(),t.Transform=oh,t.PassThrough=yh,t.finished=rh,t.pipeline=xh}(0,Ld.exports);var Ah=Ld.exports;var Mh={},Lh={exports:{}},Th=function e(t,n){if(t&&n)return e(t)(n);if("function"!=typeof t)throw new TypeError("need wrapper function");return Object.keys(t).forEach((function(e){r[e]=t[e]})),r;function r(){for(var e=new Array(arguments.length),n=0;n<e.length;n++)e[n]=arguments[n];var r=t.apply(this,e),i=e[e.length-1];return"function"==typeof r&&r!==i&&Object.keys(i).forEach((function(e){r[e]=i[e]})),r}};function Oh(e){var t=function(){return t.called?t.value:(t.called=!0,t.value=e.apply(this,arguments))};return t.called=!1,t}function Rh(e){var t=function(){if(t.called)throw new Error(t.onceError);return t.called=!0,t.value=e.apply(this,arguments)},n=e.name||"Function wrapped with `once`";return t.onceError=n+" shouldn't be called more than once",t.called=!1,t}Lh.exports=Th(Oh),Lh.exports.strict=Th(Rh),Oh.proto=Oh((function(){Object.defineProperty(Function.prototype,"once",{value:function(){return Oh(this)},configurable:!0}),Object.defineProperty(Function.prototype,"onceStrict",{value:function(){return Rh(this)},configurable:!0})}));var Ph=Lh.exports,Ih={};Object.defineProperty(Ih,"__esModule",{value:!0}),Ih.Substream=void 0;const Nh=Ah;class Bh extends Nh.Duplex{constructor({parent:e,name:t}){super({objectMode:!0}),this._parent=e,this._name=t}_read(){}_write(e,t,n){this._parent.push({name:this._name,data:e}),n()}}Ih.Substream=Bh;var Dh=Kt&&Kt.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Mh,"__esModule",{value:!0}),Mh.ObjectMultiplex=void 0;const $h=Ah,jh=Dh(Ph),Kh=Ih,Uh=Symbol("IGNORE_SUBSTREAM");let Fh=class extends $h.Duplex{constructor(e={}){super(Object.assign(Object.assign({},e),{objectMode:!0})),this._substreams={}}createStream(e){if(this.destroyed)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already destroyed`);if(this._readableState.ended||this._writableState.ended)throw new Error(`ObjectMultiplex - parent stream for name "${e}" already ended`);if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);const t=new Kh.Substream({parent:this,name:e});return this._substreams[e]=t,function(e,t){const n=(0,jh.default)(t);(0,$h.finished)(e,{readable:!1},n),(0,$h.finished)(e,{writable:!1},n)}(this,(e=>t.destroy(e||void 0))),t}ignoreStream(e){if(!e)throw new Error("ObjectMultiplex - name must not be empty");if(this._substreams[e])throw new Error(`ObjectMultiplex - Substream for name "${e}" already exists`);this._substreams[e]=Uh}_read(){}_write(e,t,n){const{name:r,data:i}=e;if(!r)return console.warn(`ObjectMultiplex - malformed chunk without name "${e}"`),n();const o=this._substreams[r];return o?(o!==Uh&&o.push(i),n()):(console.warn(`ObjectMultiplex - orphaned data for stream "${r}"`),n())}};Mh.ObjectMultiplex=Fh;var Hh=Ut(Mh.ObjectMultiplex);const zh=e=>null!==e&&"object"==typeof e&&"function"==typeof e.pipe;zh.writable=e=>zh(e)&&!1!==e.writable&&"function"==typeof e._write&&"object"==typeof e._writableState,zh.readable=e=>zh(e)&&!1!==e.readable&&"function"==typeof e._read&&"object"==typeof e._readableState,zh.duplex=e=>zh.writable(e)&&zh.readable(e),zh.transform=e=>zh.duplex(e)&&"function"==typeof e._transform;var qh,Vh=zh,Wh=class extends Md{constructor(e,{jsonRpcStreamName:t,logger:n=console,maxEventListeners:r=100,rpcMiddleware:i=[]}){if(super({logger:n,maxEventListeners:r,rpcMiddleware:i}),!Vh.duplex(e))throw new Error(Ra.errors.invalidDuplexStream());this._handleStreamDisconnect=this._handleStreamDisconnect.bind(this);const o=new Hh;Ah.pipeline(e,o,e,this._handleStreamDisconnect.bind(this,"MetaMask")),this._jsonRpcConnection=function(e={}){const t={},n=new Ah.Duplex({objectMode:!0,read:()=>{},write:function(n,o,s){let a=null;try{n.id?function(e){const{id:n}=e;if(null===n)return;const r=t[n];r?(delete t[n],Object.assign(r.res,e),setTimeout(r.end)):console.warn(`StreamMiddleware - Unknown response id "${n}"`)}(n):function(n){e?.retryOnMessage&&n.method===e.retryOnMessage&&Object.values(t).forEach((({req:e,retryCount:n=0})=>{if(!e.id)return;if(n>=3)throw new Error(`StreamMiddleware - Retry limit exceeded for request id "${e.id}"`);const r=t[e.id];r&&(r.retryCount=n+1),i(e)})),r.emit("notification",n)}(n)}catch(e){a=e}s(a)}}),r=new nd;return{events:r,middleware:(e,n,r,o)=>{t[e.id]={req:e,res:n,next:r,end:o},i(e)},stream:n};function i(e){n.push(e)}}({retryOnMessage:"METAMASK_EXTENSION_CONNECT_CAN_RETRY"}),Ah.pipeline(this._jsonRpcConnection.stream,o.createStream(t),this._jsonRpcConnection.stream,this._handleStreamDisconnect.bind(this,"MetaMask RpcProvider")),this._rpcEngine.push(this._jsonRpcConnection.middleware),this._jsonRpcConnection.events.on("notification",(t=>{const{method:n,params:r}=t;"metamask_accountsChanged"===n?this._handleAccountsChanged(r):"metamask_unlockStateChanged"===n?this._handleUnlockStateChanged(r):"metamask_chainChanged"===n?this._handleChainChanged(r):sd.includes(n)?this.emit("message",{type:n,data:r}):"METAMASK_STREAM_FAILURE"===n&&e.destroy(new Error(Ra.errors.permanentlyDisconnected()))}))}async _initializeStateAsync(){let e;try{e=await this.request({method:"metamask_getProviderState"})}catch(e){this._log.error("MetaMask: Failed to get initial state. Please report this bug.",e)}this._initializeState(e)}_handleStreamDisconnect(e,t){let n=`MetaMask: Lost connection to "${e}".`;t?.stack&&(n+=`\n${t.stack}`),this._log.warn(n),this.listenerCount("error")>0&&this.emit("error",n),this._handleDisconnect(!1,t?t.message:void 0)}_handleChainChanged({chainId:e,networkVersion:t}={}){dd(e)&&(e=>Boolean(e)&&"string"==typeof e)(t)?"loading"===t?this._handleDisconnect(!0):super._handleChainChanged({chainId:e}):this._log.error(Ra.errors.invalidNetworkParams(),{chainId:e,networkVersion:t})}},Gh=class extends Wh{constructor(e,{jsonRpcStreamName:t="metamask-provider",logger:n=console,maxEventListeners:r=100,shouldSendMetadata:i}={}){if(super(e,{jsonRpcStreamName:t,logger:n,maxEventListeners:r,rpcMiddleware:ad(n)}),this._sentWarnings={chainId:!1,networkVersion:!1,selectedAddress:!1,enable:!1,experimentalMethods:!1,send:!1,events:{close:!1,data:!1,networkChanged:!1,notification:!1}},vd(this,qh,void 0),this._initializeStateAsync(),bd(this,qh,null),this.isMetaMask=!0,this._sendSync=this._sendSync.bind(this),this.enable=this.enable.bind(this),this.send=this.send.bind(this),this.sendAsync=this.sendAsync.bind(this),this._warnOfDeprecation=this._warnOfDeprecation.bind(this),this._metamask=this._getExperimentalApi(),this._jsonRpcConnection.events.on("notification",(e=>{const{method:t}=e;sd.includes(t)&&(this.emit("data",e),this.emit("notification",e.params.result))})),i)if("complete"===document.readyState)hd(this._rpcEngine,this._log);else{const e=()=>{hd(this._rpcEngine,this._log),window.removeEventListener("DOMContentLoaded",e)};window.addEventListener("DOMContentLoaded",e)}}get chainId(){return this._sentWarnings.chainId||(this._log.warn(Ra.warnings.chainIdDeprecation),this._sentWarnings.chainId=!0),super.chainId}get networkVersion(){return this._sentWarnings.networkVersion||(this._log.warn(Ra.warnings.networkVersionDeprecation),this._sentWarnings.networkVersion=!0),yd(this,qh)}get selectedAddress(){return this._sentWarnings.selectedAddress||(this._log.warn(Ra.warnings.selectedAddressDeprecation),this._sentWarnings.selectedAddress=!0),super.selectedAddress}sendAsync(e,t){this._rpcRequest(e,t)}addListener(e,t){return this._warnOfDeprecation(e),super.addListener(e,t)}on(e,t){return this._warnOfDeprecation(e),super.on(e,t)}once(e,t){return this._warnOfDeprecation(e),super.once(e,t)}prependListener(e,t){return this._warnOfDeprecation(e),super.prependListener(e,t)}prependOnceListener(e,t){return this._warnOfDeprecation(e),super.prependOnceListener(e,t)}_handleDisconnect(e,t){super._handleDisconnect(e,t),yd(this,qh)&&!e&&bd(this,qh,null)}_warnOfDeprecation(e){!1===this._sentWarnings?.events[e]&&(this._log.warn(Ra.warnings.events[e]),this._sentWarnings.events[e]=!0)}async enable(){return this._sentWarnings.enable||(this._log.warn(Ra.warnings.enableDeprecation),this._sentWarnings.enable=!0),new Promise(((e,t)=>{try{this._rpcRequest({method:"eth_requestAccounts",params:[]},ld(e,t))}catch(e){t(e)}}))}send(e,t){return this._sentWarnings.send||(this._log.warn(Ra.warnings.sendDeprecation),this._sentWarnings.send=!0),"string"!=typeof e||t&&!Array.isArray(t)?e&&"object"==typeof e&&"function"==typeof t?this._rpcRequest(e,t):this._sendSync(e):new Promise(((n,r)=>{try{this._rpcRequest({method:e,params:t},ld(n,r,!1))}catch(e){r(e)}}))}_sendSync(e){let t;switch(e.method){case"eth_accounts":t=this.selectedAddress?[this.selectedAddress]:[];break;case"eth_coinbase":t=this.selectedAddress??null;break;case"eth_uninstallFilter":this._rpcRequest(e,ud),t=!0;break;case"net_version":t=yd(this,qh)??null;break;default:throw new Error(Ra.errors.unsupportedSync(e.method))}return{id:e.id,jsonrpc:e.jsonrpc,result:t}}_getExperimentalApi(){return new Proxy({isUnlocked:async()=>(this._state.initialized||await new Promise((e=>{this.on("_initialized",(()=>e()))})),this._state.isUnlocked),requestBatch:async e=>{if(!Array.isArray(e))throw Sl({message:"Batch requests must be made with an array of request objects.",data:e});return new Promise(((t,n)=>{this._rpcRequest(e,ld(t,n))}))}},{get:(e,t,...n)=>(this._sentWarnings.experimentalMethods||(this._log.warn(Ra.warnings.experimentalMethods),this._sentWarnings.experimentalMethods=!0),Reflect.get(e,t,...n))})}_handleChainChanged({chainId:e,networkVersion:t}={}){super._handleChainChanged({chainId:e,networkVersion:t}),this._state.isConnected&&t!==yd(this,qh)&&(bd(this,qh,t),this._state.initialized&&this.emit("networkChanged",yd(this,qh)))}};qh=new WeakMap;const Yh=f("MM_SDK");Yh.color="#FFAC1C";var Zh={},Jh={};Object.defineProperty(Jh,"__esModule",{value:!0}),Jh.EthereumProviderError=Jh.EthereumRpcError=void 0;const Xh=cl;class Qh extends Error{constructor(e,t,n){if(!Number.isInteger(e))throw new Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw new Error('"message" must be a nonempty string.');super(t),this.code=e,void 0!==n&&(this.data=n)}serialize(){const e={code:this.code,message:this.message};return void 0!==this.data&&(e.data=this.data),this.stack&&(e.stack=this.stack),e}toString(){return Xh.default(this.serialize(),ef,2)}}function ef(e,t){if("[Circular]"!==t)return t}Jh.EthereumRpcError=Qh,Jh.EthereumProviderError=class extends Qh{constructor(e,t,n){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw new Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,n)}};var tf={},nf={};Object.defineProperty(nf,"__esModule",{value:!0}),nf.errorValues=nf.errorCodes=void 0,nf.errorCodes={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}},nf.errorValues={"-32700":{standard:"JSON RPC 2.0",message:"Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text."},"-32600":{standard:"JSON RPC 2.0",message:"The JSON sent is not a valid Request object."},"-32601":{standard:"JSON RPC 2.0",message:"The method does not exist / is not available."},"-32602":{standard:"JSON RPC 2.0",message:"Invalid method parameter(s)."},"-32603":{standard:"JSON RPC 2.0",message:"Internal JSON-RPC error."},"-32000":{standard:"EIP-1474",message:"Invalid input."},"-32001":{standard:"EIP-1474",message:"Resource not found."},"-32002":{standard:"EIP-1474",message:"Resource unavailable."},"-32003":{standard:"EIP-1474",message:"Transaction rejected."},"-32004":{standard:"EIP-1474",message:"Method not supported."},"-32005":{standard:"EIP-1474",message:"Request limit exceeded."},4001:{standard:"EIP-1193",message:"User rejected the request."},4100:{standard:"EIP-1193",message:"The requested account and/or method has not been authorized by the user."},4200:{standard:"EIP-1193",message:"The requested method is not supported by this Ethereum provider."},4900:{standard:"EIP-1193",message:"The provider is disconnected from all chains."},4901:{standard:"EIP-1193",message:"The provider is disconnected from the specified chain."}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.serializeError=e.isValidCode=e.getMessageFromCode=e.JSON_RPC_SERVER_ERROR_MESSAGE=void 0;const t=nf,n=Jh,r=t.errorCodes.rpc.internal,i={code:r,message:o(r)};function o(n,r="Unspecified error message. This is a bug, please report it."){if(Number.isInteger(n)){const r=n.toString();if(l(t.errorValues,r))return t.errorValues[r].message;if(a(n))return e.JSON_RPC_SERVER_ERROR_MESSAGE}return r}function s(e){if(!Number.isInteger(e))return!1;const n=e.toString();return!!t.errorValues[n]||!!a(e)}function a(e){return e>=-32099&&e<=-32e3}function c(e){return e&&"object"==typeof e&&!Array.isArray(e)?Object.assign({},e):e}function l(e,t){return Object.prototype.hasOwnProperty.call(e,t)}e.JSON_RPC_SERVER_ERROR_MESSAGE="Unspecified server error.",e.getMessageFromCode=o,e.isValidCode=s,e.serializeError=function(e,{fallbackError:t=i,shouldIncludeStack:r=!1}={}){var a,d;if(!t||!Number.isInteger(t.code)||"string"!=typeof t.message)throw new Error("Must provide fallback error with integer number code and string message.");if(e instanceof n.EthereumRpcError)return e.serialize();const u={};if(e&&"object"==typeof e&&!Array.isArray(e)&&l(e,"code")&&s(e.code)){const t=e;u.code=t.code,t.message&&"string"==typeof t.message?(u.message=t.message,l(t,"data")&&(u.data=t.data)):(u.message=o(u.code),u.data={originalError:c(e)})}else{u.code=t.code;const n=null===(a=e)||void 0===a?void 0:a.message;u.message=n&&"string"==typeof n?n:t.message,u.data={originalError:c(e)}}const h=null===(d=e)||void 0===d?void 0:d.stack;return r&&e&&h&&"string"==typeof h&&(u.stack=h),u}}(tf);var rf={};Object.defineProperty(rf,"__esModule",{value:!0}),rf.ethErrors=void 0;const of=Jh,sf=tf,af=nf;function cf(e,t){const[n,r]=df(t);return new of.EthereumRpcError(e,n||sf.getMessageFromCode(e),r)}function lf(e,t){const[n,r]=df(t);return new of.EthereumProviderError(e,n||sf.getMessageFromCode(e),r)}function df(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){const{message:t,data:n}=e;if(t&&"string"!=typeof t)throw new Error("Must specify string message.");return[t||void 0,n]}}return[]}rf.ethErrors={rpc:{parse:e=>cf(af.errorCodes.rpc.parse,e),invalidRequest:e=>cf(af.errorCodes.rpc.invalidRequest,e),invalidParams:e=>cf(af.errorCodes.rpc.invalidParams,e),methodNotFound:e=>cf(af.errorCodes.rpc.methodNotFound,e),internal:e=>cf(af.errorCodes.rpc.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum RPC Server errors must provide single object argument.");const{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw new Error('"code" must be an integer such that: -32099 <= code <= -32005');return cf(t,e)},invalidInput:e=>cf(af.errorCodes.rpc.invalidInput,e),resourceNotFound:e=>cf(af.errorCodes.rpc.resourceNotFound,e),resourceUnavailable:e=>cf(af.errorCodes.rpc.resourceUnavailable,e),transactionRejected:e=>cf(af.errorCodes.rpc.transactionRejected,e),methodNotSupported:e=>cf(af.errorCodes.rpc.methodNotSupported,e),limitExceeded:e=>cf(af.errorCodes.rpc.limitExceeded,e)},provider:{userRejectedRequest:e=>lf(af.errorCodes.provider.userRejectedRequest,e),unauthorized:e=>lf(af.errorCodes.provider.unauthorized,e),unsupportedMethod:e=>lf(af.errorCodes.provider.unsupportedMethod,e),disconnected:e=>lf(af.errorCodes.provider.disconnected,e),chainDisconnected:e=>lf(af.errorCodes.provider.chainDisconnected,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw new Error("Ethereum Provider custom errors must provide single object argument.");const{code:t,message:n,data:r}=e;if(!n||"string"!=typeof n)throw new Error('"message" must be a nonempty string');return new of.EthereumProviderError(t,n,r)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMessageFromCode=e.serializeError=e.EthereumProviderError=e.EthereumRpcError=e.ethErrors=e.errorCodes=void 0;const t=Jh;Object.defineProperty(e,"EthereumRpcError",{enumerable:!0,get:function(){return t.EthereumRpcError}}),Object.defineProperty(e,"EthereumProviderError",{enumerable:!0,get:function(){return t.EthereumProviderError}});const n=tf;Object.defineProperty(e,"serializeError",{enumerable:!0,get:function(){return n.serializeError}}),Object.defineProperty(e,"getMessageFromCode",{enumerable:!0,get:function(){return n.getMessageFromCode}});const r=rf;Object.defineProperty(e,"ethErrors",{enumerable:!0,get:function(){return r.ethErrors}});const i=nf;Object.defineProperty(e,"errorCodes",{enumerable:!0,get:function(){return i.errorCodes}})}(Zh);var uf={exports:{}};uf.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=90)}({17:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=n(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var n=t.match(e);return n&&n.length>0&&n[1]||""},e.getSecondMatch=function(e,t){var n=t.match(e);return n&&n.length>1&&n[2]||""},e.matchAndReturnConst=function(e,t,n){if(e.test(t))return n},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":case"NT 5.1":return"XP";case"NT 5.0":return"2000";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,n,r){void 0===r&&(r=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(n),s=Math.max(i,o),a=0,c=e.map([t,n],(function(t){var n=s-e.getVersionPrecision(t),r=t+new Array(n+1).join(".0");return e.map(r.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(r&&(a=s-Math.min(i,o)),s-=1;s>=a;){if(c[0][s]>c[1][s])return 1;if(c[0][s]===c[1][s]){if(s===a)return 0;s-=1}else if(c[0][s]<c[1][s])return-1}},e.map=function(e,t){var n,r=[];if(Array.prototype.map)return Array.prototype.map.call(e,t);for(n=0;n<e.length;n+=1)r.push(t(e[n]));return r},e.find=function(e,t){var n,r;if(Array.prototype.find)return Array.prototype.find.call(e,t);for(n=0,r=e.length;n<r;n+=1){var i=e[n];if(t(i,n))return i}},e.assign=function(e){for(var t,n,r=e,i=arguments.length,o=new Array(i>1?i-1:0),s=1;s<i;s++)o[s-1]=arguments[s];if(Object.assign)return Object.assign.apply(Object,[e].concat(o));var a=function(){var e=o[t];"object"==typeof e&&null!==e&&Object.keys(e).forEach((function(t){r[t]=e[t]}))};for(t=0,n=o.length;t<n;t+=1)a();return e},e.getBrowserAlias=function(e){return r.BROWSER_ALIASES_MAP[e]},e.getBrowserTypeByAlias=function(e){return r.BROWSER_MAP[e]||""},e}();t.default=i,e.exports=t.default},18:function(e,t,n){t.__esModule=!0,t.ENGINE_MAP=t.OS_MAP=t.PLATFORMS_MAP=t.BROWSER_MAP=t.BROWSER_ALIASES_MAP=void 0,t.BROWSER_ALIASES_MAP={"Amazon Silk":"amazon_silk","Android Browser":"android",Bada:"bada",BlackBerry:"blackberry",Chrome:"chrome",Chromium:"chromium",Electron:"electron",Epiphany:"epiphany",Firefox:"firefox",Focus:"focus",Generic:"generic","Google Search":"google_search",Googlebot:"googlebot","Internet Explorer":"ie","K-Meleon":"k_meleon",Maxthon:"maxthon","Microsoft Edge":"edge","MZ Browser":"mz","NAVER Whale Browser":"naver",Opera:"opera","Opera Coast":"opera_coast",PhantomJS:"phantomjs",Puffin:"puffin",QupZilla:"qupzilla",QQ:"qq",QQLite:"qqlite",Safari:"safari",Sailfish:"sailfish","Samsung Internet for Android":"samsung_internet",SeaMonkey:"seamonkey",Sleipnir:"sleipnir",Swing:"swing",Tizen:"tizen","UC Browser":"uc",Vivaldi:"vivaldi","WebOS Browser":"webos",WeChat:"wechat","Yandex Browser":"yandex",Roku:"roku"},t.BROWSER_MAP={amazon_silk:"Amazon Silk",android:"Android Browser",bada:"Bada",blackberry:"BlackBerry",chrome:"Chrome",chromium:"Chromium",electron:"Electron",epiphany:"Epiphany",firefox:"Firefox",focus:"Focus",generic:"Generic",googlebot:"Googlebot",google_search:"Google Search",ie:"Internet Explorer",k_meleon:"K-Meleon",maxthon:"Maxthon",edge:"Microsoft Edge",mz:"MZ Browser",naver:"NAVER Whale Browser",opera:"Opera",opera_coast:"Opera Coast",phantomjs:"PhantomJS",puffin:"Puffin",qupzilla:"QupZilla",qq:"QQ Browser",qqlite:"QQ Browser Lite",safari:"Safari",sailfish:"Sailfish",samsung_internet:"Samsung Internet for Android",seamonkey:"SeaMonkey",sleipnir:"Sleipnir",swing:"Swing",tizen:"Tizen",uc:"UC Browser",vivaldi:"Vivaldi",webos:"WebOS Browser",wechat:"WeChat",yandex:"Yandex Browser"},t.PLATFORMS_MAP={tablet:"tablet",mobile:"mobile",desktop:"desktop",tv:"tv"},t.OS_MAP={WindowsPhone:"Windows Phone",Windows:"Windows",MacOS:"macOS",iOS:"iOS",Android:"Android",WebOS:"WebOS",BlackBerry:"BlackBerry",Bada:"Bada",Tizen:"Tizen",Linux:"Linux",ChromeOS:"Chrome OS",PlayStation4:"PlayStation 4",Roku:"Roku"},t.ENGINE_MAP={EdgeHTML:"EdgeHTML",Blink:"Blink",Trident:"Trident",Presto:"Presto",Gecko:"Gecko",WebKit:"WebKit"}},90:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(91))&&r.__esModule?r:{default:r},o=n(18);function s(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var a=function(){function e(){}var t,n;return e.getParser=function(e,t){if(void 0===t&&(t=!1),"string"!=typeof e)throw new Error("UserAgent should be a string");return new i.default(e,t)},e.parse=function(e){return new i.default(e).getResult()},t=e,n=[{key:"BROWSER_MAP",get:function(){return o.BROWSER_MAP}},{key:"ENGINE_MAP",get:function(){return o.ENGINE_MAP}},{key:"OS_MAP",get:function(){return o.OS_MAP}},{key:"PLATFORMS_MAP",get:function(){return o.PLATFORMS_MAP}}],null&&s(t.prototype,null),n&&s(t,n),e}();t.default=a,e.exports=t.default},91:function(e,t,n){t.__esModule=!0,t.default=void 0;var r=c(n(92)),i=c(n(93)),o=c(n(94)),s=c(n(95)),a=c(n(17));function c(e){return e&&e.__esModule?e:{default:e}}var l=function(){function e(e,t){if(void 0===t&&(t=!1),null==e||""===e)throw new Error("UserAgent parameter can't be empty");this._ua=e,this.parsedResult={},!0!==t&&this.parse()}var t=e.prototype;return t.getUA=function(){return this._ua},t.test=function(e){return e.test(this._ua)},t.parseBrowser=function(){var e=this;this.parsedResult.browser={};var t=a.default.find(r.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.browser=t.describe(this.getUA())),this.parsedResult.browser},t.getBrowser=function(){return this.parsedResult.browser?this.parsedResult.browser:this.parseBrowser()},t.getBrowserName=function(e){return e?String(this.getBrowser().name).toLowerCase()||"":this.getBrowser().name||""},t.getBrowserVersion=function(){return this.getBrowser().version},t.getOS=function(){return this.parsedResult.os?this.parsedResult.os:this.parseOS()},t.parseOS=function(){var e=this;this.parsedResult.os={};var t=a.default.find(i.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.os=t.describe(this.getUA())),this.parsedResult.os},t.getOSName=function(e){var t=this.getOS().name;return e?String(t).toLowerCase()||"":t||""},t.getOSVersion=function(){return this.getOS().version},t.getPlatform=function(){return this.parsedResult.platform?this.parsedResult.platform:this.parsePlatform()},t.getPlatformType=function(e){void 0===e&&(e=!1);var t=this.getPlatform().type;return e?String(t).toLowerCase()||"":t||""},t.parsePlatform=function(){var e=this;this.parsedResult.platform={};var t=a.default.find(o.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.platform=t.describe(this.getUA())),this.parsedResult.platform},t.getEngine=function(){return this.parsedResult.engine?this.parsedResult.engine:this.parseEngine()},t.getEngineName=function(e){return e?String(this.getEngine().name).toLowerCase()||"":this.getEngine().name||""},t.parseEngine=function(){var e=this;this.parsedResult.engine={};var t=a.default.find(s.default,(function(t){if("function"==typeof t.test)return t.test(e);if(t.test instanceof Array)return t.test.some((function(t){return e.test(t)}));throw new Error("Browser's test function is not valid")}));return t&&(this.parsedResult.engine=t.describe(this.getUA())),this.parsedResult.engine},t.parse=function(){return this.parseBrowser(),this.parseOS(),this.parsePlatform(),this.parseEngine(),this},t.getResult=function(){return a.default.assign({},this.parsedResult)},t.satisfies=function(e){var t=this,n={},r=0,i={},o=0;if(Object.keys(e).forEach((function(t){var s=e[t];"string"==typeof s?(i[t]=s,o+=1):"object"==typeof s&&(n[t]=s,r+=1)})),r>0){var s=Object.keys(n),c=a.default.find(s,(function(e){return t.isOS(e)}));if(c){var l=this.satisfies(n[c]);if(void 0!==l)return l}var d=a.default.find(s,(function(e){return t.isPlatform(e)}));if(d){var u=this.satisfies(n[d]);if(void 0!==u)return u}}if(o>0){var h=Object.keys(i),f=a.default.find(h,(function(e){return t.isBrowser(e,!0)}));if(void 0!==f)return this.compareVersion(i[f])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var n=this.getBrowserName().toLowerCase(),r=e.toLowerCase(),i=a.default.getBrowserTypeByAlias(r);return t&&i&&(r=i.toLowerCase()),r===n},t.compareVersion=function(e){var t=[0],n=e,r=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(n=e.substr(1),"="===e[1]?(r=!0,n=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?n=e.substr(1):"~"===e[0]&&(r=!0,n=e.substr(1)),t.indexOf(a.default.compareVersions(i,n,r))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=l,e.exports=t.default},92:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=/version\/(\d+(\.?_?\d+)+)/i,s=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},n=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},n=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},n=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},n=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},n=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},n=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},n=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},n=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},n=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},n=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},n=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},n=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},n=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},n=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return n&&(t.version=n),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},n=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},n=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},n=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},n=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},n=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},n=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},n=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},n=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},n=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},n=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},n=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},n=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},n=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t={name:"Android Browser"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},n=i.default.getFirstMatch(o,e);return n&&(t.version=n),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=s,e.exports=t.default},93:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),n=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:n}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},n=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return n&&(t.version=n),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),n=i.default.getMacOSVersionName(t),r={name:o.OS_MAP.MacOS,version:t};return n&&(r.versionName=n),r}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),n=e.test(/android/i);return t&&n},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),n=i.default.getAndroidVersionName(t),r={name:o.OS_MAP.Android,version:t};return n&&(r.versionName=n),r}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),n={name:o.OS_MAP.WebOS};return t&&t.length&&(n.version=t),n}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=s,e.exports=t.default},94:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",n={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(n.model=t),n}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),n=e.test(/like (ipod|iphone)/i);return t&&!n},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=s,e.exports=t.default},95:function(e,t,n){t.__esModule=!0,t.default=void 0;var r,i=(r=n(17))&&r.__esModule?r:{default:r},o=n(18),s=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},n=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},n=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:function(e){var t=e.test(/gecko/i),n=e.test(/like gecko/i);return t&&!n},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},n=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},n=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return n&&(t.version=n),t}}];t.default=s,e.exports=t.default}});var hf=Ut(uf.exports);const ff={Initialized:"initialized",DisplayURI:"display_uri",ProviderUpdate:"provider_update",ConnectWithResponse:"connectWithResponse",ConnectionStatus:"connection_status",ServiceStatus:"service_status"};class pf{constructor({shouldSetOnWindow:e,connectionStream:t,shouldSendMetadata:n=!1,shouldShimWeb3:r,sdkInstance:i}){const o=new yf({connectionStream:t,shouldSendMetadata:n,shouldSetOnWindow:e,shouldShimWeb3:r,autoRequestAccounts:!1}),s=new Proxy(o,{deleteProperty:()=>!0});if(this.provider=s,this.sdkInstance=i,e&&"undefined"!=typeof window)try{a=o,window.ethereum=a,window.dispatchEvent(new Event("ethereum#initialized"))}catch(e){Yh("[Ethereum] Unable to set global provider - window.ethereum may be read-only",e)}var a;if(r&&"undefined"!=typeof window)try{!function(e,t=console){let n=!1,r=!1;if(!window.web3){const i="__isMetaMaskShim__";let o={currentProvider:e};Object.defineProperty(o,i,{value:!0,enumerable:!0,configurable:!1,writable:!1}),o=new Proxy(o,{get:(o,s,...a)=>("currentProvider"!==s||n?"currentProvider"===s||s===i||r||(r=!0,t.error("MetaMask no longer injects web3. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),e.request({method:"metamask_logWeb3ShimUsage"}).catch((e=>{t.debug("MetaMask: Failed to log web3 shim usage.",e)}))):(n=!0,t.warn("You are accessing the MetaMask window.web3.currentProvider shim. This property is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3")),Reflect.get(o,s,...a)),set:(...e)=>(t.warn("You are accessing the MetaMask window.web3 shim. This object is deprecated; use window.ethereum instead. For details, see: https://docs.metamask.io/guide/provider-migration.html#replacing-window-web3"),Reflect.set(...e))}),Object.defineProperty(window,"web3",{value:o,enumerable:!1,configurable:!0,writable:!0})}}(this.provider)}catch(e){Yh("[Ethereum] Unable to shim web3 - window.web3 may be read-only",e)}this.provider.on("display_uri",(e=>{this.sdkInstance.emit(ff.DisplayURI,e)})),this.provider.on("_initialized",(()=>{const e={chainId:this.provider.getChainId(),isConnected:this.provider.isConnected(),isMetaMask:this.provider.isMetaMask,selectedAddress:this.provider.getSelectedAddress(),networkVersion:this.provider.getNetworkVersion()};this.sdkInstance.emit(ff.Initialized,e),Yh("[Ethereum: constructor()] provider initialized",e)}))}static init(e){var t;return Yh("[Ethereum: init()] Initializing Ethereum service"),this.instance=new pf(e),null===(t=this.instance)||void 0===t?void 0:t.provider}static destroy(){}static getInstance(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance}static getProvider(){var e;if(!(null===(e=this.instance)||void 0===e?void 0:e.provider))throw new Error("Ethereum instance not intiialized - call Ethereum.factory first.");return this.instance.provider}}class gf{constructor({useDeepLink:e,preferredOpenLink:t,debug:n=!1}){this.state={platformType:void 0,useDeeplink:!1,preferredOpenLink:void 0,debug:!1},this.state.platformType=this.getPlatformType(),this.state.useDeeplink=e,this.state.preferredOpenLink=t,this.state.debug=n}openDeeplink(e,t,n){return function(e,t,n,r){const{state:i}=e;Yh(`[PlatfformManager: openDeeplink()] universalLink --\x3e ${t}`),Yh(`[PlatfformManager: openDeeplink()] deepLink --\x3e ${n}`);try{if(i.preferredOpenLink)return void i.preferredOpenLink(i.useDeeplink?n:t,r);if(Yh(`[PlatfformManager: openDeeplink()] open link now useDeepLink=${i.useDeeplink} link=${i.useDeeplink?n:t}`),i.useDeeplink)"undefined"!=typeof window&&(window.location.href=n);else if("undefined"!=typeof document){const e=document.createElement("a");e.href=t,e.target="_self",e.rel="noreferrer noopener",e.click()}}catch(e){console.log("[PlatfformManager: openDeeplink()] can't open link",e)}}(this,e,t,n)}isReactNative(){var e;return this.isNotBrowser()&&"undefined"!=typeof window&&(null===window||void 0===window?void 0:window.navigator)&&"ReactNative"===(null===(e=window.navigator)||void 0===e?void 0:e.product)}isMetaMaskInstalled(){return function(){const e=pf.getProvider()||(null===window||void 0===window?void 0:window.ethereum);return Yh(`[PlatfformManager: isMetaMaskInstalled()] isMetaMask=${null==e?void 0:e.isMetaMask} isConnected=${null==e?void 0:e.isConnected()}`),(null==e?void 0:e.isMetaMask)&&(null==e?void 0:e.isConnected())}()}isDesktopWeb(){return this.isBrowser()&&!this.isMobileWeb()}isMobile(){var e,t;const n=hf.parse(window.navigator.userAgent);return"mobile"===(null===(e=null==n?void 0:n.platform)||void 0===e?void 0:e.type)||"tablet"===(null===(t=null==n?void 0:n.platform)||void 0===t?void 0:t.type)}isSecure(){return this.isReactNative()||this.isMobileWeb()}isMetaMaskMobileWebView(){return"undefined"!=typeof window&&Boolean(window.ReactNativeWebView)&&Boolean(navigator.userAgent.endsWith("MetaMaskMobile"))}isMobileWeb(){return this.state.platformType===ga.MobileWeb}static isNotBrowser(){var e;return"undefined"==typeof window||!(null===window||void 0===window?void 0:window.navigator)||void 0!==je&&"ReactNative"===(null===(e=null==je?void 0:je.navigator)||void 0===e?void 0:e.product)||"ReactNative"===(null===navigator||void 0===navigator?void 0:navigator.product)}isNotBrowser(){return gf.isNotBrowser()}static isBrowser(){return!this.isNotBrowser()}isBrowser(){return gf.isBrowser()}isNodeJS(){return this.isNotBrowser()&&!this.isReactNative()}isUseDeepLink(){return this.state.useDeeplink}getPlatformType(){return function(e){const{state:t}=e;return t.platformType?t.platformType:e.isReactNative()?ga.ReactNative:e.isNotBrowser()?ga.NonBrowser:e.isMetaMaskMobileWebView()?ga.MetaMaskMobileWebview:e.isMobile()?ga.MobileWeb:ga.DesktopWeb}(this)}}const mf=e=>$e(void 0,void 0,void 0,(function*(){if(gf.isBrowser()){const{StorageManagerWeb:t}=yield Promise.resolve().then((function(){return mp}));return new t(e)}const t={persistChannelConfig:()=>$e(void 0,void 0,void 0,(function*(){})),getPersistedChannelConfig:()=>$e(void 0,void 0,void 0,(function*(){})),persistAccounts:()=>$e(void 0,void 0,void 0,(function*(){})),getCachedAccounts:()=>$e(void 0,void 0,void 0,(function*(){return[]})),persistChainId:()=>$e(void 0,void 0,void 0,(function*(){})),getCachedChainId:()=>$e(void 0,void 0,void 0,(function*(){})),terminate:()=>$e(void 0,void 0,void 0,(function*(){}))};return Promise.resolve(t)}));class yf extends Gh{constructor({connectionStream:e,shouldSendMetadata:t,autoRequestAccounts:n=!1}){super(e,{logger:console,maxEventListeners:100,shouldSendMetadata:t}),this.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:"",networkVersion:""},Yh(`[SDKProvider: constructor()] autoRequestAccounts=${n}`),this.state.autoRequestAccounts=n}forceInitializeState(){return $e(this,void 0,void 0,(function*(){return Yh(`[SDKProvider: forceInitializeState()] autoRequestAccounts=${this.state.autoRequestAccounts}`),this._initializeStateAsync()}))}_setConnected(){Yh("[SDKProvider: _setConnected()] Setting connected state"),this._state.isConnected=!0}getState(){return this._state}getSDKProviderState(){return this.state}getSelectedAddress(){var e;const{accounts:t}=this._state;return t&&0!==t.length?(null===(e=t[0])||void 0===e?void 0:e.toLowerCase())||"":(Yh("[SDKProvider: getSelectedAddress] No accounts found"),null)}getChainId(){return this.state.chainId}getNetworkVersion(){return this.state.networkVersion}setSDKProviderState(e){this.state=Object.assign(Object.assign({},this.state),e)}handleAccountsChanged(e,t){return this._handleAccountsChanged(e,t)}handleDisconnect({terminate:e=!1}){!function({terminate:e=!1,instance:t}){const{state:n}=t;Yh(`[SDKProvider: handleDisconnect()] cleaning up provider state terminate=${e}`,t),e&&(t._state.accounts=null,t._state.isUnlocked=!1,t._state.isPermanentlyDisconnected=!0,t._state.initialized=!1),t._handleAccountsChanged([]),t._state.isConnected=!1,t.emit("disconnect",Zh.ethErrors.provider.disconnected()),n.providerStateRequested=!1}({terminate:e,instance:this})}_initializeStateAsync(){return $e(this,void 0,void 0,(function*(){return function(e){var t,n;return $e(this,void 0,void 0,(function*(){void 0===e.state&&(e.state={accounts:null,autoRequestAccounts:!1,providerStateRequested:!1,chainId:""});const{state:r}=e;let i;if(r.providerStateRequested)Yh("[SDKProvider: initializeStateAsync()] initialization already in progress");else{let o;r.providerStateRequested=!0;let s=null,a=!1,c=!1;const l=yield mf({enabled:!0});if(l){const e=yield l.getPersistedChannelConfig({});a=null!==(t=null==e?void 0:e.relayPersistence)&&void 0!==t&&t,o=yield l.getCachedChainId();const n=yield l.getCachedAccounts();n.length>0&&(s=n[0])}if(Yh(`[SDKProvider: initializeStateAsync()] relayPersistence=${a}`,{relayPersistence:a,cachedChainId:o,cachedSelectedAddress:s}),a)if(o&&s)i={accounts:[s],chainId:o,isUnlocked:!1},c=!0;else try{i=yield e.request({method:"metamask_getProviderState"})}catch(t){return e._log.error("MetaMask: Failed to get initial state. Please report this bug.",t),void(r.providerStateRequested=!1)}if(0===(null===(n=null==i?void 0:i.accounts)||void 0===n?void 0:n.length))if(e.getSelectedAddress())i.accounts=[e.getSelectedAddress()];else{Yh("[SDKProvider: initializeStateAsync()] Fetch accounts remotely.");const t=yield e.request({method:"eth_requestAccounts",params:[]});i.accounts=t}e._initializeState(i),r.providerStateRequested=!1,c&&(e._state.isConnected=!0,e.emit("connect",{chainId:null==i?void 0:i.chainId}))}}))}(this)}))}_initializeState(e){return Yh("[SDKProvider: _initializeState()]",e),function(e,t,n){return Yh("[SDKProvider: initializeState()] set state._initialized to false"),e._state.initialized=!1,t(n)}(this,super._initializeState.bind(this),e)}_handleChainChanged({chainId:e,networkVersion:t}={}){this.state.chainId=e,this.state.networkVersion=t,function({instance:e,chainId:t,networkVersion:n,superHandleChainChanged:r}){Yh(`[SDKProvider: handleChainChanged()] chainId=${t} networkVersion=${n}`);let i=n;n||(Yh("[SDKProvider: handleChainChanged()] forced network version to prevent provider error"),i="1"),e._state.isConnected=!0,e.emit("connect",{chainId:t}),r({chainId:t,networkVersion:i})}({instance:this,chainId:e,networkVersion:t,superHandleChainChanged:super._handleChainChanged.bind(this)})}}var vf,bf={name:"@metamask/sdk",version:"0.32.0",description:"",homepage:"https://github.com/MetaMask/metamask-sdk#readme",bugs:{url:"https://github.com/MetaMask/metamask-sdk/issues"},repository:{type:"git",url:"https://github.com/MetaMask/metamask-sdk",directory:"packages/sdk"},main:"dist/node/cjs/metamask-sdk.js",module:"dist/browser/es/metamask-sdk.js",browser:"dist/browser/es/metamask-sdk.js",unpkg:"dist/browser/umd/metamask-sdk.js","react-native":"dist/react-native/es/metamask-sdk.js",types:"dist/types/src/index.d.ts",sideEffects:!1,files:["/dist"],scripts:{"build:types":"tsc --project tsconfig.build.json --emitDeclarationOnly --outDir dist/types",build:"yarn build:types && rollup -c --bundleConfigAsCjs","build:clean":"yarn clean && yarn build","build:post-tsc":"echo 'N/A'","build:pre-tsc":"echo 'N/A'",typecheck:"tsc --noEmit",clean:"rimraf ./dist",size:"node bundle-size && size-limit",lint:"yarn lint:eslint && yarn lint:misc --check","lint:changelog":"../../scripts/validate-changelog.sh @metamask/sdk","lint:eslint":"eslint . --cache --ext js,ts","lint:fix":"yarn lint:eslint --fix && yarn lint:misc --write","lint:misc":"prettier '**/*.json' '**/*.md' '!CHANGELOG.md' --ignore-path ../../.gitignore",prepack:"../../scripts/prepack.sh","publish:preview":"yarn npm publish --tag preview",reset:"yarn clean && rimraf ./node_modules/",test:'jest --testPathIgnorePatterns "/e2e/"',"test:coverage":'jest --coverage --testPathIgnorePatterns "/e2e/"',"test:e2e":'jest --testPathPattern "/e2e/"',"test:ci":'jest --coverage --passWithNoTests --setupFilesAfterEnv ./jest-preload.js --testPathIgnorePatterns "/e2e/"',"test:dev":'jest -c ./jest.config.ts --detectOpenHandles --testPathIgnorePatterns "/e2e/"',watch:"rollup -c -w",dev:'concurrently "tsc --watch" "rollup -c -w --bundleConfigAsCjs"',"build:dev":"yarn build:types && NODE_ENV=dev rollup -c --bundleConfigAsCjs"},dependencies:{"@babel/runtime":"^7.26.0","@metamask/onboarding":"^1.0.1","@metamask/providers":"16.1.0","@metamask/sdk-communication-layer":"workspace:*","@metamask/sdk-install-modal-web":"workspace:*","@paulmillr/qr":"^0.2.1",bowser:"^2.9.0","cross-fetch":"^4.0.0",debug:"^4.3.4",eciesjs:"^0.4.11","eth-rpc-errors":"^4.0.3",eventemitter2:"^6.4.9","obj-multiplex":"^1.0.0",pump:"^3.0.0","readable-stream":"^3.6.2","socket.io-client":"^4.5.1",tslib:"^2.6.0",util:"^0.12.4",uuid:"^8.3.2"},devDependencies:{"@jest/globals":"^29.3.1","@lavamoat/allow-scripts":"^2.3.1","@metamask/auto-changelog":"3.1.0","@metamask/eslint-config":"^6.0.0","@metamask/eslint-config-nodejs":"^6.0.0","@metamask/eslint-config-typescript":"^6.0.0","@react-native-async-storage/async-storage":"^1.19.6","@rollup/plugin-alias":"^5.1.1","@rollup/plugin-commonjs":"^25.0.7","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-replace":"^6.0.1","@rollup/plugin-terser":"^0.4.1","@size-limit/preset-big-lib":"^11.0.2","@types/dom-screen-wake-lock":"^1.0.2","@types/node":"^20.1.3","@types/pump":"^1.1.1","@types/qrcode-terminal":"^0.12.0","@types/uuid":"^10.0.0","@typescript-eslint/eslint-plugin":"^4.26.0","@typescript-eslint/parser":"^4.26.0","browserify-zlib":"^0.2.0",buffer:"^6.0.3",concurrently:"^9.1.2","crypto-browserify":"^3.12.0",eslint:"^7.30.0","eslint-config-prettier":"^8.3.0","eslint-plugin-import":"^2.23.4","eslint-plugin-jest":"^24.4.0","eslint-plugin-jsdoc":"^36.1.0","eslint-plugin-node":"^11.1.0","eslint-plugin-prettier":"^3.4.0","https-browserify":"^1.0.0",jest:"^29.3.1","jest-environment-jsdom":"^29.3.1",prettier:"^2.3.0",process:"^0.11.10",rimraf:"^4.4.0",rollup:"^4.26.0","rollup-plugin-analyzer":"^4.0.0","rollup-plugin-jscc":"^2.0.0","rollup-plugin-natives":"^0.7.5","rollup-plugin-node-builtins":"^2.1.2","rollup-plugin-polyfill-node":"^0.13.0","rollup-plugin-sizes":"^1.0.6","rollup-plugin-typescript2":"^0.31.2","rollup-plugin-visualizer":"^5.12.0","size-limit":"^11.0.2","stream-browserify":"^3.0.0","stream-http":"^3.2.0","ts-jest":"^29.0.3","ts-node":"^10.9.1",typescript:"^4.3.2",url:"^0.11.0",webpack:"^5.0.0"},publishConfig:{access:"public",registry:"https://registry.npmjs.org/"},lavamoat:{allowScripts:{"eciesjs>secp256k1":!1,"socket.io-client>engine.io-client>ws>bufferutil":!1,"socket.io-client>engine.io-client>ws>utf-8-validate":!1,"@metamask/sdk-communication-layer>bufferutil":!1,"@metamask/sdk-communication-layer>eciesjs>secp256k1":!1,"@metamask/sdk-communication-layer>utf-8-validate":!1}}};!function(e){e.INPAGE="metamask-inpage",e.CONTENT_SCRIPT="metamask-contentscript",e.PROVIDER="metamask-provider"}(vf||(vf={}));const wf="direct",Ef="https://metamask.app.link/connect",Cf="metamask://connect",_f={NAME:"MetaMask",RDNS:["io.metamask","io.metamask.flask"]},Sf=/(?:^[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}$)|(?:^0{8}-0{4}-0{4}-0{4}-0{12}$)/u,kf={METAMASK_GETPROVIDERSTATE:"metamask_getProviderState",METAMASK_CONNECTSIGN:"metamask_connectSign",METAMASK_CONNECTWITH:"metamask_connectWith",METAMASK_OPEN:"metamask_open",METAMASK_BATCH:"metamask_batch",PERSONAL_SIGN:"personal_sign",WALLET_REQUESTPERMISSIONS:"wallet_requestPermissions",WALLET_REVOKEPERMISSIONS:"wallet_revokePermissions",WALLET_GETPERMISSIONS:"wallet_getPermissions",WALLET_WATCHASSET:"wallet_watchAsset",WALLET_ADDETHEREUMCHAIN:"wallet_addEthereumChain",WALLET_SWITCHETHETHEREUMCHAIN:"wallet_switchEthereumChain",ETH_REQUESTACCOUNTS:"eth_requestAccounts",ETH_ACCOUNTS:"eth_accounts",ETH_CHAINID:"eth_chainId",ETH_SENDTRANSACTION:"eth_sendTransaction",ETH_SIGNTYPEDDATA:"eth_signTypedData",ETH_SIGNTYPEDDATA_V3:"eth_signTypedData_v3",ETH_SIGNTYPEDDATA_V4:"eth_signTypedData_v4",ETH_SIGNTRANSACTION:"eth_signTransaction",ETH_SIGN:"eth_sign",PERSONAL_EC_RECOVER:"personal_ecRecover"},xf={[kf.ETH_REQUESTACCOUNTS]:!0,[kf.ETH_SENDTRANSACTION]:!0,[kf.ETH_SIGNTRANSACTION]:!0,[kf.ETH_SIGN]:!0,[kf.PERSONAL_SIGN]:!0,[kf.ETH_ACCOUNTS]:!1,[kf.ETH_CHAINID]:!1,[kf.PERSONAL_SIGN]:!0,[kf.ETH_SIGNTYPEDDATA]:!0,[kf.ETH_SIGNTYPEDDATA_V3]:!0,[kf.ETH_SIGNTYPEDDATA_V4]:!0,[kf.WALLET_REQUESTPERMISSIONS]:!0,[kf.WALLET_GETPERMISSIONS]:!0,[kf.WALLET_WATCHASSET]:!0,[kf.WALLET_ADDETHEREUMCHAIN]:!0,[kf.WALLET_SWITCHETHETHEREUMCHAIN]:!0,[kf.METAMASK_CONNECTSIGN]:!0,[kf.METAMASK_CONNECTWITH]:!0,[kf.PERSONAL_EC_RECOVER]:!0,[kf.METAMASK_BATCH]:!0,[kf.METAMASK_OPEN]:!0},Af=Object.keys(xf).map((e=>e.toLowerCase())),Mf=["eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sign"].map((e=>e.toLowerCase())),Lf=".sdk-comm",Tf="providerType",Of=".MMSDK_cached_address",Rf=".MMSDK_cached_chainId",Pf="chainChanged",If="accountsChanged",Nf="disconnect",Bf="connect",Df="connected";var $f;!function(e){e.TERMINATE="terminate",e.EXTENSION="extension",e.INITIALIZED="initialized"}($f||($f={}));const jf="undefined"!=typeof window&&window.localStorage;function Kf(e){var t,n;return $e(this,void 0,void 0,(function*(){Yh("[MetaMaskSDK: connectWithExtensionProvider()] ",e),e.sdkProvider=e.activeProvider,e.activeProvider=window.extension,window.ethereum=window.extension;try{const e=yield null===(t=window.extension)||void 0===t?void 0:t.request({method:"eth_requestAccounts"});Yh(`[MetaMaskSDK: connectWithExtensionProvider()] accounts=${e}`)}catch(e){return void console.warn("[MetaMaskSDK: connectWithExtensionProvider()] can't request accounts error",e)}localStorage.setItem(Tf,"extension"),e.extensionActive=!0,e.emit(ff.ProviderUpdate,$f.EXTENSION),e.options.enableAnalytics&&(null===(n=e.analytics)||void 0===n||n.send({event:ea.SDK_USE_EXTENSION}))}))}function Uf(e){let t;if(void 0!==et)t=et.from(e,"utf8").toString("base64");else if("function"==typeof btoa)t=btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/gu,((e,t)=>String.fromCharCode(parseInt(t,16)))));else{if("object"!=typeof je||!("Buffer"in je))throw new Error("Unable to base64 encode: No available method.");t=je.Buffer.from(e,"utf8").toString("base64")}return t}class Ff extends Ah.Duplex{constructor({name:e,remote:t,deeplinkProtocol:n,platformManager:r}){super({objectMode:!0}),this.state={_name:null,remote:null,deeplinkProtocol:!1,platformManager:null},this.state._name=e,this.state.remote=t,this.state.deeplinkProtocol=n,this.state.platformManager=r,this._onMessage=this._onMessage.bind(this),this.state.remote.on(Zs.MESSAGE,this._onMessage)}_write(e,t,n){return $e(this,void 0,void 0,(function*(){return function(e,t,n,r){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C,_;return $e(this,void 0,void 0,(function*(){const n=null===(i=e.state.remote)||void 0===i?void 0:i.isReady(),S=null===(o=e.state.remote)||void 0===o?void 0:o.isConnected(),k=null===(s=e.state.remote)||void 0===s?void 0:s.isPaused(),x=pf.getProvider(),A=null===(a=e.state.remote)||void 0===a?void 0:a.getChannelId(),M=null===(c=e.state.remote)||void 0===c?void 0:c.isAuthorized(),{deeplinkProtocol:L}=e.state,{method:T,data:O,triggeredInstaller:R}=(e=>{var t,n,r,i;let o;et.isBuffer(e)?(o=e.toJSON(),o._isBuffer=!0):o=e;const s=null===(t=null==o?void 0:o.data)||void 0===t?void 0:t.method;let a=!1;return"object"==typeof(null===(n=null==o?void 0:o.data)||void 0===n?void 0:n.params)&&!0===(null===(i=null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.params)||void 0===i?void 0:i.__triggeredInstaller)&&(a=!0,o.data.params=o.data.params.wrappedParams),{method:s,data:o,triggeredInstaller:a}})(t);if(Yh(`[RCPMS: write()] method='${T}' isRemoteReady=${n} channelId=${A} isSocketConnected=${S} isRemotePaused=${k} providerConnected=${x.isConnected()}`,t),!A)return T!==kf.METAMASK_GETPROVIDERSTATE&&Yh(`[RCPMS: write()] ${T} --\x3e channelId is undefined`),r(new Error("disconnected"));Yh(`[RCPMS: write()] remote.isPaused()=${null===(l=e.state.remote)||void 0===l?void 0:l.isPaused()} authorized=${M} ready=${n} socketConnected=${S}`,t);const P=null===(d=e.state.platformManager)||void 0===d?void 0:d.isSecure(),I=null!==(h=null===(u=e.state.platformManager)||void 0===u?void 0:u.isMobileWeb())&&void 0!==h&&h,N=null!==(p=null===(f=e.state.remote)||void 0===f?void 0:f.hasDeeplinkProtocol())&&void 0!==p&&p&&I&&M;try{if(!R){const t=JSON.stringify(null==O?void 0:O.data);if(t.length>1e6)return r(new Error(`Message size ${t.length} exceeds maximum allowed size of 1000000 bytes`));null===(g=e.state.remote)||void 0===g||g.sendMessage(null==O?void 0:O.data).then((()=>{Yh(`[RCPMS: _write()] ${T} sent successfully`)})).catch((e=>{Yh("[RCPMS: _write()] error sending message",e)}))}if(!P)return Yh(`[RCPMS: _write()] unsecure platform for method ${T} -- return callback`),r();if(R)return Yh("[RCPMS: _write()] prevent deeplink -- installation completed separately."),r();const t=null!==(v=null===(y=null===(m=e.state.remote)||void 0===m?void 0:m.getKeyInfo())||void 0===y?void 0:y.ecies.public)&&void 0!==v?v:"";let n=encodeURI(`channelId=${A}&pubkey=${t}&comm=socket&t=d&v=2`);if(N){const t=JSON.stringify(null==O?void 0:O.data),i=null===(b=e.state.remote)||void 0===b?void 0:b.encrypt(t);if(!i)return Yh("[RCPMS: _write()] error encrypting message"),r(new Error("RemoteCommunicationPostMessageStream - disconnected"));n+=`&scheme=${L}&rpc=${Uf(i)}`}if(!(null===(w=e.state.platformManager)||void 0===w?void 0:w.isMetaMaskInstalled()))return Yh("[RCPMS: _write()] prevent deeplink until installation is completed."),r();xf[T]?(Yh(`[RCPMS: _write()] redirect link for '${T}' socketConnected=${S} connect?${n}`),null===(E=e.state.platformManager)||void 0===E||E.openDeeplink(`${Ef}?${n}`,`${Cf}?${n}`,"_self")):(null===(C=e.state.remote)||void 0===C?void 0:C.isPaused())?(Yh(`[RCPMS: _write()] MM is PAUSED! deeplink with connect! targetMethod=${T}`),null===(_=e.state.platformManager)||void 0===_||_.openDeeplink(`${Ef}?redirect=true&${n}`,`${Cf}?redirect=true&${n}`,"_self")):Yh(`[RCPMS: _write()] method ${T} doesn't need redirect.`)}catch(e){return Yh("[RCPMS: _write()] error sending message",e),r(new Error("RemoteCommunicationPostMessageStream - disconnected"))}return r()}))}(this,e,0,n)}))}_read(){}_onMessage(e){return function(e,t){try{if(Yh("[RCPMS: onMessage()] message",t),!t||"object"!=typeof t)return;if("object"!=typeof(null==t?void 0:t.data))return;if(!(null==t?void 0:t.name))return void Yh("[RCPMS: onMessage()] ignore message without name",t);if((null==t?void 0:t.name)!==vf.PROVIDER)return void Yh(`[RCPMS: onMessage()] ignore message with wrong name message=${t}`);if(et.isBuffer(t)){const n=et.from(t);e.push(n)}else e.push(t)}catch(e){Yh(`[RCPMS: onMessage()] ignore message error err=${e}`)}}(this,e)}start(){}}let Hf=1;const zf=e=>new Promise((t=>{setTimeout((()=>{t(!0)}),e)})),qf=({checkInstallationOnAllCalls:e=!1,communicationLayerPreference:t,injectProvider:n,shouldShimWeb3:r,platformManager:i,installer:o,sdk:s,remoteConnection:a,debug:l})=>$e(void 0,void 0,void 0,(function*(){var d,u;const h=(({name:e,remoteConnection:t})=>{if(!t||!(null==t?void 0:t.getConnector()))throw new Error("Missing remote connection parameter");return new Ff({name:e,remote:null==t?void 0:t.getConnector(),deeplinkProtocol:null==t?void 0:t.state.deeplinkProtocol,platformManager:null==t?void 0:t.getPlatformManager()})})({name:vf.INPAGE,target:vf.CONTENT_SCRIPT,platformManager:i,communicationLayerPreference:t,remoteConnection:a}),f=i.getPlatformType(),p=s.options.dappMetadata,g=`Sdk/Javascript SdkVersion/${bf.version} Platform/${f} dApp/${null!==(d=p.url)&&void 0!==d?d:p.name} dAppTitle/${p.name}`;let m=null,y=null;const v=null===(u=s.options.storage)||void 0===u?void 0:u.storageManager;if(v){try{const e=yield v.getCachedAccounts();e.length>0&&(m=e[0])}catch(e){console.error(`[initializeMobileProvider] failed to get cached addresses: ${e}`)}try{const e=yield v.getCachedChainId();e&&(y=e)}catch(e){console.error(`[initializeMobileProvider] failed to parse cached chainId: ${e}`)}}Yh(`[initializeMobileProvider] cachedAccountAddress: ${m}, cachedChainId: ${y}`);const b=!(!n||f===ga.NonBrowser||f===ga.ReactNative),w=pf.init({shouldSetOnWindow:b,connectionStream:h,shouldShimWeb3:r,sdkInstance:s});let E=!1;const C=e=>{E=e},_=()=>E,S=(t,n,r,l)=>$e(void 0,void 0,void 0,(function*(){var d,u,h,f,p,b,w,S,k;const x=pf.getProvider();if(E){x.emit("display_uri",(null==a?void 0:a.state.qrcodeLink)||""),null==a||a.showActiveModal();let e=_();for(;e;){const t=_(),n=null==a?void 0:a.isAuthorized();e=t&&!n,Yh(`[initializeMobileProvider: sendRequest()] waiting for initialization to complete - initializing: ${t} authorized: ${n}`),yield zf(1e3)}return Yh("[initializeMobileProvider: sendRequest()] initial method completed -- prevent installation and call provider"),r(...n)}const A=i.isMetaMaskInstalled(),M=null==a?void 0:a.isConnected();let L=null,T=null,O=null;if(L=null!==(d=x.getSelectedAddress())&&void 0!==d?d:m,O=x.getChainId()||y,L&&v&&L!==m&&v.persistAccounts([L]).catch((e=>{console.error(`[initializeMobileProvider] failed to persist account: ${e}`)})),O&&(y=O,v&&v.persistChainId(O).catch((e=>{console.error(`[initializeMobileProvider] failed to persist chainId: ${e}`)}))),Yh("[initializeMobileProvider: sendRequest()]",{selectedAddress:L,chainId:O}),l&&Yh(`[initializeMobileProvider: sendRequest()] method=${t} ongoing=${E} selectedAddress=${L} isInstalled=${A} checkInstallationOnAllCalls=${e} socketConnected=${M}`),L&&t.toLowerCase()===kf.ETH_ACCOUNTS.toLowerCase())return[L];if(O&&t.toLowerCase()===kf.ETH_CHAINID.toLowerCase())return O;const R=[kf.ETH_REQUESTACCOUNTS,kf.WALLET_REQUESTPERMISSIONS,kf.METAMASK_CONNECTSIGN,kf.METAMASK_CONNECTWITH],P=!xf[t],I=null===(u=s.options.readonlyRPCMap)||void 0===u?void 0:u[O];if(I&&P)try{const e=null===(h=null==n?void 0:n[0])||void 0===h?void 0:h.params,r=yield(({rpcEndpoint:e,method:t,sdkInfo:n,params:r})=>$e(void 0,void 0,void 0,(function*(){const i=JSON.stringify({jsonrpc:"2.0",method:t,params:r,id:(Hf+=1,Hf)}),o={Accept:"application/json","Content-Type":"application/json"};let s;e.includes("infura")&&(o["Metamask-Sdk-Info"]=n);try{s=yield c(e,{method:"POST",headers:o,body:i})}catch(e){throw e instanceof Error?new Error(`Failed to fetch from RPC: ${e.message}`):new Error(`Failed to fetch from RPC: ${e}`)}if(!s.ok)throw new Error(`Server responded with a status of ${s.status}`);return(yield s.json()).result})))({rpcEndpoint:I,sdkInfo:g,method:t,params:e||[]});return l&&Yh(`initializeProvider::ReadOnlyRPCResponse ${r}`),r}catch(e){console.warn(`[initializeMobileProvider: sendRequest()] method=${t} readOnlyRPCRequest failed:`,e)}if((!A||A&&!M)&&t!==kf.METAMASK_GETPROVIDERSTATE){const c=(null===(f=null==n?void 0:n[0])||void 0===f?void 0:f.params)||[];if(-1!==R.indexOf(t)||e){C(!0);const e=t===kf.METAMASK_CONNECTWITH,i=`${Date.now()}`;try{yield o.start({wait:!1,connectWith:e?{method:t,id:i,params:c}:void 0}),yield new Promise(((e,t)=>{(null==a?void 0:a.isAuthorized())&&(Yh("[initializeMobileProvider: sendRequest()] already authorized"),e(!0)),null==a||a.getConnector().once(Zs.AUTHORIZED,(()=>{e(!0)})),s.once(Zs.PROVIDER_UPDATE,(e=>{Yh(`[initializeMobileProvider: sendRequest()] PROVIDER_UPDATE --- remote provider request interupted type=${e}`),e===$f.EXTENSION?t(Zs.PROVIDER_UPDATE):t(new Error("Connection Terminated"))}))}))}catch(e){if($f.EXTENSION===e){if(Yh(`[initializeMobileProvider: sendRequest()] extension provider detect: re-create ${t} on the active provider`),t.toLowerCase()===kf.METAMASK_CONNECTSIGN.toLowerCase()){const e=yield null===(p=s.getProvider())||void 0===p?void 0:p.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!e.length)throw new Error("SDK state invalid -- undefined accounts");const t=yield null===(b=s.getProvider())||void 0===b?void 0:b.request({method:kf.PERSONAL_SIGN,params:[c[0],e[0]]});return s.emit(ff.ConnectWithResponse,t),t}if(t.toLowerCase()===kf.METAMASK_CONNECTWITH.toLowerCase()){const[e]=c,t=yield(({method:e,sdk:t,params:n})=>$e(void 0,void 0,void 0,(function*(){var r,i,o,s;if(!t.isExtensionActive())throw new Error("SDK state invalid -- extension is not active");Yh("[MetaMaskProvider: extensionConnectWithOverwrite()] Overwriting request method",e,n);const a=yield null===(r=t.getProvider())||void 0===r?void 0:r.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!a.length)throw new Error("SDK state invalid -- undefined accounts");if((null==e?void 0:e.toLowerCase())===kf.PERSONAL_SIGN.toLowerCase()){const r={method:e,params:[n[0],a[0]]};return yield null===(i=t.getProvider())||void 0===i?void 0:i.request(r)}if((null==e?void 0:e.toLowerCase())===kf.ETH_SENDTRANSACTION.toLowerCase()){const r={method:e,params:[Object.assign(Object.assign({},n[0]),{from:a[0]})]};return yield null===(o=t.getProvider())||void 0===o?void 0:o.request(r)}return Mf.includes(e.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${e} -- not handled by the extension -- call separately`),a):yield null===(s=t.getProvider())||void 0===s?void 0:s.request({method:e,params:n})})))({method:e.method,sdk:s,params:e.params});return s.emit(ff.ConnectWithResponse,t),t}return Yh(`[initializeMobileProvider: sendRequest()] sending '${t}' on active provider`,c),yield null===(w=s.getProvider())||void 0===w?void 0:w.request({method:t,params:c})}if(e===Zs.REJECTED)throw null==a||a.closeModal(),null===(S=s.getProvider())||void 0===S||S.handleDisconnect({terminate:!1}),Object.assign(new Error("User rejected connection"),{code:4001});throw Yh(`[initializeMobileProvider: sendRequest()] failed to start installer: ${e}`),e}finally{C(!1)}if(t===kf.ETH_REQUESTACCOUNTS)return T=yield new Promise((e=>{const t=setInterval((()=>{const{accounts:n}=x.getState();n&&(clearInterval(t),e(n))}),100)})),Yh(`[initializeMobileProvider: sendRequest()] selectedAddress: ${L} --- SKIP rpc call`),T;if(t===kf.METAMASK_CONNECTWITH)try{let e=0;const t=5,n=({resolve:n,reject:r})=>{e+=1;const o=null==a?void 0:a.getConnector().getRPCMethodTracker(),c=null==o?void 0:o[i];return Yh(`TRACKER: update method ${i}`,c),(null==c?void 0:c.result)?(Yh("[initializeMobileProvider: sendRequest()] found result",c.result),s.emit(ff.ConnectWithResponse,c.result),void n(c.result)):(null==c?void 0:c.error)?(Yh("[initializeMobileProvider: sendRequest()] found error",c.error),void r(c.error)):e>=t?(Yh("[initializeMobileProvider: sendRequest()] max message count reached without result"),void r(new Error("Max message count reached without result"))):void Yh("[initializeMobileProvider: sendRequest()] not found yet, need to wait for next update")};let r,o;const c=yield new Promise(((e,t)=>{const s=null==a?void 0:a.getConnector().getRPCMethodTracker();Yh(`TRACKER: method ${i}`,s),(null==s?void 0:s[i].result)?(Yh("[initializeMobileProvider: sendRequest()] found result",null==s?void 0:s[i].result),e(null==s?void 0:s[i].result)):(null==s?void 0:s[i].error)&&(Yh("[initializeMobileProvider: sendRequest()] found error",null==s?void 0:s[i].error),t(null==s?void 0:s[i].error)),o=()=>n({resolve:e,reject:t}),r=null==a?void 0:a.getConnector().on(Zs.RPC_UPDATE,o)}));return o&&(null==r||r.off(Zs.RPC_UPDATE,o)),Yh("TRACKER: result",c),c}catch(e){throw Yh("[initializeMobileProvider: sendRequest()] error:",e),e}return n[0]&&"object"==typeof n[0]&&(n[0].params={__triggeredInstaller:!0,wrappedParams:n[0].params}),r(...n)}if(i.isSecure()&&xf[t])return r(...n);if(s.isExtensionActive())return Yh(`[initializeMobileProvider: sendRequest()] EXTENSION active - redirect request '${t}' to it`,n,c),yield null===(k=s.getProvider())||void 0===k?void 0:k.request({method:t,params:c});throw Yh(`[initializeMobileProvider: sendRequest()] method=${t} --- skip --- not connected/installed`),new Error("MetaMask is not connected/installed, please call eth_requestAccounts to connect first.")}try{const e=yield r(...n);if(Yh(`[initializeMobileProvider: sendRequest()] method=${t} rpcResponse`,e),t===kf.WALLET_REQUESTPERMISSIONS){const t=e.reduce(((e,t)=>{var n;if("eth_accounts"===t.parentCapability){const r=null===(n=t.caveats.find((e=>"restrictReturnedAccounts"===e.type)))||void 0===n?void 0:n.value;r&&e.push(...r)}return e}),[]);Yh("[initializeMobileProvider: sendRequest()] accountsToPersist:",t),t.length>0&&(x.handleAccountsChanged(t,!1),null==v||v.persistAccounts(t))}return e}catch(e){throw console.error("[initializeMobileProvider: sendRequest()] error:",e),e}})),{request:k}=w;w.request=(...e)=>$e(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0].method,e,k,l)}));const{send:x}=w;return w.send=(...e)=>$e(void 0,void 0,void 0,(function*(){return S(null==e?void 0:e[0],e,x,l)})),Yh("[initializeMobileProvider: sendRequest()] metamaskStream.start()"),h.start(),w}));class Vf{constructor({serverUrl:e,enabled:t,originatorInfo:n}){this.serverURL=Hs,this.serverURL=e,this.originatorInfo=n,this.enabled=null==t||t}send({event:e,params:t}){if(!this.enabled)return;const n=Object.assign(Object.assign({id:"sdk",event:e,sdkVersion:bf.version},this.originatorInfo),{params:t});Yh(`[Analytics: send()] event: ${e}`,n),Ks(n,this.serverURL).catch((e=>{Yh(`[Analytics: send()] error: ${e}`)}))}}function Wf(e){var t,n,i;const{dappMetadata:o}=e,s=function({url:e,name:t}){var n;const i=Uf(e+t);if(!localStorage)return"";let o=null!==(n=localStorage.getItem(i))&&void 0!==n?n:"";if(!o){o=r();try{localStorage.setItem(i,o)}catch(e){return""}}return o}({url:null!==(t=null==o?void 0:o.url)&&void 0!==t?t:"no_url",name:null!==(n=null==o?void 0:o.name)&&void 0!==n?n:"no_name"}),a=null===(i=e.platformManager)||void 0===i?void 0:i.getPlatformType(),c=a===ga.DesktopWeb,l=a===ga.MetaMaskMobileWebview;let d="N/A";return c?d="extension":l&&(d="mobile"),{id:s,from:d}}const Gf=({provider:e,sdkInstance:t})=>{if("state"in e)throw new Error("INVALID EXTENSION PROVIDER");return new Proxy(e,{get:(n,r)=>"request"===r?function(e){var r,i;return $e(this,void 0,void 0,(function*(){Yh("[wrapExtensionProvider()] Overwriting request method",e);const{method:o,params:s}=e,a=Af.includes(o.toLowerCase()),{id:c,from:l}=Wf(t);if(a&&(null===(r=t.analytics)||void 0===r||r.send({event:ea.SDK_RPC_REQUEST,params:{method:o,from:l,id:c}})),o===kf.METAMASK_BATCH&&Array.isArray(s))return(({target:e,args:t,trackEvent:n,sdkInstance:r})=>$e(void 0,void 0,void 0,(function*(){var i,o;if("metamask_batch"!==t.method)throw new Error("Invalid usage");const s=[],a=null!==(i=null==t?void 0:t.params)&&void 0!==i?i:[];for(const t of a){const n=yield null==e?void 0:e.request({method:t.method,params:t.params});s.push(n)}const{id:c,from:l}=Wf(r);return n&&(null===(o=r.analytics)||void 0===o||o.send({event:ea.SDK_RPC_REQUEST_DONE,params:{method:t.method,from:l,id:c}})),s})))({target:n,args:e,trackEvent:a,sdkInstance:t});if(o.toLowerCase()===kf.METAMASK_CONNECTSIGN.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>$e(void 0,void 0,void 0,(function*(){const n=yield e.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!n.length)throw new Error("SDK state invalid -- undefined accounts");return yield e.request({method:kf.PERSONAL_SIGN,params:[t[0],n[0]]})})))({target:n,params:s});if(o.toLowerCase()===kf.METAMASK_CONNECTWITH.toLowerCase()&&Array.isArray(s))return(({target:e,params:t})=>$e(void 0,void 0,void 0,(function*(){const[n]=t,r=n.method,i=n.params,o=yield e.request({method:kf.ETH_REQUESTACCOUNTS,params:[]});if(!o.length)throw new Error("SDK state invalid -- undefined accounts");return(null==r?void 0:r.toLowerCase())===kf.PERSONAL_SIGN.toLowerCase()?yield e.request({method:r,params:[i[0],o[0]]}):(null==r?void 0:r.toLowerCase())===kf.ETH_SENDTRANSACTION.toLowerCase()?yield e.request({method:r,params:[Object.assign(Object.assign({},i[0]),{from:o[0]})]}):Mf.includes(r.toLowerCase())?(console.warn(`MetaMaskSDK connectWith method=${r} -- not handled by the extension -- call separately`),o):yield e.request({method:r,params:i})})))({target:n,params:s});let d;try{return d=yield n.request(e),d}finally{a&&(null===(i=t.analytics)||void 0===i||i.send({event:ea.SDK_RPC_REQUEST_DONE,params:{method:o,from:l,id:c}}))}}))}:"getChainId"===r?function(){return e.chainId}:"getNetworkVersion"===r?function(){return e.networkVersion}:"getSelectedAddress"===r?function(){return e.selectedAddress}:"isConnected"===r?function(){return e._state.isConnected}:n[r]})};var Yf;!function(e){e.Announce="eip6963:announceProvider",e.Request="eip6963:requestProvider"}(Yf||(Yf={}));var Zf="INSTALLED",Jf="NOT_INSTALLED",Xf="REGISTERED",Qf="REGISTERING",ep="RELOADING",tp={CHROME:"https://chrome.google.com/webstore/detail/metamask/nkbihfbeogaeaoehlefnkodbefgpgknn",FIREFOX:"https://addons.mozilla.org/firefox/addon/ether-metamask/",DEFAULT:"https://metamask.io"},np="REGISTRATION_IN_PROGRESS",rp="FORWARDER_ID",ip=function(){function e(t){var n=void 0===t?{}:t,r=n.forwarderOrigin,i=void 0===r?"https://fwd.metamask.io":r,o=n.forwarderMode,s=void 0===o?e.FORWARDER_MODE.INJECT:o;this.forwarderOrigin=i,this.forwarderMode=s,this.state=e.isMetaMaskInstalled()?Zf:Jf;var a=e._detectBrowser();this.downloadUrl=a?tp[a]:tp.DEFAULT,this._onMessage=this._onMessage.bind(this),this._onMessageFromForwarder=this._onMessageFromForwarder.bind(this),this._openForwarder=this._openForwarder.bind(this),this._openDownloadPage=this._openDownloadPage.bind(this),this.startOnboarding=this.startOnboarding.bind(this),this.stopOnboarding=this.stopOnboarding.bind(this),window.addEventListener("message",this._onMessage),s===e.FORWARDER_MODE.INJECT&&"true"===sessionStorage.getItem(np)&&e._injectForwarder(this.forwarderOrigin)}return e.prototype._onMessage=function(e){if(e.origin===this.forwarderOrigin)return"metamask:reload"===e.data.type?this._onMessageFromForwarder(e):void console.debug("Unknown message from '"+e.origin+"' with data "+JSON.stringify(e.data))},e.prototype._onMessageUnknownStateError=function(e){throw new Error("Unknown state: '"+e+"'")},e.prototype._onMessageFromForwarder=function(t){return function(e,t,n,r){return new(n||(n=Promise))((function(t,i){function o(e){try{a(r.next(e))}catch(e){i(e)}}function s(e){try{a(r.throw(e))}catch(e){i(e)}}function a(e){var r;e.done?t(e.value):(r=e.value,r instanceof n?r:new n((function(e){e(r)}))).then(o,s)}a((r=r.apply(e,[])).next())}))}(this,0,void 0,(function(){return function(e,t){var n,r,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!((i=(i=s.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){s=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){s.label=o[1];break}if(6===o[0]&&s.label<i[1]){s.label=i[1],i=o;break}if(i&&s.label<i[2]){s.label=i[2],s.ops.push(o);break}i[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}(this,(function(n){switch(n.label){case 0:switch(this.state){case ep:return[3,1];case Jf:return[3,2];case Zf:return[3,3];case Qf:return[3,5];case Xf:return[3,6]}return[3,7];case 1:return console.debug("Ignoring message while reloading"),[3,8];case 2:return console.debug("Reloading now to register with MetaMask"),this.state=ep,location.reload(),[3,8];case 3:return console.debug("Registering with MetaMask"),this.state=Qf,[4,e._register()];case 4:return n.sent(),this.state=Xf,t.source.postMessage({type:"metamask:registrationCompleted"},t.origin),this.stopOnboarding(),[3,8];case 5:return console.debug("Already registering - ignoring reload message"),[3,8];case 6:return console.debug("Already registered - ignoring reload message"),[3,8];case 7:this._onMessageUnknownStateError(this.state),n.label=8;case 8:return[2]}}))}))},e.prototype.startOnboarding=function(){sessionStorage.setItem(np,"true"),this._openDownloadPage(),this._openForwarder()},e.prototype.stopOnboarding=function(){"true"===sessionStorage.getItem(np)&&(this.forwarderMode===e.FORWARDER_MODE.INJECT&&(console.debug("Removing forwarder"),e._removeForwarder()),sessionStorage.setItem(np,"false"))},e.prototype._openForwarder=function(){this.forwarderMode===e.FORWARDER_MODE.OPEN_TAB?window.open(this.forwarderOrigin,"_blank"):e._injectForwarder(this.forwarderOrigin)},e.prototype._openDownloadPage=function(){window.open(this.downloadUrl,"_blank")},e.isMetaMaskInstalled=function(){return Boolean(window.ethereum&&window.ethereum.isMetaMask)},e._register=function(){return window.ethereum.request({method:"wallet_registerOnboarding"})},e._injectForwarder=function(e){var t=document.body,n=document.createElement("iframe");n.setAttribute("height","0"),n.setAttribute("width","0"),n.setAttribute("style","display: none;"),n.setAttribute("src",e),n.setAttribute("id",rp),t.insertBefore(n,t.children[0])},e._removeForwarder=function(){var e;null===(e=document.getElementById(rp))||void 0===e||e.remove()},e._detectBrowser=function(){var e=hf.parse(window.navigator.userAgent);return"Firefox"===e.browser.name?"FIREFOX":["Chrome","Chromium"].includes(e.browser.name||"")?"CHROME":null},e.FORWARDER_MODE={INJECT:"INJECT",OPEN_TAB:"OPEN_TAB"},e}();class op{constructor({remote:e,preferDesktop:t,platformManager:n,debug:r=!1}){this.state={isInstalling:!1,hasInstalled:!1,resendRequest:null,preferDesktop:!1,platformManager:null,remote:null,debug:!1,connectWith:void 0},this.state.remote=e,this.state.preferDesktop=t,this.state.platformManager=n,this.state.debug=r}startDesktopOnboarding(){return function(){return $e(this,void 0,void 0,(function*(){Yh("[MetamaskInstaller: startDesktopOnboarding() starting desktop onboarding"),window.ethereum&&(window.ethereum=void 0),(new ip).startOnboarding()}))}()}redirectToProperInstall(){return $e(this,void 0,void 0,(function*(){return function(e){var t,n;return $e(this,void 0,void 0,(function*(){const{state:r}=e,i=null===(t=r.platformManager)||void 0===t?void 0:t.getPlatformType();if(Yh(`[MetamaskInstaller: redirectToProperInstall()] platform=${i}`),i===ga.MetaMaskMobileWebview)return!1;r.isInstalling=!0;try{yield null===(n=r.remote)||void 0===n?void 0:n.startConnection({connectWith:r.connectWith}),r.isInstalling=!1,r.hasInstalled=!0}catch(e){throw r.isInstalling=!1,e}return!0}))}(this)}))}checkInstallation(){return $e(this,void 0,void 0,(function*(){return function(e){var t;return $e(this,void 0,void 0,(function*(){const{state:n}=e,r=null===(t=n.platformManager)||void 0===t?void 0:t.isMetaMaskInstalled();return Yh(`[MetamaskInstaller: checkInstallation()] isInstalled=${r}`),!!r||(yield e.redirectToProperInstall())}))}(this)}))}start({wait:e=!1,connectWith:t}){return $e(this,void 0,void 0,(function*(){this.state.connectWith=t,Yh(`[MetaMaskInstaller: start()] wait=${e}`,t),yield function(e,{wait:t=!1}){return $e(this,void 0,void 0,(function*(){return Yh(`[MetamaskInstaller: startInstaller()] wait=${t}`),t&&(yield zf(1e3)),yield e.checkInstallation()}))}(this,{wait:e})}))}}class sp{constructor({debug:e,sdkVersion:t}){this.containers={install:void 0,pending:void 0,select:void 0},this.defined={install:!1,pending:!1,select:!1},this.debug=null!=e&&e,this.sdkVersion=t}loadComponent(e){return $e(this,void 0,void 0,(function*(){if(!this.defined[e]){this.defined[e]=!0;try{const e=yield Promise.resolve().then((function(){return Rg}));console.log("loader",e),e.defineCustomElements()}catch(t){console.error(`Failed to load ${e} modal:`,t)}}}))}renderInstallModal(e){var t;return $e(this,void 0,void 0,(function*(){this.debug&&console.debug("ModalLoader: renderInstallModal",e),this.containers.install=e.parentElement,yield this.loadComponent("install");const n=document.createElement("mm-install-modal");n.link=e.link,n.preferDesktop=e.preferDesktop,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("startDesktopOnboarding",e.metaMaskInstaller.startDesktopOnboarding),n.addEventListener("trackAnalytics",(t=>{var n;return null===(n=e.onAnalyticsEvent)||void 0===n?void 0:n.call(e,t.detail)})),e.parentElement.appendChild(n)}))}renderSelectModal(e){var t;return $e(this,void 0,void 0,(function*(){this.containers.select=e.parentElement,yield this.loadComponent("select");const n=document.createElement("mm-select-modal");n.link=e.link,n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.preferDesktop=e.preferDesktop,n.addEventListener("close",(({detail:{shouldTerminate:t}})=>e.onClose(t))),n.addEventListener("connectWithExtension",e.connectWithExtension),e.parentElement.appendChild(n),setTimeout((()=>this.updateQRCode(e.link)),100)}))}renderPendingModal(e){var t;return $e(this,void 0,void 0,(function*(){this.containers.pending=e.parentElement,yield this.loadComponent("pending");const n=document.createElement("mm-pending-modal");n.sdkVersion=null!==(t=e.sdkVersion)&&void 0!==t?t:this.sdkVersion,n.displayOTP=e.displayOTP,n.addEventListener("close",e.onClose),n.addEventListener("updateOTPValue",(({detail:{otpValue:t}})=>e.updateOTPValue(t))),e.onDisconnect&&n.addEventListener("disconnect",e.onDisconnect),e.parentElement.appendChild(n)}))}updateOTPValue(e){const t=()=>{var t;const n=null===(t=this.containers.pending)||void 0===t?void 0:t.querySelector("mm-pending-modal");return!!n&&(n.otpCode=e,!0)};setTimeout((()=>{t()}),800)}updateQRCode(e){var t,n;const r=null===(t=this.containers.install)||void 0===t?void 0:t.querySelector("mm-install-modal");if(r)r.link=e;else{const t=null===(n=this.containers.select)||void 0===n?void 0:n.querySelector("mm-select-modal");t&&(t.link=e)}}unmount(){Object.entries(this.containers).forEach((([e,t])=>{var n;null===(n=null==t?void 0:t.parentNode)||void 0===n||n.removeChild(t),this.containers[e]=void 0}))}}const ap=({link:e,debug:t,installer:n,terminate:r,connectWithExtension:i,preferDesktop:o,onAnalyticsEvent:s})=>{let a=null,c=null;Yh("[UI: InstallModal-web: sdkWebInstallModal()] ################## Installing Modal #################"),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] link=${e}`),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --ios`),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] npx uri-scheme open "${e}" --android`),Yh(`[UI: InstallModal-web: sdkWebInstallModal()] adb shell am start -a android.intent.action.VIEW -d "${e}"`);const l=e=>{var t;Yh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web unmounting install modal -- shouldTerminate:",e,c),(null==c?void 0:c.parentNode)&&(null===(t=c.parentNode)||void 0===t||t.removeChild(c)),c=null,a=null,!0===e&&(null==r||r())};return{mount:r=>{if(Yh("[UI: InstallModal-web: sdkWebInstallModal()] installModal-web mounting install modal",c),c)return c.style.display="block",void(null==a||a.updateQRCode(r));a=new sp({debug:t,sdkVersion:bf.version}),c=document.createElement("div"),document.body.appendChild(c),window.extension?a.renderSelectModal({parentElement:c,connectWithExtension:()=>{l(),null==i||i()},onClose:l,link:e,preferDesktop:null!=o&&o}).catch((e=>{console.error(e)})):a.renderInstallModal({parentElement:c,preferDesktop:null!=o&&o,link:e,metaMaskInstaller:n,onClose:l,onAnalyticsEvent:s}).catch((e=>{console.error("[UI: InstallModal-web: sdkWebInstallModal()]",e)}))},unmount:l}},cp=({onDisconnect:e,debug:t})=>{let n=null,r=null;const i=()=>{Yh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web unmount",n),(null==n?void 0:n.parentNode)&&n.parentNode.removeChild(n),n=null,r=null},o=e=>{Yh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web updateOTPValue",e),r&&r.updateOTPValue(e)},s=({displayOTP:s}={displayOTP:!0})=>{Yh("[UI: pendingModal-web: sdkWebPendingModal()] pendingModal-web mount",n),n?n.style.display="block":(r=new sp({debug:t,sdkVersion:bf.version}),n=document.createElement("div"),document.body.appendChild(n),r.renderPendingModal({parentElement:n,onClose:i,onDisconnect:e,updateOTPValue:o,displayOTP:s}).catch((e=>{console.error("[UI: pendingModal-web: sdkWebPendingModal()]",e)})))};return s(),{mount:s,unmount:i,updateOTPValue:o}};function lp(e,t){var n,r,i,o;e.connector||(Yh("[RemoteConnection: initializeConnector()] initialize connector"),e.connector=new La({platformType:t.platformManager.getPlatformType(),communicationLayerPreference:t.communicationLayerPreference,transports:t.transports,dappMetadata:Object.assign(Object.assign({},t.dappMetadata),{source:t._source}),analytics:t.enableAnalytics,communicationServerUrl:t.communicationServerUrl,sdkVersion:bf.version,context:"dapp",ecies:t.ecies,storage:t.storage,logging:t.logging}),t.timer&&(Yh("[RemoteConnection: initializeConnector()] reset background timer",t.timer),null===(r=null===(n=t.timer)||void 0===n?void 0:n.stopBackgroundTimer)||void 0===r||r.call(n),null===(o=null===(i=t.timer)||void 0===i?void 0:i.runBackgroundTimer)||void 0===o||o.call(i,(()=>!1),1e4)))}function dp(e){e.listeners.forEach((({event:t,handler:n})=>{var r;null===(r=e.connector)||void 0===r||r.off(t,n)})),e.listeners=[]}function up(e,t){function n(t,n){var r;null===(r=e.connector)||void 0===r||r.on(t,n),e.listeners.push({event:t,handler:n})}e.connector&&(dp(e),n(Zs.WALLET_INIT,(({accounts:e,chainId:t})=>$e(this,void 0,void 0,(function*(){Yh(`[RemoteConnection: setupListeners() => EventType.WALLET_INIT] 'wallet_init' accounts=${e} chainId=${t}`);const n=pf.getProvider();n._setConnected();const r={accounts:e,chainId:t,isUnlocked:!1};n._initializeState(r),n.emit("chainChanged",t),n.emit("accountsChanged",e)})))),n(Zs.AUTHORIZED,(()=>$e(this,void 0,void 0,(function*(){var t,n,r,i;try{Yh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' closing modals",e.pendingModal,e.installModal);const o=pf.getProvider();o._setConnected(),null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!1),e.otpAnswer=void 0,e.authorized=!0,Yh("[RemoteConnection: setupListeners() => EventType.AUTHORIZED] 'authorized' provider.state",o.getState()),yield o.forceInitializeState()}catch(e){}})))),n(Zs.TERMINATE,(()=>{var t,n,r,i,o;null===(n=null===(t=e.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),null===(i=null===(r=e.installModal)||void 0===r?void 0:r.unmount)||void 0===i||i.call(r,!0),e.pendingModal=void 0,e.installModal=void 0,e.otpAnswer=void 0,null===(o=e.connector)||void 0===o||o.disconnect({terminate:!0}),e.authorized=!1,pf.getProvider().handleDisconnect({terminate:!0}),dp(e),Yh("[RemoteConnection: setupListeners()] All listeners cleaned up")})))}function hp(e,t,{initialCheck:n,connectWith:r}={}){var i,o,s,a,c,l,d,u,h,f,p,g,m,y,v,b,w,E,C;return $e(this,void 0,void 0,(function*(){try{if(lp(e,t),!e.connector)throw new Error("no connector defined");up(e);const _=pf.getProvider();e.authorized=!1,_.emit("connecting");const S=yield null===(i=e.connector)||void 0===i?void 0:i.originatorSessionConnect();Yh(`[RemoteConnection: startConnection()] after originatorSessionConnect initialCheck=${n}`,S);let k=null!==(o=null==S?void 0:S.channelId)&&void 0!==o?o:"",x=null!==(a=null===(s=e.connector.getKeyInfo())||void 0===s?void 0:s.ecies.public)&&void 0!==a?a:"",A=null!==(l=null===(c=e.connector.getKeyInfo())||void 0===c?void 0:c.ecies.private)&&void 0!==l?l:"";if(n&&!S)return Promise.resolve();if(!S&&!n){const t=yield e.connector.generateChannelIdConnect();k=null!==(d=t.channelId)&&void 0!==d?d:"",x=null!==(u=t.pubKey)&&void 0!==u?u:"",A=null!==(h=t.privKey)&&void 0!==h?h:"";const n=Date.now();null===(f=e.connector.state.storageManager)||void 0===f||f.persistChannelConfig({channelId:k,localKey:A,lastActive:n,validUntil:n+qs})}if(n&&(null==S?void 0:S.channelId))return(null===(p=e.connector)||void 0===p?void 0:p.isConnected())||(Yh(`[RemoteConnection: startConnection()] reconnecting to channel initialCheck=${n}`,S),yield null===(g=e.connector)||void 0===g?void 0:g.connectToChannel({channelId:k})),Promise.resolve();S&&!(null===(m=e.connector)||void 0===m?void 0:m.isConnected())&&(Yh("[RemoteConnection: startConnection()] reconnecting to channel",S),yield null===(y=e.connector)||void 0===y?void 0:y.connectToChannel({channelId:k}));const M=(null===(v=e.platformManager)||void 0===v?void 0:v.isSecure())?"":"&t=q",L=bf.version,{iconUrl:T,name:O,url:R,scheme:P}=t.dappMetadata||{},I=null===(b=e.platformManager)||void 0===b?void 0:b.getPlatformType();let N="N/A";"undefined"!=typeof window&&window.location&&window.location.hostname?N=window.location.hostname:void 0!==O?N=O:void 0!==R&&(N=R);const B={url:null!=R?R:"",title:null!=O?O:"",icon:T,scheme:null!=P?P:"",apiVersion:L,dappId:N||R||"N/A",platform:null!=I?I:"",source:null!==(w=t._source)&&void 0!==w?w:""},D=Uf(JSON.stringify(B));let $=`channelId=${k}&v=2&comm=${null!==(E=e.communicationLayerPreference)&&void 0!==E?E:""}&pubkey=${x}${M}&originatorInfo=${D}`;if(r){$+=`&rpc=${Uf(JSON.stringify(r))}`;const t=e.connector.getRPCMethodTracker();t&&(t[`${r.id}`]=Object.assign(Object.assign({},r),{id:`${r.id}`,timestamp:Date.now()}))}const j=encodeURI($),K=`${e.useDeeplink?Cf:Ef}?${$}`;return e.qrcodeLink=K,e.developerMode&&Yh(`[RemoteConnection: startConnection()] qrcodeLink=${j}`),_.emit("display_uri",K),(null===(C=e.platformManager)||void 0===C?void 0:C.isSecure())?(yield function(e,t){var n,r;return $e(this,void 0,void 0,(function*(){const i=`${Ef}?${t}`,o=`${Cf}?${t}`;null===(r=null===(n=e.platformManager)||void 0===n?void 0:n.openDeeplink)||void 0===r||r.call(n,i,o,"_self")}))}(e,j),new Promise(((t,n)=>{var r,i,o;(null===(r=e.connector)||void 0===r?void 0:r.isAuthorized())?t():(null===(i=e.connector)||void 0===i||i.once(Zs.AUTHORIZED,(()=>{t()})),null===(o=e.connector)||void 0===o||o.once(Zs.REJECTED,(()=>{n(Zs.REJECTED)})))}))):function(e,t,n){return $e(this,void 0,void 0,(function*(){return new Promise(((r,i)=>{if(!e.connector)return void i(new Error("No connector available"));Yh("[RemoteConnection: connectWithModalInstaller()]",{state:e,options:t,linkParams:n});const o=`${e.useDeeplink?Cf:Ef}?${n}`;!function(e,t,n){var r,i,o,s;e.installModal=null===(i=(r=t.modals).install)||void 0===i?void 0:i.call(r,{link:n,preferDesktop:e.preferDesktop,installer:t.getMetaMaskInstaller(),terminate:()=>{Yh("[RemoteConnection: showInstallModal() => terminate()] terminate connection"),t.sdk.terminate().catch((e=>{console.warn("[MMSDK] failed to terminate connection",e)}))},debug:e.developerMode,connectWithExtension:()=>{var e;return null===(e=t.connectWithExtensionProvider)||void 0===e||e.call(t),!1},onAnalyticsEvent:({event:n,params:r})=>{var i,o,s;const a=Object.assign(Object.assign({},r),{sdkVersion:t.sdk.getVersion(),dappId:null===(i=t.dappMetadata)||void 0===i?void 0:i.name,source:t._source,url:null===(o=t.dappMetadata)||void 0===o?void 0:o.url});null===(s=e.analytics)||void 0===s||s.send({event:n,params:a})}}),null===(s=null===(o=e.installModal)||void 0===o?void 0:o.mount)||void 0===s||s.call(o,n)}(e,t,o),t.sdk.once(Zs.PROVIDER_UPDATE,(e=>$e(this,void 0,void 0,(function*(){Yh("[RemoteConnection: connectWithModalInstaller()] once provider_update -- resolving startConnection promise"),e!==$f.TERMINATE?i(e):i({code:4001,message:"User rejected the request."})})))),e.connector.once(Zs.AUTHORIZED,(()=>{r()})),e.connector.once(Zs.REJECTED,(()=>{i(Zs.REJECTED)})),e.connector.once(Zs.CLIENTS_READY,(()=>$e(this,void 0,void 0,(function*(){Yh("[RemoteConnection: connectWithModalInstaller()] once clients_ready -- resolving startConnection promise"),r()}))))}))}))}(e,t,j)}catch(e){throw console.error("[startConnection] error",e),e}}))}class fp{constructor(e){var t,n,r;this.state={connector:void 0,qrcodeLink:void 0,analytics:void 0,developerMode:!1,authorized:!1,reconnection:!1,preferDesktop:!1,deeplinkProtocol:!1,listeners:[],communicationLayerPreference:void 0,platformManager:void 0,pendingModal:void 0,installModal:void 0,otpAnswer:void 0},this.options=e;const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode)||!0===(null===(n=e.logging)||void 0===n?void 0:n.sdk);this.state.developerMode=i,this.state.analytics=e.analytics,this.state.preferDesktop=null!==(r=e.preferDesktop)&&void 0!==r&&r,this.state.useDeeplink=e.sdk.options.useDeeplink,this.state.communicationLayerPreference=e.communicationLayerPreference,this.state.platformManager=e.platformManager,e.modals.install||(e.modals.install=ap),e.modals.otp||(e.modals.otp=cp)}startConnection(e){return $e(this,void 0,void 0,(function*(){return hp(this.state,this.options,e)}))}initRemoteCommunication({sdkInstance:e}){var t,n,r;return $e(this,void 0,void 0,(function*(){const i=yield null===(n=null===(t=e.options.storage)||void 0===t?void 0:t.storageManager)||void 0===n?void 0:n.getPersistedChannelConfig();if(!this.options.ecies){const e={privateKey:null==i?void 0:i.localKey};this.options.ecies=e}lp(this.state,this.options),yield null===(r=this.getConnector())||void 0===r?void 0:r.initFromDappStorage(),up(this.state,this.options)}))}showActiveModal(){return function(e){var t,n,r,i;e.authorized?Yh("[RemoteConnection: showActiveModal()] already authorized"):e.pendingModal?null===(n=(t=e.pendingModal).mount)||void 0===n||n.call(t):e.installModal&&(null===(i=(r=e.installModal).mount)||void 0===i||i.call(r,e.qrcodeLink||""))}(this.state)}closeModal(){var e,t,n,r;null===(t=null===(e=this.state.pendingModal)||void 0===e?void 0:e.unmount)||void 0===t||t.call(e),null===(r=null===(n=this.state.installModal)||void 0===n?void 0:n.unmount)||void 0===r||r.call(n,!1)}getUniversalLink(){if(!this.state.qrcodeLink)throw new Error("connection not started. run startConnection() first.");return this.state.qrcodeLink}getChannelConfig(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getChannelConfig()}getKeyInfo(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.getKeyInfo()}getConnector(){if(!this.state.connector)throw new Error("invalid remote connector");return this.state.connector}getPlatformManager(){if(!this.state.platformManager)throw new Error("PlatformManager not available");return this.state.platformManager}isConnected(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isReady())||!1}isAuthorized(){var e;return(null===(e=this.state.connector)||void 0===e?void 0:e.isAuthorized())||!1}isPaused(){var e;return null===(e=this.state.connector)||void 0===e?void 0:e.isPaused()}disconnect(e){var t,n,r;Yh("[RemoteConnection: disconnect()]",e),(null==e?void 0:e.terminate)&&(pf.getProvider().handleDisconnect({terminate:!0}),null===(n=null===(t=this.state.pendingModal)||void 0===t?void 0:t.unmount)||void 0===n||n.call(t),this.state.otpAnswer=void 0),null===(r=this.state.connector)||void 0===r||r.disconnect(e),function(e){Yh("[RemoteConnection: cleanupConnector()] cleaning up connector"),e.connector&&(dp(e),e.connector.disconnect({terminate:!0}).catch((e=>{Yh("[RemoteConnection: cleanupConnector()] error disconnecting connector",e)})))}(this.state)}}function pp(e){var t,n,r,i,o,s,a,c,l,d,u;return $e(this,void 0,void 0,(function*(){const{options:h}=e;if(h.logging=null!==(t=h.logging)&&void 0!==t?t:{},h.communicationLayerPreference=null!==(n=h.communicationLayerPreference)&&void 0!==n?n:pa.SOCKET,void 0!==h.enableDebug&&(f.enable("MM_SDK"),console.warn("enableDebug is removed. Please use enableAnalytics instead.")),h.enableAnalytics=null===(r=h.enableAnalytics)||void 0===r||r,h.injectProvider=null===(i=h.injectProvider)||void 0===i||i,h.shouldShimWeb3=null===(o=h.shouldShimWeb3)||void 0===o||o,h.extensionOnly=null===(s=h.extensionOnly)||void 0===s||s,h.useDeeplink=null===(a=h.useDeeplink)||void 0===a||a,h.storage=null!==(c=h.storage)&&void 0!==c?c:{enabled:!0},h.headless){f("[MetaMaskSDK: performSDKInitialization()] headless mode enabled");const e=()=>{},t={install:()=>({mount:e,unmount:e})},n={installer:e};h.modals=t,h.ui=n}const p=!0===(null===(l=h.logging)||void 0===l?void 0:l.developerMode);e.debug=(null===(d=h.logging)||void 0===d?void 0:d.sdk)||p,Yh("[MetaMaskSDK: performSDKInitialization()] options",e.options);const g=Object.assign({},h.logging);p&&(g.sdk=!0,g.eciesLayer=!0,g.keyExchangeLayer=!0,g.remoteLayer=!0,g.serviceLayer=!0,g.plaintext=!0),yield function(e){var t;return $e(this,void 0,void 0,(function*(){const{options:n}=e;e.platformManager=new gf({useDeepLink:null!==(t=n.useDeeplink)&&void 0!==t&&t,preferredOpenLink:n.openDeeplink,debug:e.debug})}))}(e),yield function(e){var t,n,r,i,o,s,a,c,l;return $e(this,void 0,void 0,(function*(){const{options:d}=e,u=null===(t=e.platformManager)||void 0===t?void 0:t.getPlatformType();e.analytics=new Vf({serverUrl:null!==(n=d.communicationServerUrl)&&void 0!==n?n:Hs,enabled:d.enableAnalytics,originatorInfo:{url:null!==(r=d.dappMetadata.url)&&void 0!==r?r:"",title:null!==(i=d.dappMetadata.name)&&void 0!==i?i:"",dappId:"undefined"==typeof window||void 0===window.location?null!==(c=null!==(s=null===(o=d.dappMetadata)||void 0===o?void 0:o.name)&&void 0!==s?s:null===(a=d.dappMetadata)||void 0===a?void 0:a.url)&&void 0!==c?c:"N/A":window.location.hostname,platform:null!=u?u:"",source:null!==(l=d._source)&&void 0!==l?l:""}})}))}(e),yield function(e){var t;return $e(this,void 0,void 0,(function*(){const{options:n}=e;!0!==(null===(t=n.storage)||void 0===t?void 0:t.enabled)||n.storage.storageManager||(n.storage.storageManager=yield mf(n.storage))}))}(e),yield function(e){return $e(this,void 0,void 0,(function*(){const{options:t}=e,n=/^(http|https):\/\/[^\s]*$/;if(t.dappMetadata){t.dappMetadata.iconUrl&&!n.test(t.dappMetadata.iconUrl)&&(console.warn("Invalid dappMetadata.iconUrl: URL must start with http:// or https://"),t.dappMetadata.iconUrl=void 0),t.dappMetadata.base64Icon&&t.dappMetadata.base64Icon.length>163400&&(console.warn("Invalid dappMetadata.base64Icon: Base64-encoded icon string length must be less than 163400 characters"),t.dappMetadata.base64Icon=void 0),t.dappMetadata.url&&!n.test(t.dappMetadata.url)&&console.warn("Invalid dappMetadata.url: URL must start with http:// or https://");const e=(()=>{if("undefined"==typeof document)return;let e;const t=document.getElementsByTagName("link");for(let n=0;n<t.length;n++)"icon"!==t[n].getAttribute("rel")&&"shortcut icon"!==t[n].getAttribute("rel")||(e=t[n].getAttribute("href"));return e})();if(e&&!t.dappMetadata.iconUrl&&!t.dappMetadata.base64Icon){const n=`${window.location.protocol}//${window.location.host}${e}`;t.dappMetadata.iconUrl=n}}e.dappMetadata=t.dappMetadata}))}(e),yield(e=>$e(void 0,void 0,void 0,(function*(){const{options:t}=e,{infuraAPIKey:n}=t;if(!n)return;const r={"0x1":`https://mainnet.infura.io/v3/${n}`,"0x5":`https://goerli.infura.io/v3/${n}`,"0xaa36a7":`https://sepolia.infura.io/v3/${n}`,"0xe708":`https://linea-mainnet.infura.io/v3/${n}`,"0xe704":`https://linea-goerli.infura.io/v3/${n}`,"0x89":`https://polygon-mainnet.infura.io/v3/${n}`,"0x13881":`https://polygon-mumbai.infura.io/v3/${n}`,"0x45":`https://optimism-mainnet.infura.io/v3/${n}`,"0x1a4":`https://optimism-goerli.infura.io/v3/${n}`,"0xa4b1":`https://arbitrum-mainnet.infura.io/v3/${n}`,"0x66eed":`https://arbitrum-goerli.infura.io/v3/${n}`,"0x2a15c308d":`https://palm-mainnet.infura.io/v3/${n}`,"0x2a15c3083":`https://palm-testnet.infura.io/v3/${n}`,"0xa86a":`https://avalanche-mainnet.infura.io/v3/${n}`,"0xa869":`https://avalanche-fuji.infura.io/v3/${n}`,"0x4e454152":`https://aurora-mainnet.infura.io/v3/${n}`,"0x4e454153":`https://aurora-testnet.infura.io/v3/${n}`,"0x534e5f4d41494e":`https://starknet-mainnet.infura.io/v3/${n}`,"0x534e5f474f45524c49":`https://starknet-goerli.infura.io/v3/${n}`,"0x534e5f474f45524c4932":`https://starknet-goerli2.infura.io/v3/${n}`,"0xa4ec":`https://celo-mainnet.infura.io/v3/${n}`,"0xaef3":`https://celo-alfajores.infura.io/v3/${n}`};e.options.readonlyRPCMap?e.options.readonlyRPCMap=Object.assign(Object.assign({},e.options.readonlyRPCMap),r):e.options.readonlyRPCMap=r})))(e),yield(e=>$e(void 0,void 0,void 0,(function*(){const{options:t}=e,{readonlyRPCMap:n}=t;if(n)try{Yh("[MetaMaskSDK: setupReadOnlyRPCProviders()] Setting up Readonly RPC Providers",n),e.setReadOnlyRPCCalls(!0)}catch(e){throw new Error("Invalid Infura Settings")}})))(e);const{metamaskBrowserExtension:m,preferExtension:y,shouldReturn:v}=yield function(e){var t,n,r,i;return $e(this,void 0,void 0,(function*(){const{options:o}=e;let s,a=!1,c=!1;if("undefined"!=typeof window&&window.ethereum&&!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){a="extension"===localStorage.getItem(Tf);try{s=yield function({mustBeMetaMask:e,sdkInstance:t}){return $e(this,void 0,void 0,(function*(){if("undefined"==typeof window)throw new Error("window not available");try{const e=yield new Promise(((e,t)=>{const n=setTimeout((()=>{t(new Error("eip6963RequestProvider timed out"))}),500);window.addEventListener(Yf.Announce,(t=>{const r=t,{detail:{info:i,provider:o}={}}=r,{name:s,rdns:a,uuid:c}=null!=i?i:{};Sf.test(c)&&s.startsWith(_f.NAME)&&_f.RDNS.includes(a)&&(clearTimeout(n),e(o))})),window.dispatchEvent(new Event(Yf.Request))}));return Gf({provider:e,sdkInstance:t})}catch(n){if(!e&&window.ethereum)return Gf({provider:window.ethereum,sdkInstance:t});throw new Error("Provider not found")}}))}({mustBeMetaMask:!0,sdkInstance:e}),window.extension=s,s.on(Pf,(t=>{Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE chainChanged chainId=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Pf,t)})),s.on(If,(t=>$e(this,void 0,void 0,(function*(){var n;Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE accountsChanged accounts=${t}`);const r=Boolean(e.sdkProvider),i=Boolean(e.extensionActive);if(r&&e.getMobileProvider().emit(If,t),i&&0===(null==t?void 0:t.length)&&0===(yield null===(n=e.getProvider())||void 0===n?void 0:n.request({method:kf.WALLET_GETPERMISSIONS,params:[]})).length)try{yield e.terminate()}catch(e){Yh("[MetaMaskSDK: setupExtensionPreferences()] error terminating on permissions revoked",e)}})))),s.on(Nf,(t=>{Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE disconnect error=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Nf,t)})),s.on(Bf,(t=>{Yh(`[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connect args=${t}`),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Bf,t)})),s.on(Df,(t=>{Yh("[MetaMaskSDK: setupExtensionPreferences()] PROPAGATE connected",t),Boolean(e.sdkProvider)&&e.getMobileProvider().emit(Df,t)}))}catch(e){window.extension=void 0}}else(null===(n=e.platformManager)||void 0===n?void 0:n.isMetaMaskMobileWebView())&&(null===(r=e.analytics)||void 0===r||r.send({event:ea.SDK_USE_INAPP_BROWSER}),e.activeProvider=Gf({provider:window.ethereum,sdkInstance:e}),e._initialized=!0,c=!0);return s&&o.extensionOnly&&(Yh("[MetaMaskSDK: setupExtensionPreferences()] EXTENSION ONLY --- prevent sdk initialization"),null===(i=e.analytics)||void 0===i||i.send({event:ea.SDK_USE_EXTENSION}),e.activeProvider=s,e.extensionActive=!0,e.extension=s,e._initialized=!0,c=!0),{preferExtension:a,shouldReturn:c,metamaskBrowserExtension:s}}))}(e);if(v)Yh("[MetaMaskSDK: performSDKInitialization()] shouldReturn=true --- prevent sdk initialization");else{yield function(e,t){var n,r,i,o,s;return $e(this,void 0,void 0,(function*(){const{options:a}=e,c=Object.assign({},a.logging);e.remoteConnection=new fp({preferDesktop:null!==(n=a.preferDesktop)&&void 0!==n&&n,communicationLayerPreference:null!==(r=a.communicationLayerPreference)&&void 0!==r?r:pa.SOCKET,analytics:e.analytics,dappMetadata:a.dappMetadata,_source:a._source,enableAnalytics:null===(i=a.enableAnalytics)||void 0===i||i,timer:a.timer,sdk:e,platformManager:e.platformManager,transports:a.transports,communicationServerUrl:a.communicationServerUrl,storage:null!==(o=a.storage)&&void 0!==o?o:{enabled:!0},getMetaMaskInstaller:()=>{if(!e.installer)throw new Error("Invalid SDK status -- installer not initialized");return e.installer},logging:c,connectWithExtensionProvider:void 0===t?void 0:()=>Kf(e),modals:Object.assign(Object.assign({},a.modals),{onPendingModalDisconnect:e.terminate.bind(e)})}),yield e.remoteConnection.initRemoteCommunication({sdkInstance:e}),e.installer=new op({remote:e.remoteConnection,preferDesktop:null!==(s=a.preferDesktop)&&void 0!==s&&s,platformManager:e.platformManager,debug:e.debug})}))}(e,m),yield function(e){var t,n,r,i;return $e(this,void 0,void 0,(function*(){const{options:o}=e,s={communicationLayerPreference:null!==(t=o.communicationLayerPreference)&&void 0!==t?t:pa.SOCKET,platformManager:e.platformManager,sdk:e,checkInstallationOnAllCalls:o.checkInstallationOnAllCalls,injectProvider:null===(n=o.injectProvider)||void 0===n||n,shouldShimWeb3:null===(r=o.shouldShimWeb3)||void 0===r||r,extensionOnly:null===(i=o.extensionOnly)||void 0===i||i,installer:e.installer,remoteConnection:e.remoteConnection,debug:e.debug},a=yield qf(s);e.activeProvider=a,function(e){var t,n,r,i;null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n||n.on(ff.ConnectionStatus,(t=>{e.emit(ff.ConnectionStatus,t)})),null===(i=null===(r=e.remoteConnection)||void 0===r?void 0:r.getConnector())||void 0===i||i.on(ff.ServiceStatus,(t=>{e.emit(ff.ServiceStatus,t)}))}(e)}))}(e),yield function(e,t){var n,r;return $e(this,void 0,void 0,(function*(){const{options:i}=e;t?(Yh("[MetaMaskSDK: handleAutoAndExtensionConnections()] preferExtension is detected -- connect with it."),null===(n=e.analytics)||void 0===n||n.send({event:ea.SDK_EXTENSION_UTILIZED}),Kf(e).catch((e=>{console.warn("Can't connect with MetaMask extension...",e),localStorage.removeItem(Tf)}))):i.checkInstallationImmediately&&((null===(r=e.platformManager)||void 0===r?void 0:r.isDesktopWeb())?(Yh("[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately"),e.connect().catch((e=>{Yh(`[MetaMaskSDK: handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- error on autoconnect _err=${e}`)}))):console.warn("[handleAutoAndExtensionConnections()] checkInstallationImmediately --- IGNORED --- only for web desktop")),e._initialized=!0}))}(e,y);try{yield null===(u=e.remoteConnection)||void 0===u?void 0:u.startConnection({initialCheck:!0})}catch(e){console.error("[MetaMaskSDK: setupRemoteConnectionAndInstaller()] Error while checking installation",e)}e.emit(ff.ProviderUpdate,$f.INITIALIZED)}}))}class gp extends g{constructor(e={storage:{enabled:!0},injectProvider:!0,forceInjectProvider:!1,enableAnalytics:!0,shouldShimWeb3:!0,useDeeplink:!0,extensionOnly:!0,headless:!1,dappMetadata:{name:"",url:"",iconUrl:""},_source:wf,i18nOptions:{enabled:!1}}){var t,n,r;super(),this.extensionActive=!1,this._initialized=!1,this.sdkInitPromise=void 0,this.debug=!1,this.readonlyRPCCalls=!1,this.availableLanguages=["en"],f.disable();const i=!0===(null===(t=e.logging)||void 0===t?void 0:t.developerMode);if(((null===(n=e.logging)||void 0===n?void 0:n.sdk)||i)&&f.enable("MM_SDK"),Yh("[MetaMaskSDK: constructor()]: begin."),this.setMaxListeners(50),!(null===(r=e.dappMetadata)||void 0===r?void 0:r.url)){if("undefined"==typeof window||"undefined"==typeof document)throw new Error("You must provide dAppMetadata url");e.dappMetadata=Object.assign(Object.assign({},e.dappMetadata),{url:`${window.location.protocol}//${window.location.host}`})}this.options=e,this.options._source||(e._source=wf),this.init().then((()=>{Yh("[MetaMaskSDK: constructor()]: initialized successfully."),"undefined"!=typeof window&&(window.mmsdk=this)})).catch((e=>{console.error("[MetaMaskSDK: constructor()] error during initialization",e)}))}init(){return $e(this,void 0,void 0,(function*(){return function(e){var t;return $e(this,void 0,void 0,(function*(){if("undefined"!=typeof window&&(null===(t=window.mmsdk)||void 0===t?void 0:t.isInitialized()))return Yh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),Promise.resolve(window.mmsdk);if(e._initialized)return Yh("[MetaMaskSDK: initializeMetaMaskSDK()] already initialized"),e.sdkInitPromise;if(e.sdkInitPromise)return Yh("[MetaMaskSDK: initializeMetaMaskSDK()] already initializing"),e.sdkInitPromise;try{e.sdkInitPromise=pp(e),yield e.sdkInitPromise}catch(e){throw console.error(e),e}return e.sdkInitPromise}))}(this)}))}isExtensionActive(){return this.extensionActive}checkExtensionAvailability(){var e;return"undefined"!=typeof window&&Boolean(null===(e=window.ethereum)||void 0===e?void 0:e.isMetaMask)}connect(){return $e(this,void 0,void 0,(function*(){return function(e){return $e(this,void 0,void 0,(function*(){if(e._initialized||(Yh("[MetaMaskSDK: connect()] provider not ready -- wait for init()"),yield e.init()),Yh(`[MetaMaskSDK: connect()] isExtensionActive=${e.isExtensionActive()} activeProvider`,e.activeProvider),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const t=e.activeProvider.getSelectedAddress();return t?[t]:e.activeProvider.request({method:kf.ETH_REQUESTACCOUNTS,params:[]})}))}(this)}))}connectAndSign({msg:e}){return $e(this,void 0,void 0,(function*(){return function({instance:e,msg:t}){return $e(this,void 0,void 0,(function*(){if(e._initialized||(Yh("[MetaMaskSDK: connectAndSign()] provider not ready -- wait for init()"),yield e.init()),Yh(`[MetaMaskSDK: connectAndSign()] activeProvider=${e.activeProvider}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");const n=/^0x([0-9A-Fa-f]{2})*$/u.test(t)?t:function(e){let t;if(void 0!==et)t=et.from(e,"utf8").toString("hex");else if("undefined"!=typeof TextEncoder){const n=(new TextEncoder).encode(e);t=Array.from(n).map((e=>e.toString(16).padStart(2,"0"))).join("")}else{if("object"!=typeof je||!("Buffer"in je))throw new Error("Unable to convert string to hex: No available method.");t=je.Buffer.from(e,"utf8").toString("hex")}return`0x${t}`}(t);return e.activeProvider.request({method:kf.METAMASK_CONNECTWITH,params:[{method:kf.PERSONAL_SIGN,params:[n]}]})}))}({instance:this,msg:e})}))}connectWith(e){return $e(this,void 0,void 0,(function*(){return function({instance:e,rpc:t}){return $e(this,void 0,void 0,(function*(){if(e._initialized||(Yh("[MetaMaskSDK: connectWith()] provider not ready -- wait for init()"),yield e.init()),Yh(`[MetaMaskSDK: connectWith()] method: ${t.method} rpc=${t}`),!e.activeProvider)throw new Error("SDK state invalid -- undefined provider");return e.activeProvider.request({method:kf.METAMASK_CONNECTWITH,params:[t]})}))}({instance:this,rpc:e})}))}resume(){return function(e){var t,n,r;return $e(this,void 0,void 0,(function*(){if(!(null===(n=null===(t=e.remoteConnection)||void 0===t?void 0:t.getConnector())||void 0===n?void 0:n.isReady()))return Yh("[MetaMaskSDK: resume()] channel is not ready -- starting connection"),void(null===(r=e.remoteConnection)||void 0===r||r.startConnection());Yh("[MetaMaskSDK: resume()] channel is ready")}))}(this)}disconnect(){return console.warn("MetaMaskSDK.disconnect() is deprecated, use terminate()"),this.terminate()}isAuthorized(){var e;null===(e=this.remoteConnection)||void 0===e||e.isAuthorized()}terminate(){return function(e){var t,n,r;return $e(this,void 0,void 0,(function*(){if(!(null===(t=e.platformManager)||void 0===t?void 0:t.isMetaMaskMobileWebView())){if(jf&&(window.localStorage.removeItem(Tf),window.localStorage.removeItem(Rf),window.localStorage.removeItem(Of)),e.extensionActive){try{yield null===(n=e.activeProvider)||void 0===n?void 0:n.request({method:kf.WALLET_REVOKEPERMISSIONS,params:[{eth_accounts:{}}]})}catch(e){Yh("[MetaMaskSDK: terminate()] error revoking permissions",e)}return e.options.extensionOnly?(e.emit(ff.ProviderUpdate,$f.TERMINATE),void Yh("[MetaMaskSDK: terminate()] extensionOnly --- prevent switching providers")):(e.activeProvider=e.sdkProvider,window.ethereum=e.activeProvider,e.extensionActive=!1,void e.emit(ff.ProviderUpdate,$f.TERMINATE))}e.emit(ff.ProviderUpdate,$f.TERMINATE),Yh(`[MetaMaskSDK: terminate()] remoteConnection=${e.remoteConnection}`),null===(r=e.remoteConnection)||void 0===r||r.disconnect({terminate:!0,sendMessage:!0})}}))}(this)}isInitialized(){return this._initialized}setReadOnlyRPCCalls(e){this.readonlyRPCCalls=e}hasReadOnlyRPCCalls(){return this.readonlyRPCCalls}getProvider(){if(this.activeProvider)return this.activeProvider;console.warn("MetaMaskSDK: No active provider found")}getMobileProvider(){if(!this.sdkProvider)throw new Error("SDK state invalid -- undefined mobile provider");return this.sdkProvider}getUniversalLink(){var e;const t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getUniversalLink();if(!t)throw new Error("No Universal Link available, please call eth_requestAccounts first.");return t}getChannelId(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig())||void 0===t?void 0:t.channelId}getRPCHistory(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getRPCMethodTracker()}getVersion(){return bf.version}getWalletStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getConnectionStatus()}_getChannelConfig(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getChannelConfig()}_ping(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.ping()}_keyCheck(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.keyCheck()}_getServiceStatus(){var e,t;return null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t?void 0:t.getServiceStatus()}_getRemoteConnection(){return this.remoteConnection}_getDappMetadata(){return this.dappMetadata}_getKeyInfo(){var e;return null===(e=this.remoteConnection)||void 0===e?void 0:e.getKeyInfo()}_resetKeys(){var e,t;null===(t=null===(e=this.remoteConnection)||void 0===e?void 0:e.getConnector())||void 0===t||t.resetKeys()}_getConnection(){return this.remoteConnection}emit(e,t){return super.emit(e,t)}on(e,t){return super.on(e,t)}}var mp=Object.freeze({__proto__:null,StorageManagerWeb:class{constructor({enabled:e}={enabled:!1}){this.enabled=!1,this.enabled=e}persistChannelConfig(e){return $e(this,void 0,void 0,(function*(){const t=JSON.stringify(e);Yh(`[StorageManagerWeb: persistChannelConfig()] enabled=${this.enabled}`,e),localStorage.setItem(Lf,t)}))}getPersistedChannelConfig(){return $e(this,void 0,void 0,(function*(){let e;try{if(Yh(`[StorageManagerWeb: getPersistedChannelConfig()] enabled=${this.enabled}`),e=localStorage.getItem(Lf),Yh("[StorageManagerWeb: getPersistedChannelConfig()]",e),!e)return;const t=JSON.parse(e);return Yh("[StorageManagerWeb: getPersistedChannelConfig()] channelConfig",t),t}catch(e){return void console.error("[StorageManagerWeb: getPersistedChannelConfig()] Can't find existing channel config",e)}}))}persistAccounts(e){return $e(this,void 0,void 0,(function*(){Yh(`[StorageManagerWeb: persistAccounts()] enabled=${this.enabled}`,e);const t=JSON.stringify(e);localStorage.setItem(Of,t)}))}getCachedAccounts(){return $e(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Of);return e?JSON.parse(e):[]}catch(e){throw console.error("[StorageManagerWeb: getCachedAccounts()] Error reading cached accounts",e),e}}))}persistChainId(e){return $e(this,void 0,void 0,(function*(){Yh(`[StorageManagerWeb: persistChainId()] enabled=${this.enabled}`,e),localStorage.setItem(Rf,e)}))}getCachedChainId(){return $e(this,void 0,void 0,(function*(){try{const e=localStorage.getItem(Rf);return null!=e?e:void 0}catch(e){throw console.error("[StorageManagerWeb: getCachedChainId()] Error reading cached chainId",e),e}}))}terminate(){return $e(this,void 0,void 0,(function*(){Yh(`[StorageManagerWeb: terminate()] enabled=${this.enabled}`),localStorage.removeItem(Lf)}))}}});var yp=Object.defineProperty,vp=new WeakMap,bp=e=>vp.get(e),wp=(e,t)=>vp.set(t.$lazyInstance$=e,t),Ep=(e,t)=>t in e,Cp=(e,t)=>(0,console.error)(e,t),_p=new Map,Sp=new Map,kp="slot-fb{display:contents}slot-fb[hidden]{display:none}",xp="undefined"!=typeof window?window:{},Ap=xp.document||{head:{}},Mp={$flags$:0,$resourcesUrl$:"",jmp:e=>e(),raf:e=>requestAnimationFrame(e),ael:(e,t,n,r)=>e.addEventListener(t,n,r),rel:(e,t,n,r)=>e.removeEventListener(t,n,r),ce:(e,t)=>new CustomEvent(e,t)},Lp=(()=>{try{return new CSSStyleSheet,"function"==typeof(new CSSStyleSheet).replaceSync}catch(e){}return!1})(),Tp=!1,Op=[],Rp=[],Pp=e=>{for(let t=0;t<e.length;t++)try{e[t](performance.now())}catch(e){Cp(e)}e.length=0},Ip=()=>{Pp(Op),Pp(Rp),(Tp=Op.length>0)&&Mp.raf(Ip)},Np=e=>Promise.resolve(void 0).then(e),Bp=((e,t)=>t=>{e.push(t),Tp||(Tp=!0,4&Mp.$flags$?Np(Ip):Mp.raf(Ip))})(Rp),Dp={},$p=e=>"object"==(e=typeof e)||"function"===e;function jp(e){var t,n,r;return null!=(r=null==(n=null==(t=e.head)?void 0:t.querySelector('meta[name="csp-nonce"]'))?void 0:n.getAttribute("content"))?r:void 0}((e,t)=>{for(var n in t)yp(e,n,{get:t[n],enumerable:!0})})({},{err:()=>Up,map:()=>Fp,ok:()=>Kp,unwrap:()=>zp,unwrapErr:()=>qp});var Kp=e=>({isOk:!0,isErr:!1,value:e}),Up=e=>({isOk:!1,isErr:!0,value:e});function Fp(e,t){if(e.isOk){const n=t(e.value);return n instanceof Promise?n.then((e=>Kp(e))):Kp(n)}if(e.isErr){const t=e.value;return Up(t)}throw"should never get here"}var Hp,zp=e=>{if(e.isOk)return e.value;throw e.value},qp=e=>{if(e.isErr)return e.value;throw e.value},Vp=(e,t,...n)=>{let r=null,i=!1,o=!1;const s=[],a=t=>{for(let n=0;n<t.length;n++)r=t[n],Array.isArray(r)?a(r):null!=r&&"boolean"!=typeof r&&((i="function"!=typeof e&&!$p(r))&&(r=String(r)),i&&o?s[s.length-1].$text$+=r:s.push(i?Wp(null,r):r),o=i)};if(a(n),t){const e=t.className||t.class;e&&(t.class="object"!=typeof e?e:Object.keys(e).filter((t=>e[t])).join(" "))}if("function"==typeof e)return e(null===t?{}:t,s,Yp);const c=Wp(e,null);return c.$attrs$=t,s.length>0&&(c.$children$=s),c},Wp=(e,t)=>({$flags$:0,$tag$:e,$text$:t,$elm$:null,$children$:null,$attrs$:null}),Gp={},Yp={forEach:(e,t)=>e.map(Zp).forEach(t),map:(e,t)=>e.map(Zp).map(t).map(Jp)},Zp=e=>({vattrs:e.$attrs$,vchildren:e.$children$,vkey:e.$key$,vname:e.$name$,vtag:e.$tag$,vtext:e.$text$}),Jp=e=>{if("function"==typeof e.vtag){const t={...e.vattrs};return e.vkey&&(t.key=e.vkey),e.vname&&(t.name=e.vname),Vp(e.vtag,t,...e.vchildren||[])}const t=Wp(e.vtag,e.vtext);return t.$attrs$=e.vattrs,t.$children$=e.vchildren,t.$key$=e.vkey,t.$name$=e.vname,t},Xp=e=>bp(e).$hostElement$,Qp=(e,t,n)=>{const r=Xp(e);return{emit:e=>eg(r,t,{bubbles:!!(4&n),composed:!!(2&n),cancelable:!!(1&n),detail:e})}},eg=(e,t,n)=>{const r=Mp.ce(t,n);return e.dispatchEvent(r),r},tg=new WeakMap,ng=(e,t)=>"sc-"+e.$tagName$,rg=(e,t,n,r,i,o)=>{if(n!==r){let s=Ep(e,t),a=t.toLowerCase();if("class"===t){const t=e.classList,i=og(n),o=og(r);t.remove(...i.filter((e=>e&&!o.includes(e)))),t.add(...o.filter((e=>e&&!i.includes(e))))}else if("style"===t){for(const t in n)r&&null!=r[t]||(t.includes("-")?e.style.removeProperty(t):e.style[t]="");for(const t in r)n&&r[t]===n[t]||(t.includes("-")?e.style.setProperty(t,r[t]):e.style[t]=r[t])}else if(s||"o"!==t[0]||"n"!==t[1]){const a=$p(r);if((s||a&&null!==r)&&!i)try{if(e.tagName.includes("-"))e[t]=r;else{const i=null==r?"":r;"list"===t?s=!1:null!=n&&e[t]==i||("function"==typeof e.__lookupSetter__(t)?e[t]=i:e.setAttribute(t,i))}}catch(e){}null==r||!1===r?!1===r&&""!==e.getAttribute(t)||e.removeAttribute(t):(!s||4&o||i)&&!a&&(r=!0===r?"":r,e.setAttribute(t,r))}else if(t="-"===t[2]?t.slice(3):Ep(xp,a)?a.slice(2):a[2]+t.slice(3),n||r){const i=t.endsWith(sg);t=t.replace(ag,""),n&&Mp.rel(e,t,n,i),r&&Mp.ael(e,t,r,i)}}},ig=/\s/,og=e=>e?e.split(ig):[],sg="Capture",ag=new RegExp(sg+"$"),cg=(e,t,n)=>{const r=11===t.$elm$.nodeType&&t.$elm$.host?t.$elm$.host:t.$elm$,i=e&&e.$attrs$||Dp,o=t.$attrs$||Dp;for(const e of lg(Object.keys(i)))e in o||rg(r,e,i[e],void 0,n,t.$flags$);for(const e of lg(Object.keys(o)))rg(r,e,i[e],o[e],n,t.$flags$)};function lg(e){return e.includes("ref")?[...e.filter((e=>"ref"!==e)),"ref"]:e}var dg=!1,ug=(e,t,n,r)=>{const i=t.$children$[n];let o,s,a=0;if(null!==i.$text$)o=i.$elm$=Ap.createTextNode(i.$text$);else{if(dg||(dg="svg"===i.$tag$),o=i.$elm$=Ap.createElementNS(dg?"http://www.w3.org/2000/svg":"http://www.w3.org/1999/xhtml",i.$tag$),dg&&"foreignObject"===i.$tag$&&(dg=!1),cg(null,i,dg),o.getRootNode().querySelector("body"),i.$children$)for(a=0;a<i.$children$.length;++a)s=ug(e,i,a),s&&o.appendChild(s);"svg"===i.$tag$?dg=!1:"foreignObject"===o.tagName&&(dg=!0)}return o["s-hn"]=Hp,o},hg=(e,t,n,r,i,o)=>{let s,a=e;for(a.shadowRoot&&a.tagName===Hp&&(a=a.shadowRoot);i<=o;++i)r[i]&&(s=ug(null,n,i),s&&(r[i].$elm$=s,mg(a,s,t)))},fg=(e,t,n)=>{for(let r=t;r<=n;++r){const t=e[r];if(t){const e=t.$elm$;e&&e.remove()}}},pg=(e,t,n=!1)=>e.$tag$===t.$tag$,gg=(e,t,n=!1)=>{const r=t.$elm$=e.$elm$,i=e.$children$,o=t.$children$,s=t.$tag$,a=t.$text$;null===a?(cg(e,t,dg="svg"===s||"foreignObject"!==s&&dg),null!==i&&null!==o?((e,t,n,r,i=!1)=>{let o,s=0,a=0,c=t.length-1,l=t[0],d=t[c],u=r.length-1,h=r[0],f=r[u];for(;s<=c&&a<=u;)null==l?l=t[++s]:null==d?d=t[--c]:null==h?h=r[++a]:null==f?f=r[--u]:pg(l,h,i)?(gg(l,h,i),l=t[++s],h=r[++a]):pg(d,f,i)?(gg(d,f,i),d=t[--c],f=r[--u]):pg(l,f,i)?(gg(l,f,i),mg(e,l.$elm$,d.$elm$.nextSibling),l=t[++s],f=r[--u]):pg(d,h,i)?(gg(d,h,i),mg(e,d.$elm$,l.$elm$),d=t[--c],h=r[++a]):(o=ug(t&&t[a],n,a),h=r[++a],o&&mg(l.$elm$.parentNode,o,l.$elm$));s>c?hg(e,null==r[u+1]?null:r[u+1].$elm$,n,r,a,u):a>u&&fg(t,s,c)})(r,i,t,o,n):null!==o?(null!==e.$text$&&(r.textContent=""),hg(r,null,t,o,0,o.length-1)):!n&&null!==i&&fg(i,0,i.length-1),dg&&"svg"===s&&(dg=!1)):e.$text$!==a&&(r.data=a)},mg=(e,t,n)=>null==e?void 0:e.insertBefore(t,n),yg=(e,t)=>{t&&!e.$onRenderResolve$&&t["s-p"]&&t["s-p"].push(new Promise((t=>e.$onRenderResolve$=t)))},vg=(e,t)=>{if(e.$flags$|=16,!(4&e.$flags$))return yg(e,e.$ancestorComponent$),Bp((()=>bg(e,t)));e.$flags$|=512},bg=(e,t)=>{const n=e.$hostElement$;e.$cmpMeta$.$tagName$;const r=e.$lazyInstance$;if(!r)throw new Error(`Can't render component <${n.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`);return wg(void 0,(()=>Cg(e,r,t)))},wg=(e,t)=>Eg(e)?e.then(t).catch((e=>{console.error(e),t()})):t(),Eg=e=>e instanceof Promise||e&&e.then&&"function"==typeof e.then,Cg=async(e,t,n)=>{var r;const i=e.$hostElement$;e.$cmpMeta$.$tagName$;const o=i["s-rc"];n&&(e=>{const t=e.$cmpMeta$,n=e.$hostElement$,r=t.$flags$;t.$tagName$;const i=((e,t,n)=>{var r;const i=ng(t),o=Sp.get(i);if(e=11===e.nodeType?e:Ap,o)if("string"==typeof o){e=e.head||e;let n,s=tg.get(e);if(s||tg.set(e,s=new Set),!s.has(i)){{n=Ap.createElement("style"),n.innerHTML=o;const i=null!=(r=Mp.$nonce$)?r:jp(Ap);if(null!=i&&n.setAttribute("nonce",i),!(1&t.$flags$))if("HEAD"===e.nodeName){const t=e.querySelectorAll("link[rel=preconnect]"),r=t.length>0?t[t.length-1].nextSibling:e.querySelector("style");e.insertBefore(n,r)}else if("host"in e)if(Lp){const t=new CSSStyleSheet;t.replaceSync(o),e.adoptedStyleSheets=[t,...e.adoptedStyleSheets]}else{const t=e.querySelector("style");t?t.innerHTML=o+t.innerHTML:e.prepend(n)}else e.append(n);1&t.$flags$&&"HEAD"!==e.nodeName&&e.insertBefore(n,null)}4&t.$flags$&&(n.innerHTML+=kp),s&&s.add(i)}}else e.adoptedStyleSheets.includes(o)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,o]);return i})(n.shadowRoot?n.shadowRoot:n.getRootNode(),t);10&r&&2&r&&(n["s-sc"]=i,n.classList.add(i+"-h"))})(e),e.$cmpMeta$.$tagName$,_g(e,t,i,n),o&&(o.map((e=>e())),i["s-rc"]=void 0);{const t=null!=(r=i["s-p"])?r:[],n=()=>Sg(e);0===t.length?n():(Promise.all(t).then(n),e.$flags$|=4,t.length=0)}},_g=(e,t,n,r)=>{try{t=t.render(),e.$flags$&=-17,e.$flags$|=2,((e,t,n=!1)=>{const r=e.$hostElement$,i=e.$cmpMeta$,o=e.$vnode$||Wp(null,null),s=(a=t)&&a.$tag$===Gp?t:Vp(null,null,t);var a;if(Hp=r.tagName,n&&s.$attrs$)for(const e of Object.keys(s.$attrs$))r.hasAttribute(e)&&!["key","ref","style","class"].includes(e)&&(s.$attrs$[e]=r[e]);s.$tag$=null,s.$flags$|=4,e.$vnode$=s,s.$elm$=o.$elm$=r.shadowRoot||r,r["s-sc"],0!=(1&i.$flags$),gg(o,s,n)})(e,t,r)}catch(t){Cp(t,e.$hostElement$)}return null},Sg=e=>{e.$cmpMeta$.$tagName$;const t=e.$hostElement$,n=e.$lazyInstance$,r=e.$ancestorComponent$;64&e.$flags$||(e.$flags$|=64,Ag(t),xg(n,"componentDidLoad"),e.$onReadyResolve$(t),r||kg()),e.$onRenderResolve$&&(e.$onRenderResolve$(),e.$onRenderResolve$=void 0),512&e.$flags$&&Np((()=>vg(e,!1))),e.$flags$&=-517},kg=e=>{Ag(Ap.documentElement),Np((()=>eg(xp,"appload",{detail:{namespace:"sdk-install-modal-web"}})))},xg=(e,t,n)=>{if(e&&e[t])try{return e[t](n)}catch(e){Cp(e)}},Ag=e=>e.classList.add(("hydrated","hydrated")),Mg=(e,t,n)=>{var r,i;const o=e.prototype;if(t.$members$||t.$watchers$||e.watchers){e.watchers&&!t.$watchers$&&(t.$watchers$=e.watchers);const s=Object.entries(null!=(r=t.$members$)?r:{});if(s.map((([e,[r]])=>{(31&r||2&n&&32&r)&&Object.defineProperty(o,e,{get(){return t=e,bp(this).$instanceValues$.get(t);var t},set(n){((e,t,n,r)=>{const i=bp(e);if(!i)throw new Error(`Couldn't find host element for "${r.$tagName$}" as it is unknown to this Stencil runtime. This usually happens when integrating a 3rd party Stencil component with another Stencil component or application. Please reach out to the maintainers of the 3rd party Stencil component or report this on the Stencil Discord server (https://chat.stenciljs.com) or comment on this similar [GitHub issue](https://github.com/ionic-team/stencil/issues/5457).`);const o=i.$hostElement$,s=i.$instanceValues$.get(t),a=i.$flags$,c=i.$lazyInstance$;var l,d;l=n,d=r.$members$[t][0],n=null==l||$p(l)?l:4&d?"false"!==l&&(""===l||!!l):1&d?String(l):l;const u=Number.isNaN(s)&&Number.isNaN(n);if((!(8&a)||void 0===s)&&n!==s&&!u&&(i.$instanceValues$.set(t,n),c)){if(r.$watchers$&&128&a){const e=r.$watchers$[t];e&&e.map((e=>{try{c[e](n,s,t)}catch(e){Cp(e,o)}}))}2==(18&a)&&vg(i,!1)}})(this,e,n,t)},configurable:!0,enumerable:!0})})),1&n){const n=new Map;o.attributeChangedCallback=function(e,r,i){Mp.jmp((()=>{var s;const a=n.get(e);if(this.hasOwnProperty(a))i=this[a],delete this[a];else{if(o.hasOwnProperty(a)&&"number"==typeof this[a]&&this[a]==i)return;if(null==a){const n=bp(this),o=null==n?void 0:n.$flags$;if(o&&!(8&o)&&128&o&&i!==r){const o=n.$lazyInstance$,a=null==(s=t.$watchers$)?void 0:s[e];null==a||a.forEach((t=>{null!=o[t]&&o[t].call(o,i,r,e)}))}return}}this[a]=(null!==i||"boolean"!=typeof this[a])&&i}))},e.observedAttributes=Array.from(new Set([...Object.keys(null!=(i=t.$watchers$)?i:{}),...s.filter((([e,t])=>15&t[0])).map((([e,t])=>{const r=t[1]||e;return n.set(r,e),r}))]))}}return e},Lg=e=>{xg(e,"connectedCallback")},Tg=e=>{xg(e,"disconnectedCallback")},Og=(e,t={})=>{var n;const r=[],i=t.exclude||[],o=xp.customElements,s=Ap.head,a=s.querySelector("meta[charset]"),c=Ap.createElement("style"),l=[];let d,u=!0;Object.assign(Mp,t),Mp.$resourcesUrl$=new URL(t.resourcesUrl||"./",Ap.baseURI).href;let h=!1;if(e.map((e=>{e[1].map((t=>{var n;const s={$flags$:t[0],$tagName$:t[1],$members$:t[2],$listeners$:t[3]};4&s.$flags$&&(h=!0),s.$members$=t[2],s.$watchers$=null!=(n=t[4])?n:{};const a=s.$tagName$,c=class extends HTMLElement{constructor(e){if(super(e),this.hasRegisteredEventListeners=!1,((e,t)=>{const n={$flags$:0,$hostElement$:e,$cmpMeta$:t,$instanceValues$:new Map};n.$onReadyPromise$=new Promise((e=>n.$onReadyResolve$=e)),e["s-p"]=[],e["s-rc"]=[],vp.set(e,n)})(e=this,s),1&s.$flags$)if(e.shadowRoot){if("open"!==e.shadowRoot.mode)throw new Error(`Unable to re-use existing shadow root for ${s.$tagName$}! Mode is set to ${e.shadowRoot.mode} but Stencil only supports open shadow roots.`)}else e.attachShadow({mode:"open"})}connectedCallback(){bp(this),this.hasRegisteredEventListeners||(this.hasRegisteredEventListeners=!0),d&&(clearTimeout(d),d=null),u?l.push(this):Mp.jmp((()=>(e=>{if(0==(1&Mp.$flags$)){const t=bp(e),n=t.$cmpMeta$;if(n.$tagName$,1&t.$flags$)(null==t?void 0:t.$lazyInstance$)?Lg(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Lg(t.$lazyInstance$)));else{t.$flags$|=1;{let n=e;for(;n=n.parentNode||n.host;)if(n["s-p"]){yg(t,t.$ancestorComponent$=n);break}}n.$members$&&Object.entries(n.$members$).map((([t,[n]])=>{if(31&n&&e.hasOwnProperty(t)){const n=e[t];delete e[t],e[t]=n}})),(async(e,t,n,r)=>{let i;if(0==(32&t.$flags$)){if(t.$flags$|=32,n.$lazyBundleId$){const r=((e,t,n)=>{const r=e.$tagName$.replace(/-/g,"_"),i=e.$lazyBundleId$;if(!i)return;const o=_p.get(i);if(o)return o[r];{const e=e=>(_p.set(i,e),e[r]);if("mm-install-modal_3"===i)return Promise.resolve().then((function(){return mm})).then(e,Cp)}return import(`./${i}.entry.js`).then((e=>(_p.set(i,e),e[r])),Cp)})(n);if(i=r&&"then"in r?await r:r,!i)throw new Error(`Constructor for "${n.$tagName$}#${t.$modeName$}" was not found`);i.isProxied||(n.$watchers$=i.watchers,Mg(i,n,2),i.isProxied=!0),n.$tagName$,t.$flags$|=8;try{new i(t)}catch(e){Cp(e)}t.$flags$&=-9,t.$flags$|=128,Lg(t.$lazyInstance$)}else{i=e.constructor;const n=e.localName;customElements.whenDefined(n).then((()=>t.$flags$|=128))}if(i&&i.style){let e;"string"==typeof i.style&&(e=i.style);const t=ng(n);Sp.has(t)||(n.$tagName$,((e,t,n)=>{let r=Sp.get(e);Lp&&n?(r=r||new CSSStyleSheet,"string"==typeof r?r=t:r.replaceSync(t)):r=t,Sp.set(e,r)})(t,e,!!(1&n.$flags$)))}}const o=t.$ancestorComponent$,s=()=>vg(t,!0);o&&o["s-rc"]?o["s-rc"].push(s):s()})(e,t,n)}}})(this)))}disconnectedCallback(){Mp.jmp((()=>(async e=>{if(0==(1&Mp.$flags$)){const t=bp(e);(null==t?void 0:t.$lazyInstance$)?Tg(t.$lazyInstance$):(null==t?void 0:t.$onReadyPromise$)&&t.$onReadyPromise$.then((()=>Tg(t.$lazyInstance$)))}})(this)))}componentOnReady(){return bp(this).$onReadyPromise$}};s.$lazyBundleId$=e[0],i.includes(a)||o.get(a)||(r.push(a),o.define(a,Mg(c,s,1)))}))})),r.length>0&&(h&&(c.textContent+=kp),c.textContent+=r.sort()+"{visibility:hidden}.hydrated{visibility:inherit}",c.innerHTML.length)){c.setAttribute("data-styles","");const e=null!=(n=Mp.$nonce$)?n:jp(Ap);null!=e&&c.setAttribute("nonce",e),s.insertBefore(c,a?a.nextSibling:s.firstChild)}u=!1,l.length?l.map((e=>e.connectedCallback())):Mp.jmp((()=>d=setTimeout(kg,30)))};!function(){if("undefined"!=typeof window&&void 0!==window.Reflect&&void 0!==window.customElements){var e=HTMLElement;window.HTMLElement=function(){return Reflect.construct(e,[],this.constructor)},HTMLElement.prototype=e.prototype,HTMLElement.prototype.constructor=HTMLElement,Object.setPrototypeOf(HTMLElement,e)}}();var Rg=Object.freeze({__proto__:null,defineCustomElements:async(e,t)=>{if("undefined"!=typeof window)return await void 0,Og([["mm-install-modal_3",[[1,"mm-install-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}],[1,"mm-pending-modal",{displayOTP:[4,"display-o-t-p"],sdkVersion:[1,"sdk-version"],otpCode:[1,"otp-code"],translationsLoaded:[32]}],[1,"mm-select-modal",{link:[1],sdkVersion:[1,"sdk-version"],preferDesktop:[4,"prefer-desktop"],tab:[32],isDefaultTab:[32],translationsLoaded:[32]},null,{preferDesktop:["updatePreferDesktop"]}]]]],t)},setNonce:e=>Mp.$nonce$=e});const Pg={fontFamily:"Roboto, sans-serif"},Ig=({className:e},t)=>Vp("div",{style:Pg,class:e},t),Ng=({Icon:e,text:t})=>Vp("div",{class:"flexContainer",style:{padding:"6",flexDirection:"row"}},Vp("div",{class:"flexItem1"},Vp(e,null)),Vp("div",{class:"flexItem11"},Vp("span",{style:{lineHeight:"2",color:"black"}},t))),Bg=()=>Vp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M20.0002 7.9702V10.0302C20.0002 10.5802 19.5602 11.0302 19.0002 11.0502H17.0402C15.9602 11.0502 14.9702 10.2602 14.8802 9.1802C14.8202 8.5502 15.0602 7.9602 15.4802 7.5502C15.8502 7.1702 16.3602 6.9502 16.9202 6.9502H19.0002C19.5602 6.9702 20.0002 7.4202 20.0002 7.9702Z",fill:"#037DD6"}),Vp("path",{d:"M18.47 12.55H17.04C15.14 12.55 13.54 11.12 13.38 9.3C13.29 8.26 13.67 7.22 14.43 6.48C15.07 5.82 15.96 5.45 16.92 5.45H18.47C18.76 5.45 19 5.21 18.97 4.92C18.75 2.49 17.14 0.83 14.75 0.55C14.51 0.51 14.26 0.5 14 0.5H5C4.72 0.5 4.45 0.52 4.19 0.56C1.64 0.88 0 2.78 0 5.5V12.5C0 15.26 2.24 17.5 5 17.5H14C16.8 17.5 18.73 15.75 18.97 13.08C19 12.79 18.76 12.55 18.47 12.55ZM11 6.75H5C4.59 6.75 4.25 6.41 4.25 6C4.25 5.59 4.59 5.25 5 5.25H11C11.41 5.25 11.75 5.59 11.75 6C11.75 6.41 11.41 6.75 11 6.75Z",fill:"#037DD6"})),Dg=()=>Vp("svg",{width:"20",height:"18",viewBox:"0 0 20 18",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M14.44 0.0999756C12.63 0.0999756 11.01 0.979976 10 2.32998C8.99 0.979976 7.37 0.0999756 5.56 0.0999756C2.49 0.0999756 0 2.59998 0 5.68998C0 6.87998 0.19 7.97998 0.52 8.99998C2.1 14 6.97 16.99 9.38 17.81C9.72 17.93 10.28 17.93 10.62 17.81C13.03 16.99 17.9 14 19.48 8.99998C19.81 7.97998 20 6.87998 20 5.68998C20 2.59998 17.51 0.0999756 14.44 0.0999756Z",fill:"#037DD6"})),$g=()=>Vp("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M16.28 7.53V6.28C16.28 3.58 15.63 0 10 0C4.37 0 3.72 3.58 3.72 6.28V7.53C0.92 7.88 0 9.3 0 12.79V14.65C0 18.75 1.25 20 5.35 20H14.65C18.75 20 20 18.75 20 14.65V12.79C20 9.3 19.08 7.88 16.28 7.53ZM10 16.74C8.33 16.74 6.98 15.38 6.98 13.72C6.98 12.05 8.34 10.7 10 10.7C11.66 10.7 13.02 12.06 13.02 13.72C13.02 15.39 11.67 16.74 10 16.74ZM5.35 7.44C5.27 7.44 5.2 7.44 5.12 7.44V6.28C5.12 3.35 5.95 1.4 10 1.4C14.05 1.4 14.88 3.35 14.88 6.28V7.45C14.8 7.45 14.73 7.45 14.65 7.45H5.35V7.44Z",fill:"#037DD6"})),jg=()=>Vp("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M16.4405 8.8999C20.0405 9.2099 21.5105 11.0599 21.5105 15.1099V15.2399C21.5105 19.7099 19.7205 21.4999 15.2505 21.4999H8.74047C4.27047 21.4999 2.48047 19.7099 2.48047 15.2399V15.1099C2.48047 11.0899 3.93047 9.2399 7.47047 8.9099",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M12 2V14.88",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M15.3504 12.6499L12.0004 15.9999L8.65039 12.6499",stroke:"white","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}));function Kg({version:e}){return Vp("div",{style:{textAlign:"center",color:"#BBC0C5",fontSize:"12"}},"SDK Version ",e?`v${e}`:"unknown")}const Ug=()=>Vp("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("rect",{width:"16",height:"16",fill:"white"}),Vp("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M2.40554 2.40554C2.94627 1.86482 3.82296 1.86482 4.36369 2.40554L8 6.04186L11.6363 2.40554C12.177 1.86482 13.0537 1.86482 13.5945 2.40554C14.1352 2.94627 14.1352 3.82296 13.5945 4.36369L9.95814 8L13.5945 11.6363C14.1352 12.177 14.1352 13.0537 13.5945 13.5945C13.0537 14.1352 12.177 14.1352 11.6363 13.5945L8 9.95814L4.36369 13.5945C3.82296 14.1352 2.94627 14.1352 2.40554 13.5945C1.86482 13.0537 1.86482 12.177 2.40554 11.6363L6.04186 8L2.40554 4.36369C1.86482 3.82296 1.86482 2.94627 2.40554 2.40554Z",fill:"#BBC0C5"})),Fg=()=>Vp("svg",{width:"273",height:"51",viewBox:"0 0 273 51",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M240.882 25.9263C239.472 24.997 237.916 24.3361 236.443 23.5101C235.489 22.9731 234.473 22.4982 233.643 21.8167C232.233 20.6602 232.524 18.3885 233.996 17.3973C236.112 15.993 239.617 16.7777 239.99 19.6483C239.99 19.7102 240.052 19.7515 240.114 19.7515H243.308C243.391 19.7515 243.454 19.6896 243.433 19.607C243.267 17.6244 242.5 15.9723 241.089 14.9191C239.741 13.9072 238.206 13.3702 236.568 13.3702C228.127 13.3702 227.359 22.271 231.901 25.0796C232.42 25.41 236.879 27.6404 238.455 28.611C240.032 29.5816 240.529 31.3576 239.845 32.7619C239.223 34.0423 237.605 34.9303 235.987 34.8271C234.224 34.7238 232.855 33.7738 232.378 32.2869C232.295 32.0185 232.254 31.5022 232.254 31.275C232.254 31.2131 232.192 31.1511 232.129 31.1511H228.666C228.604 31.1511 228.541 31.2131 228.541 31.275C228.541 33.7738 229.164 35.1575 230.864 36.4172C232.461 37.615 234.203 38.1106 236.008 38.1106C240.737 38.1106 243.184 35.4466 243.682 32.6793C244.117 29.974 243.308 27.5371 240.882 25.9263Z",fill:"#24292E"}),Vp("path",{d:"M90.4943 13.8246H88.9595H87.2795C87.2173 13.8246 87.1758 13.8659 87.1551 13.9072L84.3137 23.2416C84.2722 23.3655 84.1063 23.3655 84.0648 23.2416L81.2234 13.9072C81.2026 13.8452 81.1612 13.8246 81.0989 13.8246H79.419H77.8842H75.8102C75.748 13.8246 75.6857 13.8865 75.6857 13.9485V37.7802C75.6857 37.8422 75.748 37.9041 75.8102 37.9041H79.2738C79.336 37.9041 79.3982 37.8422 79.3982 37.7802V19.6689C79.3982 19.5244 79.6056 19.5037 79.6471 19.6276L82.5093 29.024L82.7167 29.6849C82.7374 29.7468 82.7789 29.7675 82.8411 29.7675H85.4959C85.5581 29.7675 85.5996 29.7262 85.6203 29.6849L85.8277 29.024L88.6899 19.6276C88.7313 19.4831 88.9387 19.5244 88.9387 19.6689V37.7802C88.9387 37.8422 89.001 37.9041 89.0632 37.9041H92.5268C92.589 37.9041 92.6513 37.8422 92.6513 37.7802V13.9485C92.6513 13.8865 92.589 13.8246 92.5268 13.8246H90.4943Z",fill:"#24292E"}),Vp("path",{d:"M187.849 13.8246C187.787 13.8246 187.745 13.8659 187.725 13.9072L184.883 23.2416C184.842 23.3655 184.676 23.3655 184.634 23.2416L181.793 13.9072C181.772 13.8452 181.731 13.8246 181.668 13.8246H176.4C176.338 13.8246 176.276 13.8865 176.276 13.9485V37.7802C176.276 37.8422 176.338 37.9041 176.4 37.9041H179.864C179.926 37.9041 179.988 37.8422 179.988 37.7802V19.6689C179.988 19.5244 180.196 19.5037 180.237 19.6276L183.099 29.024L183.307 29.6849C183.328 29.7468 183.369 29.7675 183.431 29.7675H186.086C186.148 29.7675 186.19 29.7262 186.211 29.6849L186.418 29.024L189.28 19.6276C189.322 19.4831 189.529 19.5244 189.529 19.6689V37.7802C189.529 37.8422 189.591 37.9041 189.653 37.9041H193.117C193.179 37.9041 193.241 37.8422 193.241 37.7802V13.9485C193.241 13.8865 193.179 13.8246 193.117 13.8246H187.849Z",fill:"#24292E"}),Vp("path",{d:"M143.174 13.8246H136.724H133.261H126.81C126.748 13.8246 126.686 13.8865 126.686 13.9485V16.9223C126.686 16.9843 126.748 17.0462 126.81 17.0462H133.136V37.7802C133.136 37.8422 133.198 37.9041 133.261 37.9041H136.724C136.786 37.9041 136.849 37.8422 136.849 37.7802V17.0462H143.174C143.237 17.0462 143.299 16.9843 143.299 16.9223V13.9485C143.299 13.8865 143.257 13.8246 143.174 13.8246Z",fill:"#24292E"}),Vp("path",{d:"M163.604 37.9041H166.756C166.839 37.9041 166.901 37.8215 166.881 37.7389L160.368 13.8245C160.347 13.7626 160.306 13.7419 160.244 13.7419H159.041H156.925H155.722C155.66 13.7419 155.619 13.7832 155.598 13.8245L149.085 37.7389C149.065 37.8215 149.127 37.9041 149.21 37.9041H152.362C152.425 37.9041 152.466 37.8628 152.487 37.8215L154.374 30.862C154.395 30.8 154.436 30.7794 154.499 30.7794H161.467C161.53 30.7794 161.571 30.8207 161.592 30.862L163.479 37.8215C163.5 37.8628 163.562 37.9041 163.604 37.9041ZM155.328 27.3719L157.859 18.0581C157.9 17.9342 158.066 17.9342 158.107 18.0581L160.638 27.3719C160.659 27.4545 160.596 27.5371 160.513 27.5371H155.453C155.37 27.5371 155.308 27.4545 155.328 27.3719Z",fill:"#24292E"}),Vp("path",{d:"M217.362 37.9041H220.515C220.598 37.9041 220.66 37.8215 220.639 37.7389L214.127 13.8245C214.106 13.7626 214.065 13.7419 214.002 13.7419H212.8H210.684H209.481C209.419 13.7419 209.377 13.7832 209.357 13.8245L202.844 37.7389C202.823 37.8215 202.886 37.9041 202.969 37.9041H206.121C206.183 37.9041 206.225 37.8628 206.246 37.8215L208.133 30.862C208.154 30.8 208.195 30.7794 208.257 30.7794H215.226C215.288 30.7794 215.33 30.8207 215.351 30.862L217.238 37.8215C217.259 37.8628 217.3 37.9041 217.362 37.9041ZM209.087 27.3719L211.617 18.0581C211.659 17.9342 211.825 17.9342 211.866 18.0581L214.397 27.3719C214.417 27.4545 214.355 27.5371 214.272 27.5371H209.211C209.129 27.5371 209.066 27.4545 209.087 27.3719Z",fill:"#24292E"}),Vp("path",{d:"M106.713 34.3727V26.9795C106.713 26.9176 106.775 26.8556 106.837 26.8556H116.067C116.129 26.8556 116.191 26.7936 116.191 26.7317V23.7579C116.191 23.6959 116.129 23.634 116.067 23.634H106.837C106.775 23.634 106.713 23.572 106.713 23.5101V17.1907C106.713 17.1288 106.775 17.0668 106.837 17.0668H117.332C117.394 17.0668 117.457 17.0049 117.457 16.9429V13.9691C117.457 13.9072 117.394 13.8452 117.332 13.8452H106.713H103.125C103.063 13.8452 103.001 13.9072 103.001 13.9691V17.0668V23.6546V26.8763V34.5173V37.7802C103.001 37.8422 103.063 37.9041 103.125 37.9041H106.713H117.768C117.83 37.9041 117.892 37.8422 117.892 37.7802V34.6412C117.892 34.5792 117.83 34.5173 117.768 34.5173H106.817C106.755 34.4966 106.713 34.4553 106.713 34.3727Z",fill:"#24292E"}),Vp("path",{d:"M272.532 37.6976L260.544 25.3687C260.502 25.3274 260.502 25.2448 260.544 25.2035L271.329 14.0517C271.412 13.9691 271.349 13.8452 271.246 13.8452H266.828C266.787 13.8452 266.766 13.8659 266.745 13.8865L257.599 23.3449C257.516 23.4275 257.391 23.3655 257.391 23.2623V13.9691C257.391 13.9072 257.329 13.8452 257.267 13.8452H253.803C253.741 13.8452 253.679 13.9072 253.679 13.9691V37.8009C253.679 37.8628 253.741 37.9248 253.803 37.9248H257.267C257.329 37.9248 257.391 37.8628 257.391 37.8009V27.3099C257.391 27.2067 257.536 27.1447 257.599 27.2273L267.969 37.8835C267.989 37.9041 268.031 37.9248 268.052 37.9248H272.469C272.552 37.9041 272.615 37.7596 272.532 37.6976Z",fill:"#24292E"}),Vp("path",{d:"M52.021 1L31.0526 16.4886L34.9517 7.36063L52.021 1Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M3.65491 1L24.4366 16.6331L20.7241 7.36063L3.65491 1Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M44.4716 36.9127L38.8925 45.4211L50.8389 48.7047L54.261 37.0986L44.4716 36.9127Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M1.43555 37.0986L4.83695 48.7047L16.7626 45.4211L11.2042 36.9127L1.43555 37.0986Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.1197 22.5395L12.8013 27.5371L24.6232 28.074L24.2292 15.3734L16.1197 22.5395Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M39.5561 22.5394L31.3222 15.2288L31.0526 28.0739L42.8746 27.537L39.5561 22.5394Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.7626 45.4212L23.918 41.9724L17.7582 37.1813L16.7626 45.4212Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.7578 41.9724L38.8925 45.4212L37.9177 37.1813L31.7578 41.9724Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M38.8923 45.4212L31.7577 41.9724L32.3384 46.5983L32.2762 48.5602L38.8923 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.7625 45.4212L23.3994 48.5602L23.3579 46.5983L23.9179 41.9724L16.7625 45.4212Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M23.5239 34.1249L17.5922 32.3902L21.7818 30.4696L23.5239 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M32.1517 34.1249L33.8939 30.4696L38.1042 32.3902L32.1517 34.1249Z",fill:"#233447",stroke:"#233447","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.7626 45.4212L17.7996 36.9128L11.2042 37.0987L16.7626 45.4212Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M37.8761 36.9128L38.8924 45.4212L44.4715 37.0987L37.8761 36.9128Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M42.8745 27.5371L31.0526 28.074L32.1518 34.1249L33.894 30.4696L38.1042 32.3902L42.8745 27.5371Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M17.5922 32.3902L21.7817 30.4696L23.5239 34.1249L24.6232 28.074L12.8012 27.5371L17.5922 32.3902Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M12.8013 27.5371L17.7582 37.1813L17.5923 32.3902L12.8013 27.5371Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M38.1044 32.3902L37.9177 37.1813L42.8746 27.5371L38.1044 32.3902Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M24.6232 28.0741L23.524 34.125L24.9136 41.2703L25.2247 31.8533L24.6232 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.0526 28.0741L30.4719 31.8327L30.7623 41.2703L32.1519 34.125L31.0526 28.0741Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M32.1519 34.1249L30.7623 41.2702L31.7578 41.9724L37.9177 37.1813L38.1043 32.3901L32.1519 34.1249Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M17.5922 32.3901L17.7581 37.1813L23.918 41.9724L24.9135 41.2702L23.5239 34.1249L17.5922 32.3901Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M32.2763 48.5602L32.3385 46.5983L31.7993 46.1439H23.8765L23.358 46.5983L23.3995 48.5602L16.7626 45.4211L19.0855 47.3211L23.7935 50.5633H31.8615L36.5903 47.3211L38.8924 45.4211L32.2763 48.5602Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.7578 41.9724L30.7622 41.2703H24.9135L23.918 41.9724L23.358 46.5983L23.8765 46.144H31.7993L32.3385 46.5983L31.7578 41.9724Z",fill:"#24292E",stroke:"#24292E","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M52.9128 17.5005L54.6757 8.95079L52.021 1L31.7578 15.9723L39.5561 22.5394L50.5692 25.7404L52.9958 22.9111L51.938 22.147L53.618 20.6188L52.3321 19.6276L54.0121 18.3472L52.9128 17.5005Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M1 8.95079L2.78366 17.5005L1.64295 18.3472L3.34365 19.6276L2.05775 20.6188L3.73771 22.147L2.67996 22.9111L5.10657 25.7404L16.1196 22.5394L23.918 15.9723L3.65475 1L1 8.95079Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M50.5692 25.7404L39.5561 22.5394L42.8746 27.5371L37.9177 37.1813L44.4716 37.0987H54.261L50.5692 25.7404Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M16.1196 22.5394L5.10651 25.7404L1.43549 37.0987H11.2041L17.7581 37.1813L12.8011 27.5371L16.1196 22.5394Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M31.0526 28.0741L31.7578 15.9724L34.9518 7.36072H20.7239L23.9179 15.9724L24.6231 28.0741L24.8927 31.8739L24.9135 41.2703H30.7622L30.783 31.8739L31.0526 28.0741Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.5","stroke-linecap":"round","stroke-linejoin":"round"}));function Hg(e,t){return e.toString(2).padStart(t,"0")}function zg(e,t){const n=e%t;return n>=0?n:t+n}function qg(e,t){return new Array(e).fill(t)}function Vg(...e){let t=0;for(const n of e)t=Math.max(t,n.length);const n=[];for(let r=0;r<t;r++)for(const t of e)r>=t.length||n.push(t[r]);return new Uint8Array(n)}function Wg(e,t,n){if(n<0||n+t.length>e.length)return!1;for(let r=0;r<t.length;r++)if(t[r]!==e[n+r])return!1;return!0}function Gg(e){return{has:t=>e.includes(t),decode:t=>{if(!Array.isArray(t)||t.length&&"string"!=typeof t[0])throw new Error("alphabet.decode input should be array of strings");return t.map((t=>{if("string"!=typeof t)throw new Error(`alphabet.decode: not string element=${t}`);const n=e.indexOf(t);if(-1===n)throw new Error(`Unknown letter: "${t}". Allowed: ${e}`);return n}))},encode:t=>{if(!Array.isArray(t)||t.length&&"number"!=typeof t[0])throw new Error("alphabet.encode input should be an array of numbers");return t.map((t=>{if(function(e){if(!Number.isSafeInteger(e))throw new Error(`Wrong integer: ${e}`)}(t),t<0||t>=e.length)throw new Error(`Digit index outside alphabet: ${t} (alphabet: ${e.length})`);return e[t]}))}}}class Yg{static size(e,t){if("number"==typeof e&&(e={height:e,width:e}),!Number.isSafeInteger(e.height)&&e.height!==1/0)throw new Error(`Bitmap: wrong height=${e.height} (${typeof e.height})`);if(!Number.isSafeInteger(e.width)&&e.width!==1/0)throw new Error(`Bitmap: wrong width=${e.width} (${typeof e.width})`);return void 0!==t&&(e={width:Math.min(e.width,t.width),height:Math.min(e.height,t.height)}),e}static fromString(e){const t=(e=e.replace(/^\n+/g,"").replace(/\n+$/g,"")).split("\n"),n=t.length,r=new Array(n);let i;for(const e of t){const t=e.split("").map((e=>{if("X"===e)return!0;if(" "===e)return!1;if("?"!==e)throw new Error(`Bitmap.fromString: unknown symbol=${e}`)}));if(i&&t.length!==i)throw new Error(`Bitmap.fromString different row sizes: width=${i} cur=${t.length}`);i=t.length,r.push(t)}return i||(i=0),new Yg({height:n,width:i},r)}constructor(e,t){const{height:n,width:r}=Yg.size(e);this.data=t||Array.from({length:n},(()=>qg(r,void 0))),this.height=n,this.width=r}point(e){return this.data[e.y][e.x]}isInside(e){return 0<=e.x&&e.x<this.width&&0<=e.y&&e.y<this.height}size(e){if(!e)return{height:this.height,width:this.width};const{x:t,y:n}=this.xy(e);return{height:this.height-n,width:this.width-t}}xy(e){if("number"==typeof e&&(e={x:e,y:e}),!Number.isSafeInteger(e.x))throw new Error(`Bitmap: wrong x=${e.x}`);if(!Number.isSafeInteger(e.y))throw new Error(`Bitmap: wrong y=${e.y}`);return e.x=zg(e.x,this.width),e.y=zg(e.y,this.height),e}rect(e,t,n){const{x:r,y:i}=this.xy(e),{height:o,width:s}=Yg.size(t,this.size({x:r,y:i}));for(let e=0;e<o;e++)for(let t=0;t<s;t++)this.data[i+e][r+t]="function"==typeof n?n({x:t,y:e},this.data[i+e][r+t]):n;return this}rectRead(e,t,n){return this.rect(e,t,((e,t)=>(n(e,t),t)))}hLine(e,t,n){return this.rect(e,{width:t,height:1},n)}vLine(e,t,n){return this.rect(e,{width:1,height:t},n)}border(e=2,t){const n=this.height+2*e,r=this.width+2*e,i=qg(e,t),o=Array.from({length:e},(()=>qg(r,t)));return new Yg({height:n,width:r},[...o,...this.data.map((e=>[...i,...e,...i])),...o])}embed(e,t){return this.rect(e,t.size(),(({x:e,y:n})=>t.data[n][e]))}rectSlice(e,t=this.size()){const n=new Yg(Yg.size(t,this.size(this.xy(e))));return this.rect(e,t,(({x:e,y:t},r)=>n.data[t][e]=r)),n}inverse(){const{height:e,width:t}=this;return new Yg({height:t,width:e}).rect({x:0,y:0},1/0,(({x:e,y:t})=>this.data[e][t]))}scale(e){if(!Number.isSafeInteger(e)||e>1024)throw new Error(`Wrong scale factor: ${e}`);const{height:t,width:n}=this;return new Yg({height:e*t,width:e*n}).rect({x:0,y:0},1/0,(({x:t,y:n})=>this.data[Math.floor(n/e)][Math.floor(t/e)]))}clone(){return new Yg(this.size()).rect({x:0,y:0},this.size(),(({x:e,y:t})=>this.data[t][e]))}assertDrawn(){this.rectRead(0,1/0,((e,t)=>{if("boolean"!=typeof t)throw new Error("Invalid color type="+typeof t)}))}toString(){return this.data.map((e=>e.map((e=>void 0===e?"?":e?"X":" ")).join(""))).join("\n")}toASCII(){const{height:e,width:t,data:n}=this;let r="";for(let i=0;i<e;i+=2){for(let o=0;o<t;o++){const t=n[i][o],s=i+1>=e||n[i+1][o];t||s?!t&&s?r+="▀":t&&!s?r+="▄":t&&s&&(r+=" "):r+="█"}r+="\n"}return r}toTerm(){const e="",t=` ${e}`,n=` ${e}`;return this.data.map((e=>e.map((e=>e?n:t)).join(""))).join("\n")}toSVG(){let e=`<svg xmlns:svg="http://www.w3.org/2000/svg" viewBox="0 0 ${this.width} ${this.height}" version="1.1" xmlns="http://www.w3.org/2000/svg">`;return this.rectRead(0,1/0,(({x:t,y:n},r)=>{r&&(e+=`<rect x="${t}" y="${n}" width="1" height="1" />`)})),e+="</svg>",e}toGIF(){const e=e=>[255&e,e>>>8&255],t=[...e(this.width),...e(this.height)],n=[];this.rectRead(0,1/0,((e,t)=>n.push(+(!0===t))));const r=126,i=[71,73,70,56,55,97,...t,246,0,0,255,255,255,...qg(381,0),44,0,0,0,0,...t,0,7],o=Math.floor(n.length/r);for(let e=0;e<o;e++)i.push(127,128,...n.slice(r*e,r*(e+1)).map((e=>+e)));return i.push(n.length%r+1,128,...n.slice(o*r).map((e=>+e))),i.push(1,129,0,59),new Uint8Array(i)}toImage(e=!1){const{height:t,width:n}=this.size(),r=new Uint8Array(t*n*(e?3:4));let i=0;for(let o=0;o<t;o++)for(let t=0;t<n;t++){const n=this.data[o][t]?0:255;r[i++]=n,r[i++]=n,r[i++]=n,e||(r[i++]=255)}return{height:t,width:n,data:r}}}const Zg=["low","medium","quartile","high"],Jg=["numeric","alphanumeric","byte","kanji","eci"],Xg=[26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706],Qg={low:[7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],medium:[10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],quartile:[13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],high:[17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},em={low:[1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],medium:[1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],quartile:[1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],high:[1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},tm={size:{encode:e=>21+4*(e-1),decode:e=>(e-17)/4},sizeType:e=>Math.floor((e+7)/17),alignmentPatterns(e){if(1===e)return[];const t=tm.size.encode(e)-6-1,n=t-6,r=Math.ceil(n/28);let i=Math.floor(n/r);i%2?i+=1:n%r*2>=r&&(i+=2);const o=[6];for(let e=1;e<r;e++)o.push(t-(r-e)*i);return o.push(t),o},ECCode:{low:1,medium:0,quartile:3,high:2},formatMask:21522,formatBits(e,t){const n=tm.ECCode[e]<<3|t;let r=n;for(let e=0;e<10;e++)r=r<<1^1335*(r>>9);return(n<<10|r)^tm.formatMask},versionBits(e){let t=e;for(let e=0;e<12;e++)t=t<<1^7973*(t>>11);return e<<12|t},alphabet:{numeric:Gg("0123456789"),alphanumerc:Gg("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")},lengthBits:(e,t)=>({numeric:[10,12,14],alphanumeric:[9,11,13],byte:[8,16,16],kanji:[8,10,12],eci:[0,0,0]}[t][tm.sizeType(e)]),modeBits:{numeric:"0001",alphanumeric:"0010",byte:"0100",kanji:"1000",eci:"0111"},capacity(e,t){const n=Xg[e-1],r=Qg[t][e-1],i=em[t][e-1],o=Math.floor(n/i)-r,s=i-n%i;return{words:r,numBlocks:i,shortBlocks:s,blockLen:o,capacity:8*(n-r*i),total:(r+o)*i+i-s}}},nm=[(e,t)=>(e+t)%2==0,(e,t)=>t%2==0,(e,t)=>e%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(t/2)+Math.floor(e/3))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0],rm={tables:(e=>{const t=qg(256,0),n=qg(256,0);for(let e=0,r=1;e<256;e++)t[e]=r,n[r]=e,r<<=1,256&r&&(r^=285);return{exp:t,log:n}})(),exp:e=>rm.tables.exp[e],log(e){if(0===e)throw new Error(`GF.log: wrong arg=${e}`);return rm.tables.log[e]%255},mul:(e,t)=>0===e||0===t?0:rm.tables.exp[(rm.tables.log[e]+rm.tables.log[t])%255],add:(e,t)=>e^t,pow:(e,t)=>rm.tables.exp[rm.tables.log[e]*t%255],inv(e){if(0===e)throw new Error(`GF.inverse: wrong arg=${e}`);return rm.tables.exp[255-rm.tables.log[e]]},polynomial(e){if(0==e.length)throw new Error("GF.polymomial: wrong length");if(0!==e[0])return e;let t=0;for(;t<e.length-1&&0==e[t];t++);return e.slice(t)},monomial(e,t){if(e<0)throw new Error(`GF.monomial: wrong degree=${e}`);if(0==t)return[0];let n=qg(e+1,0);return n[0]=t,rm.polynomial(n)},degree:e=>e.length-1,coefficient:(e,t)=>e[rm.degree(e)-t],mulPoly(e,t){if(0===e[0]||0===t[0])return[0];const n=qg(e.length+t.length-1,0);for(let r=0;r<e.length;r++)for(let i=0;i<t.length;i++)n[r+i]=rm.add(n[r+i],rm.mul(e[r],t[i]));return rm.polynomial(n)},mulPolyScalar(e,t){if(0==t)return[0];if(1==t)return e;const n=qg(e.length,0);for(let r=0;r<e.length;r++)n[r]=rm.mul(e[r],t);return rm.polynomial(n)},mulPolyMonomial(e,t,n){if(t<0)throw new Error("GF.mulPolyMonomial: wrong degree");if(0==n)return[0];const r=qg(e.length+t,0);for(let t=0;t<e.length;t++)r[t]=rm.mul(e[t],n);return rm.polynomial(r)},addPoly(e,t){if(0===e[0])return t;if(0===t[0])return e;let n=e,r=t;n.length>r.length&&([n,r]=[r,n]);let i=qg(r.length,0),o=r.length-n.length,s=r.slice(0,o);for(let e=0;e<s.length;e++)i[e]=s[e];for(let e=o;e<r.length;e++)i[e]=rm.add(n[e-o],r[e]);return rm.polynomial(i)},remainderPoly(e,t){const n=Array.from(e);for(let r=0;r<e.length-t.length+1;r++){const e=n[r];if(0!==e)for(let i=1;i<t.length;i++)0!==t[i]&&(n[r+i]=rm.add(n[r+i],rm.mul(t[i],e)))}return n.slice(e.length-t.length+1,n.length)},divisorPoly(e){let t=[1];for(let n=0;n<e;n++)t=rm.mulPoly(t,[1,rm.pow(2,n)]);return t},evalPoly(e,t){if(0==t)return rm.coefficient(e,0);let n=e[0];for(let r=1;r<e.length;r++)n=rm.add(rm.mul(t,n),e[r]);return n},euclidian(e,t,n){rm.degree(e)<rm.degree(t)&&([e,t]=[t,e]);let r=e,i=t,o=[0],s=[1];for(;2*rm.degree(i)>=n;){let e=r,t=o;if(r=i,o=s,0===r[0])throw new Error("rLast[0] === 0");i=e;let n=[0];const a=rm.inv(r[0]);for(;rm.degree(i)>=rm.degree(r)&&0!==i[0];){const e=rm.degree(i)-rm.degree(r),t=rm.mul(i[0],a);n=rm.addPoly(n,rm.monomial(e,t)),i=rm.addPoly(i,rm.mulPolyMonomial(r,e,t))}if(n=rm.mulPoly(n,o),s=rm.addPoly(n,t),rm.degree(i)>=rm.degree(r))throw new Error(`Division failed r: ${i}, rLast: ${r}`)}const a=rm.coefficient(s,0);if(0==a)throw new Error("sigmaTilde(0) was zero");const c=rm.inv(a);return[rm.mulPolyScalar(s,c),rm.mulPolyScalar(i,c)]}};function im(e,t,n,r){let i="",o=n.length;if("numeric"===r){const e=tm.alphabet.numeric.decode(n.split("")),t=e.length;for(let n=0;n<t-2;n+=3)i+=Hg(100*e[n]+10*e[n+1]+e[n+2],10);t%3==1?i+=Hg(e[t-1],4):t%3==2&&(i+=Hg(10*e[t-2]+e[t-1],7))}else if("alphanumeric"===r){const e=tm.alphabet.alphanumerc.decode(n.split("")),t=e.length;for(let n=0;n<t-1;n+=2)i+=Hg(45*e[n]+e[n+1],11);t%2==1&&(i+=Hg(e[t-1],6))}else{if("byte"!==r)throw new Error("encode: unsupported type");{const e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(n);o=e.length,i=Array.from(e).map((e=>Hg(e,8))).join("")}}const{capacity:s}=tm.capacity(e,t),a=Hg(o,tm.lengthBits(e,r));let c=tm.modeBits[r]+a+i;if(c.length>s)throw new Error("Capacity overflow");c+="0".repeat(Math.min(4,Math.max(0,s-c.length))),c.length%8&&(c+="0".repeat(8-c.length%8));for(let e=0;c.length!==s;e++)c+="1110110000010001"[e%16];const l=Uint8Array.from(c.match(/(.{8})/g).map((e=>Number(`0b${e}`))));return function(e,t){const{words:n,shortBlocks:r,numBlocks:i,blockLen:o,total:s}=tm.capacity(e,t),a=(c=n,{encode(e){const t=rm.divisorPoly(c),n=Array.from(e);return n.push(...t.slice(0,-1).fill(0)),Uint8Array.from(rm.remainderPoly(n,t))},decode(e){const t=e.slice(),n=rm.polynomial(Array.from(e));let r=qg(c,0),i=!1;for(let e=0;e<c;e++){const t=rm.evalPoly(n,rm.exp(e));r[r.length-1-e]=t,0!==t&&(i=!0)}if(!i)return t;r=rm.polynomial(r);const o=rm.monomial(c,1),[s,a]=rm.euclidian(o,r,c),l=qg(rm.degree(s),0);let d=0;for(let e=1;e<256&&d<l.length;e++)0===rm.evalPoly(s,e)&&(l[d++]=rm.inv(e));if(d!==l.length)throw new Error("RS.decode: wrong errors number");for(let e=0;e<l.length;e++){const n=t.length-1-rm.log(l[e]);if(n<0)throw new Error("RS.decode: wrong error location");const r=rm.inv(l[e]);let i=1;for(let t=0;t<l.length;t++)e!==t&&(i=rm.mul(i,rm.add(1,rm.mul(l[t],r))));t[n]=rm.add(t[n],rm.mul(rm.evalPoly(a,r),rm.inv(i)))}return t}});var c;return{encode(e){const t=[],n=[];for(let s=0;s<i;s++){const i=o+(s<r?0:1);t.push(e.subarray(0,i)),n.push(a.encode(e.subarray(0,i))),e=e.subarray(i)}const s=Vg(...t),c=Vg(...n),l=new Uint8Array(s.length+c.length);return l.set(s),l.set(c,s.length),l},decode(e){if(e.length!==s)throw new Error(`interleave.decode: len(data)=${e.length}, total=${s}`);const t=[];for(let e=0;e<i;e++){const i=e<r;t.push(new Uint8Array(n+o+(i?0:1)))}let c=0;for(let n=0;n<o;n++)for(let r=0;r<i;r++)t[r][n]=e[c++];for(let n=r;n<i;n++)t[n][o]=e[c++];for(let s=o;s<o+n;s++)for(let n=0;n<i;n++){const i=n<r;t[n][s+(i?0:1)]=e[c++]}const l=[];for(const e of t)l.push(...Array.from(a.decode(e)).slice(0,-n));return Uint8Array.from(l)}}}(e,t).encode(l)}function om(e,t,n,r,i=!1){const o=function(e,t,n,r=!1){const i=tm.size.encode(e);let o=new Yg(i+2);const s=new Yg(3).rect(0,3,!0).border(1,!1).border(1,!0).border(1,!1);o=o.embed(0,s).embed({x:-s.width,y:0},s).embed({x:0,y:-s.height},s),o=o.rectSlice(1,i);const a=new Yg(1).rect(0,1,!0).border(1,!1).border(1,!0),c=tm.alignmentPatterns(e);for(const e of c)for(const t of c)void 0===o.data[e][t]&&o.embed({x:t-2,y:e-2},a);o=o.hLine({x:0,y:6},1/0,(({x:e},t)=>void 0===t?e%2==0:t)).vLine({x:6,y:0},1/0,(({y:e},t)=>void 0===t?e%2==0:t));{const e=tm.formatBits(t,n),s=t=>!r&&1==(e>>t&1);for(let e=0;e<6;e++)o.data[e][8]=s(e);for(let e=6;e<8;e++)o.data[e+1][8]=s(e);for(let e=8;e<15;e++)o.data[i-15+e][8]=s(e);for(let e=0;e<8;e++)o.data[8][i-e-1]=s(e);for(let e=8;e<9;e++)o.data[8][15-e-1+1]=s(e);for(let e=9;e<15;e++)o.data[8][15-e-1]=s(e);o.data[i-8][8]=!r}if(e>=7){const t=tm.versionBits(e);for(let e=0;e<18;e+=1){const n=!r&&1==(t>>e&1),s=Math.floor(e/3),a=e%3+i-8-3;o.data[s][a]=n,o.data[a][s]=n}}return o}(e,t,r,i);let s=0;const a=8*n.length;if(function(e,t,n){const r=e.height,i=nm[t];let o=-1,s=r-1;for(let t=r-1;t>0;t-=2){for(6==t&&(t=5);;s+=o){for(let r=0;r<2;r+=1){const o=t-r;void 0===e.data[s][o]&&n(o,s,i(o,s))}if(s+o<0||s+o>=r)break}o=-o}}(o,r,((e,t,r)=>{let i=!1;s<a&&(i=0!=(n[s>>>3]>>(7-s&7)&1),s++),o.data[t][e]=i!==r})),s!==a)throw new Error("QR: bytes left after draw");return o}function sm(e){const t=e.inverse(),n=e=>{let t=0;for(let n,r=0,i=1;r<e.length;r++)n===e[r]&&(i++,r!==e.length-1)||(i>=5&&(t+=i-5+3),n=e[r],i=1);return t};let r=0;e.data.forEach((e=>r+=n(e))),t.data.forEach((e=>r+=n(e)));let i=0,o=e.data;const s=e.width-1,a=e.height-1;for(let e=0;e<s;e++)for(let t=0;t<a;t++){const n=e+1,r=t+1;o[e][t]===o[n][t]&&o[n][t]===o[e][r]&&o[n][t]===o[n][r]&&(i+=3)}const c=e=>{const t=[!0,!1,!0,!0,!0,!1,!0],n=[!1,!1,!1,!1],r=[...t,...n],i=[...n,...t];let o=0;for(let t=0;t<e.length;t++)Wg(e,r,t)&&(o+=40),Wg(e,i,t)&&(o+=40);return o};let l=0;for(const t of e.data)l+=c(t);for(const e of t.data)l+=c(e);let d=0;e.rectRead(0,1/0,((e,t)=>d+=t?1:0));const u=d/(e.height*e.width)*100,h=10*Math.floor(Math.abs(u-50)/5);return r+i+l+h}function am(e,t="raw",n={}){const r=void 0!==n.ecc?n.ecc:"medium";!function(e){if(!Zg.includes(e))throw new Error(`Invalid error correction mode=${e}. Expected: ${Zg}`)}(r);const i=void 0!==n.encoding?n.encoding:function(e){let t="numeric";for(let n of e)if(!tm.alphabet.numeric.has(n)&&(t="alphanumeric",!tm.alphabet.alphanumerc.has(n)))return"byte";return t}(e);!function(e){if(!Jg.includes(e))throw new Error(`Encoding: invalid mode=${e}. Expected: ${Jg}`);if("kanji"===e||"eci"===e)throw new Error(`Encoding: ${e} is not supported (yet?).`)}(i),void 0!==n.mask&&function(e){if(![0,1,2,3,4,5,6,7].includes(e)||!nm[e])throw new Error(`Invalid mask=${e}. Expected number [0..7]`)}(n.mask);let o,s=n.version,a=new Error("Unknown error");if(void 0!==s)!function(e){if(!Number.isSafeInteger(e)||e<1||e>40)throw new Error(`Invalid version=${e}. Expected number [1..40]`)}(s),o=im(s,r,e,i);else for(let t=1;t<=40;t++)try{o=im(t,r,e,i),s=t;break}catch(e){a=e}if(!s||!o)throw a;let c=function(e,t,n,r){if(void 0===r){const i=function(){let e,t=1/0;return{add(n,r){n>=t||(e=r,t=n)},get:()=>e,score:()=>t}}();for(let r=0;r<nm.length;r++)i.add(sm(om(e,t,n,r,!0)),r);r=i.get()}if(void 0===r)throw new Error("Cannot find mask");return om(e,t,n,r)}(s,r,o,n.mask);c.assertDrawn();const l=void 0===n.border?2:n.border;if(!Number.isSafeInteger(l))throw new Error("Wrong border type="+typeof l);if(c=c.border(l,!1),void 0!==n.scale&&(c=c.scale(n.scale)),"raw"===t)return c.data;if("ascii"===t)return c.toASCII();if("svg"===t)return c.toSVG();if("gif"===t)return c.toGIF();if("term"===t)return c.toTerm();throw new Error(`Unknown output: ${t}`)}const cm={DESKTOP:"Desktop",MOBILE:"Mobile",META_MASK_MOBILE_APP:"MetaMask mobile app",SCAN_TO_CONNECT:"Scan to connect and sign with",CONNECT_WITH_EXTENSION:"Connect With MetaMask Extension",INSTALL_MODAL:{TRUSTED_BY_USERS:"Trusted by over 30 million users to buy, store, send and swap crypto securely",LEADING_CRYPTO_WALLET:"The leading crypto wallet & gateway to blockchain apps built on Ethereum Mainnet, Polygon, Optimism, and many other networks",CONTROL_DIGITAL_INTERACTIONS:"Puts you in control of your digital interactions by making power of cryptography more accessible",INSTALL_META_MASK_EXTENSION:"Install MetaMask Extension"},PENDING_MODAL:{OPEN_META_MASK_SELECT_CODE:"Please open the MetaMask wallet app and select the code on the screen OR disconnect",OPEN_META_MASK_CONTINUE:"Open the MetaMask app to continue with your session.",NUMBER_AFTER_OPEN_NOTICE:"If a number doesn't appear after opening MetaMask, please click disconnect and re-scan the QRCode.",DISCONNECT:"Disconnect"},SELECT_MODAL:{CRYPTO_TAKE_CONTROL_TEXT:"Take control of your crypto and explore the blockchain with the wallet trusted by over 30 million people worldwide"},META_MASK_MODAL:{ADDRESS_COPIED:"Address copied to clipboard!",DISCONNECT:"Disconnect",ACTIVE_NETWORK:"Active Network"}};class lm{constructor(e){var t;this.translations=cm,this.supportedLocales=["es","fr","he","it","pt","tr"],this.baseUrl=null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:"https://raw.githubusercontent.com/MetaMask/metamask-sdk/refs/heads/gh-pages/locales"}getBrowserLanguage(){if((navigator.languages||[navigator.language]).some((e=>e.toLowerCase().startsWith("en"))))return"en";const e=navigator.language.toLowerCase().split("-")[0];return this.supportedLocales.includes(e)?e:"en"}async init(e){const t=this.getBrowserLanguage()||e.fallbackLng;await this.loadTranslations(t)}async loadTranslations(e){const t=e.split("-")[0];if("en"!==t&&this.supportedLocales.includes(t))try{const e=`${this.baseUrl}/${t}.json`,n=await fetch(e);if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);this.translations=await n.json()}catch(e){console.warn(`❌ Failed to load ${t} translations, falling back to English:`,e),this.translations=cm}else this.translations=cm}t(e){return this.getNestedTranslation(e,this.translations)||e}getNestedTranslation(e,t){const n=e.split(".");let r=t;for(const e of n){if("object"!=typeof r)return"";r=r[e]}return"string"==typeof r?r:""}}var dm;!function(e){e.SDK_MODAL_VIEWED="sdk_modal_viewed",e.SDK_MODAL_BUTTON_CLICKED="sdk_modal_button_clicked",e.SDK_MODAL_TOGGLE_CHANGED="sdk_modal_toggle_changed"}(dm||(dm={}));const um=class{constructor(e){wp(this,e),this.close=Qp(this,"close",7),this.startDesktopOnboarding=Qp(this,"startDesktopOnboarding",7),this.trackAnalytics=Qp(this,"trackAnalytics",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.onClose=this.onClose.bind(this),this.onStartDesktopOnboardingHandler=this.onStartDesktopOnboardingHandler.bind(this),this.setTab=this.setTab.bind(this),this.render=this.render.bind(this),this.setTab(this.preferDesktop?1:2),this.i18nInstance=new lm}componentDidLoad(){this.trackAnalytics.emit({event:dm.SDK_MODAL_VIEWED,params:{extensionInstalled:!1,tab:1===this.tab?"desktop":"mobile"}})}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}onClose(e=!1){this.close.emit({shouldTerminate:e})}onStartDesktopOnboardingHandler(){this.trackAnalytics.emit({event:dm.SDK_MODAL_BUTTON_CLICKED,params:{button_type:"install_extension",tab:"desktop"}}),this.startDesktopOnboarding.emit()}setTab(e,t=!1){t&&this.trackAnalytics.emit({event:dm.SDK_MODAL_TOGGLE_CHANGED,params:{toggle:1===this.tab?"desktop_to_mobile":"mobile_to_desktop"}}),this.tab=e,this.isDefaultTab=!1}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.isDefaultTab?this.preferDesktop?1:2:this.tab,n=am(this.link,"svg",{ecc:"medium",scale:2});return Vp(Ig,{className:"install-model"},Vp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),Vp("div",{class:"modal"},Vp("div",{class:"closeButtonContainer"},Vp("div",{class:"right"},Vp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},Vp(Ug,null)))),Vp("div",{class:"logoContainer"},Vp(Fg,null)),Vp("div",null,Vp("div",{class:"tabcontainer"},Vp("div",{class:"flexContainer"},Vp("div",{onClick:()=>this.setTab(1,!0),class:"tab flexItem "+(1===t?"tabactive":"")},e("DESKTOP")),Vp("div",{onClick:()=>this.setTab(2,!0),class:"tab flexItem "+(2===t?"tabactive":"")},e("MOBILE")))),Vp("div",{style:{display:1===t?"none":"block"}},Vp("div",{class:"flexContainer"},Vp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},n&&Vp("div",{id:"sdk-mm-qrcode",class:"center",innerHTML:n}),Vp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT")," ",Vp("br",null),Vp("span",{class:"blue"},Vp("b",null,e("META_MASK_MOBILE_APP"))))))),Vp("div",{style:{display:2===t?"none":"block"}},Vp("div",{class:"item"},Vp(Ng,{Icon:Dg,text:e("INSTALL_MODAL.TRUSTED_BY_USERS")})),Vp("div",{class:"item"},Vp(Ng,{Icon:Bg,text:e("INSTALL_MODAL.LEADING_CRYPTO_WALLET")})),Vp("div",{class:"item"},Vp(Ng,{Icon:$g,text:e("INSTALL_MODAL.CONTROL_DIGITAL_INTERACTIONS")})),Vp("button",{class:"button",onClick:()=>this.onStartDesktopOnboardingHandler()},Vp(jg,null),Vp("span",{class:"installExtensionText"},e("INSTALL_MODAL.INSTALL_META_MASK_EXTENSION"))))),Vp(Kg,{version:this.sdkVersion})))}get el(){return Xp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};um.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const hm=class{constructor(e){wp(this,e),this.close=Qp(this,"close",7),this.disconnect=Qp(this,"disconnect",7),this.updateOTPValue=Qp(this,"updateOTPValue",7),this.displayOTP=void 0,this.sdkVersion=void 0,this.otpCode=void 0,this.translationsLoaded=!1,this.i18nInstance=new lm}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(){this.close.emit()}onDisconnect(){this.disconnect.emit()}onUpdateOTPValueHandler(e){this.updateOTPValue.emit({otpValue:e})}disconnectedCallback(){this.onClose()}render(){var e;if(!this.translationsLoaded)return null;const t=null===(e=this.displayOTP)||void 0===e||e,n=this.sdkVersion,r=e=>this.i18nInstance.t(e);return Vp(Ig,{className:"pending-modal"},Vp("div",{class:"backdrop",onClick:()=>this.onClose()}),Vp("div",{class:"modal"},Vp("div",{class:"closeButtonContainer"},Vp("div",{class:"right"},Vp("span",{class:"closeButton",onClick:()=>this.onClose()},Vp(Ug,null)))),Vp("div",{class:"logoContainer"},Vp(Fg,null)),Vp("div",null,Vp("div",{class:"flexContainer",style:{flexDirection:"column",color:"black"}},Vp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"30px",marginBottom:"30px",fontSize:"16px"}},r(t?"PENDING_MODAL.OPEN_META_MASK_SELECT_CODE":"PENDING_MODAL.OPEN_META_MASK_CONTINUE")),Vp("div",{id:"sdk-mm-otp-value",style:{padding:"10px",fontSize:"32px",display:this.otpCode?"block":"none"}},this.otpCode),t&&Vp("div",{class:"notice"},"* ",r("PENDING_MODAL.NUMBER_AFTER_OPEN_NOTICE"))),Vp("div",{style:{marginTop:"20px"}},Vp("button",{class:"button blue",style:{marginTop:"5px",color:"#0376C9",borderColor:"#0376C9",borderWidth:"1px",borderStyle:"solid",backgroundColor:"white"},onClick:()=>this.onDisconnect()},r("PENDING_MODAL.DISCONNECT")))),Vp(Kg,{version:n})))}get el(){return Xp(this)}};hm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";const fm=()=>Vp("svg",{width:"21",height:"15",viewBox:"0 0 21 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M14.1364 14.9851C13.5909 14.9851 13.2273 14.5851 13.2273 13.9851C13.2273 13.3851 13.5909 12.9851 14.1364 12.9851C16.6818 12.9851 18.6818 10.7851 18.6818 7.98508C18.6818 5.18508 16.6818 2.98508 14.1364 2.98508C11.5909 2.98508 9.59091 5.18508 9.59091 7.98508C9.59091 8.58508 9.22727 8.98508 8.68182 8.98508C8.13636 8.98508 7.77273 8.58508 7.77273 7.98508C7.77273 4.08508 10.5909 0.985077 14.1364 0.985077C17.6818 0.985077 20.5 4.08508 20.5 7.98508C20.5 11.8851 17.6818 14.9851 14.1364 14.9851ZM6.68182 14.7851C3.22727 14.7851 0.5 11.6851 0.5 7.98508C0.5 4.28508 3.22727 1.18508 6.68182 1.18508C7.22727 1.18508 7.59091 1.58508 7.59091 2.18508C7.59091 2.78508 7.22727 3.18508 6.68182 3.18508C4.22727 3.18508 2.31818 5.38508 2.31818 7.98508C2.31818 10.5851 4.22727 12.7851 6.68182 12.7851C9.13636 12.7851 11.0455 10.6851 11.0455 7.98508C11.0455 7.38508 11.4091 6.98508 11.9545 6.98508C12.5 6.98508 12.8636 7.38508 12.8636 7.98508C12.7727 11.6851 10.0455 14.7851 6.68182 14.7851Z",fill:"white"})),pm=()=>Vp("svg",{width:"400",height:"300",viewBox:"0 0 467 300",fill:"none",xmlns:"http://www.w3.org/2000/svg"},Vp("path",{d:"M312.387 280.629C312.549 280.583 312.247 280.735 312.387 280.629L339.678 260.425C340.088 260.118 340.132 259.156 340.07 258.647C340.008 258.138 339.573 258.257 339.106 258.084L311.712 247.455C311.292 247.301 311.308 247.402 310.939 247.673C310.569 247.944 310.356 248.21 310.356 248.672L310.459 279.504C310.461 280.025 311.163 280.619 311.614 280.847C311.913 280.996 312.072 280.718 312.387 280.629ZM336.204 259.736L312.979 276.292L313.439 251.139L336.204 259.736Z",fill:"url(#paint0_linear_1356_14057)"}),Vp("path",{d:"M324.639 260.342C324.358 259.547 323.485 258.91 322.707 259.215C319.6 260.432 318.17 262.313 317.287 264.066C316.482 265.665 316.197 267.482 314.188 268.269C312.178 269.055 310.763 268.663 309.162 268.007C307.406 267.287 305.504 266.182 302.397 267.399C299.289 268.616 297.859 270.497 296.976 272.25C296.171 273.849 295.697 274.886 293.685 275.673C291.675 276.459 290.261 276.067 288.659 275.411C286.903 274.691 284.999 273.587 281.894 274.803C278.789 276.019 277.549 278.681 276.666 280.434C275.861 282.034 275.386 283.07 273.374 283.857C272.596 284.161 271.931 285.055 272.211 285.849C272.492 286.644 273.365 287.281 274.143 286.977C277.25 285.76 278.68 283.879 279.563 282.125C280.368 280.526 280.65 278.71 282.662 277.923C284.672 277.136 286.087 277.528 287.688 278.184C289.444 278.904 291.348 280.009 294.453 278.793C297.561 277.576 298.991 275.695 299.874 273.941C300.679 272.342 301.153 271.306 303.165 270.519C305.175 269.732 306.589 270.124 308.191 270.78C309.947 271.5 311.849 272.605 314.956 271.388C318.063 270.172 319.301 267.511 320.184 265.757C320.989 264.158 321.466 263.121 323.476 262.335C324.254 262.032 324.919 261.137 324.639 260.342Z",fill:"url(#paint1_linear_1356_14057)"}),Vp("path",{d:"M389.034 111.124C388.968 112.406 387.342 113.113 386.324 113.549C384.297 114.419 382.089 114.493 379.942 114.5C376.607 114.509 373.215 114.163 369.89 113.976C366.712 113.798 363.156 113.311 360.03 114.232C357.705 114.919 355.667 116.762 353.452 117.739C351.129 118.765 348.957 119.198 346.489 119.687C335.569 121.85 323.587 120.825 312.656 119.977C311.92 119.92 312.539 118.997 313.237 118.981C313.207 118.815 313.001 118.394 313.045 118.201C313.086 118.029 312.781 117.586 312.853 117.421C312.67 117.198 313.316 117.427 313.626 117.204C315.912 115.557 318.721 114.79 321.363 115.041C324.677 115.355 327.293 116.04 330.641 115.781C334.392 115.491 338.125 114.787 341.857 114.312C345.142 113.892 349.09 113.941 352.106 112.28C352.916 111.834 353.137 111.262 353.269 110.287C353.331 109.828 353.672 108.969 353.658 108.511C353.629 107.529 354.191 107.886 355.013 107.298C356.857 105.981 358.274 105.516 360.428 105.784C362.841 106.083 365.264 107.273 367.578 107.953C370.761 108.888 374.328 108.646 377.631 108.477C380.517 108.329 383.141 107.901 385.944 108.653C387.013 108.941 389.104 109.745 389.034 111.124Z",fill:"url(#paint2_linear_1356_14057)"}),Vp("path",{d:"M278.118 85.4414C280.313 83.8186 283.302 83.9 285.853 83.2728C290.501 82.127 295.644 78.4476 300.549 79.1524C301.299 79.2595 300.904 81.0355 300.159 80.9295C300.131 80.9256 300.187 80.9333 300.159 80.9295C300.089 81.0185 299.516 81.1051 299.385 81.1463C294.999 82.515 292.895 87.5083 289.126 89.8598C287.799 90.688 286.771 90.8351 285.258 90.9441C283.515 91.0691 280.964 90.5775 279.269 90.1219C277.15 89.5532 275.965 87.034 278.118 85.4414Z",fill:"url(#paint3_linear_1356_14057)"}),Vp("path",{d:"M122.567 166.093C113.597 172.832 104.535 179.836 99.517 190.092C98.5342 192.099 97.519 195.019 97.9533 197.204C98.9699 202.316 105.76 203.049 110.691 201.96C113.468 201.347 116.325 199.231 115.921 196.319C115.576 193.81 113.158 192.986 112.072 190.73C110.779 188.04 112.35 184.97 114.218 182.62C128.134 165.099 150.074 157.394 171.093 151.607C175.385 150.425 180.897 147.69 180.581 143.099C180.372 140.072 177.118 137.683 174.221 137.383C171.324 137.082 168.481 138.773 165.715 139.776C158.416 142.419 151.17 143.799 143.489 143.526C136.865 143.29 130.976 143.316 129.562 150.781C128.138 158.276 129.53 160.863 122.567 166.093Z",fill:"url(#paint4_linear_1356_14057)"}),Vp("path",{d:"M79.1056 153.531C60.3932 164.378 43.7478 178.354 32.8214 197.415C30.3313 201.76 27.9216 206.554 27.1821 211.512C26.4448 216.47 27.7591 222.525 30.8133 226.337C34.908 231.446 41.6938 232.915 48.1811 233.125C50.7248 233.208 53.0035 233.066 55.3316 231.947C57.6602 230.83 59.7548 228.359 59.5978 225.742C59.3303 221.315 54.5491 219.665 50.9271 217.34C42.6566 212.037 40.4958 199.493 44.2381 190.032C47.9803 180.57 55.8228 173.173 63.2316 166.338C67.229 162.651 71.5194 158.372 76.777 157.522C79.9167 157.015 83.4706 157.589 86.6295 157.252C93.9004 156.479 99.64 151.404 105.588 146.912C115.048 139.765 126.045 134.283 137.501 132.093C141.913 131.248 146.293 130.493 149.682 127.831C151.37 126.507 150.803 123.567 148.726 123.93C138.542 125.713 128.652 131.135 119.142 134.758C105.627 139.914 91.7133 146.223 79.1056 153.531Z",fill:"url(#paint5_linear_1356_14057)"}),Vp("path",{d:"M96.3677 117.321C96.0315 116.64 95.2914 116.612 94.6293 116.975C91.9858 118.417 91.5452 120.509 90.9466 122.178C90.4004 123.702 89.3647 124.67 87.6542 125.604C85.9437 126.538 85.0983 126.316 83.5956 125.91C81.9481 125.465 79.8603 125.424 77.2168 126.866C74.5734 128.309 74.1348 130.401 73.5341 132.07C72.9879 133.593 71.9522 134.562 70.2417 135.496C68.5313 136.43 67.6859 136.208 66.1832 135.801C64.5357 135.357 62.2569 134.538 59.6128 135.978C56.9694 137.42 56.5308 139.512 55.9301 141.181C55.3839 142.705 54.5398 144.454 52.8293 145.388C52.1667 145.748 52.1006 146.485 52.439 147.165C52.7752 147.845 53.5153 147.874 54.1773 147.511C56.8208 146.069 57.2594 143.977 57.86 142.307C58.4062 140.784 59.4419 139.815 61.1524 138.881C62.8629 137.948 63.7083 138.17 65.211 138.576C66.8585 139.021 68.9458 139.059 71.5898 137.619C74.2333 136.177 74.6718 134.085 75.2725 132.416C75.8187 130.892 76.8544 129.924 78.5649 128.99C80.2754 128.056 81.1207 128.278 82.6235 128.684C84.2709 129.129 86.5503 129.95 89.1938 128.507C91.8373 127.065 92.2779 124.973 92.8765 123.304C93.4227 121.78 94.2663 120.03 95.9773 119.098C96.6378 118.738 96.7039 118.001 96.3677 117.321Z",fill:"#FBC49D"}),Vp("path",{d:"M391.827 164.699C392.04 164.639 392.39 164.573 392.6 164.481C393.87 163.921 395.363 162.429 395.893 161.051C396.421 159.673 396.237 158.321 395.712 156.931C394.629 154.061 391.777 152.62 389.155 153.775C386.531 154.931 384.962 158.455 386.042 161.325C387.038 163.963 389.369 165.392 391.827 164.699ZM394.166 157.367C394.529 158.332 394.52 159.751 394.156 160.706C393.792 161.662 393.1 162.534 392.218 162.921C390.398 163.723 388.338 162.878 387.589 160.889C387.226 159.925 387.234 158.506 387.599 157.55C387.963 156.594 388.654 155.723 389.536 155.336C391.356 154.534 393.416 155.376 394.166 157.367Z",fill:"#86E29B"}),Vp("path",{d:"M62.7198 108.691C64.4912 108.191 66.6152 106.609 67.5596 104.824C68.4273 103.187 68.465 101.455 67.9609 99.7066C67.4547 97.9586 66.0792 96.5141 64.4963 95.6786C62.9135 94.843 61.2077 94.8578 59.4756 95.4255C57.7435 95.9933 56.2768 97.4364 55.409 99.074C53.6185 102.456 55.2032 106.494 58.4723 108.22C60.0142 109.035 61.1315 109.138 62.7198 108.691ZM60.6304 96.7682C61.819 96.4332 63.0232 96.8871 64.1048 97.4571C65.2463 98.0603 66.0495 98.8796 66.4145 100.142C66.7791 101.403 66.4488 103.299 65.8224 104.48C64.5299 106.919 61.2212 107.686 58.8638 106.441C56.5063 105.197 55.8538 101.858 57.1462 99.4185C57.7726 98.2375 58.6059 97.3957 59.8573 96.9862C59.9214 96.9635 60.5631 96.7872 60.6304 96.7682Z",fill:"#FFB0EB"}),Vp("path",{d:"M77.0217 242.979C75.9542 243.28 75.1664 242.151 74.9029 241.074C74.6394 239.996 75 239.378 76.0676 239.077C77.1351 238.776 78.5053 238.907 78.7688 239.984C79.0323 241.061 78.0893 242.678 77.0217 242.979Z",fill:"url(#paint6_linear_1356_14057)"}),Vp("path",{d:"M380.506 184.577C379.439 184.878 378.651 183.749 378.387 182.672C378.124 181.594 378.484 180.976 379.552 180.675C380.619 180.374 381.99 180.505 382.253 181.582C382.517 182.659 381.574 184.276 380.506 184.577Z",fill:"url(#paint7_linear_1356_14057)"}),Vp("path",{d:"M348.82 246.969C347.752 247.27 346.382 247.14 346.119 246.063C345.855 244.985 346.798 243.369 347.866 243.068C348.933 242.767 349.721 243.896 349.985 244.973C350.248 246.05 349.888 246.669 348.82 246.969Z",fill:"url(#paint8_linear_1356_14057)"}),Vp("path",{d:"M140.419 282.412C139.351 282.713 138.754 282.365 138.491 281.288C138.227 280.21 138.397 278.812 139.464 278.511C140.532 278.21 142.093 279.121 142.357 280.198C142.62 281.275 141.486 282.111 140.419 282.412Z",fill:"url(#paint9_linear_1356_14057)"}),Vp("path",{d:"M121.462 101.679C120.395 101.979 119.798 101.631 119.534 100.554C119.271 99.4764 119.44 98.0779 120.508 97.777C121.575 97.4761 123.136 98.3868 123.4 99.4642C123.663 100.542 122.53 101.378 121.462 101.679Z",fill:"url(#paint10_linear_1356_14057)"}),Vp("path",{d:"M370.749 159.005C369.682 159.306 368.311 159.175 368.048 158.098C367.784 157.021 368.727 155.404 369.795 155.103C370.863 154.802 371.65 155.931 371.914 157.008C372.177 158.086 371.817 158.704 370.749 159.005Z",fill:"url(#paint11_linear_1356_14057)"}),Vp("path",{d:"M384.211 245.345C383.143 245.646 381.773 245.515 381.51 244.438C381.246 243.361 382.189 241.744 383.257 241.443C384.324 241.142 385.112 242.271 385.376 243.348C385.639 244.426 385.278 245.044 384.211 245.345Z",fill:"url(#paint12_linear_1356_14057)"}),Vp("path",{d:"M364.771 41.3873C363.063 41.8687 361.337 40.8616 360.915 39.1378C360.493 37.414 361.536 35.6263 363.244 35.1449C364.953 34.6634 366.679 35.6706 367.101 37.3944C367.522 39.1182 366.479 40.9059 364.771 41.3873Z",fill:"url(#paint13_linear_1356_14057)"}),Vp("path",{d:"M404.311 77.905C404.602 77.8231 404.875 77.9236 405.084 77.6871C405.437 77.2908 404.814 76.6385 404.703 76.1265L401.277 58.7418C401.149 58.163 400.687 57.5371 400.123 57.3991C399.558 57.2611 398.969 57.3812 398.576 57.835L385.784 73.1179C385.395 73.564 385.199 74.3453 385.393 74.8964C385.585 75.4481 385.978 76.1646 386.548 76.2391L403.538 78.123C403.744 78.1479 404.114 77.9607 404.311 77.905ZM398.948 62.7348L401.811 74.4394L389.841 72.8085L398.948 62.7348Z",fill:"#FFB0EB"}),Vp("path",{d:"M97.5393 295.311C97.7108 295.263 97.4284 295.461 97.5393 295.311L108.785 280.464C108.975 280.211 108.718 279.972 108.594 279.684C108.47 279.396 108.124 279.917 107.821 279.902L88.5106 278.672C88.2101 278.659 87.895 278.62 87.7374 278.89C87.5798 279.159 87.7755 279.402 87.9283 279.67L96.5753 294.749C96.7102 294.99 97.2696 295.297 97.5393 295.311C97.6283 295.319 97.4556 295.335 97.5393 295.311ZM106.465 281.118L96.9667 292.97L90.6295 280.577L106.465 281.118Z",fill:"#86E29B"}),Vp("path",{d:"M393.699 108.848C389.518 104.446 414.629 114.366 413.945 120.659C413.259 126.952 401.355 129.102 403.894 123.491C406.042 118.747 400.376 115.876 393.699 108.848Z",fill:"#FBC49D"}),Vp("path",{d:"M139.414 115.959C139.434 115.953 139.392 115.965 139.414 115.959C141.963 115.2 143.436 111.976 142.717 109.189C142.37 107.839 141.526 107.199 140.408 106.504C139.289 105.808 138.171 105.449 136.933 105.815C135.698 106.182 134.85 107.033 134.222 108.247C133.595 109.461 133.282 111.234 133.63 112.585C133.978 113.935 134.821 114.574 135.94 115.27C137.04 115.952 138.199 116.301 139.414 115.959ZM137.315 107.375C138.222 107.12 139.005 106.994 139.825 107.502C140.661 108.02 140.912 108.618 141.171 109.625C141.708 111.704 140.935 113.834 139.032 114.398C138.11 114.675 137.356 114.791 136.522 114.272C135.686 113.753 135.436 113.155 135.176 112.149C134.917 111.142 134.718 109.714 135.186 108.81C135.654 107.905 136.394 107.649 137.315 107.375C137.329 107.371 137.299 107.38 137.315 107.375Z",fill:"#75C4FD"}),Vp("path",{d:"M308.981 78.7519C310.052 78.4043 311.158 78.7096 312.265 78.6613C313.655 78.6006 314.936 78.517 316.323 78.3531C319.497 77.9795 322.798 77.4906 325.984 77.3012C329.309 77.1025 332.514 76.8551 335.836 77.0295C338.809 77.1842 342.163 77.3405 345.105 77.7558C352.129 78.7468 359.331 79.0578 366.347 80.1158C372.252 81.008 377.93 82.1319 383.722 83.5644C385.925 84.0054 388.267 85.0754 389.126 85.3792C389.421 85.4833 389.37 85.8347 389.317 86.1595C389.306 86.2271 389.353 86.1146 389.317 86.1595C388.269 87.414 386.564 86.8124 385.259 86.4677C384.406 86.241 381.488 85.9494 381.011 85.9957C380.14 86.0815 379.277 86.014 379.656 87.2114C380.122 88.6824 382.391 89.7375 383.704 90.2419C385.883 91.0803 388.771 91.2561 390.845 92.4015C392.968 92.821 395.425 93.5002 397.022 93.9986C402.83 95.8103 407.806 98.8678 413.033 102.002C415.503 103.482 417.829 104.764 419.973 106.72C421.647 108.248 423.771 109.882 424.595 112.091C425.113 113.482 424.451 115.471 422.848 115.085C420.353 114.488 419.638 111.665 418.227 109.714C415.003 105.251 410.067 102.067 405.118 100.06C402.64 99.0556 399.803 98.729 397.204 98.1176C394.411 97.4613 391.597 97.0442 388.707 97.1736C385.646 97.3097 382.846 97.5534 379.819 98.0078C377.027 98.4264 374.252 98.4441 371.514 97.8441C368.766 97.2421 366.276 96.7553 363.6 95.9021C361.662 95.2848 359.013 94.5583 357.232 93.5247C355.699 92.6339 355.631 91.2381 357.241 90.186C359.87 88.4656 362.778 89.8021 365.546 90.3497C365.561 90.3527 365.532 90.3468 365.546 90.3497C367.858 90.804 369.649 90.098 371.923 89.3884C372.489 89.2128 373.255 89.0482 373.47 88.953C374.383 88.5432 375.895 87.8227 375.407 86.7394C374.868 85.5457 372.659 84.8846 371.55 84.4891C369.74 83.8428 368.053 82.9215 366.147 82.6743C365.654 82.6095 365.109 83.1606 364.6 83.1097C363.36 83.1121 361.769 83.348 360.543 83.418C357.43 83.5916 354.583 83.6228 351.464 83.4719C348.714 83.3377 346.432 82.8542 343.741 82.3102C340.773 81.7101 337.52 81.5879 334.471 81.5839C331.393 81.5811 328.6 81.7214 325.583 82.4181C322.758 83.0702 319.757 83.6198 316.887 84.0326C314.698 84.3481 312.467 84.6054 310.319 84.2137C309.079 83.9871 306.994 83.3394 306.461 81.9635C305.846 80.3659 307.736 79.1556 308.981 78.7519Z",fill:"url(#paint14_linear_1356_14057)"}),Vp("path",{d:"M242.269 242.95C242.295 242.947 242.244 242.955 242.269 242.95C244.934 242.606 247.53 241.858 250.2 241.574C253.133 241.264 256.006 240.56 258.906 239.982C263.26 239.117 268.026 238.52 272.254 237.097C274.429 236.365 276.067 235.298 278.251 234.592C280.361 233.909 283.058 233.12 285.216 232.652C289.317 231.764 293.049 231.66 297.016 230.198C301.109 228.69 305.088 226.673 308.819 224.409C312.645 222.086 316.282 219.769 320.622 218.62C322.381 218.154 323.919 218.219 325.65 218.886C327.016 219.413 327.739 220.337 327.196 221.79C326.557 223.504 324.659 224.7 323.131 225.423C320.854 226.5 319.53 227.184 317.134 227.927C314.619 228.707 311.888 229.24 309.395 230.083C308.226 230.947 307.17 232.522 306.105 233.501C303.996 235.441 301.666 237.03 298.945 237.996C292.934 240.129 286.354 238.602 280.183 239.056C279.661 239.095 279.162 239.442 278.635 239.487C275.592 240.135 272.2 240.63 269.156 241.294C264.546 242.299 260.456 243.409 255.808 244.179C251.971 244.814 243.815 245.854 243.815 245.854L242.074 245.505C240.575 245.281 240.751 243.152 242.269 242.95Z",fill:"url(#paint15_linear_1356_14057)"}),Vp("path",{d:"M432.985 171.626C438.212 165.465 445.109 153.64 442.906 144.649C442.162 137.999 433.671 132.912 424.963 135.518C420.16 136.957 416.435 142.146 419.724 144.498C420.656 145.164 422.187 145.591 423.391 145.969C434.204 149.375 434.925 162.538 425.069 169.683C421.087 172.569 416.347 174.292 411.914 176.719C400.151 183.162 399.887 196.847 387.7 202.712C382.326 205.298 375.761 206.838 370.297 209.275C359.98 213.88 352.555 221.733 342.241 226.341C337.225 228.584 330.266 231.632 323.483 234.12C321.475 234.855 321.999 237.058 324.056 236.46C324.098 236.449 324.017 236.474 324.056 236.46C329.079 234.971 334.437 233.161 339.331 231.33C352.278 226.48 365.28 220.971 377.43 214.775C401.78 202.367 416.881 190.609 432.985 171.626Z",fill:"url(#paint16_linear_1356_14057)"}),Vp("path",{d:"M343.644 241.104C348.002 234.144 357.126 232.455 364.343 231.134C368.176 230.431 372.406 229.878 376.137 228.662C380.691 227.175 384.558 224.095 388.327 221.077C389.452 220.177 391.204 218.466 392.393 217.436C393.185 216.748 393.644 216.026 394.33 215.225C396 213.275 399.599 209.812 401.687 208.16C403.263 206.914 407.779 204.758 408.259 207.986C408.611 210.359 406.379 213.087 404.961 214.747C402.224 217.953 398.998 221.079 395.475 223.243C391.749 225.531 387.701 227.439 383.674 229.051C381.672 229.853 379.519 230.073 377.486 230.785C376.001 231.307 374.486 232.236 373.037 232.866C371.034 233.738 368.99 234.28 367.041 235.38C364.436 236.849 361.782 238.783 359.108 240.105C356.331 241.477 353.823 242.691 350.791 243.27C348.6 243.687 345.501 243.641 343.836 241.884C343.526 241.554 343.389 241.51 343.644 241.104Z",fill:"url(#paint17_linear_1356_14057)"}),Vp("path",{d:"M190.163 273.219C222.905 268.849 232.64 262.943 213.962 259.057C195.285 255.172 187.5 262.08 188.434 266.2C189.366 270.32 180.381 271.326 169.286 272.39C158.193 273.454 157.141 276.354 190.163 273.219Z",fill:"url(#paint18_linear_1356_14057)"}),Vp("path",{d:"M295.952 95.4242L241.395 135.226L251.54 111.77L295.952 95.4242Z",fill:"#E17726",stroke:"#E17726","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M170.111 95.4242L224.181 135.598L214.522 111.77L170.111 95.4242Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M276.309 187.712L261.793 209.576L292.876 218.014L301.78 188.189L276.309 187.712Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M164.336 188.189L173.186 218.014L204.215 209.576L189.753 187.712L164.336 188.189Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M202.542 150.776L193.908 163.618L224.667 164.998L223.642 132.36L202.542 150.776Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M263.52 150.775L242.097 131.989L241.395 164.998L272.154 163.618L263.52 150.775Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M204.215 209.576L222.832 200.714L206.805 188.402L204.215 209.576Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M243.23 200.714L261.793 209.576L259.257 188.402L243.23 200.714Z",fill:"#E27625",stroke:"#E27625","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M261.793 209.576L243.23 200.714L244.741 212.601L244.579 217.643L261.793 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M204.215 209.576L221.483 217.643L221.375 212.601L222.832 200.714L204.215 209.576Z",fill:"#D5BFB2",stroke:"#D5BFB2","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M221.807 180.547L206.373 176.09L217.274 171.154L221.807 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M244.255 180.547L248.788 171.154L259.742 176.09L244.255 180.547Z",fill:"#233447",stroke:"#233447","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M204.215 209.576L206.913 187.712L189.753 188.189L204.215 209.576Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M259.149 187.712L261.793 209.576L276.309 188.189L259.149 187.712Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M272.154 163.618L241.395 164.998L244.255 180.547L248.788 171.154L259.742 176.09L272.154 163.618Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M206.373 176.09L217.274 171.154L221.807 180.547L224.667 164.998L193.908 163.618L206.373 176.09Z",fill:"#CC6228",stroke:"#CC6228","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M193.908 163.618L206.805 188.402L206.373 176.09L193.908 163.618Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M259.743 176.09L259.257 188.402L272.154 163.618L259.743 176.09Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M224.667 164.998L221.807 180.548L225.422 198.909L226.232 174.71L224.667 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M241.395 164.998L239.884 174.657L240.64 198.909L244.255 180.548L241.395 164.998Z",fill:"#E27525",stroke:"#E27525","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M244.255 180.547L240.64 198.909L243.23 200.714L259.257 188.402L259.743 176.09L244.255 180.547Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M206.373 176.09L206.805 188.402L222.832 200.714L225.422 198.909L221.807 180.547L206.373 176.09Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M244.579 217.643L244.741 212.601L243.338 211.434H222.724L221.375 212.601L221.483 217.643L204.215 209.576L210.259 214.459L222.508 222.791H243.5L255.803 214.459L261.793 209.576L244.579 217.643Z",fill:"#C0AC9D",stroke:"#C0AC9D","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M243.23 200.714L240.64 198.909H225.422L222.832 200.714L221.375 212.601L222.724 211.434H243.338L244.741 212.601L243.23 200.714Z",fill:"#161616",stroke:"#161616","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M298.272 137.827L302.859 115.856L295.952 95.4242L243.23 133.899L263.52 150.775L292.174 159.001L298.488 151.731L295.736 149.767L300.107 145.84L296.761 143.293L301.132 140.002L298.272 137.827Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M163.203 115.856L167.844 137.827L164.876 140.002L169.301 143.293L165.955 145.84L170.326 149.767L167.574 151.731L173.888 159.001L202.542 150.775L222.832 133.899L170.11 95.4242L163.203 115.856Z",fill:"#763E1A",stroke:"#763E1A","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M292.175 159.001L263.52 150.775L272.154 163.618L259.257 188.402L276.309 188.189H301.78L292.175 159.001Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M202.542 150.775L173.888 159.001L164.336 188.189H189.753L206.805 188.402L193.908 163.618L202.542 150.775Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("path",{d:"M241.395 164.998L243.23 133.9L251.54 111.77H214.522L222.832 133.9L224.667 164.998L225.368 174.763L225.422 198.909H240.64L240.694 174.763L241.395 164.998Z",fill:"#F5841F",stroke:"#F5841F","stroke-width":"0.94513","stroke-linecap":"round","stroke-linejoin":"round"}),Vp("defs",null,Vp("linearGradient",{id:"paint0_linear_1356_14057",x1:"335.991",y1:"250.487",x2:"303.873",y2:"266.801",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint1_linear_1356_14057",x1:"276.993",y1:"303.722",x2:"205.254",y2:"401.574",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint2_linear_1356_14057",x1:"271.074",y1:"119.924",x2:"553.077",y2:"104.53",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint3_linear_1356_14057",x1:"264.209",y1:"91.0943",x2:"357.834",y2:"72.8792",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint4_linear_1356_14057",x1:"212.46",y1:"121.997",x2:"92.6119",y2:"183.406",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint5_linear_1356_14057",x1:"23.0498",y1:"204.411",x2:"161.86",y2:"163.003",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint6_linear_1356_14057",x1:"78.8647",y1:"240.375",x2:"74.9655",y2:"241.328",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint7_linear_1356_14057",x1:"382.349",y1:"181.971",x2:"378.45",y2:"182.925",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint8_linear_1356_14057",x1:"349.889",y1:"244.583",x2:"345.99",y2:"245.537",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint9_linear_1356_14057",x1:"142.262",y1:"279.808",x2:"138.362",y2:"280.762",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint10_linear_1356_14057",x1:"123.305",y1:"99.0746",x2:"119.406",y2:"100.028",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint11_linear_1356_14057",x1:"371.818",y1:"156.617",x2:"367.919",y2:"157.571",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint12_linear_1356_14057",x1:"385.281",y1:"242.958",x2:"381.382",y2:"243.911",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint13_linear_1356_14057",x1:"367.125",y1:"37.5052",x2:"360.843",y2:"38.8076",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"1","stop-color":"#75C3FC"})),Vp("linearGradient",{id:"paint14_linear_1356_14057",x1:"300.182",y1:"91.321",x2:"479.464",y2:"104.041",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint15_linear_1356_14057",x1:"363.434",y1:"201.232",x2:"102.977",y2:"302.269",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})),Vp("linearGradient",{id:"paint16_linear_1356_14057",x1:"447.962",y1:"165.159",x2:"313.049",y2:"197.95",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint17_linear_1356_14057",x1:"410.211",y1:"215.859",x2:"341.378",y2:"232.788",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#75C3FC"}),Vp("stop",{offset:"0.0929","stop-color":"#81C2F6"}),Vp("stop",{offset:"1","stop-color":"#F0B8BD"})),Vp("linearGradient",{id:"paint18_linear_1356_14057",x1:"222.282",y1:"258.986",x2:"162.257",y2:"273.774",gradientUnits:"userSpaceOnUse"},Vp("stop",{"stop-color":"#FFE466"}),Vp("stop",{offset:"1","stop-color":"#FFAFEA"})))),gm=class{constructor(e){wp(this,e),this.close=Qp(this,"close",7),this.connectWithExtension=Qp(this,"connectWithExtension",7),this.link=void 0,this.sdkVersion=void 0,this.preferDesktop=void 0,this.tab=1,this.isDefaultTab=!0,this.translationsLoaded=!1,this.i18nInstance=new lm,this.setTab(this.preferDesktop?1:2)}async connectedCallback(){await this.i18nInstance.init({fallbackLng:"en"}),this.translationsLoaded=!0}onClose(e=!1){this.close.emit({shouldTerminate:e})}connectWithExtensionHandler(){this.connectWithExtension.emit()}setTab(e){this.tab=e,this.isDefaultTab=!1}disconnectedCallback(){this.onClose()}updatePreferDesktop(e){e?this.setTab(1):this.setTab(2)}render(){if(!this.translationsLoaded)return null;const e=e=>this.i18nInstance.t(e),t=this.sdkVersion,n=this.isDefaultTab?this.preferDesktop?1:2:this.tab,r=am(this.link,"svg",{ecc:"medium",scale:2});return Vp(Ig,{className:"select-modal"},Vp("div",{class:"backdrop",onClick:()=>this.onClose(!0)}),Vp("div",{class:"modal"},Vp("div",{class:"closeButtonContainer"},Vp("div",{class:"right"},Vp("span",{class:"closeButton",onClick:()=>this.onClose(!0)},Vp(Ug,null)))),Vp("div",{class:"logoContainer"},Vp(Fg,null)),Vp("div",null,Vp("div",{class:"tabcontainer"},Vp("div",{class:"flexContainer"},Vp("div",{onClick:()=>this.setTab(1),class:"tab flexItem "+(1===n?"tabactive":"")},e("DESKTOP")),Vp("div",{onClick:()=>this.setTab(2),class:"tab flexItem "+(2===n?"tabactive":"")},e("MOBILE")))),Vp("div",{style:{display:1===n?"none":"block"}},Vp("div",{class:"flexContainer"},Vp("div",{class:"flexItem",style:{textAlign:"center",marginTop:"4"}},Vp("div",{class:"center",id:"sdk-mm-qrcode",innerHTML:r}),Vp("div",{class:"connectMobileText"},e("SCAN_TO_CONNECT"),Vp("br",null),Vp("span",{class:"blue"},Vp("b",null,e("META_MASK_MOBILE_APP"))))))),Vp("div",{style:{display:2===n?"none":"block"}},Vp("div",{style:{display:"flex",justifyContent:"center",height:"300",marginTop:"-20"}},Vp(pm,null)),Vp("div",{class:"extensionLabel"},e("SELECT_MODAL.CRYPTO_TAKE_CONTROL_TEXT")),Vp("button",{class:"button",onClick:()=>this.connectWithExtensionHandler()},Vp(fm,null),Vp("span",{class:"installExtensionText"},e("CONNECT_WITH_EXTENSION"))))),Vp(Kg,{version:t})))}get el(){return Xp(this)}static get watchers(){return{preferDesktop:["updatePreferDesktop"]}}};gm.style=".flexContainer {\n display: flex;\n justify-content: center;\n align-items: center;\n flex-direction: row;\n}\n\n.flexItem {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem11 {\n flex: 11;\n justify-content: center;\n align-items: center;\n}\n\n.flexItem1 {\n flex: 1;\n justify-content: center;\n align-items: center;\n}\n\n.tab {\n padding: 8px;\n cursor: pointer;\n background-color: #F2F4F6;\n font-size: 12px;\n text-align: center;\n color: #24292E;\n}\n\n.tabcontainer {\n padding: 4px;\n background-color: #F2F4F6;\n border-radius: 8px;\n margin-bottom: 30px;\n margin-top: 30px;\n}\n\n.tabactive {\n background-color: white;\n -webkit-transition: background-color 300ms linear;\n -ms-transition: background-color 300ms linear;\n transition: background-color 300ms linear;\n border-radius: 8px;\n}\n\n.item {\n font-size: 12px;\n margin-bottom: 16px;\n border-radius: 8px;\n padding: 10px;\n border: 2px #F2F4F6 solid;\n color: #24292E;\n}\n\n.extensionLabel {\n font-style: normal;\n font-weight: bold;\n font-size: 14px;\n text-align: cetner;\n color: #24272A;\n}\n\n.notice {\n font-size: 12px;\n margin-left: 10px;\n margin-right: 10px;\n color: grey;\n}\n\n.button {\n margin-top: 41.5px;\n margin-bottom: 20px;\n width: 100%;\n display: flex;\n flex-direction: row;\n justify-content: center;\n align-items: center;\n padding: 12px 20px;\n background: #037DD6;\n border-radius: 32px;\n color: white;\n border: 0;\n font-size: 14px;\n cursor: pointer;\n}\n\n.backdrop {\n visibility: visible;\n position: fixed;\n top: 0;\n left: 0;\n right: 0;\n bottom: 0;\n width: 100%;\n z-index: 99998;\n background: rgba(0, 0, 0, 0.87);\n opacity: 0.3;\n}\n\n.modal {\n visibility: visible;\n position: fixed;\n left: 50%;\n transform: translate(-50%, -50%);\n z-index: 99999;\n background: white;\n padding: 20px;\n border-radius: 8px;\n top: 50%;\n max-width: 100%;\n width: 460px;\n min-width: 300px;\n box-shadow: rgba(0, 0, 0, 0.2) 0px 11px 15px -7px, rgba(0, 0, 0, 0.14) 0px 24px 38px 3px, rgba(0, 0, 0, 0.12) 0px 9px 46px 8px;\n -webkit-font-smoothing: antialiased;\n}\n\n.closeButton {\n color: #BBC0C5;\n cursor: pointer;\n}\n\n.logoContainer {\n margin-left: 24px;\n margin-right: 24px;\n margin-top: 24px;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.connectMobileText {\n font-size: 14px;\n color: black;\n margin-top: 28px;\n margin-bottom: 28px;\n line-height: 2;\n}\n\n.blue {\n color: #037DD6;\n font-weight: 700;\n}\n\n.installExtensionText {\n margin-left: 10px;\n}\n\n.center {\n display: flex;\n justify-content: center;\n align-items: center;\n}\n\n.right {\n display: flex;\n align-items: center;\n justify-content: right;\n}\n\n#sdk-mm-qrcode {\n svg {\n width: 50%;\n }\n}";var mm=Object.freeze({__proto__:null,mm_install_modal:um,mm_pending_modal:hm,mm_select_modal:gm});function ym(e,r){return t(this,void 0,void 0,(function*(){const t={};e.rpc&&Object.entries(e.rpc).forEach((([e,n])=>{const r=`0x${Number(e).toString(16)}`;t[r]=n}));const i=new gp({useDeeplink:!0,enableAnalytics:!1,dappMetadata:{name:e.appName,iconUrl:e.appLogoUrl},readonlyRPCMap:t});i.isInitialized()||(yield i.init());let o=vm(i,r);yield i.connect(),o||(o=vm(i,r));return yield n(o)}))}function vm(e,t){const n=e.getProvider();try{n.on("connect",t.connect),n.on("disconnect",t.disconnect),n.on("accountsChanged",t.accountsChanged),n.on("chainChanged",t.chainChanged),n.on("message",t.message)}catch(e){}return n}export{ym as default};