LavaPack.loadBundle([[3307,{"../constants":3296,"@babel/runtime/helpers/defineProperty":181,"@babel/runtime/helpers/interopRequireDefault":186},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");r.__esModule=!0,r.BlockchainMessage=r.ResponseMessage=r.TransportMessage=r.DeviceMessage=r.UiMessage=void 0;var s=n(e("@babel/runtime/helpers/defineProperty")),o=e("../constants");function i(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?i(Object(r),!0).forEach((function(t){(0,s.default)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}r.UiMessage=function(e,t){return{event:o.UI_EVENT,type:e,payload:t}};r.DeviceMessage=function(e,t){return{event:o.DEVICE_EVENT,type:e,payload:t}};r.TransportMessage=function(e,t){return{event:o.TRANSPORT_EVENT,type:e,payload:t.error?a(a({},t),{},{error:t.error.message,code:t.error.code}):t}};r.ResponseMessage=function(e,t,r){return void 0===r&&(r=null),{event:o.RESPONSE_EVENT,type:o.RESPONSE_EVENT,id:e,success:t,payload:t?r:{error:r.error.message,code:r.error.code}}};r.BlockchainMessage=function(e,t){return{event:o.BLOCKCHAIN_EVENT,type:e,payload:t}}}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/message/builder.js"}],[3308,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.__esModule=!0,r.errorMessage=r.parseMessage=void 0;r.parseMessage=function(e){var t={event:e.event,type:e.type,payload:e.payload};return"number"==typeof e.id&&(t.id=e.id),"boolean"==typeof e.success&&(t.success=e.success),t};r.errorMessage=function(e){return{success:!1,payload:{error:e.message,code:e.code}}}}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/message/index.js"}],[3309,{"@babel/runtime/helpers/defineProperty":181,"@babel/runtime/helpers/interopRequireDefault":186,"@metamask/eth-sig-util":1194},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault")(e("@babel/runtime/helpers/defineProperty"));function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}var o=e("@metamask/eth-sig-util");function i(e){switch(Object.prototype.toString.call(e)){case"[object Object]":var t=Object.keys(e).map((function(t){return[t,i(e[t])]}));return Object.fromEntries(t);case"[object Array]":return e.map((function(e){return i(e)}));case"[object BigInt]":return e.toString();default:return e}}t.exports=function(e,t){if(!t)throw new Error("Trezor: Only version 4 of typed data signing is supported");var r=o.SignTypedDataVersion.V4,a=o.TypedDataUtils.sanitizeData(e),c=a.types,l=a.primaryType,u=a.domain,d=a.message;return function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){(0,n.default)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({domain_separator_hash:o.TypedDataUtils.hashStruct("EIP712Domain",i(u),c,r).toString("hex"),message_hash:o.TypedDataUtils.hashStruct(l,i(d),c,r).toString("hex")},e)}}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/plugins/ethereum/typedData.js"}],[3310,{"../constants/iframe":3295,"../constants/popup":3298,"../constants/ui":3300,"../env/browser/networkUtils":3303,"../utils/deferred":3334,"./showPopupRequest":3311,"@babel/runtime/helpers/assertThisInitialized":176,"@babel/runtime/helpers/asyncToGenerator":177,"@babel/runtime/helpers/defineProperty":181,"@babel/runtime/helpers/inheritsLoose":185,"@babel/runtime/helpers/interopRequireDefault":186,"@babel/runtime/regenerator":205,events:1944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");r.__esModule=!0,r.default=void 0;var s=n(e("@babel/runtime/regenerator")),o=n(e("@babel/runtime/helpers/asyncToGenerator")),i=n(e("@babel/runtime/helpers/assertThisInitialized")),a=n(e("@babel/runtime/helpers/inheritsLoose")),c=n(e("@babel/runtime/helpers/defineProperty")),l=n(e("events")),u=y(e("../constants/popup")),d=y(e("../constants/iframe")),h=y(e("../constants/ui")),p=e("./showPopupRequest"),g=e("../env/browser/networkUtils"),f=e("../utils/deferred");function m(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(m=function(e){return e?r:t})(e)}function y(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=m(t);if(r&&r.has(e))return r.get(e);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var i=s?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(n,o,i):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}var b=function(e){function t(t){var r;return r=e.call(this)||this,(0,c.default)((0,i.default)(r),"requestTimeout",0),(0,c.default)((0,i.default)(r),"closeInterval",0),(0,c.default)((0,i.default)(r),"extensionTabId",0),r.settings=t,r.origin=(0,g.getOrigin)(t.popupSrc),r.handleMessage=r.handleMessage.bind((0,i.default)(r)),r.iframeHandshake=(0,f.create)(d.LOADED),"webextension"===r.settings.env&&(r.handleExtensionConnect=r.handleExtensionConnect.bind((0,i.default)(r)),r.handleExtensionMessage=r.handleExtensionMessage.bind((0,i.default)(r)),chrome.runtime.onConnect.addListener(r.handleExtensionConnect)),window.addEventListener("message",r.handleMessage,!1),r}(0,a.default)(t,e);var r=t.prototype;return r.request=function(e){var t=this;if(void 0===e&&(e=!1),this.locked)this._window&&("webextension"===this.settings.env?chrome.tabs.update(this._window.id,{active:!0}):this._window.focus());else{var r=this.open.bind(this);if(this.locked=!0,this.settings.supportedBrowser){var n=e||"webextension"===this.settings.env?1:850;this.requestTimeout=window.setTimeout((function(){t.requestTimeout=0,r(e)}),n)}else r()}},r.cancel=function(){this.close()},r.unlock=function(){this.locked=!1},r.open=function(e){var t=this,r=this.settings.popupSrc;this.settings.supportedBrowser?(this.popupPromise=(0,f.create)(u.LOADED),this.openWrapper(e?r+"#loading":r),this.closeInterval=window.setInterval((function(){t._window&&("webextension"===t.settings.env?chrome.tabs.get(t._window.id,(function(e){e||(t.close(),t.emit(u.CLOSED))})):t._window.closed&&(t.close(),t.emit(u.CLOSED)))}),500),this.openTimeout=window.setTimeout((function(){t.close(),(0,p.showPopupRequest)(t.open.bind(t),(function(){t.emit(u.CLOSED)}))}),3e3)):this.openWrapper(r+"#unsupported")},r.openWrapper=function(e){var t=this;"webextension"===this.settings.env?chrome.windows.getCurrent(null,(function(r){"normal"!==r.type?chrome.windows.create({url:e},(function(e){chrome.tabs.query({windowId:e.id,active:!0},(function(e){t._window=e[0]}))})):chrome.tabs.query({currentWindow:!0,active:!0},(function(r){t.extensionTabId=r[0].id,chrome.tabs.create({url:e,index:r[0].index+1},(function(e){t._window=e}))}))})):"electron"===this.settings.env?this._window=window.open(e,"modal"):(this._window=window.open("","_blank"),this._window&&(this._window.location.href=e))},r.handleExtensionConnect=function(e){"trezor-connect"===e.name&&(!this._window||this._window&&this._window.id!==e.sender.tab.id?e.disconnect():(window.clearTimeout(this.openTimeout),this.extensionPort=e,this.extensionPort.onMessage.addListener(this.handleExtensionMessage)))},r.handleExtensionMessage=function(e){var t=this;if(this.extensionPort){var r=this.extensionPort,n=e.data;if(n&&"object"==typeof n)if(n.type===u.ERROR){var s=n.payload&&"string"==typeof n.payload.error?n.payload.error:null;this.emit(u.CLOSED,s?"Popup error: "+s:null),this.close()}else n.type===u.LOADED?(this.popupPromise&&this.popupPromise.resolve(),this.iframeHandshake.promise.then((function(e){r.postMessage({type:u.INIT,payload:{settings:t.settings,useBroadcastChannel:e}})}))):n.type===u.EXTENSION_USB_PERMISSIONS?chrome.tabs.query({currentWindow:!0,active:!0},(function(e){chrome.tabs.create({url:"trezor-usb-permissions.html",index:e[0].index+1},(function(e){}))})):n.type===u.CLOSE_WINDOW&&(this.emit(u.CLOSED),this.close())}},r.handleMessage=function(e){var t=this,r=e.data;if((0,g.getOrigin)(e.origin)===this.origin&&r&&"object"==typeof r)if(r.type===d.LOADED){var n=!(!r.payload||"boolean"!=typeof r.payload.useBroadcastChannel)&&r.payload.useBroadcastChannel;this.iframeHandshake.resolve(n)}else if(r.type===u.BOOTSTRAP)window.clearTimeout(this.openTimeout);else if(r.type===u.ERROR&&this._window){var s=r.payload&&"string"==typeof r.payload.error?r.payload.error:null;this.emit(u.CLOSED,s?"Popup error: "+s:null),this.close()}else r.type===u.LOADED?(this.popupPromise&&this.popupPromise.resolve(),this.iframeHandshake.promise.then((function(e){t._window.postMessage({type:u.INIT,payload:{settings:t.settings,useBroadcastChannel:e}},t.origin)}))):r.type!==u.CANCEL_POPUP_REQUEST&&r.type!==h.CLOSE_UI_WINDOW||this.close()},r.close=function(){if(this.locked=!1,this.popupPromise=undefined,this.requestTimeout&&(window.clearTimeout(this.requestTimeout),this.requestTimeout=0),this.openTimeout&&(window.clearTimeout(this.openTimeout),this.openTimeout=0),this.closeInterval&&(window.clearInterval(this.closeInterval),this.closeInterval=0),this.extensionPort&&(this.extensionPort.disconnect(),this.extensionPort=null),this.extensionTabId&&(chrome.tabs.update(this.extensionTabId,{active:!0}),this.extensionTabId=0),this._window){if("webextension"===this.settings.env){chrome.runtime.lastError;chrome.tabs.remove(this._window.id,(function(){chrome.runtime.lastError}))}else this._window.close();this._window=null}},r.postMessage=function(){var e=(0,o.default)(s.default.mark((function e(t){var r=this;return s.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._window||t.type===h.REQUEST_UI_WINDOW||!this.openTimeout){e.next=4;break}return this.close(),(0,p.showPopupRequest)(this.open.bind(this),(function(){r.emit(u.CLOSED)})),e.abrupt("return");case 4:if(!this.popupPromise){e.next=7;break}return e.next=7,this.popupPromise.promise;case 7:this._window&&this._window.postMessage(t,this.origin);case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t}(l.default);r.default=b}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/popup/PopupManager.js"}],[3311,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.__esModule=!0,r.showPopupRequest=void 0;var n="TrezorConnectInteractionLayer",s='\n    <div class="trezorconnect-container" id="'+n+'">\n        <div class="trezorconnect-window">\n            <div class="trezorconnect-head">\n                <svg class="trezorconnect-logo" x="0px" y="0px" viewBox="0 0 163.7 41.9" width="78px" height="20px" preserveAspectRatio="xMinYMin meet">\n                    <polygon points="101.1,12.8 118.2,12.8 118.2,17.3 108.9,29.9 118.2,29.9 118.2,35.2 101.1,35.2 101.1,30.7 110.4,18.1 101.1,18.1"/>\n                    <path d="M158.8,26.9c2.1-0.8,4.3-2.9,4.3-6.6c0-4.5-3.1-7.4-7.7-7.4h-10.5v22.3h5.8v-7.5h2.2l4.1,7.5h6.7L158.8,26.9z M154.7,22.5 h-4V18h4c1.5,0,2.5,0.9,2.5,2.2C157.2,21.6,156.2,22.5,154.7,22.5z"/>\n                    <path d="M130.8,12.5c-6.8,0-11.6,4.9-11.6,11.5s4.9,11.5,11.6,11.5s11.7-4.9,11.7-11.5S137.6,12.5,130.8,12.5z M130.8,30.3 c-3.4,0-5.7-2.6-5.7-6.3c0-3.8,2.3-6.3,5.7-6.3c3.4,0,5.8,2.6,5.8,6.3C136.6,27.7,134.2,30.3,130.8,30.3z"/>\n                    <polygon points="82.1,12.8 98.3,12.8 98.3,18 87.9,18 87.9,21.3 98,21.3 98,26.4 87.9,26.4 87.9,30 98.3,30 98.3,35.2 82.1,35.2 "/>\n                    <path d="M24.6,9.7C24.6,4.4,20,0,14.4,0S4.2,4.4,4.2,9.7v3.1H0v22.3h0l14.4,6.7l14.4-6.7h0V12.9h-4.2V9.7z M9.4,9.7 c0-2.5,2.2-4.5,5-4.5s5,2,5,4.5v3.1H9.4V9.7z M23,31.5l-8.6,4l-8.6-4V18.1H23V31.5z"/>\n                    <path d="M79.4,20.3c0-4.5-3.1-7.4-7.7-7.4H61.2v22.3H67v-7.5h2.2l4.1,7.5H80l-4.9-8.3C77.2,26.1,79.4,24,79.4,20.3z M71,22.5h-4V18 h4c1.5,0,2.5,0.9,2.5,2.2C73.5,21.6,72.5,22.5,71,22.5z"/>\n                    <polygon points="40.5,12.8 58.6,12.8 58.6,18.1 52.4,18.1 52.4,35.2 46.6,35.2 46.6,18.1 40.5,18.1 "/>\n                </svg>\n                <div class="trezorconnect-close">\n                    <svg x="0px" y="0px" viewBox="24 24 60 60" width="24px" height="24px" preserveAspectRatio="xMinYMin meet">\n                        <polygon class="st0" points="40,67.9 42.1,70 55,57.1 67.9,70 70,67.9 57.1,55 70,42.1 67.9,40 55,52.9 42.1,40 40,42.1 52.9,55 "/>\n                    </svg>\n                </div>\n            </div>\n            <div class="trezorconnect-body">\n                <h3>Popup was blocked</h3>\n                <p>Please click to “Continue” to open popup manually</p>\n                <button class="trezorconnect-open">Continue</button>\n            </div>\n        </div>\n    </div>\n';r.showPopupRequest=function(e,t){if(!document.getElementById(n)){var r=document.createElement("div");r.id=n,r.className="trezorconnect-container",r.innerHTML=s,document.body&&document.body.appendChild(r),r.getElementsByClassName("trezorconnect-open")[0].onclick=function(){e(),document.body&&document.body.removeChild(r)},r.getElementsByClassName("trezorconnect-close")[0].onclick=function(){t(),document.body&&document.body.removeChild(r)}}}}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/popup/showPopupRequest.js"}],[3312,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/account.js"}],[3313,{"../constants":3296,"./account":3312,"./backend/blockchain":3314,"./events":3316,"./misc":3318,"./networks/binance":3319,"./networks/bitcoin":3320,"./networks/cardano":3321,"./networks/coinInfo":3322,"./networks/eos":3323,"./networks/ethereum":3324,"./networks/nem":3325,"./networks/ripple":3326,"./networks/stellar":3327,"./networks/tezos":3328,"./params":3329,"./trezor/device":3330,"./trezor/management":3331,"./trezor/protobuf":3332},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){s(e("../constants")),s(e("./params")),s(e("./trezor/device")),s(e("./trezor/management")),s(e("./trezor/protobuf")),s(e("./account")),s(e("./networks/bitcoin")),s(e("./networks/binance")),s(e("./networks/cardano")),s(e("./networks/coinInfo")),s(e("./networks/eos")),s(e("./networks/ethereum")),s(e("./networks/nem")),s(e("./networks/ripple")),s(e("./networks/stellar")),s(e("./networks/tezos")),s(e("./misc")),s(e("./events")),s(e("./backend/blockchain"));function n(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(n=function(e){return e?r:t})(e)}function s(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=n(t);if(r&&r.has(e))return r.get(e);var s={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&Object.prototype.hasOwnProperty.call(e,i)){var a=o?Object.getOwnPropertyDescriptor(e,i):null;a&&(a.get||a.set)?Object.defineProperty(s,i,a):s[i]=e[i]}return s.default=e,r&&r.set(e,s),s}}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/api.js"}],[3314,{"../../constants":3296},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){e("../../constants")}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/backend/blockchain.js"}],[3315,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/backend/transactions.js"}],[3316,{"../constants":3296},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){e("../constants")}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/events.js"}],[3317,{"./account":3312,"./api":3313,"./backend/blockchain":3314,"./backend/transactions":3315,"./events":3316,"./misc":3318,"./networks/binance":3319,"./networks/bitcoin":3320,"./networks/cardano":3321,"./networks/coinInfo":3322,"./networks/eos":3323,"./networks/ethereum":3324,"./networks/nem":3325,"./networks/ripple":3326,"./networks/stellar":3327,"./networks/tezos":3328,"./params":3329,"./trezor/device":3330,"./trezor/management":3331},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.__esModule=!0;var n=e("./api");Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||(r[e]=n[e]))}));var s=e("./events");Object.keys(s).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===s[e]||(r[e]=s[e]))}));var o=e("./misc");Object.keys(o).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===o[e]||(r[e]=o[e]))}));var i=e("./params");Object.keys(i).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===i[e]||(r[e]=i[e]))}));var a=e("./account");Object.keys(a).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===a[e]||(r[e]=a[e]))}));var c=e("./trezor/device");Object.keys(c).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===c[e]||(r[e]=c[e]))}));var l=e("./trezor/management");Object.keys(l).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===l[e]||(r[e]=l[e]))}));var u=e("./networks/bitcoin");Object.keys(u).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===u[e]||(r[e]=u[e]))}));var d=e("./networks/binance");Object.keys(d).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===d[e]||(r[e]=d[e]))}));var h=e("./networks/cardano");Object.keys(h).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===h[e]||(r[e]=h[e]))}));var p=e("./networks/coinInfo");Object.keys(p).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===p[e]||(r[e]=p[e]))}));var g=e("./networks/eos");Object.keys(g).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===g[e]||(r[e]=g[e]))}));var f=e("./networks/ethereum");Object.keys(f).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===f[e]||(r[e]=f[e]))}));var m=e("./networks/nem");Object.keys(m).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===m[e]||(r[e]=m[e]))}));var y=e("./networks/ripple");Object.keys(y).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===y[e]||(r[e]=y[e]))}));var b=e("./networks/stellar");Object.keys(b).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===b[e]||(r[e]=b[e]))}));var v=e("./networks/tezos");Object.keys(v).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===v[e]||(r[e]=v[e]))}));var w=e("./backend/blockchain");Object.keys(w).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===w[e]||(r[e]=w[e]))}));var S=e("./backend/transactions");Object.keys(S).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===S[e]||(r[e]=S[e]))}))}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/index.js"}],[3318,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/misc.js"}],[3319,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/binance.js"}],[3320,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/bitcoin.js"}],[3321,{"../trezor/protobuf":3332},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.__esModule=!0,r.CardanoTxWitnessType=r.CardanoTxSigningMode=r.CardanoPoolRelayType=r.CardanoNativeScriptHashDisplayFormat=r.CardanoNativeScriptType=r.CardanoCertificateType=r.CardanoAddressType=void 0;var n=e("../trezor/protobuf");r.CardanoAddressType=n.Enum_CardanoAddressType,r.CardanoCertificateType=n.Enum_CardanoCertificateType,r.CardanoNativeScriptType=n.Enum_CardanoNativeScriptType,r.CardanoNativeScriptHashDisplayFormat=n.Enum_CardanoNativeScriptHashDisplayFormat,r.CardanoPoolRelayType=n.Enum_CardanoPoolRelayType,r.CardanoTxSigningMode=n.Enum_CardanoTxSigningMode,r.CardanoTxWitnessType=n.Enum_CardanoTxWitnessType}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/cardano.js"}],[3322,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/coinInfo.js"}],[3323,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/eos.js"}],[3324,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/ethereum.js"}],[3325,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/nem.js"}],[3326,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/ripple.js"}],[3327,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/stellar.js"}],[3328,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/networks/tezos.js"}],[3329,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/params.js"}],[3330,{"../../constants":3296},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){e("../../constants")}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/trezor/device.js"}],[3331,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/trezor/management.js"}],[3332,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.__esModule=!0,r.Enum_TezosBallotType=r.Enum_TezosContractType=r.Enum_StellarSignerType=r.Enum_StellarMemoType=r.Enum_StellarAssetType=r.Enum_NEMImportanceTransferMode=r.Enum_NEMModificationType=r.Enum_NEMSupplyChangeType=r.Enum_NEMMosaicLevy=r.Enum_WordRequestType=r.Enum_RecoveryDeviceType=r.Enum_SdProtectOperationType=r.Enum_Capability=r.Enum_SafetyCheckLevel=r.Enum_BackupType=r.Enum_EthereumDataType=r.Enum_PinMatrixRequestType=r.Enum_ButtonRequestType=r.Enum_FailureType=r.Enum_CardanoTxWitnessType=r.Enum_CardanoTxSigningMode=r.Enum_CardanoTxAuxiliaryDataSupplementType=r.Enum_CardanoPoolRelayType=r.Enum_CardanoCertificateType=r.Enum_CardanoNativeScriptHashDisplayFormat=r.Enum_CardanoNativeScriptType=r.Enum_CardanoAddressType=r.Enum_CardanoDerivationType=r.Enum_RequestType=r.Enum_AmountUnit=r.Enum_DecredStakingSpendType=r.Enum_OutputScriptType=r.Enum_InputScriptType=r.Enum_BinanceTimeInForce=r.Enum_BinanceOrderSide=r.Enum_BinanceOrderType=void 0;var n=Object.freeze({OT_UNKNOWN:0,MARKET:1,LIMIT:2,OT_RESERVED:3});r.Enum_BinanceOrderType=n;var s=Object.freeze({SIDE_UNKNOWN:0,BUY:1,SELL:2});r.Enum_BinanceOrderSide=s;var o=Object.freeze({TIF_UNKNOWN:0,GTE:1,TIF_RESERVED:2,IOC:3});r.Enum_BinanceTimeInForce=o;var i=Object.freeze({SPENDADDRESS:0,SPENDMULTISIG:1,EXTERNAL:2,SPENDWITNESS:3,SPENDP2SHWITNESS:4,SPENDTAPROOT:5});r.Enum_InputScriptType=i;var a=Object.freeze({PAYTOADDRESS:0,PAYTOSCRIPTHASH:1,PAYTOMULTISIG:2,PAYTOOPRETURN:3,PAYTOWITNESS:4,PAYTOP2SHWITNESS:5,PAYTOTAPROOT:6});r.Enum_OutputScriptType=a;var c=Object.freeze({SSGen:0,SSRTX:1});r.Enum_DecredStakingSpendType=c;var l=Object.freeze({BITCOIN:0,MILLIBITCOIN:1,MICROBITCOIN:2,SATOSHI:3});r.Enum_AmountUnit=l;var u=Object.freeze({TXINPUT:0,TXOUTPUT:1,TXMETA:2,TXFINISHED:3,TXEXTRADATA:4,TXORIGINPUT:5,TXORIGOUTPUT:6});r.Enum_RequestType=u;var d=Object.freeze({LEDGER:0,ICARUS:1,ICARUS_TREZOR:2});r.Enum_CardanoDerivationType=d;var h=Object.freeze({BASE:0,BASE_SCRIPT_KEY:1,BASE_KEY_SCRIPT:2,BASE_SCRIPT_SCRIPT:3,POINTER:4,POINTER_SCRIPT:5,ENTERPRISE:6,ENTERPRISE_SCRIPT:7,BYRON:8,REWARD:14,REWARD_SCRIPT:15});r.Enum_CardanoAddressType=h;var p=Object.freeze({PUB_KEY:0,ALL:1,ANY:2,N_OF_K:3,INVALID_BEFORE:4,INVALID_HEREAFTER:5});r.Enum_CardanoNativeScriptType=p;var g=Object.freeze({HIDE:0,BECH32:1,POLICY_ID:2});r.Enum_CardanoNativeScriptHashDisplayFormat=g;var f=Object.freeze({STAKE_REGISTRATION:0,STAKE_DEREGISTRATION:1,STAKE_DELEGATION:2,STAKE_POOL_REGISTRATION:3});r.Enum_CardanoCertificateType=f;var m=Object.freeze({SINGLE_HOST_IP:0,SINGLE_HOST_NAME:1,MULTIPLE_HOST_NAME:2});r.Enum_CardanoPoolRelayType=m;var y=Object.freeze({NONE:0,CATALYST_REGISTRATION_SIGNATURE:1});r.Enum_CardanoTxAuxiliaryDataSupplementType=y;var b=Object.freeze({ORDINARY_TRANSACTION:0,POOL_REGISTRATION_AS_OWNER:1,MULTISIG_TRANSACTION:2});r.Enum_CardanoTxSigningMode=b;var v=Object.freeze({BYRON_WITNESS:0,SHELLEY_WITNESS:1});r.Enum_CardanoTxWitnessType=v;var w=Object.freeze({Failure_UnexpectedMessage:1,Failure_ButtonExpected:2,Failure_DataError:3,Failure_ActionCancelled:4,Failure_PinExpected:5,Failure_PinCancelled:6,Failure_PinInvalid:7,Failure_InvalidSignature:8,Failure_ProcessError:9,Failure_NotEnoughFunds:10,Failure_NotInitialized:11,Failure_PinMismatch:12,Failure_WipeCodeMismatch:13,Failure_InvalidSession:14,Failure_FirmwareError:99});r.Enum_FailureType=w;var S=Object.freeze({ButtonRequest_Other:1,ButtonRequest_FeeOverThreshold:2,ButtonRequest_ConfirmOutput:3,ButtonRequest_ResetDevice:4,ButtonRequest_ConfirmWord:5,ButtonRequest_WipeDevice:6,ButtonRequest_ProtectCall:7,ButtonRequest_SignTx:8,ButtonRequest_FirmwareCheck:9,ButtonRequest_Address:10,ButtonRequest_PublicKey:11,ButtonRequest_MnemonicWordCount:12,ButtonRequest_MnemonicInput:13,_Deprecated_ButtonRequest_PassphraseType:14,ButtonRequest_UnknownDerivationPath:15,ButtonRequest_RecoveryHomepage:16,ButtonRequest_Success:17,ButtonRequest_Warning:18,ButtonRequest_PassphraseEntry:19,ButtonRequest_PinEntry:20});r.Enum_ButtonRequestType=S;var T=Object.freeze({PinMatrixRequestType_Current:1,PinMatrixRequestType_NewFirst:2,PinMatrixRequestType_NewSecond:3,PinMatrixRequestType_WipeCodeFirst:4,PinMatrixRequestType_WipeCodeSecond:5});r.Enum_PinMatrixRequestType=T;var k=Object.freeze({UINT:1,INT:2,BYTES:3,STRING:4,BOOL:5,ADDRESS:6,ARRAY:7,STRUCT:8});r.Enum_EthereumDataType=k;var C=Object.freeze({Bip39:0,Slip39_Basic:1,Slip39_Advanced:2});r.Enum_BackupType=C;var _=Object.freeze({Strict:0,PromptAlways:1,PromptTemporarily:2});r.Enum_SafetyCheckLevel=_;var E=Object.freeze({Capability_Bitcoin:1,Capability_Bitcoin_like:2,Capability_Binance:3,Capability_Cardano:4,Capability_Crypto:5,Capability_EOS:6,Capability_Ethereum:7,Capability_Lisk:8,Capability_Monero:9,Capability_NEM:10,Capability_Ripple:11,Capability_Stellar:12,Capability_Tezos:13,Capability_U2F:14,Capability_Shamir:15,Capability_ShamirGroups:16,Capability_PassphraseEntry:17});r.Enum_Capability=E;var M=Object.freeze({DISABLE:0,ENABLE:1,REFRESH:2});r.Enum_SdProtectOperationType=M;var A=Object.freeze({RecoveryDeviceType_ScrambledWords:0,RecoveryDeviceType_Matrix:1});r.Enum_RecoveryDeviceType=A;var P=Object.freeze({WordRequestType_Plain:0,WordRequestType_Matrix9:1,WordRequestType_Matrix6:2});r.Enum_WordRequestType=P;var I=Object.freeze({MosaicLevy_Absolute:1,MosaicLevy_Percentile:2});r.Enum_NEMMosaicLevy=I;var N=Object.freeze({SupplyChange_Increase:1,SupplyChange_Decrease:2});r.Enum_NEMSupplyChangeType=N;var O=Object.freeze({CosignatoryModification_Add:1,CosignatoryModification_Delete:2});r.Enum_NEMModificationType=O;var R=Object.freeze({ImportanceTransfer_Activate:1,ImportanceTransfer_Deactivate:2});r.Enum_NEMImportanceTransferMode=R;var x=Object.freeze({NATIVE:0,ALPHANUM4:1,ALPHANUM12:2});r.Enum_StellarAssetType=x;var L=Object.freeze({NONE:0,TEXT:1,ID:2,HASH:3,RETURN:4});r.Enum_StellarMemoType=L;var D=Object.freeze({ACCOUNT:0,PRE_AUTH:1,HASH:2});r.Enum_StellarSignerType=D;var j=Object.freeze({Implicit:0,Originated:1});r.Enum_TezosContractType=j;var U=Object.freeze({Yay:0,Nay:1,Pass:2});r.Enum_TezosBallotType=U}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/types/trezor/protobuf.js"}],[3333,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.__esModule=!0,r.getLog=r.enableLogByPrefix=r.enableLog=r.initLog=void 0;var n={DescriptorStream:"color: #77ab59",DeviceList:"color: #36802d",Device:"color: #bada55",Core:"color: #c9df8a",IFrame:"color: #FFFFFF; background: #f4a742;",Popup:"color: #f48a00"},s=function(){function e(e,t){this.prefix=e,this.enabled=t,this.messages=[],this.css=n[e]||"color: #000000; background: #FFFFFF;"}var t=e.prototype;return t.addMessage=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),s=2;s<r;s++)n[s-2]=arguments[s];this.messages.push({level:e,prefix:t,message:n,timestamp:(new Date).getTime()}),this.messages.length>100&&this.messages.shift()},t.log=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n;(this.addMessage.apply(this,["log",this.prefix].concat(t)),this.enabled)&&(n=console).log.apply(n,[this.prefix].concat(t))},t.error=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n;(this.addMessage.apply(this,["error",this.prefix].concat(t)),this.enabled)&&(n=console).error.apply(n,[this.prefix].concat(t))},t.warn=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n;(this.addMessage.apply(this,["warn",this.prefix].concat(t)),this.enabled)&&(n=console).warn.apply(n,[this.prefix].concat(t))},t.debug=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n;(this.addMessage.apply(this,["debug",this.prefix].concat(t)),this.enabled)&&(n=console).log.apply(n,["%c"+this.prefix,this.css].concat(t))},e}(),o={};r.initLog=function(e,t){var r=new s(e,!!t);return o[e]=r,r};r.enableLog=function(e){Object.keys(o).forEach((function(t){o[t].enabled=e}))};r.enableLogByPrefix=function(e,t){o[e]&&(o[e].enabled=t)};r.getLog=function(){var e=[];return Object.keys(o).forEach((function(t){e=e.concat(o[t].messages)})),e.sort((function(e,t){return e.timestamp-t.timestamp})),e}}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/utils/debug.js"}],[3334,{"@babel/runtime/helpers/asyncToGenerator":177,"@babel/runtime/helpers/interopRequireDefault":186,"@babel/runtime/regenerator":205},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=e("@babel/runtime/helpers/interopRequireDefault");r.__esModule=!0,r.create=function(e,t){var r,n=function(e){},i=function(e){},a=new Promise(function(){var t=(0,o.default)(s.default.mark((function t(o,a){return s.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o,i=a,"function"!=typeof e){t.next=11;break}return t.prev=3,t.next=6,e();case 6:t.next=11;break;case 8:t.prev=8,t.t0=t.catch(3),a(t.t0);case 11:"string"==typeof e&&(r=e);case 12:case"end":return t.stop()}}),t,null,[[3,8]])})));return function(e,r){return t.apply(this,arguments)}}());return{id:r,device:t,resolve:n,reject:i,promise:a}},r.createAsync=function(e){var t=function(e){},r=function(e){},n=new Promise((function(e,n){t=e,r=n})),i=function(){var t=(0,o.default)(s.default.mark((function t(){return s.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e();case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return{resolve:t,reject:r,promise:n,run:function(){return i(),n}}},r.resolveTimeoutPromise=function(e,t){return new Promise((function(r){setTimeout((function(){r(t)}),e)}))},r.rejectTimeoutPromise=void 0;var s=n(e("@babel/runtime/regenerator")),o=n(e("@babel/runtime/helpers/asyncToGenerator"));r.rejectTimeoutPromise=function(e,t){return new Promise((function(r,n){setTimeout((function(){n(t)}),e)}))}}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/utils/deferred.js"}],[3335,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.__esModule=!0,r.default=void 0;var n=function(e,t,r){var n=e||".trezor-webusb-button",s=document.querySelectorAll(n),o=t+"?"+Date.now();s.forEach((function(e){if(e.getElementsByTagName("iframe").length<1){var t=e.getBoundingClientRect(),n=document.createElement("iframe");n.frameBorder="0",n.width=Math.round(t.width)+"px",n.height=Math.round(t.height)+"px",n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.zIndex="1",n.setAttribute("allow","usb"),n.setAttribute("scrolling","no"),n.onload=function(){n.contentWindow.postMessage({},r)},n.src=o,e.append(n)}}))};r.default=n}}},{package:"eth-trezor-keyring>trezor-connect",file:"node_modules/trezor-connect/lib/webusb/button.js"}],[3337,{buffer:1942},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(e){(function(){var r,n;r=this,n=function(){var t={};function r(e){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(e))throw new TypeError("invalid encoding")}return t.decodeUTF8=function(e){if("string"!=typeof e)throw new TypeError("expected string");var t,r=unescape(encodeURIComponent(e)),n=new Uint8Array(r.length);for(t=0;t<r.length;t++)n[t]=r.charCodeAt(t);return n},t.encodeUTF8=function(e){var t,r=[];for(t=0;t<e.length;t++)r.push(String.fromCharCode(e[t]));return decodeURIComponent(escape(r.join("")))},"undefined"==typeof atob?void 0!==e.from?(t.encodeBase64=function(t){return e.from(t).toString("base64")},t.decodeBase64=function(t){return r(t),new Uint8Array(Array.prototype.slice.call(e.from(t,"base64"),0))}):(t.encodeBase64=function(t){return new e(t).toString("base64")},t.decodeBase64=function(t){return r(t),new Uint8Array(Array.prototype.slice.call(new e(t,"base64"),0))}):(t.encodeBase64=function(e){var t,r=[],n=e.length;for(t=0;t<n;t++)r.push(String.fromCharCode(e[t]));return btoa(r.join(""))},t.decodeBase64=function(e){r(e);var t,n=atob(e),s=new Uint8Array(n.length);for(t=0;t<n.length;t++)s[t]=n.charCodeAt(t);return s}),t},void 0!==t&&t.exports?t.exports=n():(r.nacl||(r.nacl={}),r.nacl.util=n())}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"eth-sig-util>tweetnacl-util",file:"node_modules/tweetnacl-util/nacl-util.js"}],[3338,{crypto:1942},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){!function(t){var r=function(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;t++)r[t]=e[t];return r},n=function(){throw new Error("no PRNG")},s=new Uint8Array(16),o=new Uint8Array(32);o[0]=9;var i=r(),a=r([1]),c=r([56129,1]),l=r([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),u=r([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),d=r([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),h=r([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),p=r([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function g(e,t,r,n){e[t]=r>>24&255,e[t+1]=r>>16&255,e[t+2]=r>>8&255,e[t+3]=255&r,e[t+4]=n>>24&255,e[t+5]=n>>16&255,e[t+6]=n>>8&255,e[t+7]=255&n}function f(e,t,r,n,s){var o,i=0;for(o=0;o<s;o++)i|=e[t+o]^r[n+o];return(1&i-1>>>8)-1}function m(e,t,r,n){return f(e,t,r,n,16)}function y(e,t,r,n){return f(e,t,r,n,32)}function b(e,t,r,n){!function(e,t,r,n){for(var s,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,l=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,g=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,m=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,y=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,S=o,T=i,k=a,C=c,_=l,E=u,M=d,A=h,P=p,I=g,N=f,O=m,R=y,x=b,L=v,D=w,j=0;j<20;j+=2)S^=(s=(R^=(s=(P^=(s=(_^=(s=S+R|0)<<7|s>>>25)+S|0)<<9|s>>>23)+_|0)<<13|s>>>19)+P|0)<<18|s>>>14,E^=(s=(T^=(s=(x^=(s=(I^=(s=E+T|0)<<7|s>>>25)+E|0)<<9|s>>>23)+I|0)<<13|s>>>19)+x|0)<<18|s>>>14,N^=(s=(M^=(s=(k^=(s=(L^=(s=N+M|0)<<7|s>>>25)+N|0)<<9|s>>>23)+L|0)<<13|s>>>19)+k|0)<<18|s>>>14,D^=(s=(O^=(s=(A^=(s=(C^=(s=D+O|0)<<7|s>>>25)+D|0)<<9|s>>>23)+C|0)<<13|s>>>19)+A|0)<<18|s>>>14,S^=(s=(C^=(s=(k^=(s=(T^=(s=S+C|0)<<7|s>>>25)+S|0)<<9|s>>>23)+T|0)<<13|s>>>19)+k|0)<<18|s>>>14,E^=(s=(_^=(s=(A^=(s=(M^=(s=E+_|0)<<7|s>>>25)+E|0)<<9|s>>>23)+M|0)<<13|s>>>19)+A|0)<<18|s>>>14,N^=(s=(I^=(s=(P^=(s=(O^=(s=N+I|0)<<7|s>>>25)+N|0)<<9|s>>>23)+O|0)<<13|s>>>19)+P|0)<<18|s>>>14,D^=(s=(L^=(s=(x^=(s=(R^=(s=D+L|0)<<7|s>>>25)+D|0)<<9|s>>>23)+R|0)<<13|s>>>19)+x|0)<<18|s>>>14;S=S+o|0,T=T+i|0,k=k+a|0,C=C+c|0,_=_+l|0,E=E+u|0,M=M+d|0,A=A+h|0,P=P+p|0,I=I+g|0,N=N+f|0,O=O+m|0,R=R+y|0,x=x+b|0,L=L+v|0,D=D+w|0,e[0]=S>>>0&255,e[1]=S>>>8&255,e[2]=S>>>16&255,e[3]=S>>>24&255,e[4]=T>>>0&255,e[5]=T>>>8&255,e[6]=T>>>16&255,e[7]=T>>>24&255,e[8]=k>>>0&255,e[9]=k>>>8&255,e[10]=k>>>16&255,e[11]=k>>>24&255,e[12]=C>>>0&255,e[13]=C>>>8&255,e[14]=C>>>16&255,e[15]=C>>>24&255,e[16]=_>>>0&255,e[17]=_>>>8&255,e[18]=_>>>16&255,e[19]=_>>>24&255,e[20]=E>>>0&255,e[21]=E>>>8&255,e[22]=E>>>16&255,e[23]=E>>>24&255,e[24]=M>>>0&255,e[25]=M>>>8&255,e[26]=M>>>16&255,e[27]=M>>>24&255,e[28]=A>>>0&255,e[29]=A>>>8&255,e[30]=A>>>16&255,e[31]=A>>>24&255,e[32]=P>>>0&255,e[33]=P>>>8&255,e[34]=P>>>16&255,e[35]=P>>>24&255,e[36]=I>>>0&255,e[37]=I>>>8&255,e[38]=I>>>16&255,e[39]=I>>>24&255,e[40]=N>>>0&255,e[41]=N>>>8&255,e[42]=N>>>16&255,e[43]=N>>>24&255,e[44]=O>>>0&255,e[45]=O>>>8&255,e[46]=O>>>16&255,e[47]=O>>>24&255,e[48]=R>>>0&255,e[49]=R>>>8&255,e[50]=R>>>16&255,e[51]=R>>>24&255,e[52]=x>>>0&255,e[53]=x>>>8&255,e[54]=x>>>16&255,e[55]=x>>>24&255,e[56]=L>>>0&255,e[57]=L>>>8&255,e[58]=L>>>16&255,e[59]=L>>>24&255,e[60]=D>>>0&255,e[61]=D>>>8&255,e[62]=D>>>16&255,e[63]=D>>>24&255}(e,t,r,n)}function v(e,t,r,n){!function(e,t,r,n){for(var s,o=255&n[0]|(255&n[1])<<8|(255&n[2])<<16|(255&n[3])<<24,i=255&r[0]|(255&r[1])<<8|(255&r[2])<<16|(255&r[3])<<24,a=255&r[4]|(255&r[5])<<8|(255&r[6])<<16|(255&r[7])<<24,c=255&r[8]|(255&r[9])<<8|(255&r[10])<<16|(255&r[11])<<24,l=255&r[12]|(255&r[13])<<8|(255&r[14])<<16|(255&r[15])<<24,u=255&n[4]|(255&n[5])<<8|(255&n[6])<<16|(255&n[7])<<24,d=255&t[0]|(255&t[1])<<8|(255&t[2])<<16|(255&t[3])<<24,h=255&t[4]|(255&t[5])<<8|(255&t[6])<<16|(255&t[7])<<24,p=255&t[8]|(255&t[9])<<8|(255&t[10])<<16|(255&t[11])<<24,g=255&t[12]|(255&t[13])<<8|(255&t[14])<<16|(255&t[15])<<24,f=255&n[8]|(255&n[9])<<8|(255&n[10])<<16|(255&n[11])<<24,m=255&r[16]|(255&r[17])<<8|(255&r[18])<<16|(255&r[19])<<24,y=255&r[20]|(255&r[21])<<8|(255&r[22])<<16|(255&r[23])<<24,b=255&r[24]|(255&r[25])<<8|(255&r[26])<<16|(255&r[27])<<24,v=255&r[28]|(255&r[29])<<8|(255&r[30])<<16|(255&r[31])<<24,w=255&n[12]|(255&n[13])<<8|(255&n[14])<<16|(255&n[15])<<24,S=0;S<20;S+=2)o^=(s=(y^=(s=(p^=(s=(l^=(s=o+y|0)<<7|s>>>25)+o|0)<<9|s>>>23)+l|0)<<13|s>>>19)+p|0)<<18|s>>>14,u^=(s=(i^=(s=(b^=(s=(g^=(s=u+i|0)<<7|s>>>25)+u|0)<<9|s>>>23)+g|0)<<13|s>>>19)+b|0)<<18|s>>>14,f^=(s=(d^=(s=(a^=(s=(v^=(s=f+d|0)<<7|s>>>25)+f|0)<<9|s>>>23)+v|0)<<13|s>>>19)+a|0)<<18|s>>>14,w^=(s=(m^=(s=(h^=(s=(c^=(s=w+m|0)<<7|s>>>25)+w|0)<<9|s>>>23)+c|0)<<13|s>>>19)+h|0)<<18|s>>>14,o^=(s=(c^=(s=(a^=(s=(i^=(s=o+c|0)<<7|s>>>25)+o|0)<<9|s>>>23)+i|0)<<13|s>>>19)+a|0)<<18|s>>>14,u^=(s=(l^=(s=(h^=(s=(d^=(s=u+l|0)<<7|s>>>25)+u|0)<<9|s>>>23)+d|0)<<13|s>>>19)+h|0)<<18|s>>>14,f^=(s=(g^=(s=(p^=(s=(m^=(s=f+g|0)<<7|s>>>25)+f|0)<<9|s>>>23)+m|0)<<13|s>>>19)+p|0)<<18|s>>>14,w^=(s=(v^=(s=(b^=(s=(y^=(s=w+v|0)<<7|s>>>25)+w|0)<<9|s>>>23)+y|0)<<13|s>>>19)+b|0)<<18|s>>>14;e[0]=o>>>0&255,e[1]=o>>>8&255,e[2]=o>>>16&255,e[3]=o>>>24&255,e[4]=u>>>0&255,e[5]=u>>>8&255,e[6]=u>>>16&255,e[7]=u>>>24&255,e[8]=f>>>0&255,e[9]=f>>>8&255,e[10]=f>>>16&255,e[11]=f>>>24&255,e[12]=w>>>0&255,e[13]=w>>>8&255,e[14]=w>>>16&255,e[15]=w>>>24&255,e[16]=d>>>0&255,e[17]=d>>>8&255,e[18]=d>>>16&255,e[19]=d>>>24&255,e[20]=h>>>0&255,e[21]=h>>>8&255,e[22]=h>>>16&255,e[23]=h>>>24&255,e[24]=p>>>0&255,e[25]=p>>>8&255,e[26]=p>>>16&255,e[27]=p>>>24&255,e[28]=g>>>0&255,e[29]=g>>>8&255,e[30]=g>>>16&255,e[31]=g>>>24&255}(e,t,r,n)}var w=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function S(e,t,r,n,s,o,i){var a,c,l=new Uint8Array(16),u=new Uint8Array(64);for(c=0;c<16;c++)l[c]=0;for(c=0;c<8;c++)l[c]=o[c];for(;s>=64;){for(b(u,l,i,w),c=0;c<64;c++)e[t+c]=r[n+c]^u[c];for(a=1,c=8;c<16;c++)a=a+(255&l[c])|0,l[c]=255&a,a>>>=8;s-=64,t+=64,n+=64}if(s>0)for(b(u,l,i,w),c=0;c<s;c++)e[t+c]=r[n+c]^u[c];return 0}function T(e,t,r,n,s){var o,i,a=new Uint8Array(16),c=new Uint8Array(64);for(i=0;i<16;i++)a[i]=0;for(i=0;i<8;i++)a[i]=n[i];for(;r>=64;){for(b(c,a,s,w),i=0;i<64;i++)e[t+i]=c[i];for(o=1,i=8;i<16;i++)o=o+(255&a[i])|0,a[i]=255&o,o>>>=8;r-=64,t+=64}if(r>0)for(b(c,a,s,w),i=0;i<r;i++)e[t+i]=c[i];return 0}function k(e,t,r,n,s){var o=new Uint8Array(32);v(o,n,s,w);for(var i=new Uint8Array(8),a=0;a<8;a++)i[a]=n[a+16];return T(e,t,r,i,o)}function C(e,t,r,n,s,o,i){var a=new Uint8Array(32);v(a,o,i,w);for(var c=new Uint8Array(8),l=0;l<8;l++)c[l]=o[l+16];return S(e,t,r,n,s,c,a)}var _=function(e){var t,r,n,s,o,i,a,c;this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0,t=255&e[0]|(255&e[1])<<8,this.r[0]=8191&t,r=255&e[2]|(255&e[3])<<8,this.r[1]=8191&(t>>>13|r<<3),n=255&e[4]|(255&e[5])<<8,this.r[2]=7939&(r>>>10|n<<6),s=255&e[6]|(255&e[7])<<8,this.r[3]=8191&(n>>>7|s<<9),o=255&e[8]|(255&e[9])<<8,this.r[4]=255&(s>>>4|o<<12),this.r[5]=o>>>1&8190,i=255&e[10]|(255&e[11])<<8,this.r[6]=8191&(o>>>14|i<<2),a=255&e[12]|(255&e[13])<<8,this.r[7]=8065&(i>>>11|a<<5),c=255&e[14]|(255&e[15])<<8,this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127,this.pad[0]=255&e[16]|(255&e[17])<<8,this.pad[1]=255&e[18]|(255&e[19])<<8,this.pad[2]=255&e[20]|(255&e[21])<<8,this.pad[3]=255&e[22]|(255&e[23])<<8,this.pad[4]=255&e[24]|(255&e[25])<<8,this.pad[5]=255&e[26]|(255&e[27])<<8,this.pad[6]=255&e[28]|(255&e[29])<<8,this.pad[7]=255&e[30]|(255&e[31])<<8};function E(e,t,r,n,s,o){var i=new _(o);return i.update(r,n,s),i.finish(e,t),0}function M(e,t,r,n,s,o){var i=new Uint8Array(16);return E(i,0,r,n,s,o),m(e,t,i,0)}function A(e,t,r,n,s){var o;if(r<32)return-1;for(C(e,0,t,0,r,n,s),E(e,16,e,32,r-32,e),o=0;o<16;o++)e[o]=0;return 0}function P(e,t,r,n,s){var o,i=new Uint8Array(32);if(r<32)return-1;if(k(i,0,32,n,s),0!==M(t,16,t,32,r-32,i))return-1;for(C(e,0,t,0,r,n,s),o=0;o<32;o++)e[o]=0;return 0}function I(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function N(e){var t,r,n=1;for(t=0;t<16;t++)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function O(e,t,r){for(var n,s=~(r-1),o=0;o<16;o++)n=s&(e[o]^t[o]),e[o]^=n,t[o]^=n}function R(e,t){var n,s,o,i=r(),a=r();for(n=0;n<16;n++)a[n]=t[n];for(N(a),N(a),N(a),s=0;s<2;s++){for(i[0]=a[0]-65517,n=1;n<15;n++)i[n]=a[n]-65535-(i[n-1]>>16&1),i[n-1]&=65535;i[15]=a[15]-32767-(i[14]>>16&1),o=i[15]>>16&1,i[14]&=65535,O(a,i,1-o)}for(n=0;n<16;n++)e[2*n]=255&a[n],e[2*n+1]=a[n]>>8}function x(e,t){var r=new Uint8Array(32),n=new Uint8Array(32);return R(r,e),R(n,t),y(r,0,n,0)}function L(e){var t=new Uint8Array(32);return R(t,e),1&t[0]}function D(e,t){var r;for(r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}function j(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]+r[n]}function U(e,t,r){for(var n=0;n<16;n++)e[n]=t[n]-r[n]}function B(e,t,r){var n,s,o=0,i=0,a=0,c=0,l=0,u=0,d=0,h=0,p=0,g=0,f=0,m=0,y=0,b=0,v=0,w=0,S=0,T=0,k=0,C=0,_=0,E=0,M=0,A=0,P=0,I=0,N=0,O=0,R=0,x=0,L=0,D=r[0],j=r[1],U=r[2],B=r[3],F=r[4],K=r[5],q=r[6],$=r[7],z=r[8],H=r[9],G=r[10],W=r[11],V=r[12],Y=r[13],Q=r[14],J=r[15];o+=(n=t[0])*D,i+=n*j,a+=n*U,c+=n*B,l+=n*F,u+=n*K,d+=n*q,h+=n*$,p+=n*z,g+=n*H,f+=n*G,m+=n*W,y+=n*V,b+=n*Y,v+=n*Q,w+=n*J,i+=(n=t[1])*D,a+=n*j,c+=n*U,l+=n*B,u+=n*F,d+=n*K,h+=n*q,p+=n*$,g+=n*z,f+=n*H,m+=n*G,y+=n*W,b+=n*V,v+=n*Y,w+=n*Q,S+=n*J,a+=(n=t[2])*D,c+=n*j,l+=n*U,u+=n*B,d+=n*F,h+=n*K,p+=n*q,g+=n*$,f+=n*z,m+=n*H,y+=n*G,b+=n*W,v+=n*V,w+=n*Y,S+=n*Q,T+=n*J,c+=(n=t[3])*D,l+=n*j,u+=n*U,d+=n*B,h+=n*F,p+=n*K,g+=n*q,f+=n*$,m+=n*z,y+=n*H,b+=n*G,v+=n*W,w+=n*V,S+=n*Y,T+=n*Q,k+=n*J,l+=(n=t[4])*D,u+=n*j,d+=n*U,h+=n*B,p+=n*F,g+=n*K,f+=n*q,m+=n*$,y+=n*z,b+=n*H,v+=n*G,w+=n*W,S+=n*V,T+=n*Y,k+=n*Q,C+=n*J,u+=(n=t[5])*D,d+=n*j,h+=n*U,p+=n*B,g+=n*F,f+=n*K,m+=n*q,y+=n*$,b+=n*z,v+=n*H,w+=n*G,S+=n*W,T+=n*V,k+=n*Y,C+=n*Q,_+=n*J,d+=(n=t[6])*D,h+=n*j,p+=n*U,g+=n*B,f+=n*F,m+=n*K,y+=n*q,b+=n*$,v+=n*z,w+=n*H,S+=n*G,T+=n*W,k+=n*V,C+=n*Y,_+=n*Q,E+=n*J,h+=(n=t[7])*D,p+=n*j,g+=n*U,f+=n*B,m+=n*F,y+=n*K,b+=n*q,v+=n*$,w+=n*z,S+=n*H,T+=n*G,k+=n*W,C+=n*V,_+=n*Y,E+=n*Q,M+=n*J,p+=(n=t[8])*D,g+=n*j,f+=n*U,m+=n*B,y+=n*F,b+=n*K,v+=n*q,w+=n*$,S+=n*z,T+=n*H,k+=n*G,C+=n*W,_+=n*V,E+=n*Y,M+=n*Q,A+=n*J,g+=(n=t[9])*D,f+=n*j,m+=n*U,y+=n*B,b+=n*F,v+=n*K,w+=n*q,S+=n*$,T+=n*z,k+=n*H,C+=n*G,_+=n*W,E+=n*V,M+=n*Y,A+=n*Q,P+=n*J,f+=(n=t[10])*D,m+=n*j,y+=n*U,b+=n*B,v+=n*F,w+=n*K,S+=n*q,T+=n*$,k+=n*z,C+=n*H,_+=n*G,E+=n*W,M+=n*V,A+=n*Y,P+=n*Q,I+=n*J,m+=(n=t[11])*D,y+=n*j,b+=n*U,v+=n*B,w+=n*F,S+=n*K,T+=n*q,k+=n*$,C+=n*z,_+=n*H,E+=n*G,M+=n*W,A+=n*V,P+=n*Y,I+=n*Q,N+=n*J,y+=(n=t[12])*D,b+=n*j,v+=n*U,w+=n*B,S+=n*F,T+=n*K,k+=n*q,C+=n*$,_+=n*z,E+=n*H,M+=n*G,A+=n*W,P+=n*V,I+=n*Y,N+=n*Q,O+=n*J,b+=(n=t[13])*D,v+=n*j,w+=n*U,S+=n*B,T+=n*F,k+=n*K,C+=n*q,_+=n*$,E+=n*z,M+=n*H,A+=n*G,P+=n*W,I+=n*V,N+=n*Y,O+=n*Q,R+=n*J,v+=(n=t[14])*D,w+=n*j,S+=n*U,T+=n*B,k+=n*F,C+=n*K,_+=n*q,E+=n*$,M+=n*z,A+=n*H,P+=n*G,I+=n*W,N+=n*V,O+=n*Y,R+=n*Q,x+=n*J,w+=(n=t[15])*D,i+=38*(T+=n*U),a+=38*(k+=n*B),c+=38*(C+=n*F),l+=38*(_+=n*K),u+=38*(E+=n*q),d+=38*(M+=n*$),h+=38*(A+=n*z),p+=38*(P+=n*H),g+=38*(I+=n*G),f+=38*(N+=n*W),m+=38*(O+=n*V),y+=38*(R+=n*Y),b+=38*(x+=n*Q),v+=38*(L+=n*J),o=(n=(o+=38*(S+=n*j))+(s=1)+65535)-65536*(s=Math.floor(n/65536)),i=(n=i+s+65535)-65536*(s=Math.floor(n/65536)),a=(n=a+s+65535)-65536*(s=Math.floor(n/65536)),c=(n=c+s+65535)-65536*(s=Math.floor(n/65536)),l=(n=l+s+65535)-65536*(s=Math.floor(n/65536)),u=(n=u+s+65535)-65536*(s=Math.floor(n/65536)),d=(n=d+s+65535)-65536*(s=Math.floor(n/65536)),h=(n=h+s+65535)-65536*(s=Math.floor(n/65536)),p=(n=p+s+65535)-65536*(s=Math.floor(n/65536)),g=(n=g+s+65535)-65536*(s=Math.floor(n/65536)),f=(n=f+s+65535)-65536*(s=Math.floor(n/65536)),m=(n=m+s+65535)-65536*(s=Math.floor(n/65536)),y=(n=y+s+65535)-65536*(s=Math.floor(n/65536)),b=(n=b+s+65535)-65536*(s=Math.floor(n/65536)),v=(n=v+s+65535)-65536*(s=Math.floor(n/65536)),w=(n=w+s+65535)-65536*(s=Math.floor(n/65536)),o=(n=(o+=s-1+37*(s-1))+(s=1)+65535)-65536*(s=Math.floor(n/65536)),i=(n=i+s+65535)-65536*(s=Math.floor(n/65536)),a=(n=a+s+65535)-65536*(s=Math.floor(n/65536)),c=(n=c+s+65535)-65536*(s=Math.floor(n/65536)),l=(n=l+s+65535)-65536*(s=Math.floor(n/65536)),u=(n=u+s+65535)-65536*(s=Math.floor(n/65536)),d=(n=d+s+65535)-65536*(s=Math.floor(n/65536)),h=(n=h+s+65535)-65536*(s=Math.floor(n/65536)),p=(n=p+s+65535)-65536*(s=Math.floor(n/65536)),g=(n=g+s+65535)-65536*(s=Math.floor(n/65536)),f=(n=f+s+65535)-65536*(s=Math.floor(n/65536)),m=(n=m+s+65535)-65536*(s=Math.floor(n/65536)),y=(n=y+s+65535)-65536*(s=Math.floor(n/65536)),b=(n=b+s+65535)-65536*(s=Math.floor(n/65536)),v=(n=v+s+65535)-65536*(s=Math.floor(n/65536)),w=(n=w+s+65535)-65536*(s=Math.floor(n/65536)),o+=s-1+37*(s-1),e[0]=o,e[1]=i,e[2]=a,e[3]=c,e[4]=l,e[5]=u,e[6]=d,e[7]=h,e[8]=p,e[9]=g,e[10]=f,e[11]=m,e[12]=y,e[13]=b,e[14]=v,e[15]=w}function F(e,t){B(e,t,t)}function K(e,t){var n,s=r();for(n=0;n<16;n++)s[n]=t[n];for(n=253;n>=0;n--)F(s,s),2!==n&&4!==n&&B(s,s,t);for(n=0;n<16;n++)e[n]=s[n]}function q(e,t){var n,s=r();for(n=0;n<16;n++)s[n]=t[n];for(n=250;n>=0;n--)F(s,s),1!==n&&B(s,s,t);for(n=0;n<16;n++)e[n]=s[n]}function $(e,t,n){var s,o,i=new Uint8Array(32),a=new Float64Array(80),l=r(),u=r(),d=r(),h=r(),p=r(),g=r();for(o=0;o<31;o++)i[o]=t[o];for(i[31]=127&t[31]|64,i[0]&=248,D(a,n),o=0;o<16;o++)u[o]=a[o],h[o]=l[o]=d[o]=0;for(l[0]=h[0]=1,o=254;o>=0;--o)O(l,u,s=i[o>>>3]>>>(7&o)&1),O(d,h,s),j(p,l,d),U(l,l,d),j(d,u,h),U(u,u,h),F(h,p),F(g,l),B(l,d,l),B(d,u,p),j(p,l,d),U(l,l,d),F(u,l),U(d,h,g),B(l,d,c),j(l,l,h),B(d,d,l),B(l,h,g),B(h,u,a),F(u,p),O(l,u,s),O(d,h,s);for(o=0;o<16;o++)a[o+16]=l[o],a[o+32]=d[o],a[o+48]=u[o],a[o+64]=h[o];var f=a.subarray(32),m=a.subarray(16);return K(f,f),B(m,m,f),R(e,m),0}function z(e,t){return $(e,t,o)}function H(e,t){return n(t,32),z(e,t)}function G(e,t,r){var n=new Uint8Array(32);return $(n,r,t),v(e,s,n,w)}_.prototype.blocks=function(e,t,r){for(var n,s,o,i,a,c,l,u,d,h,p,g,f,m,y,b,v,w,S,T=this.fin?0:2048,k=this.h[0],C=this.h[1],_=this.h[2],E=this.h[3],M=this.h[4],A=this.h[5],P=this.h[6],I=this.h[7],N=this.h[8],O=this.h[9],R=this.r[0],x=this.r[1],L=this.r[2],D=this.r[3],j=this.r[4],U=this.r[5],B=this.r[6],F=this.r[7],K=this.r[8],q=this.r[9];r>=16;)h=d=0,h+=(k+=8191&(n=255&e[t+0]|(255&e[t+1])<<8))*R,h+=(C+=8191&(n>>>13|(s=255&e[t+2]|(255&e[t+3])<<8)<<3))*(5*q),h+=(_+=8191&(s>>>10|(o=255&e[t+4]|(255&e[t+5])<<8)<<6))*(5*K),h+=(E+=8191&(o>>>7|(i=255&e[t+6]|(255&e[t+7])<<8)<<9))*(5*F),d=(h+=(M+=8191&(i>>>4|(a=255&e[t+8]|(255&e[t+9])<<8)<<12))*(5*B))>>>13,h&=8191,h+=(A+=a>>>1&8191)*(5*U),h+=(P+=8191&(a>>>14|(c=255&e[t+10]|(255&e[t+11])<<8)<<2))*(5*j),h+=(I+=8191&(c>>>11|(l=255&e[t+12]|(255&e[t+13])<<8)<<5))*(5*D),h+=(N+=8191&(l>>>8|(u=255&e[t+14]|(255&e[t+15])<<8)<<8))*(5*L),p=d+=(h+=(O+=u>>>5|T)*(5*x))>>>13,p+=k*x,p+=C*R,p+=_*(5*q),p+=E*(5*K),d=(p+=M*(5*F))>>>13,p&=8191,p+=A*(5*B),p+=P*(5*U),p+=I*(5*j),p+=N*(5*D),d+=(p+=O*(5*L))>>>13,p&=8191,g=d,g+=k*L,g+=C*x,g+=_*R,g+=E*(5*q),d=(g+=M*(5*K))>>>13,g&=8191,g+=A*(5*F),g+=P*(5*B),g+=I*(5*U),g+=N*(5*j),f=d+=(g+=O*(5*D))>>>13,f+=k*D,f+=C*L,f+=_*x,f+=E*R,d=(f+=M*(5*q))>>>13,f&=8191,f+=A*(5*K),f+=P*(5*F),f+=I*(5*B),f+=N*(5*U),m=d+=(f+=O*(5*j))>>>13,m+=k*j,m+=C*D,m+=_*L,m+=E*x,d=(m+=M*R)>>>13,m&=8191,m+=A*(5*q),m+=P*(5*K),m+=I*(5*F),m+=N*(5*B),y=d+=(m+=O*(5*U))>>>13,y+=k*U,y+=C*j,y+=_*D,y+=E*L,d=(y+=M*x)>>>13,y&=8191,y+=A*R,y+=P*(5*q),y+=I*(5*K),y+=N*(5*F),b=d+=(y+=O*(5*B))>>>13,b+=k*B,b+=C*U,b+=_*j,b+=E*D,d=(b+=M*L)>>>13,b&=8191,b+=A*x,b+=P*R,b+=I*(5*q),b+=N*(5*K),v=d+=(b+=O*(5*F))>>>13,v+=k*F,v+=C*B,v+=_*U,v+=E*j,d=(v+=M*D)>>>13,v&=8191,v+=A*L,v+=P*x,v+=I*R,v+=N*(5*q),w=d+=(v+=O*(5*K))>>>13,w+=k*K,w+=C*F,w+=_*B,w+=E*U,d=(w+=M*j)>>>13,w&=8191,w+=A*D,w+=P*L,w+=I*x,w+=N*R,S=d+=(w+=O*(5*q))>>>13,S+=k*q,S+=C*K,S+=_*F,S+=E*B,d=(S+=M*U)>>>13,S&=8191,S+=A*j,S+=P*D,S+=I*L,S+=N*x,k=h=8191&(d=(d=((d+=(S+=O*R)>>>13)<<2)+d|0)+(h&=8191)|0),C=p+=d>>>=13,_=g&=8191,E=f&=8191,M=m&=8191,A=y&=8191,P=b&=8191,I=v&=8191,N=w&=8191,O=S&=8191,t+=16,r-=16;this.h[0]=k,this.h[1]=C,this.h[2]=_,this.h[3]=E,this.h[4]=M,this.h[5]=A,this.h[6]=P,this.h[7]=I,this.h[8]=N,this.h[9]=O},_.prototype.finish=function(e,t){var r,n,s,o,i=new Uint16Array(10);if(this.leftover){for(o=this.leftover,this.buffer[o++]=1;o<16;o++)this.buffer[o]=0;this.fin=1,this.blocks(this.buffer,0,16)}for(r=this.h[1]>>>13,this.h[1]&=8191,o=2;o<10;o++)this.h[o]+=r,r=this.h[o]>>>13,this.h[o]&=8191;for(this.h[0]+=5*r,r=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=r,r=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=r,i[0]=this.h[0]+5,r=i[0]>>>13,i[0]&=8191,o=1;o<10;o++)i[o]=this.h[o]+r,r=i[o]>>>13,i[o]&=8191;for(i[9]-=8192,n=(1^r)-1,o=0;o<10;o++)i[o]&=n;for(n=~n,o=0;o<10;o++)this.h[o]=this.h[o]&n|i[o];for(this.h[0]=65535&(this.h[0]|this.h[1]<<13),this.h[1]=65535&(this.h[1]>>>3|this.h[2]<<10),this.h[2]=65535&(this.h[2]>>>6|this.h[3]<<7),this.h[3]=65535&(this.h[3]>>>9|this.h[4]<<4),this.h[4]=65535&(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14),this.h[5]=65535&(this.h[6]>>>2|this.h[7]<<11),this.h[6]=65535&(this.h[7]>>>5|this.h[8]<<8),this.h[7]=65535&(this.h[8]>>>8|this.h[9]<<5),s=this.h[0]+this.pad[0],this.h[0]=65535&s,o=1;o<8;o++)s=(this.h[o]+this.pad[o]|0)+(s>>>16)|0,this.h[o]=65535&s;e[t+0]=this.h[0]>>>0&255,e[t+1]=this.h[0]>>>8&255,e[t+2]=this.h[1]>>>0&255,e[t+3]=this.h[1]>>>8&255,e[t+4]=this.h[2]>>>0&255,e[t+5]=this.h[2]>>>8&255,e[t+6]=this.h[3]>>>0&255,e[t+7]=this.h[3]>>>8&255,e[t+8]=this.h[4]>>>0&255,e[t+9]=this.h[4]>>>8&255,e[t+10]=this.h[5]>>>0&255,e[t+11]=this.h[5]>>>8&255,e[t+12]=this.h[6]>>>0&255,e[t+13]=this.h[6]>>>8&255,e[t+14]=this.h[7]>>>0&255,e[t+15]=this.h[7]>>>8&255},_.prototype.update=function(e,t,r){var n,s;if(this.leftover){for((s=16-this.leftover)>r&&(s=r),n=0;n<s;n++)this.buffer[this.leftover+n]=e[t+n];if(r-=s,t+=s,this.leftover+=s,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0}if(r>=16&&(s=r-r%16,this.blocks(e,t,s),t+=s,r-=s),r){for(n=0;n<r;n++)this.buffer[this.leftover+n]=e[t+n];this.leftover+=r}};var W=A,V=P;var Y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Q(e,t,r,n){for(var s,o,i,a,c,l,u,d,h,p,g,f,m,y,b,v,w,S,T,k,C,_,E,M,A,P,I=new Int32Array(16),N=new Int32Array(16),O=e[0],R=e[1],x=e[2],L=e[3],D=e[4],j=e[5],U=e[6],B=e[7],F=t[0],K=t[1],q=t[2],$=t[3],z=t[4],H=t[5],G=t[6],W=t[7],V=0;n>=128;){for(T=0;T<16;T++)k=8*T+V,I[T]=r[k+0]<<24|r[k+1]<<16|r[k+2]<<8|r[k+3],N[T]=r[k+4]<<24|r[k+5]<<16|r[k+6]<<8|r[k+7];for(T=0;T<80;T++)if(s=O,o=R,i=x,a=L,c=D,l=j,u=U,B,h=F,p=K,g=q,f=$,m=z,y=H,b=G,W,E=65535&(_=W),M=_>>>16,A=65535&(C=B),P=C>>>16,E+=65535&(_=(z>>>14|D<<18)^(z>>>18|D<<14)^(D>>>9|z<<23)),M+=_>>>16,A+=65535&(C=(D>>>14|z<<18)^(D>>>18|z<<14)^(z>>>9|D<<23)),P+=C>>>16,E+=65535&(_=z&H^~z&G),M+=_>>>16,A+=65535&(C=D&j^~D&U),P+=C>>>16,E+=65535&(_=Y[2*T+1]),M+=_>>>16,A+=65535&(C=Y[2*T]),P+=C>>>16,C=I[T%16],M+=(_=N[T%16])>>>16,A+=65535&C,P+=C>>>16,A+=(M+=(E+=65535&_)>>>16)>>>16,E=65535&(_=S=65535&E|M<<16),M=_>>>16,A=65535&(C=w=65535&A|(P+=A>>>16)<<16),P=C>>>16,E+=65535&(_=(F>>>28|O<<4)^(O>>>2|F<<30)^(O>>>7|F<<25)),M+=_>>>16,A+=65535&(C=(O>>>28|F<<4)^(F>>>2|O<<30)^(F>>>7|O<<25)),P+=C>>>16,M+=(_=F&K^F&q^K&q)>>>16,A+=65535&(C=O&R^O&x^R&x),P+=C>>>16,d=65535&(A+=(M+=(E+=65535&_)>>>16)>>>16)|(P+=A>>>16)<<16,v=65535&E|M<<16,E=65535&(_=f),M=_>>>16,A=65535&(C=a),P=C>>>16,M+=(_=S)>>>16,A+=65535&(C=w),P+=C>>>16,R=s,x=o,L=i,D=a=65535&(A+=(M+=(E+=65535&_)>>>16)>>>16)|(P+=A>>>16)<<16,j=c,U=l,B=u,O=d,K=h,q=p,$=g,z=f=65535&E|M<<16,H=m,G=y,W=b,F=v,T%16==15)for(k=0;k<16;k++)C=I[k],E=65535&(_=N[k]),M=_>>>16,A=65535&C,P=C>>>16,C=I[(k+9)%16],E+=65535&(_=N[(k+9)%16]),M+=_>>>16,A+=65535&C,P+=C>>>16,w=I[(k+1)%16],E+=65535&(_=((S=N[(k+1)%16])>>>1|w<<31)^(S>>>8|w<<24)^(S>>>7|w<<25)),M+=_>>>16,A+=65535&(C=(w>>>1|S<<31)^(w>>>8|S<<24)^w>>>7),P+=C>>>16,w=I[(k+14)%16],M+=(_=((S=N[(k+14)%16])>>>19|w<<13)^(w>>>29|S<<3)^(S>>>6|w<<26))>>>16,A+=65535&(C=(w>>>19|S<<13)^(S>>>29|w<<3)^w>>>6),P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,I[k]=65535&A|P<<16,N[k]=65535&E|M<<16;E=65535&(_=F),M=_>>>16,A=65535&(C=O),P=C>>>16,C=e[0],M+=(_=t[0])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[0]=O=65535&A|P<<16,t[0]=F=65535&E|M<<16,E=65535&(_=K),M=_>>>16,A=65535&(C=R),P=C>>>16,C=e[1],M+=(_=t[1])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[1]=R=65535&A|P<<16,t[1]=K=65535&E|M<<16,E=65535&(_=q),M=_>>>16,A=65535&(C=x),P=C>>>16,C=e[2],M+=(_=t[2])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[2]=x=65535&A|P<<16,t[2]=q=65535&E|M<<16,E=65535&(_=$),M=_>>>16,A=65535&(C=L),P=C>>>16,C=e[3],M+=(_=t[3])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[3]=L=65535&A|P<<16,t[3]=$=65535&E|M<<16,E=65535&(_=z),M=_>>>16,A=65535&(C=D),P=C>>>16,C=e[4],M+=(_=t[4])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[4]=D=65535&A|P<<16,t[4]=z=65535&E|M<<16,E=65535&(_=H),M=_>>>16,A=65535&(C=j),P=C>>>16,C=e[5],M+=(_=t[5])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[5]=j=65535&A|P<<16,t[5]=H=65535&E|M<<16,E=65535&(_=G),M=_>>>16,A=65535&(C=U),P=C>>>16,C=e[6],M+=(_=t[6])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[6]=U=65535&A|P<<16,t[6]=G=65535&E|M<<16,E=65535&(_=W),M=_>>>16,A=65535&(C=B),P=C>>>16,C=e[7],M+=(_=t[7])>>>16,A+=65535&C,P+=C>>>16,P+=(A+=(M+=(E+=65535&_)>>>16)>>>16)>>>16,e[7]=B=65535&A|P<<16,t[7]=W=65535&E|M<<16,V+=128,n-=128}return n}function J(e,t,r){var n,s=new Int32Array(8),o=new Int32Array(8),i=new Uint8Array(256),a=r;for(s[0]=1779033703,s[1]=3144134277,s[2]=1013904242,s[3]=2773480762,s[4]=1359893119,s[5]=2600822924,s[6]=528734635,s[7]=1541459225,o[0]=4089235720,o[1]=2227873595,o[2]=4271175723,o[3]=1595750129,o[4]=2917565137,o[5]=725511199,o[6]=4215389547,o[7]=327033209,Q(s,o,t,r),r%=128,n=0;n<r;n++)i[n]=t[a-r+n];for(i[r]=128,i[(r=256-128*(r<112?1:0))-9]=0,g(i,r-8,a/536870912|0,a<<3),Q(s,o,i,r),n=0;n<8;n++)g(e,8*n,s[n],o[n]);return 0}function X(e,t){var n=r(),s=r(),o=r(),i=r(),a=r(),c=r(),l=r(),d=r(),h=r();U(n,e[1],e[0]),U(h,t[1],t[0]),B(n,n,h),j(s,e[0],e[1]),j(h,t[0],t[1]),B(s,s,h),B(o,e[3],t[3]),B(o,o,u),B(i,e[2],t[2]),j(i,i,i),U(a,s,n),U(c,i,o),j(l,i,o),j(d,s,n),B(e[0],a,c),B(e[1],d,l),B(e[2],l,c),B(e[3],a,d)}function Z(e,t,r){var n;for(n=0;n<4;n++)O(e[n],t[n],r)}function ee(e,t){var n=r(),s=r(),o=r();K(o,t[2]),B(n,t[0],o),B(s,t[1],o),R(e,s),e[31]^=L(n)<<7}function te(e,t,r){var n,s;for(I(e[0],i),I(e[1],a),I(e[2],a),I(e[3],i),s=255;s>=0;--s)Z(e,t,n=r[s/8|0]>>(7&s)&1),X(t,e),X(e,e),Z(e,t,n)}function re(e,t){var n=[r(),r(),r(),r()];I(n[0],d),I(n[1],h),I(n[2],a),B(n[3],d,h),te(e,n,t)}function ne(e,t,s){var o,i=new Uint8Array(64),a=[r(),r(),r(),r()];for(s||n(t,32),J(i,t,32),i[0]&=248,i[31]&=127,i[31]|=64,re(a,i),ee(e,a),o=0;o<32;o++)t[o+32]=e[o];return 0}var se=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function oe(e,t){var r,n,s,o;for(n=63;n>=32;--n){for(r=0,s=n-32,o=n-12;s<o;++s)t[s]+=r-16*t[n]*se[s-(n-32)],r=Math.floor((t[s]+128)/256),t[s]-=256*r;t[s]+=r,t[n]=0}for(r=0,s=0;s<32;s++)t[s]+=r-(t[31]>>4)*se[s],r=t[s]>>8,t[s]&=255;for(s=0;s<32;s++)t[s]-=r*se[s];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function ie(e){var t,r=new Float64Array(64);for(t=0;t<64;t++)r[t]=e[t];for(t=0;t<64;t++)e[t]=0;oe(e,r)}function ae(e,t,n,s){var o,i,a=new Uint8Array(64),c=new Uint8Array(64),l=new Uint8Array(64),u=new Float64Array(64),d=[r(),r(),r(),r()];J(a,s,32),a[0]&=248,a[31]&=127,a[31]|=64;var h=n+64;for(o=0;o<n;o++)e[64+o]=t[o];for(o=0;o<32;o++)e[32+o]=a[32+o];for(J(l,e.subarray(32),n+32),ie(l),re(d,l),ee(e,d),o=32;o<64;o++)e[o]=s[o];for(J(c,e,n+64),ie(c),o=0;o<64;o++)u[o]=0;for(o=0;o<32;o++)u[o]=l[o];for(o=0;o<32;o++)for(i=0;i<32;i++)u[o+i]+=c[o]*a[i];return oe(e.subarray(32),u),h}function ce(e,t,n,s){var o,c=new Uint8Array(32),u=new Uint8Array(64),d=[r(),r(),r(),r()],h=[r(),r(),r(),r()];if(n<64)return-1;if(function(e,t){var n=r(),s=r(),o=r(),c=r(),u=r(),d=r(),h=r();return I(e[2],a),D(e[1],t),F(o,e[1]),B(c,o,l),U(o,o,e[2]),j(c,e[2],c),F(u,c),F(d,u),B(h,d,u),B(n,h,o),B(n,n,c),q(n,n),B(n,n,o),B(n,n,c),B(n,n,c),B(e[0],n,c),F(s,e[0]),B(s,s,c),x(s,o)&&B(e[0],e[0],p),F(s,e[0]),B(s,s,c),x(s,o)?-1:(L(e[0])===t[31]>>7&&U(e[0],i,e[0]),B(e[3],e[0],e[1]),0)}(h,s))return-1;for(o=0;o<n;o++)e[o]=t[o];for(o=0;o<32;o++)e[o+32]=s[o];if(J(u,e,n),ie(u),te(d,h,u),re(h,t.subarray(32)),X(d,h),ee(c,d),n-=64,y(t,0,c,0)){for(o=0;o<n;o++)e[o]=0;return-1}for(o=0;o<n;o++)e[o]=t[o+64];return n}var le=16,ue=64,de=32,he=64;function pe(e,t){if(32!==e.length)throw new Error("bad key size");if(24!==t.length)throw new Error("bad nonce size")}function ge(){for(var e=0;e<arguments.length;e++)if(!(arguments[e]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function fe(e){for(var t=0;t<e.length;t++)e[t]=0}t.lowlevel={crypto_core_hsalsa20:v,crypto_stream_xor:C,crypto_stream:k,crypto_stream_salsa20_xor:S,crypto_stream_salsa20:T,crypto_onetimeauth:E,crypto_onetimeauth_verify:M,crypto_verify_16:m,crypto_verify_32:y,crypto_secretbox:A,crypto_secretbox_open:P,crypto_scalarmult:$,crypto_scalarmult_base:z,crypto_box_beforenm:G,crypto_box_afternm:W,crypto_box:function(e,t,r,n,s,o){var i=new Uint8Array(32);return G(i,s,o),W(e,t,r,n,i)},crypto_box_open:function(e,t,r,n,s,o){var i=new Uint8Array(32);return G(i,s,o),V(e,t,r,n,i)},crypto_box_keypair:H,crypto_hash:J,crypto_sign:ae,crypto_sign_keypair:ne,crypto_sign_open:ce,crypto_secretbox_KEYBYTES:32,crypto_secretbox_NONCEBYTES:24,crypto_secretbox_ZEROBYTES:32,crypto_secretbox_BOXZEROBYTES:le,crypto_scalarmult_BYTES:32,crypto_scalarmult_SCALARBYTES:32,crypto_box_PUBLICKEYBYTES:32,crypto_box_SECRETKEYBYTES:32,crypto_box_BEFORENMBYTES:32,crypto_box_NONCEBYTES:24,crypto_box_ZEROBYTES:32,crypto_box_BOXZEROBYTES:16,crypto_sign_BYTES:ue,crypto_sign_PUBLICKEYBYTES:de,crypto_sign_SECRETKEYBYTES:he,crypto_sign_SEEDBYTES:32,crypto_hash_BYTES:64,gf:r,D:l,L:se,pack25519:R,unpack25519:D,M:B,A:j,S:F,Z:U,pow2523:q,add:X,set25519:I,modL:oe,scalarmult:te,scalarbase:re},t.randomBytes=function(e){var t=new Uint8Array(e);return n(t,e),t},t.secretbox=function(e,t,r){ge(e,t,r),pe(r,t);for(var n=new Uint8Array(32+e.length),s=new Uint8Array(n.length),o=0;o<e.length;o++)n[o+32]=e[o];return A(s,n,n.length,t,r),s.subarray(le)},t.secretbox.open=function(e,t,r){ge(e,t,r),pe(r,t);for(var n=new Uint8Array(le+e.length),s=new Uint8Array(n.length),o=0;o<e.length;o++)n[o+le]=e[o];return n.length<32||0!==P(s,n,n.length,t,r)?null:s.subarray(32)},t.secretbox.keyLength=32,t.secretbox.nonceLength=24,t.secretbox.overheadLength=le,t.scalarMult=function(e,t){if(ge(e,t),32!==e.length)throw new Error("bad n size");if(32!==t.length)throw new Error("bad p size");var r=new Uint8Array(32);return $(r,e,t),r},t.scalarMult.base=function(e){if(ge(e),32!==e.length)throw new Error("bad n size");var t=new Uint8Array(32);return z(t,e),t},t.scalarMult.scalarLength=32,t.scalarMult.groupElementLength=32,t.box=function(e,r,n,s){var o=t.box.before(n,s);return t.secretbox(e,r,o)},t.box.before=function(e,t){ge(e,t),function(e,t){if(32!==e.length)throw new Error("bad public key size");if(32!==t.length)throw new Error("bad secret key size")}(e,t);var r=new Uint8Array(32);return G(r,e,t),r},t.box.after=t.secretbox,t.box.open=function(e,r,n,s){var o=t.box.before(n,s);return t.secretbox.open(e,r,o)},t.box.open.after=t.secretbox.open,t.box.keyPair=function(){var e=new Uint8Array(32),t=new Uint8Array(32);return H(e,t),{publicKey:e,secretKey:t}},t.box.keyPair.fromSecretKey=function(e){if(ge(e),32!==e.length)throw new Error("bad secret key size");var t=new Uint8Array(32);return z(t,e),{publicKey:t,secretKey:new Uint8Array(e)}},t.box.publicKeyLength=32,t.box.secretKeyLength=32,t.box.sharedKeyLength=32,t.box.nonceLength=24,t.box.overheadLength=t.secretbox.overheadLength,t.sign=function(e,t){if(ge(e,t),t.length!==he)throw new Error("bad secret key size");var r=new Uint8Array(ue+e.length);return ae(r,e,e.length,t),r},t.sign.open=function(e,t){if(ge(e,t),t.length!==de)throw new Error("bad public key size");var r=new Uint8Array(e.length),n=ce(r,e,e.length,t);if(n<0)return null;for(var s=new Uint8Array(n),o=0;o<s.length;o++)s[o]=r[o];return s},t.sign.detached=function(e,r){for(var n=t.sign(e,r),s=new Uint8Array(ue),o=0;o<s.length;o++)s[o]=n[o];return s},t.sign.detached.verify=function(e,t,r){if(ge(e,t,r),t.length!==ue)throw new Error("bad signature size");if(r.length!==de)throw new Error("bad public key size");var n,s=new Uint8Array(ue+e.length),o=new Uint8Array(ue+e.length);for(n=0;n<ue;n++)s[n]=t[n];for(n=0;n<e.length;n++)s[n+ue]=e[n];return ce(o,s,s.length,r)>=0},t.sign.keyPair=function(){var e=new Uint8Array(de),t=new Uint8Array(he);return ne(e,t),{publicKey:e,secretKey:t}},t.sign.keyPair.fromSecretKey=function(e){if(ge(e),e.length!==he)throw new Error("bad secret key size");for(var t=new Uint8Array(de),r=0;r<t.length;r++)t[r]=e[32+r];return{publicKey:t,secretKey:new Uint8Array(e)}},t.sign.keyPair.fromSeed=function(e){if(ge(e),32!==e.length)throw new Error("bad seed size");for(var t=new Uint8Array(de),r=new Uint8Array(he),n=0;n<32;n++)r[n]=e[n];return ne(t,r,!0),{publicKey:t,secretKey:r}},t.sign.publicKeyLength=de,t.sign.secretKeyLength=he,t.sign.seedLength=32,t.sign.signatureLength=ue,t.hash=function(e){ge(e);var t=new Uint8Array(64);return J(t,e,e.length),t},t.hash.hashLength=64,t.verify=function(e,t){return ge(e,t),0!==e.length&&0!==t.length&&(e.length===t.length&&0===f(e,0,t,0,e.length))},t.setPRNG=function(e){n=e},function(){var r="undefined"!=typeof self?self.crypto||self.msCrypto:null;if(r&&r.getRandomValues){t.setPRNG((function(e,t){var n,s=new Uint8Array(t);for(n=0;n<t;n+=65536)r.getRandomValues(s.subarray(n,n+Math.min(t-n,65536)));for(n=0;n<t;n++)e[n]=s[n];fe(s)}))}else void 0!==e&&(r=e("crypto"))&&r.randomBytes&&t.setPRNG((function(e,t){var n,s=r.randomBytes(t);for(n=0;n<t;n++)e[n]=s[n];fe(s)}))}()}(void 0!==t&&t.exports?t.exports:self.nacl=self.nacl||{})}}},{package:"eth-sig-util>tweetnacl",file:"node_modules/tweetnacl/nacl-fast.js"}],[3339,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){t.exports=function(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const r=new Uint8Array(t);let n=0;for(const t of e)r.set(t,n),n+=t.length;return r}}}},{package:"@ensdomains/content-hash>cids>uint8arrays",file:"node_modules/uint8arrays/concat.js"}],[3340,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){t.exports=function(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let r=0;r<e.byteLength;r++)if(e[r]!==t[r])return!1;return!0}}}},{package:"@ensdomains/content-hash>cids>uint8arrays",file:"node_modules/uint8arrays/equals.js"}],[3341,{multibase:2956},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){const{encoding:n}=e("multibase"),s=new TextEncoder;t.exports=function(e,t="utf8"){return"utf8"===t||"utf-8"===t?s.encode(e):"ascii"===t?function(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}(e):n(t).decode(e)}}}},{package:"@ensdomains/content-hash>cids>uint8arrays",file:"node_modules/uint8arrays/from-string.js"}],[3342,{multibase:2956},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){const{encoding:n}=e("multibase"),s=new TextDecoder("utf8");t.exports=function(e,t="utf8"){return"utf8"===t||"utf-8"===t?s.decode(e):"ascii"===t?function(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}(e):n(t).encode(e)}}}},{package:"@ensdomains/content-hash>cids>uint8arrays",file:"node_modules/uint8arrays/to-string.js"}],[3376,{util:1949},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){r.TextEncoder="undefined"!=typeof TextEncoder?TextEncoder:e("util").TextEncoder,r.TextDecoder="undefined"!=typeof TextDecoder?TextDecoder:e("util").TextDecoder}}},{package:"@ensdomains/content-hash>multihashes>web-encoding",file:"node_modules/web-encoding/src/lib.js"}],[3399,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.METAMETRICS_FINALIZE_EVENT_FRAGMENT_ALARM=r.AUTO_LOCK_TIMEOUT_ALARM=void 0;r.AUTO_LOCK_TIMEOUT_ALARM="AUTO_LOCK_TIMEOUT_ALARM";r.METAMETRICS_FINALIZE_EVENT_FRAGMENT_ALARM="METAMETRICS_FINALIZE_EVENT_FRAGMENT_ALARM"}}},{package:"$root$",file:"shared/constants/alarms.js"}],[34,{"../../../../shared/constants/app":3401,"../../../../shared/constants/network":3409,"../../../../shared/constants/transaction":3417,"../../../../shared/modules/random-id":3439,"../../../../shared/modules/transaction.utils":3444,"../../metamask-controller":83,"./lib/tx-state-history-helpers":30,"./lib/util":31,"@metamask/obs-store":1298,"@metamask/safe-event-emitter":1325,lodash:2932,loglevel:2944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.ERROR_SUBMITTING=void 0;var n=f(e("@metamask/safe-event-emitter")),s=e("@metamask/obs-store"),o=f(e("loglevel")),i=e("lodash"),a=f(e("../../../../shared/modules/random-id")),c=e("../../../../shared/constants/transaction"),l=e("../../metamask-controller"),u=e("../../../../shared/modules/transaction.utils"),d=e("../../../../shared/constants/app"),h=e("../../../../shared/constants/network"),p=e("./lib/tx-state-history-helpers"),g=e("./lib/util");function f(e){return e&&e.__esModule?e:{default:e}}const m="There was an error when resubmitting this transaction.";r.ERROR_SUBMITTING=m;class y extends n.default{constructor({initState:e,txHistoryLimit:t,getNetworkId:r,getNetworkStatus:n,getCurrentChainId:o}){super(),this.store=new s.ObservableStore({transactions:{},...e}),this.txHistoryLimit=t,this.getNetworkId=r,this.getNetworkStatus=n,this.getCurrentChainId=o}generateTxMeta(e={}){var t;const r=this.getNetworkId(),n=this.getNetworkStatus(),s=this.getCurrentChainId();if(n!==h.NetworkStatus.Available)throw new Error("MetaMask is having trouble connecting to the network");let o=null;return e.txParams&&"string"==typeof e.origin&&e.origin!==d.ORIGIN_METAMASK&&(void 0!==e.txParams.gasPrice?o={gasPrice:e.txParams.gasPrice}:void 0===e.txParams.maxFeePerGas&&void 0===e.txParams.maxPriorityFeePerGas||(o={maxPriorityFeePerGas:e.txParams.maxPriorityFeePerGas,maxFeePerGas:e.txParams.maxFeePerGas}),void 0!==e.txParams.gas&&(o={...o,gas:e.txParams.gas})),{id:(0,a.default)(),time:(new Date).getTime(),status:c.TransactionStatus.unapproved,metamaskNetworkId:r,originalGasEstimate:null===(t=e.txParams)||void 0===t?void 0:t.gas,userEditedGasLimit:!1,chainId:s,loadingDefaults:!0,dappSuggestedGasFees:o,sendFlowHistory:[],...e}}getUnapprovedTxList(){const e=this.getCurrentChainId(),t=this.getNetworkId();return(0,i.pickBy)(this.store.getState().transactions,(r=>r.status===c.TransactionStatus.unapproved&&(0,u.transactionMatchesNetwork)(r,e,t)))}getApprovedTransactions(e){const t={status:c.TransactionStatus.approved};return e&&(t.from=e),this.getTransactions({searchCriteria:t})}getPendingTransactions(e){const t={status:c.TransactionStatus.submitted};return e&&(t.from=e),this.getTransactions({searchCriteria:t})}getConfirmedTransactions(e){const t={status:c.TransactionStatus.confirmed};return e&&(t.from=e),this.getTransactions({searchCriteria:t})}getTransactionWithActionId(e){return(0,i.values)((0,i.pickBy)(this.store.getState().transactions,(t=>t.actionId===e)))[0]}addTransaction(e){e.txParams&&(e.txParams=(0,g.normalizeAndValidateTxParams)(e.txParams,!1)),this.once(`${e.id}:signed`,(()=>{this.removeAllListeners(`${e.id}:rejected`)})),this.once(`${e.id}:rejected`,(()=>{this.removeAllListeners(`${e.id}:signed`)})),e.history=[];const t=(0,p.snapshotFromTxMeta)(e);e.history.push(t);const r=this.getTransactions({filterToCurrentNetwork:!1}),{txHistoryLimit:n}=this,s=new Set,o=r.reverse().filter((e=>{const{nonce:t,from:r}=e.txParams,{chainId:o,metamaskNetworkId:i,status:a}=e,c=`${t}-${o??i}-${r}`;return!s.has(c)&&(!(s.size<n-1||!1===(0,g.getFinalStates)().includes(a))||(s.add(c),!1))})).map((e=>e.id));return this._deleteTransactions(o),this._addTransactionsToState([e]),e}addExternalTransaction(e){var t;const r=null==e||null===(t=e.txParams)||void 0===t?void 0:t.from,n=this.getConfirmedTransactions(r),s=this.getPendingTransactions(r);return(0,g.validateConfirmedExternalTransaction)({txMeta:e,pendingTransactions:s,confirmedTransactions:n}),this._addTransactionsToState([e]),e}getTransaction(e){const{transactions:t}=this.store.getState();return t[e]}updateTransaction(e,t){if(e.txParams)try{e.txParams=(0,g.normalizeAndValidateTxParams)(e.txParams,!1)}catch(t){if(e.warning.message!==m)throw t;return void this.setTxStatusFailed(e.id,t)}this._updateTransactionHistory(e,t)}_updateTransactionHistory(e,t){const r=(0,p.snapshotFromTxMeta)(e),n=(0,p.replayHistory)(e.history),s=(0,p.generateHistoryEntry)(n,r,t);s.length&&e.history.push(s);const o=e.id;this.store.updateState({transactions:{...this.store.getState().transactions,[o]:e}})}getTransactions({searchCriteria:e={},initialList:t,filterToCurrentNetwork:r=!0,limit:n}={}){const s=this.getCurrentChainId(),o=this.getNetworkId(),a=(0,i.mapValues)(e,(e=>"function"==typeof e?e:t=>t===e)),c=t?(0,i.keyBy)(t,"id"):this.store.getState().transactions,l=(0,i.sortBy)((0,i.pickBy)(c,(e=>{if(r&&!1===(0,u.transactionMatchesNetwork)(e,s,o))return!1;for(const[t,r]of Object.entries(a))if(t in e.txParams){if(!1===r(e.txParams[t]))return!1}else if(!1===r(e[t]))return!1;return!0})),"time");if(n!==undefined){const e=new Set,t=[];for(let r=l.length-1;r>-1;r--){const s=l[r],{nonce:o}=s.txParams;if(!e.has(o)){if(!(e.size<n))continue;e.add(o)}t.unshift(s)}return t}return l}setTxStatusRejected(e){this._setTransactionStatus(e,c.TransactionStatus.rejected),this._deleteTransaction(e)}setTxStatusUnapproved(e){this._setTransactionStatus(e,c.TransactionStatus.unapproved)}setTxStatusApproved(e){this._setTransactionStatus(e,c.TransactionStatus.approved)}setTxStatusSigned(e){this._setTransactionStatus(e,c.TransactionStatus.signed)}setTxStatusSubmitted(e){const t=this.getTransaction(e);t.submittedTime=(new Date).getTime(),this.updateTransaction(t,"txStateManager - add submitted time stamp"),this._setTransactionStatus(e,c.TransactionStatus.submitted)}setTxStatusConfirmed(e){this._setTransactionStatus(e,c.TransactionStatus.confirmed)}setTxStatusDropped(e){this._setTransactionStatus(e,c.TransactionStatus.dropped)}setTxStatusFailed(e,t){var r;const n=t||new Error("Internal metamask failure"),s=this.getTransaction(e);s.err={message:(null===(r=n.message)||void 0===r?void 0:r.toString())||n.toString(),rpc:n.value,stack:n.stack},this._updateTransactionHistory(s,"transactions:tx-state-manager#fail - add error"),this._setTransactionStatus(e,c.TransactionStatus.failed)}wipeTransactions(e){const{transactions:t}=this.store.getState(),r=this.getCurrentChainId(),n=this.getNetworkId();this.store.updateState({transactions:(0,i.omitBy)(t,(t=>t.txParams.from===e&&(0,u.transactionMatchesNetwork)(t,r,n)))})}clearUnapprovedTxs(){this.store.updateState({transactions:(0,i.omitBy)(this.store.getState().transactions,(e=>e.status===c.TransactionStatus.unapproved))})}_setTransactionStatus(e,t){const r=this.getTransaction(e);if(r){r.status=t;try{this._updateTransactionHistory(r,`txStateManager: setting status to ${t}`),this.emit(`${r.id}:${t}`,e),this.emit("tx:status-update",e,t),[c.TransactionStatus.submitted,c.TransactionStatus.rejected,c.TransactionStatus.failed].includes(t)&&this.emit(`${r.id}:finished`,r),this.emit(l.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE)}catch(e){o.default.error(e)}}}_addTransactionsToState(e){this.store.updateState({transactions:e.reduce(((e,t)=>(e[t.id]=t,e)),this.store.getState().transactions)})}_deleteTransaction(e){const{transactions:t}=this.store.getState();delete t[e],this.store.updateState({transactions:t})}_deleteTransactions(e){const{transactions:t}=this.store.getState();e.forEach((e=>{delete t[e]})),this.store.updateState({transactions:t})}}r.default=y}}},{package:"$root$",file:"app/scripts/controllers/transactions/tx-state-manager.js"}],[3412,{"./time":3415},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME=r.FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER=r.FALLBACK_SMART_TRANSACTIONS_DEADLINE=void 0;const n=10*e("./time").SECOND;r.FALLBACK_SMART_TRANSACTIONS_REFRESH_TIME=n;r.FALLBACK_SMART_TRANSACTIONS_DEADLINE=180;r.FALLBACK_SMART_TRANSACTIONS_MAX_FEE_MULTIPLIER=2}}},{package:"$root$",file:"shared/constants/smartTransactions.js"}],[3414,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ACTION_QUEUE_METRICS_E2E_TEST=void 0;r.ACTION_QUEUE_METRICS_E2E_TEST="action_queue_metrics_e2e_test"}}},{package:"$root$",file:"shared/constants/test-flags.js"}],[35,{"../../shared/constants/app":3401,"./lib/util":82,"webextension-polyfill":3385},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.onMessageReceived=r.checkForMultipleVersionsRunning=void 0;var n,s=(n=e("webextension-polyfill"))&&n.__esModule?n:{default:n},o=e("../../shared/constants/app"),i=e("./lib/util");const a="isRunning";r.onMessageReceived=e=>{e===a&&console.warn("Warning! You have multiple instances of MetaMask running!")};r.checkForMultipleVersionsRunning=async()=>{if((0,i.getPlatform)()!==o.PLATFORM_CHROME&&(0,i.getPlatform)()!==o.PLATFORM_FIREFOX)return;const e=(0,i.getPlatform)()===o.PLATFORM_CHROME?o.CHROME_BUILD_IDS:o.FIREFOX_BUILD_IDS,t=s.default.runtime.id;for(const r of e)if(r!==t)try{await s.default.runtime.sendMessage(r,a)}catch(e){}}}}},{package:"$root$",file:"app/scripts/detect-multiple-instances.js"}],[36,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n={config:{}};r.default=n}}},{package:"$root$",file:"app/scripts/first-time-state.js"}],[37,{"@metamask/base-controller":1079,"@metamask/obs-store":1298},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("@metamask/obs-store"),s=e("@metamask/base-controller");function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(r!==undefined){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class i extends n.ObservableStore{constructor({config:e,controllerMessenger:t,state:r,persist:n}){super(r),o(this,"config",{}),this.persist=n,this.controllerMessenger=t,e&&this.updateStructure(e)}updateStructure(e){this.config=e,this.removeAllListeners();for(const t of Object.keys(e)){if(!e[t])throw new Error(`Undefined '${t}'`);const r=e[t];r.subscribe?e[t].subscribe((e=>{this.updateState({[t]:e})})):this.controllerMessenger.subscribe(`${r.name}:stateChange`,(r=>{let n=r;this.persist&&(n=(0,s.getPersistentState)(r,e[t].metadata)),this.updateState({[t]:n})}))}}getFlatState(){if(!this.config)return{};let e={};for(const t of Object.keys(this.config)){const r=this.config[t],n=r.getState?r.getState():r.state;e={...e,...n}}return e}}r.default=i}}},{package:"$root$",file:"app/scripts/lib/ComposableObservableStore.js"}],[38,{"../../../shared/constants/network":3409,"../constants/contracts":5,"./util":82,"@ethersproject/contracts":420,"@ethersproject/providers":459,"@metamask/obs-store":1298,"eth-query":2166,loglevel:2944,pify:3024,"single-call-balance-checker-abi":3278},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=p(e("eth-query")),s=e("@metamask/obs-store"),o=p(e("loglevel")),i=p(e("pify")),a=e("@ethersproject/providers"),c=e("@ethersproject/contracts"),l=p(e("single-call-balance-checker-abi")),u=e("../../../shared/constants/network"),d=e("../constants/contracts"),h=e("./util");function p(e){return e&&e.__esModule?e:{default:e}}r.default=class{constructor(e={}){const t={accounts:{},currentBlockGasLimit:""};this.store=new s.ObservableStore({...t,...e.initState}),this.resetState=()=>{this.store.updateState(t)},this._provider=e.provider,this._query=(0,i.default)(new n.default(this._provider)),this._blockTracker=e.blockTracker,this._currentBlockNumber=this._blockTracker.getCurrentBlock(),this._blockTracker.once("latest",(e=>{this._currentBlockNumber=e})),this._updateForBlock=this._updateForBlock.bind(this),this.getCurrentChainId=e.getCurrentChainId,this.getNetworkIdentifier=e.getNetworkIdentifier,this.preferencesController=e.preferencesController,this.onboardingController=e.onboardingController,this.onboardingController.store.subscribe((0,h.previousValueComparator)((async(e,t)=>{const{completedOnboarding:r}=e,{completedOnboarding:n}=t;!r&&n&&this._updateAccounts()}),this.onboardingController.store.getState())),this.preferencesController.store.subscribe((0,h.previousValueComparator)((async(e,t)=>{const{selectedAddress:r}=e,{selectedAddress:n,useMultiAccountBalanceChecker:s}=t;r===n||s||this._updateAccounts()}),this.onboardingController.store.getState())),this.ethersProvider=new a.Web3Provider(this._provider)}start(){this._blockTracker.removeListener("latest",this._updateForBlock),this._blockTracker.addListener("latest",this._updateForBlock),this._updateAccounts()}stop(){this._blockTracker.removeListener("latest",this._updateForBlock)}syncWithAddresses(e){const{accounts:t}=this.store.getState(),r=Object.keys(t),n=[];e.forEach((e=>{r.includes(e)||n.push(e)}));const s=[];r.forEach((t=>{e.includes(t)||s.push(t)})),this.addAccounts(n),this.removeAccount(s)}addAccounts(e){const{accounts:t}=this.store.getState();e.forEach((e=>{t[e]={}})),this.store.updateState({accounts:t}),this._currentBlockNumber&&this._updateAccounts()}removeAccount(e){const{accounts:t}=this.store.getState();e.forEach((e=>{delete t[e]})),this.store.updateState({accounts:t})}clearAccounts(){this.store.updateState({accounts:{}})}async _updateForBlock(e){this._currentBlockNumber=e;const t=await this._query.getBlockByNumber(e,!1);if(!t)return;const r=t.gasLimit;this.store.updateState({currentBlockGasLimit:r});try{await this._updateAccounts()}catch(e){o.default.error(e)}}async _updateAccounts(){const{completedOnboarding:e}=this.onboardingController.store.getState();if(!e)return;const{useMultiAccountBalanceChecker:t}=this.preferencesController.store.getState();let r=[];if(t){const{accounts:e}=this.store.getState();r=Object.keys(e)}else{r=[this.preferencesController.getSelectedAddress()]}const n=this.getCurrentChainId(),s=this.getNetworkIdentifier();if(s===u.LOCALHOST_RPC_URL||"http://127.0.0.1:8545"===s)await Promise.all(r.map(this._updateAccount.bind(this)));else switch(n){case u.CHAIN_IDS.MAINNET:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS);break;case u.CHAIN_IDS.GOERLI:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_GOERLI);break;case u.CHAIN_IDS.SEPOLIA:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_SEPOLIA);break;case u.CHAIN_IDS.BSC:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_BSC);break;case u.CHAIN_IDS.OPTIMISM:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_OPTIMISM);break;case u.CHAIN_IDS.POLYGON:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_POLYGON);break;case u.CHAIN_IDS.AVALANCHE:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_AVALANCHE);break;case u.CHAIN_IDS.FANTOM:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_FANTOM);break;case u.CHAIN_IDS.ARBITRUM:await this._updateAccountsViaBalanceChecker(r,d.SINGLE_CALL_BALANCES_ADDRESS_ARBITRUM);break;default:await Promise.all(r.map(this._updateAccount.bind(this)))}}async _updateAccount(e){const{useMultiAccountBalanceChecker:t}=this.preferencesController.store.getState();let r="0x0";try{r=await this._query.getBalance(e)}catch(e){var n,s;if("eth_getBalance"!==(null===(n=e.data)||void 0===n||null===(s=n.request)||void 0===s?void 0:s.method))throw e}const o={address:e,balance:r},{accounts:i}=this.store.getState();if(!i[e])return;let a=i;t||(a={},Object.keys(i).forEach((t=>{e!==t&&(a[t]={address:t,balance:null})}))),a[e]=o,this.store.updateState({accounts:a})}async _updateAccountsViaBalanceChecker(e,t){const{accounts:r}=this.store.getState(),n={};Object.keys(r).forEach((t=>{e.includes(t)||(n[t]={address:t,balance:null})})),this.ethersProvider=new a.Web3Provider(this._provider);const s=await new c.Contract(t,l.default,this.ethersProvider),i=["0x0000000000000000000000000000000000000000"];try{const t=await s.balances(e,i);e.forEach(((e,r)=>{const s=t[r]?t[r].toHexString():"0x0";n[e]={address:e,balance:s}})),this.store.updateState({accounts:n})}catch(t){o.default.warn("MetaMask - Account Tracker single call balance fetch failed",t),Promise.all(e.map(this._updateAccount.bind(this)))}}}}}},{package:"$root$",file:"app/scripts/lib/account-tracker.js"}],[39,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){let{name:t}=e;t=t===undefined?"Error":String(t);let r=e.message;r=r===undefined?"":String(r),""===t?e.stack=e.message:""===r?e.stack=e.name:e.stack||(e.stack=`${e.name}: ${e.message}`);return e}}}},{package:"$root$",file:"app/scripts/lib/cleanErrorStack.js"}],[40,{loglevel:2944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(){const e=[];return function(t,r,n,o){return e.indexOf(t.id)>=0?(s.default.info(`RPC request with id ${t.id} already seen.`),o()):(e.push(t.id),n())}};var n,s=(n=e("loglevel"))&&n.__esModule?n:{default:n}}}},{package:"$root$",file:"app/scripts/lib/createDupeReqFilterMiddleware.js"}],[41,{loglevel:2944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return function(t,r,n){n((n=>{r.error&&s.default.error("Error in RPC response:\n",r),t.isMetamaskInternal||(s.default.info(`RPC (${e.origin}):`,t,"->",r),n())}))}};var n,s=(n=e("loglevel"))&&n.__esModule?n:{default:n}}}},{package:"$root$",file:"app/scripts/lib/createLoggerMiddleware.js"}],[42,{"../../../shared/modules/mv3.utils":3436,"eth-rpc-errors":2170},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("eth-rpc-errors"),s=e("../../../shared/modules/mv3.utils");var o=(e,t,r,o)=>async i=>{if(t._writableState.ended)return;if(!e[i.method])return void t.write({jsonrpc:"2.0",error:n.ethErrors.rpc.methodNotFound({message:`${i.method} not found`}),id:i.id});let a,c;try{a=await e[i.method](...i.params)}catch(e){c=e}finally{s.isManifestV3&&r&&"getState"!==i.method&&o.set(r.getState())}t._writableState.ended?c&&console.error(c):c?t.write({jsonrpc:"2.0",error:(0,n.serializeError)(c,{shouldIncludeStack:!0}),id:i.id}):t.write({jsonrpc:"2.0",result:a,id:i.id})};r.default=o}}},{package:"$root$",file:"app/scripts/lib/createMetaRPCHandler.js"}],[43,{"./middleware/pending":60,"@metamask/eth-json-rpc-middleware":1145,"json-rpc-engine":2724},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({version:e,getAccounts:t,processTransaction:r,processEthSignMessage:i,processTypedMessage:a,processTypedMessageV3:c,processTypedMessageV4:l,processPersonalMessage:u,processDecryptMessage:d,processEncryptionPublicKey:h,getPendingNonce:p,getPendingTransactionByHash:g}){return(0,n.mergeMiddleware)([(0,n.createScaffoldMiddleware)({eth_syncing:!1,web3_clientVersion:`MetaMask/v${e}`}),(0,s.createWalletMiddleware)({getAccounts:t,processTransaction:r,processEthSignMessage:i,processTypedMessage:a,processTypedMessageV3:c,processTypedMessageV4:l,processPersonalMessage:u,processDecryptMessage:d,processEncryptionPublicKey:h}),(0,o.createPendingNonceMiddleware)({getPendingNonce:p}),(0,o.createPendingTxMiddleware)({getPendingTransactionByHash:g})])};var n=e("json-rpc-engine"),s=e("@metamask/eth-json-rpc-middleware"),o=e("./middleware/pending")}}},{package:"$root$",file:"app/scripts/lib/createMetamaskMiddleware.js"}],[44,{loglevel:2944,"webextension-polyfill":3385},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({location:e,registerOnboarding:t}){return async function(r,o,i,a){try{if("wallet_registerOnboarding"!==r.method)return void i();r.tabId&&r.tabId!==s.default.tabs.TAB_ID_NONE?await t(e,r.tabId):n.default.debug(`'wallet_registerOnboarding' message from ${e} ignored due to missing tabId`),o.result=!0,a()}catch(e){a(e)}}};var n=o(e("loglevel")),s=o(e("webextension-polyfill"));function o(e){return e&&e.__esModule?e:{default:e}}}}},{package:"$root$",file:"app/scripts/lib/createOnboardingMiddleware.js"}],[45,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return function(t,r,n){t.origin=e.origin,n()}}}}},{package:"$root$",file:"app/scripts/lib/createOriginMiddleware.js"}],[46,{"../../../shared/constants/app":3401,"../../../shared/constants/metametrics":3408,"../../../shared/constants/time":3415,"../../../shared/constants/transaction":3417,"@metamask/controller-utils":1084,"eth-rpc-errors":2170,"ethereumjs-util":2231},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({trackEvent:e,getMetricsState:t,rateLimitSeconds:r=300,securityProviderRequest:h}){return async function(m,y,b){const{origin:v,method:w}=m,S=p[w]??u,T=S===u&&void 0!==f[w],k=!0===t().participateInMetaMetrics,C=g[w],_={},E=v!==i.ORIGIN_METAMASK&&S!==d&&!1===T&&!0===k;if(E){const t=C?C.REQUESTED:l.MetaMetricsEventName.ProviderMethodCalled;if(t===l.MetaMetricsEventName.SignatureRequested){var M,A;let e,t;var P,I,N,O;if(_.signature_type=w,(0,o.isValidAddress)(null==m||null===(M=m.params)||void 0===M?void 0:M[1]))e=null==m||null===(P=m.params)||void 0===P?void 0:P[0],t=null==m||null===(I=m.params)||void 0===I?void 0:I[1];else e=null==m||null===(N=m.params)||void 0===N?void 0:N[1],t=null==m||null===(O=m.params)||void 0===O?void 0:O[0];const r={msgParams:{...null==m||null===(A=m.params)||void 0===A?void 0:A[2],from:t,data:e,origin:v},status:a.TransactionStatus.unapproved,type:m.method};try{const t=await h(r,m.method);if(1===(null==t?void 0:t.flagAsDangerous)?_.ui_customizations=[l.MetaMetricsEventUiCustomization.FlaggedAsMalicious]:2===(null==t?void 0:t.flagAsDangerous)&&(_.ui_customizations=[l.MetaMetricsEventUiCustomization.FlaggedAsSafetyUnknown]),w===i.MESSAGE_TYPE.PERSONAL_SIGN){const{isSIWEMessage:t}=(0,s.detectSIWE)({data:e});t&&(_.ui_customizations=(_.ui_customizations||[]).concat(l.MetaMetricsEventUiCustomization.Siwe))}}catch(e){console.warn(`createRPCMethodTrackingMiddleware: Error calling securityProviderRequest - ${e}`)}}else _.method=w;e({event:t,category:l.MetaMetricsEventCategory.InpageProvider,referrer:{url:v},properties:_}),f[w]=setTimeout((()=>{delete f[w]}),c.SECOND*r)}b((async t=>{var r,s;if(!1===E||void 0===C)return t();let o;return w===i.MESSAGE_TYPE.ETH_SIGN&&(null===(r=y.error)||void 0===r?void 0:r.code)===n.errorCodes.rpc.methodNotFound?(o=C.FAILED,_.error=y.error):o=(null===(s=y.error)||void 0===s?void 0:s.code)===n.errorCodes.provider.userRejectedRequest?C.REJECTED:C.APPROVED,e({event:o,category:l.MetaMetricsEventCategory.InpageProvider,referrer:{url:v},properties:_}),t()}))}};var n=e("eth-rpc-errors"),s=e("@metamask/controller-utils"),o=e("ethereumjs-util"),i=e("../../../shared/constants/app"),a=e("../../../shared/constants/transaction"),c=e("../../../shared/constants/time"),l=e("../../../shared/constants/metametrics");const u="rate_limited",d="blocked",h="non_rate_limited",p={[i.MESSAGE_TYPE.ETH_SIGN]:h,[i.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA]:h,[i.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V3]:h,[i.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4]:h,[i.MESSAGE_TYPE.PERSONAL_SIGN]:h,[i.MESSAGE_TYPE.ETH_DECRYPT]:h,[i.MESSAGE_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY]:h,[i.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS]:u,[i.MESSAGE_TYPE.WALLET_REQUEST_PERMISSIONS]:u,[i.MESSAGE_TYPE.SEND_METADATA]:d,[i.MESSAGE_TYPE.GET_PROVIDER_STATE]:d},g={[i.MESSAGE_TYPE.ETH_SIGN]:{APPROVED:l.MetaMetricsEventName.SignatureApproved,FAILED:l.MetaMetricsEventName.SignatureFailed,REJECTED:l.MetaMetricsEventName.SignatureRejected,REQUESTED:l.MetaMetricsEventName.SignatureRequested},[i.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA]:{APPROVED:l.MetaMetricsEventName.SignatureApproved,REJECTED:l.MetaMetricsEventName.SignatureRejected,REQUESTED:l.MetaMetricsEventName.SignatureRequested},[i.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V3]:{APPROVED:l.MetaMetricsEventName.SignatureApproved,REJECTED:l.MetaMetricsEventName.SignatureRejected,REQUESTED:l.MetaMetricsEventName.SignatureRequested},[i.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4]:{APPROVED:l.MetaMetricsEventName.SignatureApproved,REJECTED:l.MetaMetricsEventName.SignatureRejected,REQUESTED:l.MetaMetricsEventName.SignatureRequested},[i.MESSAGE_TYPE.PERSONAL_SIGN]:{APPROVED:l.MetaMetricsEventName.SignatureApproved,REJECTED:l.MetaMetricsEventName.SignatureRejected,REQUESTED:l.MetaMetricsEventName.SignatureRequested},[i.MESSAGE_TYPE.ETH_DECRYPT]:{APPROVED:l.MetaMetricsEventName.DecryptionApproved,REJECTED:l.MetaMetricsEventName.DecryptionRejected,REQUESTED:l.MetaMetricsEventName.DecryptionRequested},[i.MESSAGE_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY]:{APPROVED:l.MetaMetricsEventName.EncryptionPublicKeyApproved,REJECTED:l.MetaMetricsEventName.EncryptionPublicKeyRejected,REQUESTED:l.MetaMetricsEventName.EncryptionPublicKeyRequested},[i.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS]:{APPROVED:l.MetaMetricsEventName.PermissionsApproved,REJECTED:l.MetaMetricsEventName.PermissionsRejected,REQUESTED:l.MetaMetricsEventName.PermissionsRequested},[i.MESSAGE_TYPE.WALLET_REQUEST_PERMISSIONS]:{APPROVED:l.MetaMetricsEventName.PermissionsApproved,REJECTED:l.MetaMetricsEventName.PermissionsRejected,REQUESTED:l.MetaMetricsEventName.PermissionsRequested}},f={}}}},{package:"$root$",file:"app/scripts/lib/createRPCMethodTrackingMiddleware.js"}],[47,{"promise-to-callback":3028,"readable-stream":3190},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e,t){return new i(e,t)};var n,s=e("readable-stream"),o=(n=e("promise-to-callback"))&&n.__esModule?n:{default:n};class i extends s.Writable{constructor(e,t){super({objectMode:!0,...t}),this._asyncWriteFn=e}_write(e,t,r){(0,o.default)(this._asyncWriteFn(e,t))(r)}}}}},{package:"$root$",file:"app/scripts/lib/createStreamSink.js"}],[48,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return function(t,r,n){t.tabId=e.tabId,n()}}}}},{package:"$root$",file:"app/scripts/lib/createTabIdMiddleware.js"}],[49,{"../../../shared/constants/app":3401,"../../../shared/constants/metametrics":3408,"../../../shared/modules/hexstring-utils":3435,"../../../shared/modules/random-id":3439,"../metamask-controller":83,"./util":82,"@metamask/obs-store":1298,buffer:1943,"eth-rpc-errors":2170,"ethereumjs-util":2231,events:1944,loglevel:2944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=g(e("events")),s=e("@metamask/obs-store"),o=e("ethereumjs-util"),i=e("eth-rpc-errors"),a=g(e("loglevel")),c=e("../../../shared/constants/app"),l=e("../../../shared/constants/metametrics"),u=e("../metamask-controller"),d=g(e("../../../shared/modules/random-id")),h=e("../../../shared/modules/hexstring-utils"),p=e("./util");function g(e){return e&&e.__esModule?e:{default:e}}const f=/^[0-9A-Fa-f]+$/gu;class m extends n.default{constructor(e){super(),this.memStore=new s.ObservableStore({unapprovedDecryptMsgs:{},unapprovedDecryptMsgCount:0}),this.resetState=()=>{this.memStore.updateState({unapprovedDecryptMsgs:{},unapprovedDecryptMsgCount:0})},this.messages=[],this.metricsEvent=e.metricsEvent}get unapprovedDecryptMsgCount(){return Object.keys(this.getUnapprovedMsgs()).length}getUnapprovedMsgs(){return this.messages.filter((e=>"unapproved"===e.status)).reduce(((e,t)=>(e[t.id]=t,e)),{})}addUnapprovedMessageAsync(e,t){return new Promise(((r,n)=>{if(!e.from)return void n(new Error("MetaMask Decryption: from field is required."));const s=this.addUnapprovedMessage(e,t);this.once(`${s}:finished`,(t=>{switch(t.status){case"decrypted":return void r(t.rawData);case"rejected":return void n(i.ethErrors.provider.userRejectedRequest("MetaMask Decryption: User denied message decryption."));case"errored":return void n(new Error("This message cannot be decrypted"));default:n(new Error(`MetaMask Decryption: Unknown problem: ${JSON.stringify(e)}`))}}))}))}addUnapprovedMessage(e,t){a.default.debug(`DecryptMessageManager addUnapprovedMessage: ${JSON.stringify(e)}`),t&&(e.origin=t.origin),e.data=this.normalizeMsgData(e.data);const r=(new Date).getTime(),n=(0,d.default)(),s={id:n,msgParams:e,time:r,status:"unapproved",type:c.MESSAGE_TYPE.ETH_DECRYPT};return this.addMsg(s),this.emit("update"),n}addMsg(e){this.messages.push(e),this._saveMsgList()}getMsg(e){return this.messages.find((t=>t.id===e))}approveMessage(e){return this.setMsgStatusApproved(e.metamaskId),this.prepMsgForDecryption(e)}setMsgStatusApproved(e){this._setMsgStatus(e,"approved")}setMsgStatusDecrypted(e,t){const r=this.getMsg(e);r.rawData=t,this._updateMsg(r),this._setMsgStatus(e,"decrypted")}async prepMsgForDecryption(e){return delete e.metamaskId,e}rejectMsg(e,t=undefined){t&&this.metricsEvent({event:t,category:l.MetaMetricsEventCategory.Messages,properties:{action:"Decrypt Message Request"}}),this._setMsgStatus(e,"rejected")}errorMessage(e,t){const r=this.getMsg(e);r.error=t,this._updateMsg(r),this._setMsgStatus(e,"errored")}clearUnapproved(){this.messages=this.messages.filter((e=>"unapproved"!==e.status)),this._saveMsgList()}_setMsgStatus(e,t){const r=this.getMsg(e);if(!r)throw new Error(`DecryptMessageManager - Message not found for id: "${e}".`);r.status=t,this._updateMsg(r),this.emit(`${e}:${t}`,r),"rejected"!==t&&"decrypted"!==t&&"errored"!==t||this.emit(`${e}:finished`,r)}_updateMsg(e){const t=this.messages.findIndex((t=>t.id===e.id));-1!==t&&(this.messages[t]=e),this._saveMsgList()}_saveMsgList(){const e=this.getUnapprovedMsgs(),t=Object.keys(e).length;this.memStore.updateState({unapprovedDecryptMsgs:e,unapprovedDecryptMsgCount:t}),this.emit(u.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE)}normalizeMsgData(e){try{const t=(0,h.stripHexPrefix)(e);if(t.match(f))return(0,p.addHexPrefix)(t)}catch(e){a.default.debug("Message was not hex encoded, interpreting as utf8.")}return(0,o.bufferToHex)(t.from(e,"utf8"))}}r.default=m}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"$root$",file:"app/scripts/lib/decrypt-message-manager.js"}],[5,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.SINGLE_CALL_BALANCES_ADDRESS_SEPOLIA=r.SINGLE_CALL_BALANCES_ADDRESS_POLYGON=r.SINGLE_CALL_BALANCES_ADDRESS_OPTIMISM=r.SINGLE_CALL_BALANCES_ADDRESS_GOERLI=r.SINGLE_CALL_BALANCES_ADDRESS_FANTOM=r.SINGLE_CALL_BALANCES_ADDRESS_BSC=r.SINGLE_CALL_BALANCES_ADDRESS_AVALANCHE=r.SINGLE_CALL_BALANCES_ADDRESS_ARBITRUM=r.SINGLE_CALL_BALANCES_ADDRESS=void 0;r.SINGLE_CALL_BALANCES_ADDRESS="0xb1f8e55c7f64d203c1400b9d8555d050f94adf39";r.SINGLE_CALL_BALANCES_ADDRESS_GOERLI="0x9788C4E93f9002a7ad8e72633b11E8d1ecd51f9b";r.SINGLE_CALL_BALANCES_ADDRESS_SEPOLIA="";r.SINGLE_CALL_BALANCES_ADDRESS_BSC="0x2352c63A83f9Fd126af8676146721Fa00924d7e4";r.SINGLE_CALL_BALANCES_ADDRESS_OPTIMISM="0xB1c568e9C3E6bdaf755A60c7418C269eb11524FC";r.SINGLE_CALL_BALANCES_ADDRESS_POLYGON="0x2352c63A83f9Fd126af8676146721Fa00924d7e4";r.SINGLE_CALL_BALANCES_ADDRESS_AVALANCHE="0xD023D153a0DFa485130ECFdE2FAA7e612EF94818";r.SINGLE_CALL_BALANCES_ADDRESS_FANTOM="0x07f697424ABe762bB808c109860c04eA488ff92B";r.SINGLE_CALL_BALANCES_ADDRESS_ARBITRUM="0x151E24A486D7258dd7C33Fb67E4bB01919B7B32c"}}},{package:"$root$",file:"app/scripts/constants/contracts.ts"}],[50,{"../../../shared/constants/app":3401,"../../../shared/constants/metametrics":3408,"../../../shared/modules/random-id":3439,"../metamask-controller":83,"@metamask/obs-store":1298,"eth-rpc-errors":2170,events:1944,loglevel:2944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=d(e("events")),s=e("@metamask/obs-store"),o=e("eth-rpc-errors"),i=d(e("loglevel")),a=e("../../../shared/constants/app"),c=e("../../../shared/constants/metametrics"),l=e("../metamask-controller"),u=d(e("../../../shared/modules/random-id"));function d(e){return e&&e.__esModule?e:{default:e}}class h extends n.default{constructor(e){super(),this.memStore=new s.ObservableStore({unapprovedEncryptionPublicKeyMsgs:{},unapprovedEncryptionPublicKeyMsgCount:0}),this.resetState=()=>{this.memStore.updateState({unapprovedEncryptionPublicKeyMsgs:{},unapprovedEncryptionPublicKeyMsgCount:0})},this.messages=[],this.metricsEvent=e.metricsEvent}get unapprovedEncryptionPublicKeyMsgCount(){return Object.keys(this.getUnapprovedMsgs()).length}getUnapprovedMsgs(){return this.messages.filter((e=>"unapproved"===e.status)).reduce(((e,t)=>(e[t.id]=t,e)),{})}addUnapprovedMessageAsync(e,t){return new Promise(((r,n)=>{if(!e)return void n(new Error("MetaMask Message: address field is required."));const s=this.addUnapprovedMessage(e,t);this.once(`${s}:finished`,(t=>{switch(t.status){case"received":return void r(t.rawData);case"rejected":return void n(o.ethErrors.provider.userRejectedRequest("MetaMask EncryptionPublicKey: User denied message EncryptionPublicKey."));default:n(new Error(`MetaMask EncryptionPublicKey: Unknown problem: ${JSON.stringify(e)}`))}}))}))}addUnapprovedMessage(e,t){i.default.debug("EncryptionPublicKeyManager addUnapprovedMessage: address");const r=(new Date).getTime(),n=(0,u.default)(),s={id:n,msgParams:e,time:r,status:"unapproved",type:a.MESSAGE_TYPE.ETH_GET_ENCRYPTION_PUBLIC_KEY};return t&&(s.origin=t.origin),this.addMsg(s),this.emit("update"),n}addMsg(e){this.messages.push(e),this._saveMsgList()}getMsg(e){return this.messages.find((t=>t.id===e))}approveMessage(e){return this.setMsgStatusApproved(e.metamaskId),this.prepMsgForEncryptionPublicKey(e)}setMsgStatusApproved(e){this._setMsgStatus(e,"approved")}setMsgStatusReceived(e,t){const r=this.getMsg(e);r.rawData=t,this._updateMsg(r),this._setMsgStatus(e,"received")}async prepMsgForEncryptionPublicKey(e){return delete e.metamaskId,e}rejectMsg(e,t=undefined){t&&this.metricsEvent({event:t,category:c.MetaMetricsEventCategory.Messages,properties:{action:"Encryption public key Request"}}),this._setMsgStatus(e,"rejected")}errorMessage(e,t){const r=this.getMsg(e);r.error=t,this._updateMsg(r),this._setMsgStatus(e,"errored")}clearUnapproved(){this.messages=this.messages.filter((e=>"unapproved"!==e.status)),this._saveMsgList()}_setMsgStatus(e,t){const r=this.getMsg(e);if(!r)throw new Error(`EncryptionPublicKeyManager - Message not found for id: "${e}".`);r.status=t,this._updateMsg(r),this.emit(`${e}:${t}`,r),"rejected"!==t&&"received"!==t||this.emit(`${e}:finished`,r)}_updateMsg(e){const t=this.messages.findIndex((t=>t.id===e.id));-1!==t&&(this.messages[t]=e),this._saveMsgList()}_saveMsgList(){const e=this.getUnapprovedMsgs(),t=Object.keys(e).length;this.memStore.updateState({unapprovedEncryptionPublicKeyMsgs:e,unapprovedEncryptionPublicKeyMsgCount:t}),this.emit(l.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE)}}r.default=h}}},{package:"$root$",file:"app/scripts/lib/encryption-public-key-manager.js"}],[51,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=[{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"resolver",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"owner",outputs:[{name:"",type:"address"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"label",type:"bytes32"},{name:"owner",type:"address"}],name:"setSubnodeOwner",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"ttl",type:"uint64"}],name:"setTTL",outputs:[],payable:!1,type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"ttl",outputs:[{name:"",type:"uint64"}],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"resolver",type:"address"}],name:"setResolver",outputs:[],payable:!1,type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"owner",type:"address"}],name:"setOwner",outputs:[],payable:!1,type:"function"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"label",type:"bytes32"},{indexed:!1,name:"owner",type:"address"}],name:"NewOwner",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"resolver",type:"address"}],name:"NewResolver",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"ttl",type:"uint64"}],name:"NewTTL",type:"event"}];r.default=n}}},{package:"$root$",file:"app/scripts/lib/ens-ipfs/contracts/registry.js"}],[518,{"@ethereumjs/tx":363,"@ethereumjs/util":374,"@keystonehq/bc-ur-registry-eth":524,buffer:1943,hdkey:2683,rlp:521,uuid:3351},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(r,"__esModule",{value:!0});var s=n(e("hdkey")),o=e("@ethereumjs/util"),i=n(e("rlp")),a=e("@ethereumjs/tx"),c=e("@keystonehq/bc-ur-registry-eth"),l=e("uuid");const u="QR Hardware Wallet Device",d="m",h="0/*";var p,g;!function(e){e.hd="hd",e.pubkey="pubkey"}(p||(p={})),function(e){e.standard="account.standard",e.ledger_live="account.ledger_live",e.ledger_legacy="account.ledger_legacy"}(g||(g={}));class f{constructor(e){this.version=1,this.getInteraction=()=>{throw new Error("KeystoneError#invalid_extends: method getInteraction not implemented, please extend BaseKeyring by overwriting this method.")},this.type=u,this.requestSignature=async(e,t,r,n)=>{const s=await this.getInteraction().requestSignature(t,r,n),o=s.getRequestId(),i=s.getSignature();if(o){if(l.stringify(o)!==e)throw new Error("KeystoneError#invalid_data: read signature error: mismatched requestId")}return{r:i.slice(0,32),s:i.slice(32,64),v:i.slice(64)}},this.__readCryptoHDKey=e=>{var t,r;const n=`m/${e.getOrigin().getPath()}`,s=null==(t=e.getOrigin().getSourceFingerprint())?void 0:t.toString("hex"),o=(null==(r=e.getChildren())?void 0:r.getPath())||h,i=e.getName();if(e.getNote()===g.standard?this.keyringAccount=g.standard:e.getNote()===g.ledger_legacy&&(this.keyringAccount=g.ledger_legacy),!s)throw new Error("KeystoneError#invalid_data: invalid crypto-hdkey, cannot get source fingerprint");const a=e.getBip32Key();this.xfp=s,this.xpub=a,this.hdPath=n,this.childrenPath=o,i!==undefined&&""!==i&&(this.name=i),this.initialized=!0},this.__readCryptoAccount=e=>{var t,r;const n=null==(t=e.getMasterFingerprint())?void 0:t.toString("hex");if(!n)throw new Error("KeystoneError#invalid_data: invalid crypto-account, cannot get master fingerprint");this.xfp=n,this.initialized=!0;let s=!1;const i=e.getOutputDescriptors();if(!i||0===i.length)throw new Error("KeystoneError#invalid_data: invalid crypto-account, no crypto output found");if(i.length%5!=0)throw new Error("KeystoneError#invalid_data: only support 5x pubkey accounts for now");return null==(r=e.getOutputDescriptors())||r.forEach((e=>{try{const t=e.getHDKey();if(t){const e=t.getKey(),r=`M/${t.getOrigin().getPath()}`,n="0x"+o.publicToAddress(e,!0).toString("hex");this.name=t.getName(),t.getNote()===g.ledger_live&&(this.keyringAccount=g.ledger_live),this.paths[o.toChecksumAddress(n)]===undefined&&(s=!0),this.paths[o.toChecksumAddress(n)]=r}}catch(e){throw new Error(`KeystoneError#invalid_data: ${e}`)}})),s},this.getName=()=>this.name,this.setAccountToUnlock=e=>{this.unlockedAccount=parseInt(e,10)},this.__getNormalPage=async e=>{this.page+=e,this.page<=0&&(this.page=1);const t=(this.page-1)*this.perPage,r=t+this.perPage,n=[];for(let e=t;e<r;e++){const t=await this.__addressFromIndex(d,e);n.push({address:t,balance:null,index:e}),this.indexes[o.toChecksumAddress(t)]=e}return n},this.__getLedgerLivePage=async e=>{const t=(this.page+e-1)*this.perPage,r=t+this.perPage,n=[];for(let e=t;e<r;e++){const t=await this.__addressFromIndex(d,e);n.push({address:t,balance:null,index:e})}return this.page+=e,n},this.__addressFromIndex=async(e,t)=>{if(this.keyringMode===p.hd){this.checkKeyring(),this.hdk||(this.hdk=s.fromExtendedKey(this.xpub));const r=this.childrenPath.replace("*",String(t)).replace(/\*/g,"0"),n=this.hdk.derive(`${e}/${r}`),i="0x"+o.publicToAddress(n.publicKey,!0).toString("hex");return o.toChecksumAddress(i)}{const e=Object.keys(this.paths)[t];if(e)return o.toChecksumAddress(e);throw new Error("KeystoneError#pubkey_account.no_expected_account")}},this.page=0,this.perPage=5,this.accounts=[],this.currentAccount=0,this.unlockedAccount=0,this.name="QR Hardware",this.keyringMode=p.hd,this.keyringAccount=g.standard,this.initialized=!1,this.xfp="",this.xpub="",this.hdPath="",this.childrenPath=h,this.indexes={},this.paths={},this.deserialize(e)}async readKeyring(){const e=await this.getInteraction().readCryptoHDKeyOrCryptoAccount();this.syncKeyring(e)}syncKeyring(e){e.getRegistryType().getType()===c.extend.RegistryTypes.CRYPTO_HDKEY.getType()?(this.keyringMode=p.hd,this.__readCryptoHDKey(e)):(this.keyringMode=p.pubkey,this.__readCryptoAccount(e))}checkKeyring(){if(!this.xfp||!this.xpub||!this.hdPath)throw new Error("KeystoneError#invalid_keyring: keyring not fulfilled, please call function `readKeyring` firstly")}serialize(){return Promise.resolve({initialized:this.initialized,accounts:this.accounts,currentAccount:this.currentAccount,page:this.page,perPage:this.perPage,keyringAccount:this.keyringAccount,keyringMode:this.keyringMode,name:this.name,version:this.version,xfp:this.xfp,xpub:this.xpub,hdPath:this.hdPath,childrenPath:this.childrenPath,indexes:this.indexes,paths:this.paths})}deserialize(e){e&&(this.accounts=e.accounts,this.currentAccount=e.currentAccount,this.page=e.page,this.perPage=e.perPage,this.name=e.name,this.initialized=e.initialized,this.keyringMode=e.keyringMode||p.hd,this.keyringAccount=e.keyringAccount||g.standard,this.xfp=e.xfp,this.xpub=e.xpub,this.hdPath=e.hdPath,this.indexes=e.indexes,this.paths=e.paths,this.childrenPath=e.childrenPath||h)}setCurrentAccount(e){this.currentAccount=e}getCurrentAccount(){return this.currentAccount}getCurrentAddress(){return this.accounts[this.currentAccount]}async addAccounts(e=1){const t=this.unlockedAccount,r=t+e,n=[];for(let e=t;e<r;e++){const t=await this.__addressFromIndex(d,e);n.push(t),this.page=0,this.unlockedAccount++}return this.accounts=this.accounts.concat(n),this.accounts}getFirstPage(){return this.page=0,this.__getPage(1)}getNextPage(){return this.__getPage(1)}getPreviousPage(){return this.__getPage(-1)}async __getPage(e){return this.initialized||await this.readKeyring(),this.keyringMode===p.hd?this.__getNormalPage(e):this.__getLedgerLivePage(e)}getAccounts(){return Promise.resolve(this.accounts)}removeAccount(e){if(!this.accounts.map((e=>e.toLowerCase())).includes(e.toLowerCase()))throw new Error(`Address ${e} not found in this keyring`);this.accounts=this.accounts.filter((t=>t.toLowerCase()!==e.toLowerCase()))}async signTransaction(e,r){const n=0===r.type?c.DataType.transaction:c.DataType.typedTransaction;let s;s=0===r.type?t.from(i.encode(r.getMessageToSign(!1))):r.getMessageToSign(!1);const o=await this._pathFromAddress(e),u=r.common.chainId(),d=l.v4(),h=c.EthSignRequest.constructETHRequest(s,n,o,this.xfp,d,u),{r:p,s:g,v:f}=await this.requestSignature(d,h,"Scan with your Keystone",'After your Keystone has signed the transaction, click on "Scan Keystone" to receive the signature');return a.TransactionFactory.fromTxData({...r.toJSON(),type:r.type,r:p,s:g,v:f},{common:r.common})}signMessage(e,t){return this.signPersonalMessage(e,t)}async signPersonalMessage(e,r){const n=o.stripHexPrefix(r),s=await this._pathFromAddress(e),i=l.v4(),a=c.EthSignRequest.constructETHRequest(t.from(n,"hex"),c.DataType.personalMessage,s,this.xfp,i,undefined,e),{r:u,s:d,v:h}=await this.requestSignature(i,a,"Scan with your Keystone",'After your Keystone has signed this message, click on "Scan Keystone" to receive the signature');return"0x"+t.concat([u,d,h]).toString("hex")}async signTypedData(e,r){const n=await this._pathFromAddress(e),s=l.v4(),o=c.EthSignRequest.constructETHRequest(t.from(JSON.stringify(r),"utf-8"),c.DataType.typedData,n,this.xfp,s,undefined,e),{r:i,s:a,v:u}=await this.requestSignature(s,o,"Scan with your Keystone",'After your Keystone has signed this data, click on "Scan Keystone" to receive the signature');return"0x"+t.concat([i,a,u]).toString("hex")}async _pathFromAddress(e){if(this.keyringMode===p.hd){const t=o.toChecksumAddress(e);let r=this.indexes[t];if(void 0===r)for(let e=0;e<1e3;e++)if(t===await this.__addressFromIndex(d,e)){r=e;break}if(void 0===r)throw new Error("Unknown address");return`${this.hdPath}/${this.childrenPath.replace("*",r.toString()).replace(/\*/g,"0")}`}{const t=o.toChecksumAddress(e),r=this.paths[t];if(void 0===r)throw new Error("Unknown address");return r}}}f.type=u,r.BaseKeyring=f}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@keystonehq/metamask-airgapped-keyring>@keystonehq/base-eth-keyring",file:"node_modules/@keystonehq/base-eth-keyring/dist/base-eth-keyring.cjs.development.js"}],[519,{"@ethereumjs/tx":363,"@ethereumjs/util":374,"@keystonehq/bc-ur-registry-eth":524,buffer:1943,hdkey:2683,rlp:521,uuid:3351},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){function n(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(r,"__esModule",{value:!0});var s,o,i=n(e("hdkey")),a=e("@ethereumjs/util"),c=n(e("rlp")),l=e("@ethereumjs/tx"),u=e("@keystonehq/bc-ur-registry-eth"),d=e("uuid");!function(e){e.hd="hd",e.pubkey="pubkey"}(s||(s={})),function(e){e.standard="account.standard",e.ledger_live="account.ledger_live",e.ledger_legacy="account.ledger_legacy"}(o||(o={}));class h{constructor(e){this.version=1,this.getInteraction=()=>{throw new Error("KeystoneError#invalid_extends: method getInteraction not implemented, please extend BaseKeyring by overwriting this method.")},this.type="QR Hardware Wallet Device",this.requestSignature=async(e,t,r,n)=>{const s=await this.getInteraction().requestSignature(t,r,n),o=s.getRequestId(),i=s.getSignature();if(o&&d.stringify(o)!==e)throw new Error("KeystoneError#invalid_data: read signature error: mismatched requestId");return{r:i.slice(0,32),s:i.slice(32,64),v:i.slice(64)}},this.__readCryptoHDKey=e=>{var t,r;const n="m/"+e.getOrigin().getPath(),s=null==(t=e.getOrigin().getSourceFingerprint())?void 0:t.toString("hex"),i=(null==(r=e.getChildren())?void 0:r.getPath())||"0/*",a=e.getName();if(e.getNote()===o.standard?this.keyringAccount=o.standard:e.getNote()===o.ledger_legacy&&(this.keyringAccount=o.ledger_legacy),!s)throw new Error("KeystoneError#invalid_data: invalid crypto-hdkey, cannot get source fingerprint");const c=e.getBip32Key();this.xfp=s,this.xpub=c,this.hdPath=n,this.childrenPath=i,void 0!==a&&""!==a&&(this.name=a),this.initialized=!0},this.__readCryptoAccount=e=>{var t,r;const n=null==(t=e.getMasterFingerprint())?void 0:t.toString("hex");if(!n)throw new Error("KeystoneError#invalid_data: invalid crypto-account, cannot get master fingerprint");this.xfp=n,this.initialized=!0;let s=!1;const i=e.getOutputDescriptors();if(!i||0===i.length)throw new Error("KeystoneError#invalid_data: invalid crypto-account, no crypto output found");if(i.length%5!=0)throw new Error("KeystoneError#invalid_data: only support 5x pubkey accounts for now");return null==(r=e.getOutputDescriptors())||r.forEach((e=>{try{const t=e.getHDKey();if(t){const e=t.getKey(),r="M/"+t.getOrigin().getPath(),n="0x"+a.publicToAddress(e,!0).toString("hex");this.name=t.getName(),t.getNote()===o.ledger_live&&(this.keyringAccount=o.ledger_live),void 0===this.paths[a.toChecksumAddress(n)]&&(s=!0),this.paths[a.toChecksumAddress(n)]=r}}catch(e){throw new Error("KeystoneError#invalid_data: "+e)}})),s},this.getName=()=>this.name,this.setAccountToUnlock=e=>{this.unlockedAccount=parseInt(e,10)},this.__getNormalPage=async e=>{this.page+=e,this.page<=0&&(this.page=1);const t=(this.page-1)*this.perPage,r=t+this.perPage,n=[];for(let e=t;e<r;e++){const t=await this.__addressFromIndex("m",e);n.push({address:t,balance:null,index:e}),this.indexes[a.toChecksumAddress(t)]=e}return n},this.__getLedgerLivePage=async e=>{const t=(this.page+e-1)*this.perPage,r=t+this.perPage,n=[];for(let e=t;e<r;e++){const t=await this.__addressFromIndex("m",e);n.push({address:t,balance:null,index:e})}return this.page+=e,n},this.__addressFromIndex=async(e,t)=>{if(this.keyringMode===s.hd){this.checkKeyring(),this.hdk||(this.hdk=i.fromExtendedKey(this.xpub));const r=this.childrenPath.replace("*",String(t)).replace(/\*/g,"0"),n=this.hdk.derive(`${e}/${r}`),s="0x"+a.publicToAddress(n.publicKey,!0).toString("hex");return a.toChecksumAddress(s)}{const e=Object.keys(this.paths)[t];if(e)return a.toChecksumAddress(e);throw new Error("KeystoneError#pubkey_account.no_expected_account")}},this.page=0,this.perPage=5,this.accounts=[],this.currentAccount=0,this.unlockedAccount=0,this.name="QR Hardware",this.keyringMode=s.hd,this.keyringAccount=o.standard,this.initialized=!1,this.xfp="",this.xpub="",this.hdPath="",this.childrenPath="0/*",this.indexes={},this.paths={},this.deserialize(e)}async readKeyring(){const e=await this.getInteraction().readCryptoHDKeyOrCryptoAccount();this.syncKeyring(e)}syncKeyring(e){e.getRegistryType().getType()===u.extend.RegistryTypes.CRYPTO_HDKEY.getType()?(this.keyringMode=s.hd,this.__readCryptoHDKey(e)):(this.keyringMode=s.pubkey,this.__readCryptoAccount(e))}checkKeyring(){if(!this.xfp||!this.xpub||!this.hdPath)throw new Error("KeystoneError#invalid_keyring: keyring not fulfilled, please call function `readKeyring` firstly")}serialize(){return Promise.resolve({initialized:this.initialized,accounts:this.accounts,currentAccount:this.currentAccount,page:this.page,perPage:this.perPage,keyringAccount:this.keyringAccount,keyringMode:this.keyringMode,name:this.name,version:this.version,xfp:this.xfp,xpub:this.xpub,hdPath:this.hdPath,childrenPath:this.childrenPath,indexes:this.indexes,paths:this.paths})}deserialize(e){e&&(this.accounts=e.accounts,this.currentAccount=e.currentAccount,this.page=e.page,this.perPage=e.perPage,this.name=e.name,this.initialized=e.initialized,this.keyringMode=e.keyringMode||s.hd,this.keyringAccount=e.keyringAccount||o.standard,this.xfp=e.xfp,this.xpub=e.xpub,this.hdPath=e.hdPath,this.indexes=e.indexes,this.paths=e.paths,this.childrenPath=e.childrenPath||"0/*")}setCurrentAccount(e){this.currentAccount=e}getCurrentAccount(){return this.currentAccount}getCurrentAddress(){return this.accounts[this.currentAccount]}async addAccounts(e=1){const t=this.unlockedAccount,r=t+e,n=[];for(let e=t;e<r;e++){const t=await this.__addressFromIndex("m",e);n.push(t),this.page=0,this.unlockedAccount++}return this.accounts=this.accounts.concat(n),this.accounts}getFirstPage(){return this.page=0,this.__getPage(1)}getNextPage(){return this.__getPage(1)}getPreviousPage(){return this.__getPage(-1)}async __getPage(e){return this.initialized||await this.readKeyring(),this.keyringMode===s.hd?this.__getNormalPage(e):this.__getLedgerLivePage(e)}getAccounts(){return Promise.resolve(this.accounts)}removeAccount(e){if(!this.accounts.map((e=>e.toLowerCase())).includes(e.toLowerCase()))throw new Error(`Address ${e} not found in this keyring`);this.accounts=this.accounts.filter((t=>t.toLowerCase()!==e.toLowerCase()))}async signTransaction(e,r){const n=0===r.type?u.DataType.transaction:u.DataType.typedTransaction;let s;s=0===r.type?t.from(c.encode(r.getMessageToSign(!1))):r.getMessageToSign(!1);const o=await this._pathFromAddress(e),i=r.common.chainId(),a=d.v4(),h=u.EthSignRequest.constructETHRequest(s,n,o,this.xfp,a,i),{r:p,s:g,v:f}=await this.requestSignature(a,h,"Scan with your Keystone",'After your Keystone has signed the transaction, click on "Scan Keystone" to receive the signature');return l.TransactionFactory.fromTxData({...r.toJSON(),type:r.type,r:p,s:g,v:f},{common:r.common})}signMessage(e,t){return this.signPersonalMessage(e,t)}async signPersonalMessage(e,r){const n=a.stripHexPrefix(r),s=await this._pathFromAddress(e),o=d.v4(),i=u.EthSignRequest.constructETHRequest(t.from(n,"hex"),u.DataType.personalMessage,s,this.xfp,o,void 0,e),{r:c,s:l,v:h}=await this.requestSignature(o,i,"Scan with your Keystone",'After your Keystone has signed this message, click on "Scan Keystone" to receive the signature');return"0x"+t.concat([c,l,h]).toString("hex")}async signTypedData(e,r){const n=await this._pathFromAddress(e),s=d.v4(),o=u.EthSignRequest.constructETHRequest(t.from(JSON.stringify(r),"utf-8"),u.DataType.typedData,n,this.xfp,s,void 0,e),{r:i,s:a,v:c}=await this.requestSignature(s,o,"Scan with your Keystone",'After your Keystone has signed this data, click on "Scan Keystone" to receive the signature');return"0x"+t.concat([i,a,c]).toString("hex")}async _pathFromAddress(e){if(this.keyringMode===s.hd){const t=a.toChecksumAddress(e);let r=this.indexes[t];if(void 0===r)for(let e=0;e<1e3;e++)if(t===await this.__addressFromIndex("m",e)){r=e;break}if(void 0===r)throw new Error("Unknown address");return`${this.hdPath}/${this.childrenPath.replace("*",r.toString()).replace(/\*/g,"0")}`}{const t=a.toChecksumAddress(e),r=this.paths[t];if(void 0===r)throw new Error("Unknown address");return r}}}h.type="QR Hardware Wallet Device",r.BaseKeyring=h}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@keystonehq/metamask-airgapped-keyring>@keystonehq/base-eth-keyring",file:"node_modules/@keystonehq/base-eth-keyring/dist/base-eth-keyring.cjs.production.min.js"}],[52,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=[{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes32"}],name:"setContent",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"content",outputs:[{name:"",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"interfaceID",type:"bytes4"}],name:"supportsInterface",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"pure",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"key",type:"string"},{name:"value",type:"string"}],name:"setText",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"contentTypes",type:"uint256"}],name:"ABI",outputs:[{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],name:"setPubkey",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"hash",type:"bytes"}],name:"setContenthash",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"addr",outputs:[{name:"",type:"address"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"},{name:"key",type:"string"}],name:"text",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"contentType",type:"uint256"},{name:"data",type:"bytes"}],name:"setABI",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"name",type:"string"}],name:"setName",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"contenthash",outputs:[{name:"",type:"bytes"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"node",type:"bytes32"}],name:"pubkey",outputs:[{name:"x",type:"bytes32"},{name:"y",type:"bytes32"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"node",type:"bytes32"},{name:"addr",type:"address"}],name:"setAddr",outputs:[],payable:!1,stateMutability:"nonpayable",type:"function"},{inputs:[{name:"ensAddr",type:"address"}],payable:!1,stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"a",type:"address"}],name:"AddrChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"name",type:"string"}],name:"NameChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!0,name:"contentType",type:"uint256"}],name:"ABIChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"x",type:"bytes32"},{indexed:!1,name:"y",type:"bytes32"}],name:"PubkeyChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"indexedKey",type:"string"},{indexed:!1,name:"key",type:"string"}],name:"TextChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"node",type:"bytes32"},{indexed:!1,name:"hash",type:"bytes"}],name:"ContenthashChanged",type:"event"}];r.default=n}}},{package:"$root$",file:"app/scripts/lib/ens-ipfs/contracts/resolver.js"}],[520,{"./base-eth-keyring.cjs.development.js":518,"./base-eth-keyring.cjs.production.min.js":519},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){t.exports=e("./base-eth-keyring.cjs.production.min.js")}}},{package:"@keystonehq/metamask-airgapped-keyring>@keystonehq/base-eth-keyring",file:"node_modules/@keystonehq/base-eth-keyring/dist/index.js"}],[521,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){function n(e){if(Array.isArray(e)){const t=[];for(let r=0;r<e.length;r++)t.push(n(e[r]));const r=p(...t);return p(i(r.length,192),r)}const t=y(e);return 1===t.length&&t[0]<128?t:p(i(t.length,128),t)}function s(e,t,r){if(r>e.length)throw new Error("invalid RLP (safeSlice): end slice of Uint8Array out-of-bounds");return e.slice(t,r)}function o(e){if(0===e[0])throw new Error("invalid RLP: extra zeros");return d(u(e))}function i(e,t){if(e<56)return Uint8Array.from([e+t]);const r=f(e),n=f(t+55+r.length/2);return Uint8Array.from(h(n+r))}function a(e,t=!1){if(!e||0===e.length)return Uint8Array.from([]);const r=c(y(e));if(t)return r;if(0!==r.remainder.length)throw new Error("invalid RLP: remainder must be zero");return r.data}function c(e){let t,r,n,i,a;const l=[],u=e[0];if(u<=127)return{data:e.slice(0,1),remainder:e.slice(1)};if(u<=183){if(t=u-127,n=128===u?Uint8Array.from([]):s(e,1,t),2===t&&n[0]<128)throw new Error("invalid RLP encoding: invalid prefix, single byte < 0x80 are not prefixed");return{data:n,remainder:e.slice(t)}}if(u<=191){if(r=u-182,e.length-1<r)throw new Error("invalid RLP: not enough bytes for string length");if(t=o(s(e,1,r)),t<=55)throw new Error("invalid RLP: expected string length to be greater than 55");return n=s(e,r,t+r),{data:n,remainder:e.slice(t+r)}}if(u<=247){for(t=u-191,i=s(e,1,t);i.length;)a=c(i),l.push(a.data),i=a.remainder;return{data:l,remainder:e.slice(t)}}{if(r=u-246,t=o(s(e,1,r)),t<56)throw new Error("invalid RLP: encoded list too short");const n=r+t;if(n>e.length)throw new Error("invalid RLP: total length is larger than the data");for(i=s(e,r,n);i.length;)a=c(i),l.push(a.data),i=a.remainder;return{data:l,remainder:e.slice(n)}}}Object.defineProperty(r,"__esModule",{value:!0}),r.utils=r.decode=r.encode=void 0,r.encode=n,r.decode=a;const l=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function u(e){let t="";for(let r=0;r<e.length;r++)t+=l[e[r]];return t}function d(e){const t=Number.parseInt(e,16);if(Number.isNaN(t))throw new Error("Invalid byte sequence");return t}function h(e){if("string"!=typeof e)throw new TypeError("hexToBytes: expected string, got "+typeof e);if(e.length%2)throw new Error("hexToBytes: received invalid unpadded hex");const t=new Uint8Array(e.length/2);for(let r=0;r<t.length;r++){const n=2*r;t[r]=d(e.slice(n,n+2))}return t}function p(...e){if(1===e.length)return e[0];const t=e.reduce(((e,t)=>e+t.length),0),r=new Uint8Array(t);for(let t=0,n=0;t<e.length;t++){const s=e[t];r.set(s,n),n+=s.length}return r}function g(e){return(new TextEncoder).encode(e)}function f(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");const t=e.toString(16);return t.length%2?`0${t}`:t}function m(e){return e.length>=2&&"0"===e[0]&&"x"===e[1]}function y(e){if(e instanceof Uint8Array)return e;if("string"==typeof e)return m(e)?h((t="string"!=typeof(r=e)?r:m(r)?r.slice(2):r).length%2?`0${t}`:t):g(e);var t,r;if("number"==typeof e||"bigint"==typeof e)return e?h(f(e)):Uint8Array.from([]);if(null===e||e===undefined)return Uint8Array.from([]);throw new Error("toBytes: received unsupported type "+typeof e)}r.utils={bytesToHex:u,concatBytes:p,hexToBytes:h,utf8ToBytes:g};const b={encode:n,decode:a};r.default=b}}},{package:"@keystonehq/metamask-airgapped-keyring>@keystonehq/base-eth-keyring>rlp",file:"node_modules/@keystonehq/base-eth-keyring/node_modules/rlp/dist/index.js"}],[53,{"./contracts/registry":51,"./contracts/resolver":52,"@ensdomains/content-hash":293,"eth-ens-namehash":2139,"ethjs-contract":2270,"ethjs-query":2274},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=async function({provider:e,name:t}){const r=new s.default(e),l=n.default.hash(t),d=new o.default(r),h=Number.parseInt(await r.net_version(),10),p=function(e){switch(e){case 1:case 3:case 4:case 5:case 6:return"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";default:return null}}(h);if(!p)throw new Error(`EnsIpfsResolver - no known ens-ipfs registry for chainId "${h}"`);const g=d(a.default).at(p),f=(await g.resolver(l))[0];if(u(f))throw new Error(`EnsIpfsResolver - no resolver found for name "${t}"`);const m=d(c.default).at(f),y=await m.supportsInterface("0xbc1c58d1"),b=await m.supportsInterface("0xd8389dc5");if(y[0]){const e=(await m.contenthash(l))[0];let t=i.default.decode(e);const r=i.default.getCodec(e);return"ipfs-ns"!==r&&"ipns-ns"!==r||(t=i.default.helpers.cidV0ToV1Base32(t)),{type:r,hash:t}}if(b[0]){const e=(await m.content(l))[0];if(u(e))throw new Error(`EnsIpfsResolver - no content ID found for name "${t}"`);return{type:"swarm-ns",hash:e.slice(2)}}throw new Error(`EnsIpfsResolver - the resolver for name "${t}" is not standard, it should either supports contenthash() or content()`)};var n=l(e("eth-ens-namehash")),s=l(e("ethjs-query")),o=l(e("ethjs-contract")),i=l(e("@ensdomains/content-hash")),a=l(e("./contracts/registry")),c=l(e("./contracts/resolver"));function l(e){return e&&e.__esModule?e:{default:e}}function u(e){return[undefined,null,"0x","0x0","0x0000000000000000000000000000000000000000000000000000000000000000"].includes(e)}}}},{package:"$root$",file:"app/scripts/lib/ens-ipfs/resolver.js"}],[54,{"../../../../shared/modules/fetch-with-timeout":3433,"./resolver":53,"base32-encode":1850,"base64-js":1851,"webextension-polyfill":3385},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function({provider:e,getCurrentChainId:t,getIpfsGateway:r}){const i=u.map((e=>`*://*.${e}/*`));return o.default.webRequest.onErrorOccurred.addListener(c,{urls:i,types:["main_frame"]}),{remove(){o.default.webRequest.onErrorOccurred.removeListener(c)}};async function c(i){const{tabId:c,url:d}=i;if(-1===c||"0x1"!==t())return;const{hostname:h,pathname:p,search:g,hash:f}=new URL(d),m=h.split("."),y=m[m.length-1];u.includes(y)&&async function({tabId:t,name:i,pathname:c,search:u,fragment:d}){const h=r();o.default.tabs.update(t,{url:"loading.html"});let p=`https://app.ens.domains/name/${i}`;try{const{type:r,hash:g}=await(0,a.default)({provider:e,name:i});if("ipfs-ns"===r||"ipns-ns"===r){const e=`https://${g}.${r.slice(0,4)}.${h}${c}${u||""}${d||""}`;try{200===(await l(e,{method:"HEAD"})).status&&(p=e)}catch(e){console.warn(e)}}else if("swarm-ns"===r)p=`https://swarm-gateways.net/bzz:/${g}${c}${u||""}${d||""}`;else if("onion"===r||"onion3"===r)p=`http://${g}.onion${c}${u||""}${d||""}`;else if("zeronet"===r)p=`http://127.0.0.1:43110/${g}${c}${u||""}${d||""}`;else if("skynet-ns"===r){const e=g.padEnd(g.length+4-g.length%4,"="),t=s.default.toByteArray(e),r={padding:!1};p=`https://${(0,n.default)(t,"RFC4648-HEX",r).toLowerCase()}.siasky.net${c}${u||""}${d||""}`}}catch(e){console.warn(e)}finally{o.default.tabs.update(t,{url:p})}}({tabId:c,name:h,pathname:p,search:g,fragment:f})}};var n=c(e("base32-encode")),s=c(e("base64-js")),o=c(e("webextension-polyfill")),i=c(e("../../../../shared/modules/fetch-with-timeout")),a=c(e("./resolver"));function c(e){return e&&e.__esModule?e:{default:e}}const l=(0,i.default)(),u=["eth"]}}},{package:"$root$",file:"app/scripts/lib/ens-ipfs/setup.js"}],[547,{"./metamask-airgapped-keyring.cjs.development.js":548,"./metamask-airgapped-keyring.cjs.production.min.js":549},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){t.exports=e("./metamask-airgapped-keyring.cjs.production.min.js")}}},{package:"@keystonehq/metamask-airgapped-keyring",file:"node_modules/@keystonehq/metamask-airgapped-keyring/dist/index.js"}],[548,{"@ethereumjs/tx":363,"@keystonehq/base-eth-keyring":520,"@keystonehq/bc-ur-registry-eth":524,"@metamask/obs-store":554,buffer:1943,events:1944,rlp:3206,uuid:3351},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0});var n,s=e("@keystonehq/base-eth-keyring"),o=e("events"),i=e("@metamask/obs-store"),a=e("@keystonehq/bc-ur-registry-eth"),c=e("uuid"),l=e("@ethereumjs/tx"),u=(n=e("rlp"))&&"object"==typeof n&&"default"in n?n.default:n;class d extends o.EventEmitter{constructor(){if(super(),this.cleanSyncListeners=()=>{this.removeAllListeners("keystone-sync_success-hdkey"),this.removeAllListeners("keystone-sync_success-account"),this.removeAllListeners("keystone-sync_cancel")},this.cleanSignListeners=e=>{this.removeAllListeners(`${e}-signed`),this.removeAllListeners(`${e}-canceled`)},this.readCryptoHDKeyOrCryptoAccount=()=>new Promise(((e,r)=>{this.memStore.updateState({sync:{reading:!0}}),this.on("keystone-sync_success-hdkey",(r=>{const n=a.CryptoHDKey.fromCBOR(t.from(r,"hex"));this.resetState(),e(n)})),this.on("keystone-sync_success-account",(r=>{const n=a.CryptoAccount.fromCBOR(t.from(r,"hex"));this.resetState(),e(n)})),this.on("keystone-sync_cancel",(()=>{this.resetState(),r(new Error("KeystoneError#sync_cancel. Sync process canceled, please retry"))}))})),this.submitCryptoHDKey=e=>{this.emit("keystone-sync_success-hdkey",e)},this.submitCryptoAccount=e=>{this.emit("keystone-sync_success-account",e)},this.cancelSync=()=>{this.emit("keystone-sync_cancel")},this.requestSignature=(e,r,n)=>new Promise(((s,o)=>{const i=e.toUR(),l=e.getRequestId(),u=c.stringify(l),d={requestId:u,payload:{type:i.type,cbor:i.cbor.toString("hex")},title:r,description:n};this.memStore.updateState({sign:{request:d}}),this.once(`${u}-signed`,(e=>{const r=a.ETHSignature.fromCBOR(t.from(e,"hex"));this.resetState(),s(r)})),this.once(`${u}-canceled`,(()=>{this.resetState(),o(new Error("KeystoneError#Tx_canceled. Signing canceled, please retry"))}))})),this.submitSignature=(e,t)=>{this.emit(`${e}-signed`,t)},this.cancelRequestSignature=()=>{const e=this.memStore.getState().sign.request;if(e){const{requestId:t}=e;this.memStore.updateState({sign:{}}),this.emit(`${t}-canceled`)}},this.reset=()=>{this.cleanSyncListeners();const e=this.memStore.getState().sign.request;if(e){const{requestId:t}=e;this.cleanSignListeners(t)}this.resetState()},this.resetState=()=>{this.memStore.updateState({sync:{reading:!1},sign:{}})},d.instance)return d.instance;this.memStore=new i.ObservableStore({sync:{reading:!1},sign:{},_version:1}),d.instance=this}}class h extends s.BaseKeyring{constructor(e){if(super(e),this.getInteraction=()=>new d,this.resetStore=()=>{this.getInteraction().reset()},this.getMemStore=()=>this.getInteraction().memStore,this.removeAccount=e=>{if(!this.accounts.map((e=>e.toLowerCase())).includes(e.toLowerCase()))throw new Error(`Address ${e} not found in this keyring`);this.accounts=this.accounts.filter((t=>t.toLowerCase()!==e.toLowerCase()))},this.forgetDevice=()=>{this.page=0,this.perPage=5,this.accounts=[],this.currentAccount=0,this.name="QR Hardware",this.initialized=!1,this.xfp="",this.xpub="",this.hdPath="",this.indexes={},this.hdk=undefined,this.paths={}},this.submitCryptoHDKey=this.getInteraction().submitCryptoHDKey,this.submitCryptoAccount=this.getInteraction().submitCryptoAccount,this.submitSignature=this.getInteraction().submitSignature,this.cancelSync=this.getInteraction().cancelSync,this.cancelSignRequest=this.getInteraction().cancelRequestSignature,h.instance)return h.instance.deserialize(e),h.instance;h.instance=this}async signTransaction(e,t){const r=0===t.type?a.DataType.transaction:a.DataType.typedTransaction;let n;n=0===t.type?u.encode(t.getMessageToSign(!1)):t.getMessageToSign(!1);const s=await this._pathFromAddress(e),o=t.common.chainId(),i=c.v4(),d=a.EthSignRequest.constructETHRequest(n,r,s,this.xfp,i,o,e),{r:h,s:p,v:g}=await this.requestSignature(i,d,"Scan with your Keystone",'After your Keystone has signed the transaction, click on "Scan Keystone" to receive the signature'),f=t.toJSON();f.v=g,f.s=p,f.r=h,f.type=t.type;return l.TransactionFactory.fromTxData(f,{common:t.common})}}h.type=s.BaseKeyring.type,r.MetaMaskKeyring=h}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@keystonehq/metamask-airgapped-keyring",file:"node_modules/@keystonehq/metamask-airgapped-keyring/dist/metamask-airgapped-keyring.cjs.development.js"}],[549,{"@ethereumjs/tx":363,"@keystonehq/base-eth-keyring":520,"@keystonehq/bc-ur-registry-eth":524,"@metamask/obs-store":554,buffer:1943,events:1944,rlp:3206,uuid:3351},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0});var n,s=e("@keystonehq/base-eth-keyring"),o=e("events"),i=e("@metamask/obs-store"),a=e("@keystonehq/bc-ur-registry-eth"),c=e("uuid"),l=e("@ethereumjs/tx"),u=(n=e("rlp"))&&"object"==typeof n&&"default"in n?n.default:n;class d extends o.EventEmitter{constructor(){if(super(),this.cleanSyncListeners=()=>{this.removeAllListeners("keystone-sync_success-hdkey"),this.removeAllListeners("keystone-sync_success-account"),this.removeAllListeners("keystone-sync_cancel")},this.cleanSignListeners=e=>{this.removeAllListeners(e+"-signed"),this.removeAllListeners(e+"-canceled")},this.readCryptoHDKeyOrCryptoAccount=()=>new Promise(((e,r)=>{this.memStore.updateState({sync:{reading:!0}}),this.on("keystone-sync_success-hdkey",(r=>{const n=a.CryptoHDKey.fromCBOR(t.from(r,"hex"));this.resetState(),e(n)})),this.on("keystone-sync_success-account",(r=>{const n=a.CryptoAccount.fromCBOR(t.from(r,"hex"));this.resetState(),e(n)})),this.on("keystone-sync_cancel",(()=>{this.resetState(),r(new Error("KeystoneError#sync_cancel. Sync process canceled, please retry"))}))})),this.submitCryptoHDKey=e=>{this.emit("keystone-sync_success-hdkey",e)},this.submitCryptoAccount=e=>{this.emit("keystone-sync_success-account",e)},this.cancelSync=()=>{this.emit("keystone-sync_cancel")},this.requestSignature=(e,r,n)=>new Promise(((s,o)=>{const i=e.toUR(),l=e.getRequestId(),u=c.stringify(l),d={requestId:u,payload:{type:i.type,cbor:i.cbor.toString("hex")},title:r,description:n};this.memStore.updateState({sign:{request:d}}),this.once(u+"-signed",(e=>{const r=a.ETHSignature.fromCBOR(t.from(e,"hex"));this.resetState(),s(r)})),this.once(u+"-canceled",(()=>{this.resetState(),o(new Error("KeystoneError#Tx_canceled. Signing canceled, please retry"))}))})),this.submitSignature=(e,t)=>{this.emit(e+"-signed",t)},this.cancelRequestSignature=()=>{const e=this.memStore.getState().sign.request;if(e){const{requestId:t}=e;this.memStore.updateState({sign:{}}),this.emit(t+"-canceled")}},this.reset=()=>{this.cleanSyncListeners();const e=this.memStore.getState().sign.request;if(e){const{requestId:t}=e;this.cleanSignListeners(t)}this.resetState()},this.resetState=()=>{this.memStore.updateState({sync:{reading:!1},sign:{}})},d.instance)return d.instance;this.memStore=new i.ObservableStore({sync:{reading:!1},sign:{},_version:1}),d.instance=this}}class h extends s.BaseKeyring{constructor(e){if(super(e),this.getInteraction=()=>new d,this.resetStore=()=>{this.getInteraction().reset()},this.getMemStore=()=>this.getInteraction().memStore,this.removeAccount=e=>{if(!this.accounts.map((e=>e.toLowerCase())).includes(e.toLowerCase()))throw new Error(`Address ${e} not found in this keyring`);this.accounts=this.accounts.filter((t=>t.toLowerCase()!==e.toLowerCase()))},this.forgetDevice=()=>{this.page=0,this.perPage=5,this.accounts=[],this.currentAccount=0,this.name="QR Hardware",this.initialized=!1,this.xfp="",this.xpub="",this.hdPath="",this.indexes={},this.hdk=void 0,this.paths={}},this.submitCryptoHDKey=this.getInteraction().submitCryptoHDKey,this.submitCryptoAccount=this.getInteraction().submitCryptoAccount,this.submitSignature=this.getInteraction().submitSignature,this.cancelSync=this.getInteraction().cancelSync,this.cancelSignRequest=this.getInteraction().cancelRequestSignature,h.instance)return h.instance.deserialize(e),h.instance;h.instance=this}async signTransaction(e,t){const r=0===t.type?a.DataType.transaction:a.DataType.typedTransaction;let n;n=0===t.type?u.encode(t.getMessageToSign(!1)):t.getMessageToSign(!1);const s=await this._pathFromAddress(e),o=t.common.chainId(),i=c.v4(),d=a.EthSignRequest.constructETHRequest(n,r,s,this.xfp,i,o,e),{r:h,s:p,v:g}=await this.requestSignature(i,d,"Scan with your Keystone",'After your Keystone has signed the transaction, click on "Scan Keystone" to receive the signature'),f=t.toJSON();return f.v=g,f.s=p,f.r=h,f.type=t.type,l.TransactionFactory.fromTxData(f,{common:t.common})}}h.type=s.BaseKeyring.type,r.MetaMaskKeyring=h}).call(this)}).call(this,e("buffer").Buffer)}}},{package:"@keystonehq/metamask-airgapped-keyring",file:"node_modules/@keystonehq/metamask-airgapped-keyring/dist/metamask-airgapped-keyring.cjs.production.min.js"}],[550,{"./ObservableStore":552},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.ComposedStore=void 0;const n=e("./ObservableStore");class s extends n.ObservableStore{constructor(e){super({}),this._children=e||{},Object.keys(this._children).forEach((e=>{const t=this._children[e];this._addChild(e,t)}))}_addChild(e,t){const r=t=>{const r=this.getState();r[e]=t,this.putState(r)};t.subscribe(r),r(t.getState())}}r.ComposedStore=s}}},{package:"@keystonehq/metamask-airgapped-keyring>@metamask/obs-store",file:"node_modules/@keystonehq/metamask-airgapped-keyring/node_modules/@metamask/obs-store/dist/ComposedStore.js"}],[551,{"./ObservableStore":552},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.MergedStore=void 0;const n=e("./ObservableStore");class s extends n.ObservableStore{constructor(e=[]){super({}),this._children=e,e.forEach((e=>this._addChild(e))),this._updateWholeState()}_addChild(e){e.subscribe((()=>this._updateWholeState()))}_updateWholeState(){const e=this._children.map((e=>e.getState())),t=Object.assign({},...e);this.putState(t)}}r.MergedStore=s}}},{package:"@keystonehq/metamask-airgapped-keyring>@metamask/obs-store",file:"node_modules/@keystonehq/metamask-airgapped-keyring/node_modules/@metamask/obs-store/dist/MergedStore.js"}],[552,{"@metamask/safe-event-emitter":1325},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.ObservableStore=void 0;const s=n(e("@metamask/safe-event-emitter"));class o extends s.default{constructor(e){super(),this._state=e||{}}getState(){return this._getState()}putState(e){this._putState(e),this.emit("update",e)}updateState(e){if(e&&"object"==typeof e){const t=this.getState();this.putState(Object.assign(Object.assign({},t),e))}else this.putState(e)}subscribe(e){this.on("update",e)}unsubscribe(e){this.removeListener("update",e)}_getState(){return this._state}_putState(e){this._state=e}}r.ObservableStore=o}}},{package:"@keystonehq/metamask-airgapped-keyring>@metamask/obs-store",file:"node_modules/@keystonehq/metamask-airgapped-keyring/node_modules/@metamask/obs-store/dist/ObservableStore.js"}],[553,{stream:1946},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.storeAsStream=void 0;const n=e("stream");class s extends n.Duplex{constructor(e){super({objectMode:!0}),this.resume(),this.handler=e=>this.push(e),this.obsStore=e,this.obsStore.subscribe(this.handler)}pipe(e,t){const r=super.pipe(e,t);return e.write(this.obsStore.getState()),r}_write(e,t,r){this.obsStore.putState(e),r()}_read(e){return undefined}_destroy(e,t){this.obsStore.unsubscribe(this.handler),super._destroy(e,t)}}r.storeAsStream=function(e){return new s(e)}}}},{package:"@keystonehq/metamask-airgapped-keyring>@metamask/obs-store",file:"node_modules/@keystonehq/metamask-airgapped-keyring/node_modules/@metamask/obs-store/dist/asStream.js"}],[554,{"./ComposedStore":550,"./MergedStore":551,"./ObservableStore":552,"./asStream":553,"./transform":555},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){n===undefined&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){n===undefined&&(n=r),e[n]=t[r]}),s=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(r,"__esModule",{value:!0}),s(e("./asStream"),r),s(e("./ComposedStore"),r),s(e("./MergedStore"),r),s(e("./ObservableStore"),r),s(e("./transform"),r)}}},{package:"@keystonehq/metamask-airgapped-keyring>@metamask/obs-store",file:"node_modules/@keystonehq/metamask-airgapped-keyring/node_modules/@metamask/obs-store/dist/index.js"}],[555,{through2:556},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.storeTransformStream=void 0;const n=e("through2");r.storeTransformStream=function(e){return n.obj(((t,r,n)=>{try{return n(null,e(t)),undefined}catch(e){return n(e),undefined}}))}}}},{package:"@keystonehq/metamask-airgapped-keyring>@metamask/obs-store",file:"node_modules/@keystonehq/metamask-airgapped-keyring/node_modules/@metamask/obs-store/dist/transform.js"}],[556,{_process:3027,"readable-stream":3190,util:1949,xtend:3389},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(r){(function(){var n=e("readable-stream").Transform,s=e("util").inherits,o=e("xtend");function i(e){n.call(this,e),this._destroyed=!1}function a(e,t,r){r(null,e)}function c(e){return function(t,r,n){return"function"==typeof t&&(n=r,r=t,t={}),"function"!=typeof r&&(r=a),"function"!=typeof n&&(n=null),e(t,r,n)}}s(i,n),i.prototype.destroy=function(e){if(!this._destroyed){this._destroyed=!0;var t=this;r.nextTick((function(){e&&t.emit("error",e),t.emit("close")}))}},t.exports=c((function(e,t,r){var n=new i(e);return n._transform=t,r&&(n._flush=r),n})),t.exports.ctor=c((function(e,t,r){function n(t){if(!(this instanceof n))return new n(t);this.options=o(e,t),i.call(this,this.options)}return s(n,i),n.prototype._transform=t,r&&(n.prototype._flush=r),n})),t.exports.obj=c((function(e,t,r){var n=new i(o({objectMode:!0,highWaterMark:16},e));return n._transform=t,r&&(n._flush=r),n}))}).call(this)}).call(this,e("_process"))}}},{package:"@keystonehq/metamask-airgapped-keyring>@metamask/obs-store>through2",file:"node_modules/@keystonehq/metamask-airgapped-keyring/node_modules/through2/through2.js"}],[57,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=function(e){return s((0,n.cloneDeep)(e),(e=>null===e?"null":typeof e))};var n=e("lodash");function s(e={},t){return Object.entries(e).forEach((([r,n])=>{e[r]="object"==typeof n&&null!==n?s(n,t):t(n)})),e}}}},{package:"$root$",file:"app/scripts/lib/getObjStructure.js"}],[58,{"../../../shared/modules/browser-runtime.utils":3428,"@sentry/browser":1403,loglevel:2944,"webextension-polyfill":3385},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=a(e("webextension-polyfill")),s=a(e("loglevel")),o=e("@sentry/browser"),i=e("../../../shared/modules/browser-runtime.utils");function a(e){return e&&e.__esModule?e:{default:e}}r.default=class{constructor(){this.isSupported=Boolean(n.default.storage.local),this.isSupported||s.default.error("Storage local API not available."),this.dataPersistenceFailing=!1}setMetadata(e){this.metadata=e}async set(e){if(!this.isSupported)throw new Error("Metamask- cannot persist state to local store as this browser does not support this action");if(!e)throw new Error("MetaMask - updated state is missing");if(!this.metadata)throw new Error('MetaMask - metadata must be set on instance of ExtensionStore before calling "set"');try{await this._set({data:e,meta:this.metadata}),this.dataPersistenceFailing&&(this.dataPersistenceFailing=!1)}catch(e){this.dataPersistenceFailing||(this.dataPersistenceFailing=!0,(0,o.captureException)(e)),s.default.error("error setting state in local store:",e)}}async get(){if(!this.isSupported)return undefined;const e=await this._get();return t=e,0===Object.keys(t).length?undefined:e;var t}_get(){const{local:e}=n.default.storage;return new Promise(((t,r)=>{e.get(null).then((e=>{const n=(0,i.checkForLastError)();n?r(n):t(e)}))}))}_set(e){const{local:t}=n.default.storage;return new Promise(((r,n)=>{t.set(e).then((()=>{const e=(0,i.checkForLastError)();e?n(e):r()}))}))}}}}},{package:"$root$",file:"app/scripts/lib/local-store.js"}],[6,{"../../../shared/constants/alerts":3400,"@metamask/obs-store":1298},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("@metamask/obs-store"),s=e("../../../shared/constants/alerts");const o={alertEnabledness:s.TOGGLEABLE_ALERT_TYPES.reduce(((e,t)=>(e[t]=!0,e)),{}),unconnectedAccountAlertShownOrigins:{},web3ShimUsageOrigins:{}};r.default=class{constructor(e={}){const{initState:t={},preferencesStore:r}=e,s={...o,alertEnabledness:{...o.alertEnabledness,...t.alertEnabledness}};this.store=new n.ObservableStore(s),this.selectedAddress=r.getState().selectedAddress,r.subscribe((({selectedAddress:e})=>{this.store.getState().unconnectedAccountAlertShownOrigins&&this.selectedAddress!==e&&(this.selectedAddress=e,this.store.updateState({unconnectedAccountAlertShownOrigins:{}}))}))}setAlertEnabledness(e,t){let{alertEnabledness:r}=this.store.getState();r={...r},r[e]=t,this.store.updateState({alertEnabledness:r})}setUnconnectedAccountAlertShown(e){let{unconnectedAccountAlertShownOrigins:t}=this.store.getState();t={...t},t[e]=!0,this.store.updateState({unconnectedAccountAlertShownOrigins:t})}getWeb3ShimUsageState(e){return this.store.getState().web3ShimUsageOrigins[e]}setWeb3ShimUsageRecorded(e){this._setWeb3ShimUsageState(e,s.Web3ShimUsageAlertStates.recorded)}setWeb3ShimUsageAlertDismissed(e){this._setWeb3ShimUsageState(e,s.Web3ShimUsageAlertStates.dismissed)}_setWeb3ShimUsageState(e,t){let{web3ShimUsageOrigins:r}=this.store.getState();r={...r},r[e]=t,this.store.updateState({web3ShimUsageOrigins:r})}}}}},{package:"$root$",file:"app/scripts/controllers/alert.js"}],[60,{"../util":82,"json-rpc-engine":2724},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.createPendingNonceMiddleware=function({getPendingNonce:e}){return(0,n.createAsyncMiddleware)((async(t,r,n)=>{const{method:s,params:o}=t;if("eth_getTransactionCount"!==s)return void n();const[i,a]=o;"pending"===a?r.result=await e(i):n()}))},r.createPendingTxMiddleware=function({getPendingTransactionByHash:e}){return(0,n.createAsyncMiddleware)((async(t,r,n)=>{const{method:o,params:i}=t;if("eth_getTransactionByHash"!==o)return void n();const[a]=i,c=e(a);c?r.result=(0,s.formatTxMetaForRpcResult)(c):n()}))};var n=e("json-rpc-engine"),s=e("../util")}}},{package:"$root$",file:"app/scripts/lib/middleware/pending.js"}],[61,{events:1944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=(n=e("events"))&&n.__esModule?n:{default:n};class o extends s.default{constructor(e={}){super();const t=e.migrations||[];this.migrations=t.sort(((e,t)=>e.version-t.version));const r=this.migrations.slice(-1)[0];this.defaultVersion=e.defaultVersion||r&&r.version||0}async migrateData(e=this.generateInitialState()){const t=this.migrations.filter((function(t){return t.version>e.meta.version}));for(const r of t)try{const t=await r.migrate(e);if(!t.data)throw new Error("Migrator - migration returned empty data");if(t.version!==undefined&&t.meta.version!==r.version)throw new Error("Migrator - Migration did not update version number correctly");e=t}catch(t){const n=t.message;return t.message=`MetaMask Migration Error #${r.version}: ${n}`,this.emit("error",t),e}return e}generateInitialState(e){return{meta:{version:this.defaultVersion},data:e}}}r.default=o}}},{package:"$root$",file:"app/scripts/lib/migrator/index.js"}],[62,{"../../../shared/modules/fetch-with-timeout":3433,loglevel:2944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=s(e("loglevel"));function s(e){return e&&e.__esModule?e:{default:e}}function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(r!==undefined){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const i=(0,s(e("../../../shared/modules/fetch-with-timeout")).default)();r.default=class{constructor(){o(this,"isSupported",!0),this._initialized=!1,this._initializing=this._init(),this._state=undefined}async _init(){try{const e=await i("http://localhost:12345/state.json");e.ok&&(this._state=await e.json())}catch(e){n.default.debug(`Error loading network state: '${e.message}'`)}finally{this._initialized=!0}}async get(){return this._initialized||await this._initializing,this._state}setMetadata(e){this.metadata=e}async set(e){if(!this.isSupported)throw new Error("Metamask- cannot persist state to local store as this browser does not support this action");if(!e)throw new Error("MetaMask - updated state is missing");if(!this.metadata)throw new Error('MetaMask - metadata must be set on instance of ExtensionStore before calling "set"');this._initialized||await this._initializing,this._state={data:e,meta:this._metadata}}}}}},{package:"$root$",file:"app/scripts/lib/network-store.js"}],[63,{"../platforms/extension":169,"@metamask/safe-event-emitter":1325},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.NOTIFICATION_MANAGER_EVENTS=void 0;var n=o(e("@metamask/safe-event-emitter")),s=o(e("../platforms/extension"));function o(e){return e&&e.__esModule?e:{default:e}}const i={POPUP_CLOSED:"onPopupClosed"};r.NOTIFICATION_MANAGER_EVENTS=i;class a extends n.default{constructor(){super(),this.platform=new s.default,this.platform.addOnRemovedListener(this._onWindowClosed.bind(this))}markAsAutomaticallyClosed(){this._popupAutomaticallyClosed=!0}async showPopup(e,t){this._popupId=t,this._setCurrentPopupId=e;const r=await this._getPopup(t);if(r)await this.platform.focusWindow(r.id);else{let e=0,t=0;try{const r=await this.platform.getLastFocusedWindow();t=r.top,e=r.left+(r.width-360)}catch(r){const{screenX:n,screenY:s,outerWidth:o}=window;t=Math.max(s,0),e=Math.max(n+(o-360),0)}const r=await this.platform.openWindow({url:"notification.html",type:"popup",width:360,height:620,left:e,top:t});r.left!==e&&"fullscreen"!==r.state&&await this.platform.updateWindowPosition(r.id,e,t),this._setCurrentPopupId(r.id),this._popupId=r.id}}_onWindowClosed(e){e===this._popupId&&(this._setCurrentPopupId(undefined),this._popupId=undefined,this.emit(i.POPUP_CLOSED,{automaticallyClosed:this._popupAutomaticallyClosed}),this._popupAutomaticallyClosed=undefined)}async _getPopup(){const e=await this.platform.getAllWindows();return this._getPopupIn(e)}_getPopupIn(e){return e?e.find((e=>e&&"popup"===e.type&&e.id===this._popupId)):null}}r.default=a}}},{package:"$root$",file:"app/scripts/lib/notification-manager.js"}],[64,{"../../../../shared/constants/network":3409,"./handlers":68,"@metamask/permission-controller":1305,"@metamask/rpc-methods/dist/utils":1324,"eth-rpc-errors":2170,lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.createMethodMiddleware=function(e){const t=d.filter((t=>!Object.hasOwnProperty.call(e,t)));if(t.length>0)throw new Error(`Missing expected hooks:\n\n${t.join("\n")}\n`);return async function(t,r,n,s){if(c.UNSUPPORTED_RPC_METHODS.has(t.method))return s(i.ethErrors.rpc.methodNotSupported());const a=u.get(t.method);if(a){const{implementation:i,hookNames:c}=a;try{return await i(t,r,n,s,(0,o.selectHooks)(e,c))}catch(e){return console.error(e),s(e)}}return n()}};var n,s=e("@metamask/permission-controller"),o=e("@metamask/rpc-methods/dist/utils"),i=e("eth-rpc-errors"),a=e("lodash"),c=e("../../../../shared/constants/network");const l=[...((n=e("./handlers"))&&n.__esModule?n:{default:n}).default,...s.permissionRpcMethods.handlers],u=l.reduce(((e,t)=>{for(const r of t.methodNames)e.set(r,t);return e}),new Map),d=Array.from(new Set((0,a.flatten)(l.map((({hookNames:e})=>Object.keys(e))))).values())}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/createMethodMiddleware.js"}],[65,{"../../../../../shared/constants/app":3401,"../../../../../shared/constants/metametrics":3408,"../../../../../shared/modules/network.utils":3437,"eth-rpc-errors":2170,lodash:2932,"valid-url":3366},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=e("eth-rpc-errors"),o=(n=e("valid-url"))&&n.__esModule?n:{default:n},i=e("lodash"),a=e("../../../../../shared/constants/app"),c=e("../../../../../shared/modules/network.utils"),l=e("../../../../../shared/constants/metametrics");var u={methodNames:[a.MESSAGE_TYPE.ADD_ETHEREUM_CHAIN],implementation:async function(e,t,r,n,{upsertNetworkConfiguration:u,getCurrentChainId:d,getCurrentRpcUrl:h,findNetworkConfigurationBy:p,setActiveNetwork:g,requestUserApproval:f}){var m;if(null===(m=e.params)||void 0===m||!m[0]||"object"!=typeof e.params[0])return n(s.ethErrors.rpc.invalidParams({message:`Expected single, object parameter. Received:\n${JSON.stringify(e.params)}`}));const{origin:y}=e,{chainId:b,chainName:v=null,blockExplorerUrls:w=null,nativeCurrency:S=null,rpcUrls:T}=e.params[0],k=Object.keys((0,i.omit)(e.params[0],["chainId","chainName","blockExplorerUrls","iconUrls","rpcUrls","nativeCurrency"]));if(k.length>0)return n(s.ethErrors.rpc.invalidParams({message:`Received unexpected keys on object parameter. Unsupported keys:\n${k}`}));const C=e=>{try{const t=new URL(e);return"localhost"===t.hostname||"127.0.0.1"===t.hostname}catch(e){return!1}},_=Array.isArray(T)?T.find((e=>C(e)||o.default.isHttpsUri(e))):null,E=null!==w&&Array.isArray(w)?w.find((e=>C(e)||o.default.isHttpsUri(e))):null;if(!_)return n(s.ethErrors.rpc.invalidParams({message:`Expected an array with at least one valid string HTTPS url 'rpcUrls', Received:\n${T}`}));if(null!==w&&!E)return n(s.ethErrors.rpc.invalidParams({message:`Expected null or array with at least one valid string HTTPS URL 'blockExplorerUrl'. Received: ${w}`}));const M="string"==typeof b&&b.toLowerCase();if(!(0,c.isPrefixedFormattedHexString)(M))return n(s.ethErrors.rpc.invalidParams({message:`Expected 0x-prefixed, unpadded, non-zero hexadecimal string 'chainId'. Received:\n${b}`}));if(!(0,c.isSafeChainId)(parseInt(M,16)))return n(s.ethErrors.rpc.invalidParams({message:`Invalid chain ID "${M}": numerical value greater than max safe value. Received:\n${b}`}));const A=p({chainId:M});if(A&&A.rpcUrl===_){t.result=null;const e=d(),r=h();if(e===M&&r===_)return n();try{await f({origin:y,type:a.MESSAGE_TYPE.SWITCH_ETHEREUM_CHAIN,requestData:{rpcUrl:A.rpcUrl,chainId:A.chainId,nickname:A.nickname,ticker:A.ticker}}),await g(A.id),t.result=null}catch(e){if(e.code!==s.errorCodes.provider.userRejectedRequest)return n(e)}return n()}if("string"!=typeof v||!v)return n(s.ethErrors.rpc.invalidParams({message:`Expected non-empty string 'chainName'. Received:\n${v}`}));const P=v.length>100?v.substring(0,100):v;if(null!==S){if("object"!=typeof S||Array.isArray(S))return n(s.ethErrors.rpc.invalidParams({message:`Expected null or object 'nativeCurrency'. Received:\n${S}`}));if(18!==S.decimals)return n(s.ethErrors.rpc.invalidParams({message:`Expected the number 18 for 'nativeCurrency.decimals' when 'nativeCurrency' is provided. Received: ${S.decimals}`}));if(!S.symbol||"string"!=typeof S.symbol)return n(s.ethErrors.rpc.invalidParams({message:`Expected a string 'nativeCurrency.symbol'. Received: ${S.symbol}`}))}const I=(null==S?void 0:S.symbol)||a.UNKNOWN_TICKER_SYMBOL;if(I!==a.UNKNOWN_TICKER_SYMBOL&&("string"!=typeof I||I.length<2||I.length>6))return n(s.ethErrors.rpc.invalidParams({message:`Expected 2-6 character string 'nativeCurrency.symbol'. Received:\n${I}`}));if(A&&A.chainId===M&&A.ticker!==I)return n(s.ethErrors.rpc.invalidParams({message:`nativeCurrency.symbol does not match currency symbol for a network the user already has added with the same chainId. Received:\n${I}`}));let N;try{await f({origin:y,type:a.MESSAGE_TYPE.ADD_ETHEREUM_CHAIN,requestData:{chainId:M,rpcPrefs:{blockExplorerUrl:E},chainName:P,rpcUrl:_,ticker:I}}),N=await u({chainId:M,rpcPrefs:{blockExplorerUrl:E},nickname:P,rpcUrl:_,ticker:I},{source:l.MetaMetricsNetworkEventSource.Dapp,referrer:y}),t.result=null}catch(e){return n(e)}try{await f({origin:y,type:a.MESSAGE_TYPE.SWITCH_ETHEREUM_CHAIN,requestData:{rpcUrl:_,chainId:M,nickname:P,ticker:I,networkConfigurationId:N}}),await g(N)}catch(e){if(e.code!==s.errorCodes.provider.userRejectedRequest)return n(e)}return n()},hookNames:{upsertNetworkConfiguration:!0,getCurrentChainId:!0,getCurrentRpcUrl:!0,findNetworkConfigurationBy:!0,setActiveNetwork:!0,requestUserApproval:!0}};r.default=u}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js"}],[66,{"../../../../../shared/constants/app":3401},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n={methodNames:[e("../../../../../shared/constants/app").MESSAGE_TYPE.ETH_ACCOUNTS],implementation:async function(e,t,r,n,{getAccounts:s}){return t.result=await s(),n()},hookNames:{getAccounts:!0}};r.default=n}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/eth-accounts.js"}],[67,{"../../../../../shared/constants/app":3401},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n={methodNames:[e("../../../../../shared/constants/app").MESSAGE_TYPE.GET_PROVIDER_STATE],implementation:async function(e,t,r,n,{getProviderState:s}){return t.result={...await s(e.origin)},n()},hookNames:{getProviderState:!0}};r.default=n}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/get-provider-state.js"}],[68,{"./add-ethereum-chain":65,"./eth-accounts":66,"./get-provider-state":67,"./log-web3-shim-usage":69,"./request-accounts":70,"./send-metadata":71,"./switch-ethereum-chain":72,"./watch-asset":73},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=d(e("./add-ethereum-chain")),s=d(e("./eth-accounts")),o=d(e("./get-provider-state")),i=d(e("./log-web3-shim-usage")),a=d(e("./request-accounts")),c=d(e("./send-metadata")),l=d(e("./switch-ethereum-chain")),u=d(e("./watch-asset"));function d(e){return e&&e.__esModule?e:{default:e}}var h=[n.default,s.default,o.default,i.default,a.default,c.default,l.default,u.default];r.default=h}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/index.js"}],[69,{"../../../../../shared/constants/app":3401,"../../../../../shared/constants/metametrics":3408},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("../../../../../shared/constants/app"),s=e("../../../../../shared/constants/metametrics");var o={methodNames:[n.MESSAGE_TYPE.LOG_WEB3_SHIM_USAGE],implementation:function(e,t,r,n,{sendMetrics:o,getWeb3ShimUsageState:i,setWeb3ShimUsageRecorded:a}){const{origin:c}=e;i(c)===undefined&&(a(c),o({event:"Website Accessed window.web3 Shim",category:s.MetaMetricsEventCategory.InpageProvider,referrer:{url:c}},{excludeMetaMetricsId:!0}));return t.result=!0,n()},hookNames:{sendMetrics:!0,getWeb3ShimUsageState:!0,setWeb3ShimUsageRecorded:!0}};r.default=o}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/log-web3-shim-usage.js"}],[7,{"../../../shared/constants/alarms":3399,"../../../shared/constants/app":3401,"../../../shared/constants/time":3415,"../../../shared/modules/mv3.utils":3436,"../../../ui/helpers/utils/build-types":4088,"../metamask-controller":83,"@metamask/obs-store":1298,events:1944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=(n=e("events"))&&n.__esModule?n:{default:n},o=e("@metamask/obs-store"),i=e("../metamask-controller"),a=e("../../../shared/constants/time"),c=e("../../../shared/constants/alarms"),l=e("../../../shared/modules/mv3.utils"),u=e("../../../ui/helpers/utils/build-types"),d=e("../../../shared/constants/app");class h extends s.default{constructor(e={}){const{addUnlockListener:t,isUnlocked:r,initState:n,onInactiveTimeout:s,showUnlockRequest:i,preferencesStore:a,qrHardwareStore:c}=e;super(),this.onInactiveTimeout=s||(()=>undefined),this.store=new o.ObservableStore({timeoutMinutes:0,connectedStatusPopoverHasBeenShown:!0,defaultHomeActiveTabName:null,browserEnvironment:{},popupGasPollTokens:[],notificationGasPollTokens:[],fullScreenGasPollTokens:[],recoveryPhraseReminderHasBeenShown:!1,recoveryPhraseReminderLastShown:(new Date).getTime(),outdatedBrowserWarningLastShown:(new Date).getTime(),nftsDetectionNoticeDismissed:!1,showTestnetMessageInDropdown:!0,showBetaHeader:(0,u.isBeta)(),trezorModel:null,currentPopupId:undefined,...n,qrHardware:{},nftsDropdownState:{},usedNetworks:{"0x1":!0,"0x5":!0,"0x539":!0},serviceWorkerLastActiveTime:0}),this.timer=null,this.isUnlocked=r,this.waitingForUnlock=[],t(this.handleUnlock.bind(this)),this._showUnlockRequest=i,a.subscribe((({preferences:e})=>{this.store.getState().timeoutMinutes!==e.autoLockTimeLimit&&this._setInactiveTimeout(e.autoLockTimeLimit)})),c.subscribe((e=>{this.store.updateState({qrHardware:e})}));const{preferences:l}=a.getState();this._setInactiveTimeout(l.autoLockTimeLimit)}getUnlockPromise(e){return new Promise((t=>{this.isUnlocked()?t():this.waitForUnlock(t,e)}))}waitForUnlock(e,t){this.waitingForUnlock.push({resolve:e}),this.emit(i.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE),t&&this._showUnlockRequest()}handleUnlock(){if(this.waitingForUnlock.length>0){for(;this.waitingForUnlock.length>0;)this.waitingForUnlock.shift().resolve();this.emit(i.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE)}}setDefaultHomeActiveTabName(e){this.store.updateState({defaultHomeActiveTabName:e})}setConnectedStatusPopoverHasBeenShown(){this.store.updateState({connectedStatusPopoverHasBeenShown:!0})}setRecoveryPhraseReminderHasBeenShown(){this.store.updateState({recoveryPhraseReminderHasBeenShown:!0})}setRecoveryPhraseReminderLastShown(e){this.store.updateState({recoveryPhraseReminderLastShown:e})}setOutdatedBrowserWarningLastShown(e){this.store.updateState({outdatedBrowserWarningLastShown:e})}setLastActiveTime(){this._resetTimer()}_setInactiveTimeout(e){this.store.updateState({timeoutMinutes:e}),this._resetTimer()}_resetTimer(){const{timeoutMinutes:e}=this.store.getState();this.timer?clearTimeout(this.timer):l.isManifestV3&&chrome.alarms.clear(c.AUTO_LOCK_TIMEOUT_ALARM),e&&(l.isManifestV3?(chrome.alarms.create(c.AUTO_LOCK_TIMEOUT_ALARM,{delayInMinutes:e,periodInMinutes:e}),chrome.alarms.onAlarm.addListener((e=>{e.name===c.AUTO_LOCK_TIMEOUT_ALARM&&(this.onInactiveTimeout(),chrome.alarms.clear(c.AUTO_LOCK_TIMEOUT_ALARM))}))):this.timer=setTimeout((()=>this.onInactiveTimeout()),e*a.MINUTE))}setBrowserEnvironment(e,t){this.store.updateState({browserEnvironment:{os:e,browser:t}})}addPollingToken(e,t){if(t!==d.POLLING_TOKEN_ENVIRONMENT_TYPES[d.ENVIRONMENT_TYPE_BACKGROUND]){const r=this.store.getState()[t];this.store.updateState({[t]:[...r,e]})}}removePollingToken(e,t){if(t!==d.POLLING_TOKEN_ENVIRONMENT_TYPES[d.ENVIRONMENT_TYPE_BACKGROUND]){const r=this.store.getState()[t];this.store.updateState({[t]:r.filter((t=>t!==e))})}}clearPollingTokens(){this.store.updateState({popupGasPollTokens:[],notificationGasPollTokens:[],fullScreenGasPollTokens:[]})}setShowTestnetMessageInDropdown(e){this.store.updateState({showTestnetMessageInDropdown:e})}setShowBetaHeader(e){this.store.updateState({showBetaHeader:e})}setTrezorModel(e){this.store.updateState({trezorModel:e})}updateNftDropDownState(e){this.store.updateState({nftsDropdownState:e})}setFirstTimeUsedNetwork(e){const t=this.store.getState(),{usedNetworks:r}=t;r[e]=!0,this.store.updateState({usedNetworks:r})}setCurrentPopupId(e){this.store.updateState({currentPopupId:e})}getCurrentPopupId(){return this.store.getState().currentPopupId}setServiceWorkerLastActiveTime(e){this.store.updateState({serviceWorkerLastActiveTime:e})}}r.default=h}}},{package:"$root$",file:"app/scripts/controllers/app-state.js"}],[70,{"../../../../../shared/constants/app":3401,"eth-rpc-errors":2170},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("eth-rpc-errors"),s=e("../../../../../shared/constants/app");var o={methodNames:[s.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS],implementation:async function(e,t,r,o,{origin:a,getAccounts:c,getUnlockPromise:l,hasPermission:u,requestAccountsPermission:d}){if(i.has(a))return t.error=n.ethErrors.rpc.resourceUnavailable(`Already processing ${s.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS}. Please wait.`),o();if(u(s.MESSAGE_TYPE.ETH_ACCOUNTS)){try{i.add(a),await l(!0),t.result=await c(),o()}catch(e){o(e)}finally{i.delete(a)}return undefined}try{await d()}catch(e){return t.error=e,o()}const h=await c();h.length>0?t.result=h:t.error=n.ethErrors.rpc.internal("Accounts unexpectedly unavailable. Please report this bug.");return o()},hookNames:{origin:!0,getAccounts:!0,getUnlockPromise:!0,hasPermission:!0,requestAccountsPermission:!0}};r.default=o;const i=new Set}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js"}],[71,{"../../../../../shared/constants/app":3401,"eth-rpc-errors":2170},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("eth-rpc-errors");var s={methodNames:[e("../../../../../shared/constants/app").MESSAGE_TYPE.SEND_METADATA],implementation:function(e,t,r,s,{addSubjectMetadata:o,subjectType:i}){const{origin:a,params:c}=e;if(!c||"object"!=typeof c||Array.isArray(c))return s(n.ethErrors.rpc.invalidParams({data:c}));{const{icon:e=null,name:t=null,...r}=c;o({...r,iconUrl:e,name:t,subjectType:i,origin:a})}return t.result=!0,s()},hookNames:{addSubjectMetadata:!0,subjectType:!0}};r.default=s}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/send-metadata.js"}],[72,{"../../../../../shared/constants/app":3401,"../../../../../shared/constants/network":3409,"../../../../../shared/modules/network.utils":3437,"eth-rpc-errors":2170,lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("eth-rpc-errors"),s=e("lodash"),o=e("../../../../../shared/constants/app"),i=e("../../../../../shared/constants/network"),a=e("../../../../../shared/modules/network.utils");var c={methodNames:[o.MESSAGE_TYPE.SWITCH_ETHEREUM_CHAIN],implementation:async function(e,t,r,c,{getCurrentChainId:l,findNetworkConfigurationBy:u,setProviderType:d,setActiveNetwork:h,requestUserApproval:p}){var g;if(null===(g=e.params)||void 0===g||!g[0]||"object"!=typeof e.params[0])return c(n.ethErrors.rpc.invalidParams({message:`Expected single, object parameter. Received:\n${JSON.stringify(e.params)}`}));const{origin:f}=e,{chainId:m}=e.params[0],y=Object.keys((0,s.omit)(e.params[0],["chainId"]));if(y.length>0)return c(n.ethErrors.rpc.invalidParams({message:`Received unexpected keys on object parameter. Unsupported keys:\n${y}`}));const b="string"==typeof m&&m.toLowerCase();if(!(0,a.isPrefixedFormattedHexString)(b))return c(n.ethErrors.rpc.invalidParams({message:`Expected 0x-prefixed, unpadded, non-zero hexadecimal string 'chainId'. Received:\n${m}`}));if(!(0,a.isSafeChainId)(parseInt(b,16)))return c(n.ethErrors.rpc.invalidParams({message:`Invalid chain ID "${b}": numerical value greater than max safe value. Received:\n${m}`}));const v=function(e,t){if(e in i.CHAIN_ID_TO_TYPE_MAP)return{chainId:e,ticker:i.CURRENCY_SYMBOLS.ETH,nickname:i.NETWORK_TO_NAME_MAP[e],rpcUrl:i.CHAIN_ID_TO_RPC_URL_MAP[e],type:i.CHAIN_ID_TO_TYPE_MAP[e]};return t({chainId:e})}(b,u);if(v){if(l()===b)return t.result=null,c();try{const e=await p({origin:f,type:o.MESSAGE_TYPE.SWITCH_ETHEREUM_CHAIN,requestData:v});m in i.CHAIN_ID_TO_TYPE_MAP&&e.type!==i.NETWORK_TYPES.LOCALHOST&&e.type!==i.NETWORK_TYPES.LINEA_TESTNET?d(e.type):await h(e.id),t.result=null}catch(e){return c(e)}return c()}return c(n.ethErrors.provider.custom({code:4902,message:`Unrecognized chain ID "${m}". Try adding the chain using ${o.MESSAGE_TYPE.ADD_ETHEREUM_CHAIN} first.`}))},hookNames:{getCurrentChainId:!0,findNetworkConfigurationBy:!0,setProviderType:!0,setActiveNetwork:!0,requestUserApproval:!0}};r.default=c}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js"}],[73,{"../../../../../shared/constants/app":3401,"eth-rpc-errors":2170},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("eth-rpc-errors"),s=e("../../../../../shared/constants/app");var o={methodNames:[s.MESSAGE_TYPE.WATCH_ASSET,s.MESSAGE_TYPE.WATCH_ASSET_LEGACY],implementation:async function(e,t,r,s,{handleWatchAssetRequest:o}){try{const{options:r,type:n}=e.params,i=await o(r,n);return await i.result,t.result=!0,s()}catch(e){return"User rejected to watch the asset."===e.message?s(n.ethErrors.provider.userRejectedRequest()):s(e)}},hookNames:{handleWatchAssetRequest:!0}};r.default=o}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/handlers/watch-asset.js"}],[74,{"./createMethodMiddleware":64},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});var n=e("./createMethodMiddleware");Object.keys(n).forEach((function(e){"default"!==e&&"__esModule"!==e&&(e in r&&r[e]===n[e]||Object.defineProperty(r,e,{enumerable:!0,get:function(){return n[e]}}))}))}}},{package:"$root$",file:"app/scripts/lib/rpc-method-middleware/index.js"}],[75,{"../../../shared/constants/app":3401,"../../../shared/modules/fetch-with-timeout":3433},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.securityProviderCheck=async function(e,t,r,n){let s;if(t===o.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA)s={host_name:e.msgParams.origin,rpc_method_name:t,chain_id:r,data:e.msgParams.data,currentLocale:n};else if(t===o.MESSAGE_TYPE.ETH_SIGN||t===o.MESSAGE_TYPE.PERSONAL_SIGN)s={host_name:e.msgParams.origin,rpc_method_name:t,chain_id:r,data:{signer_address:e.msgParams.from,msg_to_sign:e.msgParams.data},currentLocale:n};else{var a,c,l,u,d,h;s={host_name:e.origin,rpc_method_name:t,chain_id:r,data:{from_address:null==e||null===(a=e.txParams)||void 0===a?void 0:a.from,to_address:null==e||null===(c=e.txParams)||void 0===c?void 0:c.to,gas:null==e||null===(l=e.txParams)||void 0===l?void 0:l.gas,gasPrice:null==e||null===(u=e.txParams)||void 0===u?void 0:u.gasPrice,value:null==e||null===(d=e.txParams)||void 0===d?void 0:d.value,data:null==e||null===(h=e.txParams)||void 0===h?void 0:h.data},currentLocale:n}}const p=await i("https://proxy.metafi.codefi.network/opensea/security/v1/validate",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(s)});return await p.json()};var n,s=(n=e("../../../shared/modules/fetch-with-timeout"))&&n.__esModule?n:{default:n},o=e("../../../shared/constants/app");const i=(0,s.default)()}}},{package:"$root$",file:"app/scripts/lib/security-provider-helpers.js"}],[76,{"../../../shared/constants/keyring":3406,"@metamask/eth-keyring-controller":1173,loglevel:2944},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n,s=e("@metamask/eth-keyring-controller"),o=(n=e("loglevel"))&&n.__esModule?n:{default:n},i=e("../../../shared/constants/keyring");var a={async verifyAccounts(e,t){if(!e||e.length<1)throw new Error("No created accounts defined.");const r=new s.KeyringController({}).getKeyringBuilderForType(i.KeyringType.hdKeyTree)(),n={mnemonic:t,numberOfAccounts:e.length};await r.deserialize(n);const a=await r.getAccounts();if(o.default.debug(`Created accounts: ${JSON.stringify(e)}`),o.default.debug(`Restored accounts: ${JSON.stringify(a)}`),a.length!==e.length)throw new Error("Wrong number of accounts");for(let t=0;t<a.length;t++)if(a[t].toLowerCase()!==e[t].toLowerCase())throw new Error(`Not identical accounts! Original: ${e[t]}, Restored: ${a[t]}`)}};r.default=a}}},{package:"$root$",file:"app/scripts/lib/seed-phrase-verifier.js"}],[77,{"../util":82,"@segment/loosely-validate-event":1397,buffer:1943,"is-retry-allowed":2706,lodash:2932,"remove-trailing-slash":3200,timers:3285},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t,n){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var s=l(e("remove-trailing-slash")),o=l(e("@segment/loosely-validate-event")),i=e("lodash"),a=l(e("is-retry-allowed")),c=e("../util");function l(e){return e&&e.__esModule?e:{default:e}}const u=()=>({});r.default=class{constructor(e,t={}){this.writeKey=e,this.host=(0,s.default)(t.host||"https://api.segment.io"),this.flushInterval=t.flushInterval||1e4,this.flushAt=t.flushAt||Math.max(t.flushAt,1)||20,this.queue=[],this.path="/v1/batch",this.maxQueueSize=460800,this.flushed=!1,this.retryCount=3,Object.defineProperty(this,"enable",{configurable:!1,writable:!1,enumerable:!0,value:!0})}_validate(e,t){(0,o.default)(e,t)}_message(e,t,r){return this._validate(t,e),this.enqueue(e,t,r),this}identify(e,t){return this._message("identify",e,t)}track(e,t){return this._message("track",e,t)}page(e,t){return this._message("page",e,t)}enqueue(e,t,r=u){if(!this.enable)return void n(r);const s={...t,type:e};if(s.context={...s.context,library:{name:"analytics-node"}},s.timestamp||(s.timestamp=new Date),s.messageId||(s.messageId=(0,c.generateRandomId)()),s.anonymousId&&!(0,i.isString)(s.anonymousId)&&(s.anonymousId=JSON.stringify(s.anonymousId)),s.userId&&!(0,i.isString)(s.userId)&&(s.userId=JSON.stringify(s.userId)),this.queue.push({message:s,callback:r}),!this.flushed)return this.flushed=!0,void this.flush();const o=this.queue.length>=this.flushAt,a=this.queue.reduce(((e,t)=>e+JSON.stringify(t).length),0)>=this.maxQueueSize;(o||a)&&this.flush(),this.flushInterval&&!this.timer&&(this.timer=setTimeout(this.flush.bind(this),this.flushInterval))}flush(e=u){if(!this.enable)return n(e),Promise.resolve();if(this.timer&&(clearTimeout(this.timer),this.timer=null),!this.queue.length)return n(e),Promise.resolve();const r=this.queue.splice(0,this.flushAt),s=r.map((e=>e.callback)),o={batch:r.map((e=>e.message)),timestamp:new Date,sentAt:new Date},i={Authorization:`Basic ${t.from(this.writeKey,"utf8").toString("base64")}`};return this._sendRequest(`${this.host}${this.path}`,{method:"POST",body:JSON.stringify(o),headers:i},(t=>{n((()=>{s.forEach((e=>e(t,o))),e(t,o)}))}),0)}_retryRequest(e,t,r,n){const s=100*Math.pow(2,n);setTimeout((()=>{this._sendRequest(e,t,r,n+1)}),s)}async _sendRequest(e,t,r,n){return fetch(e,t).then((async s=>{if(s.ok)r();else if(this._isErrorRetryable({response:s})&&n<=this.retryCount)this._retryRequest(e,t,r,n);else{const e=new Error(s.statusText);r(e)}})).catch((s=>{this._isErrorRetryable(s)&&n<=this.retryCount?this._retryRequest(e,t,r,n):r(s)}))}_isErrorRetryable(e){return!!function(e){return!e.response&&Boolean(e.code)&&"ECONNABORTED"!==e.code&&(0,a.default)(e)}(e)||!!e.response&&(e.response.status>=500&&e.response.status<=599||429===e.response.status)}}}).call(this)}).call(this,e("buffer").Buffer,e("timers").setImmediate)}}},{package:"$root$",file:"app/scripts/lib/segment/analytics.js"}],[78,{"../../../../shared/constants/time":3415,"./analytics":77,_process:3027},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.segment=r.createSegmentMock=void 0;var n,s=e("../../../../shared/constants/time"),o=(n=e("./analytics"))&&n.__esModule?n:{default:n};const i="XdGJ17zKf3NjBPCDQ2UDjJjkx6FYBMGP",a=t.env.SEGMENT_HOST??null,c=undefined,l=5*s.SECOND,u=(e=c)=>{const t={queue:[],flush(){t.queue.forEach((([e,t])=>{t()})),t.queue=[]},track(r,n=(()=>undefined)){t.queue.push([r,n]),t.queue.length>=e&&t.flush()},page(){},identify(){}};return t};r.createSegmentMock=u;const d=new o.default(i,{host:a,flushAt:c,flushInterval:l});r.segment=d}).call(this)}).call(this,e("_process"))}}},{package:"$root$",file:"app/scripts/lib/segment/index.js"}],[8,{"../../../shared/modules/string-utils":3442},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("../../../shared/modules/string-utils");r.default=class{constructor(e={}){const{preferencesController:t,addressBookController:r,networkController:n,trackMetaMetricsEvent:s}=e;this.preferencesController=t,this.addressBookController=r,this.networkController=n,this._trackMetaMetricsEvent=s}async restoreUserData(e){const t=this.preferencesController.store.getState(),{preferences:r,addressBook:n,network:s}=JSON.parse(e);r&&(r.identities=t.identities,r.lostIdentities=t.lostIdentities,r.selectedAddress=t.selectedAddress,this.preferencesController.store.updateState(r)),n&&this.addressBookController.update(n,!0),s&&this.networkController.store.updateState(s),(r||n||s)&&this._trackMetaMetricsEvent({event:"User Data Imported",category:"Backup"})}async backupUserData(){const e={preferences:{...this.preferencesController.store.getState()},addressBook:{...this.addressBookController.state},network:{networkConfigurations:this.networkController.store.getState().networkConfigurations}};delete e.preferences.identities,delete e.preferences.lostIdentities,delete e.preferences.selectedAddress;const t=JSON.stringify(e),r=new Date,s=e=>(0,n.prependZero)(e,2);return{fileName:`MetaMaskUserData.${r.getFullYear()}_${s(r.getMonth()+1)}_${s(r.getDay())}_${s(r.getHours())}_${s(r.getMinutes())}_${s(r.getDay())}.json`,data:t}}}}}},{package:"$root$",file:"app/scripts/controllers/backup.js"}],[83,{"../../shared/constants/app":3401,"../../shared/constants/hardware-wallets":3405,"../../shared/constants/keyring":3406,"../../shared/constants/metametrics":3408,"../../shared/constants/network":3409,"../../shared/constants/permissions":3410,"../../shared/constants/swaps":3413,"../../shared/constants/test-flags":3414,"../../shared/constants/time":3415,"../../shared/constants/tokens":3416,"../../shared/constants/transaction":3417,"../../shared/lib/metamask-controller-utils":3420,"../../shared/lib/token-util.ts":3424,"../../shared/modules/conversion.utils":3431,"../../shared/modules/hexstring-utils":3435,"../../shared/modules/mv3.utils":3436,"../../shared/modules/string-utils":3442,"../../shared/modules/transaction.utils":3444,"../../shared/notifications":3445,"./account-import-strategies":3,"./controllers/alert":6,"./controllers/app-state":7,"./controllers/backup":8,"./controllers/cached-balances":9,"./controllers/detect-tokens":10,"./controllers/ens":12,"./controllers/incoming-transactions":13,"./controllers/metametrics":14,"./controllers/network":16,"./controllers/onboarding":18,"./controllers/permissions":22,"./controllers/preferences":26,"./controllers/sign":27,"./controllers/swaps":28,"./controllers/transactions":29,"./detect-multiple-instances":35,"./lib/ComposableObservableStore":37,"./lib/account-tracker":38,"./lib/createDupeReqFilterMiddleware":40,"./lib/createLoggerMiddleware":41,"./lib/createMetaRPCHandler":42,"./lib/createMetamaskMiddleware":43,"./lib/createOnboardingMiddleware":44,"./lib/createOriginMiddleware":45,"./lib/createRPCMethodTrackingMiddleware":46,"./lib/createTabIdMiddleware":48,"./lib/decrypt-message-manager":49,"./lib/encryption-public-key-manager":50,"./lib/rpc-method-middleware":74,"./lib/security-provider-helpers":75,"./lib/seed-phrase-verifier":76,"./lib/segment":78,"./lib/stream-utils":81,"./lib/util":82,"@keystonehq/metamask-airgapped-keyring":547,"@metamask/address-book-controller":1016,"@metamask/announcement-controller":1026,"@metamask/approval-controller":1033,"@metamask/assets-controllers":1055,"@metamask/base-controller":1079,"@metamask/eth-json-rpc-middleware":1145,"@metamask/eth-keyring-controller":1173,"@metamask/eth-ledger-bridge-keyring":1174,"@metamask/gas-fee-controller":1233,"@metamask/obs-store":1298,"@metamask/obs-store/dist/asStream":1297,"@metamask/permission-controller":1305,"@metamask/phishing-controller":1318,"@metamask/smart-transactions-controller":1331,"@metamask/subject-metadata-controller":1340,"@sentry/browser":1403,_process:3027,"await-semaphore":1718,buffer:1943,"eth-json-rpc-filters":2146,"eth-json-rpc-filters/subscriptionManager":2148,"eth-lattice-keyring":2150,"eth-query":2166,"eth-rpc-errors":2170,"eth-trezor-keyring":2182,events:1944,"json-rpc-engine":2724,"json-rpc-middleware-stream":2728,lodash:2932,loglevel:2944,nanoid:2984,pump:3041},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t,n){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.default=r.METAMASK_CONTROLLER_EVENTS=void 0;var s=De(e("events")),o=De(e("pump")),i=e("@metamask/obs-store"),a=e("@metamask/obs-store/dist/asStream"),c=e("json-rpc-engine"),l=e("json-rpc-middleware-stream"),u=e("@metamask/eth-json-rpc-middleware"),d=e("lodash"),h=e("@metamask/eth-keyring-controller"),p=De(e("eth-json-rpc-filters")),g=De(e("eth-json-rpc-filters/subscriptionManager")),f=e("eth-rpc-errors"),m=e("await-semaphore"),y=De(e("loglevel")),b=De(e("eth-trezor-keyring")),v=De(e("@metamask/eth-ledger-bridge-keyring")),w=De(e("eth-lattice-keyring")),S=e("@keystonehq/metamask-airgapped-keyring"),T=De(e("eth-query")),k=De(e("nanoid")),C=e("@sentry/browser"),_=e("@metamask/address-book-controller"),E=e("@metamask/approval-controller"),M=e("@metamask/base-controller"),A=e("@metamask/assets-controllers"),P=e("@metamask/phishing-controller"),I=e("@metamask/announcement-controller"),N=e("@metamask/gas-fee-controller"),O=e("@metamask/permission-controller"),R=e("@metamask/subject-metadata-controller"),x=De(e("@metamask/smart-transactions-controller")),L=e("../../shared/constants/transaction"),D=e("../../shared/constants/swaps"),j=e("../../shared/constants/network"),U=e("../../shared/constants/hardware-wallets"),B=e("../../shared/constants/keyring"),F=e("../../shared/constants/permissions"),K=e("../../shared/notifications"),q=e("../../shared/modules/hexstring-utils"),$=e("../../shared/constants/time"),z=e("../../shared/constants/app"),H=e("../../shared/constants/metametrics"),G=e("../../shared/lib/token-util.ts"),W=e("../../shared/modules/string-utils"),V=e("../../shared/modules/transaction.utils"),Y=e("../../shared/constants/tokens"),Q=e("../../shared/lib/metamask-controller-utils"),J=e("../../shared/modules/mv3.utils"),X=e("../../shared/modules/conversion.utils"),Z=e("../../shared/constants/test-flags"),ee=e("./detect-multiple-instances"),te=De(e("./lib/ComposableObservableStore")),re=De(e("./lib/account-tracker")),ne=De(e("./lib/createDupeReqFilterMiddleware")),se=De(e("./lib/createLoggerMiddleware")),oe=e("./lib/rpc-method-middleware"),ie=De(e("./lib/createOriginMiddleware")),ae=De(e("./lib/createTabIdMiddleware")),ce=De(e("./lib/createOnboardingMiddleware")),le=e("./lib/stream-utils"),ue=De(e("./controllers/ens")),de=function(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=Le(t);if(r&&r.has(e))return r.get(e);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var i=s?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(n,o,i):n[o]=e[o]}n.default=e,r&&r.set(e,n);return n}(e("./controllers/network")),he=De(e("./controllers/preferences")),pe=De(e("./controllers/app-state")),ge=De(e("./controllers/cached-balances")),fe=De(e("./controllers/alert")),me=De(e("./controllers/onboarding")),ye=De(e("./controllers/backup")),be=De(e("./controllers/incoming-transactions")),ve=De(e("./lib/decrypt-message-manager")),we=De(e("./lib/encryption-public-key-manager")),Se=De(e("./controllers/transactions")),Te=De(e("./controllers/detect-tokens")),ke=De(e("./controllers/swaps")),Ce=De(e("./account-import-strategies")),_e=De(e("./lib/seed-phrase-verifier")),Ee=De(e("./controllers/metametrics")),Me=e("./lib/segment"),Ae=De(e("./lib/createMetaRPCHandler")),Pe=e("./lib/util"),Ie=De(e("./lib/createMetamaskMiddleware")),Ne=De(e("./controllers/sign")),Oe=e("./controllers/permissions"),Re=De(e("./lib/createRPCMethodTrackingMiddleware")),xe=e("./lib/security-provider-helpers");function Le(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(Le=function(e){return e?r:t})(e)}function De(e){return e&&e.__esModule?e:{default:e}}function je(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(r!==undefined){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}r.METAMASK_CONTROLLER_EVENTS={UPDATE_BADGE:"updateBadge",APPROVAL_STATE_CHANGE:"ApprovalController:stateChange"};class Ue extends s.default{constructor(e){var r;super(),je(this,"removePermissionsFor",(e=>{try{this.permissionController.revokePermissions(e)}catch(e){if(!(e instanceof O.PermissionsRequestNotFoundError))throw e}})),je(this,"rejectPermissionsRequest",(e=>{try{this.permissionController.rejectPermissionsRequest(e)}catch(e){if(!(e instanceof O.PermissionsRequestNotFoundError))throw e}})),je(this,"acceptPermissionsRequest",(e=>{try{this.permissionController.acceptPermissionsRequest(e)}catch(e){if(!(e instanceof O.PermissionsRequestNotFoundError))throw e}})),je(this,"resolvePendingApproval",((e,t)=>{try{this.approvalController.accept(e,t)}catch(e){if(!(e instanceof E.ApprovalRequestNotFoundError))throw e}})),je(this,"rejectPendingApproval",((e,t)=>{try{this.approvalController.reject(e,new f.EthereumRpcError(t.code,t.message,t.data))}catch(e){if(!(e instanceof E.ApprovalRequestNotFoundError))throw e}}));const{isFirstMetaMaskControllerSetup:n}=e;this.defaultMaxListeners=20,this.sendUpdate=(0,d.debounce)(this.privateSendUpdate.bind(this),200*$.MILLISECOND),this.opts=e,this.extension=e.browser,this.platform=e.platform,this.notificationManager=e.notificationManager;const s=e.initState||{},o=this.platform.getVersion();this.recordFirstTimeInfo(s),this.activeControllerConnections=0,this.getRequestAccountTabIds=e.getRequestAccountTabIds,this.getOpenMetamaskTabsIds=e.getOpenMetamaskTabsIds,this.controllerMessenger=new M.ControllerMessenger,this.localStoreApiWrapper=e.localStore,this.store=new te.default({state:s,controllerMessenger:this.controllerMessenger,persist:!0}),this.connections={},this.createVaultMutex=new m.Mutex,this.extension.runtime.onInstalled.addListener((e=>{"update"===e.reason&&"8.1.0"===o&&this.platform.openExtensionInBrowser()})),this.approvalController=new E.ApprovalController({messenger:this.controllerMessenger.getRestricted({name:"ApprovalController"}),showApprovalRequest:e.showUserConfirmation,typesExcludedFromRateLimiting:[z.MESSAGE_TYPE.ETH_SIGN,z.MESSAGE_TYPE.PERSONAL_SIGN,z.MESSAGE_TYPE.ETH_SIGN_TYPED_DATA]});const i=this.controllerMessenger.getRestricted({name:"NetworkController",allowedEvents:Object.values(de.NetworkControllerEventTypes)});this.networkController=new de.default({messenger:i,state:s.NetworkController,infuraProjectId:e.infuraProjectId,trackMetaMetricsEvent:(...e)=>this.metaMetricsController.trackEvent(...e)}),this.networkController.initializeProvider(),this.provider=this.networkController.getProviderAndBlockTracker().provider,this.blockTracker=this.networkController.getProviderAndBlockTracker().blockTracker;const a=this.controllerMessenger.getRestricted({name:"TokenListController"});this.tokenListController=new A.TokenListController({chainId:(0,X.hexToDecimal)(this.networkController.store.getState().provider.chainId),preventPollingOnNetworkRestart:!s.TokenListController||s.TokenListController.preventPollingOnNetworkRestart,onNetworkStateChange:e=>{this.networkController.store.subscribe((t=>{const r={...t,providerConfig:{...t.provider,chainId:(0,X.hexToDecimal)(t.provider.chainId)}};return e(r)}))},messenger:a,state:s.TokenListController}),this.preferencesController=new he.default({initState:s.PreferencesController,initLangCode:e.initLangCode,onInfuraIsBlocked:i.subscribe.bind(i,de.NetworkControllerEventTypes.InfuraIsBlocked),onInfuraIsUnblocked:i.subscribe.bind(i,de.NetworkControllerEventTypes.InfuraIsUnblocked),tokenListController:this.tokenListController,provider:this.provider}),this.tokensController=new A.TokensController({onPreferencesStateChange:this.preferencesController.store.subscribe.bind(this.preferencesController.store),onNetworkStateChange:e=>this.networkController.store.subscribe((t=>{const r={...t,providerConfig:{...t.provider}};return e(r)})),config:{provider:this.provider},state:s.TokensController}),this.assetsContractController=new A.AssetsContractController({onPreferencesStateChange:e=>this.preferencesController.store.subscribe(e),onNetworkStateChange:e=>i.subscribe(de.NetworkControllerEventTypes.NetworkDidChange,(()=>{const t=this.networkController.store.getState(),r={...t,providerConfig:{...t.provider,chainId:(0,X.hexToDecimal)(t.provider.chainId)}};return e(r)}))},{provider:this.provider},s.AssetsContractController),this.nftController=new A.NftController({onPreferencesStateChange:this.preferencesController.store.subscribe.bind(this.preferencesController.store),onNetworkStateChange:e=>this.networkController.store.subscribe((t=>{const r={...t,providerConfig:{...t.provider,chainId:(0,X.hexToDecimal)(t.provider.chainId)}};return e(r)})),getERC721AssetName:this.assetsContractController.getERC721AssetName.bind(this.assetsContractController),getERC721AssetSymbol:this.assetsContractController.getERC721AssetSymbol.bind(this.assetsContractController),getERC721TokenURI:this.assetsContractController.getERC721TokenURI.bind(this.assetsContractController),getERC721OwnerOf:this.assetsContractController.getERC721OwnerOf.bind(this.assetsContractController),getERC1155BalanceOf:this.assetsContractController.getERC1155BalanceOf.bind(this.assetsContractController),getERC1155TokenURI:this.assetsContractController.getERC1155TokenURI.bind(this.assetsContractController),onNftAdded:({address:e,symbol:t,tokenId:r,standard:n,source:s})=>this.metaMetricsController.trackEvent({event:H.MetaMetricsEventName.NftAdded,category:H.MetaMetricsEventCategory.Wallet,properties:{token_contract_address:e,token_symbol:t,asset_type:L.AssetType.NFT,token_standard:n,source:s},sensitiveProperties:{tokenId:r}})},{},s.NftController),this.nftController.setApiKey(t.env.OPENSEA_KEY),this.nftDetectionController=new A.NftDetectionController({onNftsStateChange:e=>this.nftController.subscribe(e),onPreferencesStateChange:this.preferencesController.store.subscribe.bind(this.preferencesController.store),onNetworkStateChange:e=>this.networkController.store.subscribe((t=>{const r={...t,providerConfig:{...t.provider,chainId:(0,X.hexToDecimal)(t.provider.chainId)}};return e(r)})),getOpenSeaApiKey:()=>this.nftController.openSeaApiKey,getBalancesInSingleCall:this.assetsContractController.getBalancesInSingleCall.bind(this.assetsContractController),addNft:this.nftController.addNft.bind(this.nftController),getNftState:()=>this.nftController.state}),this.metaMetricsController=new Ee.default({segment:Me.segment,preferencesStore:this.preferencesController.store,onNetworkDidChange:i.subscribe.bind(i,de.NetworkControllerEventTypes.NetworkDidChange),getNetworkIdentifier:()=>{const{type:e,rpcUrl:t}=this.networkController.store.getState().provider;return e===j.NETWORK_TYPES.RPC?t:e},getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,version:this.platform.getVersion(),environment:"production",extension:this.extension,initState:s.MetaMetricsController,captureException:C.captureException}),this.on("update",(e=>{this.metaMetricsController.handleMetaMaskStateUpdate(e)}));const c=this.controllerMessenger.getRestricted({name:"GasFeeController"}),l=D.GAS_API_BASE_URL;this.gasFeeController=new N.GasFeeController({state:s.GasFeeController,interval:1e4,messenger:c,clientId:D.SWAPS_CLIENT_ID,getProvider:()=>this.networkController.getProviderAndBlockTracker().provider,onNetworkStateChange:i.subscribe.bind(i,de.NetworkControllerEventTypes.NetworkDidChange),getCurrentNetworkEIP1559Compatibility:this.networkController.getEIP1559Compatibility.bind(this.networkController),getCurrentAccountEIP1559Compatibility:this.getCurrentAccountEIP1559Compatibility.bind(this),legacyAPIEndpoint:`${l}/networks/<chain_id>/gasPrices`,EIP1559APIEndpoint:`${l}/networks/<chain_id>/suggestedGasFees`,getCurrentNetworkLegacyGasAPICompatibility:()=>{const{chainId:e}=this.networkController.store.getState().provider;return e===j.CHAIN_IDS.MAINNET},getChainId:()=>this.networkController.store.getState().provider.chainId}),this.qrHardwareKeyring=new S.MetaMaskKeyring,this.appStateController=new pe.default({addUnlockListener:this.on.bind(this,"unlock"),isUnlocked:this.isUnlocked.bind(this),initState:s.AppStateController,onInactiveTimeout:()=>this.setLocked(),showUnlockRequest:e.showUserConfirmation,preferencesStore:this.preferencesController.store,qrHardwareStore:this.qrHardwareKeyring.getMemStore()});const u=this.controllerMessenger.getRestricted({name:"CurrencyRateController"});this.currencyRateController=new A.CurrencyRateController({includeUsdRate:!0,messenger:u,state:{...s.CurrencyController,nativeCurrency:this.networkController.providerStore.getState().ticker}}),this.phishingController=new P.PhishingController({},s.PhishingController),this.phishingController.maybeUpdateState(),this.announcementController=new I.AnnouncementController({allAnnouncements:K.UI_NOTIFICATIONS},s.AnnouncementController),this.tokenRatesController=new A.TokenRatesController({onTokensStateChange:e=>this.tokensController.subscribe(e),onCurrencyRateStateChange:e=>this.controllerMessenger.subscribe(`${this.currencyRateController.name}:stateChange`,e),onNetworkStateChange:e=>this.networkController.store.subscribe((t=>{const r={...t,providerConfig:{...t.provider,chainId:(0,X.hexToDecimal)(t.provider.chainId)}};return e(r)}))},{disabled:!this.preferencesController.store.getState().useCurrencyRateCheck},s.TokenRatesController),this.preferencesController.store.subscribe((0,Pe.previousValueComparator)(((e,t)=>{const{useCurrencyRateCheck:r}=e,{useCurrencyRateCheck:n}=t;n&&!r?(this.currencyRateController.start(),this.tokenRatesController.configure({disabled:!1},!1,!1)):!n&&r&&(this.currencyRateController.stop(),this.tokenRatesController.configure({disabled:!0},!1,!1))}),this.preferencesController.store.getState())),this.ensController=new ue.default({provider:this.provider,getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,onNetworkDidChange:i.subscribe.bind(i,de.NetworkControllerEventTypes.NetworkDidChange)}),this.onboardingController=new me.default({initState:s.OnboardingController}),this.incomingTransactionsController=new be.default({blockTracker:this.blockTracker,onNetworkDidChange:i.subscribe.bind(i,de.NetworkControllerEventTypes.NetworkDidChange),getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,preferencesController:this.preferencesController,onboardingController:this.onboardingController,initState:s.IncomingTransactionsController}),this.accountTracker=new re.default({provider:this.provider,blockTracker:this.blockTracker,getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,getNetworkIdentifier:()=>{const{type:e,rpcUrl:t}=this.networkController.store.getState().provider;return e===j.NETWORK_TYPES.RPC?t:e},preferencesController:this.preferencesController,onboardingController:this.onboardingController,initState:J.isManifestV3&&!1===n&&null!==(r=s.AccountTracker)&&void 0!==r&&r.accounts?{accounts:s.AccountTracker.accounts}:{accounts:{}}}),this.on("controllerConnectionChanged",(e=>{const{completedOnboarding:t}=this.onboardingController.store.getState();e>0&&t?this.triggerNetworkrequests():this.stopNetworkRequests()})),this.onboardingController.store.subscribe((0,Pe.previousValueComparator)((async(e,t)=>{const{completedOnboarding:r}=e,{completedOnboarding:n}=t;!r&&n&&this.triggerNetworkrequests()}),this.onboardingController.store.getState())),this.cachedBalancesController=new ge.default({accountTracker:this.accountTracker,getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,initState:s.CachedBalancesController}),this.tokensController.hub.on("pendingSuggestedAsset",(async()=>{await e.openPopup()}));let p=[(0,h.keyringBuilderFactory)(S.MetaMaskKeyring)];if(this.canUseHardwareWallets()){var g;const e=null===(g=this.opts.overrides)||void 0===g?void 0:g.keyrings;p=[(null==e?void 0:e.trezor)||b.default,(null==e?void 0:e.ledger)||v.default,(null==e?void 0:e.lattice)||w.default,S.MetaMaskKeyring].map((e=>(0,h.keyringBuilderFactory)(e)))}this.keyringController=new h.KeyringController({keyringBuilders:p,initState:s.KeyringController,encryptor:e.encryptor||undefined,cacheEncryptionKey:J.isManifestV3}),this.keyringController.memStore.subscribe((e=>this._onKeyringControllerUpdate(e))),this.keyringController.on("unlock",(()=>this._onUnlock())),this.keyringController.on("lock",(()=>this._onLock()));const T=()=>this.preferencesController.store.getState().identities;if(this.permissionController=new O.PermissionController({messenger:this.controllerMessenger.getRestricted({name:"PermissionController",allowedActions:[`${this.approvalController.name}:addRequest`,`${this.approvalController.name}:hasRequest`,`${this.approvalController.name}:acceptRequest`,`${this.approvalController.name}:rejectRequest`,"SnapController:getPermitted","SnapController:install"]}),state:s.PermissionController,caveatSpecifications:(0,Oe.getCaveatSpecifications)({getIdentities:T}),permissionSpecifications:{...(0,Oe.getPermissionSpecifications)({getIdentities:T,getAllAccounts:this.keyringController.getAccounts.bind(this.keyringController),captureKeyringTypesWithMissingIdentities:(e={},t=[])=>{const r=t.filter((t=>!e[t])).map((e=>{var t;return null===(t=this.keyringController.getKeyringForAccount(e))||void 0===t?void 0:t.type})),n=Object.keys(e||{}).length,s=Object.keys(this.accountTracker.store.getState().accounts||{}).length;(0,C.captureException)(new Error(`Attempt to get permission specifications failed because their were ${t.length} accounts, but ${n} identities, and the ${r} keyrings included accounts with missing identities. Meanwhile, there are ${s} accounts in the account tracker.`))}})},unrestrictedMethods:Oe.unrestrictedMethods}),this.permissionLogController=new Oe.PermissionLogController({restrictedMethods:new Set(Object.keys(F.RestrictedMethods)),initState:s.PermissionLogController}),this.subjectMetadataController=new R.SubjectMetadataController({messenger:this.controllerMessenger.getRestricted({name:"SubjectMetadataController",allowedActions:[`${this.permissionController.name}:hasPermissions`]}),state:s.SubjectMetadataController,subjectCacheLimit:100}),this.detectTokensController=new Te.default({preferences:this.preferencesController,tokensController:this.tokensController,assetsContractController:this.assetsContractController,network:this.networkController,keyringMemStore:this.keyringController.memStore,tokenList:this.tokenListController,trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}),this.addressBookController=new _.AddressBookController(undefined,s.AddressBookController),this.alertController=new fe.default({initState:s.AlertController,preferencesStore:this.preferencesController.store}),this.backupController=new ye.default({preferencesController:this.preferencesController,addressBookController:this.addressBookController,networkController:this.networkController,trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}),this.txController=new Se.default({initState:s.TransactionController||s.TransactionManager,getPermittedAccounts:this.getPermittedAccounts.bind(this),getProviderConfig:()=>this.networkController.store.getState().provider,getCurrentNetworkEIP1559Compatibility:this.networkController.getEIP1559Compatibility.bind(this.networkController),getCurrentAccountEIP1559Compatibility:this.getCurrentAccountEIP1559Compatibility.bind(this),getNetworkId:()=>this.networkController.store.getState().networkId,getNetworkStatus:()=>this.networkController.store.getState().networkStatus,onNetworkStateChange:e=>this.networkController.networkIdStore.subscribe(e),getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,preferencesStore:this.preferencesController.store,txHistoryLimit:60,signTransaction:this.keyringController.signTransaction.bind(this.keyringController),provider:this.provider,blockTracker:this.blockTracker,createEventFragment:this.metaMetricsController.createEventFragment.bind(this.metaMetricsController),updateEventFragment:this.metaMetricsController.updateEventFragment.bind(this.metaMetricsController),finalizeEventFragment:this.metaMetricsController.finalizeEventFragment.bind(this.metaMetricsController),getEventFragmentById:this.metaMetricsController.getEventFragmentById.bind(this.metaMetricsController),trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController),getParticipateInMetrics:()=>this.metaMetricsController.state.participateInMetaMetrics,getEIP1559GasFeeEstimates:this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController),getExternalPendingTransactions:this.getExternalPendingTransactions.bind(this),getAccountType:this.getAccountType.bind(this),getDeviceModel:this.getDeviceModel.bind(this),getTokenStandardAndDetails:this.getTokenStandardAndDetails.bind(this),securityProviderRequest:this.securityProviderRequest.bind(this)}),this.txController.on("newUnapprovedTx",(()=>e.showUserConfirmation())),this.txController.on("tx:status-update",(async(e,t)=>{if(t===L.TransactionStatus.confirmed||t===L.TransactionStatus.failed){const t=this.txController.txStateManager.getTransaction(e);let o={};if(t.chainId){const{networkConfigurations:e}=this.networkController.store.getState(),r=Object.values(e).find((e=>e.chainId===t.chainId));o=(null==r?void 0:r.rpcPrefs)??{}}try{await this.platform.showTransactionNotification(t,o)}catch(e){y.default.error("Failed to create transaction notification",e)}const{txReceipt:i}=t;if(t.type===L.TransactionType.tokenMethodTransferFrom&&t.txParams!==undefined){var r,n;const{data:e,to:s,from:o}=t.txParams,{chainId:i}=t,a=(0,V.parseStandardTokenTransactionData)(e),c=(0,G.getTokenIdParam)(a)??(0,Q.getTokenValueParam)(a),{allNfts:l}=this.nftController.state,u=(0,X.hexToDecimal)(i),d=null==l||null===(r=l[o])||void 0===r||null===(n=r[u])||void 0===n?void 0:n.find((({address:e,tokenId:t})=>(0,W.isEqualCaseInsensitive)(e,s)&&t===c));d&&this.nftController.checkAndUpdateSingleNftOwnershipStatus(d,!1,{userAddress:o,chainId:u})}const a=this.getState();var s;if(i&&"0x0"===i.status)this.metaMetricsController.trackEvent({event:"Tx Status Update: On-Chain Failure",category:H.MetaMetricsEventCategory.Background,properties:{action:"Transactions",errorMessage:null===(s=t.simulationFails)||void 0===s?void 0:s.reason,numberOfTokens:a.tokens.length,numberOfAccounts:Object.keys(a.accounts).length}},{matomoEvent:!0})}})),i.subscribe(de.NetworkControllerEventTypes.NetworkDidChange,(async()=>{const{ticker:e}=this.networkController.store.getState().provider;try{await this.currencyRateController.setNativeCurrency(e)}catch(e){console.error(e)}})),this.networkController.lookupNetwork(),this.decryptMessageManager=new ve.default({metricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}),this.encryptionPublicKeyManager=new we.default({metricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)}),this.signController=new Ne.default({messenger:this.controllerMessenger.getRestricted({name:"SignController",allowedActions:[`${this.approvalController.name}:addRequest`,`${this.approvalController.name}:acceptRequest`,`${this.approvalController.name}:rejectRequest`]}),keyringController:this.keyringController,preferencesController:this.preferencesController,getState:this.getState.bind(this),securityProviderRequest:this.securityProviderRequest.bind(this)}),this.swapsController=new ke.default({getBufferedGasLimit:this.txController.txGasUtil.getBufferedGasLimit.bind(this.txController.txGasUtil),networkController:this.networkController,onNetworkStateChange:e=>this.networkController.store.subscribe(e),provider:this.provider,getProviderConfig:()=>this.networkController.store.getState().provider,getTokenRatesState:()=>this.tokenRatesController.state,getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,getEIP1559GasFeeEstimates:this.gasFeeController.fetchGasFeeEstimates.bind(this.gasFeeController)}),this.smartTransactionsController=new x.default({onNetworkStateChange:e=>{this.networkController.store.subscribe((t=>{const r={...t,providerConfig:{...t.provider}};return e(r)}))},getNetwork:()=>this.networkController.store.getState().networkId??"loading",getNonceLock:this.txController.nonceTracker.getNonceLock.bind(this.txController.nonceTracker),confirmExternalTransaction:this.txController.confirmExternalTransaction.bind(this.txController),provider:this.provider,trackMetaMetricsEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController)},{supportedChainIds:[j.CHAIN_IDS.MAINNET,j.CHAIN_IDS.GOERLI]},s.SmartTransactionsController),i.subscribe(de.NetworkControllerEventTypes.NetworkDidChange,(()=>{this.accountTracker._updateAccounts()})),i.subscribe(de.NetworkControllerEventTypes.NetworkWillChange,(()=>{this.txController.txStateManager.clearUnapprovedTxs(),this.encryptionPublicKeyManager.clearUnapproved(),this.decryptMessageManager.clearUnapproved(),this.signController.clearUnapproved()})),J.isManifestV3&&!1===globalThis.isFirstTimeProfileLoaded){const{serviceWorkerLastActiveTime:e}=this.appStateController.store.getState(),t={category:H.MetaMetricsEventCategory.ServiceWorkers,event:H.MetaMetricsEventName.ServiceWorkerRestarted,properties:{service_worker_restarted_time:Date.now()-e}};try{this.metaMetricsController.trackEvent(t)}catch(e){y.default.warn("Failed to track service worker restart metric:",e)}}this.metamaskMiddleware=(0,Ie.default)({static:{eth_syncing:!1,web3_clientVersion:`MetaMask/v${o}`},version:o,getAccounts:async({origin:e},{suppressUnauthorizedError:t=!0}={})=>{if(e===z.ORIGIN_METAMASK){const e=this.preferencesController.getSelectedAddress();return e?[e]:[]}return this.isUnlocked()?await this.getPermittedAccounts(e,{suppressUnauthorizedError:t}):[]},processTransaction:this.newUnapprovedTransaction.bind(this),processEthSignMessage:this.signController.newUnsignedMessage.bind(this.signController),processTypedMessage:this.signController.newUnsignedTypedMessage.bind(this.signController),processTypedMessageV3:this.signController.newUnsignedTypedMessage.bind(this.signController),processTypedMessageV4:this.signController.newUnsignedTypedMessage.bind(this.signController),processPersonalMessage:this.signController.newUnsignedPersonalMessage.bind(this.signController),processDecryptMessage:this.newRequestDecryptMessage.bind(this),processEncryptionPublicKey:this.newRequestEncryptionPublicKey.bind(this),getPendingNonce:this.getPendingNonce.bind(this),getPendingTransactionByHash:e=>this.txController.getTransactions({searchCriteria:{hash:e,status:L.TransactionStatus.submitted}})[0]}),this.on("update",(e=>this._onStateUpdate(e)));const k={AccountTracker:this.accountTracker.store,TxController:this.txController.memStore,TokenRatesController:this.tokenRatesController,DecryptMessageManager:this.decryptMessageManager.memStore,EncryptionPublicKeyManager:this.encryptionPublicKeyManager.memStore,SignController:this.signController,SwapsController:this.swapsController.store,EnsController:this.ensController.store,ApprovalController:this.approvalController};this.store.updateStructure({AppStateController:this.appStateController.store,TransactionController:this.txController.store,KeyringController:this.keyringController.store,PreferencesController:this.preferencesController.store,MetaMetricsController:this.metaMetricsController.store,AddressBookController:this.addressBookController,CurrencyController:this.currencyRateController,NetworkController:this.networkController.store,CachedBalancesController:this.cachedBalancesController.store,AlertController:this.alertController.store,OnboardingController:this.onboardingController.store,IncomingTransactionsController:this.incomingTransactionsController.store,PermissionController:this.permissionController,PermissionLogController:this.permissionLogController.store,SubjectMetadataController:this.subjectMetadataController,BackupController:this.backupController,AnnouncementController:this.announcementController,GasFeeController:this.gasFeeController,TokenListController:this.tokenListController,TokensController:this.tokensController,SmartTransactionsController:this.smartTransactionsController,NftController:this.nftController,PhishingController:this.phishingController,...k}),this.memStore=new te.default({config:{AppStateController:this.appStateController.store,NetworkController:this.networkController.store,CachedBalancesController:this.cachedBalancesController.store,KeyringController:this.keyringController.memStore,PreferencesController:this.preferencesController.store,MetaMetricsController:this.metaMetricsController.store,AddressBookController:this.addressBookController,CurrencyController:this.currencyRateController,AlertController:this.alertController.store,OnboardingController:this.onboardingController.store,IncomingTransactionsController:this.incomingTransactionsController.store,PermissionController:this.permissionController,PermissionLogController:this.permissionLogController.store,SubjectMetadataController:this.subjectMetadataController,BackupController:this.backupController,AnnouncementController:this.announcementController,GasFeeController:this.gasFeeController,TokenListController:this.tokenListController,TokensController:this.tokensController,SmartTransactionsController:this.smartTransactionsController,NftController:this.nftController,...k},controllerMessenger:this.controllerMessenger});const U=[this.accountTracker.resetState,this.txController.resetState,this.decryptMessageManager.resetState,this.encryptionPublicKeyManager.resetState,this.signController.resetState.bind(this.signController),this.swapsController.resetState,this.ensController.resetState,this.approvalController.clear.bind(this.approvalController)];J.isManifestV3?!0===n&&(this.resetStates(U),this.extension.storage.session.set({isFirstMetaMaskControllerSetup:!1})):this.resetStates(U),!this.isUnlocked()&&this.onboardingController.store.getState().completedOnboarding?this._loginUser():this._startUISync(),this.extension.runtime.getPlatformInfo().then((({os:e})=>{this.appStateController.setBrowserEnvironment(e,this.extension.runtime.getBrowserInfo===undefined?"chrome":"firefox")})),this.setupControllerEventSubscriptions(),this.publicConfigStore=this.createPublicConfigStore(),this.extension.runtime.onMessageExternal.addListener(ee.onMessageReceived),(0,ee.checkForMultipleVersionsRunning)()}triggerNetworkrequests(){this.accountTracker.start(),this.incomingTransactionsController.start(),this.preferencesController.store.getState().useCurrencyRateCheck&&this.currencyRateController.start(),this.preferencesController.store.getState().useTokenDetection&&this.tokenListController.start()}stopNetworkRequests(){this.accountTracker.stop(),this.incomingTransactionsController.stop(),this.preferencesController.store.getState().useCurrencyRateCheck&&this.currencyRateController.stop(),this.preferencesController.store.getState().useTokenDetection&&this.tokenListController.stop()}canUseHardwareWallets(){var e;return!J.isManifestV3||(null===(e={})||void 0===e?void 0:e.HARDWARE_WALLETS_MV3)}resetStates(e){e.forEach((e=>{try{e()}catch(e){console.error(e)}}))}setupControllerEventSubscriptions(){const e=async(e,t)=>{this.isUnlocked()&&this.notifyConnections(e,{method:Oe.NOTIFICATION_NAMES.accountsChanged,params:t.length<2?t:await this.getPermittedAccounts(e)}),this.permissionLogController.updateAccountsHistory(e,t)};let t;this.preferencesController.store.subscribe((async({selectedAddress:r})=>{if(r&&r!==t){t=r;const n=(0,Oe.getPermittedAccountsByOrigin)(this.permissionController.state);for(const[t,s]of n.entries())s.includes(r)&&e(t,s)}})),this.controllerMessenger.subscribe(`${this.permissionController.name}:stateChange`,(async(t,r)=>{const n=(0,Oe.getChangedAccounts)(t,r);for(const[t,r]of n.entries())e(t,r)}),Oe.getPermittedAccountsByOrigin)}createPublicConfigStore(){const e=new i.ObservableStore,{networkController:t}=this;function r(r){const{chainId:n}=t.store.getState().provider;r.networkStatus===j.NetworkStatus.Available&&e.putState(function(e,{isUnlocked:t,networkId:r}){return{isUnlocked:t,chainId:e,networkVersion:r??"loading"}}(n,r))}return this.on("update",r),r(this.getState()),e}async getProviderState(e){return{isUnlocked:this.isUnlocked(),...this.getProviderNetworkState(),accounts:await this.getPermittedAccounts(e)}}getProviderNetworkState(e){const{networkId:t}=e||this.getState();return{chainId:this.networkController.store.getState().provider.chainId,networkVersion:t??"loading"}}getState(){const{vault:e}=this.keyringController.store.getState();return{isInitialized:Boolean(e),...this.memStore.getFlatState()}}getApi(){const{addressBookController:e,alertController:t,appStateController:r,nftController:n,nftDetectionController:s,currencyRateController:o,detectTokensController:i,ensController:a,gasFeeController:c,metaMetricsController:l,networkController:u,announcementController:d,onboardingController:h,permissionController:p,preferencesController:g,qrHardwareKeyring:f,swapsController:m,tokensController:y,smartTransactionsController:b,txController:v,assetsContractController:w,backupController:S,approvalController:T}=this;return{getState:this.getState.bind(this),setCurrentCurrency:o.setCurrentCurrency.bind(o),setUseBlockie:g.setUseBlockie.bind(g),setUseNonceField:g.setUseNonceField.bind(g),setUsePhishDetect:g.setUsePhishDetect.bind(g),setUseMultiAccountBalanceChecker:g.setUseMultiAccountBalanceChecker.bind(g),setUseTokenDetection:g.setUseTokenDetection.bind(g),setUseNftDetection:g.setUseNftDetection.bind(g),setUseCurrencyRateCheck:g.setUseCurrencyRateCheck.bind(g),setOpenSeaEnabled:g.setOpenSeaEnabled.bind(g),setIpfsGateway:g.setIpfsGateway.bind(g),setParticipateInMetaMetrics:l.setParticipateInMetaMetrics.bind(l),setCurrentLocale:g.setCurrentLocale.bind(g),markPasswordForgotten:this.markPasswordForgotten.bind(this),unMarkPasswordForgotten:this.unMarkPasswordForgotten.bind(this),getRequestAccountTabIds:this.getRequestAccountTabIds,getOpenMetamaskTabsIds:this.getOpenMetamaskTabsIds,markNotificationPopupAsAutomaticallyClosed:()=>this.notificationManager.markAsAutomaticallyClosed(),requestUserApproval:T.addAndShowApprovalRequest.bind(T),addNewAccount:this.addNewAccount.bind(this),verifySeedPhrase:this.verifySeedPhrase.bind(this),resetAccount:this.resetAccount.bind(this),removeAccount:this.removeAccount.bind(this),importAccountWithStrategy:this.importAccountWithStrategy.bind(this),connectHardware:this.connectHardware.bind(this),forgetDevice:this.forgetDevice.bind(this),checkHardwareStatus:this.checkHardwareStatus.bind(this),unlockHardwareWalletAccount:this.unlockHardwareWalletAccount.bind(this),setLedgerTransportPreference:this.setLedgerTransportPreference.bind(this),attemptLedgerTransportCreation:this.attemptLedgerTransportCreation.bind(this),establishLedgerTransportPreference:this.establishLedgerTransportPreference.bind(this),submitQRHardwareCryptoHDKey:f.submitCryptoHDKey.bind(f),submitQRHardwareCryptoAccount:f.submitCryptoAccount.bind(f),cancelSyncQRHardware:f.cancelSync.bind(f),submitQRHardwareSignature:f.submitSignature.bind(f),cancelQRHardwareSignRequest:f.cancelSignRequest.bind(f),submitPassword:this.submitPassword.bind(this),verifyPassword:this.verifyPassword.bind(this),setProviderType:u.setProviderType.bind(u),rollbackToPreviousProvider:u.rollbackToPreviousProvider.bind(u),removeNetworkConfiguration:u.removeNetworkConfiguration.bind(u),setActiveNetwork:u.setActiveNetwork.bind(u),upsertNetworkConfiguration:this.networkController.upsertNetworkConfiguration.bind(this.networkController),setSelectedAddress:g.setSelectedAddress.bind(g),addToken:y.addToken.bind(y),rejectWatchAsset:y.rejectWatchAsset.bind(y),acceptWatchAsset:y.acceptWatchAsset.bind(y),updateTokenType:y.updateTokenType.bind(y),setAccountLabel:g.setAccountLabel.bind(g),setFeatureFlag:g.setFeatureFlag.bind(g),setPreference:g.setPreference.bind(g),addKnownMethodData:g.addKnownMethodData.bind(g),setDismissSeedBackUpReminder:g.setDismissSeedBackUpReminder.bind(g),setDisabledRpcMethodPreference:g.setDisabledRpcMethodPreference.bind(g),getRpcMethodPreferences:g.getRpcMethodPreferences.bind(g),setAdvancedGasFee:g.setAdvancedGasFee.bind(g),setTheme:g.setTheme.bind(g),setTransactionSecurityCheckEnabled:g.setTransactionSecurityCheckEnabled.bind(g),getTokenStandardAndDetails:this.getTokenStandardAndDetails.bind(this),addNft:n.addNft.bind(n),addNftVerifyOwnership:n.addNftVerifyOwnership.bind(n),removeAndIgnoreNft:n.removeAndIgnoreNft.bind(n),removeNft:n.removeNft.bind(n),checkAndUpdateAllNftsOwnershipStatus:n.checkAndUpdateAllNftsOwnershipStatus.bind(n),checkAndUpdateSingleNftOwnershipStatus:n.checkAndUpdateSingleNftOwnershipStatus.bind(n),isNftOwner:n.isNftOwner.bind(n),setAddressBook:e.set.bind(e),removeFromAddressBook:e.delete.bind(e),setLastActiveTime:r.setLastActiveTime.bind(r),setDefaultHomeActiveTabName:r.setDefaultHomeActiveTabName.bind(r),setConnectedStatusPopoverHasBeenShown:r.setConnectedStatusPopoverHasBeenShown.bind(r),setRecoveryPhraseReminderHasBeenShown:r.setRecoveryPhraseReminderHasBeenShown.bind(r),setRecoveryPhraseReminderLastShown:r.setRecoveryPhraseReminderLastShown.bind(r),setOutdatedBrowserWarningLastShown:r.setOutdatedBrowserWarningLastShown.bind(r),setShowTestnetMessageInDropdown:r.setShowTestnetMessageInDropdown.bind(r),setShowBetaHeader:r.setShowBetaHeader.bind(r),updateNftDropDownState:r.updateNftDropDownState.bind(r),setFirstTimeUsedNetwork:r.setFirstTimeUsedNetwork.bind(r),tryReverseResolveAddress:a.reverseResolveAddress.bind(a),setLocked:this.setLocked.bind(this),createNewVaultAndKeychain:this.createNewVaultAndKeychain.bind(this),createNewVaultAndRestore:this.createNewVaultAndRestore.bind(this),exportAccount:this.exportAccount.bind(this),cancelTransaction:v.cancelTransaction.bind(v),updateTransaction:v.updateTransaction.bind(v),updateAndApproveTransaction:v.updateAndApproveTransaction.bind(v),approveTransactionsWithSameNonce:v.approveTransactionsWithSameNonce.bind(v),createCancelTransaction:this.createCancelTransaction.bind(this),createSpeedUpTransaction:this.createSpeedUpTransaction.bind(this),estimateGas:this.estimateGas.bind(this),getNextNonce:this.getNextNonce.bind(this),addUnapprovedTransaction:v.addUnapprovedTransaction.bind(v),createTransactionEventFragment:v.createTransactionEventFragment.bind(v),getTransactions:v.getTransactions.bind(v),updateEditableParams:v.updateEditableParams.bind(v),updateTransactionGasFees:v.updateTransactionGasFees.bind(v),updateTransactionSendFlowHistory:v.updateTransactionSendFlowHistory.bind(v),updateSwapApprovalTransaction:v.updateSwapApprovalTransaction.bind(v),updateSwapTransaction:v.updateSwapTransaction.bind(v),updatePreviousGasParams:v.updatePreviousGasParams.bind(v),signMessage:this.signController.signMessage.bind(this.signController),cancelMessage:this.signController.cancelMessage.bind(this.signController),signPersonalMessage:this.signController.signPersonalMessage.bind(this.signController),cancelPersonalMessage:this.signController.cancelPersonalMessage.bind(this.signController),signTypedMessage:this.signController.signTypedMessage.bind(this.signController),cancelTypedMessage:this.signController.cancelTypedMessage.bind(this.signController),decryptMessage:this.decryptMessage.bind(this),decryptMessageInline:this.decryptMessageInline.bind(this),cancelDecryptMessage:this.cancelDecryptMessage.bind(this),encryptionPublicKey:this.encryptionPublicKey.bind(this),cancelEncryptionPublicKey:this.cancelEncryptionPublicKey.bind(this),setSeedPhraseBackedUp:h.setSeedPhraseBackedUp.bind(h),completeOnboarding:h.completeOnboarding.bind(h),setFirstTimeFlowType:h.setFirstTimeFlowType.bind(h),setAlertEnabledness:t.setAlertEnabledness.bind(t),setUnconnectedAccountAlertShown:t.setUnconnectedAccountAlertShown.bind(t),setWeb3ShimUsageAlertDismissed:t.setWeb3ShimUsageAlertDismissed.bind(t),removePermissionsFor:this.removePermissionsFor,approvePermissionsRequest:this.acceptPermissionsRequest,rejectPermissionsRequest:this.rejectPermissionsRequest,...(0,Oe.getPermissionBackgroundApiMethods)(p),fetchAndSetQuotes:m.fetchAndSetQuotes.bind(m),setSelectedQuoteAggId:m.setSelectedQuoteAggId.bind(m),resetSwapsState:m.resetSwapsState.bind(m),setSwapsTokens:m.setSwapsTokens.bind(m),clearSwapsQuotes:m.clearSwapsQuotes.bind(m),setApproveTxId:m.setApproveTxId.bind(m),setTradeTxId:m.setTradeTxId.bind(m),setSwapsTxGasPrice:m.setSwapsTxGasPrice.bind(m),setSwapsTxGasLimit:m.setSwapsTxGasLimit.bind(m),setSwapsTxMaxFeePerGas:m.setSwapsTxMaxFeePerGas.bind(m),setSwapsTxMaxFeePriorityPerGas:m.setSwapsTxMaxFeePriorityPerGas.bind(m),safeRefetchQuotes:m.safeRefetchQuotes.bind(m),stopPollingForQuotes:m.stopPollingForQuotes.bind(m),setBackgroundSwapRouteState:m.setBackgroundSwapRouteState.bind(m),resetPostFetchState:m.resetPostFetchState.bind(m),setSwapsErrorKey:m.setSwapsErrorKey.bind(m),setInitialGasEstimate:m.setInitialGasEstimate.bind(m),setCustomApproveTxData:m.setCustomApproveTxData.bind(m),setSwapsLiveness:m.setSwapsLiveness.bind(m),setSwapsFeatureFlags:m.setSwapsFeatureFlags.bind(m),setSwapsUserFeeLevel:m.setSwapsUserFeeLevel.bind(m),setSwapsQuotesPollingLimitEnabled:m.setSwapsQuotesPollingLimitEnabled.bind(m),setSmartTransactionsOptInStatus:b.setOptInState.bind(b),fetchSmartTransactionFees:b.getFees.bind(b),clearSmartTransactionFees:b.clearFees.bind(b),submitSignedTransactions:b.submitSignedTransactions.bind(b),cancelSmartTransaction:b.cancelSmartTransaction.bind(b),fetchSmartTransactionsLiveness:b.fetchLiveness.bind(b),updateSmartTransaction:b.updateSmartTransaction.bind(b),setStatusRefreshInterval:b.setStatusRefreshInterval.bind(b),trackMetaMetricsEvent:l.trackEvent.bind(l),trackMetaMetricsPage:l.trackPage.bind(l),createEventFragment:l.createEventFragment.bind(l),updateEventFragment:l.updateEventFragment.bind(l),finalizeEventFragment:l.finalizeEventFragment.bind(l),resolvePendingApproval:this.resolvePendingApproval,rejectPendingApproval:this.rejectPendingApproval,updateViewedNotifications:d.updateViewed.bind(d),getGasFeeEstimatesAndStartPolling:c.getGasFeeEstimatesAndStartPolling.bind(c),disconnectGasFeeEstimatePoller:c.disconnectPoller.bind(c),getGasFeeTimeEstimate:c.getTimeEstimate.bind(c),addPollingTokenToAppState:r.addPollingToken.bind(r),removePollingTokenFromAppState:r.removePollingToken.bind(r),backupUserData:S.backupUserData.bind(S),restoreUserData:S.restoreUserData.bind(S),detectNewTokens:i.detectNewTokens.bind(i),detectNfts:s.detectNfts.bind(s),addDetectedTokens:y.addDetectedTokens.bind(y),addImportedTokens:y.addTokens.bind(y),ignoreTokens:y.ignoreTokens.bind(y),getBalancesInSingleCall:w.getBalancesInSingleCall.bind(w)}}async exportAccount(e,t){return await this.verifyPassword(t),this.keyringController.exportAccount(e,t)}async getTokenStandardAndDetails(e,t,r){var n,s,o,i;const{tokenList:a}=this.tokenListController.state,{tokens:c}=this.tokensController.state,l={...Y.STATIC_MAINNET_TOKEN_LIST[e.toLowerCase()]||{},...a[e.toLowerCase()]||{},...c.find((({address:t})=>(0,W.isEqualCaseInsensitive)(t,e)))||{}},u=(0,W.isEqualCaseInsensitive)(l.standard,L.TokenStandard.ERC20)||!0===l.erc20,d=!(r||(0,W.isEqualCaseInsensitive)(l.standard,L.TokenStandard.ERC1155)||(0,W.isEqualCaseInsensitive)(l.standard,L.TokenStandard.ERC721)||l.erc721),h=l.decimals!==undefined&&l.symbol;let p;if(u||d&&h)try{const r=await(0,G.fetchTokenBalance)(e,t,this.provider);p={address:e,balance:r,standard:L.TokenStandard.ERC20,decimals:l.decimals,symbol:l.symbol}}catch(e){y.default.warning(`Failed to get token balance. Error: ${e}`)}return p===undefined&&(p=await this.assetsContractController.getTokenStandardAndDetails(e,t,r)),{...p,decimals:null===(n=p)||void 0===n||null===(s=n.decimals)||void 0===s?void 0:s.toString(10),balance:null===(o=p)||void 0===o||null===(i=o.balance)||void 0===i?void 0:i.toString(10)}}async createNewVaultAndKeychain(e){const t=await this.createVaultMutex.acquire();try{let r;if((await this.keyringController.getAccounts()).length>0)r=await this.keyringController.fullUpdate();else{r=await this.keyringController.createNewVaultAndKeychain(e);const t=await this.keyringController.getAccounts();this.preferencesController.setAddresses(t),this.selectFirstIdentity()}return r}finally{t()}}async createNewVaultAndRestore(e,t){const r=await this.createVaultMutex.acquire();try{let s,o;const i=n.from(t),{keyringController:a}=this;this.preferencesController.setAddresses([]),this.permissionController.clearState(),this.accountTracker.clearAccounts(),this.cachedBalancesController.clearCachedBalances(),this.txController.txStateManager.clearUnapprovedTxs();const c=await a.createNewVaultAndRestore(e,i),l=new T.default(this.provider);s=await a.getAccounts(),o=await this.getBalance(s[s.length-1],l);const[u]=a.getKeyringsByType(B.KeyringType.hdKeyTree);if(!u)throw new Error("MetamaskController - No HD Key Tree found");for(;"0x0"!==o;)await a.addNewAccount(u),s=await a.getAccounts(),o=await this.getBalance(s[s.length-1],l);s.length>1&&"0x0"===o&&(await this.removeAccount(s[s.length-1]),s=await a.getAccounts());const d=this.preferencesController.getLedgerTransportPreference();return this.setLedgerTransportPreference(d),this.preferencesController.setAddresses(s),this.selectFirstIdentity(),c}finally{r()}}getBalance(e,t){return new Promise(((r,n)=>{const s=this.accountTracker.store.getState().accounts[e];s&&s.balance?r(s.balance):t.getBalance(e,((e,t)=>{e?(n(e),y.default.error(e)):r(t||"0x0")}))}))}async submitPassword(e){await this.keyringController.submitPassword(e);try{await this.blockTracker.checkForLatestBlock()}catch(e){y.default.error("Error while unlocking extension.",e)}const t=this.preferencesController.getLedgerTransportPreference();return this.setLedgerTransportPreference(t),this.keyringController.fullUpdate()}async _loginUser(){try{var e;const t=null===(e={})||void 0===e?void 0:e.PASSWORD;t?await this.submitPassword(t):J.isManifestV3&&await this.submitEncryptionKey(),await this.accountTracker._updateAccounts()}finally{this._startUISync()}}_startUISync(){this.emit("startUISync"),this.startUISync=!0,this.memStore.subscribe(this.sendUpdate.bind(this))}async submitEncryptionKey(){try{const{loginToken:e,loginSalt:t}=await this.extension.storage.session.get(["loginToken","loginSalt"]);if(e&&t){const{vault:r}=this.keyringController.store.getState();if(JSON.parse(r).salt!==t)return console.warn("submitEncryptionKey: Stored salt and vault salt do not match"),void await this.clearLoginArtifacts();await this.keyringController.submitEncryptionKey(e,t)}}catch(e){throw await this.clearLoginArtifacts(),e}}async clearLoginArtifacts(){await this.extension.storage.session.remove(["loginToken","loginSalt"])}async verifyPassword(e){await this.keyringController.verifyPassword(e)}selectFirstIdentity(){const{identities:e}=this.preferencesController.store.getState(),[t]=Object.keys(e);this.preferencesController.setSelectedAddress(t)}getPrimaryKeyringMnemonic(){const[e]=this.keyringController.getKeyringsByType(B.KeyringType.hdKeyTree);if(!e.mnemonic)throw new Error("Primary keyring mnemonic unavailable.");return e.mnemonic}async getKeyringForDevice(e,t=null){var r,n,s,o;const i=null===(r=this.opts.overrides)||void 0===r?void 0:r.keyrings;let a=null;if(e!==U.HardwareDeviceNames.QR&&!this.canUseHardwareWallets())throw new Error("Hardware wallets are not supported on this version.");switch(e){case U.HardwareDeviceNames.trezor:a=(null==i||null===(n=i.trezor)||void 0===n?void 0:n.type)||b.default.type;break;case U.HardwareDeviceNames.ledger:a=(null==i||null===(s=i.ledger)||void 0===s?void 0:s.type)||v.default.type;break;case U.HardwareDeviceNames.qr:a=S.MetaMaskKeyring.type;break;case U.HardwareDeviceNames.lattice:a=(null==i||null===(o=i.lattice)||void 0===o?void 0:o.type)||w.default.type;break;default:throw new Error("MetamaskController:getKeyringForDevice - Unknown device")}let[c]=await this.keyringController.getKeyringsByType(a);if(c||(c=await this.keyringController.addNewKeyring(a)),t&&c.setHdPath&&c.setHdPath(t),e===U.HardwareDeviceNames.lattice&&(c.appName="MetaMask"),e===U.HardwareDeviceNames.trezor){const e=c.getModel();this.appStateController.setTrezorModel(e)}return c.network=this.networkController.store.getState().provider.type,c}async attemptLedgerTransportCreation(){const e=await this.getKeyringForDevice(U.HardwareDeviceNames.ledger);return await e.attemptMakeApp()}async establishLedgerTransportPreference(){const e=this.preferencesController.getLedgerTransportPreference();return await this.setLedgerTransportPreference(e)}async connectHardware(e,t,r){const n=await this.getKeyringForDevice(e,r);let s=[];switch(t){case-1:s=await n.getPreviousPage();break;case 1:s=await n.getNextPage();break;default:s=await n.getFirstPage()}const o=await this.keyringController.getAccounts(),i=[...new Set(o.concat(s.map((e=>e.address.toLowerCase()))))];return this.accountTracker.syncWithAddresses(i),s}async checkHardwareStatus(e,t){return(await this.getKeyringForDevice(e,t)).isUnlocked()}async forgetDevice(e){return(await this.getKeyringForDevice(e)).forgetDevice(),!0}async getAccountType(e){switch((await this.keyringController.getKeyringForAccount(e)).type){case B.KeyringType.trezor:case B.KeyringType.lattice:case B.KeyringType.qr:case B.KeyringType.ledger:return"hardware";case B.KeyringType.imported:return"imported";default:return"MetaMask"}}async getDeviceModel(e){const t=await this.keyringController.getKeyringForAccount(e);switch(t.type){case B.KeyringType.trezor:return t.getModel();case B.KeyringType.qr:return t.getName();case B.KeyringType.ledger:return U.HardwareDeviceNames.ledger;case B.KeyringType.lattice:return U.HardwareDeviceNames.lattice;default:return"N/A"}}getAccountLabel(e,t,r){return`${e[0].toUpperCase()}${e.slice(1)} ${parseInt(t,10)+1} ${r||""}`.trim()}async unlockHardwareWalletAccount(e,t,r,n){const s=await this.getKeyringForDevice(t,r);s.setAccountToUnlock(e);const o=await this.keyringController.getAccounts(),i=await this.keyringController.addNewAccount(s),a=await this.keyringController.getAccounts();this.preferencesController.setAddresses(a),a.forEach((r=>{if(!o.includes(r)){const o=this.getAccountLabel(t===U.HardwareDeviceNames.qr?s.getName():t,e,n);this.preferencesController.setAccountLabel(r,o),this.preferencesController.setSelectedAddress(r)}}));const{identities:c}=this.preferencesController.store.getState();return{...i,identities:c}}async addNewAccount(e){this.appStateController.store.getState()[Z.ACTION_QUEUE_METRICS_E2E_TEST];const[t]=this.keyringController.getKeyringsByType(B.KeyringType.hdKeyTree);if(!t)throw new Error("MetamaskController - No HD Key Tree found");const{keyringController:r}=this,{identities:n}=this.preferencesController.store.getState();if(Object.keys(n).length===e){const e=await r.getAccounts(),n=await r.addNewAccount(t),s=await r.getAccounts();await this.verifySeedPhrase(),this.preferencesController.setAddresses(s),s.forEach((t=>{e.includes(t)||this.preferencesController.setSelectedAddress(t)}));const{identities:o}=this.preferencesController.store.getState();return{...n,identities:o}}return{...r.memStore.getState(),identities:n}}async verifySeedPhrase(){const[e]=this.keyringController.getKeyringsByType(B.KeyringType.hdKeyTree);if(!e)throw new Error("MetamaskController - No HD Key Tree found");const t=await e.serialize(),r=n.from(t.mnemonic),s=await e.getAccounts();if(s.length<1)throw new Error("MetamaskController - No accounts found");try{return await _e.default.verifyAccounts(s,r),Array.from(r.values())}catch(e){throw y.default.error(e.message),e}}async resetAccount(){const e=this.preferencesController.getSelectedAddress();return this.txController.wipeTransactions(e),this.networkController.resetConnection(),e}async getPermittedAccounts(e,{suppressUnauthorizedError:t=!0}={}){try{return await this.permissionController.executeRestrictedMethod(e,F.RestrictedMethods.eth_accounts)}catch(e){if(t&&e.code===f.errorCodes.provider.unauthorized)return[];throw e}}removeAllAccountPermissions(e){this.permissionController.updatePermissionsByCaveat(F.CaveatTypes.restrictReturnedAccounts,(t=>Oe.CaveatMutatorFactories[F.CaveatTypes.restrictReturnedAccounts].removeAccount(e,t)))}async removeAccount(e){this.removeAllAccountPermissions(e),this.preferencesController.removeAddress(e),this.accountTracker.removeAccount([e]);const t=await this.keyringController.getKeyringForAccount(e);await this.keyringController.removeAccount(e);const r=t?await t.getAccounts():{};var n;0===(null==r?void 0:r.length)&&(null===(n=t.destroy)||void 0===n||n.call(t));return e}async importAccountWithStrategy(e,t){const r=await Ce.default.importAccount(e,t),n=await this.keyringController.addNewKeyring(B.KeyringType.imported,[r]),[s]=await n.getAccounts(),o=await this.keyringController.getAccounts();this.preferencesController.setAddresses(o),this.preferencesController.setSelectedAddress(s)}async newUnapprovedTransaction(e,t){return await this.txController.newUnapprovedTransaction(e,t)}async newRequestDecryptMessage(e,t){const r=this.decryptMessageManager.addUnapprovedMessageAsync(e,t);return this.sendUpdate(),this.opts.showUserConfirmation(),r}async decryptMessageInline(e){y.default.info("MetaMaskController - decryptMessageInline");const t=e.metamaskId,r=this.decryptMessageManager.getMsg(t);try{const t=(0,q.stripHexPrefix)(e.data),s=n.from(t,"hex");e.data=JSON.parse(s.toString("utf8")),r.rawData=await this.keyringController.decryptMessage(e)}catch(e){r.error=e.message}return this.decryptMessageManager._updateMsg(r),this.getState()}async decryptMessage(e){y.default.info("MetaMaskController - decryptMessage");const t=e.metamaskId;try{const r=await this.decryptMessageManager.approveMessage(e),s=(0,q.stripHexPrefix)(r.data),o=n.from(s,"hex");r.data=JSON.parse(o.toString("utf8"));const i=await this.keyringController.decryptMessage(r);this.decryptMessageManager.setMsgStatusDecrypted(t,i)}catch(e){y.default.info("MetaMaskController - eth_decrypt failed.",e),this.decryptMessageManager.errorMessage(t,e)}return this.getState()}cancelDecryptMessage(e){return this.decryptMessageManager.rejectMsg(e),this.getState()}async newRequestEncryptionPublicKey(e,t){const r=e;switch((await this.keyringController.getKeyringForAccount(r)).type){case B.KeyringType.ledger:return new Promise(((e,t)=>{t(new Error("Ledger does not support eth_getEncryptionPublicKey."))}));case B.KeyringType.trezor:return new Promise(((e,t)=>{t(new Error("Trezor does not support eth_getEncryptionPublicKey."))}));case B.KeyringType.lattice:return new Promise(((e,t)=>{t(new Error("Lattice does not support eth_getEncryptionPublicKey."))}));case B.KeyringType.qr:return Promise.reject(new Error("QR hardware does not support eth_getEncryptionPublicKey."));default:{const r=this.encryptionPublicKeyManager.addUnapprovedMessageAsync(e,t);return this.sendUpdate(),this.opts.showUserConfirmation(),r}}}async encryptionPublicKey(e){y.default.info("MetaMaskController - encryptionPublicKey");const t=e.metamaskId;try{const r=await this.encryptionPublicKeyManager.approveMessage(e),n=await this.keyringController.getEncryptionPublicKey(r.data);this.encryptionPublicKeyManager.setMsgStatusReceived(t,n)}catch(e){y.default.info("MetaMaskController - eth_getEncryptionPublicKey failed.",e),this.encryptionPublicKeyManager.errorMessage(t,e)}return this.getState()}cancelEncryptionPublicKey(e){return this.encryptionPublicKeyManager.rejectMsg(e),this.getState()}async getCurrentAccountEIP1559Compatibility(){return!0}async createCancelTransaction(e,t,r){await this.txController.createCancelTransaction(e,t,r);return this.getState()}async createSpeedUpTransaction(e,t,r){await this.txController.createSpeedUpTransaction(e,t,r);return this.getState()}estimateGas(e){return new Promise(((t,r)=>this.txController.txGasUtil.query.estimateGas(e,((e,n)=>e?r(e):t(n.toString(16))))))}markPasswordForgotten(){this.preferencesController.setPasswordForgotten(!0),this.sendUpdate()}unMarkPasswordForgotten(){this.preferencesController.setPasswordForgotten(!1),this.sendUpdate()}setupUntrustedCommunication({connectionStream:e,sender:t,subjectType:r}){const{usePhishDetect:n}=this.preferencesController.store.getState();let s;if(s=r||(t.id&&t.id!==this.extension.runtime.id?R.SubjectType.Extension:R.SubjectType.Website),t.url){const{hostname:r}=new URL(t.url);this.phishingController.maybeUpdateState();const s=this.phishingController.test(r);if(n&&null!=s&&s.result)return this.sendPhishingWarning(e,r),void this.metaMetricsController.trackEvent({event:H.MetaMetricsEventName.PhishingPageDisplayed,category:H.MetaMetricsEventCategory.Phishing,properties:{url:r}})}const o=(0,le.setupMultiplex)(e);this.setupProviderConnection(o.createStream("metamask-provider"),t,s),t.url&&this.setupPublicConfig(o.createStream("publicConfig"))}setupTrustedCommunication(e,t){const r=(0,le.setupMultiplex)(e);this.setupControllerConnection(r.createStream("controller")),this.setupProviderConnection(r.createStream("provider"),t,R.SubjectType.Internal)}setupPhishingCommunication({connectionStream:e}){const{usePhishDetect:t}=this.preferencesController.store.getState();if(!t)return;const r=(0,le.setupMultiplex)(e).createStream("metamask-phishing-safelist");r.on("data",(0,Ae.default)({safelistPhishingDomain:this.safelistPhishingDomain.bind(this),backToSafetyPhishingWarning:this.backToSafetyPhishingWarning.bind(this)},r))}sendPhishingWarning(e,t){(0,le.setupMultiplex)(e).createStream("phishing").write({hostname:t})}setupControllerConnection(e){const t=this.getApi();this.activeControllerConnections+=1,this.emit("controllerConnectionChanged",this.activeControllerConnections),e.on("data",(0,Ae.default)(t,e,this.store,this.localStoreApiWrapper));const r=t=>{e._writableState.ended||e.write({jsonrpc:"2.0",method:"sendUpdate",params:[t]})};this.on("update",r);const n=()=>{e._writableState.ended||e.write({jsonrpc:"2.0",method:"startUISync"})};this.startUISync?n():this.once("startUISync",n),e.on("end",(()=>{this.activeControllerConnections-=1,this.emit("controllerConnectionChanged",this.activeControllerConnections),this.removeListener("update",r)}))}setupProviderConnection(e,t,r){let n,s;n=r===R.SubjectType.Internal?z.ORIGIN_METAMASK:new URL(t.url).origin,t.id&&t.id!==this.extension.runtime.id&&this.subjectMetadataController.addSubjectMetadata({origin:n,extensionId:t.id,subjectType:R.SubjectType.Extension}),t.tab&&t.tab.id&&(s=t.tab.id);const i=this.setupProviderEngine({origin:n,sender:t,subjectType:r,tabId:s}),a=(0,l.createEngineStream)({engine:i}),c=this.addConnection(n,{engine:i});(0,o.default)(e,a,e,(e=>{i._middleware.forEach((e=>{e.destroy&&"function"==typeof e.destroy&&e.destroy()})),c&&this.removeConnection(n,c),e&&y.default.error(e)}))}setupProviderEngine({origin:e,subjectType:t,sender:r,tabId:n}){const s=new c.JsonRpcEngine,{blockTracker:o,provider:i}=this,a=(0,p.default)({provider:i,blockTracker:o}),l=(0,g.default)({provider:i,blockTracker:o});return l.events.on("notification",(e=>s.emit("notification",e))),J.isManifestV3&&s.push((0,ne.default)()),s.push((0,ie.default)({origin:e})),n&&s.push((0,ae.default)({tabId:n})),s.push((0,se.default)({origin:e})),s.push(this.permissionLogController.createMiddleware()),s.push((0,Re.default)({trackEvent:this.metaMetricsController.trackEvent.bind(this.metaMetricsController),getMetricsState:this.metaMetricsController.store.getState.bind(this.metaMetricsController.store),securityProviderRequest:this.securityProviderRequest.bind(this)})),t===R.SubjectType.Website&&s.push((0,ce.default)({location:r.url,registerOnboarding:this.onboardingController.registerOnboarding})),s.push((0,oe.createMethodMiddleware)({origin:e,subjectType:t,addSubjectMetadata:this.subjectMetadataController.addSubjectMetadata.bind(this.subjectMetadataController),getProviderState:this.getProviderState.bind(this),getUnlockPromise:this.appStateController.getUnlockPromise.bind(this.appStateController),handleWatchAssetRequest:this.tokensController.watchAsset.bind(this.tokensController),requestUserApproval:this.approvalController.addAndShowApprovalRequest.bind(this.approvalController),sendMetrics:this.metaMetricsController.trackEvent.bind(this.metaMetricsController),getAccounts:this.getPermittedAccounts.bind(this,e),getPermissionsForOrigin:this.permissionController.getPermissions.bind(this.permissionController,e),hasPermission:this.permissionController.hasPermission.bind(this.permissionController,e),requestAccountsPermission:this.permissionController.requestPermissions.bind(this.permissionController,{origin:e},{eth_accounts:{}}),requestPermissionsForOrigin:this.permissionController.requestPermissions.bind(this.permissionController,{origin:e}),getCurrentChainId:()=>this.networkController.store.getState().provider.chainId,getCurrentRpcUrl:()=>this.networkController.store.getState().provider.rpcUrl,getNetworkConfigurations:()=>this.networkController.store.getState().networkConfigurations,upsertNetworkConfiguration:this.networkController.upsertNetworkConfiguration.bind(this.networkController),setActiveNetwork:this.networkController.setActiveNetwork.bind(this.networkController),findNetworkConfigurationBy:this.findNetworkConfigurationBy.bind(this),setProviderType:this.networkController.setProviderType.bind(this.networkController),getWeb3ShimUsageState:this.alertController.getWeb3ShimUsageState.bind(this.alertController),setWeb3ShimUsageRecorded:this.alertController.setWeb3ShimUsageRecorded.bind(this.alertController)})),s.push(a),s.push(l.middleware),t!==R.SubjectType.Internal&&s.push(this.permissionController.createPermissionMiddleware({origin:e})),s.push(this.metamaskMiddleware),s.push((0,u.providerAsMiddleware)(i)),s}setupPublicConfig(e){const t=(0,a.storeAsStream)(this.publicConfigStore);(0,o.default)(t,e,(e=>{t.destroy(),e&&y.default.error(e)}))}addConnection(e,{engine:t}){if(e===z.ORIGIN_METAMASK)return null;this.connections[e]||(this.connections[e]={});const r=(0,k.default)();return this.connections[e][r]={engine:t},r}removeConnection(e,t){const r=this.connections[e];r&&(delete r[t],0===Object.keys(r).length&&delete this.connections[e])}removeAllConnections(e){const t=this.connections[e];t&&Object.keys(t).forEach((t=>{this.removeConnection(e,t)}))}notifyConnections(e,t){const r=this.connections[e];r&&Object.values(r).forEach((e=>{e.engine&&e.engine.emit("notification",t)}))}notifyAllConnections(e){const t="function"==typeof e?t=>e(t):()=>e;Object.keys(this.connections).forEach((e=>{Object.values(this.connections[e]).forEach((async r=>{r.engine&&r.engine.emit("notification",await t(e))}))}))}async _onKeyringControllerUpdate(e){const{keyrings:t,encryptionKey:r,encryptionSalt:n}=e,s=t.reduce(((e,{accounts:t})=>e.concat(t)),[]);J.isManifestV3&&await this.extension.storage.session.set({loginToken:r,loginSalt:n}),s.length&&(this.preferencesController.syncAddresses(s),this.accountTracker.syncWithAddresses(s))}_onUnlock(){this.notifyAllConnections((async e=>({method:Oe.NOTIFICATION_NAMES.unlockStateChanged,params:{isUnlocked:!0,accounts:await this.getPermittedAccounts(e)}}))),this.unMarkPasswordForgotten(),this.emit("unlock")}_onLock(){this.notifyAllConnections({method:Oe.NOTIFICATION_NAMES.unlockStateChanged,params:{isUnlocked:!1}}),this.emit("lock")}_onStateUpdate(e){this.isClientOpenAndUnlocked=e.isUnlocked&&this._isClientOpen,this.notifyAllConnections({method:Oe.NOTIFICATION_NAMES.chainChanged,params:this.getProviderNetworkState(e)})}privateSendUpdate(){this.emit("update",this.getState())}isUnlocked(){return this.keyringController.memStore.getState().isUnlocked}getExternalPendingTransactions(e){return this.smartTransactionsController.getTransactions({addressFrom:e,status:"pending"})}async getPendingNonce(e){const{nonceDetails:t,releaseLock:r}=await this.txController.nonceTracker.getNonceLock(e),n=t.params.highestSuggested;return r(),n}async getNextNonce(e){const t=await this.txController.nonceTracker.getNonceLock(e);return t.releaseLock(),t.nextNonce}findNetworkConfigurationBy(e){const{networkConfigurations:t}=this.networkController.store.getState();return Object.values(t).find((t=>Object.keys(e).some((r=>t[r]===e[r]))))||null}async setLedgerTransportPreference(e){if(!this.canUseHardwareWallets())return undefined;const t=this.preferencesController.getLedgerTransportPreference(),r=this.preferencesController.setLedgerTransportPreference(e),n=await this.getKeyringForDevice(U.HardwareDeviceNames.ledger);return null!=n&&n.updateTransportMethod?n.updateTransportMethod(r).catch((e=>{throw this.preferencesController.setLedgerTransportPreference(t),e})):undefined}recordFirstTimeInfo(e){if(!("firstTimeInfo"in e)){const t=this.platform.getVersion();e.firstTimeInfo={version:t,date:Date.now()}}}set isClientOpen(e){this._isClientOpen=e,this.detectTokensController.isOpen=e}onClientClosed(){try{this.gasFeeController.stopPolling(),this.appStateController.clearPollingTokens()}catch(e){console.error(e)}}onEnvironmentTypeClosed(e){const t=z.POLLING_TOKEN_ENVIRONMENT_TYPES[e];this.appStateController.store.getState()[t].forEach((e=>{this.gasFeeController.disconnectPoller(e),this.appStateController.removePollingToken(e,t)}))}safelistPhishingDomain(e){return this.phishingController.bypass(e)}async backToSafetyPhishingWarning(){const e=this.platform.getExtensionURL();await this.platform.switchToAnotherURL(undefined,e)}setLocked(){var e;const[t]=this.keyringController.getKeyringsByType(B.KeyringType.trezor);t&&t.dispose();const[r]=this.keyringController.getKeyringsByType(B.KeyringType.ledger);return null==r||null===(e=r.destroy)||void 0===e||e.call(r),J.isManifestV3&&this.clearLoginArtifacts(),this.keyringController.setLocked()}async securityProviderRequest(e,t){const{currentLocale:r,transactionSecurityCheckEnabled:n}=this.preferencesController.store.getState();if(n){const n=Number((0,X.hexToDecimal)(this.networkController.store.getState().provider.chainId));try{return await(0,xe.securityProviderCheck)(e,t,n,r)}catch(e){throw y.default.error(e.message),e}}return null}}r.default=Ue}).call(this)}).call(this,e("_process"),e("buffer").Buffer)}}},{package:"$root$",file:"app/scripts/metamask-controller.js"}],[84,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:2,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=2;try{"etherscan"===t.data.config.provider.type&&(t.data.config.provider.type="rpc",t.data.config.provider.rpcTarget="https://rpc.metamask.io/")}catch(e){}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/002.js"}],[85,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:3,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=3;try{"https://rawtestrpc.metamask.io/"===t.data.config.provider.rpcTarget&&(t.data.config.provider.rpcTarget="https://testrpc.metamask.io/")}catch(e){}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/003.js"}],[86,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:4,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=4;try{if("rpc"!==t.data.config.provider.type)return Promise.resolve(t);switch(t.data.config.provider.rpcTarget){case"https://testrpc.metamask.io/":t.data.config.provider={type:"testnet"};break;case"https://rpc.metamask.io/":t.data.config.provider={type:"mainnet"}}}catch(e){}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/004.js"}],[87,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:5,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=5;try{const e=function(e){const{config:t}=e,r={...e,KeyringController:{vault:e.vault,selectedAccount:t.selectedAccount,walletNicknames:e.walletNicknames}};return delete r.vault,delete r.walletNicknames,delete r.config.selectedAccount,r}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #5${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/005.js"}],[88,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:6,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=6;try{const e=function(e){const t=e.KeyringController,r={...e,PreferencesController:{selectedAddress:t.selectedAccount}};return delete r.KeyringController.selectedAccount,r}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #6${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/006.js"}],[89,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:7,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=7;try{const e=function(e){const t={...e,TransactionManager:{transactions:e.transactions||[],gasMultiplier:e.gasMultiplier||1}};return delete t.transactions,delete t.gasMultiplier,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #7${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/007.js"}],[9,{"@metamask/obs-store":1298},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("@metamask/obs-store");r.default=class{constructor(e={}){const{accountTracker:t,getCurrentChainId:r}=e;this.accountTracker=t,this.getCurrentChainId=r;const s={cachedBalances:{},...e.initState};this.store=new n.ObservableStore(s),this._registerUpdates()}async updateCachedBalances({accounts:e}){const t=this.getCurrentChainId(),r=await this._generateBalancesToCache(e,t);this.store.updateState({cachedBalances:r})}_generateBalancesToCache(e,t){const{cachedBalances:r}=this.store.getState(),n={...r[t]};Object.keys(e).forEach((t=>{const r=e[t];r.balance&&(n[t]=r.balance)}));return{...r,[t]:n}}clearCachedBalances(){this.store.updateState({cachedBalances:{}})}_registerUpdates(){const e=this.updateCachedBalances.bind(this);this.accountTracker.store.subscribe(e)}}}}},{package:"$root$",file:"app/scripts/controllers/cached-balances.js"}],[90,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:8,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=8;try{const e=function(e){const t={...e,NoticeController:{noticesList:e.noticesList||[]}};return delete t.noticesList,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #8${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/008.js"}],[91,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:9,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=9;try{const e=function(e){const t=(0,n.merge)({},e,{CurrencyController:{currentCurrency:e.currentFiat||e.fiatCurrency||"USD",conversionRate:e.conversionRate,conversionDate:e.conversionDate}});return delete t.currentFiat,delete t.fiatCurrency,delete t.conversionRate,delete t.conversionDate,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #9${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/009.js"}],[92,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:10,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=10;try{const e=function(e){const t=(0,n.merge)({},e,{ShapeShiftController:{shapeShiftTxList:e.shapeShiftTxList||[]}});return delete t.shapeShiftTxList,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #10${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/010.js"}],[93,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:11,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=11;try{const e=function(e){const t=e;return delete t.TOSHash,delete t.isDisclaimerConfirmed,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #11${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/011.js"}],[94,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:12,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=12;try{const e=function(e){const t=e;return t.NoticeController.noticesList.forEach((e=>{e.read&&(e.body="")})),t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #12${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/012.js"}],[95,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:13,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=13;try{const e=function(e){const t=e,{config:r}=t;r&&r.provider&&"testnet"===r.provider.type&&(t.config.provider.type="ropsten");return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #13${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/013.js"}],[96,{lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash");var s={version:14,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=14;try{const e=function(e){const t=e;return t.NetworkController={},t.NetworkController.provider=t.config.provider,delete t.config.provider,t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #14${e.stack}`)}return Promise.resolve(t)}};r.default=s}}},{package:"$root$",file:"app/scripts/migrations/014.js"}],[97,{"../../../shared/constants/transaction":3417,lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash"),s=e("../../../shared/constants/transaction");var o={version:15,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=15;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=r;t.TransactionController.transactions=e.map((e=>e.err?("Gave up submitting tx."===e.err.message&&(e.status=s.TransactionStatus.failed),e):e))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #15${e.stack}`)}return Promise.resolve(t)}};r.default=o}}},{package:"$root$",file:"app/scripts/migrations/015.js"}],[98,{"../../../shared/constants/transaction":3417,lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash"),s=e("../../../shared/constants/transaction");var o={version:16,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=16;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=t.TransactionController;t.TransactionController.transactions=e.map((e=>e.err?("transaction with the same hash was already imported."===e.err&&(e.status=s.TransactionStatus.submitted,delete e.err),e):e))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #16${e.stack}`)}return Promise.resolve(t)}};r.default=o}}},{package:"$root$",file:"app/scripts/migrations/016.js"}],[99,{"../../../shared/constants/transaction":3417,lodash:2932},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=e("lodash"),s=e("../../../shared/constants/transaction");var o={version:17,migrate(e){const t=(0,n.cloneDeep)(e);t.meta.version=17;try{const e=function(e){const t=e,{TransactionController:r}=t;if(r&&r.transactions){const{transactions:e}=t.TransactionController;t.TransactionController.transactions=e.map((e=>(!e.status===s.TransactionStatus.failed||e.retryCount>0&&e.retryCount<2&&(e.status=s.TransactionStatus.submitted,delete e.err),e)))}return t}(t.data);t.data=e}catch(e){console.warn(`MetaMask Migration #17${e.stack}`)}return Promise.resolve(t)}};r.default=o}}},{package:"$root$",file:"app/scripts/migrations/017.js"}],[4,{"../../shared/constants/app":3401,"../../shared/constants/metametrics":3408,"../../shared/constants/time":3415,"../../shared/modules/browser-runtime.utils":3428,"../../shared/modules/mv3.utils":3436,"../../shared/modules/object.utils":3438,"./first-time-state":36,"./lib/createStreamSink":47,"./lib/ens-ipfs/setup":54,"./lib/get-first-preferred-lang-code":56,"./lib/getObjStructure":57,"./lib/local-store":58,"./lib/migrator":61,"./lib/network-store":62,"./lib/notification-manager":63,"./lib/setupSentry":80,"./lib/util":82,"./metamask-controller":83,"./migrations":168,"./platforms/extension":169,"@metamask/obs-store":1298,_process:3027,"debounce-stream":2072,"end-of-stream":2111,"eth-rpc-errors":2170,events:1944,"extension-port-stream":2287,loglevel:2944,pump:3041,"webextension-polyfill":3385},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(t){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.loadStateFromPersistence=ne,r.setupController=se,r.statePersistenceEvents=void 0;var n=R(e("events")),s=R(e("end-of-stream")),o=R(e("pump")),i=R(e("debounce-stream")),a=R(e("loglevel")),c=R(e("webextension-polyfill")),l=e("@metamask/obs-store"),u=R(e("extension-port-stream")),d=e("eth-rpc-errors"),h=e("../../shared/constants/app"),p=e("../../shared/constants/time"),g=e("../../shared/constants/metametrics"),f=e("../../shared/modules/browser-runtime.utils"),m=e("../../shared/modules/mv3.utils"),y=e("../../shared/modules/object.utils"),b=R(e("./migrations")),v=R(e("./lib/migrator")),w=R(e("./platforms/extension")),S=R(e("./lib/local-store")),T=(R(e("./lib/network-store")),e("./lib/setupSentry")),k=R(e("./lib/createStreamSink")),C=O(e("./lib/notification-manager")),_=O(e("./metamask-controller")),E=R(e("./first-time-state")),M=R(e("./lib/get-first-preferred-lang-code")),A=R(e("./lib/getObjStructure")),P=R(e("./lib/ens-ipfs/setup")),I=e("./lib/util");function N(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(N=function(e){return e?r:t})(e)}function O(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=N(t);if(r&&r.has(e))return r.get(e);var n={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var i=s?Object.getOwnPropertyDescriptor(e,o):null;i&&(i.get||i.set)?Object.defineProperty(n,o,i):n[o]=e[o]}return n.default=e,r&&r.set(e,n),n}function R(e){return e&&e.__esModule?e:{default:e}}const{sentry:x}=global,L={...E.default},D={[h.ENVIRONMENT_TYPE_POPUP]:!0,[h.ENVIRONMENT_TYPE_NOTIFICATION]:!0,[h.ENVIRONMENT_TYPE_FULLSCREEN]:!0},j=["trezor-connect"];a.default.setDefaultLevel("info");const U=new w.default,B=new C.default;global.METAMASK_NOTIFIER=B;let F=!1,K=!1,q=!1;const $={},z={};let H;const G=new S.default;let W;const V=new URL("https://metamask.github.io/phishing-warning/v2.1.0/"),Y=new n.default;r.statePersistenceEvents=Y;const{promise:Q,resolve:J,reject:X}=(0,I.deferredPromise)();let Z,ee;async function te(){try{const e=await ne(),t=await(0,M.default)();let r;if(m.isManifestV3){const e=await c.default.storage.session.get(["isFirstMetaMaskControllerSetup"]);r=(null==e?void 0:e.isFirstMetaMaskControllerSetup)===undefined,await c.default.storage.session.set({isFirstMetaMaskControllerSetup:r})}se(e,t,{},r),m.isManifestV3||await async function(){let e;try{const t=new URL("https://metamask.github.io/phishing-warning/v2.1.0/");let r,n;t.hash="#extensionStartup",e=window.document.createElement("iframe"),e.setAttribute("src",t.href),e.setAttribute("sandbox","allow-scripts allow-same-origin");const s=new Promise(((e,t)=>{r=e,n=t}));e.addEventListener("load",r),window.document.body.appendChild(e),setTimeout((()=>n(new re)),1e3),await s}catch(e){e instanceof re?console.warn("Phishing warning page timeout; page not guaraneteed to work offline."):console.error("Failed to initialize phishing warning page",e)}finally{e&&e.remove()}}(),await(async()=>{const e=await c.default.tabs.query({url:"<all_urls>",windowType:"normal"}).then((e=>((0,f.checkForLastErrorAndLog)(),e))).catch((()=>{(0,f.checkForLastErrorAndLog)()}));for(const t of e)c.default.tabs.sendMessage(t.id,{name:h.EXTENSION_MESSAGES.READY}).then((()=>{(0,f.checkForLastErrorAndLog)()})).catch((()=>{(0,f.checkForLastErrorAndLog)()}))})(),a.default.info("MetaMask initialization complete."),J()}catch(e){X(e)}}c.default.runtime.onConnect.addListener((async(...e)=>{await Q,Z(...e)})),c.default.runtime.onConnectExternal.addListener((async(...e)=>{await Q,ee(...e)}));class re extends Error{constructor(){super("Timeout failed")}}async function ne(){const e=new v.default({migrations:b.default});if(e.on("error",console.warn),W=await G.get()||e.generateInitialState(L),W&&!W.data&&(W=e.generateInitialState(L),x.captureMessage("MetaMask - Empty vault found - unable to recover")),e.on("error",(e=>{const t=(0,A.default)(W);x.captureException(e,{extra:{vaultStructure:t}})})),W=await e.migrateData(W),!W)throw new Error("MetaMask - migrator returned undefined");return G.setMetadata(W.meta),G.set(W.data),W.data}function se(e,t,r,n){var p;H=new _.default({infuraProjectId:"b6bf7d3508c941499b10025c0776eaf8",showUserConfirmation:oe,openPopup:ie,initState:e,initLangCode:t,platform:U,notificationManager:B,browser:c.default,getRequestAccountTabIds:()=>z,getOpenMetamaskTabsIds:()=>$,localStore:G,overrides:r,isFirstMetaMaskControllerSetup:n}),(0,P.default)({getCurrentChainId:()=>H.networkController.store.getState().provider.chainId,getIpfsGateway:H.preferencesController.getIpfsGateway.bind(H.preferencesController),provider:H.provider}),(0,o.default)((0,l.storeAsStream)(H.store),(0,i.default)(1e3),(0,k.default)((async e=>{await G.set(e),Y.emit("state-persisted",e)})),(e=>{a.default.error("MetaMask - Persistence pipeline failed",e)})),p=H,global.stateHooks.getSentryState=function(){const e=p.getState(),t=(0,y.maskObject)({metamask:e},T.SENTRY_STATE);return{browser:window.navigator.userAgent,store:t,version:U.getVersion()}};const f=()=>F||Boolean(Object.keys($).length)||K,b=(e,t)=>{if(!1===e)H.onClientClosed();else{if(t===h.ENVIRONMENT_TYPE_FULLSCREEN&&Boolean(Object.keys($).length))return;H.onEnvironmentTypeClosed(t)}};function v(){let e="";const t=w();t&&(e=String(t)),m.isManifestV3?(c.default.action.setBadgeText({text:e}),c.default.action.setBadgeBackgroundColor({color:"#037DD6"})):(c.default.browserAction.setBadgeText({text:e}),c.default.browserAction.setBadgeBackgroundColor({color:"#037DD6"}))}function w(){const e=H.txController.getUnapprovedTxCount(),{unapprovedDecryptMsgCount:t}=H.decryptMessageManager,{unapprovedEncryptionPublicKeyMsgCount:r}=H.encryptionPublicKeyManager;return e+t+r+H.approvalController.getTotalApprovalCount()+H.appStateController.waitingForUnlock.length}Z=async e=>{var t;const n=e.name;if(j.includes(e.name))return;let o=!1;const i=(0,I.getPlatform)(),a=null!==(t=e.sender)&&void 0!==t&&t.url?new URL(e.sender.url):null;if(o=i===h.PLATFORM_FIREFOX?D[n]:(null==a?void 0:a.origin)===`chrome-extension://${c.default.runtime.id}`,o){var l;const t=(null==r||null===(l=r.getPortStream)||void 0===l?void 0:l.call(r,e))||new u.default(e);if(H.isClientOpen=!0,H.setupTrustedCommunication(t,e.sender),m.isManifestV3&&e.onMessage.addListener((t=>{"WORKER_KEEP_ALIVE_MESSAGE"===t.name&&(e.postMessage({name:"ACK_KEEP_ALIVE_MESSAGE"}),H.appStateController.setServiceWorkerLastActiveTime(Date.now()))})),n===h.ENVIRONMENT_TYPE_POPUP&&(F=!0,(0,s.default)(t,(()=>{F=!1;const e=f();H.isClientOpen=e,b(e,h.ENVIRONMENT_TYPE_POPUP)}))),n===h.ENVIRONMENT_TYPE_NOTIFICATION&&(K=!0,(0,s.default)(t,(()=>{K=!1;const e=f();H.isClientOpen=e,b(e,h.ENVIRONMENT_TYPE_NOTIFICATION)}))),n===h.ENVIRONMENT_TYPE_FULLSCREEN){const r=e.sender.tab.id;$[r]=!0,(0,s.default)(t,(()=>{delete $[r];const e=f();H.isClientOpen=e,b(e,h.ENVIRONMENT_TYPE_FULLSCREEN)}))}}else if(a&&a.origin===V.origin&&a.pathname===V.pathname){var d;const t=(null==r||null===(d=r.getPortStream)||void 0===d?void 0:d.call(r,e))||new u.default(e);H.setupPhishingCommunication({connectionStream:t})}else{if(e.sender&&e.sender.tab&&e.sender.url){const t=e.sender.tab.id,r=new URL(e.sender.url),{origin:n}=r;e.onMessage.addListener((e=>{e.data&&"eth_requestAccounts"===e.data.method&&(z[n]=t)}))}ee(e)}},ee=e=>{var t;const n=(null==r||null===(t=r.getPortStream)||void 0===t?void 0:t.call(r,e))||new u.default(e);H.setupUntrustedCommunication({connectionStream:n,sender:e.sender})},null!=r&&r.registerConnectListeners&&r.registerConnectListeners(Z,ee),v(),H.txController.on(_.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,v),H.decryptMessageManager.on(_.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,v),H.encryptionPublicKeyManager.on(_.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,v),H.signController.hub.on(_.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,v),H.appStateController.on(_.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,v),H.controllerMessenger.subscribe(_.METAMASK_CONTROLLER_EVENTS.APPROVAL_STATE_CHANGE,v),B.on(C.NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,(({automaticallyClosed:e})=>{e?w()>0&&oe():(Object.keys(H.txController.txStateManager.getUnapprovedTxList()).forEach((e=>H.txController.txStateManager.setTxStatusRejected(e))),H.signController.rejectUnapproved(g.REJECT_NOTIFICATION_CLOSE_SIG),H.decryptMessageManager.messages.filter((e=>"unapproved"===e.status)).forEach((e=>H.decryptMessageManager.rejectMsg(e.id,g.REJECT_NOTIFICATION_CLOSE))),H.encryptionPublicKeyManager.messages.filter((e=>"unapproved"===e.status)).forEach((e=>H.encryptionPublicKeyManager.rejectMsg(e.id,g.REJECT_NOTIFICATION_CLOSE))),Object.values(H.approvalController.state.pendingApprovals).forEach((({id:e,type:t})=>{H.approvalController.reject(e,d.ethErrors.provider.userRejectedRequest())})),v())}))}async function oe(){const e=await U.getActiveTabs(),t=Boolean(e.find((e=>$[e.id]))),r=e.length>0&&e[0].extData&&e[0].extData.indexOf("vivaldi_tab")>-1;if(!q&&(r||!F)&&!t){q=!0;try{const e=H.appStateController.getCurrentPopupId();await B.showPopup((e=>H.appStateController.setCurrentPopupId(e)),e)}finally{q=!1}}}async function ie(){await oe(),await new Promise((e=>{const t=setInterval((()=>{K||(clearInterval(t),e())}),p.SECOND)}))}const ae=()=>{if(H)return H.metaMetricsController.updateTraits({[g.MetaMetricsUserTrait.InstallDateExt]:(new Date).toISOString().split("T")[0]}),void H.metaMetricsController.addEventBeforeMetricsOptIn({category:g.MetaMetricsEventCategory.App,event:g.MetaMetricsEventName.AppInstalled,properties:{}});setTimeout((()=>{ae()}),1e3)};c.default.runtime.onInstalled.addListener((({reason:e})=>{"install"===e&&(ae(),U.openExtensionInBrowser())})),t.env.SKIP_BACKGROUND_INITIALIZATION||te().catch(a.default.error)}).call(this)}).call(this,e("_process"))}}},{package:"$root$",file:"app/scripts/background.js"}]],[4],{});