LavaPack.loadBundle([[998,{"@firebase/component":999,"@firebase/logger":1001,"@firebase/util":1004,idb:6872},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"FirebaseError",{enumerable:!0,get:function(){return i.FirebaseError}}),a._DEFAULT_ENTRY_NAME=a.SDK_VERSION=void 0,a._addComponent=z,a._addOrOverwriteComponent=function(e,t){e.container.addOrOverwriteComponent(t)},a._apps=void 0,a._clearComponents=function(){V.clear()}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */,a._components=void 0,a._getProvider=$,a._isFirebaseApp=H,a._isFirebaseServerApp=function(e){return e.settings!==undefined},a._registerComponent=K,a._removeServiceInstance=function(e,t,a=F){$(e,t).clearInstance(a)},a._serverApps=void 0,a.deleteApp=X,a.getApp=function(e=F){const t=x.get(e);if(!t&&e===F&&(0,i.getDefaultAppConfig)())return J();if(!t)throw G.create("no-app",{appName:e});return t},a.getApps=function(){return Array.from(x.values())},a.initializeApp=J,a.initializeServerApp=function(e,t){if((0,i.isBrowser)()&&!(0,i.isWebWorker)())throw G.create("invalid-server-app-environment");t.automaticDataCollectionEnabled===undefined&&(t.automaticDataCollectionEnabled=!1);let a;a=H(e)?e.options:e;const n=Object.assign(Object.assign({},t),a);n.releaseOnDeref!==undefined&&delete n.releaseOnDeref;if(t.releaseOnDeref!==undefined&&"undefined"==typeof FinalizationRegistry)throw G.create("finalization-registry-not-supported",{});const s=""+(l=JSON.stringify(n),[...l].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0)),o=B.get(s);var l;if(o)return o.incRefCount(t.releaseOnDeref),o;const c=new r.ComponentContainer(s);for(const e of V.values())c.addComponent(e);const d=new q(a,t,s,c);return B.set(s,d),d},a.onLog=function(e,t){if(null!==e&&"function"!=typeof e)throw G.create("invalid-log-argument");(0,n.setUserLogHandler)(e,t)},a.registerVersion=Z,a.setLogLevel=function(e){(0,n.setLogLevel)(e)}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */;var r=e("@firebase/component"),n=e("@firebase/logger"),i=e("@firebase/util"),s=e("idb");
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class o{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const l="@firebase/app",c="0.10.18",d=new n.Logger("@firebase/app"),u="@firebase/app-compat",p="@firebase/analytics-compat",f="@firebase/analytics",h="@firebase/app-check-compat",g="@firebase/app-check",m="@firebase/auth",b="@firebase/auth-compat",E="@firebase/database",v="@firebase/data-connect",w="@firebase/database-compat",C="@firebase/functions",S="@firebase/functions-compat",M="@firebase/installations",y="@firebase/installations-compat",I="@firebase/messaging",_="@firebase/messaging-compat",T="@firebase/performance",A="@firebase/performance-compat",O="@firebase/remote-config",P="@firebase/remote-config-compat",N="@firebase/storage",k="@firebase/storage-compat",R="@firebase/firestore",D="@firebase/vertexai",L="@firebase/firestore-compat",U="firebase",F=a._DEFAULT_ENTRY_NAME="[DEFAULT]",j={[l]:"fire-core",[u]:"fire-core-compat",[f]:"fire-analytics",[p]:"fire-analytics-compat",[g]:"fire-app-check",[h]:"fire-app-check-compat",[m]:"fire-auth",[b]:"fire-auth-compat",[E]:"fire-rtdb",[v]:"fire-data-connect",[w]:"fire-rtdb-compat",[C]:"fire-fn",[S]:"fire-fn-compat",[M]:"fire-iid",[y]:"fire-iid-compat",[I]:"fire-fcm",[_]:"fire-fcm-compat",[T]:"fire-perf",[A]:"fire-perf-compat",[O]:"fire-rc",[P]:"fire-rc-compat",[N]:"fire-gcs",[k]:"fire-gcs-compat",[R]:"fire-fst",[L]:"fire-fst-compat",[D]:"fire-vertex","fire-js":"fire-js",[U]:"fire-js-all"},x=a._apps=new Map,B=a._serverApps=new Map,V=a._components=new Map;function z(e,t){try{e.container.addComponent(t)}catch(a){d.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,a)}}function K(e){const t=e.name;if(V.has(t))return d.debug(`There were multiple attempts to register component ${t}.`),!1;V.set(t,e);for(const t of x.values())z(t,e);for(const t of B.values())z(t,e);return!0}function $(e,t){const a=e.container.getProvider("heartbeat").getImmediate({optional:!0});return a&&a.triggerHeartbeat(),e.container.getProvider(t)}function H(e){return e.options!==undefined}const Y={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},G=new i.ErrorFactory("app","Firebase",Y);
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
class W{constructor(e,t,a){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=a,this.container.addComponent(new r.Component("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw G.create("app-deleted",{appName:this._name})}}
/**
 * @license
 * Copyright 2023 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class q extends W{constructor(e,t,a,r){const n=t.automaticDataCollectionEnabled!==undefined&&t.automaticDataCollectionEnabled,i={name:a,automaticDataCollectionEnabled:n};if(e.apiKey!==undefined)super(e,i,r);else{super(e.options,i,r)}this._serverConfig=Object.assign({automaticDataCollectionEnabled:n},t),this._finalizationRegistry=null,"undefined"!=typeof FinalizationRegistry&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=undefined,t.releaseOnDeref=undefined,Z(l,c,"serverapp")}toJSON(){return undefined}get refCount(){return this._refCount}incRefCount(e){this.isDeleted||(this._refCount++,e!==undefined&&null!==this._finalizationRegistry&&this._finalizationRegistry.register(e,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){X(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw G.create("server-app-deleted")}}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */a.SDK_VERSION="11.2.0";function J(e,t={}){let a=e;if("object"!=typeof t){t={name:t}}const n=Object.assign({name:F,automaticDataCollectionEnabled:!1},t),s=n.name;if("string"!=typeof s||!s)throw G.create("bad-app-name",{appName:String(s)});if(a||(a=(0,i.getDefaultAppConfig)()),!a)throw G.create("no-options");const o=x.get(s);if(o){if((0,i.deepEqual)(a,o.options)&&(0,i.deepEqual)(n,o.config))return o;throw G.create("duplicate-app",{appName:s})}const l=new r.ComponentContainer(s);for(const e of V.values())l.addComponent(e);const c=new W(a,n,l);return x.set(s,c),c}async function X(e){let t=!1;const a=e.name;if(x.has(a))t=!0,x.delete(a);else if(B.has(a)){e.decRefCount()<=0&&(B.delete(a),t=!0)}t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function Z(e,t,a){var n;let i=null!==(n=j[e])&&void 0!==n?n:e;a&&(i+=`-${a}`);const s=i.match(/\s|\//),o=t.match(/\s|\//);if(s||o){const e=[`Unable to register library "${i}" with version "${t}":`];return s&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&o&&e.push("and"),o&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void d.warn(e.join(" "))}K(new r.Component(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}const Q="firebase-heartbeat-store";let ee=null;function te(){return ee||(ee=(0,s.openDB)("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(Q)}catch(e){console.warn(e)}}}).catch(e=>{throw G.create("idb-open",{originalErrorMessage:e.message})})),ee}async function ae(e,t){try{const a=(await te()).transaction(Q,"readwrite"),r=a.objectStore(Q);await r.put(t,re(e)),await a.done}catch(e){if(e instanceof i.FirebaseError)d.warn(e.message);else{const t=G.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});d.warn(t.message)}}}function re(e){return`${e.name}!${e.options.appId}`}
/**
 * @license
 * Copyright 2021 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class ne{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new se(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{const a=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=ie();if(null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)))return;if(this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(e=>e.date===r))return;return this._heartbeatsCache.heartbeats.push({date:r,agent:a}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(e=>{const t=new Date(e.date).valueOf();return Date.now()-t<=2592e6}),this._storage.overwrite(this._heartbeatsCache)}catch(e){d.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";const t=ie(),{heartbeatsToSend:a,unsentEntries:r}=function(e,t=1024){const a=[];let r=e.slice();for(const n of e){const e=a.find(e=>e.agent===n.agent);if(e){if(e.dates.push(n.date),oe(a)>t){e.dates.pop();break}}else if(a.push({agent:n.agent,dates:[n.date]}),oe(a)>t){a.pop();break}r=r.slice(1)}return{heartbeatsToSend:a,unsentEntries:r}}(this._heartbeatsCache.heartbeats),n=(0,i.base64urlEncodeWithoutPadding)(JSON.stringify({version:2,heartbeats:a}));return this._heartbeatsCache.lastSentHeartbeatDate=t,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),n}catch(e){return d.warn(e),""}}}function ie(){return(new Date).toISOString().substring(0,10)}class se{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,i.isIndexedDBAvailable)()&&(0,i.validateIndexedDBOpenable)().then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await te()).transaction(Q),a=await t.objectStore(Q).get(re(e));return await t.done,a}catch(e){if(e instanceof i.FirebaseError)d.warn(e.message);else{const t=G.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});d.warn(t.message)}}}(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const a=await this.read();return ae(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:a.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const a=await this.read();return ae(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:a.lastSentHeartbeatDate,heartbeats:[...a.heartbeats,...e.heartbeats]})}}}function oe(e){return(0,i.base64urlEncodeWithoutPadding)(JSON.stringify({version:2,heartbeats:e})).length}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */var le;le="",K(new r.Component("platform-logger",e=>new o(e),"PRIVATE")),K(new r.Component("heartbeat",e=>new ne(e),"PRIVATE")),Z(l,c,le),Z(l,c,"esm2017"),Z("fire-js","")}}},{package:"@metamask/notification-services-controller>firebase>@firebase/app",file:"node_modules/@firebase/app/dist/esm/index.esm2017.js"}],[999,{"@firebase/util":1004},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.Provider=a.ComponentContainer=a.Component=void 0;var r=e("@firebase/util");
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
a.Component=class{constructor(e,t,a){this.name=e,this.instanceFactory=t,this.type=a,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}};const n="[DEFAULT]";
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */class i{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new r.Deferred;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const a=this.getOrInitializeService({instanceIdentifier:t});a&&e.resolve(a)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const a=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(a)&&!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:a})}catch(e){if(r)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}
/**
 * @license
 * Copyright 2019 Google LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */(e))try{this.getOrInitializeService({instanceIdentifier:n})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const a=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:a});t.resolve(e)}catch(e){}}}}clearInstance(e=n){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=n){return this.instances.has(e)}getOptions(e=n){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,a=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(a))throw Error(`${this.name}(${a}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:a,options:t});for(const[e,t]of this.instancesDeferred.entries()){a===this.normalizeInstanceIdentifier(e)&&t.resolve(r)}return r}onInit(e,t){var a;const r=this.normalizeInstanceIdentifier(t),n=null!==(a=this.onInitCallbacks.get(r))&&void 0!==a?a:new Set;n.add(e),this.onInitCallbacks.set(r,n);const i=this.instances.get(r);return i&&e(i,r),()=>{n.delete(e)}}invokeOnInitCallbacks(e,t){const a=this.onInitCallbacks.get(t);if(a)for(const r of a)try{r(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let a=this.instances.get(e);if(!a&&this.component&&(a=this.component.instanceFactory(this.container,{instanceIdentifier:(r=e,r===n?undefined:r),options:t}),this.instances.set(e,a),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(a,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,a)}catch(e){}var r;return a||null}normalizeInstanceIdentifier(e=n){return this.component?this.component.multipleInstances?e:n:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}a.Provider=i;a.ComponentContainer=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new i(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}}}},{package:"@metamask/notification-services-controller>firebase>@firebase/app>@firebase/component",file:"node_modules/@firebase/component/dist/esm/index.esm2017.js"}],[13,{"../../shared/constants/app":8503,"../../shared/constants/app-state":8502,"../../shared/constants/defi-referrals":8513,"../../shared/constants/errors":8514,"../../shared/constants/infura-project-id":8519,"../../shared/constants/messages":8524,"../../shared/constants/metametrics":8525,"../../shared/constants/offscreen-communication":8531,"../../shared/constants/onboarding":8532,"../../shared/constants/start-up-errors":8545,"../../shared/constants/ui-initialization":8553,"../../shared/lib/active-tab-domain-metrics":8570,"../../shared/lib/browser-runtime.utils":8587,"../../shared/lib/caip-stream":8590,"../../shared/lib/fetch-with-timeout":8643,"../../shared/lib/get-first-preferred-lang-code":8663,"../../shared/lib/install-attribution":8667,"../../shared/lib/manifestFlags":8669,"../../shared/lib/mv3.utils":8681,"../../shared/lib/object.utils":8684,"../../shared/lib/promise-with-resolvers":8694,"../../shared/lib/selectors/networks":8704,"../../shared/lib/sentry":8710,"../../shared/lib/stores/persistence-manager":8724,"./constants/background":14,"./constants/marketing-site-whitelist":15,"./constants/sentry-state":16,"./constants/snaps":17,"./constants/stream":18,"./controllers/analytics":22,"./first-time-state":66,"./lib/CronjobControllerStorageManager":70,"./lib/approval/utils":77,"./lib/critical-error/critical-error-recovery":92,"./lib/critical-error/critical-error-tab-handoff":93,"./lib/deep-links/deep-link-router":97,"./lib/deep-links/metrics":98,"./lib/defi-referrals/createDefiReferralMiddleware":99,"./lib/ens-ipfs/setup":107,"./lib/extension-lazy-listener/extension-lazy-listener":108,"./lib/getIframeProperties":110,"./lib/getObjStructure":111,"./lib/migrator":117,"./lib/notification-manager":120,"./lib/repair":134,"./lib/safe-reload":151,"./lib/setup-initial-state-hooks":155,"./lib/start-up-errors/start-up-errors":168,"./lib/state-corruption/state-corruption-recovery":169,"./lib/stream-utils":172,"./lib/update-remote-feature-flags":209,"./lib/use-split-state-storage":210,"./lib/util":211,"./metamask-controller":434,"./migrations":683,"./offscreen":684,"./on-update":685,"./platforms/extension":686,"@metamask/base-controller":1481,"@metamask/design-tokens":2155,"@metamask/utils":4031,"extension-port-stream":6591,loglevel:7192,"readable-stream":7671,"webextension-polyfill":8490},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,a){Object.defineProperty(a,"__esModule",{value:!0}),a.loadStateFromPersistence=it,a.setupController=ut;var r=e("./lib/setup-initial-state-hooks");e("../../shared/constants/infura-project-id");var n=e("@metamask/design-tokens"),i=e("readable-stream"),s=pe(e("loglevel")),o=pe(e("webextension-polyfill")),l=e("@metamask/utils"),c=e("@metamask/base-controller"),d=e("extension-port-stream"),u=e("../../shared/lib/promise-with-resolvers"),p=e("../../shared/constants/onboarding"),f=e("../../shared/constants/app"),h=e("../../shared/constants/app-state"),g=e("../../shared/constants/messages"),m=e("../../shared/constants/ui-initialization"),b=e("../../shared/constants/metametrics"),E=e("../../shared/lib/active-tab-domain-metrics"),v=e("../../shared/lib/browser-runtime.utils"),w=e("../../shared/lib/mv3.utils"),C=e("../../shared/lib/object.utils"),S=(e("../../shared/constants/offscreen-communication"),e("../../shared/lib/sentry")),M=e("../../shared/lib/selectors/networks"),y=e("../../shared/lib/caip-stream"),I=pe(e("../../shared/lib/fetch-with-timeout")),_=e("../../shared/constants/errors"),T=pe(e("../../shared/lib/get-first-preferred-lang-code")),A=(e("../../shared/lib/manifestFlags"),e("../../shared/constants/start-up-errors")),O=e("../../shared/constants/defi-referrals"),P=e("../../shared/lib/install-attribution"),N=e("../../shared/lib/stores/persistence-manager"),k=e("./lib/critical-error/critical-error-recovery"),R=e("./lib/state-corruption/state-corruption-recovery"),D=e("./lib/approval/utils"),L=e("./lib/use-split-state-storage"),U=pe(e("./migrations")),F=pe(e("./lib/migrator")),j=e("./lib/update-remote-feature-flags"),x=pe(e("./platforms/extension")),B=e("./constants/sentry-state"),V=ue(e("./lib/notification-manager")),z=ue(e("./metamask-controller")),K=e("./controllers/analytics"),$=pe(e("./lib/getObjStructure")),H=pe(e("./lib/ens-ipfs/setup")),Y=e("./lib/util"),G=e("./offscreen"),W=e("./lib/stream-utils"),q=pe(e("./first-time-state")),J=e("./on-update"),X=e("./constants/marketing-site-whitelist"),Z=e("./constants/stream"),Q=e("./constants/snaps"),ee=e("./lib/extension-lazy-listener/extension-lazy-listener"),te=e("./lib/deep-links/deep-link-router"),ae=e("./lib/deep-links/metrics"),re=e("./lib/safe-reload"),ne=e("./lib/critical-error/critical-error-tab-handoff"),ie=e("./lib/repair"),se=e("./lib/start-up-errors/start-up-errors"),oe=e("./lib/CronjobControllerStorageManager"),le=e("./lib/defi-referrals/createDefiReferralMiddleware"),ce=e("./lib/getIframeProperties"),de=e("./constants/background");function ue(e,t){if("function"==typeof WeakMap)var a=new WeakMap,r=new WeakMap;return(ue=function(e,t){if(!t&&e&&e.__esModule)return e;var n,i,s={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return s;if(n=t?r:a){if(n.has(e))return n.get(e);n.set(e,s)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(n=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?n(s,t,i):s[t]=e[t]);return s})(e,t)}function pe(e){return e&&e.__esModule?e:{default:e}}const fe=globalThis.stateHooks.lazyListener??new ee.ExtensionLazyListener(o.default),he="#0376C9",ge=n.lightTheme.colors.error.default,me=9,be=99,Ee=!1;const ve=null,{safePersist:we,requestSafeReload:Ce,evacuate:Se}=(0,re.getRequestSafeReload)(r.persistenceManager);global.stateHooks.getMostRecentPersistedState=()=>r.persistenceManager.mostRecentRetrievedState,global.stateHooks.getStorageKind=()=>r.persistenceManager.storageKind,global.logEncryptedVault=()=>{r.persistenceManager.logEncryptedVault()};const{sentry:Me}=global;let ye={...q.default};const Ie={[f.ENVIRONMENT_TYPE_POPUP]:!0,[f.ENVIRONMENT_TYPE_NOTIFICATION]:!0,[f.ENVIRONMENT_TYPE_FULLSCREEN]:!0};s.default.setLevel("info",!1);const _e=new x.default,Te=new V.default,Ae=(0,Y.getPlatform)()===f.PLATFORM_FIREFOX;function Oe(e){const t=e.name,a=e.sender?.url?new URL(e.sender.url):null;let r;return r=Ae?Boolean(Ie[t]):a?.origin===`chrome-extension://${o.default.runtime.id}`,{processName:t,senderUrl:a,isMetaMaskUIPort:r}}let Pe=0,Ne=!1,ke=!1,Re=0,De=0;const Le=new Set,Ue={},Fe={};let je;const xe={},Be={},Ve={};const ze=new URL("https://metamask.github.io/phishing-warning/v5.1.0/"),Ke=ze.toString();let $e,He,Ye;function Ge(){const e=(0,u.withResolvers)();$e=e.promise,He=e.resolve,Ye=e.reject}fe.once("runtime","onInstalled").then(e=>{!async function([e]){if("install"===e.reason)await async function(){s.default.debug("First install detected");const e=(0,P.getInstallAttribution)();_e.openExtensionInBrowser();await $e,await ft(e)}();else if("update"===e.reason){const{previousVersion:t}=e;if(!t||t===_e.getVersion())return;await $e,(0,J.onUpdate)(je,_e,t,Ce)}}(e)}),Ge(),o.default?.sidePanel?.setPanelBehavior&&o.default.sidePanel.setPanelBehavior({openPanelOnActionClick:!0}).catch(()=>{});let We,qe,Je,Xe;const Ze=new R.CorruptionHandler,Qe=new k.CriticalErrorHandler,et=async e=>{const{isMetaMaskUIPort:t}=Oe(e);try{e.postMessage({data:{method:m.BACKGROUND_LIVENESS_METHOD},name:"background-liveness"})}catch(e){return void s.default.error("MetaMask - background-liveness check: Failed to message to port",e)}let a;t&&(Qe.registerPortForCriticalError({port:e,repairCallback:()=>(0,ie.requestRepair)(()=>(0,ne.openRestoringTabAndReload)(Ce))}),a=()=>Qe.removeListenersForPort(e));try{if(await $e,t&&!(0,se.tryPostMessage)(e,m.BACKGROUND_INITIALIZED_METHOD))return;Ee,We(e,a)}catch(n){try{if(Me?.captureException(n),t)if((0,_.isStateCorruptionError)(n))await Ze.handleStateCorruptionError({port:e,error:n,database:r.persistenceManager,repairCallback:async e=>{Ge(),(0,N.hasVault)(e)?(await ht(e),je.onboardingController.setFirstTimeFlowType(p.FirstTimeFlowType.restore)):(await r.persistenceManager.reset(),await ht(null))}});else{const t=(0,l.isObject)(n)?{message:n.message??"Unknown error",name:n.name??"UnknownError",stack:n.stack,...n.sentryTags&&{sentryTags:n.sentryTags}}:{message:String(n),name:"UnknownError",stack:""};(0,se.tryPostMessage)(e,A.DISPLAY_GENERAL_STARTUP_ERROR,{error:t,currentLocale:je?.preferencesController?.state?.currentLocale})}}finally{a?.()}}},tt=()=>{fe.addListener("runtime","onConnect",et)};function at(){const e=(new Date).toISOString();o.default.storage.session.set({timestamp:e})}async function rt(e){(0,Y.initInstallType)();const t=w.isManifestV3?(0,G.createOffscreen)():null;let a=null,n=!1;w.isManifestV3&&(0,G.addOffscreenConnectivityListener)(e=>{if(n&&je.connectivityAdapter){const t=e?"online":"offline";je.connectivityAdapter.setStatus(t)}else a=e});const i=await it(e),s=i.data,l=await(0,T.default)();let c;if(w.isManifestV3){if(!1!==s.PreferencesController?.enableMV3TimestampSave){const e=2e3;at(),setInterval(at,e)}const e=await o.default.storage.session.get(["isFirstMetaMaskControllerSetup"]);c=e?.isFirstMetaMaskControllerSetup===undefined,await o.default.storage.session.set({isFirstMetaMaskControllerSetup:c})}const d=await async function(){const e=(0,I.default)(),t=Q.PREINSTALLED_SNAPS_URLS.map(async t=>{const a=await e(t);if(t.pathname.endsWith(".json.gz")){const e=new DecompressionStream("gzip"),t=a.body.pipeThrough(e);return await new Response(t).json()}return await a.json()});return Promise.all(t)}(),u=new oe.CronjobControllerStorageManager;if(await u.init(),ut(s,l,c,i.meta,t,d,u),je.metaMetricsController.updateTraits({[b.MetaMetricsUserTrait.StorageKind]:r.persistenceManager.storageKind}),function(e){async function t(e,t){try{const a=await o.default.tabs.get(e);return!(a.url&&a.url.startsWith("https://www.google.com/search")||(await o.default.tabs.update(e,{url:t}),0))}catch(e){return Me?.captureException(e),!1}}const a=!w.isManifestV3;o.default.webRequest.onBeforeRequest.addListener(r=>{if(r.tabId===o.default.tabs.TAB_ID_NONE)return{};const{completedOnboarding:n}=e.onboardingController.state;if(!n)return{};if(!e.preferencesController.state.usePhishDetect)return{};if(r.initiator&&"null"!==r.initiator&&new URL(r.initiator).host===ze.host)return{};const{hostname:i,href:s,searchParams:l}=new URL(r.url);e.phishingController.maybeUpdateState();const c=e.phishingController.isBlockedRequest(r.url);let d,u;if("main_frame"!==r.type&&"sub_frame"!==r.type||(d=e.phishingController.test(r.url)),!d?.result&&!c.result)return{};let p,f=s;d?.result&&c.result?u=`${d.type} and ${c.type}`:d?.result?u=d.type:(u=c.type,f=r.initiator);try{p=new URL(f).hostname}catch{p=i,f=s}const h=new URLSearchParams({hostname:p,href:f}),g=new URL(Ke);g.hash=h.toString();const m=g.toString(),E=()=>{Ae||(0,K.trackEvent)((0,K.createEventBuilder)(b.MetaMetricsEventName.PhishingPageDisplayed).addCategory(b.MetaMetricsEventCategory.Phishing).addProperties({url:f,referrer:{url:f},reason:u,requestDomain:c.result?i:undefined}).build({excludeMetaMetricsId:!0}))};return a?"main_frame"===r.type?(E(),{redirectUrl:m}):(t(r.tabId,m).then(e=>{e&&E()}),{cancel:!0}):(t(r.tabId,m).then(e=>{e&&E()}),{})},{urls:["http://*/*","https://*/*","ws://*/*","wss://*/*"]},a?["blocking"]:[])}(je),w.isManifestV3){if(n=!0,null!==a){const e=a?"online":"offline";je.connectivityAdapter.setStatus(e)}}else{const e=e=>{const t=e?"online":"offline";je.connectivityAdapter.setStatus(t)};e(globalThis.navigator.onLine),globalThis.addEventListener("online",()=>e(!0)),globalThis.addEventListener("offline",()=>e(!1))}w.isManifestV3||await async function(){let e;try{const t=new URL(Ke);let a,r;t.hash="#extensionStartup",e=window.document.createElement("iframe"),e.setAttribute("src",t.href),e.setAttribute("sandbox","allow-scripts allow-same-origin");const n=new Promise((e,t)=>{a=e,r=t});e.addEventListener("load",a),window.document.body.appendChild(e),setTimeout(()=>r(new nt),1e3),await n}catch(e){e instanceof nt?console.warn("Phishing warning page timeout; page not guaranteed to work offline."):console.error("Failed to initialize phishing warning page",e)}finally{e&&e.remove()}}(),await(async()=>{const e=await o.default.tabs.query({url:"<all_urls>",windowType:"normal"}).then(e=>((0,v.checkForLastErrorAndLog)(),e)).catch(()=>{(0,v.checkForLastErrorAndLog)()});for(const t of e)o.default.tabs.sendMessage(t.id,{name:g.EXTENSION_MESSAGES.READY}).then(()=>{(0,v.checkForLastErrorAndLog)()}).catch(()=>{(0,v.checkForLastErrorAndLog)()})})(),new te.DeepLinkRouter({getExtensionURL:_e.getExtensionURL,getState:je.getState.bind(je)}).on("navigate",async({url:e,parsed:t})=>{"redirectTo"in t||(0,K.trackEvent)((0,ae.createEvent)({signature:t.signature,url:e}))}).on("error",e=>Me?.captureException(e)).install()}tt(),o.default.runtime.onConnectExternal.addListener(async(...e)=>{await $e,qe(...e)});class nt extends Error{constructor(){super("Timeout failed")}}async function it(e){let t;if(e){t={data:{},meta:{}};for(const a of N.backedUpStateKeys)(0,l.hasProperty)(e,a)&&(t.data[a]=e[a]);(0,l.hasProperty)(e,"meta")&&(0,l.isObject)(e.meta)&&(t.meta=e.meta,"split"===e.meta.storageKind||"data"===e.meta.storageKind?r.persistenceManager.storageKind=e.meta.storageKind:r.persistenceManager.storageKind="data"),"number"!=typeof t.meta.version&&(s.default.error("The `backup`'s `meta.version` property was missing during backup restore."),t.meta.version=155)}else{const e=!0;t=await r.persistenceManager.get({validateVault:e})}const a=new F.default({migrations:U.default,defaultVersion:null});a.on("error",e=>{console.warn(e);const a=(0,$.default)(t);Me?.captureException(e,{extra:{vaultStructure:a}})});let n=!1;t?.data||t?.meta||(n=!0,t=a.generateInitialState(ye));const{state:i,changedKeys:o}=await a.migrateData(t),c=async a=>{const n=t?.meta?.version,s="number"==typeof n&&n>=157;let o=e?.AppMetadataController?.firstTimeInfo??i?.data?.AppMetadataController?.firstTimeInfo??i?.data?.firstTimeInfo??t?.data?.AppMetadataController?.firstTimeInfo??t?.data?.firstTimeInfo;if(!o)try{const e=await r.persistenceManager.getBackup();o=e?.AppMetadataController?.firstTimeInfo}catch{}const l=new Error(a);return l.sentryTags={"corruption.preMigrationVersion":String(n??"unknown"),"corruption.backupShouldExist":String(s),"corruption.installVersion":String(o?.version??"unknown"),"corruption.installDate":String(o?.date??"unknown")},l};if(!i)throw await c("MetaMask - migrator returned undefined");if(!(0,l.isObject)(i.meta))throw await c(`MetaMask - migrator metadata has invalid type '${typeof i.meta}'`);if("number"!=typeof i.meta.version)throw await c(`MetaMask - migrator metadata version has invalid type '${typeof i.meta.version}'`);if(!["data","split",undefined].includes(i.meta.storageKind))throw await c(`MetaMask - migrator metadata storageKind has invalid value '${i.meta.storageKind}'`);if(!(0,l.isObject)(i.data))throw await c(`MetaMask - migrator data has invalid type '${typeof i.data}'`);if(r.persistenceManager.setMetadata(i.meta),s.default.debug("[Split State]: Loaded data from persistence with storageKind '%s'",r.persistenceManager.storageKind),"data"===r.persistenceManager.storageKind){const e=!0===i.meta.platformSplitStateGradualRolloutAttempted,t=!e&&await(0,L.useSplitStateStorage)(i.data);s.default.debug("[Split State]: shouldUseSplitStateStorage: %s (alreadyTried: %s)",t,e),t&&(i.meta.platformSplitStateGradualRolloutAttempted=!0,r.persistenceManager.setMetadata(i.meta)),s.default.debug("[Split State]: Writing data to persistence with storageKind 'data'"),await r.persistenceManager.set(i.data),t&&(await r.persistenceManager.migrateToSplitState(i.data),i.meta=r.persistenceManager.getMetaData(),i.meta!==undefined&&(delete i.meta.platformSplitStateGradualRolloutAttempted,r.persistenceManager.setMetadata(i.meta)),await r.persistenceManager.persist())}else{if("split"!==r.persistenceManager.storageKind)throw new Error(`MetaMask - persistenceManager has invalid storageKind '${r.persistenceManager.storageKind}'`);if(n)for(const[e,t]of Object.entries(i.data))r.persistenceManager.update(e,t);else for(const e of o)r.persistenceManager.update(e,i.data[e]);await r.persistenceManager.persist()}return s.default.debug("[Split State]: Load complete."),i}function st(e,t,a){const{analyticsId:r}=je.getState();if(!(0,Y.shouldEmitDappViewedEvent)(r))return;const n=je.getPermittedAccounts(e).length;if(0===n)return;const i=je.controllerMessenger.call("AccountsController:getState"),s=Object.keys(i.internalAccounts.accounts).length,o=(0,ce.getIframeProperties)({frameId:a,origin:e,mainFrameOrigin:t});(0,K.trackEvent)((0,K.createEventBuilder)(b.MetaMetricsEventName.DappViewed).addCategory(b.MetaMetricsEventCategory.InpageProvider).addProperties({is_first_visit:!1,number_of_accounts:s,number_of_accounts_connected:n,...o}).build({referrer:{url:e},excludeMetaMetricsId:!0}))}function ot(e){if(!e.sender?.tab||!e.sender?.url||!e.sender?.tab?.url)return;const t=e.sender.tab.id,a=new URL(e.sender.url),{origin:r}=a,n=new URL(e.sender.tab.url),{origin:i}=n,{frameId:s}=e.sender;Object.keys(xe).includes(t)||(xe[t]=r),t in Be||(Be[t]=i),t in Ve||(Ve[t]=s);const o=je.controllerMessenger.call("PermissionController:hasPermissions",r),l="New Tab"!==e.sender.tab.title;o&&l&&st(r,i,s)}function lt(e){const{completedMetaMetricsOnboarding:t,optedIn:a}=je.getState();if(!t||!a)return;const r=je.appStateController.state.appActiveTab?.origin,n=(0,E.getActiveTabDomainAllowlist)(je.remoteFeatureFlagController.state),i=(0,E.getActiveTabDomainForMetrics)(r,n);(0,K.trackEvent)((0,K.createEventBuilder)(b.MetaMetricsEventName.AppOpened).addCategory(b.MetaMetricsEventCategory.App).addProperties(i?{active_tab_domain:i}:{}).build({environmentType:e}))}function ct(e){const t=[f.ENVIRONMENT_TYPE_POPUP,f.ENVIRONMENT_TYPE_NOTIFICATION,f.ENVIRONMENT_TYPE_FULLSCREEN,f.ENVIRONMENT_TYPE_SIDEPANEL];return!(Object.values(Ue).some(Boolean)||Ne||Pe>0||Re>0)&&t.includes(e)}const dt=async e=>{if(await $e,je)try{const t=e?{active:!0,windowId:e}:{active:!0,currentWindow:!0},a=await o.default.tabs.query(t);if(!a||0===a.length)return;const r=a[0],{id:n,title:i,url:s,favIconUrl:l}=r;if(!s)return void je.appStateController.clearAppActiveTab();const{origin:c,protocol:d,host:u,href:p}=new URL(s);if(!(0,Y.isWebOrigin)(c))return void je.appStateController.clearAppActiveTab();je.appStateController.setAppActiveTab({id:n,title:i,origin:c,protocol:d,url:s,host:u,href:p,favIconUrl:l}),je.subjectMetadataController.addSubjectMetadata({origin:c,name:i||u||c,iconUrl:l||null,subjectType:"website"})}catch(e){console.log("Error refreshing appActiveTab:",e.message)}};function ut(e,t,a,n,l,u,p){je=new z.default({infuraProjectId:globalThis.INFURA_PROJECT_ID,showUserConfirmation:pt,initState:e,initLangCode:t,platform:_e,notificationManager:Te,browser:o.default,getRequestAccountTabIds:()=>Fe,getOpenMetamaskTabsIds:()=>Ue,isFirstMetaMaskControllerSetup:a,currentMigrationVersion:n.version,featureFlags:{},offscreenPromise:l,preinstalledSnaps:u,requestSafeReload:Ce,cronjobControllerStorageManager:p}),r.persistenceManager.setOnSetFailed(e=>{je.appStateController.setStorageWriteErrorType(e)});const g=[],m=je.store.getState();for(const t of Object.keys(m)){const a=e[t]||{},r=m[t];if(null===r||"object"!=typeof r){(0,S.captureException)(new Error(`Invalid controller state for '${t}' of type '${null===r?"null":typeof r}'`));continue}const n=Object.keys(r);if(n.length===Object.keys(a).length){for(const e of n)if(r[e]!==a[e]){g.push(t);break}}else g.push(t)}var E;"split"===r.persistenceManager.storageKind?(g.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${g.join(", ")}. Persisting updated state.`),g.forEach(e=>{r.persistenceManager.update(e,m[e])}),we().catch(e=>{s.default.error("Error persisting updated state:",e),Me?.captureException(e)})),je.store.on("stateChange",async({controllerKey:e,newState:t,_oldState:a,_patches:n})=>{r.persistenceManager.update(e,t),N.backedUpStateKeys.includes(e)&&N.backedUpStateKeys.forEach(t=>{if(t===e)return;const a=je.store.config[t];if(!a?.metadata)throw new Error(`Cannot backup ${t}: controller metadata is required but not found. All controllers in backedUpStateKeys must extend BaseController and define metadata.`);const n=je.controllerMessenger.call(`${t}:getState`),i=(0,c.deriveStateFromMetadata)(n,a.metadata,"persist");r.persistenceManager.update(t,i)});try{await we()}catch(e){s.default.error("Error persisting state change:",e),Me?.captureException(e)}})):(g.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${g.join(", ")}. Persisting updated state.`),we(m).catch(e=>{s.default.error("Error persisting updated controller state:",e),Me?.captureException(e)})),je.store.on("update",we)),je.store.on("error",e=>{s.default.error("MetaMask controller.store error:",e),Me?.captureException(e)}),(0,H.default)({getCurrentChainId:()=>(0,M.getCurrentChainId)({metamask:je.networkController.state}),getIpfsGateway:je.preferencesController.getIpfsGateway.bind(je.preferencesController),getUseAddressBarEnsResolution:()=>je.preferencesController.state.useAddressBarEnsResolution,provider:je.provider}),E=je,global.stateHooks.getSentryAppState=function(){const e=E.memStore.getState();return(0,C.maskObject)(e,B.SENTRY_BACKGROUND_STATE)};const v=()=>Pe>0||Boolean(Object.keys(Ue).length)||Ne||Re>0||!1,I=()=>Pe>0||Re>0,_=()=>Ne&&!I(),T=(e,t)=>{if(!1===e)je.onClientClosed();else{if(t===f.ENVIRONMENT_TYPE_FULLSCREEN&&Boolean(Object.keys(Ue).length)||t===f.ENVIRONMENT_TYPE_SIDEPANEL&&Re>0)return;je.onEnvironmentTypeClosed(t)}};function A(e){try{je.appStateController.setDefaultHomeActiveTabName(e??null)}catch(e){console.error("Error setting landing tab:",e)}}function O(){Le.clear(),De=0,k()}function P(e,t){return e>t?`${t}+`:String(e)}function k(){const e=R();let t="",a=he;De>0&&!_()?(t=P(De,me),a=ge):e>0&&(t=P(e,me));try{const e={text:t},r={color:a};w.isManifestV3?(o.default.action.setBadgeText(e),o.default.action.setBadgeBackgroundColor(r)):(o.default.browserAction.setBadgeText(e),o.default.browserAction.setBadgeBackgroundColor(r))}catch(e){console.error("Error updating browser badge:",e)}}function R(){try{return(0,D.getAttentionRequiredApprovalCount)({approvalController:je.approvalController})}catch(e){return console.error("Failed to get pending approval count:",e),0}}We=(e,t)=>{if(de.BLOCKED_PORTS.includes(e.name))return;const{processName:a,senderUrl:r,isMetaMaskUIPort:n}=Oe(e);if(n){const r=new d.ExtensionPortStream(e),n=function({chunkSize:e}){(0,K.trackEvent)((0,K.createEventBuilder)(b.MetaMetricsEventName.PortStreamChunked).addCategory(b.MetaMetricsEventCategory.PortStream).addProperties({chunkSize:e}).build())};e.onDisconnect.addListener(()=>r.off("message-too-large",n)),r.on("message-too-large",n),je.isClientOpen=!0,je.setupTrustedCommunication(r,e.sender).finally(()=>{t?.()});const o=a===f.ENVIRONMENT_TYPE_SIDEPANEL&&ct(f.ENVIRONMENT_TYPE_SIDEPANEL);if(a!==f.ENVIRONMENT_TYPE_SIDEPANEL&&ct(s=a)&&lt(s),(0,j.updateRemoteFeatureFlags)(je),a===f.ENVIRONMENT_TYPE_POPUP&&(O(),Pe+=1,(0,i.finished)(r,()=>{Pe-=1;const e=v();je.isClientOpen=e,T(e,f.ENVIRONMENT_TYPE_POPUP)})),a===f.ENVIRONMENT_TYPE_SIDEPANEL&&(O(),Re+=1,dt().then(()=>{o&&lt(f.ENVIRONMENT_TYPE_SIDEPANEL)}),(0,i.finished)(r,()=>{Re=Math.max(Re-1,0);const e=v();je.isClientOpen=e,T(e,f.ENVIRONMENT_TYPE_SIDEPANEL)})),a===f.ENVIRONMENT_TYPE_NOTIFICATION&&(Ne=!0,(0,i.finished)(r,()=>{Ne=!1,De>0&&A(h.AccountOverviewTabKey.Activity),k();const e=v();je.isClientOpen=e,T(e,f.ENVIRONMENT_TYPE_NOTIFICATION)})),a===f.ENVIRONMENT_TYPE_FULLSCREEN){O();const t=e.sender.tab.id;Ue[t]=!0,(0,i.finished)(r,()=>{delete Ue[t];const e=v();je.isClientOpen=e,T(e,f.ENVIRONMENT_TYPE_FULLSCREEN)})}}else if(r&&r.origin===ze.origin&&r.pathname===ze.pathname){const t=new d.ExtensionPortStream(e,{chunkSize:0});je.setupPhishingCommunication({connectionStream:t})}else{if(e.sender&&e.sender.tab&&e.sender.url){const t=e.sender.tab.id,a=new URL(e.sender.url),{origin:r}=a;ot(e),e.onMessage.addListener(e=>{e.data&&e.data.method===f.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS&&(Fe[r]=t)})}if(r&&X.COOKIE_ID_MARKETING_WHITELIST_ORIGINS.some(e=>e===r.origin)){const t=new d.ExtensionPortStream(e,{chunkSize:0});je.setUpCookieHandlerCommunication({connectionStream:t})}const t=new d.ExtensionPortStream(e,{chunkSize:0});if(Je(t,e.sender),Ae||!w.isManifestV3){const a=(0,W.setupMultiplex)(t);a.ignoreStream(Z.METAMASK_EIP_1193_PROVIDER),Xe(a.createStream(Z.METAMASK_CAIP_MULTICHAIN_PROVIDER),e.sender)}}var s},qe=e=>{const t=e.sender?.url;if(t){const{hostname:a}=new URL(t);if(de.BLOCKED_HOSTNAMES.includes(a))return void e.disconnect()}const a=new d.ExtensionPortStream(e,{chunkSize:0});if(!e.sender.id){if(de.BLOCKED_PORTS.includes(e.name))return;ot(e),Xe((0,y.createCaipStream)(a),e.sender)}else Je(a,e.sender)},Je=(e,t)=>{je.setupUntrustedCommunicationEip1193({connectionStream:e,sender:t})},Xe=(e,t)=>{je.setupUntrustedCommunicationCaip({connectionStream:e,sender:t})},k(),je.controllerMessenger.subscribe(z.METAMASK_CONTROLLER_EVENTS.DECRYPT_MESSAGE_MANAGER_UPDATE_BADGE,k),je.controllerMessenger.subscribe(z.METAMASK_CONTROLLER_EVENTS.ENCRYPTION_PUBLIC_KEY_MANAGER_UPDATE_BADGE,k),je.signatureController.hub.on(z.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,k),je.controllerMessenger.subscribe(z.METAMASK_CONTROLLER_EVENTS.APP_STATE_UNLOCK_CHANGE,k),je.controllerMessenger.subscribe(z.METAMASK_CONTROLLER_EVENTS.APPROVAL_STATE_CHANGE,k),je.controllerMessenger.subscribe(z.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_LIST_UPDATED,k),je.controllerMessenger.subscribe(z.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_MARK_AS_READ,k),je.controllerMessenger.subscribe("TransactionController:transactionStatusUpdated",function({transactionMeta:e}){const{status:t,txParams:a,chainId:r}=e??{};if("failed"!==t&&"dropped"!==t)return;const{from:n,nonce:i}=a??{},s=n&&i!==undefined&&r?`${r}:${n.toLowerCase()}:${i}`:undefined;if(s&&Le.has(s))return;if(I())return;s&&(Le.size>=be&&Le.clear(),Le.add(s));De+=1,_()||A(h.AccountOverviewTabKey.Activity);k()}),Te.on(V.NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,({automaticallyClosed:e})=>{e?R()>0&&pt():(je.signatureController.rejectUnapproved(b.REJECT_NOTIFICATION_CLOSE_SIG),je.decryptMessageController.rejectUnapproved(b.REJECT_NOTIFICATION_CLOSE),je.encryptionPublicKeyController.rejectUnapproved(b.REJECT_NOTIFICATION_CLOSE),je.legacyBackgroundApiService.rejectAllPendingApprovals()),k()})}async function pt(){const e=await _e.getActiveTabs(),t=Boolean(e.find(e=>Ue[e.id])),a=e.length>0&&e[0].extData&&e[0].extData.indexOf("vivaldi_tab")>-1;if(!ke&&(a||0===Pe)&&!t&&0===Re){ke=!0;try{const e=je.appStateController.getCurrentPopupId();await Te.showPopup(e=>je.appStateController.setCurrentPopupId(e),e)}finally{ke=!1}}}const ft=async e=>{const{deferredDeepLink:t,traits:a}=await e;je.metaMetricsController.updateTraits({[b.MetaMetricsUserTrait.InstallDateExt]:(new Date).toISOString().split("T")[0],...a});const r={};t&&(je.appStateController.setDeferredDeepLink(t),r.install_source="deeplink",r.deeplink_path=t.referringLink);const n={category:b.MetaMetricsEventCategory.App,event:b.MetaMetricsEventName.AppInstalled,properties:r},{completedMetaMetricsOnboarding:i,optedIn:s,analyticsId:o}=je.getState();!0===i&&!1===s||(!0===i&&!0===s&&o?(0,K.trackEvent)((0,K.createEventBuilder)(b.MetaMetricsEventName.AppInstalled).addCategory(b.MetaMetricsEventCategory.App).addProperties(r).build()):je.metaMetricsController.addEventBeforeMetricsOptIn(n))};o.default.runtime.onUpdateAvailable.addListener(async function(e){await $e,s.default.info("An update is available",e?.version),je.appStateController.setPendingExtensionVersion(e?.version??null)});(async()=>{if(o.default?.sidePanel)try{await $e,await async function(){if(!o.default?.sidePanel?.setPanelBehavior)return;const e=je?.preferencesController?.state?.preferences?.useSidePanelAsDefault??!0;await o.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e})}(),je?.controllerMessenger?.subscribe("PreferencesController:stateChange",e=>{o.default?.sidePanel?.setPanelBehavior&&o.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e}).catch(e=>console.error("Error updating panel behavior:",e))},e=>e?.preferences?.useSidePanelAsDefault??!0)}catch(e){console.error("Error setting side panel toolbar behavior:",e)}})();async function ht(e){o.default.tabs.onActivated.addListener(e=>{if(je){const{tabId:t}=e,a=xe[t],r=Be[t];a&&je.permissionController.state.subjects[a]!==undefined&&st(a,r,Ve[t]);const n=(0,O.getPartnerByOrigin)(r);n&&je.permissionController.state.subjects[r]!==undefined&&je.handleDefiReferral(n,t,le.ReferralTriggerType.OnNavigateConnectedTab).catch(e=>{s.default.error(`Failed to handle ${n.name} referral after navigation to connected tab: `,e)})}});try{await rt(e),r.persistenceManager.cleanUpMostRecentRetrievedState(),s.default.info("MetaMask initialization complete."),He()}catch(e){s.default.error(e),Ye(e)}}(async()=>{await dt()})(),o.default.tabs.onActivated.addListener(async({tabId:e})=>{if(await $e,!je)return{};try{const t=await o.default.tabs.get(e),{id:a,title:r,url:n,favIconUrl:i}=t;if(!n)return je.appStateController.clearAppActiveTab(),{};const{origin:s,protocol:l,host:c,href:d}=new URL(n);if(!(0,Y.isWebOrigin)(s))return je.appStateController.clearAppActiveTab(),{};je.appStateController.setAppActiveTab({id:a,title:r,origin:s,protocol:l,url:n,host:c,href:d,favIconUrl:i}),je.subjectMetadataController.addSubjectMetadata({origin:s,name:r||c||s,iconUrl:i||null,subjectType:"website"})}catch(e){console.log("Error in tabs.onActivated listener:",e.message)}return{}}),o.default.tabs.onUpdated.addListener(async(e,t,a)=>{if(await $e,!je)return{};const r=t.url!==undefined,n="complete"===t.status;if(!r&&!n)return{};try{const t=a||await o.default.tabs.get(e),{id:i,title:s,url:l,favIconUrl:c}=t,d=je.appStateController.state.appActiveTab,u=d?.id===i;if(!l)return u&&je.appStateController.clearAppActiveTab(),{};const{origin:p,protocol:f,host:h,href:g}=new URL(l);if(!p||"null"===p||p.startsWith("chrome-extension://")||p.startsWith("moz-extension://"))return u&&je.appStateController.clearAppActiveTab(),{};let m=!1;try{m=(await o.default.tabs.query({active:!0,currentWindow:!0})).some(e=>e.id===i)}catch(e){m=u}(r||n)&&m&&(je.appStateController.setAppActiveTab({id:i,title:s,origin:p,protocol:f,url:l,host:h,href:g,favIconUrl:c}),je.subjectMetadataController.addSubjectMetadata({origin:p,name:s||h||p,iconUrl:c||null,subjectType:"website"}))}catch(e){console.log("Error in tabs.onUpdated listener:",e.message)}return{}}),o.default.windows.onFocusChanged.addListener(async e=>{e!==o.default.windows.WINDOW_ID_NONE&&await dt(e)}),async function(){const e=await(0,ne.readCriticalErrorRestoreSession)(o.default),t=undefined;let a=null;(e||t?.simulateBackgroundStateSyncHang||t?.simulateBackgroundInitializationHang)&&(a=await r.persistenceManager.getBackup().catch(()=>null));const n=(0,N.hasVault)(a);if((t?.simulateBackgroundStateSyncHang||t?.simulateBackgroundInitializationHang)&&ve&&(ve.hasVaultAtStartup=n?Date.now():null),e&&(await(0,ne.clearCriticalErrorRestoreSession)(o.default),n)){ve&&(ve.restoreInProgress=!0);const t={tabId:e.tabId,tabUrl:e.tabUrl};ht(a);try{await $e}catch(e){return void s.default.error("critical-error-restore: initialization failed",e)}return je.onboardingController.setFirstTimeFlowType(p.FirstTimeFlowType.restore),void await(0,ne.handoffRestoringTabToExtension)(_e,t)}ht(null)}().catch(e=>{s.default.error("initOrRestoreBackground failed",e)})}}},{package:"$root$",file:"app/scripts/background.js"}]],[13],{});