LavaPack.loadBundle([[960,{_process:7245},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=N,r=P){const n=t*Math.pow(r,e),o=Math.round(I*n*(Math.random()-.5)*2);return Math.min(k,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 O(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],a=r[i];if(T(n)&&T(a)){if(!e(n,a))return!1}else if(n!==a)return!1}for(const e of o)if(!n.includes(e))return!1;return!0},r.deepExtend=f,r.errorPrefix=A,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=S,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(A(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(A(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(A(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},a=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,a=i?e[t+1]:0,s=t+2<e.length,l=s?e[t+2]:0,c=o>>2,u=(3&o)<<4|a>>4;let f=(15&a)<<2|l>>6,d=63&l;s||(d=64,i||(f=64)),n.push(r[c],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++],a=e[r++];t[n++]=String.fromCharCode((15&o)<<12|(63&i)<<6|63&a)}}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 a=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==a||null==l)throw new s;const c=o<<2|i>>4;if(n.push(c),64!==a){const e=i<<4&240|a>>2;if(n.push(e),64!==l){const e=a<<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 s extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}r.DecodeBase64StringError=s;const l=function(e){const t=i(e);return a.encodeByteArray(t,!0)};r.base64Encode=l;const c=function(e){return l(e).replace(/\./g,"")};r.base64urlEncodeWithoutPadding=c;const u=function(e){try{return a.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 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,w.prototype.create)}}r.FirebaseError=E;class w{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(_,(e,r)=>{const n=t[r];return null!=n?String(n):`<${r}?>`})}(o,r):"Error",a=`${this.serviceName}: ${i} (${n}).`;return new E(n,a,r)}}r.ErrorFactory=w;const _=/\{\$([^}]+)}/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 S(e){return JSON.parse(e)}const M=function(e){let t={},r={},n={},o="";try{const i=e.split(".");t=S(u(i[0])||""),r=S(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 T(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],a=this.chain_[1],s=this.chain_[2],l=this.chain_[3],c=this.chain_[4];for(let e=0;e<80;e++){e<40?e<20?(n=l^a&(s^l),o=1518500249):(n=a^s^l,o=1859775393):e<60?(n=a&s|l&(a|s),o=2400959708):(n=a^s^l,o=3395469782);const t=(i<<5|i>>>27)+n+c+o+r[e]&4294967295;c=l,l=s,s=4294967295&(a<<30|a>>>2),a=i,i=t}this.chain_[0]=this.chain_[0]+i&4294967295,this.chain_[1]=this.chain_[1]+a&4294967295,this.chain_[2]=this.chain_[2]+s&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 O{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=C),n.error===undefined&&(n.error=C),n.complete===undefined&&(n.complete=C);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 C(){}
/**
 * @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 A(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 N=1e3,P=2,k=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"}],[961,{},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"}],[962,{"@json-schema-tools/reference-resolver":967,"@json-schema-tools/traverse":970,"fast-safe-stringify":6369},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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(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(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.NonStringRefError=void 0;var s=a(e("@json-schema-tools/traverse")),l=a(e("@json-schema-tools/reference-resolver")),c=a(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 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 a=i[o];l.default.protocolHandlerMap[a]=this.options.protocolHandlerMap[a]}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,a,c,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,a=t,i.label=1;case 1:return o<a.length?(c=a[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 d=l.default.resolve(c,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||"#"===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]=f(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=f(this.schema,this.refCache[this.schema.$ref]):(0,s.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,s.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"}],[963,{"./dereferencer":962},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"}],[964,{},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"}],[965,{"./errors":966,"isomorphic-fetch":6673},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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(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(a,s)}l((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./errors"),s=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,s.default)(e)];case 1:return t=n.sent(),[3,3];case 2:throw n.sent(),new a.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 a.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"}],[966,{},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 a=function(e){this.name="InvalidFileSystemPathError",this.message=["InvalidFileSystemPathError","The path was not resolvable: ".concat(e)].join("\n")};r.InvalidFileSystemPathError=a}}},{package:"@open-rpc/schema-utils-js>@json-schema-tools/reference-resolver",file:"node_modules/@json-schema-tools/reference-resolver/build/errors.js"}],[967,{"./default-protocol-handler-map":965,"./reference-resolver":968},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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(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(a,s)}l((n=n.apply(e,t||[])).next())})},i=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var s=a(e("./default-protocol-handler-map")),l=a(e("./reference-resolver")),c=n(n({},s.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"}],[968,{"./errors":966,"./resolve-pointer":969},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 a(e){try{l(n.next(e))}catch(e){i(e)}}function s(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(a,s)}l((n=n.apply(e,t||[])).next())})},o=this&&this.__generator||function(e,t){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0});var a=e("./errors"),s=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,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,s.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 a.NonJsonRefError({$ref:e},c.message);case 4:if(l!==undefined)return h=l,n&&(h=(0,s.default)(n,h)),[2,h];if(!1===e.includes("://"))throw new a.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,s.default)(n,h)),[2,h];o.label=7;case 7:return u++,[3,5];case 8:throw new a.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"}],[969,{"@json-schema-spec/json-pointer":961},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"}],[970,{},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("")},a=function(e,t){var r=t.find(function(t){return t===e});return r||!1},s=function(e,t){return void 0===t&&(t=1),e[e.length-t]};r.default=function e(t,l,c,u,f,d,p,h,m){void 0===c&&(c=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),c);if(0===u&&(p=[""]),"boolean"==typeof t||t instanceof Boolean)return!0===g.skipFirstMutation&&0===u?t:l(t,!1,i(p),s(d));var b=t;!1===g.mutable&&(b=n({},t)),d.push(b),!0===g.bfs&&(!1!==g.skipFirstMutation&&0===u||(b=l(b,!1,i(p),s(d,2)))),f.push(t),h.push([t,b]);var v=function(t,r){var n=a(t,f);return n?(m.push(n),!0===g.skipFirstMutation&&n===f[0]?l(t,!0,i(r),s(d)):h.find(function(e){var t=e[0];return n===t})[1]):e(t,l,c,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=a(t.items,f);if(y)if(m.push(y),!0===g.skipFirstMutation&&y===f[0])b.items=l(t.items,!0,i(p),s(d));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,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 w=t.properties,_={};Object.keys(t.properties).forEach(function(e){_[e]=v(w[e],o(o([],p,!0),["properties",e.toString()],!1))}),b.properties=_}if(t.patternProperties!==undefined){var S=t.patternProperties,M={};Object.keys(t.patternProperties).forEach(function(e){M[e]=v(S[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 T=-1!==m.indexOf(t);return d.pop(),l(b,T,i(p),s(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"}],[98,{"../util":189},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.createPendingNonceMiddleware=function({getPendingNonce:e}){return async({request:t,context:r,next:n})=>{const{method:o,params:i}=t;if("eth_getTransactionCount"!==o)return n();const[a,s]=i;return"pending"!==s?n():await e(a,r.get("networkClientId"))}},r.createPendingTxMiddleware=function({getPendingTransactionByHash:e}){return async({request:t,next:r})=>{const{method:o,params:i}=t;if("eth_getTransactionByHash"!==o)return r();const[a]=i,s=e(a);return s?(0,n.formatTxMetaForRpcResult)(s):r()}};var n=e("../util")}}},{package:"$root$",file:"app/scripts/lib/middleware/pending.ts"}],[99,{"../../../../shared/lib/stores/persistence-manager":8455,"@metamask/utils":4512,events:6349,loglevel:6962},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var n=s(e("events")),o=s(e("loglevel")),i=e("@metamask/utils"),a=e("../../../../shared/lib/stores/persistence-manager");function s(e){return e&&e.__esModule?e:{default:e}}class l extends n.default{constructor(e={}){super();const t=e.migrations||[];this.migrations=t.sort((e,t)=>e.version-t.version);const r=this.migrations.slice(-1)[0];this.defaultVersion=e.defaultVersion||r&&r.version||0}async migrateData(e=this.generateInitialState()){const t=(0,i.isObject)(e.data)&&e.meta.version<186?new Set(Object.keys(e.data)):new Set;let r=e;for(const e of this.migrations)if(a(e))try{let n;if(o.default.info(`Running migration ${e.version}...`),e.version<186)n=await e.migrate(r),s(n,e);else{n=structuredClone(r);const i=new Set,a=await e.migrate(n,i);if(s(n,e),void 0!==a)throw new Error("Migrator - migration returned value when none expected");if(0===i.size)o.default.debug(`Migrator - migration ${e.version} did not report any changes`);else for(const e of i)t.add(e)}r=n,o.default.info(`Migration ${e.version} complete`)}catch(t){const r=new AggregateError([t],`MetaMask Migration Error #${e.version}`);this.emit("error",r);break}const n=e.meta.version<186&&(0,i.isObject)(r.data)?new Set(Object.keys(r.data)):new Set;for(const e of t)n.add(e);return{state:r,changedKeys:n};function a(e){return e.version>r.meta.version}function s(e,t){if(!e.data)throw new Error("Migrator - migration returned empty data");if(e.version!==undefined&&e.meta.version!==t.version)throw new Error("Migrator - Migration did not update version number correctly")}}generateInitialState(e){return{data:e,meta:{storageKind:a.PersistenceManager.defaultStorageKind,version:this.defaultVersion}}}}r.default=l}}},{package:"$root$",file:"app/scripts/lib/migrator/index.js"}],[9,{"../../shared/constants/app":8268,"../../shared/constants/app-state":8267,"../../shared/constants/defi-referrals":8275,"../../shared/constants/errors":8276,"../../shared/constants/infura-project-id":8281,"../../shared/constants/messages":8286,"../../shared/constants/metametrics":8287,"../../shared/constants/offscreen-communication":8293,"../../shared/constants/onboarding":8294,"../../shared/constants/start-up-errors":8307,"../../shared/constants/ui-initialization":8315,"../../shared/lib/browser-runtime.utils":8335,"../../shared/lib/caip-stream":8337,"../../shared/lib/deep-links/utils":8372,"../../shared/lib/fetch-with-timeout":8388,"../../shared/lib/get-first-preferred-lang-code":8402,"../../shared/lib/manifestFlags":8407,"../../shared/lib/mv3.utils":8416,"../../shared/lib/object.utils":8419,"../../shared/lib/promise-with-resolvers":8428,"../../shared/lib/selectors/networks":8437,"../../shared/lib/sentry":8441,"../../shared/lib/stores/persistence-manager":8455,"./constants/marketing-site-whitelist":10,"./constants/sentry-state":11,"./constants/snaps":12,"./constants/stream":13,"./first-time-state":50,"./lib/CronjobControllerStorageManager":54,"./lib/approval/utils":61,"./lib/createDefiReferralMiddleware":63,"./lib/critical-error/critical-error-recovery":77,"./lib/critical-error/critical-error-tab-handoff":78,"./lib/deep-links/deep-link-router":82,"./lib/deep-links/metrics":83,"./lib/ens-ipfs/setup":89,"./lib/extension-lazy-listener/extension-lazy-listener":90,"./lib/getIframeProperties":92,"./lib/getObjStructure":93,"./lib/migrator":99,"./lib/notification-manager":103,"./lib/repair":115,"./lib/safe-reload":132,"./lib/setup-initial-state-hooks":135,"./lib/start-up-errors/start-up-errors":147,"./lib/state-corruption/state-corruption-recovery":148,"./lib/stream-utils":151,"./lib/update-remote-feature-flags":187,"./lib/use-split-state-storage":188,"./lib/util":189,"./metamask-controller":412,"./migrations":652,"./offscreen":653,"./on-update":654,"./platforms/extension":655,"@metamask/base-controller":1710,"@metamask/design-tokens":2306,"@metamask/utils":4512,"extension-port-stream":6354,loglevel:6962,"readable-stream":7433,"webextension-polyfill":8255},function(){with(this.scopeTerminator)with(this.globalThis)return function(){"use strict";return function(e,t,r){Object.defineProperty(r,"__esModule",{value:!0}),r.loadStateFromPersistence=nt,r.setupController=lt;var n=e("./lib/setup-initial-state-hooks");e("../../shared/constants/infura-project-id");var o=e("@metamask/design-tokens"),i=e("readable-stream"),a=ce(e("loglevel")),s=ce(e("webextension-polyfill")),l=e("@metamask/utils"),c=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/app-state"),m=e("../../shared/constants/messages"),g=e("../../shared/constants/ui-initialization"),b=e("../../shared/constants/metametrics"),v=e("../../shared/lib/browser-runtime.utils"),y=e("../../shared/lib/mv3.utils"),E=e("../../shared/lib/object.utils"),w=(e("../../shared/constants/offscreen-communication"),e("../../shared/lib/sentry")),_=e("../../shared/lib/selectors/networks"),S=e("../../shared/lib/caip-stream"),M=ce(e("../../shared/lib/fetch-with-timeout")),T=e("../../shared/constants/errors"),O=ce(e("../../shared/lib/get-first-preferred-lang-code")),C=(e("../../shared/lib/manifestFlags"),e("../../shared/constants/start-up-errors")),A=e("../../shared/constants/defi-referrals"),N=e("../../shared/lib/deep-links/utils"),P=e("../../shared/lib/stores/persistence-manager"),k=e("./lib/critical-error/critical-error-recovery"),I=e("./lib/state-corruption/state-corruption-recovery"),j=e("./lib/approval/utils"),R=e("./lib/use-split-state-storage"),x=ce(e("./migrations")),D=ce(e("./lib/migrator")),L=e("./lib/update-remote-feature-flags"),U=ce(e("./platforms/extension")),$=e("./constants/sentry-state"),F=le(e("./lib/notification-manager")),B=le(e("./metamask-controller")),V=ce(e("./lib/getObjStructure")),K=ce(e("./lib/ens-ipfs/setup")),W=e("./lib/util"),z=e("./offscreen"),H=e("./lib/stream-utils"),G=ce(e("./first-time-state")),J=e("./on-update"),q=e("./constants/marketing-site-whitelist"),Y=e("./constants/stream"),X=e("./constants/snaps"),Q=e("./lib/extension-lazy-listener/extension-lazy-listener"),Z=e("./lib/deep-links/deep-link-router"),ee=e("./lib/deep-links/metrics"),te=e("./lib/safe-reload"),re=e("./lib/critical-error/critical-error-tab-handoff"),ne=e("./lib/repair"),oe=e("./lib/start-up-errors/start-up-errors"),ie=e("./lib/CronjobControllerStorageManager"),ae=e("./lib/createDefiReferralMiddleware"),se=e("./lib/getIframeProperties");function le(e,t){if("function"==typeof WeakMap)var r=new WeakMap,n=new WeakMap;return(le=function(e,t){if(!t&&e&&e.__esModule)return e;var o,i,a={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return a;if(o=t?n:r){if(o.has(e))return o.get(e);o.set(e,a)}for(const t in e)"default"!==t&&{}.hasOwnProperty.call(e,t)&&((i=(o=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(i.get||i.set)?o(a,t,i):a[t]=e[t]);return a})(e,t)}function ce(e){return e&&e.__esModule?e:{default:e}}const ue=globalThis.stateHooks.lazyListener??new Q.ExtensionLazyListener(s.default),fe="#0376C9",de=o.lightTheme.colors.error.default,pe=9,he=99,me=!1;const ge=null,{safePersist:be,requestSafeReload:ve,evacuate:ye}=(0,te.getRequestSafeReload)(n.persistenceManager);global.stateHooks.getMostRecentPersistedState=()=>n.persistenceManager.mostRecentRetrievedState,global.stateHooks.getStorageKind=()=>n.persistenceManager.storageKind,global.logEncryptedVault=()=>{n.persistenceManager.logEncryptedVault()};const{sentry:Ee}=global;let we={...G.default};const _e={[p.ENVIRONMENT_TYPE_POPUP]:!0,[p.ENVIRONMENT_TYPE_NOTIFICATION]:!0,[p.ENVIRONMENT_TYPE_FULLSCREEN]:!0},Se=["trezor-connect"];a.default.setLevel("info",!1);const Me=new U.default,Te=new F.default,Oe=(0,W.getPlatform)()===p.PLATFORM_FIREFOX;function Ce(e){const t=e.name,r=e.sender?.url?new URL(e.sender.url):null;let n;return n=Oe?Boolean(_e[t]):r?.origin===`chrome-extension://${s.default.runtime.id}`,{processName:t,senderUrl:r,isMetaMaskUIPort:n}}let Ae=0,Ne=!1,Pe=!1,ke=0,Ie=0;const je=new Set,Re={},xe={};let De;const Le={},Ue={},$e={};const Fe=new URL("https://metamask.github.io/phishing-warning/v5.1.0/"),Be=Fe.toString();let Ve,Ke,We;function ze(){const e=(0,f.withResolvers)();Ve=e.promise,Ke=e.resolve,We=e.reject}ue.once("runtime","onInstalled").then(e=>{!async function([e]){if("install"===e.reason)await async function(){a.default.debug("First install detected"),Me.openExtensionInBrowser();await ut()}();else if("update"===e.reason){const{previousVersion:t}=e;if(!t||t===Me.getVersion())return;await Ve,(0,J.onUpdate)(De,Me,t,ve)}}(e)}),ze(),s.default?.sidePanel?.setPanelBehavior&&s.default.sidePanel.setPanelBehavior({openPanelOnActionClick:!0}).catch(()=>{});let He,Ge,Je,qe;const Ye=new I.CorruptionHandler,Xe=new k.CriticalErrorHandler,Qe=async e=>{const{isMetaMaskUIPort:t}=Ce(e);try{e.postMessage({data:{method:g.BACKGROUND_LIVENESS_METHOD},name:"background-liveness"})}catch(e){return void a.default.error("MetaMask - background-liveness check: Failed to message to port",e)}let r;t&&(Xe.registerPortForCriticalError({port:e,repairCallback:()=>(0,ne.requestRepair)(()=>(0,re.openRestoringTabAndReload)(ve))}),r=()=>Xe.removeListenersForPort(e));try{if(await Ve,!(0,oe.tryPostMessage)(e,g.BACKGROUND_INITIALIZED_METHOD))return;me,He(e,r)}catch(o){try{if(Ee?.captureException(o),t)if((0,T.isStateCorruptionError)(o))await Ye.handleStateCorruptionError({port:e,error:o,database:n.persistenceManager,repairCallback:async e=>{ze(),(0,P.hasVault)(e)?(await ft(e),De.onboardingController.setFirstTimeFlowType(d.FirstTimeFlowType.restore)):(await n.persistenceManager.reset(),await ft(null))}});else{const t=(0,l.isObject)(o)?{message:o.message??"Unknown error",name:o.name??"UnknownError",stack:o.stack,...o.sentryTags&&{sentryTags:o.sentryTags}}:{message:String(o),name:"UnknownError",stack:""};(0,oe.tryPostMessage)(e,C.DISPLAY_GENERAL_STARTUP_ERROR,{error:t,currentLocale:De?.preferencesController?.state?.currentLocale})}}finally{r?.()}}},Ze=()=>{ue.addListener("runtime","onConnect",Qe)};function et(){const e=(new Date).toISOString();s.default.storage.session.set({timestamp:e})}async function tt(e){(0,W.initInstallType)();const t=y.isManifestV3?(0,z.createOffscreen)():null;let r=null,o=!1;y.isManifestV3&&(0,z.addOffscreenConnectivityListener)(e=>{if(o&&De.messengerClientApi.setConnectivityStatus){const t=e?"online":"offline";De.messengerClientApi.setConnectivityStatus(t)}else r=e});const i=await nt(e),a=i.data,l=await(0,O.default)();let c;if(y.isManifestV3){if(!1!==a.PreferencesController?.enableMV3TimestampSave){const e=2e3;et(),setInterval(et,e)}const e=await s.default.storage.session.get(["isFirstMetaMaskControllerSetup"]);c=e?.isFirstMetaMaskControllerSetup===undefined,await s.default.storage.session.set({isFirstMetaMaskControllerSetup:c})}const u={},f=await async function(){const e=(0,M.default)(),t=X.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 ie.CronjobControllerStorageManager;if(await d.init(),lt(a,l,u,c,i.meta,t,f,d),De.metaMetricsController.updateTraits({[b.MetaMetricsUserTrait.StorageKind]:n.persistenceManager.storageKind}),function(e){async function t(e,t){try{const r=await s.default.tabs.get(e);return!(r.url&&r.url.startsWith("https://www.google.com/search")||(await s.default.tabs.update(e,{url:t}),0))}catch(e){return Ee?.captureException(e),!1}}const r=!y.isManifestV3;s.default.webRequest.onBeforeRequest.addListener(n=>{if(n.tabId===s.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===Fe.host)return{};const{hostname:i,href:a,searchParams:l}=new URL(n.url);e.phishingController.maybeUpdateState();const c=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&&!c.result)return{};let d,p=a;u?.result&&c.result?f=`${u.type} and ${c.type}`:u?.result?f=u.type:(f=c.type,p=n.initiator);try{d=new URL(p).hostname}catch{d=i,p=a}const h=new URLSearchParams({hostname:d,href:p}),m=new URL(Be);m.hash=h.toString();const g=m.toString(),v=()=>{Oe||e.metaMetricsController.trackEvent({event:b.MetaMetricsEventName.PhishingPageDisplayed,category:b.MetaMetricsEventCategory.Phishing,properties:{url:p,referrer:{url:p},reason:f,requestDomain:c.result?i:undefined}},{excludeMetaMetricsId:!0})};return r?"main_frame"===n.type?(v(),{redirectUrl:g}):(t(n.tabId,g).then(e=>{e&&v()}),{cancel:!0}):(t(n.tabId,g).then(e=>{e&&v()}),{})},{urls:["http://*/*","https://*/*","ws://*/*","wss://*/*"]},r?["blocking"]:[])}(De),y.isManifestV3){if(o=!0,null!==r){const e=r?"online":"offline";De.messengerClientApi.setConnectivityStatus(e)}}else{const e=e=>{const t=e?"online":"offline";De.messengerClientApi.setConnectivityStatus(t)};e(globalThis.navigator.onLine),globalThis.addEventListener("online",()=>e(!0)),globalThis.addEventListener("offline",()=>e(!1))}y.isManifestV3||await async function(){let e;try{const t=new URL(Be);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 rt),1e3),await o}catch(e){e instanceof rt?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 s.default.tabs.query({url:"<all_urls>",windowType:"normal"}).then(e=>((0,v.checkForLastErrorAndLog)(),e)).catch(()=>{(0,v.checkForLastErrorAndLog)()});for(const t of e)s.default.tabs.sendMessage(t.id,{name:m.EXTENSION_MESSAGES.READY}).then(()=>{(0,v.checkForLastErrorAndLog)()}).catch(()=>{(0,v.checkForLastErrorAndLog)()})})(),new Z.DeepLinkRouter({getExtensionURL:Me.getExtensionURL,getState:De.getState.bind(De)}).on("navigate",async({url:e,parsed:t})=>{"redirectTo"in t||await De.metaMetricsController.trackEvent((0,ee.createEvent)({signature:t.signature,url:e}))}).on("error",e=>Ee?.captureException(e)).install()}Ze(),s.default.runtime.onConnectExternal.addListener(async(...e)=>{await Ve,Ge(...e)});class rt extends Error{constructor(){super("Timeout failed")}}async function nt(e){let t;if(e){t={data:{},meta:{}};for(const r of P.backedUpStateKeys)(0,l.hasProperty)(e,r)&&(t.data[r]=e[r]);(0,l.hasProperty)(e,"meta")&&(0,l.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&&(a.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 D.default({migrations:x.default,defaultVersion:null});r.on("error",e=>{console.warn(e);const r=(0,V.default)(t);Ee?.captureException(e,{extra:{vaultStructure:r}})});let o=!1;t?.data||t?.meta||(o=!0,t=r.generateInitialState(we));const{state:i,changedKeys:s}=await r.migrateData(t),c=async r=>{const o=t?.meta?.version,a="number"==typeof o&&o>=157;let s=e?.AppMetadataController?.firstTimeInfo??i?.data?.AppMetadataController?.firstTimeInfo??i?.data?.firstTimeInfo??t?.data?.AppMetadataController?.firstTimeInfo??t?.data?.firstTimeInfo;if(!s)try{const e=await n.persistenceManager.getBackup();s=e?.AppMetadataController?.firstTimeInfo}catch{}const l=new Error(r);return l.sentryTags={"corruption.preMigrationVersion":String(o??"unknown"),"corruption.backupShouldExist":String(a),"corruption.installVersion":String(s?.version??"unknown"),"corruption.installDate":String(s?.date??"unknown")},l};if(!i)throw await c("MetaMask - migrator returned undefined");if(!(0,l.isObject)(i.meta))throw await c(`MetaMask - migrator metadata has invalid type '${typeof i.meta}'`);if("number"!=typeof i.meta.version)throw await c(`MetaMask - migrator metadata version has invalid type '${typeof i.meta.version}'`);if(!["data","split",undefined].includes(i.meta.storageKind))throw await c(`MetaMask - migrator metadata storageKind has invalid value '${i.meta.storageKind}'`);if(!(0,l.isObject)(i.data))throw await c(`MetaMask - migrator data has invalid type '${typeof i.data}'`);if(n.persistenceManager.setMetadata(i.meta),a.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,R.useSplitStateStorage)(i.data);a.default.debug("[Split State]: shouldUseSplitStateStorage: %s (alreadyTried: %s)",t,e),t&&(i.meta.platformSplitStateGradualRolloutAttempted=!0,n.persistenceManager.setMetadata(i.meta)),a.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 s)n.persistenceManager.update(e,i.data[e]);await n.persistenceManager.persist()}return a.default.debug("[Split State]: Load complete."),i}function ot(e,t,r){const{metaMetricsId:n}=De.metaMetricsController.state;if(!(0,W.shouldEmitDappViewedEvent)(n))return;const o=De.getPermittedAccounts(e).length;if(0===o)return;const i=De.controllerMessenger.call("AccountsController:getState"),a=Object.keys(i.internalAccounts.accounts).length,s=(0,se.getIframeProperties)({frameId:r,origin:e,mainFrameOrigin:t});De.metaMetricsController.trackEvent({event:b.MetaMetricsEventName.DappViewed,category:b.MetaMetricsEventCategory.InpageProvider,referrer:{url:e},properties:{is_first_visit:!1,number_of_accounts:a,number_of_accounts_connected:o,...s}},{excludeMetaMetricsId:!0})}function it(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,{frameId:a}=e.sender;Object.keys(Le).includes(t)||(Le[t]=n),t in Ue||(Ue[t]=i),t in $e||($e[t]=a);const s=De.controllerMessenger.call("PermissionController:hasPermissions",n),l="New Tab"!==e.sender.tab.title;s&&l&&ot(n,i,a)}function at(e){const t=[p.ENVIRONMENT_TYPE_POPUP,p.ENVIRONMENT_TYPE_NOTIFICATION,p.ENVIRONMENT_TYPE_FULLSCREEN,p.ENVIRONMENT_TYPE_SIDEPANEL];!(Object.values(Re).some(Boolean)||Ne||Ae>0||ke>0)&&t.includes(e)&&function(e){const{metaMetricsId:t,participateInMetaMetrics:r}=De.metaMetricsController.state;(null!==t||r)&&De.metaMetricsController.trackEvent({event:b.MetaMetricsEventName.AppOpened,category:b.MetaMetricsEventCategory.App,environmentType:e})}(e)}const st=async e=>{if(await Ve,De)try{const t=e?{active:!0,windowId:e}:{active:!0,currentWindow:!0},r=await s.default.tabs.query(t);if(!r||0===r.length)return;const n=r[0],{id:o,title:i,url:a,favIconUrl:l}=n;if(!a)return void De.appStateController.clearAppActiveTab();const{origin:c,protocol:u,host:f,href:d}=new URL(a);if(!(0,W.isWebOrigin)(c))return void De.appStateController.clearAppActiveTab();De.appStateController.setAppActiveTab({id:o,title:i,origin:c,protocol:u,url:a,host:f,href:d,favIconUrl:l}),De.subjectMetadataController.addSubjectMetadata({origin:c,name:i||f||c,iconUrl:l||null,subjectType:"website"})}catch(e){console.log("Error refreshing appActiveTab:",e.message)}};function lt(e,t,r,o,l,f,d,m){De=new B.default({infuraProjectId:globalThis.INFURA_PROJECT_ID,showUserConfirmation:ct,initState:e,initLangCode:t,platform:Me,notificationManager:Te,browser:s.default,getRequestAccountTabIds:()=>xe,getOpenMetamaskTabsIds:()=>Re,overrides:r,isFirstMetaMaskControllerSetup:o,currentMigrationVersion:l.version,featureFlags:{},offscreenPromise:f,preinstalledSnaps:d,requestSafeReload:ve,cronjobControllerStorageManager:m}),n.persistenceManager.setOnSetFailed(e=>{De.appStateController.setStorageWriteErrorType(e)});const g=[],v=De.store.getState();for(const t of Object.keys(v)){const r=e[t]||{},n=v[t];if(null===n||"object"!=typeof n){(0,w.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]){g.push(t);break}}else g.push(t)}var M;"split"===n.persistenceManager.storageKind?(g.length>0&&(a.default.info(`MetaMaskController state changed during configuration for controllers: ${g.join(", ")}. Persisting updated state.`),g.forEach(e=>{n.persistenceManager.update(e,v[e])}),be().catch(e=>{a.default.error("Error persisting updated state:",e),Ee?.captureException(e)})),De.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=De.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=De.controllerMessenger.call(`${t}:getState`),i=(0,c.deriveStateFromMetadata)(o,r.metadata,"persist");n.persistenceManager.update(t,i)});try{await be()}catch(e){a.default.error("Error persisting state change:",e),Ee?.captureException(e)}})):(g.length>0&&(a.default.info(`MetaMaskController state changed during configuration for controllers: ${g.join(", ")}. Persisting updated state.`),be(v).catch(e=>{a.default.error("Error persisting updated controller state:",e),Ee?.captureException(e)})),De.store.on("update",be)),De.store.on("error",e=>{a.default.error("MetaMask controller.store error:",e),Ee?.captureException(e)}),(0,K.default)({getCurrentChainId:()=>(0,_.getCurrentChainId)({metamask:De.networkController.state}),getIpfsGateway:De.preferencesController.getIpfsGateway.bind(De.preferencesController),getUseAddressBarEnsResolution:()=>De.preferencesController.state.useAddressBarEnsResolution,provider:De.provider}),M=De,global.stateHooks.getSentryAppState=function(){const e=M.memStore.getState();return(0,E.maskObject)(e,$.SENTRY_BACKGROUND_STATE)};const T=()=>Ae>0||Boolean(Object.keys(Re).length)||Ne||ke>0||!1,O=()=>Ae>0||ke>0,C=()=>Ne&&!O(),A=(e,t)=>{if(!1===e)De.onClientClosed();else{if(t===p.ENVIRONMENT_TYPE_FULLSCREEN&&Boolean(Object.keys(Re).length)||t===p.ENVIRONMENT_TYPE_SIDEPANEL&&ke>0)return;De.onEnvironmentTypeClosed(t)}};function N(e){try{De.appStateController.setDefaultHomeActiveTabName(e??null)}catch(e){console.error("Error setting landing tab:",e)}}function k(){je.clear(),Ie=0,R()}function I(e,t){return e>t?`${t}+`:String(e)}function R(){const e=x();let t="",r=fe;Ie>0&&!C()?(t=I(Ie,pe),r=de):e>0&&(t=I(e,pe));try{const e={text:t},n={color:r};y.isManifestV3?(s.default.action.setBadgeText(e),s.default.action.setBadgeBackgroundColor(n)):(s.default.browserAction.setBadgeText(e),s.default.browserAction.setBadgeBackgroundColor(n))}catch(e){console.error("Error updating browser badge:",e)}}function x(){try{return De.appStateController.waitingForUnlock.length+(0,j.getAttentionRequiredApprovalCount)({approvalController:De.approvalController})}catch(e){return console.error("Failed to get pending approval count:",e),0}}He=(e,t)=>{if(Se.includes(e.name))return;const{processName:n,senderUrl:o,isMetaMaskUIPort:a}=Ce(e);if(a){const o=r?.getPortStream?.(e)||new u.ExtensionPortStream(e),a=function({chunkSize:e}){De.metaMetricsController.trackEvent({event:b.MetaMetricsEventName.PortStreamChunked,category:b.MetaMetricsEventCategory.PortStream,properties:{chunkSize:e}})};if(e.onDisconnect.addListener(()=>o.off("message-too-large",a)),o.on("message-too-large",a),De.isClientOpen=!0,De.setupTrustedCommunication(o,e.sender).finally(()=>{t?.()}),at(n),(0,L.updateRemoteFeatureFlags)(De),n===p.ENVIRONMENT_TYPE_POPUP&&(k(),Ae+=1,(0,i.finished)(o,()=>{Ae-=1;const e=T();De.isClientOpen=e,A(e,p.ENVIRONMENT_TYPE_POPUP)})),n===p.ENVIRONMENT_TYPE_SIDEPANEL&&(k(),ke+=1,st(),(0,i.finished)(o,()=>{ke=Math.max(ke-1,0);const e=T();De.isClientOpen=e,A(e,p.ENVIRONMENT_TYPE_SIDEPANEL)})),n===p.ENVIRONMENT_TYPE_NOTIFICATION&&(Ne=!0,(0,i.finished)(o,()=>{Ne=!1,Ie>0&&N(h.AccountOverviewTabKey.Activity),R();const e=T();De.isClientOpen=e,A(e,p.ENVIRONMENT_TYPE_NOTIFICATION)})),n===p.ENVIRONMENT_TYPE_FULLSCREEN){k();const t=e.sender.tab.id;Re[t]=!0,(0,i.finished)(o,()=>{delete Re[t];const e=T();De.isClientOpen=e,A(e,p.ENVIRONMENT_TYPE_FULLSCREEN)})}}else if(o&&o.origin===Fe.origin&&o.pathname===Fe.pathname){const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});De.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;it(e),e.onMessage.addListener(e=>{e.data&&e.data.method===p.MESSAGE_TYPE.ETH_REQUEST_ACCOUNTS&&(xe[n]=t)})}if(o&&q.COOKIE_ID_MARKETING_WHITELIST_ORIGINS.some(e=>e===o.origin)){const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});De.setUpCookieHandlerCommunication({connectionStream:t})}const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});if(Je(t,e.sender),Oe||!y.isManifestV3){const r=(0,H.setupMultiplex)(t);r.ignoreStream(Y.METAMASK_EIP_1193_PROVIDER),qe(r.createStream(Y.METAMASK_CAIP_MULTICHAIN_PROVIDER),e.sender)}}},Ge=e=>{const t=r?.getPortStream?.(e)||new u.ExtensionPortStream(e,{chunkSize:0});if(!e.sender.id){if(Se.includes(e.name))return;it(e),qe((0,S.createCaipStream)(t),e.sender)}else Je(t,e.sender)},Je=(e,t)=>{De.setupUntrustedCommunicationEip1193({connectionStream:e,sender:t})},qe=(e,t)=>{De.setupUntrustedCommunicationCaip({connectionStream:e,sender:t})},r?.registerConnectListeners&&r.registerConnectListeners(He,Je),R(),De.controllerMessenger.subscribe(B.METAMASK_CONTROLLER_EVENTS.DECRYPT_MESSAGE_MANAGER_UPDATE_BADGE,R),De.controllerMessenger.subscribe(B.METAMASK_CONTROLLER_EVENTS.ENCRYPTION_PUBLIC_KEY_MANAGER_UPDATE_BADGE,R),De.signatureController.hub.on(B.METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,R),De.controllerMessenger.subscribe(B.METAMASK_CONTROLLER_EVENTS.APP_STATE_UNLOCK_CHANGE,R),De.controllerMessenger.subscribe(B.METAMASK_CONTROLLER_EVENTS.APPROVAL_STATE_CHANGE,R),De.controllerMessenger.subscribe(B.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_LIST_UPDATED,R),De.controllerMessenger.subscribe(B.METAMASK_CONTROLLER_EVENTS.METAMASK_NOTIFICATIONS_MARK_AS_READ,R),De.controllerMessenger.subscribe("TransactionController:transactionStatusUpdated",function({transactionMeta:e}){const{status:t,txParams:r,chainId:n}=e??{};if("failed"!==t&&"dropped"!==t)return;const{from:o,nonce:i}=r??{},a=o&&i!==undefined&&n?`${n}:${o.toLowerCase()}:${i}`:undefined;if(a&&je.has(a))return;if(O())return;a&&(je.size>=he&&je.clear(),je.add(a));Ie+=1,C()||N(h.AccountOverviewTabKey.Activity);R()}),Te.on(F.NOTIFICATION_MANAGER_EVENTS.POPUP_CLOSED,({automaticallyClosed:e})=>{e?x()>0&&ct():(De.signatureController.rejectUnapproved(b.REJECT_NOTIFICATION_CLOSE_SIG),De.decryptMessageController.rejectUnapproved(b.REJECT_NOTIFICATION_CLOSE),De.encryptionPublicKeyController.rejectUnapproved(b.REJECT_NOTIFICATION_CLOSE),De.rejectAllPendingApprovals()),R()})}async function ct(){const e=await Me.getActiveTabs(),t=Boolean(e.find(e=>Re[e.id])),r=e.length>0&&e[0].extData&&e[0].extData.indexOf("vivaldi_tab")>-1;if(!Pe&&(r||0===Ae)&&!t&&0===ke){Pe=!0;try{const e=De.appStateController.getCurrentPopupId();await Te.showPopup(e=>De.appStateController.setCurrentPopupId(e),e)}finally{Pe=!1}}}const ut=async()=>{if(De){De.metaMetricsController.updateTraits({[b.MetaMetricsUserTrait.InstallDateExt]:(new Date).toISOString().split("T")[0]});const e=await(0,N.getDeferredDeepLinkFromCookie)(),t={};return e&&(De.appStateController.setDeferredDeepLink(e),t.install_source="deeplink",t.deeplink_path=e.referringLink),void De.metaMetricsController.addEventBeforeMetricsOptIn({category:b.MetaMetricsEventCategory.App,event:b.MetaMetricsEventName.AppInstalled,properties:t})}setTimeout(async()=>{await ut()},500)};s.default.runtime.onUpdateAvailable.addListener(async function(e){await Ve,a.default.info("An update is available",e?.version),De.appStateController.setPendingExtensionVersion(e?.version??null)});(async()=>{if(s.default?.sidePanel)try{await Ve,await async function(){if(!s.default?.sidePanel?.setPanelBehavior)return;const e=De?.preferencesController?.state?.preferences?.useSidePanelAsDefault??!0;await s.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e})}(),De?.controllerMessenger?.subscribe("PreferencesController:stateChange",e=>{s.default?.sidePanel?.setPanelBehavior&&s.default.sidePanel.setPanelBehavior({openPanelOnActionClick:e}).catch(e=>console.error("Error updating panel behavior:",e))},e=>e?.preferences?.useSidePanelAsDefault??!0)}catch(e){console.error("Error setting side panel toolbar behavior:",e)}})();async function ft(e){s.default.tabs.onActivated.addListener(e=>{if(De){const{tabId:t}=e,r=Le[t],n=Ue[t];r&&De.permissionController.state.subjects[r]!==undefined&&ot(r,n,$e[t]);const o=(0,A.getPartnerByOrigin)(n);o&&De.permissionController.state.subjects[n]!==undefined&&De.handleDefiReferral(o,t,ae.ReferralTriggerType.OnNavigateConnectedTab).catch(e=>{a.default.error(`Failed to handle ${o.name} referral after navigation to connected tab: `,e)})}});try{await tt(e),n.persistenceManager.cleanUpMostRecentRetrievedState(),a.default.info("MetaMask initialization complete."),Ke()}catch(e){a.default.error(e),We(e)}}(async()=>{await st()})(),s.default.tabs.onActivated.addListener(async({tabId:e})=>{if(await Ve,!De)return{};try{const t=await s.default.tabs.get(e),{id:r,title:n,url:o,favIconUrl:i}=t;if(!o)return De.appStateController.clearAppActiveTab(),{};const{origin:a,protocol:l,host:c,href:u}=new URL(o);if(!(0,W.isWebOrigin)(a))return De.appStateController.clearAppActiveTab(),{};De.appStateController.setAppActiveTab({id:r,title:n,origin:a,protocol:l,url:o,host:c,href:u,favIconUrl:i}),De.subjectMetadataController.addSubjectMetadata({origin:a,name:n||c||a,iconUrl:i||null,subjectType:"website"})}catch(e){console.log("Error in tabs.onActivated listener:",e.message)}return{}}),s.default.tabs.onUpdated.addListener(async(e,t,r)=>{if(await Ve,!De)return{};const n=t.url!==undefined,o="complete"===t.status;if(!n&&!o)return{};try{const t=r||await s.default.tabs.get(e),{id:i,title:a,url:l,favIconUrl:c}=t,u=De.appStateController.state.appActiveTab,f=u?.id===i;if(!l)return f&&De.appStateController.clearAppActiveTab(),{};const{origin:d,protocol:p,host:h,href:m}=new URL(l);if(!d||"null"===d||d.startsWith("chrome-extension://")||d.startsWith("moz-extension://"))return f&&De.appStateController.clearAppActiveTab(),{};let g=!1;try{g=(await s.default.tabs.query({active:!0,currentWindow:!0})).some(e=>e.id===i)}catch(e){g=f}(n||o)&&g&&(De.appStateController.setAppActiveTab({id:i,title:a,origin:d,protocol:p,url:l,host:h,href:m,favIconUrl:c}),De.subjectMetadataController.addSubjectMetadata({origin:d,name:a||h||d,iconUrl:c||null,subjectType:"website"}))}catch(e){console.log("Error in tabs.onUpdated listener:",e.message)}return{}}),s.default.windows.onFocusChanged.addListener(async e=>{e!==s.default.windows.WINDOW_ID_NONE&&await st(e)}),async function(){const e=await(0,re.readCriticalErrorRestoreSession)(s.default),t=undefined;let r=null;(e||t?.simulateBackgroundStateSyncHang||t?.simulateBackgroundInitializationHang)&&(r=await n.persistenceManager.getBackup().catch(()=>null));const o=(0,P.hasVault)(r);if((t?.simulateBackgroundStateSyncHang||t?.simulateBackgroundInitializationHang)&&ge&&(ge.hasVaultAtStartup=o?Date.now():null),e&&(await(0,re.clearCriticalErrorRestoreSession)(s.default),o)){ge&&(ge.restoreInProgress=!0);const t={tabId:e.tabId,tabUrl:e.tabUrl};ft(r);try{await Ve}catch(e){return void a.default.error("critical-error-restore: initialization failed",e)}return De.onboardingController.setFirstTimeFlowType(d.FirstTimeFlowType.restore),void await(0,re.handoffRestoringTabToExtension)(Me,t)}ft(null)}().catch(e=>{a.default.error("initOrRestoreBackground failed",e)})}}},{package:"$root$",file:"app/scripts/background.js"}]],[9],{});