LavaPack.loadBundle([[570,{"../../development/wdyr":573,"../../shared/constants/app":5744,"../../shared/constants/infura-project-id":5754,"../../shared/lib/trace":5857,"../../shared/modules/browser-runtime.utils":5868,"../../shared/modules/mv3.utils":5880,"../../ui":7187,"./lib/metaRPCClientFactory":268,"./lib/setup-initial-state-hooks":305,"./lib/stream-utils":323,"./lib/util":341,"./platforms/extension":557,"@lavamoat/lavadome-react":845,"@metamask/json-rpc-engine":2003,"@metamask/providers":2386,"extension-port-stream":4329,loglevel:4787,"react-devtools-core":4019,"webextension-polyfill":5727},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){e("@lavamoat/lavadome-react"),e("./lib/setup-initial-state-hooks"),e("../../development/wdyr"),e("../../shared/constants/infura-project-id");v(e("react-devtools-core"));var n=h(e("webextension-polyfill")),a=e("@metamask/providers"),o=e("@metamask/json-rpc-engine"),i=h(e("loglevel")),s=e("extension-port-stream"),c=v(e("../../ui")),l=e("../../shared/constants/app"),u=e("../../shared/modules/mv3.utils"),d=e("../../shared/modules/browser-runtime.utils"),m=e("../../shared/lib/trace"),p=h(e("./platforms/extension")),f=e("./lib/stream-utils"),g=e("./lib/util"),w=h(e("./lib/metaRPCClientFactory"));function h(e){return e&&e.__esModule?e:{default:e}}function b(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(b=function(e){return e?r:t})(e)}function v(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=b(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&{}.hasOwnProperty.call(e,o)){var i=a?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}const y="phishing-warning-sw-registered",T=document.getElementById("app-content");class P extends Error{constructor(){super("Timeout failed")}}(async function(){const e=performance.now(),t=(0,m.trace)({name:m.TraceName.UIStartup,startTime:performance.timeOrigin});(0,m.trace)({name:m.TraceName.LoadScripts,startTime:performance.timeOrigin,parentContext:t}),(0,m.endTrace)({name:m.TraceName.LoadScripts,timestamp:performance.timeOrigin+e}),global.platform=new p.default;const r=(0,g.getEnvironmentType)(),h=n.default.runtime.connect({name:r}),b=new c.CriticalStartupErrorHandler(h,T);b.install();const v=function(e){const t=(0,f.setupMultiplex)(e),r=t.createStream("controller"),n=t.createStream("provider");return t.ignoreStream("background-liveness"),{controller:r,provider:n}}(new s.ExtensionPortStream(h)),k=(0,w.default)(v.controller);(0,c.connectToBackground)(k,async function(){(0,m.endTrace)({name:m.TraceName.BackgroundConnect}),b.uninstall(),await async function(e){const t=new a.StreamProvider(e,{rpcMiddleware:[(0,o.createIdRemapMiddleware)()]});e.on("error",console.error.bind(console)),t.on("error",console.error.bind(console)),await t.initialize(),global.ethereumProvider=t}(v.provider);const e=await async function(e){if(e!==l.ENVIRONMENT_TYPE_POPUP)return{};const t=await n.default.tabs.query({active:!0,currentWindow:!0}).catch(e=>{(0,d.checkForLastErrorAndLog)()||i.default.error(e)}),[r]=t,{id:a,title:o,url:s}=r,{origin:c,protocol:u}=s?new URL(s):{};return c&&"null"!==c?{id:a,title:o,origin:c,protocol:u,url:s}:{}}(r);await async function(e,t,r,n){try{const a=await async function(e,t,r){return await(0,c.default)({activeTab:e,container:T,backgroundConnection:t,traceContext:r})}(e,t,n);(0,m.endTrace)({name:m.TraceName.UIStartup});const o=a.getState(),{metamask:{completedOnboarding:i}={}}=o;i||r===l.ENVIRONMENT_TYPE_FULLSCREEN||global.platform.openExtensionInBrowser()}catch(e){await(0,c.displayCriticalError)(T,c.CriticalErrorTranslationKey.TroubleStarting,e)}}(e,k,r,t),u.isManifestV3&&await async function(){if((await n.default.storage.session.get(y))[y])return;const e=(0,g.getPlatform)();let t;try{const r=new URL("https://metamask.github.io/phishing-warning/v5.1.0/");let a,o;r.hash="#extensionStartup",t=window.document.createElement("iframe"),t.setAttribute("src",r.href),t.setAttribute("sandbox","allow-scripts allow-same-origin");const i=new Promise((e,t)=>{a=e,o=t});t.addEventListener("load",a),window.document.body.appendChild(t),setTimeout(()=>o(new P),1e3),await i,e===l.PLATFORM_FIREFOX?console.error("Firefox does not support required MV3 APIs: Phishing warning page iframe and service worker will reload each page refresh"):n.default.storage.session.set({[y]:!0})}catch(e){e instanceof P?console.warn("Phishing warning page timeout; page not guaranteed to work offline."):console.error("Failed to initialize phishing warning page",e)}finally{t&&t.remove()}}()}),(0,m.trace)({name:m.TraceName.BackgroundConnect,parentContext:t})})().catch(i.default.error)}}},{package:"$root$",file:"app/scripts/ui.js"}]],[570],{});