LavaPack.loadBundle([[918,{_process:6002},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[l(JSON.stringify({alg:"none",type:"JWT"})),l(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 f(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=f,r.errorPrefix=O,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(O(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(O(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(O(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,c=a?e[t+2]:0,l=o>>2,u=(3&o)<<4|s>>4;let f=(15&s)<<2|c>>6,d=63&c;a||(d=64,i||(f=64)),n.push(r[l],r[u],r[f],r[d])}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 c=t<e.length?r[e.charAt(t)]:64;if(++t,null==o||null==i||null==s||null==c)throw new a;const l=o<<2|i>>4;if(n.push(l),64!==s){const e=i<<4&240|s>>2;if(n.push(e),64!==c){const e=s<<6&192|c;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 c=function(e){const t=i(e);return s.encodeByteArray(t,!0)};r.base64Encode=c;const l=function(e){return c(e).replace(/\./g,"")};r.base64urlEncodeWithoutPadding=l;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 f(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)&&d(r)&&(e[r]=f(e[r],t[r]));return e}function d(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 S extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,S.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,E.prototype.create)}}r.FirebaseError=S;class E{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 S(n,s,r)}}r.ErrorFactory=E;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],c=this.chain_[3],l=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(n=c^s&(a^c),o=1518500249):(n=s^a^c,o=1859775393):e<60?(n=s&a|c&(s|a),o=2400959708):(n=s^a^c,o=3395469782);const t=(i<<5|i>>>27)+n+l+o+r[e]&4294967295;l=c,c=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]+c&4294967295,this.chain_[4]=this.chain_[4]+l&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=k),n.error===undefined&&(n.error=k),n.complete===undefined&&(n.complete=k);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 k(){}
/**
 * @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 O(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"}],[919,{},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"}],[92,{"@metamask/messenger":2783},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getBridgeStatusControllerMessenger=function(e){const t=new n.Messenger({namespace:"BridgeStatusController",parent:e});return e.delegate({messenger:t,actions:["AccountsController:getAccountByAddress","AuthenticationController:getBearerToken","NetworkController:getNetworkClientById","NetworkController:findNetworkClientIdByChainId","NetworkController:getState","KeyringController:signTypedMessage","BridgeController:trackUnifiedSwapBridgeEvent","BridgeController:stopPollingForQuotes","GasFeeController:getState","SnapController:handleRequest","TransactionController:getState","TransactionController:isAtomicBatchSupported","TransactionController:addTransaction","TransactionController:estimateGasFee","TransactionController:updateTransaction"],events:["TransactionController:transactionFailed","TransactionController:transactionConfirmed"]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/bridge-status-controller-messenger.ts"}],[920,{"@json-schema-tools/reference-resolver":925,"@json-schema-tools/traverse":928,"fast-safe-stringify":5269},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{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((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(c){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,c])}}},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")),c=s(e("@json-schema-tools/reference-resolver")),l=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,l.default)(e))].join("\n")};r.NonStringRefError=u;var f=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},d=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];c.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,l,u,d,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?(l=s[o],u=void 0,this.refCache[l]===undefined?[3,2]:(u=this.refCache[l],[3,5])):[3,11];case 2:if("#"!==l)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 d=c.default.resolve(l,this.options.rootSchema),r.push(d),[4,d];case 4:u=i.sent(),i.label=5;case 5:return!0!==this.options.recursive||!0===u||!1===u||"#"===l?[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[l]=f(u,g),[3,8];case 7:this.refCache[l]=u,i.label=8;case 8:return[3,10];case 9:this.refCache[l]=u,i.label=10;case 10:return o++,[3,1];case 11:return this.schema.$ref!==undefined?this.schema=f(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 f(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=d}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer",file:"node_modules/@json-schema-tools/dereferencer/build/dereferencer.js"}],[921,{"./dereferencer":920},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"}],[922,{},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"}],[923,{"./errors":924,"isomorphic-fetch":5498},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{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((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(c){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,c])}}},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")),c=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:c,http:c}}}},{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"}],[924,{},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"}],[925,{"./default-protocol-handler-map":923,"./reference-resolver":926},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{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((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(c){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,c])}}},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")),c=s(e("./reference-resolver")),l=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 c.default(l)}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/index-web.js"}],[926,{"./errors":924,"./resolve-pointer":927},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{c(n.next(e))}catch(e){i(e)}}function a(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(s,a)}c((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(c){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,c])}}},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")),c=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,c,l,u,f,d,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 c=o.sent(),[3,4];case 3:throw l=o.sent(),new s.NonJsonRefError({$ref:e},l.message);case 4:if(c!==undefined)return h=c,n&&(h=(0,a.default)(n,h)),[2,h];if(!1===e.includes("://"))throw new s.InvalidFileSystemPathError(e);u=0,f=Object.keys(this.protocolHandlerMap),o.label=5;case 5:return u<f.length?(d=f[u],i.startsWith(d)?[4,this.protocolHandlerMap[d](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=c}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/reference-resolver.js"}],[927,{"@json-schema-spec/json-pointer":919},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"}],[928,{},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,c,l,u,f,d,p,h,m){void 0===l&&(l=r.defaultOptions),void 0===u&&(u=0),void 0===f&&(f=[]),void 0===d&&(d=[]),void 0===p&&(p=[]),void 0===h&&(h=[]),void 0===m&&(m=[]);var g=n(n({},r.defaultOptions),l);if(0===u&&(p=[""]),"boolean"==typeof t||t instanceof Boolean)return!0===g.skipFirstMutation&&0===u?t:c(t,!1,i(p),a(d));var b=t;!1===g.mutable&&(b=n({},t)),d.push(b),!0===g.bfs&&(!1!==g.skipFirstMutation&&0===u||(b=c(b,!1,i(p),a(d,2)))),f.push(t),h.push([t,b]);var v=function(t,r){var n=s(t,f);return n?(m.push(n),!0===g.skipFirstMutation&&n===f[0]?c(t,!0,i(r),a(d)):h.find(function(e){var t=e[0];return n===t})[1]):e(t,c,l,u+1,f,d,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,f);if(y)if(m.push(y),!0===g.skipFirstMutation&&y===f[0])b.items=c(t.items,!0,i(p),a(d));else{var S=h.find(function(e){var t=e[0];return y===t})[1];b.items=S}else b.items=e(t.items,c,l,u+1,f,d,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 E=t.properties,w={};Object.keys(t.properties).forEach(function(e){w[e]=v(E[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 d.pop(),b;var C=-1!==m.indexOf(t);return d.pop(),c(b,C,i(p),a(d))}}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/dereferencer>@json-schema-tools/traverse",file:"node_modules/@json-schema-tools/traverse/build/index.js"}],[93,{"@metamask/messenger":2783},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getClaimsControllerInitMessenger=function(e){const t=new n.Messenger({namespace:"ClaimsControllerInit",parent:e});return e.delegate({messenger:t,events:[],actions:[]}),t},r.getClaimsControllerMessenger=function(e){const t=new n.Messenger({namespace:"ClaimsController",parent:e});return e.delegate({messenger:t,actions:["ClaimsService:fetchClaimsConfigurations","ClaimsService:getClaimsApiUrl","ClaimsService:getRequestHeaders","ClaimsService:generateMessageForClaimSignature","ClaimsService:getClaims","KeyringController:signPersonalMessage"],events:[]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/claims/claims-controller-messenger.ts"}],[94,{"@metamask/messenger":2783},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.getClaimsServiceInitMessenger=function(e){return new n.Messenger({namespace:"ClaimsServiceInit",parent:e})},r.getClaimsServiceMessenger=function(e){const t=new n.Messenger({namespace:"ClaimsService",parent:e});return e.delegate({messenger:t,actions:["AuthenticationController:getBearerToken"],events:[]}),t};var n=e("@metamask/messenger")}}},{package:"$root$",file:"app/scripts/controller-init/messengers/claims/claims-service-messenger.ts"}],[95,{"@metamask/messenger":2783},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"}],[96,{"./connectivity-controller-messenger":95},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"}],[97,{"@metamask/messenger":2783},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"}],[98,{"@metamask/messenger":2783},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"}],[99,{"./account-activity-service-messenger":97,"./backend-websocket-service-messenger":98},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"}],[10,{"../../shared/constants/app":7071,"../../shared/constants/defi-referrals":7077,"../../shared/constants/errors":7078,"../../shared/constants/infura-project-id":7083,"../../shared/constants/messages":7088,"../../shared/constants/metametrics":7089,"../../shared/constants/offscreen-communication":7095,"../../shared/constants/onboarding":7096,"../../shared/constants/start-up-errors":7106,"../../shared/constants/ui-initialization":7114,"../../shared/lib/browser-runtime.utils":7131,"../../shared/lib/caip-stream":7133,"../../shared/lib/deep-links/utils":7168,"../../shared/lib/fetch-with-timeout":7199,"../../shared/lib/get-first-preferred-lang-code":7206,"../../shared/lib/manifestFlags":7211,"../../shared/lib/mv3.utils":7220,"../../shared/lib/object.utils":7223,"../../shared/lib/promise-with-resolvers":7226,"../../shared/lib/selectors/networks":7235,"../../shared/lib/sentry":7240,"./constants/marketing-site-whitelist":11,"./constants/sentry-state":12,"./constants/snaps":13,"./constants/stream":14,"./first-time-state":265,"./lib/CronjobControllerStorageManager":269,"./lib/createDefiReferralMiddleware":278,"./lib/deep-links/deep-link-router":293,"./lib/deep-links/metrics":294,"./lib/ens-ipfs/setup":300,"./lib/extension-lazy-listener/extension-lazy-listener":301,"./lib/getObjStructure":303,"./lib/migrator":309,"./lib/notification-manager":313,"./lib/safe-reload":342,"./lib/setup-initial-state-hooks":346,"./lib/start-up-errors/start-up-errors":358,"./lib/state-corruption/state-corruption-recovery":359,"./lib/stores/persistence-manager":366,"./lib/stream-utils":368,"./lib/update-remote-feature-flags":402,"./lib/use-split-state-storage":403,"./lib/util":404,"./metamask-controller":405,"./migrations":640,"./offscreen":641,"./on-update":642,"./platforms/extension":643,"@metamask/base-controller":1580,"@metamask/design-tokens":2090,"@metamask/utils":3786,"extension-port-stream":5254,loglevel:5696,"readable-stream":6160,"webextension-polyfill":6982},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.loadStateFromPersistence=Ge,r.setupController=Xe;var n=e("./lib/setup-initial-state-hooks");e("../../shared/constants/infura-project-id");var o=e("@metamask/design-tokens"),i=e("readable-stream"),s=oe(e("loglevel")),a=oe(e("webextension-polyfill")),c=e("@metamask/utils"),l=e("@metamask/base-controller"),u=e("extension-port-stream"),f=e("../../shared/lib/promise-with-resolvers"),d=e("../../shared/constants/onboarding"),p=e("../../shared/constants/app"),h=e("../../shared/constants/messages"),m=e("../../shared/constants/ui-initialization"),g=e("../../shared/constants/metametrics"),b=e("../../shared/lib/browser-runtime.utils"),v=e("../../shared/lib/mv3.utils"),y=e("../../shared/lib/object.utils"),S=(e("../../shared/constants/offscreen-communication"),e("../../shared/lib/sentry")),E=e("../../shared/lib/selectors/networks"),w=e("../../shared/lib/caip-stream"),_=oe(e("../../shared/lib/fetch-with-timeout")),M=e("../../shared/constants/errors"),C=oe(e("../../shared/lib/get-first-preferred-lang-code")),T=(e("../../shared/lib/manifestFlags"),e("../../shared/constants/start-up-errors")),k=e("../../shared/constants/defi-referrals"),O=e("../../shared/lib/deep-links/utils"),A=e("./lib/state-corruption/state-corruption-recovery"),P=e("./lib/stores/persistence-manager"),N=e("./lib/use-split-state-storage"),I=oe(e("./migrations")),j=oe(e("./lib/migrator")),R=e("./lib/update-remote-feature-flags"),x=oe(e("./platforms/extension")),L=e("./constants/sentry-state"),D=ne(e("./lib/notification-manager")),$=ne(e("./metamask-controller")),U=oe(e("./lib/getObjStructure")),B=oe(e("./lib/ens-ipfs/setup")),F=e("./lib/util"),V=e("./offscreen"),W=e("./lib/stream-utils"),K=oe(e("./first-time-state")),z=e("./on-update"),G=e("./constants/marketing-site-whitelist"),J=e("./constants/stream"),H=e("./constants/snaps"),q=e("./lib/extension-lazy-listener/extension-lazy-listener"),Y=e("./lib/deep-links/deep-link-router"),X=e("./lib/deep-links/metrics"),Q=e("./lib/safe-reload"),Z=e("./lib/start-up-errors/start-up-errors"),ee=e("./lib/CronjobControllerStorageManager"),te=e("./lib/createDefiReferralMiddleware");function re(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(re=function(e){return e?r:t})(e)}function ne(e,t){if(!t&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var r=re(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 oe(e){return e&&e.__esModule?e:{default:e}}const ie=globalThis.stateHooks.lazyListener??new q.ExtensionLazyListener(a.default),se="#0376C9",ae=o.lightTheme.colors.error.default,ce=9,{safePersist:le,requestSafeReload:ue,evacuate:fe}=(0,Q.getRequestSafeReload)(n.persistenceManager);global.stateHooks.getMostRecentPersistedState=()=>n.persistenceManager.mostRecentRetrievedState,global.stateHooks.getStorageKind=()=>n.persistenceManager.storageKind,global.logEncryptedVault=()=>{n.persistenceManager.logEncryptedVault()};const{sentry:de}=global;let pe={...K.default};const he={[p.ENVIRONMENT_TYPE_POPUP]:!0,[p.ENVIRONMENT_TYPE_NOTIFICATION]:!0,[p.ENVIRONMENT_TYPE_FULLSCREEN]:!0},me=["trezor-connect"];s.default.setLevel("info",!1);const ge=new x.default,be=new D.default,ve=(0,F.getPlatform)()===p.PLATFORM_FIREFOX;function ye(e){const t=e.name,r=e.sender?.url?new URL(e.sender.url):null;let n;return n=ve?Boolean(he[t]):r?.origin===`chrome-extension://${a.default.runtime.id}`,{processName:t,senderUrl:r,isMetaMaskUIPort:n}}let Se=0,Ee=!1,we=!1,_e=0,Me=0;const Ce={},Te={};let ke;const Oe={},Ae={};const Pe=new URL("https://metamask.github.io/phishing-warning/v5.1.0/"),Ne=Pe.toString();let Ie,je,Re;function xe(){const e=(0,f.withResolvers)();Ie=e.promise,je=e.resolve,Re=e.reject}ie.once("runtime","onInstalled").then(e=>{!async function([e]){if("install"===e.reason)await async function(){s.default.debug("First install detected"),ge.openExtensionInBrowser();await Ze()}();else if("update"===e.reason){const{previousVersion:t}=e;if(!t||t===ge.getVersion())return;await Ie,(0,z.onUpdate)(ke,ge,t,ue)}}(e)}),xe();let Le,De,$e,Ue;const Be=new A.CorruptionHandler,Fe=async 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)}try{await Ie,Le(e)}catch(t){if(de?.captureException(t),ye(e).isMetaMaskUIPort)if((0,M.isStateCorruptionError)(t))await Be.handleStateCorruptionError({port:e,error:t,database:n.persistenceManager,repairCallback:async e=>{xe(),(0,A.hasVault)(e)?(await et(e),ke.onboardingController.setFirstTimeFlowType(d.FirstTimeFlowType.restore)):(await n.persistenceManager.reset(),await et(null))}});else{const r=(0,c.isObject)(t)?{message:t.message??"Unknown error",name:t.name??"UnknownError",stack:t.stack,...t.sentryTags&&{sentryTags:t.sentryTags}}:{message:String(t),name:"UnknownError",stack:""};(0,Z.tryPostMessage)(e,T.DISPLAY_GENERAL_STARTUP_ERROR,{error:r,currentLocale:ke?.preferencesController?.state?.currentLocale})}}},Ve=()=>{ie.addListener("runtime","onConnect",Fe)};function We(){const e=(new Date).toISOString();a.default.storage.session.set({timestamp:e})}async function Ke(e){(0,F.initInstallType)();const t=v.isManifestV3?(0,V.createOffscreen)():null;let r=null,o=!1;v.isManifestV3&&(0,V.addOffscreenConnectivityListener)(e=>{if(o&&ke.controllerApi.setConnectivityStatus){const t=e?"online":"offline";ke.controllerApi.setConnectivityStatus(t)}else r=e});const i=await Ge(e),s=i.data,c=await(0,C.default)();let l;if(v.isManifestV3){if(!1!==s.PreferencesController?.enableMV3TimestampSave){const e=2e3;We(),setInterval(We,e)}const e=await a.default.storage.session.get(["isFirstMetaMaskControllerSetup"]);l=e?.isFirstMetaMaskControllerSetup===undefined,await a.default.storage.session.set({isFirstMetaMaskControllerSetup:l})}const u={},f=await async function(){const e=(0,_.default)(),t=H.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)}(),d=new ee.CronjobControllerStorageManager;if(await d.init(),Xe(s,c,u,l,i.meta,t,f,d),ke.metaMetricsController.updateTraits({[g.MetaMetricsUserTrait.StorageKind]:n.persistenceManager.storageKind}),function(e){async function t(e,t){try{const r=await a.default.tabs.get(e);return!(r.url&&r.url.startsWith("https://www.google.com/search")||(await a.default.tabs.update(e,{url:t}),0))}catch(e){return de?.captureException(e),!1}}const r=!v.isManifestV3;a.default.webRequest.onBeforeRequest.addListener(n=>{if(n.tabId===a.default.tabs.TAB_ID_NONE)return{};const{completedOnboarding:o}=e.onboardingController.state;if(!o)return{};if(!e.preferencesController.state.usePhishDetect)return{};if(n.initiator&&"null"!==n.initiator&&new URL(n.initiator).host===Pe.host)return{};const{hostname:i,href:s,searchParams:c}=new URL(n.url);e.phishingController.maybeUpdateState();const l=e.phishingController.isBlockedRequest(n.url);let u,f;if("main_frame"!==n.type&&"sub_frame"!==n.type||(u=e.phishingController.test(n.url)),!u?.result&&!l.result)return{};let d,p=s;u?.result&&l.result?f=`${u.type} and ${l.type}`:u?.result?f=u.type:(f=l.type,p=n.initiator);try{d=new URL(p).hostname}catch{d=i,p=s}const h=new URLSearchParams({hostname:d,href:p}),m=new URL(Ne);m.hash=h.toString();const b=m.toString(),v=()=>{ve||e.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.PhishingPageDisplayed,category:g.MetaMetricsEventCategory.Phishing,properties:{url:p,referrer:{url:p},reason:f,requestDomain:l.result?i:undefined}},{excludeMetaMetricsId:!0})};return r?"main_frame"===n.type?(v(),{redirectUrl:b}):(t(n.tabId,b).then(e=>{e&&v()}),{cancel:!0}):(t(n.tabId,b).then(e=>{e&&v()}),{})},{urls:["http://*/*","https://*/*","ws://*/*","wss://*/*"]},r?["blocking"]:[])}(ke),v.isManifestV3){if(o=!0,null!==r){const e=r?"online":"offline";ke.controllerApi.setConnectivityStatus(e)}}else{const e=e=>{const t=e?"online":"offline";ke.controllerApi.setConnectivityStatus(t)};e(globalThis.navigator.onLine),globalThis.addEventListener("online",()=>e(!0)),globalThis.addEventListener("offline",()=>e(!1))}v.isManifestV3||await async function(){let e;try{const t=new URL(Ne);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 ze),1e3),await o}catch(e){e instanceof ze?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 a.default.tabs.query({url:"<all_urls>",windowType:"normal"}).then(e=>((0,b.checkForLastErrorAndLog)(),e)).catch(()=>{(0,b.checkForLastErrorAndLog)()});for(const t of e)a.default.tabs.sendMessage(t.id,{name:h.EXTENSION_MESSAGES.READY}).then(()=>{(0,b.checkForLastErrorAndLog)()}).catch(()=>{(0,b.checkForLastErrorAndLog)()})})(),new Y.DeepLinkRouter({getExtensionURL:ge.getExtensionURL,getState:ke.getState.bind(ke)}).on("navigate",async({url:e,parsed:t})=>{"redirectTo"in t||await ke.metaMetricsController.trackEvent((0,X.createEvent)({signature:t.signature,url:e}))}).on("error",e=>de?.captureException(e)).install()}Ve(),a.default.runtime.onConnectExternal.addListener(async(...e)=>{await Ie,De(...e)});class ze extends Error{constructor(){super("Timeout failed")}}async function Ge(e){let t;if(e){t={data:{},meta:{}};for(const r of P.backedUpStateKeys)(0,c.hasProperty)(e,r)&&(t.data[r]=e[r]);(0,c.hasProperty)(e,"meta")&&(0,c.isObject)(e.meta)&&(t.meta=e.meta,"split"===e.meta.storageKind||"data"===e.meta.storageKind?n.persistenceManager.storageKind=e.meta.storageKind:n.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 n.persistenceManager.get({validateVault:e})}const r=new j.default({migrations:I.default,defaultVersion:null});r.on("error",e=>{console.warn(e);const r=(0,U.default)(t);de?.captureException(e,{extra:{vaultStructure:r}})});let o=!1;t?.data||t?.meta||(o=!0,t=r.generateInitialState(pe));const{state:i,changedKeys:a}=await r.migrateData(t),l=async r=>{const o=t?.meta?.version,s="number"==typeof o&&o>=157;let a=e?.AppMetadataController?.firstTimeInfo??i?.data?.AppMetadataController?.firstTimeInfo??i?.data?.firstTimeInfo??t?.data?.AppMetadataController?.firstTimeInfo??t?.data?.firstTimeInfo;if(!a)try{const e=await n.persistenceManager.getBackup();a=e?.AppMetadataController?.firstTimeInfo}catch{}const c=new Error(r);return c.sentryTags={"corruption.preMigrationVersion":String(o??"unknown"),"corruption.backupShouldExist":String(s),"corruption.installVersion":String(a?.version??"unknown"),"corruption.installDate":String(a?.date??"unknown")},c};if(!i)throw await l("MetaMask - migrator returned undefined");if(!(0,c.isObject)(i.meta))throw await l(`MetaMask - migrator metadata has invalid type '${typeof i.meta}'`);if("number"!=typeof i.meta.version)throw await l(`MetaMask - migrator metadata version has invalid type '${typeof i.meta.version}'`);if(!["data","split",undefined].includes(i.meta.storageKind))throw await l(`MetaMask - migrator metadata storageKind has invalid value '${i.meta.storageKind}'`);if(!(0,c.isObject)(i.data))throw await l(`MetaMask - migrator data has invalid type '${typeof i.data}'`);if(n.persistenceManager.setMetadata(i.meta),s.default.debug("[Split State]: Loaded data from persistence with storageKind '%s'",n.persistenceManager.storageKind),"data"===n.persistenceManager.storageKind){const e=!0===i.meta.platformSplitStateGradualRolloutAttempted,t=!e&&await(0,N.useSplitStateStorage)(i.data);s.default.debug("[Split State]: shouldUseSplitStateStorage: %s (alreadyTried: %s)",t,e),t&&(i.meta.platformSplitStateGradualRolloutAttempted=!0,n.persistenceManager.setMetadata(i.meta)),s.default.debug("[Split State]: Writing data to persistence with storageKind 'data'"),await n.persistenceManager.set(i.data),t&&(await n.persistenceManager.migrateToSplitState(i.data),i.meta=n.persistenceManager.getMetaData(),i.meta!==undefined&&(delete i.meta.platformSplitStateGradualRolloutAttempted,n.persistenceManager.setMetadata(i.meta)),await n.persistenceManager.persist())}else{if("split"!==n.persistenceManager.storageKind)throw new Error(`MetaMask - persistenceManager has invalid storageKind '${n.persistenceManager.storageKind}'`);if(o)for(const[e,t]of Object.entries(i.data))n.persistenceManager.update(e,t);else for(const e of a)n.persistenceManager.update(e,i.data[e]);await n.persistenceManager.persist()}return s.default.debug("[Split State]: Load complete."),i}function Je(e){const{metaMetricsId:t}=ke.metaMetricsController.state;if(!(0,F.shouldEmitDappViewedEvent)(t))return;const r=ke.getPermittedAccounts(e).length;if(0===r)return;const n=ke.controllerMessenger.call("AccountsController:getState"),o=Object.keys(n.internalAccounts.accounts).length;ke.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.DappViewed,category:g.MetaMetricsEventCategory.InpageProvider,referrer:{url:e},properties:{is_first_visit:!1,number_of_accounts:o,number_of_accounts_connected:r}},{excludeMetaMetricsId:!0})}function He(e){if(!e.sender?.tab||!e.sender?.url||!e.sender?.tab?.url)return;const t=e.sender.tab.id,r=new URL(e.sender.url),{origin:n}=r,o=new URL(e.sender.tab.url),{origin:i}=o;Object.keys(Oe).includes(t)||(Oe[t]=n),t in Ae||(Ae[t]=i);const s=ke.controllerMessenger.call("PermissionController:hasPermissions",n),a="New Tab"!==e.sender.tab.title;s&&a&&Je(n)}function qe(e){const t=[p.ENVIRONMENT_TYPE_POPUP,p.ENVIRONMENT_TYPE_NOTIFICATION,p.ENVIRONMENT_TYPE_FULLSCREEN];!(Object.values(Ce).some(Boolean)||Ee||Se>0||_e>0)&&t.includes(e)&&function(){const{metaMetricsId:e,participateInMetaMetrics:t}=ke.metaMetricsController.state;(null!==e||t)&&ke.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.AppOpened,category:g.MetaMetricsEventCategory.App})}()}const Ye=async()=>{if(await Ie,ke)try{const e=await a.default.tabs.query({active:!0,currentWindow:!0});if(!e||0===e.length)return;const t=e[0],{id:r,title:n,url:o,favIconUrl:i}=t;if(!o)return void ke.appStateController.clearAppActiveTab();const{origin:s,protocol:c,host:l,href:u}=new URL(o);if(!(0,F.isWebOrigin)(s))return void ke.appStateController.clearAppActiveTab();ke.appStateController.setAppActiveTab({id:r,title:n,origin:s,protocol:c,url:o,host:l,href:u,favIconUrl:i}),ke.subjectMetadataController.addSubjectMetadata({origin:s,name:n||l||s,iconUrl:i||null,subjectType:"website"})}catch(e){console.log("Error refreshing appActiveTab:",e.message)}};function Xe(e,t,r,o,c,f,d,h){ke=new $.default({infuraProjectId:globalThis.INFURA_PROJECT_ID,showUserConfirmation:Qe,initState:e,initLangCode:t,platform:ge,notificationManager:be,browser:a.default,getRequestAccountTabIds:()=>Te,getOpenMetamaskTabsIds:()=>Ce,overrides:r,isFirstMetaMaskControllerSetup:o,currentMigrationVersion:c.version,featureFlags:{},offscreenPromise:f,preinstalledSnaps:d,requestSafeReload:ue,cronjobControllerStorageManager:h}),n.persistenceManager.setOnSetFailed(e=>{ke.appStateController.setStorageWriteErrorType(e)});const m=[],b=ke.store.getState();for(const t of Object.keys(b)){const r=e[t]||{},n=b[t];if(null===n||"object"!=typeof n){(0,S.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 _;"split"===n.persistenceManager.storageKind?(m.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${m.join(", ")}. Persisting updated state.`),m.forEach(e=>{n.persistenceManager.update(e,b[e])}),le().catch(e=>{s.default.error("Error persisting updated state:",e),de?.captureException(e)})),ke.store.on("stateChange",async({controllerKey:e,newState:t,_oldState:r,_patches:o})=>{n.persistenceManager.update(e,t),P.backedUpStateKeys.includes(e)&&P.backedUpStateKeys.forEach(t=>{if(t===e)return;const r=ke.store.config[t];if(!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 o=ke.controllerMessenger.call(`${t}:getState`),i=(0,l.deriveStateFromMetadata)(o,r.metadata,"persist");n.persistenceManager.update(t,i)});try{await le()}catch(e){s.default.error("Error persisting state change:",e),de?.captureException(e)}})):(m.length>0&&(s.default.info(`MetaMaskController state changed during configuration for controllers: ${m.join(", ")}. Persisting updated state.`),le(b).catch(e=>{s.default.error("Error persisting updated controller state:",e),de?.captureException(e)})),ke.store.on("update",le)),ke.store.on("error",e=>{s.default.error("MetaMask controller.store error:",e),de?.captureException(e)}),(0,B.default)({getCurrentChainId:()=>(0,E.getCurrentChainId)({metamask:ke.networkController.state}),getIpfsGateway:ke.preferencesController.getIpfsGateway.bind(ke.preferencesController),getUseAddressBarEnsResolution:()=>ke.preferencesController.state.useAddressBarEnsResolution,provider:ke.provider}),_=ke,global.stateHooks.getSentryAppState=function(){const e=_.memStore.getState();return(0,y.maskObject)(e,L.SENTRY_BACKGROUND_STATE)};const M=()=>Se>0||Boolean(Object.keys(Ce).length)||Ee||_e>0||!1,C=(e,t)=>{if(!1===e)ke.onClientClosed();else{if(t===p.ENVIRONMENT_TYPE_FULLSCREEN&&Boolean(Object.keys(Ce).length)||t===p.ENVIRONMENT_TYPE_SIDEPANEL&&_e>0)return;ke.onEnvironmentTypeClosed(t)}};function T(){Me+=1;const e=ve?"popup.html":"popup-init.html";try{v.isManifestV3?a.default.action.setPopup({popup:`${e}?tab=activity`}):a.default.browserAction.setPopup({popup:`${e}?tab=activity`})}catch(e){console.error("Error setting failed tx badge popup:",e)}A()}function k(){if(!Me)return;Me=0;const e=ve?"popup.html":"popup-init.html";try{v.isManifestV3?a.default.action.setPopup({popup:e}):a.default.browserAction.setPopup({popup:e})}catch(e){console.error("Error clearing failed tx badge popup:",e)}A()}function O(e,t){return e>t?`${t}+`:String(e)}function A(){const e=N();let t="",r=se;e?t=O(e,ce):Me&&(t=O(Me,ce),r=ae);try{const e={text:t},n={color:r};v.isManifestV3?(a.default.action.setBadgeText(e),a.default.action.setBadgeBackgroundColor(n)):(a.default.browserAction.setBadgeText(e),a.default.browserAction.setBadgeBackgroundColor(n))}catch(e){console.error("Error updating browser badge:",e)}}function N(){try{return ke.appStateController.waitingForUnlock.length+ke.approvalController.getTotalApprovalCount()}catch(e){return console.error("Failed to get pending approval count:",e),0}}Le=e=>{if(me.includes(e.name))return;const{processName:t,senderUrl:n,isMetaMaskUIPort:o}=ye(e);if(o){const n=r?.getPortStream?.(e)||new u.ExtensionPortStream(e),o=function({chunkSize:e}){ke.metaMetricsController.trackEvent({event:g.MetaMetricsEventName.PortStreamChunked,category:g.MetaMetricsEventCategory.PortStream,properties:{chunkSize:e}})};if(e.onDisconnect.addListener(()=>n.off("message-too-large",o)),n.on("message-too-large",o),ke.isClientOpen=!0,ke.setupTrustedCommunication(n,e.sender),qe(t),(0,R.updateRemoteFeatureFlags)(ke),t===p.ENVIRONMENT_TYPE_POPUP&&(k(),Se+=1,(0,i.finished)(n,()=>{Se-=1;const e=M();ke.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_POPUP)})),t===p.ENVIRONMENT_TYPE_SIDEPANEL&&(k(),_e+=1,Ye(),(0,i.finished)(n,()=>{_e=Math.max(_e-1,0);const e=M();ke.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_SIDEPANEL)})),t===p.ENVIRONMENT_TYPE_NOTIFICATION&&(Ee=!0,(0,i.finished)(n,()=>{Ee=!1;const e=M();ke.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_NOTIFICATION)})),t===p.ENVIRONMENT_TYPE_FULLSCREEN){const t=e.sender.tab.id;Ce[t]=!0,(0,i.finished)(n,()=>{delete Ce[t];const e=M();ke.isClientOpen=e,C(e,p.ENVIRONMENT_TYPE_FULLSCREEN)})}}else if(n&&n.origin===Pe.origin&&n.pathname===Pe.pathname){const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});ke.setupPhishingCommunication({connectionStream:t})}else{if(e.sender&&e.sender.tab&&e.sender.url){const t=e.sender.tab.id,r=new URL(e.sender.url),{origin:n}=r;He(e),e.onMessage.addListener(e=>{e.data&&e.data.method===p.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS&&(Te[n]=t)})}if(n&&G.COOKIE_ID_MARKETING_WHITELIST_ORIGINS.some(e=>e===n.origin)){const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});ke.setUpCookieHandlerCommunication({connectionStream:t})}const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});if($e(t,e.sender),ve||!v.isManifestV3){const r=(0,W.setupMultiplex)(t);r.ignoreStream(J.METAMASK_EIP_1193_PROVIDER),Ue(r.createStream(J.METAMASK_CAIP_MULTICHAIN_PROVIDER),e.sender)}}},De=e=>{const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});if(!e.sender.id){if(me.includes(e.name))return;He(e),Ue((0,w.createCaipStream)(t),e.sender)}else $e(t,e.sender)},$e=(e,t)=>{ke.setupUntrustedCommunicationEip1193({connectionStream:e,sender:t})},Ue=(e,t)=>{ke.setupUntrustedCommunicationCaip({connectionStream:e,sender:t})},r?.registerConnectListeners&&r.registerConnectListeners(Le,$e),A(),ke.controllerMessenger.subscribe($.METAMASK_CONTROLLER_EVENTS.DECRYPT_MESSAGE_MANAGER_UPDATE_BADGE,A),ke.controllerMessenger.subscribe($.METAMASK_CONTROLLER_EVENTS.ENCRYPTION_PUBLIC_KEY_MANAGER_UPDATE_BADGE,A),ke.signatureController.hub.on($.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,A),ke.controllerMessenger.subscribe($.METAMASK_CONTROLLER_EVENTS.APP_STATE_UNLOCK_CHANGE,A),ke.controllerMessenger.subscribe($.METAMASK_CONTROLLER_EVENTS.APPROVAL_STATE_CHANGE,A),ke.controllerMessenger.subscribe($.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_LIST_UPDATED,A),ke.controllerMessenger.subscribe($.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_MARK_AS_READ,A),ke.controllerMessenger.subscribe("TransactionController:transactionFailed",T),ke.controllerMessenger.subscribe("TransactionController:transactionDropped",T),be.on(D.NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,({automaticallyClosed:e})=>{e?N()>0&&Qe():(ke.signatureController.rejectUnapproved(g.REJECT_NOTIFICATION_CLOSE_SIG),ke.decryptMessageController.rejectUnapproved(g.REJECT_NOTIFICATION_CLOSE),ke.encryptionPublicKeyController.rejectUnapproved(g.REJECT_NOTIFICATION_CLOSE),ke.rejectAllPendingApprovals()),A()})}async function Qe(){const e=await ge.getActiveTabs(),t=Boolean(e.find(e=>Ce[e.id])),r=e.length>0&&e[0].extData&&e[0].extData.indexOf("vivaldi_tab")>-1;if(!we&&(r||0===Se)&&!t&&0===_e){we=!0;try{const e=ke.appStateController.getCurrentPopupId();await be.showPopup(e=>ke.appStateController.setCurrentPopupId(e),e)}finally{we=!1}}}const Ze=async()=>{if(ke){ke.metaMetricsController.updateTraits({[g.MetaMetricsUserTrait.InstallDateExt]:(new Date).toISOString().split("T")[0]});const e=await(0,O.getDeferredDeepLinkFromCookie)(),t={};return e&&(ke.appStateController.setDeferredDeepLink(e),t.install_source="deeplink",t.deeplink_path=e.referringLink),void ke.metaMetricsController.addEventBeforeMetricsOptIn({category:g.MetaMetricsEventCategory.App,event:g.MetaMetricsEventName.AppInstalled,properties:t})}setTimeout(async()=>{await Ze()},500)};a.default.runtime.onUpdateAvailable.addListener(async function(e){await Ie,s.default.info("An update is available",e?.version),ke.appStateController.setPendingExtensionVersion(e?.version??null)});(async()=>{if(a.default?.sidePanel)try{await Ie;const e=ke?.preferencesController?.state?.preferences?.useSidePanelAsDefault??!1;a.default?.sidePanel?.setPanelBehavior&&await a.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e})}catch(e){console.error("Error setting side panel behavior:",e)}})();(async()=>{if(a.default?.sidePanel)try{await Ie,ke?.controllerMessenger?.subscribe("PreferencesController:stateChange",e=>{const t=e?.preferences?.useSidePanelAsDefault??!1;a.default?.sidePanel?.setPanelBehavior&&a.default.sidePanel.setPanelBehavior({openPanelOnActionClick:t}).catch(e=>console.error("Error updating panel behavior:",e))})}catch(e){console.error("Error setting up preference listener:",e)}})();async function et(e){a.default.tabs.onActivated.addListener(e=>{if(ke){const{tabId:t}=e,r=Oe[t],n=Ae[t];r&&ke.permissionController.state.subjects[r]!==undefined&&Je(r);const o=(0,k.getPartnerByOrigin)(n);o&&ke.permissionController.state.subjects[n]!==undefined&&ke.handleDefiReferral(o,t,te.ReferralTriggerType.OnNavigateConnectedTab).catch(e=>{s.default.error(`Failed to handle ${o.name} referral after navigation to connected tab: `,e)})}});try{await Ke(e),n.persistenceManager.cleanUpMostRecentRetrievedState(),s.default.info("MetaMask initialization complete."),je()}catch(e){s.default.error(e),Re(e)}}(async()=>{await Ye()})(),a.default.tabs.onActivated.addListener(async({tabId:e})=>{if(await Ie,!ke)return{};try{const t=await a.default.tabs.get(e),{id:r,title:n,url:o,favIconUrl:i}=t;if(!o)return ke.appStateController.clearAppActiveTab(),{};const{origin:s,protocol:c,host:l,href:u}=new URL(o);if(!(0,F.isWebOrigin)(s))return ke.appStateController.clearAppActiveTab(),{};ke.appStateController.setAppActiveTab({id:r,title:n,origin:s,protocol:c,url:o,host:l,href:u,favIconUrl:i}),ke.subjectMetadataController.addSubjectMetadata({origin:s,name:n||l||s,iconUrl:i||null,subjectType:"website"})}catch(e){console.log("Error in tabs.onActivated listener:",e.message)}return{}}),a.default.tabs.onUpdated.addListener(async(e,t,r)=>{if(await Ie,!ke)return{};const n=t.url!==undefined,o="complete"===t.status;if(!n&&!o)return{};try{const t=r||await a.default.tabs.get(e),{id:i,title:s,url:c,favIconUrl:l}=t,u=ke.appStateController.state.appActiveTab,f=u?.id===i;if(!c)return f&&ke.appStateController.clearAppActiveTab(),{};const{origin:d,protocol:p,host:h,href:m}=new URL(c);if(!d||"null"===d||d.startsWith("chrome-extension://")||d.startsWith("moz-extension://"))return f&&ke.appStateController.clearAppActiveTab(),{};let g=!1;try{g=(await a.default.tabs.query({active:!0,currentWindow:!0})).some(e=>e.id===i)}catch(e){g=f}(n||o)&&g&&(ke.appStateController.setAppActiveTab({id:i,title:s,origin:d,protocol:p,url:c,host:h,href:m,favIconUrl:l}),ke.subjectMetadataController.addSubjectMetadata({origin:d,name:s||h||d,iconUrl:l||null,subjectType:"website"}))}catch(e){console.log("Error in tabs.onUpdated listener:",e.message)}return{}}),et(null)}}},{package:"$root$",file:"app/scripts/background.js"}]],[10],{});