LavaPack.loadBundle([[907,{_process:5737},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){(function(e){(function(){Object.defineProperty(r,"__esModule",{value:!0}),r.Sha1=r.RANDOM_FACTOR=r.MAX_VALUE_MILLIS=r.FirebaseError=r.ErrorFactory=r.Deferred=r.DecodeBase64StringError=r.CONSTANTS=void 0,r.areCookiesEnabled=function(){if("undefined"==typeof navigator||!navigator.cookieEnabled)return!1;return!0}
/**
 * @license
 * Copyright 2017 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.
 */,r.assertionError=r.assert=void 0,r.async=function(e,t){return(...r)=>{Promise.resolve(!0).then(()=>{e(...r)}).catch(e=>{t&&t(e)})}},r.base64urlEncodeWithoutPadding=r.base64Encode=r.base64Decode=r.base64=void 0,r.calculateBackoffMillis=function(e,t=A,r=P){const n=t*Math.pow(r,e),o=Math.round(I*n*(Math.random()-.5)*2);return Math.min(N,n+o)}
/**
 * @license
 * Copyright 2020 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.
 */,r.contains=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.createMockUserToken=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const r=t||"demo-project",n=e.iat||0,o=e.sub||e.user_id;if(!o)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const i=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:n,exp:n+3600,auth_time:n,sub:o,user_id:o,firebase:{sign_in_provider:"custom",identities:{}}},e);return[c(JSON.stringify({alg:"none",type:"JWT"})),c(JSON.stringify(i)),""].join(".")}
/**
 * @license
 * Copyright 2017 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.
 */,r.createSubscribe=function(e,t){const r=new T(e,t);return r.subscribe.bind(r)},r.decode=void 0,r.deepCopy=function(e){return d(undefined,e)},r.deepEqual=function e(t,r){if(t===r)return!0;const n=Object.keys(t),o=Object.keys(r);for(const i of n){if(!o.includes(i))return!1;const n=t[i],s=r[i];if(C(n)&&C(s)){if(!e(n,s))return!1}else if(n!==s)return!1}for(const e of o)if(!n.includes(e))return!1;return!0},r.deepExtend=d,r.errorPrefix=k,r.extractQuerystring=function(e){const t=e.indexOf("?");if(!t)return"";const r=e.indexOf("#",t);return e.substring(t,r>0?r:undefined)}
/**
 * @license
 * Copyright 2017 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.
 */,r.getExperimentalSetting=r.getDefaults=r.getDefaultEmulatorHostnameAndPort=r.getDefaultEmulatorHost=r.getDefaultAppConfig=void 0,r.getGlobal=p,r.getModularInstance=
/**
 * @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.
 */
function(e){return e&&e._delegate?e._delegate:e},r.getUA=b,r.isAdmin=void 0,r.isBrowser=function(){return"undefined"!=typeof window||y()},r.isBrowserExtension=function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:undefined;return"object"==typeof e&&e.id!==undefined},r.isCloudflareWorker=function(){return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent},r.isElectron=function(){return b().indexOf("Electron/")>=0},r.isEmpty=function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},r.isIE=function(){const e=b();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0},r.isIndexedDBAvailable=function(){try{return"object"==typeof indexedDB}catch(e){return!1}},r.isMobileCordova=function(){return"undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(b())},r.isNode=v,r.isNodeSdk=function(){return!0===t.NODE_CLIENT||!0===t.NODE_ADMIN},r.isReactNative=function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},r.isSafari=function(){return!v()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")},r.isUWP=function(){return b().indexOf("MSAppHost/")>=0},r.isValidTimestamp=r.isValidFormat=void 0,r.isWebWorker=y,r.issuedAtTime=void 0,r.jsonEval=_,r.map=function(e,t,r){const n={};for(const o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=t.call(r,e[o],o,e));return n},r.ordinal=function(e){if(!Number.isFinite(e))return`${e}`;return e+function(e){e=Math.abs(e);const t=e%100;if(t>=10&&t<=20)return"th";const r=e%10;if(1===r)return"st";if(2===r)return"nd";if(3===r)return"rd";return"th"}(e)},r.promiseWithTimeout=
/**
 * @license
 * Copyright 2022 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.
 */
function(e,t=2e3){const r=new g;return setTimeout(()=>r.reject("timeout!"),t),e.then(r.resolve,r.reject),r.promise}
/**
 * @license
 * Copyright 2017 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.
 */,r.querystring=function(e){const t=[];for(const[r,n]of Object.entries(e))Array.isArray(n)?n.forEach(e=>{t.push(encodeURIComponent(r)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(r)+"="+encodeURIComponent(n));return t.length?"&"+t.join("&"):""},r.querystringDecode=function(e){const t={},r=e.replace(/^\?/,"").split("&");return r.forEach(e=>{if(e){const[r,n]=e.split("=");t[decodeURIComponent(r)]=decodeURIComponent(n)}}),t},r.safeGet=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:undefined},r.stringToByteArray=r.stringLength=void 0,r.stringify=function(e){return JSON.stringify(e)}
/**
 * @license
 * Copyright 2017 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.
 */,r.validateArgCount=void 0,r.validateCallback=function(e,t,r,n){if(n&&!r)return;if("function"!=typeof r)throw new Error(k(e,t)+"must be a valid function.")},r.validateContextObject=function(e,t,r,n){if(n&&!r)return;if("object"!=typeof r||null===r)throw new Error(k(e,t)+"must be a valid context object.")}
/**
 * @license
 * Copyright 2017 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.
 */,r.validateIndexedDBOpenable=function(){return new Promise((e,t)=>{try{let r=!0;const n="validate-browser-context-for-indexeddb-analytics-module",o=self.indexedDB.open(n);o.onsuccess=()=>{o.result.close(),r||self.indexedDB.deleteDatabase(n),e(!0)},o.onupgradeneeded=()=>{r=!1},o.onerror=()=>{var e;t((null===(e=o.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}})},r.validateNamespace=function(e,t,r){if(r&&!t)return;if("string"!=typeof t)throw new Error(k(e,"namespace")+"must be a valid firebase namespace.")};
/**
 * @license
 * Copyright 2017 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.
 */
const t=r.CONSTANTS={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},n=function(e,t){if(!e)throw o(t)};
/**
 * @license
 * Copyright 2017 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.
 */r.assert=n;const o=function(e){return new Error("Firebase Database ("+t.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)};
/**
 * @license
 * Copyright 2017 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.
 */r.assertionError=o;const i=function(e){const t=[];let r=0;for(let n=0;n<e.length;n++){let o=e.charCodeAt(n);o<128?t[r++]=o:o<2048?(t[r++]=o>>6|192,t[r++]=63&o|128):55296==(64512&o)&&n+1<e.length&&56320==(64512&e.charCodeAt(n+1))?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++n)),t[r++]=o>>18|240,t[r++]=o>>12&63|128,t[r++]=o>>6&63|128,t[r++]=63&o|128):(t[r++]=o>>12|224,t[r++]=o>>6&63|128,t[r++]=63&o|128)}return t},s=r.base64={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const r=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let t=0;t<e.length;t+=3){const o=e[t],i=t+1<e.length,s=i?e[t+1]:0,a=t+2<e.length,l=a?e[t+2]:0,c=o>>2,u=(3&o)<<4|s>>4;let d=(15&s)<<2|l>>6,f=63&l;a||(f=64,i||(d=64)),n.push(r[c],r[u],r[d],r[f])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(i(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let r=0,n=0;for(;r<e.length;){const o=e[r++];if(o<128)t[n++]=String.fromCharCode(o);else if(o>191&&o<224){const i=e[r++];t[n++]=String.fromCharCode((31&o)<<6|63&i)}else if(o>239&&o<365){const i=((7&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536;t[n++]=String.fromCharCode(55296+(i>>10)),t[n++]=String.fromCharCode(56320+(1023&i))}else{const i=e[r++],s=e[r++];t[n++]=String.fromCharCode((15&o)<<12|(63&i)<<6|63&s)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const r=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let t=0;t<e.length;){const o=r[e.charAt(t++)],i=t<e.length?r[e.charAt(t)]:0;++t;const s=t<e.length?r[e.charAt(t)]:64;++t;const l=t<e.length?r[e.charAt(t)]:64;if(++t,null==o||null==i||null==s||null==l)throw new a;const c=o<<2|i>>4;if(n.push(c),64!==s){const e=i<<4&240|s>>2;if(n.push(e),64!==l){const e=s<<6&192|l;n.push(e)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class a extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}r.DecodeBase64StringError=a;const l=function(e){const t=i(e);return s.encodeByteArray(t,!0)};r.base64Encode=l;const c=function(e){return l(e).replace(/\./g,"")};r.base64urlEncodeWithoutPadding=c;const u=function(e){try{return s.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};
/**
 * @license
 * Copyright 2017 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.
 */function d(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:e===undefined&&(e={});break;case Array:e=[];break;default:return t}for(const r in t)t.hasOwnProperty(r)&&f(r)&&(e[r]=d(e[r],t[r]));return e}function f(e){return"__proto__"!==e}
/**
 * @license
 * Copyright 2022 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.
 */function p(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}
/**
 * @license
 * Copyright 2022 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.
 */r.base64Decode=u;const h=()=>{try{return p().__FIREBASE_DEFAULTS__||(()=>{if(void 0===e||void 0===e.env)return})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&u(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}};r.getDefaults=h;const m=e=>{var t,r;return null===(r=null===(t=h())||void 0===t?void 0:t.emulatorHosts)||void 0===r?void 0:r[e]};r.getDefaultEmulatorHost=m;r.getDefaultEmulatorHostnameAndPort=e=>{const t=m(e);if(!t)return undefined;const r=t.lastIndexOf(":");if(r<=0||r+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const n=parseInt(t.substring(r+1),10);return"["===t[0]?[t.substring(1,r-1),n]:[t.substring(0,r),n]};r.getDefaultAppConfig=()=>{var e;return null===(e=h())||void 0===e?void 0:e.config};
/**
 * @license
 * Copyright 2017 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.
 */
r.getExperimentalSetting=e=>{var t;return null===(t=h())||void 0===t?void 0:t[`_${e}`]};class g{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,r))}}}
/**
 * @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.
 */function b(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function v(){var e;const t=null===(e=h())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}function y(){return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope}r.Deferred=g;class E extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,E.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,S.prototype.create)}}r.FirebaseError=E;class S{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},n=`${this.service}/${e}`,o=this.errors[e],i=o?function(e,t){return e.replace(w,(e,r)=>{const n=t[r];return null!=n?String(n):`<${r}?>`})}(o,r):"Error",s=`${this.serviceName}: ${i} (${n}).`;return new E(n,s,r)}}r.ErrorFactory=S;const w=/\{\$([^}]+)}/g;
/**
 * @license
 * Copyright 2017 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.
 */function _(e){return JSON.parse(e)}const M=function(e){let t={},r={},n={},o="";try{const i=e.split(".");t=_(u(i[0])||""),r=_(u(i[1])||""),o=i[2],n=r.d||{},delete r.d}catch(e){}return{header:t,claims:r,data:n,signature:o}};r.decode=M;r.isValidTimestamp=function(e){const t=M(e).claims,r=Math.floor((new Date).getTime()/1e3);let n=0,o=0;return"object"==typeof t&&(t.hasOwnProperty("nbf")?n=t.nbf:t.hasOwnProperty("iat")&&(n=t.iat),o=t.hasOwnProperty("exp")?t.exp:n+86400),!!r&&!!n&&!!o&&r>=n&&r<=o};r.issuedAtTime=function(e){const t=M(e).claims;return"object"==typeof t&&t.hasOwnProperty("iat")?t.iat:null};r.isValidFormat=function(e){const t=M(e).claims;return!!t&&"object"==typeof t&&t.hasOwnProperty("iat")};function C(e){return null!==e&&"object"==typeof e}
/**
 * @license
 * Copyright 2017 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.
 */
r.isAdmin=function(e){const t=M(e).claims;return"object"==typeof t&&!0===t.admin};r.Sha1=class{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e<this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const r=this.W_;if("string"==typeof e)for(let n=0;n<16;n++)r[n]=e.charCodeAt(t)<<24|e.charCodeAt(t+1)<<16|e.charCodeAt(t+2)<<8|e.charCodeAt(t+3),t+=4;else for(let n=0;n<16;n++)r[n]=e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3],t+=4;for(let e=16;e<80;e++){const t=r[e-3]^r[e-8]^r[e-14]^r[e-16];r[e]=4294967295&(t<<1|t>>>31)}let n,o,i=this.chain_[0],s=this.chain_[1],a=this.chain_[2],l=this.chain_[3],c=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(n=l^s&(a^l),o=1518500249):(n=s^a^l,o=1859775393):e<60?(n=s&a|l&(s|a),o=2400959708):(n=s^a^l,o=3395469782);const t=(i<<5|i>>>27)+n+c+o+r[e]&4294967295;c=l,l=a,a=4294967295&(s<<30|s>>>2),s=i,i=t}this.chain_[0]=this.chain_[0]+i&4294967295,this.chain_[1]=this.chain_[1]+s&4294967295,this.chain_[2]=this.chain_[2]+a&4294967295,this.chain_[3]=this.chain_[3]+l&4294967295,this.chain_[4]=this.chain_[4]+c&4294967295}update(e,t){if(null==e)return;t===undefined&&(t=e.length);const r=t-this.blockSize;let n=0;const o=this.buf_;let i=this.inbuf_;for(;n<t;){if(0===i)for(;n<=r;)this.compress_(e,n),n+=this.blockSize;if("string"==typeof e){for(;n<t;)if(o[i]=e.charCodeAt(n),++i,++n,i===this.blockSize){this.compress_(o),i=0;break}}else for(;n<t;)if(o[i]=e[n],++i,++n,i===this.blockSize){this.compress_(o),i=0;break}}this.inbuf_=i,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_<56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e>=56;e--)this.buf_[e]=255&t,t/=256;this.compress_(this.buf_);let r=0;for(let t=0;t<5;t++)for(let n=24;n>=0;n-=8)e[r]=this.chain_[t]>>n&255,++r;return e}};class T{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let n;if(e===undefined&&t===undefined&&r===undefined)throw new Error("Missing Observer.");n=function(e,t){if("object"!=typeof e||null===e)return!1;for(const r of t)if(r in e&&"function"==typeof e[r])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:r},n.next===undefined&&(n.next=O),n.error===undefined&&(n.error=O),n.complete===undefined&&(n.complete=O);const o=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?n.error(this.finalError):n.complete()}catch(e){}}),this.observers.push(n),o}unsubscribeOne(e){this.observers!==undefined&&this.observers[e]!==undefined&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&this.onNoObservers!==undefined&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==undefined&&this.observers[e]!==undefined)try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,e!==undefined&&(this.finalError=e),this.task.then(()=>{this.observers=undefined,this.onNoObservers=undefined}))}}function O(){}
/**
 * @license
 * Copyright 2017 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.
 */function k(e,t){return`${e} failed: ${t} argument `}r.validateArgCount=function(e,t,r,n){let o;if(n<t?o="at least "+t:n>r&&(o=0===r?"none":"no more than "+r),o){throw new Error(e+" failed: Was called with "+n+(1===n?" argument.":" arguments.")+" Expects "+o+".")}};r.stringToByteArray=function(e){const t=[];let r=0;for(let o=0;o<e.length;o++){let i=e.charCodeAt(o);if(i>=55296&&i<=56319){const t=i-55296;o++,n(o<e.length,"Surrogate pair missing trail surrogate.");i=65536+(t<<10)+(e.charCodeAt(o)-56320)}i<128?t[r++]=i:i<2048?(t[r++]=i>>6|192,t[r++]=63&i|128):i<65536?(t[r++]=i>>12|224,t[r++]=i>>6&63|128,t[r++]=63&i|128):(t[r++]=i>>18|240,t[r++]=i>>12&63|128,t[r++]=i>>6&63|128,t[r++]=63&i|128)}return t};
/**
 * @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.
 */
r.stringLength=function(e){let t=0;for(let r=0;r<e.length;r++){const n=e.charCodeAt(r);n<128?t++:n<2048?t+=2:n>=55296&&n<=56319?(t+=4,r++):t+=3}return t};const A=1e3,P=2,N=r.MAX_VALUE_MILLIS=144e5,I=r.RANDOM_FACTOR=.5}).call(this)}).call(this,e("_process"))}}},{package:"@metamask/notification-services-controller>firebase>@firebase/util",file:"node_modules/@firebase/util/dist/index.esm2017.js"}],[908,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0});class n{static parse(e){if(""===e)return new n([]);if(!e.startsWith("/"))throw new o(e);const[,...t]=e.split("/");return new n(t.map(e=>e.replace(/~1/g,"/").replace(/~0/g,"~")))}constructor(e){this.tokens=e}toString(){if(0===this.tokens.length)return"";return`/${this.tokens.map(e=>e.replace(/~/g,"~0").replace(/\//g,"~1")).join("/")}`}shmeval(e){for(const t of this.tokens){if(!e.hasOwnProperty(t))throw new i(e,t);e=e[t]}return e}}r.default=n;class o extends Error{constructor(e){super(`Invalid JSON Pointer: ${e}`),this.ptr=e}}r.InvalidPtrError=o;class i extends Error{constructor(e,t){super(`Error evaluating JSON Pointer: no attribute ${t} on ${e}`),this.instance=e,this.token=t}}r.EvalError=i}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver>@json-schema-spec/json-pointer",file:"node_modules/@json-schema-spec/json-pointer/lib/index.js"}],[909,{"@json-schema-tools/reference-resolver":914,"@json-schema-tools/traverse":917,"fast-safe-stringify":4949},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.NonStringRefError=void 0;var a=s(e("@json-schema-tools/traverse")),l=s(e("@json-schema-tools/reference-resolver")),c=s(e("fast-safe-stringify")),u=function(e){this.name="NonStringRefError",this.message=["NonStringRefError","Found an improperly formatted $ref in schema. $ref must be a string","schema in question: ".concat((0,c.default)(e))].join("\n")};r.NonStringRefError=u;var d=function(e,t){if(e.$ref!==undefined&&Object.keys(e).length>1&&!0!==t&&!1!==t){var r=n(n({},t),e);return delete r.$ref,r}return t},f=function(){function e(e,t){var r;if(void 0===t&&(t={}),this.options=t,this.refCache={},r=!0===this.options.mutate||!0===e||!1===e?e:n({},e),this.options.recursive===undefined&&(this.options.recursive=!0),this.options.rootSchema===undefined&&(this.options.rootSchema=r),!0!==e&&!1!==e&&e.$id&&(this.options.rootSchema=r),this.options.refCache&&(this.refCache=this.options.refCache),this.options.protocolHandlerMap)for(var o=0,i=Object.keys(this.options.protocolHandlerMap);o<i.length;o++){var s=i[o];l.default.protocolHandlerMap[s]=this.options.protocolHandlerMap[s]}this.schema=r,this.refs=this.collectRefs()}return e.prototype.resolve=function(){return o(this,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,this._resolve()];case 1:return e.sent(),delete this.schema.definitions,delete this.schema.components,[2,this.schema]}})})},e.prototype._resolve=function(){return o(this,void 0,void 0,function(){var t,r,o,s,c,u,f,p,h,m,g,b=this;return i(this,function(i){switch(i.label){case 0:if(!0===this.schema||!1===this.schema)return[2,Promise.resolve(this.schema)];if(0===this.refs.length)return[2,Promise.resolve(this.schema)];t=this.refs.filter(function(e){return b.refCache[e]===undefined}),r=[],o=0,s=t,i.label=1;case 1:return o<s.length?(c=s[o],u=void 0,this.refCache[c]===undefined?[3,2]:(u=this.refCache[c],[3,5])):[3,11];case 2:if("#"!==c)return[3,3];if(this.options.rootSchema===undefined)throw new Error("options.rootSchema was not provided, but one of the schemas references '#'");return u=this.options.rootSchema,[3,5];case 3:return f=l.default.resolve(c,this.options.rootSchema),r.push(f),[4,f];case 4:u=i.sent(),i.label=5;case 5:return!0!==this.options.recursive||!0===u||!1===u||"#"===c?[3,9]:(p=n(n({},this.options),{refCache:this.refCache}),0===(h=new e(u,p)).refs.length?[3,7]:(m=h._resolve(),r.push(m),[4,m]));case 6:return g=i.sent(),this.refCache[c]=d(u,g),[3,8];case 7:this.refCache[c]=u,i.label=8;case 8:return[3,10];case 9:this.refCache[c]=u,i.label=10;case 10:return o++,[3,1];case 11:return this.schema.$ref!==undefined?this.schema=d(this.schema,this.refCache[this.schema.$ref]):(0,a.default)(this.schema,function(e){if(!0===e||!1===e)return e;if(e.$ref!==undefined){var t=b.refCache[e.$ref];return d(e,t)}return e},{mutable:!0}),[4,Promise.all(r)];case 12:return i.sent(),[2,this.schema]}})})},e.prototype.collectRefs=function(){var e=[];return(0,a.default)(this.schema,function(t){if(!0===t||!1===t)return t;if(t.$ref&&-1===e.indexOf(t.$ref)){if("string"!=typeof t.$ref)throw new u(t);e.push(t.$ref)}return t}),e},e}();r.default=f}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer",file:"node_modules/@json-schema-tools/dereferencer/build/dereferencer.js"}],[91,{"@metamask/messenger":2744},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getConnectivityControllerMessenger=function(e){return new n.Messenger({namespace:"ConnectivityController",parent:e})};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/connectivity/connectivity-controller-messenger.ts"}],[910,{"./dereferencer":909},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.NonStringRefError=void 0;var o=n(e("./dereferencer")),i=e("./dereferencer");Object.defineProperty(r,"NonStringRefError",{enumerable:!0,get:function(){return i.NonStringRefError}}),r.default=o.default}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer",file:"node_modules/@json-schema-tools/dereferencer/build/index.js"}],[911,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.jsonSchema=void 0,r.jsonSchema={$schema:"https://meta.json-schema.tools/",$id:"https://meta.json-schema.tools/",title:"JSONSchema",default:{},oneOf:[{$ref:"#/definitions/JSONSchemaObject"},{$ref:"#/definitions/JSONSchemaBoolean"}],definitions:{JSONSchemaBoolean:{title:"JSONSchemaBoolean",description:"Always valid if true. Never valid if false. Is constant.",type:"boolean"},JSONSchemaObject:{title:"JSONSchemaObject",type:"object",properties:{$id:{title:"$id",type:"string",format:"uri-reference"},$schema:{title:"$schema",type:"string",format:"uri"},$ref:{title:"$ref",type:"string",format:"uri-reference"},$comment:{title:"$comment",type:"string"},title:{title:"title",type:"string"},description:{title:"description",type:"string"},default:!0,readOnly:{title:"readOnly",type:"boolean",default:!1},examples:{title:"examples",type:"array",items:!0},multipleOf:{title:"multipleOf",type:"number",exclusiveMinimum:0},maximum:{title:"maximum",type:"number"},exclusiveMaximum:{title:"exclusiveMaximum",type:"number"},minimum:{title:"minimum",type:"number"},exclusiveMinimum:{title:"exclusiveMinimum",type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{title:"pattern",type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{title:"items",anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{title:"uniqueItems",type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{title:"definitions",type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{title:"properties",type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{title:"patternProperties",type:"object",additionalProperties:{$ref:"#"},propertyNames:{title:"propertyNames",format:"regex"},default:{}},dependencies:{title:"dependencies",type:"object",additionalProperties:{title:"dependenciesSet",anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{title:"enum",type:"array",items:!0,minItems:1,uniqueItems:!0},type:{title:"type",anyOf:[{$ref:"#/definitions/simpleTypes"},{title:"arrayOfSimpleTypes",type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{title:"format",type:"string"},contentMediaType:{title:"contentMediaType",type:"string"},contentEncoding:{title:"contentEncoding",type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}}},schemaArray:{title:"schemaArray",type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{title:"nonNegativeInteger",type:"integer",minimum:0},nonNegativeIntegerDefault0:{title:"nonNegativeIntegerDefaultZero",type:"integer",minimum:0,default:0},simpleTypes:{title:"simpleTypes",type:"string",enum:["array","boolean","integer","null","number","object","string"]},stringArray:{title:"stringArray",type:"array",items:{type:"string"},uniqueItems:!0,default:[]}}},r.default=r.jsonSchema}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/meta-schema",file:"node_modules/@json-schema-tools/meta-schema/index.js"}],[912,{"./errors":913,"isomorphic-fetch":5253},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var s=e("./errors"),a=i(e("isomorphic-fetch")),l=function(e){return n(void 0,void 0,void 0,function(){var t,r;return o(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,(0,a.default)(e)];case 1:return t=n.sent(),[3,3];case 2:throw n.sent(),new s.InvalidRemoteURLError(e);case 3:return n.trys.push([3,5,,6]),[4,t.json()];case 4:return[2,n.sent()];case 5:throw r=n.sent(),new s.NonJsonRefError({$ref:e},r.message);case 6:return[2]}})})};r.default={https:l,http:l}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/default-protocol-handler-map.js"}],[913,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.InvalidFileSystemPathError=r.InvalidRemoteURLError=r.NotResolvableError=r.NonJsonRefError=void 0;var n=function(e,t){this.name="NonJsonRefError",this.message=["NonJsonRefError","The resolved value at the reference: ".concat(e.$ref," was not JSON.parse 'able"),"The non-json content in question: ".concat(t)].join("\n")};r.NonJsonRefError=n;var o=function(e){this.name="NotResolvableError",this.message=["NotResolvableError","Could not resolve the reference: ".concat(e),"No protocol handler was found, and it was not found to be an internal reference"].join("\n")};r.NotResolvableError=o;var i=function(e){this.name="InvalidRemoteURLError",this.message=["InvalidRemoteURLError","The url was not resolvable: ".concat(e)].join("\n")};r.InvalidRemoteURLError=i;var s=function(e){this.name="InvalidFileSystemPathError",this.message=["InvalidFileSystemPathError","The path was not resolvable: ".concat(e)].join("\n")};r.InvalidFileSystemPathError=s}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/errors.js"}],[914,{"./default-protocol-handler-map":912,"./reference-resolver":915},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=s(e("./default-protocol-handler-map")),l=s(e("./reference-resolver")),c=n(n({},a.default),{file:function(){return o(void 0,void 0,void 0,function(){return i(this,function(e){return[2,undefined]})})}});r.default=new l.default(c)}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/index-web.js"}],[915,{"./errors":913,"./resolve-pointer":916},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,i){function s(e){try{l(n.next(e))}catch(e){i(e)}}function a(e){try{l(n.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,l])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var s=e("./errors"),a=i(e("./resolve-pointer")),l=function(){function e(e){this.protocolHandlerMap=e}return e.prototype.resolve=function(e){return n(this,arguments,void 0,function(e,t){var r,n,i,l,c,u,d,f,p,h;return void 0===t&&(t={}),o(this,function(o){switch(o.label){case 0:if("#"===e[0])return[2,Promise.resolve((0,a.default)(e,t))];(r=e.split("#")).length>1&&(n=r[r.length-1]),i=r[0],o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.protocolHandlerMap.file(i,t)];case 2:return l=o.sent(),[3,4];case 3:throw c=o.sent(),new s.NonJsonRefError({$ref:e},c.message);case 4:if(l!==undefined)return h=l,n&&(h=(0,a.default)(n,h)),[2,h];if(!1===e.includes("://"))throw new s.InvalidFileSystemPathError(e);u=0,d=Object.keys(this.protocolHandlerMap),o.label=5;case 5:return u<d.length?(f=d[u],i.startsWith(f)?[4,this.protocolHandlerMap[f](i,t)]:[3,7]):[3,8];case 6:if((p=o.sent())!==undefined)return h=p,n&&(h=(0,a.default)(n,h)),[2,h];o.label=7;case 7:return u++,[3,5];case 8:throw new s.NotResolvableError(e)}})})},e}();r.default=l}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/reference-resolver.js"}],[916,{"@json-schema-spec/json-pointer":908},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.InvalidJsonPointerRefError=void 0;var o=n(e("@json-schema-spec/json-pointer")),i=function(e,t){this.name="InvalidJsonPointerRefError",this.message=["InvalidJsonPointerRefError","The provided RFC6901 JSON Pointer is invalid: ".concat(e),"","addition info: ",t].join("\n")};r.InvalidJsonPointerRefError=i,r.default=function(e,t){try{var r=e.replace("#","");return o.default.parse(r).shmeval(t)}catch(t){throw new i(e,t.message)}}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/resolve-pointer.js"}],[917,{},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,i=t.length;o<i;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(r,"__esModule",{value:!0}),r.defaultOptions=void 0,r.defaultOptions={skipFirstMutation:!1,mutable:!1,bfs:!1};var i=function(e){return e.map(function(e){return""===e?"$":".".concat(e)}).join("")},s=function(e,t){var r=t.find(function(t){return t===e});return r||!1},a=function(e,t){return void 0===t&&(t=1),e[e.length-t]};r.default=function e(t,l,c,u,d,f,p,h,m){void 0===c&&(c=r.defaultOptions),void 0===u&&(u=0),void 0===d&&(d=[]),void 0===f&&(f=[]),void 0===p&&(p=[]),void 0===h&&(h=[]),void 0===m&&(m=[]);var g=n(n({},r.defaultOptions),c);if(0===u&&(p=[""]),"boolean"==typeof t||t instanceof Boolean)return!0===g.skipFirstMutation&&0===u?t:l(t,!1,i(p),a(f));var b=t;!1===g.mutable&&(b=n({},t)),f.push(b),!0===g.bfs&&(!1!==g.skipFirstMutation&&0===u||(b=l(b,!1,i(p),a(f,2)))),d.push(t),h.push([t,b]);var v=function(t,r){var n=s(t,d);return n?(m.push(n),!0===g.skipFirstMutation&&n===d[0]?l(t,!0,i(r),a(f)):h.find(function(e){var t=e[0];return n===t})[1]):e(t,l,c,u+1,d,f,r,h,m)};if(t.anyOf)b.anyOf=t.anyOf.map(function(e,t){return v(e,o(o([],p,!0),["anyOf[".concat(t,"]")],!1))});else if(t.allOf)b.allOf=t.allOf.map(function(e,t){return v(e,o(o([],p,!0),["allOf[".concat(t,"]")],!1))});else if(t.oneOf)b.oneOf=t.oneOf.map(function(e,t){return v(e,o(o([],p,!0),["oneOf[".concat(t,"]")],!1))});else{if(t.items)if(t.items instanceof Array)b.items=t.items.map(function(e,t){return v(e,o(o([],p,!0),["items[".concat(t,"]")],!1))});else{var y=s(t.items,d);if(y)if(m.push(y),!0===g.skipFirstMutation&&y===d[0])b.items=l(t.items,!0,i(p),a(f));else{var E=h.find(function(e){var t=e[0];return y===t})[1];b.items=E}else b.items=e(t.items,l,c,u+1,d,f,o(o([],p,!0),["items"],!1),h,m)}if(t.additionalItems!==undefined&&(b.additionalItems=v(t.additionalItems,o(o([],p,!0),["additionalItems"],!1))),t.properties!==undefined){var S=t.properties,w={};Object.keys(t.properties).forEach(function(e){w[e]=v(S[e],o(o([],p,!0),["properties",e.toString()],!1))}),b.properties=w}if(t.patternProperties!==undefined){var _=t.patternProperties,M={};Object.keys(t.patternProperties).forEach(function(e){M[e]=v(_[e],o(o([],p,!0),["patternProperties",e.toString()],!1))}),b.patternProperties=M}t.additionalProperties!==undefined&&!0==!!t.additionalProperties&&(b.additionalProperties=v(t.additionalProperties,o(o([],p,!0),["additionalProperties"],!1)))}if(!0===g.skipFirstMutation&&0===u)return b;if(!0===g.bfs)return f.pop(),b;var C=-1!==m.indexOf(t);return f.pop(),l(b,C,i(p),a(f))}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer>@json-schema-tools/traverse",file:"node_modules/@json-schema-tools/traverse/build/index.js"}],[92,{"./connectivity-controller-messenger":91},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"getConnectivityControllerMessenger",{enumerable:!0,get:function(){return n.getConnectivityControllerMessenger}});var n=e("./connectivity-controller-messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/connectivity/index.ts"}],[93,{"@metamask/messenger":2744},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getAccountActivityServiceMessenger=function(e){const t=new n.Messenger({namespace:"AccountActivityService",parent:e});return e.delegate({messenger:t,actions:["AccountsController:getSelectedAccount","BackendWebSocketService:connect","BackendWebSocketService:forceReconnection","BackendWebSocketService:subscribe","BackendWebSocketService:getConnectionInfo","BackendWebSocketService:channelHasSubscription","BackendWebSocketService:getSubscriptionsByChannel","BackendWebSocketService:findSubscriptionsByChannelPrefix","BackendWebSocketService:addChannelCallback","BackendWebSocketService:removeChannelCallback"],events:["AccountsController:selectedAccountChange","BackendWebSocketService:connectionStateChanged"]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/core-backend/account-activity-service-messenger.ts"}],[94,{"@metamask/messenger":2744},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getBackendWebSocketServiceInitMessenger=function(e){const t=new n.Messenger({namespace:"BackendWebSocketServiceInit",parent:e});return e.delegate({messenger:t,actions:["RemoteFeatureFlagController:getState","AuthenticationController:getBearerToken"]}),t},r.getBackendWebSocketServiceMessenger=function(e){const t=new n.Messenger({namespace:"BackendWebSocketService",parent:e});return e.delegate({messenger:t,actions:["AuthenticationController:getBearerToken"],events:["AuthenticationController:stateChange","KeyringController:lock","KeyringController:unlock"]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/core-backend/backend-websocket-service-messenger.ts"}],[95,{"./account-activity-service-messenger":93,"./backend-websocket-service-messenger":94},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),Object.defineProperty(r,"getAccountActivityServiceMessenger",{enumerable:!0,get:function(){return o.getAccountActivityServiceMessenger}}),Object.defineProperty(r,"getBackendWebSocketServiceInitMessenger",{enumerable:!0,get:function(){return n.getBackendWebSocketServiceInitMessenger}}),Object.defineProperty(r,"getBackendWebSocketServiceMessenger",{enumerable:!0,get:function(){return n.getBackendWebSocketServiceMessenger}});var n=e("./backend-websocket-service-messenger"),o=e("./account-activity-service-messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/core-backend/index.ts"}],[96,{"@metamask/messenger":2744},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getCurrencyRateControllerInitMessenger=function(e){const t=new n.Messenger({namespace:"CurrencyRateControllerInit",parent:e});return e.delegate({messenger:t,actions:["PreferencesController:getState"]}),t},r.getCurrencyRateControllerMessenger=function(e){const t=new n.Messenger({namespace:"CurrencyRateController",parent:e});return e.delegate({messenger:t,actions:["NetworkController:getNetworkClientById","NetworkController:getState"]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/currency-rate-controller-messenger.ts"}],[97,{"@metamask/messenger":2744},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getDecryptMessageControllerInitMessenger=function(e){const t=new n.Messenger({namespace:"DecryptMessageControllerInit",parent:e});return e.delegate({messenger:t,actions:["MetaMetricsController:trackEvent"]}),t},r.getDecryptMessageControllerMessenger=function(e){const t=new n.Messenger({namespace:"DecryptMessageController",parent:e});return e.delegate({messenger:t,actions:["ApprovalController:addRequest","ApprovalController:acceptRequest","ApprovalController:rejectRequest","KeyringController:decryptMessage"],events:["DecryptMessageManager:stateChange","DecryptMessageManager:unapprovedMessage"]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/decrypt-message-controller-messenger.ts"}],[98,{"@metamask/messenger":2744},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getDecryptMessageManagerMessenger=function(e){return new n.Messenger({namespace:"DecryptMessageManager",parent:e})};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/decrypt-message-manager-messenger.ts"}],[99,{"@metamask/messenger":2744},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getDeFiPositionsControllerInitMessenger=function(e){const t=new n.Messenger({namespace:"DeFiPositionsControllerInit",parent:e});return e.delegate({messenger:t,actions:["RemoteFeatureFlagController:getState","MetaMetricsController:trackEvent"]}),t},r.getDeFiPositionsControllerMessenger=function(e){const t=new n.Messenger({namespace:"DeFiPositionsController",parent:e});return e.delegate({messenger:t,actions:["AccountTreeController:getAccountsFromSelectedAccountGroup"],events:["KeyringController:lock","TransactionController:transactionConfirmed","AccountTreeController:selectedAccountGroupChange"]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/defi-positions/defi-positions-controller-messenger.ts"}],[9,{"../../shared/constants/app":6753,"../../shared/constants/defi-referrals":6758,"../../shared/constants/errors":6759,"../../shared/constants/infura-project-id":6764,"../../shared/constants/messages":6768,"../../shared/constants/metametrics":6769,"../../shared/constants/offscreen-communication":6775,"../../shared/constants/onboarding":6776,"../../shared/constants/start-up-errors":6785,"../../shared/constants/ui-initialization":6793,"../../shared/lib/deep-links/utils":6832,"../../shared/lib/get-first-preferred-lang-code":6863,"../../shared/lib/manifestFlags":6865,"../../shared/lib/promise-with-resolvers":6877,"../../shared/lib/sentry":6878,"../../shared/modules/browser-runtime.utils":6899,"../../shared/modules/caip-stream":6900,"../../shared/modules/fetch-with-timeout":6909,"../../shared/modules/mv3.utils":6914,"../../shared/modules/object.utils":6916,"../../shared/modules/selectors/networks":6923,"./constants/marketing-site-whitelist":10,"./constants/sentry-state":11,"./constants/snaps":12,"./constants/stream":13,"./first-time-state":263,"./lib/CronjobControllerStorageManager":267,"./lib/createDefiReferralMiddleware":274,"./lib/deep-links/deep-link-router":289,"./lib/deep-links/metrics":290,"./lib/ens-ipfs/setup":295,"./lib/extension-lazy-listener/extension-lazy-listener":296,"./lib/getObjStructure":298,"./lib/migrator":304,"./lib/notification-manager":308,"./lib/safe-reload":337,"./lib/setup-initial-state-hooks":341,"./lib/start-up-errors/start-up-errors":352,"./lib/state-corruption/state-corruption-recovery":353,"./lib/stores/extension-store":357,"./lib/stores/fixture-extension-store":358,"./lib/stores/persistence-manager":360,"./lib/stream-utils":362,"./lib/update-remote-feature-flags":396,"./lib/use-split-state-storage":397,"./lib/util":398,"./metamask-controller":399,"./migrations":629,"./offscreen":630,"./on-update":631,"./platforms/extension":632,"@metamask/base-controller":1655,"@metamask/utils":3650,"extension-port-stream":4934,loglevel:5453,"readable-stream":5924,"webextension-polyfill":6740},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.loadStateFromPersistence=ze,r.setupController=Ye,e("./lib/setup-initial-state-hooks"),e("../../shared/constants/infura-project-id");var n=e("readable-stream"),o=ne(e("loglevel")),i=ne(e("webextension-polyfill")),s=e("@metamask/utils"),a=e("@metamask/base-controller"),l=e("extension-port-stream"),c=e("../../shared/lib/promise-with-resolvers"),u=e("../../shared/constants/onboarding"),d=e("../../shared/constants/app"),f=e("../../shared/constants/messages"),p=e("../../shared/constants/ui-initialization"),h=e("../../shared/constants/metametrics"),m=e("../../shared/modules/browser-runtime.utils"),g=e("../../shared/modules/mv3.utils"),b=e("../../shared/modules/object.utils"),v=(e("../../shared/constants/offscreen-communication"),e("../../shared/lib/sentry")),y=e("../../shared/modules/selectors/networks"),E=e("../../shared/modules/caip-stream"),S=ne(e("../../shared/modules/fetch-with-timeout")),w=e("../../shared/constants/errors"),_=ne(e("../../shared/lib/get-first-preferred-lang-code")),M=(e("../../shared/lib/manifestFlags"),e("../../shared/constants/start-up-errors")),C=e("../../shared/constants/defi-referrals"),T=e("../../shared/lib/deep-links/utils"),O=e("./lib/state-corruption/state-corruption-recovery"),k=e("./lib/stores/persistence-manager"),A=ne(e("./lib/stores/extension-store")),P=(e("./lib/stores/fixture-extension-store"),e("./lib/use-split-state-storage")),N=ne(e("./migrations")),I=ne(e("./lib/migrator")),j=e("./lib/update-remote-feature-flags"),R=ne(e("./platforms/extension")),D=e("./constants/sentry-state"),x=re(e("./lib/notification-manager")),L=re(e("./metamask-controller")),$=ne(e("./lib/getObjStructure")),U=ne(e("./lib/ens-ipfs/setup")),B=e("./lib/util"),F=e("./offscreen"),V=e("./lib/stream-utils"),W=ne(e("./first-time-state")),K=e("./on-update"),z=e("./constants/marketing-site-whitelist"),G=e("./constants/stream"),J=e("./constants/snaps"),H=e("./lib/extension-lazy-listener/extension-lazy-listener"),q=e("./lib/deep-links/deep-link-router"),Y=e("./lib/deep-links/metrics"),X=e("./lib/safe-reload"),Q=e("./lib/start-up-errors/start-up-errors"),Z=e("./lib/CronjobControllerStorageManager"),ee=e("./lib/createDefiReferralMiddleware");function te(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(te=function(e){return e?r:t})(e)}function re(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=te(t);if(r&&r.has(e))return r.get(e);var n={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if("default"!==i&&{}.hasOwnProperty.call(e,i)){var s=o?Object.getOwnPropertyDescriptor(e,i):null;s&&(s.get||s.set)?Object.defineProperty(n,i,s):n[i]=e[i]}return n.default=e,r&&r.set(e,n),n}function ne(e){return e&&e.__esModule?e:{default:e}}const oe=globalThis.stateHooks.lazyListener??new H.ExtensionLazyListener(i.default),ie="#0376C9",se=9,ae=new A.default,le=new k.PersistenceManager({localStore:ae}),{safePersist:ce,requestSafeReload:ue,evacuate:de}=(0,X.getRequestSafeReload)(le);global.stateHooks.getMostRecentPersistedState=()=>le.mostRecentRetrievedState,global.stateHooks.getStorageKind=()=>le.storageKind,global.logEncryptedVault=()=>{le.logEncryptedVault()};const{sentry:fe}=global;let pe={...W.default};const he={[d.ENVIRONMENT_TYPE_POPUP]:!0,[d.ENVIRONMENT_TYPE_NOTIFICATION]:!0,[d.ENVIRONMENT_TYPE_FULLSCREEN]:!0},me=["trezor-connect"];o.default.setLevel("info",!1);const ge=new R.default,be=new x.default,ve=(0,B.getPlatform)()===d.PLATFORM_FIREFOX;function ye(e){var t;const r=e.name,n=null!==(t=e.sender)&&void 0!==t&&t.url?new URL(e.sender.url):null;let o;return o=ve?Boolean(he[r]):(null==n?void 0:n.origin)===`chrome-extension://${i.default.runtime.id}`,{processName:r,senderUrl:n,isMetaMaskUIPort:o}}let Ee=0,Se=!1,we=!1,_e=0;const Me={},Ce={};let Te;const Oe={},ke={};const Ae=new URL("https://metamask.github.io/phishing-warning/v5.1.0/"),Pe=Ae.toString();let Ne,Ie,je;function Re(){const e=(0,c.withResolvers)();Ne=e.promise,Ie=e.resolve,je=e.reject}oe.once("runtime","onInstalled").then(e=>{!async function([e]){if("install"===e.reason)await async function(){o.default.debug("First install detected"),ge.openExtensionInBrowser();await Qe()}();else if("update"===e.reason){const{previousVersion:t}=e;if(!t||t===ge.getVersion())return;await Ne,(0,K.onUpdate)(Te,ge,t,ue)}}(e)}),Re();let De,xe,Le,$e;const Ue=new O.CorruptionHandler,Be=async e=>{try{e.postMessage({data:{method:p.BACKGROUND_LIVENESS_METHOD},name:"background-liveness"})}catch(e){return void o.default.error("MetaMask - background-liveness check: Failed to message to port",e)}try{await Ne,De(e)}catch(r){if(null==fe||fe.captureException(r),ye(e).isMetaMaskUIPort)if((0,w.isStateCorruptionError)(r))await Ue.handleStateCorruptionError({port:e,error:r,database:le,repairCallback:async e=>{Re(),(0,O.hasVault)(e)?(await Ze(e),Te.onboardingController.setFirstTimeFlowType(u.FirstTimeFlowType.restore)):(await le.reset(),await Ze(null))}});else{var t;const n=(0,s.isObject)(r)?{message:r.message??"Unknown error",name:r.name??"UnknownError",stack:r.stack,...r.sentryTags&&{sentryTags:r.sentryTags}}:{message:String(r),name:"UnknownError",stack:""};(0,Q.tryPostMessage)(e,M.DISPLAY_GENERAL_STARTUP_ERROR,{error:n,currentLocale:null===(t=Te)||void 0===t||null===(t=t.preferencesController)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.currentLocale})}}},Fe=()=>{oe.addListener("runtime","onConnect",Be)};function Ve(){const e=(new Date).toISOString();i.default.storage.session.set({timestamp:e})}async function We(e){(0,B.initInstallType)();const t=g.isManifestV3?(0,F.createOffscreen)():null;let r=null,n=!1;g.isManifestV3&&(0,F.addOffscreenConnectivityListener)(e=>{if(n&&Te.controllerApi.setConnectivityStatus){const t=e?"online":"offline";Te.controllerApi.setConnectivityStatus(t)}else r=e});const o=await ze(e),s=o.data,a=await(0,_.default)();let l;if(g.isManifestV3){var c;if(!1!==(null===(c=s.PreferencesController)||void 0===c?void 0:c.enableMV3TimestampSave)){const e=2e3;Ve(),setInterval(Ve,e)}const e=await i.default.storage.session.get(["isFirstMetaMaskControllerSetup"]);l=(null==e?void 0:e.isFirstMetaMaskControllerSetup)===undefined,await i.default.storage.session.set({isFirstMetaMaskControllerSetup:l})}const u={},d=await async function(){const e=(0,S.default)(),t=J.PREINSTALLED_SNAPS_URLS.map(async t=>{const r=await e(t);if(t.pathname.endsWith(".json.gz")){const e=new DecompressionStream("gzip"),t=r.body.pipeThrough(e);return await new Response(t).json()}return await r.json()});return Promise.all(t)}(),p=new Z.CronjobControllerStorageManager;if(await p.init(),Ye(s,a,u,l,o.meta,t,d,p),Te.metaMetricsController.updateTraits({[h.MetaMetricsUserTrait.StorageKind]:le.storageKind}),function(e){async function t(e,t){try{const r=await i.default.tabs.get(e);return!(r.url&&r.url.startsWith("https://www.google.com/search")||(await i.default.tabs.update(e,{url:t}),0))}catch(e){return null==fe||fe.captureException(e),!1}}const r=!g.isManifestV3;i.default.webRequest.onBeforeRequest.addListener(n=>{var o,s,a;if(n.tabId===i.default.tabs.TAB_ID_NONE)return{};const{completedOnboarding:l}=e.onboardingController.state;if(!l)return{};if(!e.preferencesController.state.usePhishDetect)return{};if(n.initiator&&"null"!==n.initiator&&new URL(n.initiator).host===Ae.host)return{};const{hostname:c,href:u,searchParams:d}=new URL(n.url);e.phishingController.maybeUpdateState();const f=e.phishingController.isBlockedRequest(n.url);let p,m;if("main_frame"!==n.type&&"sub_frame"!==n.type||(p=e.phishingController.test(n.url)),!(null!==(o=p)&&void 0!==o&&o.result||f.result))return{};let g,b=u;null!==(s=p)&&void 0!==s&&s.result&&f.result?m=`${p.type} and ${f.type}`:null!==(a=p)&&void 0!==a&&a.result?m=p.type:(m=f.type,b=n.initiator);try{g=new URL(b).hostname}catch{g=c,b=u}const v=new URLSearchParams({hostname:g,href:b}),y=new URL(Pe);y.hash=v.toString();const E=y.toString(),S=()=>{ve||e.metaMetricsController.trackEvent({event:h.MetaMetricsEventName.PhishingPageDisplayed,category:h.MetaMetricsEventCategory.Phishing,properties:{url:b,referrer:{url:b},reason:m,requestDomain:f.result?c:undefined}},{excludeMetaMetricsId:!0})};return r?"main_frame"===n.type?(S(),{redirectUrl:E}):(t(n.tabId,E).then(e=>{e&&S()}),{cancel:!0}):(t(n.tabId,E).then(e=>{e&&S()}),{})},{urls:["http://*/*","https://*/*","ws://*/*","wss://*/*"]},r?["blocking"]:[])}(Te),g.isManifestV3){if(n=!0,null!==r){const e=r?"online":"offline";Te.controllerApi.setConnectivityStatus(e)}}else{const e=e=>{const t=e?"online":"offline";Te.controllerApi.setConnectivityStatus(t)};e(globalThis.navigator.onLine),globalThis.addEventListener("online",()=>e(!0)),globalThis.addEventListener("offline",()=>e(!1))}g.isManifestV3||await async function(){let e;try{const t=new URL(Pe);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 o=new Promise((e,t)=>{r=e,n=t});e.addEventListener("load",r),window.document.body.appendChild(e),setTimeout(()=>n(new Ke),1e3),await o}catch(e){e instanceof Ke?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 i.default.tabs.query({url:"<all_urls>",windowType:"normal"}).then(e=>((0,m.checkForLastErrorAndLog)(),e)).catch(()=>{(0,m.checkForLastErrorAndLog)()});for(const t of e)i.default.tabs.sendMessage(t.id,{name:f.EXTENSION_MESSAGES.READY}).then(()=>{(0,m.checkForLastErrorAndLog)()}).catch(()=>{(0,m.checkForLastErrorAndLog)()})})(),new q.DeepLinkRouter({getExtensionURL:ge.getExtensionURL,getState:Te.getState.bind(Te)}).on("navigate",async({url:e,parsed:t})=>{"redirectTo"in t||await Te.metaMetricsController.trackEvent((0,Y.createEvent)({signature:t.signature,url:e}))}).on("error",e=>null==fe?void 0:fe.captureException(e)).install()}Fe(),i.default.runtime.onConnectExternal.addListener(async(...e)=>{await Ne,xe(...e)});class Ke extends Error{constructor(){super("Timeout failed")}}async function ze(e){var t,r;let n;if(e){n={data:{},meta:{}};for(const t of k.backedUpStateKeys)(0,s.hasProperty)(e,t)&&(n.data[t]=e[t]);(0,s.hasProperty)(e,"meta")&&(0,s.isObject)(e.meta)&&(n.meta=e.meta,"split"===e.meta.storageKind||"data"===e.meta.storageKind?le.storageKind=e.meta.storageKind:le.storageKind="data"),"number"!=typeof n.meta.version&&(o.default.error("The `backup`'s `meta.version` property was missing during backup restore."),n.meta.version=155)}else{const e=!0;n=await le.get({validateVault:e})}const i=new I.default({migrations:N.default,defaultVersion:null});i.on("error",e=>{console.warn(e);const t=(0,$.default)(n);null==fe||fe.captureException(e,{extra:{vaultStructure:t}})});let a=!1;null!==(t=n)&&void 0!==t&&t.data||null!==(r=n)&&void 0!==r&&r.meta||(a=!0,n=i.generateInitialState(pe));const{state:l,changedKeys:c}=await i.migrateData(n),u=async t=>{var r,o,i,s,a,c,u,d;const f=null===(r=n)||void 0===r||null===(r=r.meta)||void 0===r?void 0:r.version,p="number"==typeof f&&f>=157;let h=(null==e||null===(o=e.AppMetadataController)||void 0===o?void 0:o.firstTimeInfo)??(null==l||null===(i=l.data)||void 0===i||null===(i=i.AppMetadataController)||void 0===i?void 0:i.firstTimeInfo)??(null==l||null===(s=l.data)||void 0===s?void 0:s.firstTimeInfo)??(null===(a=n)||void 0===a||null===(a=a.data)||void 0===a||null===(a=a.AppMetadataController)||void 0===a?void 0:a.firstTimeInfo)??(null===(c=n)||void 0===c||null===(c=c.data)||void 0===c?void 0:c.firstTimeInfo);if(!h)try{var m;const e=await le.getBackup();h=null==e||null===(m=e.AppMetadataController)||void 0===m?void 0:m.firstTimeInfo}catch{}const g=new Error(t);return g.sentryTags={"corruption.preMigrationVersion":String(f??"unknown"),"corruption.backupShouldExist":String(p),"corruption.installVersion":String((null===(u=h)||void 0===u?void 0:u.version)??"unknown"),"corruption.installDate":String((null===(d=h)||void 0===d?void 0:d.date)??"unknown")},g};if(!l)throw await u("MetaMask - migrator returned undefined");if(!(0,s.isObject)(l.meta))throw await u(`MetaMask - migrator metadata has invalid type '${typeof l.meta}'`);if("number"!=typeof l.meta.version)throw await u(`MetaMask - migrator metadata version has invalid type '${typeof l.meta.version}'`);if(!["data","split",undefined].includes(l.meta.storageKind))throw await u(`MetaMask - migrator metadata storageKind has invalid value '${l.meta.storageKind}'`);if(!(0,s.isObject)(l.data))throw await u(`MetaMask - migrator data has invalid type '${typeof l.data}'`);if(le.setMetadata(l.meta),o.default.debug("[Split State]: Loaded data from persistence with storageKind '%s'",le.storageKind),"data"===le.storageKind){const e=!0===l.meta.platformSplitStateGradualRolloutAttempted,t=!e&&await(0,P.useSplitStateStorage)(l.data);o.default.debug("[Split State]: shouldUseSplitStateStorage: %s (alreadyTried: %s)",t,e),t&&(l.meta.platformSplitStateGradualRolloutAttempted=!0,le.setMetadata(l.meta)),o.default.debug("[Split State]: Writing data to persistence with storageKind 'data'"),await le.set(l.data),t&&(await le.migrateToSplitState(l.data),l.meta=le.getMetaData(),l.meta!==undefined&&(delete l.meta.platformSplitStateGradualRolloutAttempted,le.setMetadata(l.meta)),await le.persist())}else{if("split"!==le.storageKind)throw new Error(`MetaMask - persistenceManager has invalid storageKind '${le.storageKind}'`);if(a)for(const[e,t]of Object.entries(l.data))le.update(e,t);else for(const e of c)le.update(e,l.data[e]);await le.persist()}return o.default.debug("[Split State]: Load complete."),l}function Ge(e){const{metaMetricsId:t}=Te.metaMetricsController.state;if(!(0,B.shouldEmitDappViewedEvent)(t))return;const r=Te.getPermittedAccounts(e).length;if(0===r)return;const n=Te.controllerMessenger.call("PreferencesController:getState"),o=Object.keys(n.identities).length;Te.metaMetricsController.trackEvent({event:h.MetaMetricsEventName.DappViewed,category:h.MetaMetricsEventCategory.InpageProvider,referrer:{url:e},properties:{is_first_visit:!1,number_of_accounts:o,number_of_accounts_connected:r}},{excludeMetaMetricsId:!0})}function Je(e){var t,r,n;if(null===(t=e.sender)||void 0===t||!t.tab||null===(r=e.sender)||void 0===r||!r.url||null===(n=e.sender)||void 0===n||null===(n=n.tab)||void 0===n||!n.url)return;const o=e.sender.tab.id,i=new URL(e.sender.url),{origin:s}=i,a=new URL(e.sender.tab.url),{origin:l}=a;Object.keys(Oe).includes(o)||(Oe[o]=s),o in ke||(ke[o]=l);const c=Te.controllerMessenger.call("PermissionController:hasPermissions",s),u="New Tab"!==e.sender.tab.title;c&&u&&Ge(s)}function He(e){const t=[d.ENVIRONMENT_TYPE_POPUP,d.ENVIRONMENT_TYPE_NOTIFICATION,d.ENVIRONMENT_TYPE_FULLSCREEN];!(Object.values(Me).some(Boolean)||Se||Ee>0||_e>0)&&t.includes(e)&&function(){const{metaMetricsId:e,participateInMetaMetrics:t}=Te.metaMetricsController.state;(null!==e||t)&&Te.metaMetricsController.trackEvent({event:h.MetaMetricsEventName.AppOpened,category:h.MetaMetricsEventCategory.App})}()}const qe=async()=>{if(await Ne,Te)try{const e=await i.default.tabs.query({active:!0,currentWindow:!0});if(!e||0===e.length)return;const t=e[0],{id:r,title:n,url:o,favIconUrl:s}=t;if(!o)return void Te.appStateController.clearAppActiveTab();const{origin:a,protocol:l,host:c,href:u}=new URL(o);if(!(0,B.isWebOrigin)(a))return void Te.appStateController.clearAppActiveTab();Te.appStateController.setAppActiveTab({id:r,title:n,origin:a,protocol:l,url:o,host:c,href:u,favIconUrl:s}),Te.subjectMetadataController.addSubjectMetadata({origin:a,name:n||c||a,iconUrl:s||null,subjectType:"website"})}catch(e){console.log("Error refreshing appActiveTab:",e.message)}};function Ye(e,t,r,s,c,u,f,p){Te=new L.default({infuraProjectId:globalThis.INFURA_PROJECT_ID,showUserConfirmation:Xe,initState:e,initLangCode:t,platform:ge,notificationManager:be,browser:i.default,getRequestAccountTabIds:()=>Ce,getOpenMetamaskTabsIds:()=>Me,overrides:r,isFirstMetaMaskControllerSetup:s,currentMigrationVersion:c.version,featureFlags:{},offscreenPromise:u,preinstalledSnaps:f,requestSafeReload:ue,cronjobControllerStorageManager:p}),le.setOnSetFailed(e=>{Te.appStateController.setStorageWriteErrorType(e)});const m=[],S=Te.store.getState();for(const t of Object.keys(S)){const r=e[t]||{},n=S[t];if(null===n||"object"!=typeof n){(0,v.captureException)(new Error(`Invalid controller state for '${t}' of type '${null===n?"null":typeof n}'`));continue}const o=Object.keys(n);if(o.length===Object.keys(r).length){for(const e of o)if(n[e]!==r[e]){m.push(t);break}}else m.push(t)}var w;"split"===le.storageKind?(m.length>0&&(o.default.info(`MetaMaskController state changed during configuration for controllers: ${m.join(", ")}. Persisting updated state.`),m.forEach(e=>{le.update(e,S[e])}),ce().catch(e=>{o.default.error("Error persisting updated state:",e),null==fe||fe.captureException(e)})),Te.store.on("stateChange",async({controllerKey:e,newState:t,_oldState:r,_patches:n})=>{le.update(e,t),k.backedUpStateKeys.includes(e)&&k.backedUpStateKeys.forEach(t=>{if(t===e)return;const r=Te.store.config[t];if(null==r||!r.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=Te.controllerMessenger.call(`${t}:getState`),o=(0,a.deriveStateFromMetadata)(n,r.metadata,"persist");le.update(t,o)});try{await ce()}catch(e){o.default.error("Error persisting state change:",e),null==fe||fe.captureException(e)}})):(m.length>0&&(o.default.info(`MetaMaskController state changed during configuration for controllers: ${m.join(", ")}. Persisting updated state.`),ce(S).catch(e=>{o.default.error("Error persisting updated controller state:",e),null==fe||fe.captureException(e)})),Te.store.on("update",ce)),Te.store.on("error",e=>{o.default.error("MetaMask controller.store error:",e),null==fe||fe.captureException(e)}),(0,U.default)({getCurrentChainId:()=>(0,y.getCurrentChainId)({metamask:Te.networkController.state}),getIpfsGateway:Te.preferencesController.getIpfsGateway.bind(Te.preferencesController),getUseAddressBarEnsResolution:()=>Te.preferencesController.state.useAddressBarEnsResolution,provider:Te.provider}),w=Te,global.stateHooks.getSentryAppState=function(){const e=w.memStore.getState();return(0,b.maskObject)(e,D.SENTRY_BACKGROUND_STATE)};const _=()=>Ee>0||Boolean(Object.keys(Me).length)||Se||_e>0||!1,M=(e,t)=>{if(!1===e)Te.onClientClosed();else{if(t===d.ENVIRONMENT_TYPE_FULLSCREEN&&Boolean(Object.keys(Me).length)||t===d.ENVIRONMENT_TYPE_SIDEPANEL&&_e>0)return;Te.onEnvironmentTypeClosed(t)}};function C(){const e=T();let t="";const r=ie;var n,o;e&&(t=(n=e)>(o=se)?`${o}+`:String(n));try{const e={text:t},n={color:r};g.isManifestV3?(i.default.action.setBadgeText(e),i.default.action.setBadgeBackgroundColor(n)):(i.default.browserAction.setBadgeText(e),i.default.browserAction.setBadgeBackgroundColor(n))}catch(e){console.error("Error updating browser badge:",e)}}function T(){try{return Te.appStateController.waitingForUnlock.length+Te.approvalController.getTotalApprovalCount()}catch(e){return console.error("Failed to get pending approval count:",e),0}}De=e=>{if(me.includes(e.name))return;const{processName:t,senderUrl:o,isMetaMaskUIPort:i}=ye(e);if(i){var s;const o=(null==r||null===(s=r.getPortStream)||void 0===s?void 0:s.call(r,e))||new l.ExtensionPortStream(e),i=function({chunkSize:e}){Te.metaMetricsController.trackEvent({event:h.MetaMetricsEventName.PortStreamChunked,category:h.MetaMetricsEventCategory.PortStream,properties:{chunkSize:e}})};if(e.onDisconnect.addListener(()=>o.off("message-too-large",i)),o.on("message-too-large",i),Te.isClientOpen=!0,Te.setupTrustedCommunication(o,e.sender),He(t),(0,j.updateRemoteFeatureFlags)(Te),t===d.ENVIRONMENT_TYPE_POPUP&&(Ee+=1,(0,n.finished)(o,()=>{Ee-=1;const e=_();Te.isClientOpen=e,M(e,d.ENVIRONMENT_TYPE_POPUP)})),t===d.ENVIRONMENT_TYPE_SIDEPANEL&&(_e+=1,qe(),(0,n.finished)(o,()=>{_e=Math.max(_e-1,0);const e=_();Te.isClientOpen=e,M(e,d.ENVIRONMENT_TYPE_SIDEPANEL)})),t===d.ENVIRONMENT_TYPE_NOTIFICATION&&(Se=!0,(0,n.finished)(o,()=>{Se=!1;const e=_();Te.isClientOpen=e,M(e,d.ENVIRONMENT_TYPE_NOTIFICATION)})),t===d.ENVIRONMENT_TYPE_FULLSCREEN){const t=e.sender.tab.id;Me[t]=!0,(0,n.finished)(o,()=>{delete Me[t];const e=_();Te.isClientOpen=e,M(e,d.ENVIRONMENT_TYPE_FULLSCREEN)})}}else if(o&&o.origin===Ae.origin&&o.pathname===Ae.pathname){var a;const t=(null==r||null===(a=r.getPortStream)||void 0===a?void 0:a.call(r,e))||new l.ExtensionPortStream(e,{chunkSize:0});Te.setupPhishingCommunication({connectionStream:t})}else{var c;if(e.sender&&e.sender.tab&&e.sender.url){const t=e.sender.tab.id,r=new URL(e.sender.url),{origin:n}=r;Je(e),e.onMessage.addListener(e=>{e.data&&e.data.method===d.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS&&(Ce[n]=t)})}if(o&&z.COOKIE_ID_MARKETING_WHITELIST_ORIGINS.some(e=>e===o.origin)){var u;const t=(null==r||null===(u=r.getPortStream)||void 0===u?void 0:u.call(r,e))||new l.ExtensionPortStream(e,{chunkSize:0});Te.setUpCookieHandlerCommunication({connectionStream:t})}const t=(null==r||null===(c=r.getPortStream)||void 0===c?void 0:c.call(r,e))||new l.ExtensionPortStream(e,{chunkSize:0});if(Le(t,e.sender),ve||!g.isManifestV3){const r=(0,V.setupMultiplex)(t);r.ignoreStream(G.METAMASK_EIP_1193_PROVIDER),$e(r.createStream(G.METAMASK_CAIP_MULTICHAIN_PROVIDER),e.sender)}}},xe=e=>{var t;const n=(null==r||null===(t=r.getPortStream)||void 0===t?void 0:t.call(r,e))||new l.ExtensionPortStream(e,{chunkSize:0});if(!e.sender.id){if(me.includes(e.name))return;Je(e),$e((0,E.createCaipStream)(n),e.sender)}else Le(n,e.sender)},Le=(e,t)=>{Te.setupUntrustedCommunicationEip1193({connectionStream:e,sender:t})},$e=(e,t)=>{Te.setupUntrustedCommunicationCaip({connectionStream:e,sender:t})},null!=r&&r.registerConnectListeners&&r.registerConnectListeners(De,Le),C(),Te.controllerMessenger.subscribe(L.METAMASK_CONTROLLER_EVENTS.DECRYPT_MESSAGE_MANAGER_UPDATE_BADGE,C),Te.controllerMessenger.subscribe(L.METAMASK_CONTROLLER_EVENTS.ENCRYPTION_PUBLIC_KEY_MANAGER_UPDATE_BADGE,C),Te.signatureController.hub.on(L.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,C),Te.controllerMessenger.subscribe(L.METAMASK_CONTROLLER_EVENTS.APP_STATE_UNLOCK_CHANGE,C),Te.controllerMessenger.subscribe(L.METAMASK_CONTROLLER_EVENTS.APPROVAL_STATE_CHANGE,C),Te.controllerMessenger.subscribe(L.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_LIST_UPDATED,C),Te.controllerMessenger.subscribe(L.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_MARK_AS_READ,C),be.on(x.NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,({automaticallyClosed:e})=>{e?T()>0&&Xe():(Te.signatureController.rejectUnapproved(h.REJECT_NOTIFICATION_CLOSE_SIG),Te.decryptMessageController.rejectUnapproved(h.REJECT_NOTIFICATION_CLOSE),Te.encryptionPublicKeyController.rejectUnapproved(h.REJECT_NOTIFICATION_CLOSE),Te.rejectAllPendingApprovals()),C()})}async function Xe(){const e=await ge.getActiveTabs(),t=Boolean(e.find(e=>Me[e.id])),r=e.length>0&&e[0].extData&&e[0].extData.indexOf("vivaldi_tab")>-1;if(!we&&(r||0===Ee)&&!t&&0===_e){we=!0;try{const e=Te.appStateController.getCurrentPopupId();await be.showPopup(e=>Te.appStateController.setCurrentPopupId(e),e)}finally{we=!1}}}const Qe=async()=>{if(Te){Te.metaMetricsController.updateTraits({[h.MetaMetricsUserTrait.InstallDateExt]:(new Date).toISOString().split("T")[0]});const e=await(0,T.getDeferredDeepLinkFromCookie)(),t={};return e&&(Te.appStateController.setDeferredDeepLink(e),t.install_source="deeplink",t.deeplink_path=e.referringLink),void Te.metaMetricsController.addEventBeforeMetricsOptIn({category:h.MetaMetricsEventCategory.App,event:h.MetaMetricsEventName.AppInstalled,properties:t})}setTimeout(async()=>{await Qe()},500)};i.default.runtime.onUpdateAvailable.addListener(async function(e){await Ne,o.default.info("An update is available",null==e?void 0:e.version),Te.appStateController.setPendingExtensionVersion((null==e?void 0:e.version)??null)});(async()=>{if(null!==i.default&&void 0!==i.default&&i.default.sidePanel)try{var e,t;await Ne;const r=(null===(e=Te)||void 0===e||null===(e=e.preferencesController)||void 0===e||null===(e=e.state)||void 0===e||null===(e=e.preferences)||void 0===e?void 0:e.useSidePanelAsDefault)??!1;null!==i.default&&void 0!==i.default&&null!==(t=i.default.sidePanel)&&void 0!==t&&t.setPanelBehavior&&await i.default.sidePanel.setPanelBehavior({openPanelOnActionClick:r})}catch(e){console.error("Error setting side panel behavior:",e)}})();(async()=>{if(null!==i.default&&void 0!==i.default&&i.default.sidePanel)try{var e;await Ne,null===(e=Te)||void 0===e||null===(e=e.controllerMessenger)||void 0===e||e.subscribe("PreferencesController:stateChange",e=>{var t,r;const n=(null==e||null===(t=e.preferences)||void 0===t?void 0:t.useSidePanelAsDefault)??!1;null!==i.default&&void 0!==i.default&&null!==(r=i.default.sidePanel)&&void 0!==r&&r.setPanelBehavior&&i.default.sidePanel.setPanelBehavior({openPanelOnActionClick:n}).catch(e=>console.error("Error updating panel behavior:",e))})}catch(e){console.error("Error setting up preference listener:",e)}})();async function Ze(e){i.default.tabs.onActivated.addListener(e=>{if(Te){const{tabId:t}=e,r=Oe[t],n=ke[t];r&&Te.permissionController.state.subjects[r]!==undefined&&Ge(r);const i=(0,C.getPartnerByOrigin)(n);i&&Te.permissionController.state.subjects[n]!==undefined&&Te.handleDefiReferral(i,t,ee.ReferralTriggerType.OnNavigateConnectedTab).catch(e=>{o.default.error(`Failed to handle ${i.name} referral after navigation to connected tab: `,e)})}});try{await We(e),le.cleanUpMostRecentRetrievedState(),o.default.info("MetaMask initialization complete."),Ie()}catch(e){o.default.error(e),je(e)}}(async()=>{await qe()})(),i.default.tabs.onActivated.addListener(async({tabId:e})=>{if(await Ne,!Te)return{};try{const t=await i.default.tabs.get(e),{id:r,title:n,url:o,favIconUrl:s}=t;if(!o)return Te.appStateController.clearAppActiveTab(),{};const{origin:a,protocol:l,host:c,href:u}=new URL(o);if(!(0,B.isWebOrigin)(a))return Te.appStateController.clearAppActiveTab(),{};Te.appStateController.setAppActiveTab({id:r,title:n,origin:a,protocol:l,url:o,host:c,href:u,favIconUrl:s}),Te.subjectMetadataController.addSubjectMetadata({origin:a,name:n||c||a,iconUrl:s||null,subjectType:"website"})}catch(e){console.log("Error in tabs.onActivated listener:",e.message)}return{}}),i.default.tabs.onUpdated.addListener(async(e,t,r)=>{if(await Ne,!Te)return{};const n=t.url!==undefined,o="complete"===t.status;if(!n&&!o)return{};try{const t=r||await i.default.tabs.get(e),{id:s,title:a,url:l,favIconUrl:c}=t,u=Te.appStateController.state.appActiveTab,d=(null==u?void 0:u.id)===s;if(!l)return d&&Te.appStateController.clearAppActiveTab(),{};const{origin:f,protocol:p,host:h,href:m}=new URL(l);if(!f||"null"===f||f.startsWith("chrome-extension://")||f.startsWith("moz-extension://"))return d&&Te.appStateController.clearAppActiveTab(),{};let g=!1;try{g=(await i.default.tabs.query({active:!0,currentWindow:!0})).some(e=>e.id===s)}catch(e){g=d}(n||o)&&g&&(Te.appStateController.setAppActiveTab({id:s,title:a,origin:f,protocol:p,url:l,host:h,href:m,favIconUrl:c}),Te.subjectMetadataController.addSubjectMetadata({origin:f,name:a||h||f,iconUrl:c||null,subjectType:"website"}))}catch(e){console.log("Error in tabs.onUpdated listener:",e.message)}return{}}),Ze(null)}}},{package:"$root$",file:"app/scripts/background.js"}]],[9],{});